auto-sync: 2026-05-06 10:20:01
This commit is contained in:
112
tasks/enduro-trails/prototype/deploy-ruler-fix.js
vendored
Normal file
112
tasks/enduro-trails/prototype/deploy-ruler-fix.js
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
const { Client } = require('ssh2');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const conn = new Client();
|
||||
|
||||
const config = {
|
||||
host: '82.22.50.71',
|
||||
username: 'slin',
|
||||
password: 'motoZ@yaz2010',
|
||||
readyTimeout: 30000
|
||||
};
|
||||
|
||||
const localAppJs = path.join(__dirname, 'static', 'app.js');
|
||||
const localIndexHtml = path.join(__dirname, 'static', 'index.html');
|
||||
const remoteDir = '/home/slin/enduro-trails/prototype/static/';
|
||||
const containerName = 'prototype-enduro-trails-1';
|
||||
|
||||
console.log('🔌 Connecting to server...');
|
||||
|
||||
conn.on('ready', () => {
|
||||
console.log('✅ Connected');
|
||||
|
||||
conn.sftp((err, sftp) => {
|
||||
if (err) {
|
||||
console.error('❌ SFTP error:', err);
|
||||
conn.end();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('📤 Uploading app.js...');
|
||||
const appJsStream = sftp.createWriteStream(remoteDir + 'app.js');
|
||||
fs.createReadStream(localAppJs).pipe(appJsStream);
|
||||
|
||||
appJsStream.on('close', () => {
|
||||
console.log('✅ app.js uploaded');
|
||||
|
||||
console.log('📤 Uploading index.html...');
|
||||
const indexStream = sftp.createWriteStream(remoteDir + 'index.html');
|
||||
fs.createReadStream(localIndexHtml).pipe(indexStream);
|
||||
|
||||
indexStream.on('close', () => {
|
||||
console.log('✅ index.html uploaded');
|
||||
|
||||
console.log('🔄 Copying files into container...');
|
||||
conn.exec(`docker cp ${remoteDir}app.js ${containerName}:/app/static/app.js && docker cp ${remoteDir}index.html ${containerName}:/app/static/index.html`, (err, stream) => {
|
||||
if (err) {
|
||||
console.error('❌ Docker cp error:', err);
|
||||
conn.end();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let output = '';
|
||||
stream.on('data', (data) => { output += data.toString(); });
|
||||
stream.stderr.on('data', (data) => { output += data.toString(); });
|
||||
|
||||
stream.on('close', (code) => {
|
||||
if (code !== 0) {
|
||||
console.error('❌ Docker cp failed:', output);
|
||||
conn.end();
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('✅ Files copied into container');
|
||||
|
||||
console.log('🔄 Restarting container...');
|
||||
conn.exec(`docker restart ${containerName}`, (err, stream) => {
|
||||
if (err) {
|
||||
console.error('❌ Restart error:', err);
|
||||
conn.end();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let restartOutput = '';
|
||||
stream.on('data', (data) => { restartOutput += data.toString(); });
|
||||
stream.stderr.on('data', (data) => { restartOutput += data.toString(); });
|
||||
|
||||
stream.on('close', (code) => {
|
||||
if (code !== 0) {
|
||||
console.error('❌ Restart failed:', restartOutput);
|
||||
conn.end();
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('✅ Container restarted');
|
||||
console.log('🎉 Deploy complete!');
|
||||
conn.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
indexStream.on('error', (err) => {
|
||||
console.error('❌ index.html upload error:', err);
|
||||
conn.end();
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
|
||||
appJsStream.on('error', (err) => {
|
||||
console.error('❌ app.js upload error:', err);
|
||||
conn.end();
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
conn.on('error', (err) => {
|
||||
console.error('❌ Connection error:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
conn.connect(config);
|
||||
61
tasks/enduro-trails/prototype/node_modules/.package-lock.json
generated
vendored
Normal file
61
tasks/enduro-trails/prototype/node_modules/.package-lock.json
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "prototype",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/asn1": {
|
||||
"version": "0.2.6",
|
||||
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz",
|
||||
"integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safer-buffer": "~2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bcrypt-pbkdf": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
|
||||
"integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"tweetnacl": "^0.14.3"
|
||||
}
|
||||
},
|
||||
"node_modules/nan": {
|
||||
"version": "2.26.2",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.26.2.tgz",
|
||||
"integrity": "sha512-0tTvBTYkt3tdGw22nrAy50x7gpbGCCFH3AFcyS5WiUu7Eu4vWlri1woE6qHBSfy11vksDqkiwjOnlR7WV8G1Hw==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ssh2": {
|
||||
"version": "1.17.0",
|
||||
"resolved": "https://registry.npmjs.org/ssh2/-/ssh2-1.17.0.tgz",
|
||||
"integrity": "sha512-wPldCk3asibAjQ/kziWQQt1Wh3PgDFpC0XpwclzKcdT1vql6KeYxf5LIt4nlFkUeR8WuphYMKqUA56X4rjbfgQ==",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"asn1": "^0.2.6",
|
||||
"bcrypt-pbkdf": "^1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.16.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"cpu-features": "~0.0.10",
|
||||
"nan": "^2.23.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tweetnacl": {
|
||||
"version": "0.14.5",
|
||||
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
|
||||
"integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==",
|
||||
"license": "Unlicense"
|
||||
}
|
||||
}
|
||||
}
|
||||
65
tasks/enduro-trails/prototype/node_modules/asn1/Jenkinsfile
generated
vendored
Normal file
65
tasks/enduro-trails/prototype/node_modules/asn1/Jenkinsfile
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
@Library('jenkins-joylib@v1.0.8') _
|
||||
|
||||
pipeline {
|
||||
|
||||
agent none
|
||||
|
||||
options {
|
||||
buildDiscarder(logRotator(numToKeepStr: '45'))
|
||||
timestamps()
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('top') {
|
||||
parallel {
|
||||
stage('v4-zone') {
|
||||
agent {
|
||||
label joyCommonLabels(image_ver: '15.4.1')
|
||||
}
|
||||
tools {
|
||||
nodejs 'sdcnode-v4-zone'
|
||||
}
|
||||
stages {
|
||||
stage('check') {
|
||||
steps{
|
||||
sh('make check')
|
||||
}
|
||||
}
|
||||
stage('test') {
|
||||
steps{
|
||||
sh('make test')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('v6-zone64') {
|
||||
agent {
|
||||
label joyCommonLabels(image_ver: '18.4.0')
|
||||
}
|
||||
tools {
|
||||
nodejs 'sdcnode-v6-zone64'
|
||||
}
|
||||
stages {
|
||||
stage('check') {
|
||||
steps{
|
||||
sh('make check')
|
||||
}
|
||||
}
|
||||
stage('test') {
|
||||
steps{
|
||||
sh('make test')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
joySlackNotifications()
|
||||
}
|
||||
}
|
||||
}
|
||||
19
tasks/enduro-trails/prototype/node_modules/asn1/LICENSE
generated
vendored
Normal file
19
tasks/enduro-trails/prototype/node_modules/asn1/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2011 Mark Cavage, 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
|
||||
50
tasks/enduro-trails/prototype/node_modules/asn1/README.md
generated
vendored
Normal file
50
tasks/enduro-trails/prototype/node_modules/asn1/README.md
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
node-asn1 is a library for encoding and decoding ASN.1 datatypes in pure JS.
|
||||
Currently BER encoding is supported; at some point I'll likely have to do DER.
|
||||
|
||||
## Usage
|
||||
|
||||
Mostly, if you're *actually* needing to read and write ASN.1, you probably don't
|
||||
need this readme to explain what and why. If you have no idea what ASN.1 is,
|
||||
see this: ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc
|
||||
|
||||
The source is pretty much self-explanatory, and has read/write methods for the
|
||||
common types out there.
|
||||
|
||||
### Decoding
|
||||
|
||||
The following reads an ASN.1 sequence with a boolean.
|
||||
|
||||
var Ber = require('asn1').Ber;
|
||||
|
||||
var reader = new Ber.Reader(Buffer.from([0x30, 0x03, 0x01, 0x01, 0xff]));
|
||||
|
||||
reader.readSequence();
|
||||
console.log('Sequence len: ' + reader.length);
|
||||
if (reader.peek() === Ber.Boolean)
|
||||
console.log(reader.readBoolean());
|
||||
|
||||
### Encoding
|
||||
|
||||
The following generates the same payload as above.
|
||||
|
||||
var Ber = require('asn1').Ber;
|
||||
|
||||
var writer = new Ber.Writer();
|
||||
|
||||
writer.startSequence();
|
||||
writer.writeBoolean(true);
|
||||
writer.endSequence();
|
||||
|
||||
console.log(writer.buffer);
|
||||
|
||||
## Installation
|
||||
|
||||
npm install asn1
|
||||
|
||||
## License
|
||||
|
||||
MIT.
|
||||
|
||||
## Bugs
|
||||
|
||||
See <https://github.com/joyent/node-asn1/issues>.
|
||||
13
tasks/enduro-trails/prototype/node_modules/asn1/lib/ber/errors.js
generated
vendored
Normal file
13
tasks/enduro-trails/prototype/node_modules/asn1/lib/ber/errors.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
newInvalidAsn1Error: function (msg) {
|
||||
var e = new Error();
|
||||
e.name = 'InvalidAsn1Error';
|
||||
e.message = msg || '';
|
||||
return e;
|
||||
}
|
||||
|
||||
};
|
||||
27
tasks/enduro-trails/prototype/node_modules/asn1/lib/ber/index.js
generated
vendored
Normal file
27
tasks/enduro-trails/prototype/node_modules/asn1/lib/ber/index.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
var errors = require('./errors');
|
||||
var types = require('./types');
|
||||
|
||||
var Reader = require('./reader');
|
||||
var Writer = require('./writer');
|
||||
|
||||
|
||||
// --- Exports
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reader: Reader,
|
||||
|
||||
Writer: Writer
|
||||
|
||||
};
|
||||
|
||||
for (var t in types) {
|
||||
if (types.hasOwnProperty(t))
|
||||
module.exports[t] = types[t];
|
||||
}
|
||||
for (var e in errors) {
|
||||
if (errors.hasOwnProperty(e))
|
||||
module.exports[e] = errors[e];
|
||||
}
|
||||
262
tasks/enduro-trails/prototype/node_modules/asn1/lib/ber/reader.js
generated
vendored
Normal file
262
tasks/enduro-trails/prototype/node_modules/asn1/lib/ber/reader.js
generated
vendored
Normal file
@@ -0,0 +1,262 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
var assert = require('assert');
|
||||
var Buffer = require('safer-buffer').Buffer;
|
||||
|
||||
var ASN1 = require('./types');
|
||||
var errors = require('./errors');
|
||||
|
||||
|
||||
// --- Globals
|
||||
|
||||
var newInvalidAsn1Error = errors.newInvalidAsn1Error;
|
||||
|
||||
|
||||
|
||||
// --- API
|
||||
|
||||
function Reader(data) {
|
||||
if (!data || !Buffer.isBuffer(data))
|
||||
throw new TypeError('data must be a node Buffer');
|
||||
|
||||
this._buf = data;
|
||||
this._size = data.length;
|
||||
|
||||
// These hold the "current" state
|
||||
this._len = 0;
|
||||
this._offset = 0;
|
||||
}
|
||||
|
||||
Object.defineProperty(Reader.prototype, 'length', {
|
||||
enumerable: true,
|
||||
get: function () { return (this._len); }
|
||||
});
|
||||
|
||||
Object.defineProperty(Reader.prototype, 'offset', {
|
||||
enumerable: true,
|
||||
get: function () { return (this._offset); }
|
||||
});
|
||||
|
||||
Object.defineProperty(Reader.prototype, 'remain', {
|
||||
get: function () { return (this._size - this._offset); }
|
||||
});
|
||||
|
||||
Object.defineProperty(Reader.prototype, 'buffer', {
|
||||
get: function () { return (this._buf.slice(this._offset)); }
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Reads a single byte and advances offset; you can pass in `true` to make this
|
||||
* a "peek" operation (i.e., get the byte, but don't advance the offset).
|
||||
*
|
||||
* @param {Boolean} peek true means don't move offset.
|
||||
* @return {Number} the next byte, null if not enough data.
|
||||
*/
|
||||
Reader.prototype.readByte = function (peek) {
|
||||
if (this._size - this._offset < 1)
|
||||
return null;
|
||||
|
||||
var b = this._buf[this._offset] & 0xff;
|
||||
|
||||
if (!peek)
|
||||
this._offset += 1;
|
||||
|
||||
return b;
|
||||
};
|
||||
|
||||
|
||||
Reader.prototype.peek = function () {
|
||||
return this.readByte(true);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Reads a (potentially) variable length off the BER buffer. This call is
|
||||
* not really meant to be called directly, as callers have to manipulate
|
||||
* the internal buffer afterwards.
|
||||
*
|
||||
* As a result of this call, you can call `Reader.length`, until the
|
||||
* next thing called that does a readLength.
|
||||
*
|
||||
* @return {Number} the amount of offset to advance the buffer.
|
||||
* @throws {InvalidAsn1Error} on bad ASN.1
|
||||
*/
|
||||
Reader.prototype.readLength = function (offset) {
|
||||
if (offset === undefined)
|
||||
offset = this._offset;
|
||||
|
||||
if (offset >= this._size)
|
||||
return null;
|
||||
|
||||
var lenB = this._buf[offset++] & 0xff;
|
||||
if (lenB === null)
|
||||
return null;
|
||||
|
||||
if ((lenB & 0x80) === 0x80) {
|
||||
lenB &= 0x7f;
|
||||
|
||||
if (lenB === 0)
|
||||
throw newInvalidAsn1Error('Indefinite length not supported');
|
||||
|
||||
if (lenB > 4)
|
||||
throw newInvalidAsn1Error('encoding too long');
|
||||
|
||||
if (this._size - offset < lenB)
|
||||
return null;
|
||||
|
||||
this._len = 0;
|
||||
for (var i = 0; i < lenB; i++)
|
||||
this._len = (this._len << 8) + (this._buf[offset++] & 0xff);
|
||||
|
||||
} else {
|
||||
// Wasn't a variable length
|
||||
this._len = lenB;
|
||||
}
|
||||
|
||||
return offset;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parses the next sequence in this BER buffer.
|
||||
*
|
||||
* To get the length of the sequence, call `Reader.length`.
|
||||
*
|
||||
* @return {Number} the sequence's tag.
|
||||
*/
|
||||
Reader.prototype.readSequence = function (tag) {
|
||||
var seq = this.peek();
|
||||
if (seq === null)
|
||||
return null;
|
||||
if (tag !== undefined && tag !== seq)
|
||||
throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
|
||||
': got 0x' + seq.toString(16));
|
||||
|
||||
var o = this.readLength(this._offset + 1); // stored in `length`
|
||||
if (o === null)
|
||||
return null;
|
||||
|
||||
this._offset = o;
|
||||
return seq;
|
||||
};
|
||||
|
||||
|
||||
Reader.prototype.readInt = function () {
|
||||
return this._readTag(ASN1.Integer);
|
||||
};
|
||||
|
||||
|
||||
Reader.prototype.readBoolean = function () {
|
||||
return (this._readTag(ASN1.Boolean) === 0 ? false : true);
|
||||
};
|
||||
|
||||
|
||||
Reader.prototype.readEnumeration = function () {
|
||||
return this._readTag(ASN1.Enumeration);
|
||||
};
|
||||
|
||||
|
||||
Reader.prototype.readString = function (tag, retbuf) {
|
||||
if (!tag)
|
||||
tag = ASN1.OctetString;
|
||||
|
||||
var b = this.peek();
|
||||
if (b === null)
|
||||
return null;
|
||||
|
||||
if (b !== tag)
|
||||
throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
|
||||
': got 0x' + b.toString(16));
|
||||
|
||||
var o = this.readLength(this._offset + 1); // stored in `length`
|
||||
|
||||
if (o === null)
|
||||
return null;
|
||||
|
||||
if (this.length > this._size - o)
|
||||
return null;
|
||||
|
||||
this._offset = o;
|
||||
|
||||
if (this.length === 0)
|
||||
return retbuf ? Buffer.alloc(0) : '';
|
||||
|
||||
var str = this._buf.slice(this._offset, this._offset + this.length);
|
||||
this._offset += this.length;
|
||||
|
||||
return retbuf ? str : str.toString('utf8');
|
||||
};
|
||||
|
||||
Reader.prototype.readOID = function (tag) {
|
||||
if (!tag)
|
||||
tag = ASN1.OID;
|
||||
|
||||
var b = this.readString(tag, true);
|
||||
if (b === null)
|
||||
return null;
|
||||
|
||||
var values = [];
|
||||
var value = 0;
|
||||
|
||||
for (var i = 0; i < b.length; i++) {
|
||||
var byte = b[i] & 0xff;
|
||||
|
||||
value <<= 7;
|
||||
value += byte & 0x7f;
|
||||
if ((byte & 0x80) === 0) {
|
||||
values.push(value);
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
value = values.shift();
|
||||
values.unshift(value % 40);
|
||||
values.unshift((value / 40) >> 0);
|
||||
|
||||
return values.join('.');
|
||||
};
|
||||
|
||||
|
||||
Reader.prototype._readTag = function (tag) {
|
||||
assert.ok(tag !== undefined);
|
||||
|
||||
var b = this.peek();
|
||||
|
||||
if (b === null)
|
||||
return null;
|
||||
|
||||
if (b !== tag)
|
||||
throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
|
||||
': got 0x' + b.toString(16));
|
||||
|
||||
var o = this.readLength(this._offset + 1); // stored in `length`
|
||||
if (o === null)
|
||||
return null;
|
||||
|
||||
if (this.length > 4)
|
||||
throw newInvalidAsn1Error('Integer too long: ' + this.length);
|
||||
|
||||
if (this.length > this._size - o)
|
||||
return null;
|
||||
this._offset = o;
|
||||
|
||||
var fb = this._buf[this._offset];
|
||||
var value = 0;
|
||||
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
value <<= 8;
|
||||
value |= (this._buf[this._offset++] & 0xff);
|
||||
}
|
||||
|
||||
if ((fb & 0x80) === 0x80 && i !== 4)
|
||||
value -= (1 << (i * 8));
|
||||
|
||||
return value >> 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// --- Exported API
|
||||
|
||||
module.exports = Reader;
|
||||
36
tasks/enduro-trails/prototype/node_modules/asn1/lib/ber/types.js
generated
vendored
Normal file
36
tasks/enduro-trails/prototype/node_modules/asn1/lib/ber/types.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
|
||||
module.exports = {
|
||||
EOC: 0,
|
||||
Boolean: 1,
|
||||
Integer: 2,
|
||||
BitString: 3,
|
||||
OctetString: 4,
|
||||
Null: 5,
|
||||
OID: 6,
|
||||
ObjectDescriptor: 7,
|
||||
External: 8,
|
||||
Real: 9, // float
|
||||
Enumeration: 10,
|
||||
PDV: 11,
|
||||
Utf8String: 12,
|
||||
RelativeOID: 13,
|
||||
Sequence: 16,
|
||||
Set: 17,
|
||||
NumericString: 18,
|
||||
PrintableString: 19,
|
||||
T61String: 20,
|
||||
VideotexString: 21,
|
||||
IA5String: 22,
|
||||
UTCTime: 23,
|
||||
GeneralizedTime: 24,
|
||||
GraphicString: 25,
|
||||
VisibleString: 26,
|
||||
GeneralString: 28,
|
||||
UniversalString: 29,
|
||||
CharacterString: 30,
|
||||
BMPString: 31,
|
||||
Constructor: 32,
|
||||
Context: 128
|
||||
};
|
||||
317
tasks/enduro-trails/prototype/node_modules/asn1/lib/ber/writer.js
generated
vendored
Normal file
317
tasks/enduro-trails/prototype/node_modules/asn1/lib/ber/writer.js
generated
vendored
Normal file
@@ -0,0 +1,317 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
var assert = require('assert');
|
||||
var Buffer = require('safer-buffer').Buffer;
|
||||
var ASN1 = require('./types');
|
||||
var errors = require('./errors');
|
||||
|
||||
|
||||
// --- Globals
|
||||
|
||||
var newInvalidAsn1Error = errors.newInvalidAsn1Error;
|
||||
|
||||
var DEFAULT_OPTS = {
|
||||
size: 1024,
|
||||
growthFactor: 8
|
||||
};
|
||||
|
||||
|
||||
// --- Helpers
|
||||
|
||||
function merge(from, to) {
|
||||
assert.ok(from);
|
||||
assert.equal(typeof (from), 'object');
|
||||
assert.ok(to);
|
||||
assert.equal(typeof (to), 'object');
|
||||
|
||||
var keys = Object.getOwnPropertyNames(from);
|
||||
keys.forEach(function (key) {
|
||||
if (to[key])
|
||||
return;
|
||||
|
||||
var value = Object.getOwnPropertyDescriptor(from, key);
|
||||
Object.defineProperty(to, key, value);
|
||||
});
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --- API
|
||||
|
||||
function Writer(options) {
|
||||
options = merge(DEFAULT_OPTS, options || {});
|
||||
|
||||
this._buf = Buffer.alloc(options.size || 1024);
|
||||
this._size = this._buf.length;
|
||||
this._offset = 0;
|
||||
this._options = options;
|
||||
|
||||
// A list of offsets in the buffer where we need to insert
|
||||
// sequence tag/len pairs.
|
||||
this._seq = [];
|
||||
}
|
||||
|
||||
Object.defineProperty(Writer.prototype, 'buffer', {
|
||||
get: function () {
|
||||
if (this._seq.length)
|
||||
throw newInvalidAsn1Error(this._seq.length + ' unended sequence(s)');
|
||||
|
||||
return (this._buf.slice(0, this._offset));
|
||||
}
|
||||
});
|
||||
|
||||
Writer.prototype.writeByte = function (b) {
|
||||
if (typeof (b) !== 'number')
|
||||
throw new TypeError('argument must be a Number');
|
||||
|
||||
this._ensure(1);
|
||||
this._buf[this._offset++] = b;
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeInt = function (i, tag) {
|
||||
if (typeof (i) !== 'number')
|
||||
throw new TypeError('argument must be a Number');
|
||||
if (typeof (tag) !== 'number')
|
||||
tag = ASN1.Integer;
|
||||
|
||||
var sz = 4;
|
||||
|
||||
while ((((i & 0xff800000) === 0) || ((i & 0xff800000) === 0xff800000 >> 0)) &&
|
||||
(sz > 1)) {
|
||||
sz--;
|
||||
i <<= 8;
|
||||
}
|
||||
|
||||
if (sz > 4)
|
||||
throw newInvalidAsn1Error('BER ints cannot be > 0xffffffff');
|
||||
|
||||
this._ensure(2 + sz);
|
||||
this._buf[this._offset++] = tag;
|
||||
this._buf[this._offset++] = sz;
|
||||
|
||||
while (sz-- > 0) {
|
||||
this._buf[this._offset++] = ((i & 0xff000000) >>> 24);
|
||||
i <<= 8;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeNull = function () {
|
||||
this.writeByte(ASN1.Null);
|
||||
this.writeByte(0x00);
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeEnumeration = function (i, tag) {
|
||||
if (typeof (i) !== 'number')
|
||||
throw new TypeError('argument must be a Number');
|
||||
if (typeof (tag) !== 'number')
|
||||
tag = ASN1.Enumeration;
|
||||
|
||||
return this.writeInt(i, tag);
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeBoolean = function (b, tag) {
|
||||
if (typeof (b) !== 'boolean')
|
||||
throw new TypeError('argument must be a Boolean');
|
||||
if (typeof (tag) !== 'number')
|
||||
tag = ASN1.Boolean;
|
||||
|
||||
this._ensure(3);
|
||||
this._buf[this._offset++] = tag;
|
||||
this._buf[this._offset++] = 0x01;
|
||||
this._buf[this._offset++] = b ? 0xff : 0x00;
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeString = function (s, tag) {
|
||||
if (typeof (s) !== 'string')
|
||||
throw new TypeError('argument must be a string (was: ' + typeof (s) + ')');
|
||||
if (typeof (tag) !== 'number')
|
||||
tag = ASN1.OctetString;
|
||||
|
||||
var len = Buffer.byteLength(s);
|
||||
this.writeByte(tag);
|
||||
this.writeLength(len);
|
||||
if (len) {
|
||||
this._ensure(len);
|
||||
this._buf.write(s, this._offset);
|
||||
this._offset += len;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeBuffer = function (buf, tag) {
|
||||
if (typeof (tag) !== 'number')
|
||||
throw new TypeError('tag must be a number');
|
||||
if (!Buffer.isBuffer(buf))
|
||||
throw new TypeError('argument must be a buffer');
|
||||
|
||||
this.writeByte(tag);
|
||||
this.writeLength(buf.length);
|
||||
this._ensure(buf.length);
|
||||
buf.copy(this._buf, this._offset, 0, buf.length);
|
||||
this._offset += buf.length;
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeStringArray = function (strings) {
|
||||
if ((!strings instanceof Array))
|
||||
throw new TypeError('argument must be an Array[String]');
|
||||
|
||||
var self = this;
|
||||
strings.forEach(function (s) {
|
||||
self.writeString(s);
|
||||
});
|
||||
};
|
||||
|
||||
// This is really to solve DER cases, but whatever for now
|
||||
Writer.prototype.writeOID = function (s, tag) {
|
||||
if (typeof (s) !== 'string')
|
||||
throw new TypeError('argument must be a string');
|
||||
if (typeof (tag) !== 'number')
|
||||
tag = ASN1.OID;
|
||||
|
||||
if (!/^([0-9]+\.){3,}[0-9]+$/.test(s))
|
||||
throw new Error('argument is not a valid OID string');
|
||||
|
||||
function encodeOctet(bytes, octet) {
|
||||
if (octet < 128) {
|
||||
bytes.push(octet);
|
||||
} else if (octet < 16384) {
|
||||
bytes.push((octet >>> 7) | 0x80);
|
||||
bytes.push(octet & 0x7F);
|
||||
} else if (octet < 2097152) {
|
||||
bytes.push((octet >>> 14) | 0x80);
|
||||
bytes.push(((octet >>> 7) | 0x80) & 0xFF);
|
||||
bytes.push(octet & 0x7F);
|
||||
} else if (octet < 268435456) {
|
||||
bytes.push((octet >>> 21) | 0x80);
|
||||
bytes.push(((octet >>> 14) | 0x80) & 0xFF);
|
||||
bytes.push(((octet >>> 7) | 0x80) & 0xFF);
|
||||
bytes.push(octet & 0x7F);
|
||||
} else {
|
||||
bytes.push(((octet >>> 28) | 0x80) & 0xFF);
|
||||
bytes.push(((octet >>> 21) | 0x80) & 0xFF);
|
||||
bytes.push(((octet >>> 14) | 0x80) & 0xFF);
|
||||
bytes.push(((octet >>> 7) | 0x80) & 0xFF);
|
||||
bytes.push(octet & 0x7F);
|
||||
}
|
||||
}
|
||||
|
||||
var tmp = s.split('.');
|
||||
var bytes = [];
|
||||
bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10));
|
||||
tmp.slice(2).forEach(function (b) {
|
||||
encodeOctet(bytes, parseInt(b, 10));
|
||||
});
|
||||
|
||||
var self = this;
|
||||
this._ensure(2 + bytes.length);
|
||||
this.writeByte(tag);
|
||||
this.writeLength(bytes.length);
|
||||
bytes.forEach(function (b) {
|
||||
self.writeByte(b);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.writeLength = function (len) {
|
||||
if (typeof (len) !== 'number')
|
||||
throw new TypeError('argument must be a Number');
|
||||
|
||||
this._ensure(4);
|
||||
|
||||
if (len <= 0x7f) {
|
||||
this._buf[this._offset++] = len;
|
||||
} else if (len <= 0xff) {
|
||||
this._buf[this._offset++] = 0x81;
|
||||
this._buf[this._offset++] = len;
|
||||
} else if (len <= 0xffff) {
|
||||
this._buf[this._offset++] = 0x82;
|
||||
this._buf[this._offset++] = len >> 8;
|
||||
this._buf[this._offset++] = len;
|
||||
} else if (len <= 0xffffff) {
|
||||
this._buf[this._offset++] = 0x83;
|
||||
this._buf[this._offset++] = len >> 16;
|
||||
this._buf[this._offset++] = len >> 8;
|
||||
this._buf[this._offset++] = len;
|
||||
} else {
|
||||
throw newInvalidAsn1Error('Length too long (> 4 bytes)');
|
||||
}
|
||||
};
|
||||
|
||||
Writer.prototype.startSequence = function (tag) {
|
||||
if (typeof (tag) !== 'number')
|
||||
tag = ASN1.Sequence | ASN1.Constructor;
|
||||
|
||||
this.writeByte(tag);
|
||||
this._seq.push(this._offset);
|
||||
this._ensure(3);
|
||||
this._offset += 3;
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype.endSequence = function () {
|
||||
var seq = this._seq.pop();
|
||||
var start = seq + 3;
|
||||
var len = this._offset - start;
|
||||
|
||||
if (len <= 0x7f) {
|
||||
this._shift(start, len, -2);
|
||||
this._buf[seq] = len;
|
||||
} else if (len <= 0xff) {
|
||||
this._shift(start, len, -1);
|
||||
this._buf[seq] = 0x81;
|
||||
this._buf[seq + 1] = len;
|
||||
} else if (len <= 0xffff) {
|
||||
this._buf[seq] = 0x82;
|
||||
this._buf[seq + 1] = len >> 8;
|
||||
this._buf[seq + 2] = len;
|
||||
} else if (len <= 0xffffff) {
|
||||
this._shift(start, len, 1);
|
||||
this._buf[seq] = 0x83;
|
||||
this._buf[seq + 1] = len >> 16;
|
||||
this._buf[seq + 2] = len >> 8;
|
||||
this._buf[seq + 3] = len;
|
||||
} else {
|
||||
throw newInvalidAsn1Error('Sequence too long');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Writer.prototype._shift = function (start, len, shift) {
|
||||
assert.ok(start !== undefined);
|
||||
assert.ok(len !== undefined);
|
||||
assert.ok(shift);
|
||||
|
||||
this._buf.copy(this._buf, start + shift, start, start + len);
|
||||
this._offset += shift;
|
||||
};
|
||||
|
||||
Writer.prototype._ensure = function (len) {
|
||||
assert.ok(len);
|
||||
|
||||
if (this._size - this._offset < len) {
|
||||
var sz = this._size * this._options.growthFactor;
|
||||
if (sz - this._offset < len)
|
||||
sz += len;
|
||||
|
||||
var buf = Buffer.alloc(sz);
|
||||
|
||||
this._buf.copy(buf, 0, 0, this._offset);
|
||||
this._buf = buf;
|
||||
this._size = sz;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// --- Exported API
|
||||
|
||||
module.exports = Writer;
|
||||
20
tasks/enduro-trails/prototype/node_modules/asn1/lib/index.js
generated
vendored
Normal file
20
tasks/enduro-trails/prototype/node_modules/asn1/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
|
||||
|
||||
// If you have no idea what ASN.1 or BER is, see this:
|
||||
// ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc
|
||||
|
||||
var Ber = require('./ber/index');
|
||||
|
||||
|
||||
|
||||
// --- Exported API
|
||||
|
||||
module.exports = {
|
||||
|
||||
Ber: Ber,
|
||||
|
||||
BerReader: Ber.Reader,
|
||||
|
||||
BerWriter: Ber.Writer
|
||||
|
||||
};
|
||||
31
tasks/enduro-trails/prototype/node_modules/asn1/package.json
generated
vendored
Normal file
31
tasks/enduro-trails/prototype/node_modules/asn1/package.json
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"author": "Joyent (joyent.com)",
|
||||
"contributors": [
|
||||
"Mark Cavage <mcavage@gmail.com>",
|
||||
"David Gwynne <loki@animata.net>",
|
||||
"Yunong Xiao <yunong@joyent.com>",
|
||||
"Alex Wilson <alex.wilson@joyent.com>"
|
||||
],
|
||||
"name": "asn1",
|
||||
"description": "Contains parsers and serializers for ASN.1 (currently BER only)",
|
||||
"version": "0.2.6",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/joyent/node-asn1.git"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"safer-buffer": "~2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "^0.3.6",
|
||||
"faucet": "0.0.1",
|
||||
"tape": "^3.5.0",
|
||||
"eslint": "2.13.1",
|
||||
"eslint-plugin-joyent": "~1.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "./node_modules/.bin/tape ./test/ber/*.test.js"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
13
tasks/enduro-trails/prototype/node_modules/bcrypt-pbkdf/CONTRIBUTING.md
generated
vendored
Normal file
13
tasks/enduro-trails/prototype/node_modules/bcrypt-pbkdf/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Contributing
|
||||
|
||||
This repository uses [cr.joyent.us](https://cr.joyent.us) (Gerrit) for new
|
||||
changes. Anyone can submit changes. To get started, see the [cr.joyent.us user
|
||||
guide](https://github.com/joyent/joyent-gerrit/blob/master/docs/user/README.md).
|
||||
This repo does not use GitHub pull requests.
|
||||
|
||||
See the [Joyent Engineering
|
||||
Guidelines](https://github.com/joyent/eng/blob/master/docs/index.md) for general
|
||||
best practices expected in this repository.
|
||||
|
||||
If you're changing something non-trivial or user-facing, you may want to submit
|
||||
an issue first.
|
||||
66
tasks/enduro-trails/prototype/node_modules/bcrypt-pbkdf/LICENSE
generated
vendored
Normal file
66
tasks/enduro-trails/prototype/node_modules/bcrypt-pbkdf/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
The Blowfish portions are under the following license:
|
||||
|
||||
Blowfish block cipher for OpenBSD
|
||||
Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
|
||||
All rights reserved.
|
||||
|
||||
Implementation advice by David Mazieres <dm@lcs.mit.edu>.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. 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.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
|
||||
|
||||
|
||||
The bcrypt_pbkdf portions are under the following license:
|
||||
|
||||
Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
|
||||
Performance improvements (Javascript-specific):
|
||||
|
||||
Copyright 2016, Joyent Inc
|
||||
Author: Alex Wilson <alex.wilson@joyent.com>
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
45
tasks/enduro-trails/prototype/node_modules/bcrypt-pbkdf/README.md
generated
vendored
Normal file
45
tasks/enduro-trails/prototype/node_modules/bcrypt-pbkdf/README.md
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
Port of the OpenBSD `bcrypt_pbkdf` function to pure Javascript. `npm`-ified
|
||||
version of [Devi Mandiri's port](https://github.com/devi/tmp/blob/master/js/bcrypt_pbkdf.js),
|
||||
with some minor performance improvements. The code is copied verbatim (and
|
||||
un-styled) from Devi's work.
|
||||
|
||||
This product includes software developed by Niels Provos.
|
||||
|
||||
## API
|
||||
|
||||
### `bcrypt_pbkdf.pbkdf(pass, passlen, salt, saltlen, key, keylen, rounds)`
|
||||
|
||||
Derive a cryptographic key of arbitrary length from a given password and salt,
|
||||
using the OpenBSD `bcrypt_pbkdf` function. This is a combination of Blowfish and
|
||||
SHA-512.
|
||||
|
||||
See [this article](http://www.tedunangst.com/flak/post/bcrypt-pbkdf) for
|
||||
further information.
|
||||
|
||||
Parameters:
|
||||
|
||||
* `pass`, a Uint8Array of length `passlen`
|
||||
* `passlen`, an integer Number
|
||||
* `salt`, a Uint8Array of length `saltlen`
|
||||
* `saltlen`, an integer Number
|
||||
* `key`, a Uint8Array of length `keylen`, will be filled with output
|
||||
* `keylen`, an integer Number
|
||||
* `rounds`, an integer Number, number of rounds of the PBKDF to run
|
||||
|
||||
### `bcrypt_pbkdf.hash(sha2pass, sha2salt, out)`
|
||||
|
||||
Calculate a Blowfish hash, given SHA2-512 output of a password and salt. Used as
|
||||
part of the inner round function in the PBKDF.
|
||||
|
||||
Parameters:
|
||||
|
||||
* `sha2pass`, a Uint8Array of length 64
|
||||
* `sha2salt`, a Uint8Array of length 64
|
||||
* `out`, a Uint8Array of length 32, will be filled with output
|
||||
|
||||
## License
|
||||
|
||||
This source form is a 1:1 port from the OpenBSD `blowfish.c` and `bcrypt_pbkdf.c`.
|
||||
As a result, it retains the original copyright and license. The two files are
|
||||
under slightly different (but compatible) licenses, and are here combined in
|
||||
one file. For each of the full license texts see `LICENSE`.
|
||||
556
tasks/enduro-trails/prototype/node_modules/bcrypt-pbkdf/index.js
generated
vendored
Normal file
556
tasks/enduro-trails/prototype/node_modules/bcrypt-pbkdf/index.js
generated
vendored
Normal file
@@ -0,0 +1,556 @@
|
||||
'use strict';
|
||||
|
||||
var crypto_hash_sha512 = require('tweetnacl').lowlevel.crypto_hash;
|
||||
|
||||
/*
|
||||
* This file is a 1:1 port from the OpenBSD blowfish.c and bcrypt_pbkdf.c. As a
|
||||
* result, it retains the original copyright and license. The two files are
|
||||
* under slightly different (but compatible) licenses, and are here combined in
|
||||
* one file.
|
||||
*
|
||||
* Credit for the actual porting work goes to:
|
||||
* Devi Mandiri <me@devi.web.id>
|
||||
*/
|
||||
|
||||
/*
|
||||
* The Blowfish portions are under the following license:
|
||||
*
|
||||
* Blowfish block cipher for OpenBSD
|
||||
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Implementation advice by David Mazieres <dm@lcs.mit.edu>.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The bcrypt_pbkdf portions are under the following license:
|
||||
*
|
||||
* Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Performance improvements (Javascript-specific):
|
||||
*
|
||||
* Copyright 2016, Joyent Inc
|
||||
* Author: Alex Wilson <alex.wilson@joyent.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
// Ported from OpenBSD bcrypt_pbkdf.c v1.9
|
||||
|
||||
var BLF_J = 0;
|
||||
|
||||
var Blowfish = function() {
|
||||
this.S = [
|
||||
new Uint32Array([
|
||||
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
|
||||
0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
|
||||
0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
|
||||
0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
|
||||
0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
|
||||
0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
|
||||
0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
|
||||
0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
|
||||
0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
|
||||
0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
|
||||
0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
|
||||
0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
|
||||
0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
|
||||
0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
|
||||
0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
|
||||
0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
|
||||
0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
|
||||
0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
|
||||
0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
|
||||
0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
|
||||
0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
|
||||
0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
|
||||
0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
|
||||
0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
|
||||
0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
|
||||
0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
|
||||
0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
|
||||
0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
|
||||
0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
|
||||
0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
|
||||
0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
|
||||
0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
|
||||
0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
|
||||
0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
|
||||
0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
|
||||
0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
|
||||
0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
|
||||
0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
|
||||
0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
|
||||
0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
|
||||
0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
|
||||
0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
|
||||
0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
|
||||
0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
|
||||
0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
|
||||
0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
|
||||
0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
|
||||
0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
|
||||
0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
|
||||
0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
|
||||
0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
|
||||
0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
|
||||
0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
|
||||
0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
|
||||
0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
|
||||
0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
|
||||
0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
|
||||
0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
|
||||
0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
|
||||
0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
|
||||
0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
|
||||
0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
|
||||
0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
|
||||
0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a]),
|
||||
new Uint32Array([
|
||||
0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
|
||||
0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
|
||||
0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
|
||||
0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
|
||||
0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
|
||||
0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
|
||||
0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
|
||||
0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
|
||||
0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
|
||||
0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
|
||||
0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
|
||||
0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
|
||||
0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
|
||||
0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
|
||||
0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
|
||||
0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
|
||||
0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
|
||||
0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
|
||||
0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
|
||||
0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
|
||||
0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
|
||||
0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
|
||||
0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
|
||||
0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
|
||||
0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
|
||||
0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
|
||||
0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
|
||||
0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
|
||||
0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
|
||||
0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
|
||||
0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
|
||||
0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
|
||||
0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
|
||||
0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
|
||||
0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
|
||||
0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
|
||||
0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
|
||||
0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
|
||||
0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
|
||||
0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
|
||||
0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
|
||||
0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
|
||||
0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
|
||||
0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
|
||||
0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
|
||||
0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
|
||||
0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
|
||||
0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
|
||||
0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
|
||||
0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
|
||||
0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
|
||||
0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
|
||||
0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
|
||||
0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
|
||||
0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
|
||||
0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
|
||||
0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
|
||||
0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
|
||||
0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
|
||||
0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
|
||||
0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
|
||||
0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
|
||||
0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
|
||||
0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7]),
|
||||
new Uint32Array([
|
||||
0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
|
||||
0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
|
||||
0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
|
||||
0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
|
||||
0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
|
||||
0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
|
||||
0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
|
||||
0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
|
||||
0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
|
||||
0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
|
||||
0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
|
||||
0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
|
||||
0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
|
||||
0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
|
||||
0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
|
||||
0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
|
||||
0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
|
||||
0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
|
||||
0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
|
||||
0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
|
||||
0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
|
||||
0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
|
||||
0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
|
||||
0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
|
||||
0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
|
||||
0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
|
||||
0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
|
||||
0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
|
||||
0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
|
||||
0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
|
||||
0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
|
||||
0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
|
||||
0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
|
||||
0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
|
||||
0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
|
||||
0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
|
||||
0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
|
||||
0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
|
||||
0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
|
||||
0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
|
||||
0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
|
||||
0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
|
||||
0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
|
||||
0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
|
||||
0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
|
||||
0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
|
||||
0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
|
||||
0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
|
||||
0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
|
||||
0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
|
||||
0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
|
||||
0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
|
||||
0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
|
||||
0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
|
||||
0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
|
||||
0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
|
||||
0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
|
||||
0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
|
||||
0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
|
||||
0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
|
||||
0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
|
||||
0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
|
||||
0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
|
||||
0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0]),
|
||||
new Uint32Array([
|
||||
0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
|
||||
0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
|
||||
0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
|
||||
0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
|
||||
0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
|
||||
0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
|
||||
0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
|
||||
0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
|
||||
0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
|
||||
0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
|
||||
0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
|
||||
0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
|
||||
0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
|
||||
0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
|
||||
0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
|
||||
0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
|
||||
0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
|
||||
0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
|
||||
0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
|
||||
0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
|
||||
0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
|
||||
0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
|
||||
0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
|
||||
0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
|
||||
0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
|
||||
0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
|
||||
0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
|
||||
0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
|
||||
0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
|
||||
0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
|
||||
0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
|
||||
0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
|
||||
0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
|
||||
0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
|
||||
0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
|
||||
0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
|
||||
0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
|
||||
0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
|
||||
0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
|
||||
0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
|
||||
0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
|
||||
0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
|
||||
0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
|
||||
0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
|
||||
0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
|
||||
0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
|
||||
0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
|
||||
0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
|
||||
0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
|
||||
0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
|
||||
0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
|
||||
0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
|
||||
0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
|
||||
0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
|
||||
0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
|
||||
0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
|
||||
0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
|
||||
0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
|
||||
0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
|
||||
0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
|
||||
0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
|
||||
0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
|
||||
0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
|
||||
0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6])
|
||||
];
|
||||
this.P = new Uint32Array([
|
||||
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
|
||||
0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
|
||||
0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
|
||||
0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
|
||||
0x9216d5d9, 0x8979fb1b]);
|
||||
};
|
||||
|
||||
function F(S, x8, i) {
|
||||
return (((S[0][x8[i+3]] +
|
||||
S[1][x8[i+2]]) ^
|
||||
S[2][x8[i+1]]) +
|
||||
S[3][x8[i]]);
|
||||
};
|
||||
|
||||
Blowfish.prototype.encipher = function(x, x8) {
|
||||
if (x8 === undefined) {
|
||||
x8 = new Uint8Array(x.buffer);
|
||||
if (x.byteOffset !== 0)
|
||||
x8 = x8.subarray(x.byteOffset);
|
||||
}
|
||||
x[0] ^= this.P[0];
|
||||
for (var i = 1; i < 16; i += 2) {
|
||||
x[1] ^= F(this.S, x8, 0) ^ this.P[i];
|
||||
x[0] ^= F(this.S, x8, 4) ^ this.P[i+1];
|
||||
}
|
||||
var t = x[0];
|
||||
x[0] = x[1] ^ this.P[17];
|
||||
x[1] = t;
|
||||
};
|
||||
|
||||
Blowfish.prototype.decipher = function(x) {
|
||||
var x8 = new Uint8Array(x.buffer);
|
||||
if (x.byteOffset !== 0)
|
||||
x8 = x8.subarray(x.byteOffset);
|
||||
x[0] ^= this.P[17];
|
||||
for (var i = 16; i > 0; i -= 2) {
|
||||
x[1] ^= F(this.S, x8, 0) ^ this.P[i];
|
||||
x[0] ^= F(this.S, x8, 4) ^ this.P[i-1];
|
||||
}
|
||||
var t = x[0];
|
||||
x[0] = x[1] ^ this.P[0];
|
||||
x[1] = t;
|
||||
};
|
||||
|
||||
function stream2word(data, databytes){
|
||||
var i, temp = 0;
|
||||
for (i = 0; i < 4; i++, BLF_J++) {
|
||||
if (BLF_J >= databytes) BLF_J = 0;
|
||||
temp = (temp << 8) | data[BLF_J];
|
||||
}
|
||||
return temp;
|
||||
};
|
||||
|
||||
Blowfish.prototype.expand0state = function(key, keybytes) {
|
||||
var d = new Uint32Array(2), i, k;
|
||||
var d8 = new Uint8Array(d.buffer);
|
||||
|
||||
for (i = 0, BLF_J = 0; i < 18; i++) {
|
||||
this.P[i] ^= stream2word(key, keybytes);
|
||||
}
|
||||
BLF_J = 0;
|
||||
|
||||
for (i = 0; i < 18; i += 2) {
|
||||
this.encipher(d, d8);
|
||||
this.P[i] = d[0];
|
||||
this.P[i+1] = d[1];
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (k = 0; k < 256; k += 2) {
|
||||
this.encipher(d, d8);
|
||||
this.S[i][k] = d[0];
|
||||
this.S[i][k+1] = d[1];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Blowfish.prototype.expandstate = function(data, databytes, key, keybytes) {
|
||||
var d = new Uint32Array(2), i, k;
|
||||
|
||||
for (i = 0, BLF_J = 0; i < 18; i++) {
|
||||
this.P[i] ^= stream2word(key, keybytes);
|
||||
}
|
||||
|
||||
for (i = 0, BLF_J = 0; i < 18; i += 2) {
|
||||
d[0] ^= stream2word(data, databytes);
|
||||
d[1] ^= stream2word(data, databytes);
|
||||
this.encipher(d);
|
||||
this.P[i] = d[0];
|
||||
this.P[i+1] = d[1];
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (k = 0; k < 256; k += 2) {
|
||||
d[0] ^= stream2word(data, databytes);
|
||||
d[1] ^= stream2word(data, databytes);
|
||||
this.encipher(d);
|
||||
this.S[i][k] = d[0];
|
||||
this.S[i][k+1] = d[1];
|
||||
}
|
||||
}
|
||||
BLF_J = 0;
|
||||
};
|
||||
|
||||
Blowfish.prototype.enc = function(data, blocks) {
|
||||
for (var i = 0; i < blocks; i++) {
|
||||
this.encipher(data.subarray(i*2));
|
||||
}
|
||||
};
|
||||
|
||||
Blowfish.prototype.dec = function(data, blocks) {
|
||||
for (var i = 0; i < blocks; i++) {
|
||||
this.decipher(data.subarray(i*2));
|
||||
}
|
||||
};
|
||||
|
||||
var BCRYPT_BLOCKS = 8,
|
||||
BCRYPT_HASHSIZE = 32;
|
||||
|
||||
function bcrypt_hash(sha2pass, sha2salt, out) {
|
||||
var state = new Blowfish(),
|
||||
cdata = new Uint32Array(BCRYPT_BLOCKS), i,
|
||||
ciphertext = new Uint8Array([79,120,121,99,104,114,111,109,97,116,105,
|
||||
99,66,108,111,119,102,105,115,104,83,119,97,116,68,121,110,97,109,
|
||||
105,116,101]); //"OxychromaticBlowfishSwatDynamite"
|
||||
|
||||
state.expandstate(sha2salt, 64, sha2pass, 64);
|
||||
for (i = 0; i < 64; i++) {
|
||||
state.expand0state(sha2salt, 64);
|
||||
state.expand0state(sha2pass, 64);
|
||||
}
|
||||
|
||||
for (i = 0; i < BCRYPT_BLOCKS; i++)
|
||||
cdata[i] = stream2word(ciphertext, ciphertext.byteLength);
|
||||
for (i = 0; i < 64; i++)
|
||||
state.enc(cdata, cdata.byteLength / 8);
|
||||
|
||||
for (i = 0; i < BCRYPT_BLOCKS; i++) {
|
||||
out[4*i+3] = cdata[i] >>> 24;
|
||||
out[4*i+2] = cdata[i] >>> 16;
|
||||
out[4*i+1] = cdata[i] >>> 8;
|
||||
out[4*i+0] = cdata[i];
|
||||
}
|
||||
};
|
||||
|
||||
function bcrypt_pbkdf(pass, passlen, salt, saltlen, key, keylen, rounds) {
|
||||
var sha2pass = new Uint8Array(64),
|
||||
sha2salt = new Uint8Array(64),
|
||||
out = new Uint8Array(BCRYPT_HASHSIZE),
|
||||
tmpout = new Uint8Array(BCRYPT_HASHSIZE),
|
||||
countsalt = new Uint8Array(saltlen+4),
|
||||
i, j, amt, stride, dest, count,
|
||||
origkeylen = keylen;
|
||||
|
||||
if (rounds < 1)
|
||||
return -1;
|
||||
if (passlen === 0 || saltlen === 0 || keylen === 0 ||
|
||||
keylen > (out.byteLength * out.byteLength) || saltlen > (1<<20))
|
||||
return -1;
|
||||
|
||||
stride = Math.floor((keylen + out.byteLength - 1) / out.byteLength);
|
||||
amt = Math.floor((keylen + stride - 1) / stride);
|
||||
|
||||
for (i = 0; i < saltlen; i++)
|
||||
countsalt[i] = salt[i];
|
||||
|
||||
crypto_hash_sha512(sha2pass, pass, passlen);
|
||||
|
||||
for (count = 1; keylen > 0; count++) {
|
||||
countsalt[saltlen+0] = count >>> 24;
|
||||
countsalt[saltlen+1] = count >>> 16;
|
||||
countsalt[saltlen+2] = count >>> 8;
|
||||
countsalt[saltlen+3] = count;
|
||||
|
||||
crypto_hash_sha512(sha2salt, countsalt, saltlen + 4);
|
||||
bcrypt_hash(sha2pass, sha2salt, tmpout);
|
||||
for (i = out.byteLength; i--;)
|
||||
out[i] = tmpout[i];
|
||||
|
||||
for (i = 1; i < rounds; i++) {
|
||||
crypto_hash_sha512(sha2salt, tmpout, tmpout.byteLength);
|
||||
bcrypt_hash(sha2pass, sha2salt, tmpout);
|
||||
for (j = 0; j < out.byteLength; j++)
|
||||
out[j] ^= tmpout[j];
|
||||
}
|
||||
|
||||
amt = Math.min(amt, keylen);
|
||||
for (i = 0; i < amt; i++) {
|
||||
dest = i * stride + (count - 1);
|
||||
if (dest >= origkeylen)
|
||||
break;
|
||||
key[dest] = out[i];
|
||||
}
|
||||
keylen -= i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
BLOCKS: BCRYPT_BLOCKS,
|
||||
HASHSIZE: BCRYPT_HASHSIZE,
|
||||
hash: bcrypt_hash,
|
||||
pbkdf: bcrypt_pbkdf
|
||||
};
|
||||
15
tasks/enduro-trails/prototype/node_modules/bcrypt-pbkdf/package.json
generated
vendored
Normal file
15
tasks/enduro-trails/prototype/node_modules/bcrypt-pbkdf/package.json
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "bcrypt-pbkdf",
|
||||
"version": "1.0.2",
|
||||
"description": "Port of the OpenBSD bcrypt_pbkdf function to pure JS",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/joyent/node-bcrypt-pbkdf.git"
|
||||
},
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"tweetnacl": "^0.14.3"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"license": "BSD-3-Clause"
|
||||
}
|
||||
52
tasks/enduro-trails/prototype/node_modules/nan/.github/workflows/ci.yml
generated
vendored
Normal file
52
tasks/enduro-trails/prototype/node_modules/nan/.github/workflows/ci.yml
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
|
||||
# https://github.com/actions/setup-node
|
||||
# https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
|
||||
|
||||
name: ci
|
||||
on:
|
||||
push:
|
||||
# branches: [main]
|
||||
pull_request:
|
||||
# branches: [main]
|
||||
workflow_dispatch:
|
||||
permissions:
|
||||
contents: read
|
||||
jobs:
|
||||
pre-commit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pre-commit/action@v3.0.1
|
||||
|
||||
ci:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node-version: [25.x, 24.x, 23.x, 22.x, 21.x, 20.x, 19.x, 18.x, 17.x, 16.x]
|
||||
os: [windows-latest]
|
||||
include:
|
||||
- node-version: lts/*
|
||||
os: macos-15-intel # macOS on Intel
|
||||
- node-version: lts/*
|
||||
os: macos-latest # macOS on arm64
|
||||
- node-version: lts/*
|
||||
os: ubuntu-latest # Linux on x64
|
||||
- node-version: lts/*
|
||||
os: ubuntu-24.04-arm # Linux on arm64
|
||||
- node-version: lts/*
|
||||
os: windows-2025
|
||||
- node-version: lts/*
|
||||
os: windows-11-arm # Windows on arm64
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm install
|
||||
# TODO: On Windows Node.js v11 these will fail but `make test` will succeed
|
||||
- if: matrix.node-version != '11.x'
|
||||
run: |
|
||||
npm run-script rebuild-tests
|
||||
npm test
|
||||
- run: make test
|
||||
8
tasks/enduro-trails/prototype/node_modules/nan/.pre-commit-config.yaml
generated
vendored
Normal file
8
tasks/enduro-trails/prototype/node_modules/nan/.pre-commit-config.yaml
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
repos:
|
||||
- repo: https://github.com/cpplint/cpplint
|
||||
rev: 2.0.0
|
||||
hooks:
|
||||
- id: cpplint
|
||||
args:
|
||||
- --filter=-whitespace/indent_namespace,-whitespace/parens
|
||||
- --linelength=88
|
||||
599
tasks/enduro-trails/prototype/node_modules/nan/CHANGELOG.md
generated
vendored
Normal file
599
tasks/enduro-trails/prototype/node_modules/nan/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,599 @@
|
||||
# NAN ChangeLog
|
||||
|
||||
**Version 2.26.2: current Node 25.8.1, Node 0.12: 0.12.18, Node 0.10: 0.10.48, iojs: 3.3.1**
|
||||
|
||||
### 2.26.2 Mar 18 2026
|
||||
- Bugfix: Fix nan_weak.h for V8 >= 14.2.194 (missing EmbedderDataTypeTag) (#1013) 794124c493555106eebaa3e82c0d6147d0213183
|
||||
|
||||
### 2.26.1 Mar 17 2026
|
||||
- Bugfix: remove unintended copy-pasted line (#1011) 0456abb33a3ce412b644c45fb8401776d2f647eb
|
||||
|
||||
### 2.26.0 Mar 17 2026
|
||||
- Feature: Add EmbedderDataTypeTag to SetAlignedPointerInInternalField and GetAlignedPointerFromInternalField for v8 >= 14 (#1010) fcc7b7d4698f9cd87c7dc08b431ab82bed1b3b8c
|
||||
|
||||
### 2.25.0 Jan 25 2026
|
||||
- Feature: Updating SetAccessor method to support v8 14.4 (#1007) 333d98942f1fe412a4dd859d6b1b0a9bef43c1f8
|
||||
|
||||
### 2.24.0 Dec 03 2025
|
||||
- Feature: Adding new Nan::TryEncode() wrapper for node::TryEncode() (#1005) fd5ff3f5ab3f5bb6bb6dd2d247f3eccd79227854
|
||||
|
||||
### 2.23.1 Nov 05 2025
|
||||
- Feature: Adding WriteUtf8V2() and SetPrototypeV2() methods to support v8 14.3 (#1004) 9e1106ab7b7036d262df7f430eee3bff33757e9a
|
||||
|
||||
### 2.23.0 Jul 10 2025
|
||||
|
||||
- Feature: Support Node 23 (#979) 59ab6d03d5d68554290ee9f34003cd90aa92c185
|
||||
|
||||
### 2.22.2 Feb 26 2025
|
||||
|
||||
- Bugfix: Fix version guard for `ScriptOrigin` constructors (#989) 053239d73702ac11fa0c3c438f85c1409f960f89
|
||||
|
||||
### 2.22.1 Feb 21 2025
|
||||
|
||||
- Build: Fix compatibility with Python >= 3.12 (#987) b5d90f15730b620fb6cc4fed079674740424539a
|
||||
|
||||
### 2.22.0 Oct 11 2024
|
||||
|
||||
- Feature: replace SetAccessor -> SetNativeDataProperty (#977) 6bd62c9a0004339d5d1e18a945c84929d0f6b808
|
||||
|
||||
### 2.21.0 Oct 10 2024
|
||||
|
||||
- Feature: Support for node version 20.17.0 (#976) a7df36eda8a7fe8581c00a18590f5e4faafca7ae
|
||||
|
||||
### 2.20.0 Jun 12 2024
|
||||
|
||||
- Feature: fix removal of v8::CopyablePersistent (#970) 5805ca5c4c2eef9a65316b68741e29f4825c511f
|
||||
|
||||
### 2.19.0 Mar 6 2024
|
||||
|
||||
- Feature: Fix builds for Electron 29 (#966) 1b630ddb3412cde35b64513662b440f9fd71e1ff
|
||||
|
||||
### 2.18.0 Sep 12 2023
|
||||
|
||||
- Feature: Cast v8::Object::GetInternalField() return value to v8::Value (#956) bdfee1788239f735b67fe6b46b1439da755e9b62
|
||||
|
||||
### 2.17.0 Oct 10 2022
|
||||
|
||||
- Feature: overload deprecated AccessorSignatures (#943) 7f9ceb80fbc45c9ba1a10e6591ccbef9e8dee6b4
|
||||
|
||||
### 2.16.0 May 25 2022
|
||||
|
||||
- Feature: Add support for Node 18 (#937) 16fa32231e2ccd89d2804b3f765319128b20c4ac
|
||||
|
||||
### 2.15.0 Aug 4 2021
|
||||
|
||||
- Feature: add ScriptOrigin (#918) d09debf9eeedcb7ca4073e84ffe5fbb455ecb709
|
||||
|
||||
### 2.14.2 Oct 13 2020
|
||||
|
||||
- Bugfix: fix gcc 8 function cast warning (#899) 35f0fab205574b2cbda04e6347c8b2db755e124f
|
||||
|
||||
### 2.14.1 Apr 21 2020
|
||||
|
||||
- Bugfix: use GetBackingStore() instead of GetContents() (#888) 2c023bd447661a61071da318b0ff4003c3858d39
|
||||
|
||||
### 2.14.0 May 16 2019
|
||||
|
||||
- Feature: Add missing methods to Nan::Maybe<T> (#852) 4e962489fb84a184035b9fa74f245f650249aca6
|
||||
|
||||
### 2.13.2 Mar 24 2019
|
||||
|
||||
- Bugfix: remove usage of deprecated `IsNearDeath` (#842) fbaf42252af279c3d867c6b193571f9711c39847
|
||||
|
||||
### 2.13.1 Mar 14 2019
|
||||
|
||||
- Bugfix: check V8 version directly instead of inferring from NMV (#840) 12f9df9f393285de8fb4a8cd01478dc4fe3b089d
|
||||
|
||||
### 2.13.0 Mar 13 2019
|
||||
|
||||
- Feature: add support for node master (#831) 113c0282072e7ff4f9dfc98b432fd894b798c2c
|
||||
|
||||
### 2.12.1 Dec 18 2018
|
||||
|
||||
- Bugfix: Fix build breakage with Node.js 10.0.0-10.9.0. (#833) 625e90e8fef8d39ffa7247250a76a100b2487474
|
||||
|
||||
### 2.12.0 Dec 16 2018
|
||||
|
||||
- Bugfix: Add scope.Escape() to Call() (#817) 2e5ed4fc3a8ac80a6ef1f2a55099ab3ac8800dc6
|
||||
- Bugfix: Fix Node.js v10.12.0 deprecation warnings. 509859cc23b1770376b56550a027840a2ce0f73d
|
||||
- Feature: Allow SetWeak() for non-object persistent handles. (#824) e6ef6a48e7e671fe3e4b7dddaa8912a3f8262ecd
|
||||
|
||||
### 2.11.1 Sep 29 2018
|
||||
|
||||
- Fix: adapt to V8 7.0 24a22c3b25eeeec2016c6ec239bdd6169e985447
|
||||
|
||||
### 2.11.0 Aug 25 2018
|
||||
|
||||
- Removal: remove `FunctionCallbackInfo::Callee` for nodejs `>= 10` 1a56c0a6efd4fac944cb46c30912a8e023bda7d4
|
||||
- Bugfix: Fix `AsyncProgressWorkerBase::WorkProgress` sends invalid data b0c764d1dab11e9f8b37ffb81e2560a4498aad5e
|
||||
- Feature: Introduce `GetCurrentEventLoop` b4911b0bb1f6d47d860e10ec014d941c51efac5e
|
||||
- Feature: Add `NAN_MODULE_WORKER_ENABLED` macro as a replacement for `NAN_MODULE` b058fb047d18a58250e66ae831444441c1f2ac7a
|
||||
|
||||
### 2.10.0 Mar 16 2018
|
||||
|
||||
- Deprecation: Deprecate `MakeCallback` 5e92b19a59e194241d6a658bd6ff7bfbda372950
|
||||
- Feature: add `Nan::Call` overload 4482e1242fe124d166fc1a5b2be3c1cc849fe452
|
||||
- Feature: add more `Nan::Call` overloads 8584e63e6d04c7d2eb8c4a664e4ef57d70bf672b
|
||||
- Feature: Fix deprecation warnings for Node 10 1caf258243b0602ed56922bde74f1c91b0cbcb6a
|
||||
|
||||
### 2.9.2 Feb 22 2018
|
||||
|
||||
- Bugfix: Bandaid for async hooks 212bd2f849be14ef1b02fc85010b053daa24252b
|
||||
|
||||
### 2.9.1 Feb 22 2018
|
||||
|
||||
- Bugfix: Avoid deprecation warnings in deprecated `Nan::Callback::operator()` 372b14d91289df4604b0f81780709708c45a9aa4
|
||||
- Bugfix: Avoid deprecation warnings in `Nan::JSON` 3bc294bce0b7d0a3ee4559926303e5ed4866fda2
|
||||
|
||||
### 2.9.0 Feb 22 2018
|
||||
|
||||
- Deprecation: Deprecate legacy `Callback::Call` 6dd5fa690af61ca3523004b433304c581b3ea309
|
||||
- Feature: introduce `AsyncResource` class 90c0a179c0d8cb5fd26f1a7d2b1d6231eb402d48o
|
||||
- Feature: Add context aware `Nan::Callback::Call` functions 7169e09fb088418b6e388222e88b4c13f07ebaee
|
||||
- Feature: Make `AsyncWorker` context aware 066ba21a6fb9e2b5230c9ed3a6fc51f1211736a4
|
||||
- Feature: add `Callback` overload to `Nan::Call` 5328daf66e202658c1dc0d916c3aaba99b3cc606
|
||||
- Bugfix: fix warning: suggest parentheses around `&&` within `||` b2bb63d68b8ae623a526b542764e1ac82319cb2c
|
||||
- Bugfix: Fix compilation on io.js 3 d06114dba0a522fb436f0c5f47b994210968cd7b
|
||||
|
||||
### 2.8.0 Nov 15 2017
|
||||
|
||||
- Deprecation: Deprecate `Nan::ForceSet` in favor of `Nan::DefineOwnProperty()` 95cbb976d6fbbba88ba0f86dd188223a8591b4e7
|
||||
- Feature: Add `Nan::AsyncProgressQueueWorker` a976636ecc2ef617d1b061ce4a6edf39923691cb
|
||||
- Feature: Add `Nan::DefineOwnProperty()` 95cbb976d6fbbba88ba0f86dd188223a8591b4e7
|
||||
- Bugfix: Fix compiling on io.js 1 & 2 82705a64503ce60c62e98df5bd02972bba090900
|
||||
- Bugfix: Use DefineOwnProperty instead of ForceSet 95cbb976d6fbbba88ba0f86dd188223a8591b4e7
|
||||
|
||||
### 2.7.0 Aug 30 2017
|
||||
|
||||
- Feature: Add `Nan::To<v8::Function>()` overload. b93280670c9f6da42ed4cf6cbf085ffdd87bd65b
|
||||
- Bugfix: Fix ternary in `Nan::MaybeLocal<T>::FromMaybe<S>()`. 79a26f7d362e756a9524e672a82c3d603b542867
|
||||
|
||||
### 2.6.2 Apr 12 2017
|
||||
|
||||
- Bugfix: Fix v8::JSON::Parse() deprecation warning. 87f6a3c65815fa062296a994cc863e2fa124867d
|
||||
|
||||
### 2.6.1 Apr 6 2017
|
||||
|
||||
- Bugfix: nan_json.h: fix build breakage in Node 6 ac8d47dc3c10bfbf3f15a6b951633120c0ee6d51
|
||||
|
||||
### 2.6.0 Apr 6 2017
|
||||
|
||||
- Feature: nan: add support for JSON::Parse & Stringify b533226c629cce70e1932a873bb6f849044a56c5
|
||||
|
||||
### 2.5.1 Jan 23 2017
|
||||
|
||||
- Bugfix: Fix disappearing handle for private value 6a80995694f162ef63dbc9948fbefd45d4485aa0
|
||||
- Bugfix: Add missing scopes a93b8bae6bc7d32a170db6e89228b7f60ee57112
|
||||
- Bugfix: Use string::data instead of string::front in NewOneByteString d5f920371e67e1f3b268295daee6e83af86b6e50
|
||||
|
||||
### 2.5.0 Dec 21 2016
|
||||
|
||||
- Feature: Support Private accessors a86255cb357e8ad8ccbf1f6a4a901c921e39a178
|
||||
- Bugfix: Abort in delete operators that shouldn't be called 0fe38215ff8581703967dfd26c12793feb960018
|
||||
|
||||
### 2.4.0 Jul 10 2016
|
||||
|
||||
- Feature: Rewrite Callback to add Callback::Reset c4cf44d61f8275cd5f7b0c911d7a806d4004f649
|
||||
- Feature: AsyncProgressWorker: add template types for .send 1242c9a11a7ed481c8f08ec06316385cacc513d0
|
||||
- Bugfix: Add constness to old Persistent comparison operators bd43cb9982c7639605d60fd073efe8cae165d9b2
|
||||
|
||||
### 2.3.5 May 31 2016
|
||||
|
||||
- Bugfix: Replace NAN_INLINE with 'inline' keyword. 71819d8725f822990f439479c9aba3b240804909
|
||||
|
||||
### 2.3.4 May 31 2016
|
||||
|
||||
- Bugfix: Remove V8 deprecation warnings 0592fb0a47f3a1c7763087ebea8e1138829f24f9
|
||||
- Bugfix: Fix new versions not to use WeakCallbackInfo::IsFirstPass 615c19d9e03d4be2049c10db0151edbc3b229246
|
||||
- Bugfix: Make ObjectWrap::handle() const d19af99595587fe7a26bd850af6595c2a7145afc
|
||||
- Bugfix: Fix compilation errors related to 0592fb0a47f3a1c7763087ebea8e1138829f24f9 e9191c525b94f652718325e28610a1adcf90fed8
|
||||
|
||||
### 2.3.3 May 4 2016
|
||||
|
||||
- Bugfix: Refactor SetMethod() to deal with v8::Templates (#566) b9083cf6d5de6ebe6bcb49c7502fbb7c0d9ddda8
|
||||
|
||||
### 2.3.2 Apr 27 2016
|
||||
|
||||
- Bugfix: Fix compilation on outdated versions due to Handle removal f8b7c875d04d425a41dfd4f3f8345bc3a11e6c52
|
||||
|
||||
### 2.3.1 Apr 27 2016
|
||||
|
||||
- Bugfix: Don't use deprecated v8::Template::Set() in SetMethod a90951e9ea70fa1b3836af4b925322919159100e
|
||||
|
||||
### 2.3.0 Apr 27 2016
|
||||
|
||||
- Feature: added Signal() for invoking async callbacks without sending data from AsyncProgressWorker d8adba45f20e077d00561b20199133620c990b38
|
||||
- Bugfix: Don't use deprecated v8::Template::Set() 00dacf0a4b86027415867fa7f1059acc499dcece
|
||||
|
||||
### 2.2.1 Mar 29 2016
|
||||
|
||||
- Bugfix: Use NewFromUnsigned in ReturnValue<T>::Set(uint32_t i) for pre_12 3a18f9bdce29826e0e4c217854bc476918241a58
|
||||
- Performance: Remove unneeeded nullptr checks b715ef44887931c94f0d1605b3b1a4156eebece9
|
||||
|
||||
### 2.2.0 Jan 9 2016
|
||||
|
||||
- Feature: Add Function::Call wrapper 4c157474dacf284d125c324177b45aa5dabc08c6
|
||||
- Feature: Rename GC*logueCallback to GCCallback for > 4.0 3603435109f981606d300eb88004ca101283acec
|
||||
- Bugfix: Fix Global::Pass for old versions 367e82a60fbaa52716232cc89db1cc3f685d77d9
|
||||
- Bugfix: Remove weird MaybeLocal wrapping of what already is a MaybeLocal 23b4590db10c2ba66aee2338aebe9751c4cb190b
|
||||
|
||||
### 2.1.0 Oct 8 2015
|
||||
|
||||
- Deprecation: Deprecate NanErrnoException in favor of ErrnoException 0af1ca4cf8b3f0f65ed31bc63a663ab3319da55c
|
||||
- Feature: added helper class for accessing contents of typedarrays 17b51294c801e534479d5463697a73462d0ca555
|
||||
- Feature: [Maybe types] Add MakeMaybe(...) 48d7b53d9702b0c7a060e69ea10fea8fb48d814d
|
||||
- Feature: new: allow utf16 string with length 66ac6e65c8ab9394ef588adfc59131b3b9d8347b
|
||||
- Feature: Introduce SetCallHandler and SetCallAsFunctionHandler 7764a9a115d60ba10dc24d86feb0fbc9b4f75537
|
||||
- Bugfix: Enable creating Locals from Globals under Node 0.10. 9bf9b8b190821af889790fdc18ace57257e4f9ff
|
||||
- Bugfix: Fix issue #462 where PropertyCallbackInfo data is not stored safely. 55f50adedd543098526c7b9f4fffd607d3f9861f
|
||||
|
||||
### 2.0.9 Sep 8 2015
|
||||
|
||||
- Bugfix: EscapableHandleScope in Nan::NewBuffer for Node 0.8 and 0.10 b1654d7
|
||||
|
||||
### 2.0.8 Aug 28 2015
|
||||
|
||||
- Work around duplicate linking bug in clang 11902da
|
||||
|
||||
### 2.0.7 Aug 26 2015
|
||||
|
||||
- Build: Repackage
|
||||
|
||||
### 2.0.6 Aug 26 2015
|
||||
|
||||
- Bugfix: Properly handle null callback in FunctionTemplate factory 6e99cb1
|
||||
- Bugfix: Remove unused static std::map instances 525bddc
|
||||
- Bugfix: Make better use of maybe versions of APIs bfba85b
|
||||
- Bugfix: Fix shadowing issues with handle in ObjectWrap 0a9072d
|
||||
|
||||
### 2.0.5 Aug 10 2015
|
||||
|
||||
- Bugfix: Reimplement weak callback in ObjectWrap 98d38c1
|
||||
- Bugfix: Make sure callback classes are not assignable, copyable or movable 81f9b1d
|
||||
|
||||
### 2.0.4 Aug 6 2015
|
||||
|
||||
- Build: Repackage
|
||||
|
||||
### 2.0.3 Aug 6 2015
|
||||
|
||||
- Bugfix: Don't use clang++ / g++ syntax extension. 231450e
|
||||
|
||||
### 2.0.2 Aug 6 2015
|
||||
|
||||
- Build: Repackage
|
||||
|
||||
### 2.0.1 Aug 6 2015
|
||||
|
||||
- Bugfix: Add workaround for missing REPLACE_INVALID_UTF8 60d6687
|
||||
- Bugfix: Reimplement ObjectWrap from scratch to prevent memory leaks 6484601
|
||||
- Bugfix: Fix Persistent leak in FunctionCallbackInfo and PropertyCallbackInfo 641ef5f
|
||||
- Bugfix: Add missing overload for Nan::NewInstance that takes argc/argv 29450ed
|
||||
|
||||
### 2.0.0 Jul 31 2015
|
||||
|
||||
- Change: Renamed identifiers with leading underscores b5932b4
|
||||
- Change: Replaced NanObjectWrapHandle with class NanObjectWrap 464f1e1
|
||||
- Change: Replace NanScope and NanEscpableScope macros with classes 47751c4
|
||||
- Change: Rename NanNewBufferHandle to NanNewBuffer 6745f99
|
||||
- Change: Rename NanBufferUse to NanNewBuffer 3e8b0a5
|
||||
- Change: Rename NanNewBuffer to NanCopyBuffer d6af78d
|
||||
- Change: Remove Nan prefix from all names 72d1f67
|
||||
- Change: Update Buffer API for new upstream changes d5d3291
|
||||
- Change: Rename Scope and EscapableScope to HandleScope and EscapableHandleScope 21a7a6a
|
||||
- Change: Get rid of Handles e6c0daf
|
||||
- Feature: Support io.js 3 with V8 4.4
|
||||
- Feature: Introduce NanPersistent 7fed696
|
||||
- Feature: Introduce NanGlobal 4408da1
|
||||
- Feature: Added NanTryCatch 10f1ca4
|
||||
- Feature: Update for V8 v4.3 4b6404a
|
||||
- Feature: Introduce NanNewOneByteString c543d32
|
||||
- Feature: Introduce namespace Nan 67ed1b1
|
||||
- Removal: Remove NanLocker and NanUnlocker dd6e401
|
||||
- Removal: Remove string converters, except NanUtf8String, which now follows the node implementation b5d00a9
|
||||
- Removal: Remove NanReturn* macros d90a25c
|
||||
- Removal: Remove HasInstance e8f84fe
|
||||
|
||||
|
||||
### 1.9.0 Jul 31 2015
|
||||
|
||||
- Feature: Added `NanFatalException` 81d4a2c
|
||||
- Feature: Added more error types 4265f06
|
||||
- Feature: Added dereference and function call operators to NanCallback c4b2ed0
|
||||
- Feature: Added indexed GetFromPersistent and SaveToPersistent edd510c
|
||||
- Feature: Added more overloads of SaveToPersistent and GetFromPersistent 8b1cef6
|
||||
- Feature: Added NanErrnoException dd87d9e
|
||||
- Correctness: Prevent assign, copy, and move for classes that do not support it 1f55c59, 4b808cb, c96d9b2, fba4a29, 3357130
|
||||
- Deprecation: Deprecate `NanGetPointerSafe` and `NanSetPointerSafe` 81d4a2c
|
||||
- Deprecation: Deprecate `NanBooleanOptionValue` and `NanUInt32OptionValue` 0ad254b
|
||||
|
||||
### 1.8.4 Apr 26 2015
|
||||
|
||||
- Build: Repackage
|
||||
|
||||
### 1.8.3 Apr 26 2015
|
||||
|
||||
- Bugfix: Include missing header 1af8648
|
||||
|
||||
### 1.8.2 Apr 23 2015
|
||||
|
||||
- Build: Repackage
|
||||
|
||||
### 1.8.1 Apr 23 2015
|
||||
|
||||
- Bugfix: NanObjectWrapHandle should take a pointer 155f1d3
|
||||
|
||||
### 1.8.0 Apr 23 2015
|
||||
|
||||
- Feature: Allow primitives with NanReturnValue 2e4475e
|
||||
- Feature: Added comparison operators to NanCallback 55b075e
|
||||
- Feature: Backport thread local storage 15bb7fa
|
||||
- Removal: Remove support for signatures with arguments 8a2069d
|
||||
- Correcteness: Replaced NanObjectWrapHandle macro with function 0bc6d59
|
||||
|
||||
### 1.7.0 Feb 28 2015
|
||||
|
||||
- Feature: Made NanCallback::Call accept optional target 8d54da7
|
||||
- Feature: Support atom-shell 0.21 0b7f1bb
|
||||
|
||||
### 1.6.2 Feb 6 2015
|
||||
|
||||
- Bugfix: NanEncode: fix argument type for node::Encode on io.js 2be8639
|
||||
|
||||
### 1.6.1 Jan 23 2015
|
||||
|
||||
- Build: version bump
|
||||
|
||||
### 1.5.3 Jan 23 2015
|
||||
|
||||
- Build: repackage
|
||||
|
||||
### 1.6.0 Jan 23 2015
|
||||
|
||||
- Deprecated `NanNewContextHandle` in favor of `NanNew<Context>` 49259af
|
||||
- Support utility functions moved in newer v8 versions (Node 0.11.15, io.js 1.0) a0aa179
|
||||
- Added `NanEncode`, `NanDecodeBytes` and `NanDecodeWrite` 75e6fb9
|
||||
|
||||
### 1.5.2 Jan 23 2015
|
||||
|
||||
- Bugfix: Fix non-inline definition build error with clang++ 21d96a1, 60fadd4
|
||||
- Bugfix: Readded missing String constructors 18d828f
|
||||
- Bugfix: Add overload handling NanNew<FunctionTemplate>(..) 5ef813b
|
||||
- Bugfix: Fix uv_work_cb versioning 997e4ae
|
||||
- Bugfix: Add function factory and test 4eca89c
|
||||
- Bugfix: Add object template factory and test cdcb951
|
||||
- Correctness: Lifted an io.js related typedef c9490be
|
||||
- Correctness: Make explicit downcasts of String lengths 00074e6
|
||||
- Windows: Limit the scope of disabled warning C4530 83d7deb
|
||||
|
||||
### 1.5.1 Jan 15 2015
|
||||
|
||||
- Build: version bump
|
||||
|
||||
### 1.4.3 Jan 15 2015
|
||||
|
||||
- Build: version bump
|
||||
|
||||
### 1.4.2 Jan 15 2015
|
||||
|
||||
- Feature: Support io.js 0dbc5e8
|
||||
|
||||
### 1.5.0 Jan 14 2015
|
||||
|
||||
- Feature: Support io.js b003843
|
||||
- Correctness: Improved NanNew internals 9cd4f6a
|
||||
- Feature: Implement progress to NanAsyncWorker 8d6a160
|
||||
|
||||
### 1.4.1 Nov 8 2014
|
||||
|
||||
- Bugfix: Handle DEBUG definition correctly
|
||||
- Bugfix: Accept int as Boolean
|
||||
|
||||
### 1.4.0 Nov 1 2014
|
||||
|
||||
- Feature: Added NAN_GC_CALLBACK 6a5c245
|
||||
- Performance: Removed unnecessary local handle creation 18a7243, 41fe2f8
|
||||
- Correctness: Added constness to references in NanHasInstance 02c61cd
|
||||
- Warnings: Fixed spurious warnings from -Wundef and -Wshadow, 541b122, 99d8cb6
|
||||
- Windoze: Shut Visual Studio up when compiling 8d558c1
|
||||
- License: Switch to plain MIT from custom hacked MIT license 11de983
|
||||
- Build: Added test target to Makefile e232e46
|
||||
- Performance: Removed superfluous scope in NanAsyncWorker f4b7821
|
||||
- Sugar/Feature: Added NanReturnThis() and NanReturnHolder() shorthands 237a5ff, d697208
|
||||
- Feature: Added suitable overload of NanNew for v8::Integer::NewFromUnsigned b27b450
|
||||
|
||||
### 1.3.0 Aug 2 2014
|
||||
|
||||
- Added NanNew<v8::String, std::string>(std::string)
|
||||
- Added NanNew<v8::String, std::string&>(std::string&)
|
||||
- Added NanAsciiString helper class
|
||||
- Added NanUtf8String helper class
|
||||
- Added NanUcs2String helper class
|
||||
- Deprecated NanRawString()
|
||||
- Deprecated NanCString()
|
||||
- Added NanGetIsolateData(v8::Isolate *isolate)
|
||||
- Added NanMakeCallback(v8::Handle<v8::Object> target, v8::Handle<v8::Function> func, int argc, v8::Handle<v8::Value>* argv)
|
||||
- Added NanMakeCallback(v8::Handle<v8::Object> target, v8::Handle<v8::String> symbol, int argc, v8::Handle<v8::Value>* argv)
|
||||
- Added NanMakeCallback(v8::Handle<v8::Object> target, const char* method, int argc, v8::Handle<v8::Value>* argv)
|
||||
- Added NanSetTemplate(v8::Handle<v8::Template> templ, v8::Handle<v8::String> name , v8::Handle<v8::Data> value, v8::PropertyAttribute attributes)
|
||||
- Added NanSetPrototypeTemplate(v8::Local<v8::FunctionTemplate> templ, v8::Handle<v8::String> name, v8::Handle<v8::Data> value, v8::PropertyAttribute attributes)
|
||||
- Added NanSetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ, const char *name, v8::Handle<v8::Data> value)
|
||||
- Added NanSetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ, v8::Handle<v8::String> name, v8::Handle<v8::Data> value, v8::PropertyAttribute attributes)
|
||||
|
||||
### 1.2.0 Jun 5 2014
|
||||
|
||||
- Add NanSetPrototypeTemplate
|
||||
- Changed NAN_WEAK_CALLBACK internals, switched _NanWeakCallbackData to class,
|
||||
introduced _NanWeakCallbackDispatcher
|
||||
- Removed -Wno-unused-local-typedefs from test builds
|
||||
- Made test builds Windows compatible ('Sleep()')
|
||||
|
||||
### 1.1.2 May 28 2014
|
||||
|
||||
- Release to fix more stuff-ups in 1.1.1
|
||||
|
||||
### 1.1.1 May 28 2014
|
||||
|
||||
- Release to fix version mismatch in nan.h and lack of changelog entry for 1.1.0
|
||||
|
||||
### 1.1.0 May 25 2014
|
||||
|
||||
- Remove nan_isolate, use v8::Isolate::GetCurrent() internally instead
|
||||
- Additional explicit overloads for NanNew(): (char*,int), (uint8_t*[,int]),
|
||||
(uint16_t*[,int), double, int, unsigned int, bool, v8::String::ExternalStringResource*,
|
||||
v8::String::ExternalAsciiStringResource*
|
||||
- Deprecate NanSymbol()
|
||||
- Added SetErrorMessage() and ErrorMessage() to NanAsyncWorker
|
||||
|
||||
### 1.0.0 May 4 2014
|
||||
|
||||
- Heavy API changes for V8 3.25 / Node 0.11.13
|
||||
- Use cpplint.py
|
||||
- Removed NanInitPersistent
|
||||
- Removed NanPersistentToLocal
|
||||
- Removed NanFromV8String
|
||||
- Removed NanMakeWeak
|
||||
- Removed NanNewLocal
|
||||
- Removed NAN_WEAK_CALLBACK_OBJECT
|
||||
- Removed NAN_WEAK_CALLBACK_DATA
|
||||
- Introduce NanNew, replaces NanNewLocal, NanPersistentToLocal, adds many overloaded typed versions
|
||||
- Introduce NanUndefined, NanNull, NanTrue and NanFalse
|
||||
- Introduce NanEscapableScope and NanEscapeScope
|
||||
- Introduce NanMakeWeakPersistent (requires a special callback to work on both old and new node)
|
||||
- Introduce NanMakeCallback for node::MakeCallback
|
||||
- Introduce NanSetTemplate
|
||||
- Introduce NanGetCurrentContext
|
||||
- Introduce NanCompileScript and NanRunScript
|
||||
- Introduce NanAdjustExternalMemory
|
||||
- Introduce NanAddGCEpilogueCallback, NanAddGCPrologueCallback, NanRemoveGCEpilogueCallback, NanRemoveGCPrologueCallback
|
||||
- Introduce NanGetHeapStatistics
|
||||
- Rename NanAsyncWorker#SavePersistent() to SaveToPersistent()
|
||||
|
||||
### 0.8.0 Jan 9 2014
|
||||
|
||||
- NanDispose -> NanDisposePersistent, deprecate NanDispose
|
||||
- Extract _NAN_*_RETURN_TYPE, pull up NAN_*()
|
||||
|
||||
### 0.7.1 Jan 9 2014
|
||||
|
||||
- Fixes to work against debug builds of Node
|
||||
- Safer NanPersistentToLocal (avoid reinterpret_cast)
|
||||
- Speed up common NanRawString case by only extracting flattened string when necessary
|
||||
|
||||
### 0.7.0 Dec 17 2013
|
||||
|
||||
- New no-arg form of NanCallback() constructor.
|
||||
- NanCallback#Call takes Handle rather than Local
|
||||
- Removed deprecated NanCallback#Run method, use NanCallback#Call instead
|
||||
- Split off _NAN_*_ARGS_TYPE from _NAN_*_ARGS
|
||||
- Restore (unofficial) Node 0.6 compatibility at NanCallback#Call()
|
||||
- Introduce NanRawString() for char* (or appropriate void*) from v8::String
|
||||
(replacement for NanFromV8String)
|
||||
- Introduce NanCString() for null-terminated char* from v8::String
|
||||
|
||||
### 0.6.0 Nov 21 2013
|
||||
|
||||
- Introduce NanNewLocal<T>(v8::Handle<T> value) for use in place of
|
||||
v8::Local<T>::New(...) since v8 started requiring isolate in Node 0.11.9
|
||||
|
||||
### 0.5.2 Nov 16 2013
|
||||
|
||||
- Convert SavePersistent and GetFromPersistent in NanAsyncWorker from protected and public
|
||||
|
||||
### 0.5.1 Nov 12 2013
|
||||
|
||||
- Use node::MakeCallback() instead of direct v8::Function::Call()
|
||||
|
||||
### 0.5.0 Nov 11 2013
|
||||
|
||||
- Added @TooTallNate as collaborator
|
||||
- New, much simpler, "include_dirs" for binding.gyp
|
||||
- Added full range of NAN_INDEX_* macros to match NAN_PROPERTY_* macros
|
||||
|
||||
### 0.4.4 Nov 2 2013
|
||||
|
||||
- Isolate argument from v8::Persistent::MakeWeak removed for 0.11.8+
|
||||
|
||||
### 0.4.3 Nov 2 2013
|
||||
|
||||
- Include node_object_wrap.h, removed from node.h for Node 0.11.8.
|
||||
|
||||
### 0.4.2 Nov 2 2013
|
||||
|
||||
- Handle deprecation of v8::Persistent::Dispose(v8::Isolate* isolate)) for
|
||||
Node 0.11.8 release.
|
||||
|
||||
### 0.4.1 Sep 16 2013
|
||||
|
||||
- Added explicit `#include <uv.h>` as it was removed from node.h for v0.11.8
|
||||
|
||||
### 0.4.0 Sep 2 2013
|
||||
|
||||
- Added NAN_INLINE and NAN_DEPRECATED and made use of them
|
||||
- Added NanError, NanTypeError and NanRangeError
|
||||
- Cleaned up code
|
||||
|
||||
### 0.3.2 Aug 30 2013
|
||||
|
||||
- Fix missing scope declaration in GetFromPersistent() and SaveToPersistent
|
||||
in NanAsyncWorker
|
||||
|
||||
### 0.3.1 Aug 20 2013
|
||||
|
||||
- fix "not all control paths return a value" compile warning on some platforms
|
||||
|
||||
### 0.3.0 Aug 19 2013
|
||||
|
||||
- Made NAN work with NPM
|
||||
- Lots of fixes to NanFromV8String, pulling in features from new Node core
|
||||
- Changed node::encoding to Nan::Encoding in NanFromV8String to unify the API
|
||||
- Added optional error number argument for NanThrowError()
|
||||
- Added NanInitPersistent()
|
||||
- Added NanReturnNull() and NanReturnEmptyString()
|
||||
- Added NanLocker and NanUnlocker
|
||||
- Added missing scopes
|
||||
- Made sure to clear disposed Persistent handles
|
||||
- Changed NanAsyncWorker to allocate error messages on the heap
|
||||
- Changed NanThrowError(Local<Value>) to NanThrowError(Handle<Value>)
|
||||
- Fixed leak in NanAsyncWorker when errmsg is used
|
||||
|
||||
### 0.2.2 Aug 5 2013
|
||||
|
||||
- Fixed usage of undefined variable with node::BASE64 in NanFromV8String()
|
||||
|
||||
### 0.2.1 Aug 5 2013
|
||||
|
||||
- Fixed 0.8 breakage, node::BUFFER encoding type not available in 0.8 for
|
||||
NanFromV8String()
|
||||
|
||||
### 0.2.0 Aug 5 2013
|
||||
|
||||
- Added NAN_PROPERTY_GETTER, NAN_PROPERTY_SETTER, NAN_PROPERTY_ENUMERATOR,
|
||||
NAN_PROPERTY_DELETER, NAN_PROPERTY_QUERY
|
||||
- Extracted _NAN_METHOD_ARGS, _NAN_GETTER_ARGS, _NAN_SETTER_ARGS,
|
||||
_NAN_PROPERTY_GETTER_ARGS, _NAN_PROPERTY_SETTER_ARGS,
|
||||
_NAN_PROPERTY_ENUMERATOR_ARGS, _NAN_PROPERTY_DELETER_ARGS,
|
||||
_NAN_PROPERTY_QUERY_ARGS
|
||||
- Added NanGetInternalFieldPointer, NanSetInternalFieldPointer
|
||||
- Added NAN_WEAK_CALLBACK, NAN_WEAK_CALLBACK_OBJECT,
|
||||
NAN_WEAK_CALLBACK_DATA, NanMakeWeak
|
||||
- Renamed THROW_ERROR to _NAN_THROW_ERROR
|
||||
- Added NanNewBufferHandle(char*, size_t, node::smalloc::FreeCallback, void*)
|
||||
- Added NanBufferUse(char*, uint32_t)
|
||||
- Added NanNewContextHandle(v8::ExtensionConfiguration*,
|
||||
v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)
|
||||
- Fixed broken NanCallback#GetFunction()
|
||||
- Added optional encoding and size arguments to NanFromV8String()
|
||||
- Added NanGetPointerSafe() and NanSetPointerSafe()
|
||||
- Added initial test suite (to be expanded)
|
||||
- Allow NanUInt32OptionValue to convert any Number object
|
||||
|
||||
### 0.1.0 Jul 21 2013
|
||||
|
||||
- Added `NAN_GETTER`, `NAN_SETTER`
|
||||
- Added `NanThrowError` with single Local<Value> argument
|
||||
- Added `NanNewBufferHandle` with single uint32_t argument
|
||||
- Added `NanHasInstance(Persistent<FunctionTemplate>&, Handle<Value>)`
|
||||
- Added `Local<Function> NanCallback#GetFunction()`
|
||||
- Added `NanCallback#Call(int, Local<Value>[])`
|
||||
- Deprecated `NanCallback#Run(int, Local<Value>[])` in favour of Call
|
||||
138
tasks/enduro-trails/prototype/node_modules/nan/CMakeLists.txt
generated
vendored
Normal file
138
tasks/enduro-trails/prototype/node_modules/nan/CMakeLists.txt
generated
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(nan)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
set(CPPLINT "${CMAKE_CURRENT_SOURCE_DIR}/cpplint.py")
|
||||
set(MODULES symbols strings)
|
||||
set(SOURCES "")
|
||||
set(ADDONS "")
|
||||
|
||||
foreach(MODULE ${MODULES})
|
||||
list(APPEND SOURCES "test/cpp/${MODULE}.cpp")
|
||||
list(APPEND ADDONS "test/build/${CMAKE_BUILD_TYPE}/${MODULE}.node")
|
||||
endforeach()
|
||||
|
||||
set(LINT_SOURCES examples/async_pi_estimate/addon.cc
|
||||
examples/async_pi_estimate/async.cc
|
||||
examples/async_pi_estimate/async.h
|
||||
examples/async_pi_estimate/pi_est.cc
|
||||
examples/async_pi_estimate/pi_est.h
|
||||
examples/async_pi_estimate/sync.cc
|
||||
examples/async_pi_estimate/sync.h
|
||||
nan.h
|
||||
nan_callbacks.h
|
||||
nan_callbacks_12_inl.h
|
||||
nan_callbacks_pre_12_inl.h
|
||||
nan_converters.h
|
||||
nan_converters_43_inl.h
|
||||
nan_converters_pre_43_inl.h
|
||||
nan_define_own_property_helper.h
|
||||
nan_implementation_12_inl.h
|
||||
nan_implementation_pre_12_inl.h
|
||||
nan_json.h
|
||||
nan_maybe_43_inl.h
|
||||
nan_maybe_pre_43_inl.h
|
||||
nan_new.h
|
||||
nan_object_wrap.h
|
||||
nan_persistent_12_inl.h
|
||||
nan_persistent_pre_12_inl.h
|
||||
nan_private.h
|
||||
nan_scriptorigin.h
|
||||
nan_string_bytes.h
|
||||
nan_weak.h
|
||||
test/cpp/accessors.cpp
|
||||
test/cpp/accessors2.cpp
|
||||
test/cpp/asyncresource.cpp
|
||||
test/cpp/asyncworker.cpp
|
||||
test/cpp/asyncprogressworker.cpp
|
||||
test/cpp/asyncprogressworkerstream.cpp
|
||||
test/cpp/asyncprogressworkersignal.cpp
|
||||
test/cpp/asyncprogressqueueworker.cpp
|
||||
test/cpp/asyncprogressqueueworkerstream.cpp
|
||||
test/cpp/asyncworkererror.cpp
|
||||
test/cpp/buffer.cpp
|
||||
test/cpp/bufferworkerpersistent.cpp
|
||||
test/cpp/error.cpp
|
||||
test/cpp/gc.cpp
|
||||
test/cpp/indexedinterceptors.cpp
|
||||
test/cpp/callbackcontext.cpp
|
||||
test/cpp/converters.cpp
|
||||
test/cpp/isolatedata.cpp
|
||||
test/cpp/json-parse.cpp
|
||||
test/cpp/json-stringify.cpp
|
||||
test/cpp/makecallback.cpp
|
||||
test/cpp/maybe.cpp
|
||||
test/cpp/morenews.cpp
|
||||
test/cpp/multifile1.cpp
|
||||
test/cpp/multifile2.cpp
|
||||
test/cpp/multifile2.h
|
||||
test/cpp/namedinterceptors.cpp
|
||||
test/cpp/nancallback.cpp
|
||||
test/cpp/nannew.cpp
|
||||
test/cpp/news.cpp
|
||||
test/cpp/objectwraphandle.cpp
|
||||
test/cpp/persistent.cpp
|
||||
test/cpp/private.cpp
|
||||
test/cpp/returnemptystring.cpp
|
||||
test/cpp/returnnull.cpp
|
||||
test/cpp/returnundefined.cpp
|
||||
test/cpp/returnvalue.cpp
|
||||
test/cpp/setcallhandler.cpp
|
||||
test/cpp/settemplate.cpp
|
||||
test/cpp/sleep.h
|
||||
test/cpp/strings.cpp
|
||||
test/cpp/symbols.cpp
|
||||
test/cpp/threadlocal.cpp
|
||||
test/cpp/trycatch.cpp
|
||||
test/cpp/typedarrays.cpp
|
||||
test/cpp/weak.cpp
|
||||
test/cpp/weak2.cpp
|
||||
test/cpp/wrappedobjectfactory.cpp
|
||||
node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc)
|
||||
|
||||
set(FILTER "-build/include_subdir,-whitespace/parens")
|
||||
|
||||
find_package(Python COMPONENTS Interpreter Development REQUIRED)
|
||||
|
||||
execute_process(
|
||||
COMMAND npm install
|
||||
OUTPUT_FILE node_modules
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
add_custom_target(lint
|
||||
COMMAND ${Python_EXECUTABLE} ${CPPLINT} --filter=${FILTER} ${LINT_SOURCES}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
add_custom_target(test
|
||||
DEPENDS ${ADDONS}
|
||||
COMMAND npm test
|
||||
)
|
||||
|
||||
add_custom_target(forcetest
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test
|
||||
COMMAND ../node_modules/.bin/node-gyp rebuild
|
||||
COMMAND npm test
|
||||
)
|
||||
|
||||
add_custom_target(docs
|
||||
DEPENDS README.md doc/.build.sh doc/asyncworker.md doc/buffers.md doc/callback.md
|
||||
doc/converters.md doc/errors.md doc/maybe_types.md doc/methods.md doc/new.md
|
||||
doc/node_misc.md doc/persistent.md doc/scopes.md doc/script.md doc/string_bytes.md
|
||||
doc/v8_internals.md doc/json.md doc/v8_misc.md
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND doc/.build.sh
|
||||
)
|
||||
|
||||
add_custom_command(OUTPUT ${ADDONS}
|
||||
DEPENDS ${SOURCES} nan.h nan_new.h nan_implementation_pre_12_inl.h nan_implementation_12_inl.h
|
||||
nan_callbacks.h nan_callbacks_12_inl.h nan_callbacks_pre_12_inl.h nan_converters.h
|
||||
nan_converters_43_inl.h nan_converters_pre_43_inl.h nan_define_own_property_helper.h
|
||||
nan_json.h nan_maybe_43_inl.h nan_maybe_pre_43_inl.h nan_persistent_12_inl.h
|
||||
nan_persistent_pre_12_inl.h nan_private.h nan_weak.h nan_scriptorigin.h nan_string_bytes.h
|
||||
test/binding.gyp
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test
|
||||
COMMAND ../node_modules/.bin/node-gyp rebuild
|
||||
)
|
||||
9
tasks/enduro-trails/prototype/node_modules/nan/LICENSE.md
generated
vendored
Normal file
9
tasks/enduro-trails/prototype/node_modules/nan/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 [NAN contributors](<https://github.com/nodejs/nan#wg-members--collaborators>)
|
||||
|
||||
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.
|
||||
456
tasks/enduro-trails/prototype/node_modules/nan/README.md
generated
vendored
Normal file
456
tasks/enduro-trails/prototype/node_modules/nan/README.md
generated
vendored
Normal file
@@ -0,0 +1,456 @@
|
||||
Native Abstractions for Node.js
|
||||
===============================
|
||||
|
||||
**A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 8, 10, 12, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24 and 25.**
|
||||
|
||||
***Current version: 2.26.2***
|
||||
|
||||
*(See [CHANGELOG.md](https://github.com/nodejs/nan/blob/master/CHANGELOG.md) for complete ChangeLog)*
|
||||
|
||||
[](https://nodei.co/npm/nan/) [](https://nodei.co/npm/nan/)
|
||||
|
||||
[](https://ci.appveyor.com/project/RodVagg/nan)
|
||||
|
||||
Thanks to the crazy changes in V8 (and some in Node core), keeping native addons compiling happily across versions, particularly 0.10 to 0.12 to 4.0, is a minor nightmare. The goal of this project is to store all logic necessary to develop native Node.js addons without having to inspect `NODE_MODULE_VERSION` and get yourself into a macro-tangle.
|
||||
|
||||
This project also contains some helper utilities that make addon development a bit more pleasant.
|
||||
|
||||
* **[News & Updates](#news)**
|
||||
* **[Usage](#usage)**
|
||||
* **[Example](#example)**
|
||||
* **[API](#api)**
|
||||
* **[Tests](#tests)**
|
||||
* **[Known issues](#issues)**
|
||||
* **[Governance & Contributing](#governance)**
|
||||
|
||||
<a name="news"></a>
|
||||
|
||||
## News & Updates
|
||||
|
||||
<a name="usage"></a>
|
||||
|
||||
## Usage
|
||||
|
||||
Simply add **NAN** as a dependency using a package manager like npm, yarn, or bun:
|
||||
|
||||
``` bash
|
||||
$ npm install nan
|
||||
```
|
||||
|
||||
Pull in the path to **NAN** in your *binding.gyp* so that you can use `#include <nan.h>` in your *.cpp* files:
|
||||
|
||||
``` python
|
||||
"include_dirs" : [
|
||||
"<!(node -e \"require('nan')\")"
|
||||
]
|
||||
```
|
||||
|
||||
This works like a `-I<path-to-NAN>` when compiling your addon.
|
||||
|
||||
<a name="example"></a>
|
||||
|
||||
## Example
|
||||
|
||||
Just getting started with Nan? Take a look at the **[Node Add-on Examples](https://github.com/nodejs/node-addon-examples)**.
|
||||
|
||||
Refer to a [quick-start **Nan** Boilerplate](https://github.com/fcanas/node-native-boilerplate) for a ready-to-go project that utilizes basic Nan functionality.
|
||||
|
||||
For a simpler example, see the **[async pi estimation example](https://github.com/nodejs/nan/tree/master/examples/async_pi_estimate)** in the examples directory for full code and an explanation of what this Monte Carlo Pi estimation example does. Below are just some parts of the full example that illustrate the use of **NAN**.
|
||||
|
||||
Yet another example is **[nan-example-eol](https://github.com/CodeCharmLtd/nan-example-eol)**. It shows newline detection implemented as a native addon.
|
||||
|
||||
Also take a look at our comprehensive **[C++ test suite](https://github.com/nodejs/nan/tree/master/test/cpp)** which has a plethora of code snippets for your pasting pleasure.
|
||||
|
||||
<a name="api"></a>
|
||||
|
||||
## API
|
||||
|
||||
Additional to the NAN documentation below, please consult:
|
||||
|
||||
* [The V8 Getting Started * Guide](https://v8.dev/docs/embed)
|
||||
* [V8 API Documentation](https://v8docs.nodesource.com/)
|
||||
* [Node Add-on Documentation](https://nodejs.org/api/addons.html)
|
||||
|
||||
<!-- START API -->
|
||||
|
||||
### JavaScript-accessible methods
|
||||
|
||||
A _template_ is a blueprint for JavaScript functions and objects in a context. You can use a template to wrap C++ functions and data structures within JavaScript objects so that they can be manipulated from JavaScript. See the V8 Embedders Guide section on [Templates](https://github.com/v8/v8/wiki/Embedder%27s-Guide#templates) for further information.
|
||||
|
||||
In order to expose functionality to JavaScript via a template, you must provide it to V8 in a form that it understands. Across the versions of V8 supported by NAN, JavaScript-accessible method signatures vary widely, NAN fully abstracts method declaration and provides you with an interface that is similar to the most recent V8 API but is backward-compatible with older versions that still use the now-deceased `v8::Argument` type.
|
||||
|
||||
* **Method argument types**
|
||||
- <a href="doc/methods.md#api_nan_function_callback_info"><b><code>Nan::FunctionCallbackInfo</code></b></a>
|
||||
- <a href="doc/methods.md#api_nan_property_callback_info"><b><code>Nan::PropertyCallbackInfo</code></b></a>
|
||||
- <a href="doc/methods.md#api_nan_return_value"><b><code>Nan::ReturnValue</code></b></a>
|
||||
* **Method declarations**
|
||||
- <a href="doc/methods.md#api_nan_method"><b>Method declaration</b></a>
|
||||
- <a href="doc/methods.md#api_nan_getter"><b>Getter declaration</b></a>
|
||||
- <a href="doc/methods.md#api_nan_setter"><b>Setter declaration</b></a>
|
||||
- <a href="doc/methods.md#api_nan_property_getter"><b>Property getter declaration</b></a>
|
||||
- <a href="doc/methods.md#api_nan_property_setter"><b>Property setter declaration</b></a>
|
||||
- <a href="doc/methods.md#api_nan_property_enumerator"><b>Property enumerator declaration</b></a>
|
||||
- <a href="doc/methods.md#api_nan_property_deleter"><b>Property deleter declaration</b></a>
|
||||
- <a href="doc/methods.md#api_nan_property_query"><b>Property query declaration</b></a>
|
||||
- <a href="doc/methods.md#api_nan_index_getter"><b>Index getter declaration</b></a>
|
||||
- <a href="doc/methods.md#api_nan_index_setter"><b>Index setter declaration</b></a>
|
||||
- <a href="doc/methods.md#api_nan_index_enumerator"><b>Index enumerator declaration</b></a>
|
||||
- <a href="doc/methods.md#api_nan_index_deleter"><b>Index deleter declaration</b></a>
|
||||
- <a href="doc/methods.md#api_nan_index_query"><b>Index query declaration</b></a>
|
||||
* Method and template helpers
|
||||
- <a href="doc/methods.md#api_nan_set_method"><b><code>Nan::SetMethod()</code></b></a>
|
||||
- <a href="doc/methods.md#api_nan_set_prototype_method"><b><code>Nan::SetPrototypeMethod()</code></b></a>
|
||||
- <a href="doc/methods.md#api_nan_set_accessor"><b><code>Nan::SetAccessor()</code></b></a>
|
||||
- <a href="doc/methods.md#api_nan_set_named_property_handler"><b><code>Nan::SetNamedPropertyHandler()</code></b></a>
|
||||
- <a href="doc/methods.md#api_nan_set_indexed_property_handler"><b><code>Nan::SetIndexedPropertyHandler()</code></b></a>
|
||||
- <a href="doc/methods.md#api_nan_set_template"><b><code>Nan::SetTemplate()</code></b></a>
|
||||
- <a href="doc/methods.md#api_nan_set_prototype_template"><b><code>Nan::SetPrototypeTemplate()</code></b></a>
|
||||
- <a href="doc/methods.md#api_nan_set_instance_template"><b><code>Nan::SetInstanceTemplate()</code></b></a>
|
||||
- <a href="doc/methods.md#api_nan_set_call_handler"><b><code>Nan::SetCallHandler()</code></b></a>
|
||||
- <a href="doc/methods.md#api_nan_set_call_as_function_handler"><b><code>Nan::SetCallAsFunctionHandler()</code></b></a>
|
||||
|
||||
### Scopes
|
||||
|
||||
A _local handle_ is a pointer to an object. All V8 objects are accessed using handles, they are necessary because of the way the V8 garbage collector works.
|
||||
|
||||
A handle scope can be thought of as a container for any number of handles. When you've finished with your handles, instead of deleting each one individually you can simply delete their scope.
|
||||
|
||||
The creation of `HandleScope` objects is different across the supported versions of V8. Therefore, NAN provides its own implementations that can be used safely across these.
|
||||
|
||||
- <a href="doc/scopes.md#api_nan_handle_scope"><b><code>Nan::HandleScope</code></b></a>
|
||||
- <a href="doc/scopes.md#api_nan_escapable_handle_scope"><b><code>Nan::EscapableHandleScope</code></b></a>
|
||||
|
||||
Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://github.com/v8/v8/wiki/Embedder%27s%20Guide#handles-and-garbage-collection).
|
||||
|
||||
### Persistent references
|
||||
|
||||
An object reference that is independent of any `HandleScope` is a _persistent_ reference. Where a `Local` handle only lives as long as the `HandleScope` in which it was allocated, a `Persistent` handle remains valid until it is explicitly disposed.
|
||||
|
||||
Due to the evolution of the V8 API, it is necessary for NAN to provide a wrapper implementation of the `Persistent` classes to supply compatibility across the V8 versions supported.
|
||||
|
||||
- <a href="doc/persistent.md#api_nan_persistent_base"><b><code>Nan::PersistentBase & v8::PersistentBase</code></b></a>
|
||||
- <a href="doc/persistent.md#api_nan_non_copyable_persistent_traits"><b><code>Nan::NonCopyablePersistentTraits & v8::NonCopyablePersistentTraits</code></b></a>
|
||||
- <a href="doc/persistent.md#api_nan_copyable_persistent_traits"><b><code>Nan::CopyablePersistentTraits & v8::CopyablePersistentTraits</code></b></a>
|
||||
- <a href="doc/persistent.md#api_nan_persistent"><b><code>Nan::Persistent</code></b></a>
|
||||
- <a href="doc/persistent.md#api_nan_global"><b><code>Nan::Global</code></b></a>
|
||||
- <a href="doc/persistent.md#api_nan_weak_callback_info"><b><code>Nan::WeakCallbackInfo</code></b></a>
|
||||
- <a href="doc/persistent.md#api_nan_weak_callback_type"><b><code>Nan::WeakCallbackType</code></b></a>
|
||||
|
||||
Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://v8.dev/docs/embed#handles-and-garbage-collection).
|
||||
|
||||
### New
|
||||
|
||||
NAN provides a `Nan::New()` helper for the creation of new JavaScript objects in a way that's compatible across the supported versions of V8.
|
||||
|
||||
- <a href="doc/new.md#api_nan_new"><b><code>Nan::New()</code></b></a>
|
||||
- <a href="doc/new.md#api_nan_undefined"><b><code>Nan::Undefined()</code></b></a>
|
||||
- <a href="doc/new.md#api_nan_null"><b><code>Nan::Null()</code></b></a>
|
||||
- <a href="doc/new.md#api_nan_true"><b><code>Nan::True()</code></b></a>
|
||||
- <a href="doc/new.md#api_nan_false"><b><code>Nan::False()</code></b></a>
|
||||
- <a href="doc/new.md#api_nan_empty_string"><b><code>Nan::EmptyString()</code></b></a>
|
||||
|
||||
|
||||
### Converters
|
||||
|
||||
NAN contains functions that convert `v8::Value`s to other `v8::Value` types and native types. Since type conversion is not guaranteed to succeed, they return `Nan::Maybe` types. These converters can be used in place of `value->ToX()` and `value->XValue()` (where `X` is one of the types, e.g. `Boolean`) in a way that provides a consistent interface across V8 versions. Newer versions of V8 use the new `v8::Maybe` and `v8::MaybeLocal` types for these conversions, older versions don't have this functionality so it is provided by NAN.
|
||||
|
||||
- <a href="doc/converters.md#api_nan_to"><b><code>Nan::To()</code></b></a>
|
||||
|
||||
### Maybe Types
|
||||
|
||||
The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Local` handles that _may be empty_.
|
||||
|
||||
* **Maybe Types**
|
||||
- <a href="doc/maybe_types.md#api_nan_maybe_local"><b><code>Nan::MaybeLocal</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_maybe"><b><code>Nan::Maybe</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_nothing"><b><code>Nan::Nothing</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_just"><b><code>Nan::Just</code></b></a>
|
||||
* **Maybe Helpers**
|
||||
- <a href="doc/maybe_types.md#api_nan_call"><b><code>Nan::Call()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_to_detail_string"><b><code>Nan::ToDetailString()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_to_array_index"><b><code>Nan::ToArrayIndex()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_equals"><b><code>Nan::Equals()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_new_instance"><b><code>Nan::NewInstance()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_get_function"><b><code>Nan::GetFunction()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_set"><b><code>Nan::Set()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_define_own_property"><b><code>Nan::DefineOwnProperty()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_force_set"><del><b><code>Nan::ForceSet()</code></b></del></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_get"><b><code>Nan::Get()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_get_property_attribute"><b><code>Nan::GetPropertyAttributes()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_has"><b><code>Nan::Has()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_delete"><b><code>Nan::Delete()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_get_property_names"><b><code>Nan::GetPropertyNames()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_get_own_property_names"><b><code>Nan::GetOwnPropertyNames()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_set_prototype"><b><code>Nan::SetPrototype()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_object_proto_to_string"><b><code>Nan::ObjectProtoToString()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_has_own_property"><b><code>Nan::HasOwnProperty()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_has_real_named_property"><b><code>Nan::HasRealNamedProperty()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_has_real_indexed_property"><b><code>Nan::HasRealIndexedProperty()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_has_real_named_callback_property"><b><code>Nan::HasRealNamedCallbackProperty()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_get_real_named_property_in_prototype_chain"><b><code>Nan::GetRealNamedPropertyInPrototypeChain()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_get_real_named_property"><b><code>Nan::GetRealNamedProperty()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_call_as_function"><b><code>Nan::CallAsFunction()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_call_as_constructor"><b><code>Nan::CallAsConstructor()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_get_source_line"><b><code>Nan::GetSourceLine()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_get_line_number"><b><code>Nan::GetLineNumber()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_get_start_column"><b><code>Nan::GetStartColumn()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_get_end_column"><b><code>Nan::GetEndColumn()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_clone_element_at"><b><code>Nan::CloneElementAt()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_has_private"><b><code>Nan::HasPrivate()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_get_private"><b><code>Nan::GetPrivate()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_set_private"><b><code>Nan::SetPrivate()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_delete_private"><b><code>Nan::DeletePrivate()</code></b></a>
|
||||
- <a href="doc/maybe_types.md#api_nan_make_maybe"><b><code>Nan::MakeMaybe()</code></b></a>
|
||||
|
||||
### Script
|
||||
|
||||
NAN provides `v8::Script` helpers as the API has changed over the supported versions of V8.
|
||||
|
||||
- <a href="doc/script.md#api_nan_compile_script"><b><code>Nan::CompileScript()</code></b></a>
|
||||
- <a href="doc/script.md#api_nan_run_script"><b><code>Nan::RunScript()</code></b></a>
|
||||
- <a href="doc/script.md#api_nan_script_origin"><b><code>Nan::ScriptOrigin</code></b></a>
|
||||
|
||||
|
||||
### JSON
|
||||
|
||||
The _JSON_ object provides the C++ versions of the methods offered by the `JSON` object in javascript. V8 exposes these methods via the `v8::JSON` object.
|
||||
|
||||
- <a href="doc/json.md#api_nan_json_parse"><b><code>Nan::JSON.Parse</code></b></a>
|
||||
- <a href="doc/json.md#api_nan_json_stringify"><b><code>Nan::JSON.Stringify</code></b></a>
|
||||
|
||||
Refer to the V8 JSON object in the [V8 documentation](https://v8docs.nodesource.com/node-8.16/da/d6f/classv8_1_1_j_s_o_n.html) for more information about these methods and their arguments.
|
||||
|
||||
### Errors
|
||||
|
||||
NAN includes helpers for creating, throwing and catching Errors as much of this functionality varies across the supported versions of V8 and must be abstracted.
|
||||
|
||||
Note that an Error object is simply a specialized form of `v8::Value`.
|
||||
|
||||
Also consult the V8 Embedders Guide section on [Exceptions](https://v8.dev/docs/embed#exceptions) for more information.
|
||||
|
||||
- <a href="doc/errors.md#api_nan_error"><b><code>Nan::Error()</code></b></a>
|
||||
- <a href="doc/errors.md#api_nan_range_error"><b><code>Nan::RangeError()</code></b></a>
|
||||
- <a href="doc/errors.md#api_nan_reference_error"><b><code>Nan::ReferenceError()</code></b></a>
|
||||
- <a href="doc/errors.md#api_nan_syntax_error"><b><code>Nan::SyntaxError()</code></b></a>
|
||||
- <a href="doc/errors.md#api_nan_type_error"><b><code>Nan::TypeError()</code></b></a>
|
||||
- <a href="doc/errors.md#api_nan_throw_error"><b><code>Nan::ThrowError()</code></b></a>
|
||||
- <a href="doc/errors.md#api_nan_throw_range_error"><b><code>Nan::ThrowRangeError()</code></b></a>
|
||||
- <a href="doc/errors.md#api_nan_throw_reference_error"><b><code>Nan::ThrowReferenceError()</code></b></a>
|
||||
- <a href="doc/errors.md#api_nan_throw_syntax_error"><b><code>Nan::ThrowSyntaxError()</code></b></a>
|
||||
- <a href="doc/errors.md#api_nan_throw_type_error"><b><code>Nan::ThrowTypeError()</code></b></a>
|
||||
- <a href="doc/errors.md#api_nan_fatal_exception"><b><code>Nan::FatalException()</code></b></a>
|
||||
- <a href="doc/errors.md#api_nan_errno_exception"><b><code>Nan::ErrnoException()</code></b></a>
|
||||
- <a href="doc/errors.md#api_nan_try_catch"><b><code>Nan::TryCatch</code></b></a>
|
||||
|
||||
|
||||
### Buffers
|
||||
|
||||
NAN's `node::Buffer` helpers exist as the API has changed across supported Node versions. Use these methods to ensure compatibility.
|
||||
|
||||
- <a href="doc/buffers.md#api_nan_new_buffer"><b><code>Nan::NewBuffer()</code></b></a>
|
||||
- <a href="doc/buffers.md#api_nan_copy_buffer"><b><code>Nan::CopyBuffer()</code></b></a>
|
||||
- <a href="doc/buffers.md#api_nan_free_callback"><b><code>Nan::FreeCallback()</code></b></a>
|
||||
|
||||
### Nan::Callback
|
||||
|
||||
`Nan::Callback` makes it easier to use `v8::Function` handles as callbacks. A class that wraps a `v8::Function` handle, protecting it from garbage collection and making it particularly useful for storage and use across asynchronous execution.
|
||||
|
||||
- <a href="doc/callback.md#api_nan_callback"><b><code>Nan::Callback</code></b></a>
|
||||
|
||||
### Asynchronous work helpers
|
||||
|
||||
`Nan::AsyncWorker`, `Nan::AsyncProgressWorker` and `Nan::AsyncProgressQueueWorker` are helper classes that make working with asynchronous code easier.
|
||||
|
||||
- <a href="doc/asyncworker.md#api_nan_async_worker"><b><code>Nan::AsyncWorker</code></b></a>
|
||||
- <a href="doc/asyncworker.md#api_nan_async_progress_worker"><b><code>Nan::AsyncProgressWorkerBase & Nan::AsyncProgressWorker</code></b></a>
|
||||
- <a href="doc/asyncworker.md#api_nan_async_progress_queue_worker"><b><code>Nan::AsyncProgressQueueWorker</code></b></a>
|
||||
- <a href="doc/asyncworker.md#api_nan_async_queue_worker"><b><code>Nan::AsyncQueueWorker</code></b></a>
|
||||
|
||||
### Strings & Bytes
|
||||
|
||||
Miscellaneous string & byte encoding and decoding functionality provided for compatibility across supported versions of V8 and Node. Implemented by NAN to ensure that all encoding types are supported, even for older versions of Node where they are missing.
|
||||
|
||||
- <a href="doc/string_bytes.md#api_nan_encoding"><b><code>Nan::Encoding</code></b></a>
|
||||
- <a href="doc/string_bytes.md#api_nan_encode"><b><code>Nan::Encode()</code></b></a>
|
||||
- <a href="doc/string_bytes.md#api_nan_try_encode"><b><code>Nan::TryEncode()</code></b></a>
|
||||
- <a href="doc/string_bytes.md#api_nan_decode_bytes"><b><code>Nan::DecodeBytes()</code></b></a>
|
||||
- <a href="doc/string_bytes.md#api_nan_decode_write"><b><code>Nan::DecodeWrite()</code></b></a>
|
||||
|
||||
|
||||
### Object Wrappers
|
||||
|
||||
The `ObjectWrap` class can be used to make wrapped C++ objects and a factory of wrapped objects.
|
||||
|
||||
- <a href="doc/object_wrappers.md#api_nan_object_wrap"><b><code>Nan::ObjectWrap</code></b></a>
|
||||
|
||||
|
||||
### V8 internals
|
||||
|
||||
The hooks to access V8 internals—including GC and statistics—are different across the supported versions of V8, therefore NAN provides its own hooks that call the appropriate V8 methods.
|
||||
|
||||
- <a href="doc/v8_internals.md#api_nan_gc_callback"><b><code>NAN_GC_CALLBACK()</code></b></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_add_gc_epilogue_callback"><b><code>Nan::AddGCEpilogueCallback()</code></b></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_remove_gc_epilogue_callback"><b><code>Nan::RemoveGCEpilogueCallback()</code></b></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_add_gc_prologue_callback"><b><code>Nan::AddGCPrologueCallback()</code></b></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_remove_gc_prologue_callback"><b><code>Nan::RemoveGCPrologueCallback()</code></b></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_get_heap_statistics"><b><code>Nan::GetHeapStatistics()</code></b></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_set_counter_function"><b><code>Nan::SetCounterFunction()</code></b></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_set_create_histogram_function"><b><code>Nan::SetCreateHistogramFunction()</code></b></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_set_add_histogram_sample_function"><b><code>Nan::SetAddHistogramSampleFunction()</code></b></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_idle_notification"><del><b><code>Nan::IdleNotification()</code></b></del></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_low_memory_notification"><b><code>Nan::LowMemoryNotification()</code></b></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_context_disposed_notification"><b><code>Nan::ContextDisposedNotification()</code></b></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_get_internal_field_pointer"><b><code>Nan::GetInternalFieldPointer()</code></b></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_set_internal_field_pointer"><b><code>Nan::SetInternalFieldPointer()</code></b></a>
|
||||
- <a href="doc/v8_internals.md#api_nan_adjust_external_memory"><b><code>Nan::AdjustExternalMemory()</code></b></a>
|
||||
|
||||
|
||||
### Miscellaneous V8 Helpers
|
||||
|
||||
- <a href="doc/v8_misc.md#api_nan_utf8_string"><b><code>Nan::Utf8String</code></b></a>
|
||||
- <a href="doc/v8_misc.md#api_nan_get_current_context"><b><code>Nan::GetCurrentContext()</code></b></a>
|
||||
- <a href="doc/v8_misc.md#api_nan_set_isolate_data"><b><code>Nan::SetIsolateData()</code></b></a>
|
||||
- <a href="doc/v8_misc.md#api_nan_get_isolate_data"><b><code>Nan::GetIsolateData()</code></b></a>
|
||||
- <a href="doc/v8_misc.md#api_nan_typedarray_contents"><b><code>Nan::TypedArrayContents</code></b></a>
|
||||
|
||||
|
||||
### Miscellaneous Node Helpers
|
||||
|
||||
- <a href="doc/node_misc.md#api_nan_asyncresource"><b><code>Nan::AsyncResource</code></b></a>
|
||||
- <a href="doc/node_misc.md#api_nan_make_callback"><b><code>Nan::MakeCallback()</code></b></a>
|
||||
- <a href="doc/node_misc.md#api_nan_module_init"><b><code>NAN_MODULE_INIT()</code></b></a>
|
||||
- <a href="doc/node_misc.md#api_nan_export"><b><code>Nan::Export()</code></b></a>
|
||||
|
||||
<!-- END API -->
|
||||
|
||||
|
||||
<a name="tests"></a>
|
||||
|
||||
### Tests
|
||||
|
||||
To run the NAN tests do:
|
||||
|
||||
``` sh
|
||||
npm install
|
||||
npm run-script rebuild-tests
|
||||
npm test
|
||||
```
|
||||
|
||||
Or just:
|
||||
|
||||
``` sh
|
||||
npm install
|
||||
make test
|
||||
```
|
||||
|
||||
<a name="issues"></a>
|
||||
|
||||
## Known issues
|
||||
|
||||
### Compiling against Node.js 0.12 on OSX
|
||||
|
||||
With new enough compilers available on OSX, the versions of V8 headers corresponding to Node.js 0.12
|
||||
do not compile anymore. The error looks something like:
|
||||
|
||||
```
|
||||
❯ CXX(target) Release/obj.target/accessors/cpp/accessors.o
|
||||
In file included from ../cpp/accessors.cpp:9:
|
||||
In file included from ../../nan.h:51:
|
||||
In file included from /Users/ofrobots/.node-gyp/0.12.18/include/node/node.h:61:
|
||||
/Users/ofrobots/.node-gyp/0.12.18/include/node/v8.h:5800:54: error: 'CreateHandle' is a protected member of 'v8::HandleScope'
|
||||
return Handle<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
|
||||
~~~~~~~~~~~~~^~~~~~~~~~~~
|
||||
```
|
||||
|
||||
This can be worked around by patching your local versions of v8.h corresponding to Node 0.12 to make
|
||||
`v8::Handle` a friend of `v8::HandleScope`. Since neither Node.js not V8 support this release line anymore
|
||||
this patch cannot be released by either project in an official release.
|
||||
|
||||
For this reason, we do not test against Node.js 0.12 on OSX in this project's CI. If you need to support
|
||||
that configuration, you will need to either get an older compiler, or apply a source patch to the version
|
||||
of V8 headers as a workaround.
|
||||
|
||||
<a name="governance"></a>
|
||||
|
||||
## Governance & Contributing
|
||||
|
||||
NAN is governed by the [Node.js Addon API Working Group](https://github.com/nodejs/CTC/blob/master/WORKING_GROUPS.md#addon-api)
|
||||
|
||||
### Addon API Working Group (WG)
|
||||
|
||||
The NAN project is jointly governed by a Working Group which is responsible for high-level guidance of the project.
|
||||
|
||||
Members of the WG are also known as Collaborators, there is no distinction between the two, unlike other Node.js projects.
|
||||
|
||||
The WG has final authority over this project including:
|
||||
|
||||
* Technical direction
|
||||
* Project governance and process (including this policy)
|
||||
* Contribution policy
|
||||
* GitHub repository hosting
|
||||
* Maintaining the list of additional Collaborators
|
||||
|
||||
For the current list of WG members, see the project [README.md](./README.md#collaborators).
|
||||
|
||||
Individuals making significant and valuable contributions are made members of the WG and given commit-access to the project. These individuals are identified by the WG and their addition to the WG is discussed via GitHub and requires unanimous consensus amongst those WG members participating in the discussion with a quorum of 50% of WG members required for acceptance of the vote.
|
||||
|
||||
_Note:_ If you make a significant contribution and are not considered for commit-access log an issue or contact a WG member directly.
|
||||
|
||||
For the current list of WG members / Collaborators, see the project [README.md](./README.md#collaborators).
|
||||
|
||||
### Consensus Seeking Process
|
||||
|
||||
The WG follows a [Consensus Seeking](https://en.wikipedia.org/wiki/Consensus-seeking_decision-making) decision making model.
|
||||
|
||||
Modifications of the contents of the NAN repository are made on a collaborative basis. Anybody with a GitHub account may propose a modification via pull request and it will be considered by the WG. All pull requests must be reviewed and accepted by a WG member with sufficient expertise who is able to take full responsibility for the change. In the case of pull requests proposed by an existing WG member, an additional WG member is required for sign-off. Consensus should be sought if additional WG members participate and there is disagreement around a particular modification.
|
||||
|
||||
If a change proposal cannot reach a consensus, a WG member can call for a vote amongst the members of the WG. Simple majority wins.
|
||||
|
||||
<a id="developers-certificate-of-origin"></a>
|
||||
|
||||
## Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
* (a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the open source license
|
||||
indicated in the file; or
|
||||
|
||||
* (b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the same open source license (unless I am
|
||||
permitted to submit under a different license), as indicated
|
||||
in the file; or
|
||||
|
||||
* (c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
* (d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it, including my sign-off) is
|
||||
maintained indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
||||
|
||||
<a name="collaborators"></a>
|
||||
|
||||
### WG Members / Collaborators
|
||||
|
||||
<table><tbody>
|
||||
<tr><th align="left">Rod Vagg</th><td><a href="https://github.com/rvagg">GitHub/rvagg</a></td><td><a href="http://twitter.com/rvagg">Twitter/@rvagg</a></td></tr>
|
||||
<tr><th align="left">Benjamin Byholm</th><td><a href="https://github.com/kkoopa/">GitHub/kkoopa</a></td><td>-</td></tr>
|
||||
<tr><th align="left">Trevor Norris</th><td><a href="https://github.com/trevnorris">GitHub/trevnorris</a></td><td><a href="http://twitter.com/trevnorris">Twitter/@trevnorris</a></td></tr>
|
||||
<tr><th align="left">Nathan Rajlich</th><td><a href="https://github.com/TooTallNate">GitHub/TooTallNate</a></td><td><a href="http://twitter.com/TooTallNate">Twitter/@TooTallNate</a></td></tr>
|
||||
<tr><th align="left">Brett Lawson</th><td><a href="https://github.com/brett19">GitHub/brett19</a></td><td><a href="http://twitter.com/brett19x">Twitter/@brett19x</a></td></tr>
|
||||
<tr><th align="left">Ben Noordhuis</th><td><a href="https://github.com/bnoordhuis">GitHub/bnoordhuis</a></td><td><a href="http://twitter.com/bnoordhuis">Twitter/@bnoordhuis</a></td></tr>
|
||||
<tr><th align="left">David Siegel</th><td><a href="https://github.com/agnat">GitHub/agnat</a></td><td><a href="http://twitter.com/agnat">Twitter/@agnat</a></td></tr>
|
||||
<tr><th align="left">Michael Ira Krufky</th><td><a href="https://github.com/mkrufky">GitHub/mkrufky</a></td><td><a href="http://twitter.com/mkrufky">Twitter/@mkrufky</a></td></tr>
|
||||
</tbody></table>
|
||||
|
||||
## Licence & copyright
|
||||
|
||||
Copyright (c) 2018 NAN WG Members / Collaborators (listed above).
|
||||
|
||||
Native Abstractions for Node.js is licensed under an MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
|
||||
146
tasks/enduro-trails/prototype/node_modules/nan/doc/asyncworker.md
generated
vendored
Normal file
146
tasks/enduro-trails/prototype/node_modules/nan/doc/asyncworker.md
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
## Asynchronous work helpers
|
||||
|
||||
`Nan::AsyncWorker`, `Nan::AsyncProgressWorker` and `Nan::AsyncProgressQueueWorker` are helper classes that make working with asynchronous code easier.
|
||||
|
||||
- <a href="#api_nan_async_worker"><b><code>Nan::AsyncWorker</code></b></a>
|
||||
- <a href="#api_nan_async_progress_worker"><b><code>Nan::AsyncProgressWorkerBase & Nan::AsyncProgressWorker</code></b></a>
|
||||
- <a href="#api_nan_async_progress_queue_worker"><b><code>Nan::AsyncProgressQueueWorker</code></b></a>
|
||||
- <a href="#api_nan_async_queue_worker"><b><code>Nan::AsyncQueueWorker</code></b></a>
|
||||
|
||||
<a name="api_nan_async_worker"></a>
|
||||
### Nan::AsyncWorker
|
||||
|
||||
`Nan::AsyncWorker` is an _abstract_ class that you can subclass to have much of the annoying asynchronous queuing and handling taken care of for you. It can even store arbitrary V8 objects for you and have them persist while the asynchronous work is in progress.
|
||||
|
||||
This class internally handles the details of creating an [`AsyncResource`][AsyncResource], and running the callback in the
|
||||
correct async context. To be able to identify the async resources created by this class in async-hooks, provide a
|
||||
`resource_name` to the constructor. It is recommended that the module name be used as a prefix to the `resource_name` to avoid
|
||||
collisions in the names. For more details see [`AsyncResource`][AsyncResource] documentation. The `resource_name` needs to stay valid for the lifetime of the worker instance.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
class AsyncWorker {
|
||||
public:
|
||||
explicit AsyncWorker(Callback *callback_, const char* resource_name = "nan:AsyncWorker");
|
||||
|
||||
virtual ~AsyncWorker();
|
||||
|
||||
virtual void WorkComplete();
|
||||
|
||||
void SaveToPersistent(const char *key, const v8::Local<v8::Value> &value);
|
||||
|
||||
void SaveToPersistent(const v8::Local<v8::String> &key,
|
||||
const v8::Local<v8::Value> &value);
|
||||
|
||||
void SaveToPersistent(uint32_t index,
|
||||
const v8::Local<v8::Value> &value);
|
||||
|
||||
v8::Local<v8::Value> GetFromPersistent(const char *key) const;
|
||||
|
||||
v8::Local<v8::Value> GetFromPersistent(const v8::Local<v8::String> &key) const;
|
||||
|
||||
v8::Local<v8::Value> GetFromPersistent(uint32_t index) const;
|
||||
|
||||
virtual void Execute() = 0;
|
||||
|
||||
uv_work_t request;
|
||||
|
||||
virtual void Destroy();
|
||||
|
||||
protected:
|
||||
Persistent<v8::Object> persistentHandle;
|
||||
|
||||
Callback *callback;
|
||||
|
||||
virtual void HandleOKCallback();
|
||||
|
||||
virtual void HandleErrorCallback();
|
||||
|
||||
void SetErrorMessage(const char *msg);
|
||||
|
||||
const char* ErrorMessage();
|
||||
};
|
||||
```
|
||||
|
||||
<a name="api_nan_async_progress_worker"></a>
|
||||
### Nan::AsyncProgressWorkerBase & Nan::AsyncProgressWorker
|
||||
|
||||
`Nan::AsyncProgressWorkerBase` is an _abstract_ class template that extends `Nan::AsyncWorker` and adds additional progress reporting callbacks that can be used during the asynchronous work execution to provide progress data back to JavaScript.
|
||||
|
||||
Previously the definition of `Nan::AsyncProgressWorker` only allowed sending `const char` data. Now extending `Nan::AsyncProgressWorker` will yield an instance of the implicit `Nan::AsyncProgressWorkerBase` template with type `<char>` for compatibility.
|
||||
|
||||
`Nan::AsyncProgressWorkerBase` & `Nan::AsyncProgressWorker` is intended for best-effort delivery of nonessential progress messages, e.g. a progress bar. The last event sent before the main thread is woken will be delivered.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
template<class T>
|
||||
class AsyncProgressWorkerBase<T> : public AsyncWorker {
|
||||
public:
|
||||
explicit AsyncProgressWorkerBase(Callback *callback_, const char* resource_name = ...);
|
||||
|
||||
virtual ~AsyncProgressWorkerBase();
|
||||
|
||||
void WorkProgress();
|
||||
|
||||
class ExecutionProgress {
|
||||
public:
|
||||
void Signal() const;
|
||||
void Send(const T* data, size_t count) const;
|
||||
};
|
||||
|
||||
virtual void Execute(const ExecutionProgress& progress) = 0;
|
||||
|
||||
virtual void HandleProgressCallback(const T *data, size_t count) = 0;
|
||||
|
||||
virtual void Destroy();
|
||||
};
|
||||
|
||||
typedef AsyncProgressWorkerBase<T> AsyncProgressWorker;
|
||||
```
|
||||
|
||||
<a name="api_nan_async_progress_queue_worker"></a>
|
||||
### Nan::AsyncProgressQueueWorker
|
||||
|
||||
`Nan::AsyncProgressQueueWorker` is an _abstract_ class template that extends `Nan::AsyncWorker` and adds additional progress reporting callbacks that can be used during the asynchronous work execution to provide progress data back to JavaScript.
|
||||
|
||||
`Nan::AsyncProgressQueueWorker` behaves exactly the same as `Nan::AsyncProgressWorker`, except all events are queued and delivered to the main thread.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
template<class T>
|
||||
class AsyncProgressQueueWorker<T> : public AsyncWorker {
|
||||
public:
|
||||
explicit AsyncProgressQueueWorker(Callback *callback_, const char* resource_name = "nan:AsyncProgressQueueWorker");
|
||||
|
||||
virtual ~AsyncProgressQueueWorker();
|
||||
|
||||
void WorkProgress();
|
||||
|
||||
class ExecutionProgress {
|
||||
public:
|
||||
void Send(const T* data, size_t count) const;
|
||||
};
|
||||
|
||||
virtual void Execute(const ExecutionProgress& progress) = 0;
|
||||
|
||||
virtual void HandleProgressCallback(const T *data, size_t count) = 0;
|
||||
|
||||
virtual void Destroy();
|
||||
};
|
||||
```
|
||||
|
||||
<a name="api_nan_async_queue_worker"></a>
|
||||
### Nan::AsyncQueueWorker
|
||||
|
||||
`Nan::AsyncQueueWorker` will run a `Nan::AsyncWorker` asynchronously via libuv. Both the `execute` and `after_work` steps are taken care of for you. Most of the logic for this is embedded in `Nan::AsyncWorker`.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
void AsyncQueueWorker(AsyncWorker *);
|
||||
```
|
||||
|
||||
[AsyncResource]: node_misc.md#api_nan_asyncresource
|
||||
54
tasks/enduro-trails/prototype/node_modules/nan/doc/buffers.md
generated
vendored
Normal file
54
tasks/enduro-trails/prototype/node_modules/nan/doc/buffers.md
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
## Buffers
|
||||
|
||||
NAN's `node::Buffer` helpers exist as the API has changed across supported Node versions. Use these methods to ensure compatibility.
|
||||
|
||||
- <a href="#api_nan_new_buffer"><b><code>Nan::NewBuffer()</code></b></a>
|
||||
- <a href="#api_nan_copy_buffer"><b><code>Nan::CopyBuffer()</code></b></a>
|
||||
- <a href="#api_nan_free_callback"><b><code>Nan::FreeCallback()</code></b></a>
|
||||
|
||||
<a name="api_nan_new_buffer"></a>
|
||||
### Nan::NewBuffer()
|
||||
|
||||
Allocate a new `node::Buffer` object with the specified size and optional data. Calls `node::Buffer::New()`.
|
||||
|
||||
Note that when creating a `Buffer` using `Nan::NewBuffer()` and an existing `char*`, it is assumed that the ownership of the pointer is being transferred to the new `Buffer` for management.
|
||||
When a `node::Buffer` instance is garbage collected and a `FreeCallback` has not been specified, `data` will be disposed of via a call to `free()`.
|
||||
You _must not_ free the memory space manually once you have created a `Buffer` in this way.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Object> Nan::NewBuffer(uint32_t size)
|
||||
Nan::MaybeLocal<v8::Object> Nan::NewBuffer(char* data, uint32_t size)
|
||||
Nan::MaybeLocal<v8::Object> Nan::NewBuffer(char *data,
|
||||
size_t length,
|
||||
Nan::FreeCallback callback,
|
||||
void *hint)
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_copy_buffer"></a>
|
||||
### Nan::CopyBuffer()
|
||||
|
||||
Similar to [`Nan::NewBuffer()`](#api_nan_new_buffer) except that an implicit memcpy will occur within Node. Calls `node::Buffer::Copy()`.
|
||||
|
||||
Management of the `char*` is left to the user, you should manually free the memory space if necessary as the new `Buffer` will have its own copy.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Object> Nan::CopyBuffer(const char *data, uint32_t size)
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_free_callback"></a>
|
||||
### Nan::FreeCallback()
|
||||
|
||||
A free callback that can be provided to [`Nan::NewBuffer()`](#api_nan_new_buffer).
|
||||
The supplied callback will be invoked when the `Buffer` undergoes garbage collection.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
typedef void (*FreeCallback)(char *data, void *hint);
|
||||
```
|
||||
76
tasks/enduro-trails/prototype/node_modules/nan/doc/callback.md
generated
vendored
Normal file
76
tasks/enduro-trails/prototype/node_modules/nan/doc/callback.md
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
## Nan::Callback
|
||||
|
||||
`Nan::Callback` makes it easier to use `v8::Function` handles as callbacks. A class that wraps a `v8::Function` handle, protecting it from garbage collection and making it particularly useful for storage and use across asynchronous execution.
|
||||
|
||||
- <a href="#api_nan_callback"><b><code>Nan::Callback</code></b></a>
|
||||
|
||||
<a name="api_nan_callback"></a>
|
||||
### Nan::Callback
|
||||
|
||||
```c++
|
||||
class Callback {
|
||||
public:
|
||||
Callback();
|
||||
|
||||
explicit Callback(const v8::Local<v8::Function> &fn);
|
||||
|
||||
~Callback();
|
||||
|
||||
bool operator==(const Callback &other) const;
|
||||
|
||||
bool operator!=(const Callback &other) const;
|
||||
|
||||
v8::Local<v8::Function> operator*() const;
|
||||
|
||||
MaybeLocal<v8::Value> operator()(AsyncResource* async_resource,
|
||||
v8::Local<v8::Object> target,
|
||||
int argc = 0,
|
||||
v8::Local<v8::Value> argv[] = 0) const;
|
||||
|
||||
MaybeLocal<v8::Value> operator()(AsyncResource* async_resource,
|
||||
int argc = 0,
|
||||
v8::Local<v8::Value> argv[] = 0) const;
|
||||
|
||||
void SetFunction(const v8::Local<v8::Function> &fn);
|
||||
|
||||
v8::Local<v8::Function> GetFunction() const;
|
||||
|
||||
bool IsEmpty() const;
|
||||
|
||||
void Reset(const v8::Local<v8::Function> &fn);
|
||||
|
||||
void Reset();
|
||||
|
||||
MaybeLocal<v8::Value> Call(v8::Local<v8::Object> target,
|
||||
int argc,
|
||||
v8::Local<v8::Value> argv[],
|
||||
AsyncResource* async_resource) const;
|
||||
MaybeLocal<v8::Value> Call(int argc,
|
||||
v8::Local<v8::Value> argv[],
|
||||
AsyncResource* async_resource) const;
|
||||
|
||||
// Deprecated versions. Use the versions that accept an async_resource instead
|
||||
// as they run the callback in the correct async context as specified by the
|
||||
// resource. If you want to call a synchronous JS function (i.e. on a
|
||||
// non-empty JS stack), you can use Nan::Call instead.
|
||||
v8::Local<v8::Value> operator()(v8::Local<v8::Object> target,
|
||||
int argc = 0,
|
||||
v8::Local<v8::Value> argv[] = 0) const;
|
||||
|
||||
v8::Local<v8::Value> operator()(int argc = 0,
|
||||
v8::Local<v8::Value> argv[] = 0) const;
|
||||
v8::Local<v8::Value> Call(v8::Local<v8::Object> target,
|
||||
int argc,
|
||||
v8::Local<v8::Value> argv[]) const;
|
||||
|
||||
v8::Local<v8::Value> Call(int argc, v8::Local<v8::Value> argv[]) const;
|
||||
};
|
||||
```
|
||||
|
||||
Example usage:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Function> function;
|
||||
Nan::Callback callback(function);
|
||||
callback.Call(0, 0);
|
||||
```
|
||||
41
tasks/enduro-trails/prototype/node_modules/nan/doc/converters.md
generated
vendored
Normal file
41
tasks/enduro-trails/prototype/node_modules/nan/doc/converters.md
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
## Converters
|
||||
|
||||
NAN contains functions that convert `v8::Value`s to other `v8::Value` types and native types. Since type conversion is not guaranteed to succeed, they return `Nan::Maybe` types. These converters can be used in place of `value->ToX()` and `value->XValue()` (where `X` is one of the types, e.g. `Boolean`) in a way that provides a consistent interface across V8 versions. Newer versions of V8 use the new `v8::Maybe` and `v8::MaybeLocal` types for these conversions, older versions don't have this functionality so it is provided by NAN.
|
||||
|
||||
- <a href="#api_nan_to"><b><code>Nan::To()</code></b></a>
|
||||
|
||||
<a name="api_nan_to"></a>
|
||||
### Nan::To()
|
||||
|
||||
Converts a `v8::Local<v8::Value>` to a different subtype of `v8::Value` or to a native data type. Returns a `Nan::MaybeLocal<>` or a `Nan::Maybe<>` accordingly.
|
||||
|
||||
See [maybe_types.md](./maybe_types.md) for more information on `Nan::Maybe` types.
|
||||
|
||||
Signatures:
|
||||
|
||||
```c++
|
||||
// V8 types
|
||||
Nan::MaybeLocal<v8::Boolean> Nan::To<v8::Boolean>(v8::Local<v8::Value> val);
|
||||
Nan::MaybeLocal<v8::Int32> Nan::To<v8::Int32>(v8::Local<v8::Value> val);
|
||||
Nan::MaybeLocal<v8::Integer> Nan::To<v8::Integer>(v8::Local<v8::Value> val);
|
||||
Nan::MaybeLocal<v8::Object> Nan::To<v8::Object>(v8::Local<v8::Value> val);
|
||||
Nan::MaybeLocal<v8::Number> Nan::To<v8::Number>(v8::Local<v8::Value> val);
|
||||
Nan::MaybeLocal<v8::String> Nan::To<v8::String>(v8::Local<v8::Value> val);
|
||||
Nan::MaybeLocal<v8::Uint32> Nan::To<v8::Uint32>(v8::Local<v8::Value> val);
|
||||
|
||||
// Native types
|
||||
Nan::Maybe<bool> Nan::To<bool>(v8::Local<v8::Value> val);
|
||||
Nan::Maybe<double> Nan::To<double>(v8::Local<v8::Value> val);
|
||||
Nan::Maybe<int32_t> Nan::To<int32_t>(v8::Local<v8::Value> val);
|
||||
Nan::Maybe<int64_t> Nan::To<int64_t>(v8::Local<v8::Value> val);
|
||||
Nan::Maybe<uint32_t> Nan::To<uint32_t>(v8::Local<v8::Value> val);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Value> val;
|
||||
Nan::MaybeLocal<v8::String> str = Nan::To<v8::String>(val);
|
||||
Nan::Maybe<double> d = Nan::To<double>(val);
|
||||
```
|
||||
|
||||
226
tasks/enduro-trails/prototype/node_modules/nan/doc/errors.md
generated
vendored
Normal file
226
tasks/enduro-trails/prototype/node_modules/nan/doc/errors.md
generated
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
## Errors
|
||||
|
||||
NAN includes helpers for creating, throwing and catching Errors as much of this functionality varies across the supported versions of V8 and must be abstracted.
|
||||
|
||||
Note that an Error object is simply a specialized form of `v8::Value`.
|
||||
|
||||
Also consult the V8 Embedders Guide section on [Exceptions](https://v8.dev/docs/embed#exceptions) for more information.
|
||||
|
||||
- <a href="#api_nan_error"><b><code>Nan::Error()</code></b></a>
|
||||
- <a href="#api_nan_range_error"><b><code>Nan::RangeError()</code></b></a>
|
||||
- <a href="#api_nan_reference_error"><b><code>Nan::ReferenceError()</code></b></a>
|
||||
- <a href="#api_nan_syntax_error"><b><code>Nan::SyntaxError()</code></b></a>
|
||||
- <a href="#api_nan_type_error"><b><code>Nan::TypeError()</code></b></a>
|
||||
- <a href="#api_nan_throw_error"><b><code>Nan::ThrowError()</code></b></a>
|
||||
- <a href="#api_nan_throw_range_error"><b><code>Nan::ThrowRangeError()</code></b></a>
|
||||
- <a href="#api_nan_throw_reference_error"><b><code>Nan::ThrowReferenceError()</code></b></a>
|
||||
- <a href="#api_nan_throw_syntax_error"><b><code>Nan::ThrowSyntaxError()</code></b></a>
|
||||
- <a href="#api_nan_throw_type_error"><b><code>Nan::ThrowTypeError()</code></b></a>
|
||||
- <a href="#api_nan_fatal_exception"><b><code>Nan::FatalException()</code></b></a>
|
||||
- <a href="#api_nan_errno_exception"><b><code>Nan::ErrnoException()</code></b></a>
|
||||
- <a href="#api_nan_try_catch"><b><code>Nan::TryCatch</code></b></a>
|
||||
|
||||
|
||||
<a name="api_nan_error"></a>
|
||||
### Nan::Error()
|
||||
|
||||
Create a new Error object using the [v8::Exception](https://v8docs.nodesource.com/node-8.16/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
|
||||
|
||||
Note that an Error object is simply a specialized form of `v8::Value`.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Value> Nan::Error(const char *msg);
|
||||
v8::Local<v8::Value> Nan::Error(v8::Local<v8::String> msg);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_range_error"></a>
|
||||
### Nan::RangeError()
|
||||
|
||||
Create a new RangeError object using the [v8::Exception](https://v8docs.nodesource.com/node-8.16/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
|
||||
|
||||
Note that an RangeError object is simply a specialized form of `v8::Value`.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Value> Nan::RangeError(const char *msg);
|
||||
v8::Local<v8::Value> Nan::RangeError(v8::Local<v8::String> msg);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_reference_error"></a>
|
||||
### Nan::ReferenceError()
|
||||
|
||||
Create a new ReferenceError object using the [v8::Exception](https://v8docs.nodesource.com/node-8.16/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
|
||||
|
||||
Note that an ReferenceError object is simply a specialized form of `v8::Value`.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Value> Nan::ReferenceError(const char *msg);
|
||||
v8::Local<v8::Value> Nan::ReferenceError(v8::Local<v8::String> msg);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_syntax_error"></a>
|
||||
### Nan::SyntaxError()
|
||||
|
||||
Create a new SyntaxError object using the [v8::Exception](https://v8docs.nodesource.com/node-8.16/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
|
||||
|
||||
Note that an SyntaxError object is simply a specialized form of `v8::Value`.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Value> Nan::SyntaxError(const char *msg);
|
||||
v8::Local<v8::Value> Nan::SyntaxError(v8::Local<v8::String> msg);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_type_error"></a>
|
||||
### Nan::TypeError()
|
||||
|
||||
Create a new TypeError object using the [v8::Exception](https://v8docs.nodesource.com/node-8.16/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
|
||||
|
||||
Note that an TypeError object is simply a specialized form of `v8::Value`.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Value> Nan::TypeError(const char *msg);
|
||||
v8::Local<v8::Value> Nan::TypeError(v8::Local<v8::String> msg);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_throw_error"></a>
|
||||
### Nan::ThrowError()
|
||||
|
||||
Throw an Error object (a specialized `v8::Value` as above) in the current context. If a `msg` is provided, a new Error object will be created.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::ThrowError(const char *msg);
|
||||
void Nan::ThrowError(v8::Local<v8::String> msg);
|
||||
void Nan::ThrowError(v8::Local<v8::Value> error);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_throw_range_error"></a>
|
||||
### Nan::ThrowRangeError()
|
||||
|
||||
Throw an RangeError object (a specialized `v8::Value` as above) in the current context. If a `msg` is provided, a new RangeError object will be created.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::ThrowRangeError(const char *msg);
|
||||
void Nan::ThrowRangeError(v8::Local<v8::String> msg);
|
||||
void Nan::ThrowRangeError(v8::Local<v8::Value> error);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_throw_reference_error"></a>
|
||||
### Nan::ThrowReferenceError()
|
||||
|
||||
Throw an ReferenceError object (a specialized `v8::Value` as above) in the current context. If a `msg` is provided, a new ReferenceError object will be created.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::ThrowReferenceError(const char *msg);
|
||||
void Nan::ThrowReferenceError(v8::Local<v8::String> msg);
|
||||
void Nan::ThrowReferenceError(v8::Local<v8::Value> error);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_throw_syntax_error"></a>
|
||||
### Nan::ThrowSyntaxError()
|
||||
|
||||
Throw an SyntaxError object (a specialized `v8::Value` as above) in the current context. If a `msg` is provided, a new SyntaxError object will be created.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::ThrowSyntaxError(const char *msg);
|
||||
void Nan::ThrowSyntaxError(v8::Local<v8::String> msg);
|
||||
void Nan::ThrowSyntaxError(v8::Local<v8::Value> error);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_throw_type_error"></a>
|
||||
### Nan::ThrowTypeError()
|
||||
|
||||
Throw an TypeError object (a specialized `v8::Value` as above) in the current context. If a `msg` is provided, a new TypeError object will be created.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::ThrowTypeError(const char *msg);
|
||||
void Nan::ThrowTypeError(v8::Local<v8::String> msg);
|
||||
void Nan::ThrowTypeError(v8::Local<v8::Value> error);
|
||||
```
|
||||
|
||||
<a name="api_nan_fatal_exception"></a>
|
||||
### Nan::FatalException()
|
||||
|
||||
Replaces `node::FatalException()` which has a different API across supported versions of Node. For use with [`Nan::TryCatch`](#api_nan_try_catch).
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::FatalException(const Nan::TryCatch& try_catch);
|
||||
```
|
||||
|
||||
<a name="api_nan_errno_exception"></a>
|
||||
### Nan::ErrnoException()
|
||||
|
||||
Replaces `node::ErrnoException()` which has a different API across supported versions of Node.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Value> Nan::ErrnoException(int errorno,
|
||||
const char* syscall = NULL,
|
||||
const char* message = NULL,
|
||||
const char* path = NULL);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_try_catch"></a>
|
||||
### Nan::TryCatch
|
||||
|
||||
A simple wrapper around [`v8::TryCatch`](https://v8docs.nodesource.com/node-8.16/d4/dc6/classv8_1_1_try_catch.html) compatible with all supported versions of V8. Can be used as a direct replacement in most cases. See also [`Nan::FatalException()`](#api_nan_fatal_exception) for an internal use compatible with `node::FatalException`.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
class Nan::TryCatch {
|
||||
public:
|
||||
Nan::TryCatch();
|
||||
|
||||
bool HasCaught() const;
|
||||
|
||||
bool CanContinue() const;
|
||||
|
||||
v8::Local<v8::Value> ReThrow();
|
||||
|
||||
v8::Local<v8::Value> Exception() const;
|
||||
|
||||
// Nan::MaybeLocal for older versions of V8
|
||||
v8::MaybeLocal<v8::Value> StackTrace() const;
|
||||
|
||||
v8::Local<v8::Message> Message() const;
|
||||
|
||||
void Reset();
|
||||
|
||||
void SetVerbose(bool value);
|
||||
|
||||
void SetCaptureMessage(bool value);
|
||||
};
|
||||
```
|
||||
|
||||
62
tasks/enduro-trails/prototype/node_modules/nan/doc/json.md
generated
vendored
Normal file
62
tasks/enduro-trails/prototype/node_modules/nan/doc/json.md
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
## JSON
|
||||
|
||||
The _JSON_ object provides the C++ versions of the methods offered by the `JSON` object in javascript. V8 exposes these methods via the `v8::JSON` object.
|
||||
|
||||
- <a href="#api_nan_json_parse"><b><code>Nan::JSON.Parse</code></b></a>
|
||||
- <a href="#api_nan_json_stringify"><b><code>Nan::JSON.Stringify</code></b></a>
|
||||
|
||||
Refer to the V8 JSON object in the [V8 documentation](https://v8docs.nodesource.com/node-8.16/da/d6f/classv8_1_1_j_s_o_n.html) for more information about these methods and their arguments.
|
||||
|
||||
<a name="api_nan_json_parse"></a>
|
||||
|
||||
### Nan::JSON.Parse
|
||||
|
||||
A simple wrapper around [`v8::JSON::Parse`](https://v8docs.nodesource.com/node-8.16/da/d6f/classv8_1_1_j_s_o_n.html#a936310d2540fb630ed37d3ee3ffe4504).
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Value> Nan::JSON::Parse(v8::Local<v8::String> json_string);
|
||||
```
|
||||
|
||||
Use `JSON.Parse(json_string)` to parse a string into a `v8::Value`.
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::String> json_string = Nan::New("{ \"JSON\": \"object\" }").ToLocalChecked();
|
||||
|
||||
Nan::JSON NanJSON;
|
||||
Nan::MaybeLocal<v8::Value> result = NanJSON.Parse(json_string);
|
||||
if (!result.IsEmpty()) {
|
||||
v8::Local<v8::Value> val = result.ToLocalChecked();
|
||||
}
|
||||
```
|
||||
|
||||
<a name="api_nan_json_stringify"></a>
|
||||
|
||||
### Nan::JSON.Stringify
|
||||
|
||||
A simple wrapper around [`v8::JSON::Stringify`](https://v8docs.nodesource.com/node-8.16/da/d6f/classv8_1_1_j_s_o_n.html#a44b255c3531489ce43f6110209138860).
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::String> Nan::JSON::Stringify(v8::Local<v8::Object> json_object, v8::Local<v8::String> gap = v8::Local<v8::String>());
|
||||
```
|
||||
|
||||
Use `JSON.Stringify(value)` to stringify a `v8::Object`.
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
// using `v8::Local<v8::Value> val` from the `JSON::Parse` example
|
||||
v8::Local<v8::Object> obj = Nan::To<v8::Object>(val).ToLocalChecked();
|
||||
|
||||
Nan::JSON NanJSON;
|
||||
Nan::MaybeLocal<v8::String> result = NanJSON.Stringify(obj);
|
||||
if (!result.IsEmpty()) {
|
||||
v8::Local<v8::String> stringified = result.ToLocalChecked();
|
||||
}
|
||||
```
|
||||
|
||||
583
tasks/enduro-trails/prototype/node_modules/nan/doc/maybe_types.md
generated
vendored
Normal file
583
tasks/enduro-trails/prototype/node_modules/nan/doc/maybe_types.md
generated
vendored
Normal file
@@ -0,0 +1,583 @@
|
||||
## Maybe Types
|
||||
|
||||
The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Local` handles that _may be empty_.
|
||||
|
||||
* **Maybe Types**
|
||||
- <a href="#api_nan_maybe_local"><b><code>Nan::MaybeLocal</code></b></a>
|
||||
- <a href="#api_nan_maybe"><b><code>Nan::Maybe</code></b></a>
|
||||
- <a href="#api_nan_nothing"><b><code>Nan::Nothing</code></b></a>
|
||||
- <a href="#api_nan_just"><b><code>Nan::Just</code></b></a>
|
||||
* **Maybe Helpers**
|
||||
- <a href="#api_nan_call"><b><code>Nan::Call()</code></b></a>
|
||||
- <a href="#api_nan_to_detail_string"><b><code>Nan::ToDetailString()</code></b></a>
|
||||
- <a href="#api_nan_to_array_index"><b><code>Nan::ToArrayIndex()</code></b></a>
|
||||
- <a href="#api_nan_equals"><b><code>Nan::Equals()</code></b></a>
|
||||
- <a href="#api_nan_new_instance"><b><code>Nan::NewInstance()</code></b></a>
|
||||
- <a href="#api_nan_get_function"><b><code>Nan::GetFunction()</code></b></a>
|
||||
- <a href="#api_nan_set"><b><code>Nan::Set()</code></b></a>
|
||||
- <a href="#api_nan_define_own_property"><b><code>Nan::DefineOwnProperty()</code></b></a>
|
||||
- <a href="#api_nan_force_set"><del><b><code>Nan::ForceSet()</code></b></del></a>
|
||||
- <a href="#api_nan_get"><b><code>Nan::Get()</code></b></a>
|
||||
- <a href="#api_nan_get_property_attribute"><b><code>Nan::GetPropertyAttributes()</code></b></a>
|
||||
- <a href="#api_nan_has"><b><code>Nan::Has()</code></b></a>
|
||||
- <a href="#api_nan_delete"><b><code>Nan::Delete()</code></b></a>
|
||||
- <a href="#api_nan_get_property_names"><b><code>Nan::GetPropertyNames()</code></b></a>
|
||||
- <a href="#api_nan_get_own_property_names"><b><code>Nan::GetOwnPropertyNames()</code></b></a>
|
||||
- <a href="#api_nan_set_prototype"><b><code>Nan::SetPrototype()</code></b></a>
|
||||
- <a href="#api_nan_object_proto_to_string"><b><code>Nan::ObjectProtoToString()</code></b></a>
|
||||
- <a href="#api_nan_has_own_property"><b><code>Nan::HasOwnProperty()</code></b></a>
|
||||
- <a href="#api_nan_has_real_named_property"><b><code>Nan::HasRealNamedProperty()</code></b></a>
|
||||
- <a href="#api_nan_has_real_indexed_property"><b><code>Nan::HasRealIndexedProperty()</code></b></a>
|
||||
- <a href="#api_nan_has_real_named_callback_property"><b><code>Nan::HasRealNamedCallbackProperty()</code></b></a>
|
||||
- <a href="#api_nan_get_real_named_property_in_prototype_chain"><b><code>Nan::GetRealNamedPropertyInPrototypeChain()</code></b></a>
|
||||
- <a href="#api_nan_get_real_named_property"><b><code>Nan::GetRealNamedProperty()</code></b></a>
|
||||
- <a href="#api_nan_call_as_function"><b><code>Nan::CallAsFunction()</code></b></a>
|
||||
- <a href="#api_nan_call_as_constructor"><b><code>Nan::CallAsConstructor()</code></b></a>
|
||||
- <a href="#api_nan_get_source_line"><b><code>Nan::GetSourceLine()</code></b></a>
|
||||
- <a href="#api_nan_get_line_number"><b><code>Nan::GetLineNumber()</code></b></a>
|
||||
- <a href="#api_nan_get_start_column"><b><code>Nan::GetStartColumn()</code></b></a>
|
||||
- <a href="#api_nan_get_end_column"><b><code>Nan::GetEndColumn()</code></b></a>
|
||||
- <a href="#api_nan_clone_element_at"><b><code>Nan::CloneElementAt()</code></b></a>
|
||||
- <a href="#api_nan_has_private"><b><code>Nan::HasPrivate()</code></b></a>
|
||||
- <a href="#api_nan_get_private"><b><code>Nan::GetPrivate()</code></b></a>
|
||||
- <a href="#api_nan_set_private"><b><code>Nan::SetPrivate()</code></b></a>
|
||||
- <a href="#api_nan_delete_private"><b><code>Nan::DeletePrivate()</code></b></a>
|
||||
- <a href="#api_nan_make_maybe"><b><code>Nan::MakeMaybe()</code></b></a>
|
||||
|
||||
<a name="api_nan_maybe_local"></a>
|
||||
### Nan::MaybeLocal
|
||||
|
||||
A `Nan::MaybeLocal<T>` is a wrapper around [`v8::Local<T>`](https://v8docs.nodesource.com/node-8.16/de/deb/classv8_1_1_local.html) that enforces a check that determines whether the `v8::Local<T>` is empty before it can be used.
|
||||
|
||||
If an API method returns a `Nan::MaybeLocal`, the API method can potentially fail either because an exception is thrown, or because an exception is pending, e.g. because a previous API call threw an exception that hasn't been caught yet, or because a `v8::TerminateExecution` exception was thrown. In that case, an empty `Nan::MaybeLocal` is returned.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
template<typename T> class Nan::MaybeLocal {
|
||||
public:
|
||||
MaybeLocal();
|
||||
|
||||
template<typename S> MaybeLocal(v8::Local<S> that);
|
||||
|
||||
bool IsEmpty() const;
|
||||
|
||||
template<typename S> bool ToLocal(v8::Local<S> *out);
|
||||
|
||||
// Will crash if the MaybeLocal<> is empty.
|
||||
v8::Local<T> ToLocalChecked();
|
||||
|
||||
template<typename S> v8::Local<S> FromMaybe(v8::Local<S> default_value) const;
|
||||
};
|
||||
```
|
||||
|
||||
See the documentation for [`v8::MaybeLocal`](https://v8docs.nodesource.com/node-8.16/d8/d7d/classv8_1_1_maybe_local.html) for further details.
|
||||
|
||||
<a name="api_nan_maybe"></a>
|
||||
### Nan::Maybe
|
||||
|
||||
A simple `Nan::Maybe` type, representing an object which may or may not have a value, see https://hackage.haskell.org/package/base/docs/Data-Maybe.html.
|
||||
|
||||
If an API method returns a `Nan::Maybe<>`, the API method can potentially fail either because an exception is thrown, or because an exception is pending, e.g. because a previous API call threw an exception that hasn't been caught yet, or because a `v8::TerminateExecution` exception was thrown. In that case, a "Nothing" value is returned.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
template<typename T> class Nan::Maybe {
|
||||
public:
|
||||
bool IsNothing() const;
|
||||
bool IsJust() const;
|
||||
|
||||
// Will crash if the Maybe<> is nothing.
|
||||
T FromJust();
|
||||
|
||||
T FromMaybe(const T& default_value);
|
||||
|
||||
bool operator==(const Maybe &other);
|
||||
|
||||
bool operator!=(const Maybe &other);
|
||||
};
|
||||
```
|
||||
|
||||
See the documentation for [`v8::Maybe`](https://v8docs.nodesource.com/node-8.16/d9/d4b/classv8_1_1_maybe.html) for further details.
|
||||
|
||||
<a name="api_nan_nothing"></a>
|
||||
### Nan::Nothing
|
||||
|
||||
Construct an empty `Nan::Maybe` type representing _nothing_.
|
||||
|
||||
```c++
|
||||
template<typename T> Nan::Maybe<T> Nan::Nothing();
|
||||
```
|
||||
|
||||
<a name="api_nan_just"></a>
|
||||
### Nan::Just
|
||||
|
||||
Construct a `Nan::Maybe` type representing _just_ a value.
|
||||
|
||||
```c++
|
||||
template<typename T> Nan::Maybe<T> Nan::Just(const T &t);
|
||||
```
|
||||
|
||||
<a name="api_nan_call"></a>
|
||||
### Nan::Call()
|
||||
|
||||
A helper method for calling a synchronous [`v8::Function#Call()`](https://v8docs.nodesource.com/node-8.16/d5/d54/classv8_1_1_function.html#a9c3d0e4e13ddd7721fce238aa5b94a11) in a way compatible across supported versions of V8.
|
||||
|
||||
For asynchronous callbacks, use Nan::Callback::Call along with an AsyncResource.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Value> Nan::Call(v8::Local<v8::Function> fun, v8::Local<v8::Object> recv, int argc, v8::Local<v8::Value> argv[]);
|
||||
Nan::MaybeLocal<v8::Value> Nan::Call(const Nan::Callback& callback, v8::Local<v8::Object> recv,
|
||||
int argc, v8::Local<v8::Value> argv[]);
|
||||
Nan::MaybeLocal<v8::Value> Nan::Call(const Nan::Callback& callback, int argc, v8::Local<v8::Value> argv[]);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_to_detail_string"></a>
|
||||
### Nan::ToDetailString()
|
||||
|
||||
A helper method for calling [`v8::Value#ToDetailString()`](https://v8docs.nodesource.com/node-8.16/dc/d0a/classv8_1_1_value.html#a2f9770296dc2c8d274bc8cc0dca243e5) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::String> Nan::ToDetailString(v8::Local<v8::Value> val);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_to_array_index"></a>
|
||||
### Nan::ToArrayIndex()
|
||||
|
||||
A helper method for calling [`v8::Value#ToArrayIndex()`](https://v8docs.nodesource.com/node-8.16/dc/d0a/classv8_1_1_value.html#acc5bbef3c805ec458470c0fcd6f13493) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Uint32> Nan::ToArrayIndex(v8::Local<v8::Value> val);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_equals"></a>
|
||||
### Nan::Equals()
|
||||
|
||||
A helper method for calling [`v8::Value#Equals()`](https://v8docs.nodesource.com/node-8.16/dc/d0a/classv8_1_1_value.html#a08fba1d776a59bbf6864b25f9152c64b) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<bool> Nan::Equals(v8::Local<v8::Value> a, v8::Local<v8::Value>(b));
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_new_instance"></a>
|
||||
### Nan::NewInstance()
|
||||
|
||||
A helper method for calling [`v8::Function#NewInstance()`](https://v8docs.nodesource.com/node-8.16/d5/d54/classv8_1_1_function.html#ae477558b10c14b76ed00e8dbab44ce5b) and [`v8::ObjectTemplate#NewInstance()`](https://v8docs.nodesource.com/node-8.16/db/d5f/classv8_1_1_object_template.html#ad605a7543cfbc5dab54cdb0883d14ae4) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Object> Nan::NewInstance(v8::Local<v8::Function> h);
|
||||
Nan::MaybeLocal<v8::Object> Nan::NewInstance(v8::Local<v8::Function> h, int argc, v8::Local<v8::Value> argv[]);
|
||||
Nan::MaybeLocal<v8::Object> Nan::NewInstance(v8::Local<v8::ObjectTemplate> h);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_get_function"></a>
|
||||
### Nan::GetFunction()
|
||||
|
||||
A helper method for calling [`v8::FunctionTemplate#GetFunction()`](https://v8docs.nodesource.com/node-8.16/d8/d83/classv8_1_1_function_template.html#a56d904662a86eca78da37d9bb0ed3705) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Function> Nan::GetFunction(v8::Local<v8::FunctionTemplate> t);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_set"></a>
|
||||
### Nan::Set()
|
||||
|
||||
A helper method for calling [`v8::Object#Set()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a67604ea3734f170c66026064ea808f20) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<bool> Nan::Set(v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::Value> key,
|
||||
v8::Local<v8::Value> value)
|
||||
Nan::Maybe<bool> Nan::Set(v8::Local<v8::Object> obj,
|
||||
uint32_t index,
|
||||
v8::Local<v8::Value> value);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_define_own_property"></a>
|
||||
### Nan::DefineOwnProperty()
|
||||
|
||||
A helper method for calling [`v8::Object#DefineOwnProperty()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a6f76b2ed605cb8f9185b92de0033a820) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<bool> Nan::DefineOwnProperty(v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::String> key,
|
||||
v8::Local<v8::Value> value,
|
||||
v8::PropertyAttribute attribs = v8::None);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_force_set"></a>
|
||||
### <del>Nan::ForceSet()</del>
|
||||
|
||||
Deprecated, use <a href="#api_nan_define_own_property"><code>Nan::DefineOwnProperty()</code></a>.
|
||||
|
||||
<del>A helper method for calling [`v8::Object#ForceSet()`](https://v8docs.nodesource.com/node-0.12/db/d85/classv8_1_1_object.html#acfbdfd7427b516ebdb5c47c4df5ed96c) in a way compatible across supported versions of V8.</del>
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
NAN_DEPRECATED Nan::Maybe<bool> Nan::ForceSet(v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::Value> key,
|
||||
v8::Local<v8::Value> value,
|
||||
v8::PropertyAttribute attribs = v8::None);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_get"></a>
|
||||
### Nan::Get()
|
||||
|
||||
A helper method for calling [`v8::Object#Get()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a2565f03e736694f6b1e1cf22a0b4eac2) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Value> Nan::Get(v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::Value> key);
|
||||
Nan::MaybeLocal<v8::Value> Nan::Get(v8::Local<v8::Object> obj, uint32_t index);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_get_property_attribute"></a>
|
||||
### Nan::GetPropertyAttributes()
|
||||
|
||||
A helper method for calling [`v8::Object#GetPropertyAttributes()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a9b898894da3d1db2714fd9325a54fe57) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<v8::PropertyAttribute> Nan::GetPropertyAttributes(
|
||||
v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::Value> key);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_has"></a>
|
||||
### Nan::Has()
|
||||
|
||||
A helper method for calling [`v8::Object#Has()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ab3c3d89ea7c2f9afd08965bd7299a41d) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<bool> Nan::Has(v8::Local<v8::Object> obj, v8::Local<v8::String> key);
|
||||
Nan::Maybe<bool> Nan::Has(v8::Local<v8::Object> obj, uint32_t index);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_delete"></a>
|
||||
### Nan::Delete()
|
||||
|
||||
A helper method for calling [`v8::Object#Delete()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a48e4a19b2cedff867eecc73ddb7d377f) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<bool> Nan::Delete(v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::String> key);
|
||||
Nan::Maybe<bool> Nan::Delete(v8::Local<v8::Object> obj, uint32_t index);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_get_property_names"></a>
|
||||
### Nan::GetPropertyNames()
|
||||
|
||||
A helper method for calling [`v8::Object#GetPropertyNames()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#aced885270cfd2c956367b5eedc7fbfe8) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Array> Nan::GetPropertyNames(v8::Local<v8::Object> obj);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_get_own_property_names"></a>
|
||||
### Nan::GetOwnPropertyNames()
|
||||
|
||||
A helper method for calling [`v8::Object#GetOwnPropertyNames()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a79a6e4d66049b9aa648ed4dfdb23e6eb) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Array> Nan::GetOwnPropertyNames(v8::Local<v8::Object> obj);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_set_prototype"></a>
|
||||
### Nan::SetPrototype()
|
||||
|
||||
A helper method for calling [`v8::Object#SetPrototype()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a442706b22fceda6e6d1f632122a9a9f4) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<bool> Nan::SetPrototype(v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::Value> prototype);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_object_proto_to_string"></a>
|
||||
### Nan::ObjectProtoToString()
|
||||
|
||||
A helper method for calling [`v8::Object#ObjectProtoToString()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ab7a92b4dcf822bef72f6c0ac6fea1f0b) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::String> Nan::ObjectProtoToString(v8::Local<v8::Object> obj);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_has_own_property"></a>
|
||||
### Nan::HasOwnProperty()
|
||||
|
||||
A helper method for calling [`v8::Object#HasOwnProperty()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ab7b7245442ca6de1e1c145ea3fd653ff) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<bool> Nan::HasOwnProperty(v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::String> key);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_has_real_named_property"></a>
|
||||
### Nan::HasRealNamedProperty()
|
||||
|
||||
A helper method for calling [`v8::Object#HasRealNamedProperty()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ad8b80a59c9eb3c1e6c3cd6c84571f767) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<bool> Nan::HasRealNamedProperty(v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::String> key);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_has_real_indexed_property"></a>
|
||||
### Nan::HasRealIndexedProperty()
|
||||
|
||||
A helper method for calling [`v8::Object#HasRealIndexedProperty()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#af94fc1135a5e74a2193fb72c3a1b9855) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<bool> Nan::HasRealIndexedProperty(v8::Local<v8::Object> obj,
|
||||
uint32_t index);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_has_real_named_callback_property"></a>
|
||||
### Nan::HasRealNamedCallbackProperty()
|
||||
|
||||
A helper method for calling [`v8::Object#HasRealNamedCallbackProperty()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#af743b7ea132b89f84d34d164d0668811) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<bool> Nan::HasRealNamedCallbackProperty(
|
||||
v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::String> key);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_get_real_named_property_in_prototype_chain"></a>
|
||||
### Nan::GetRealNamedPropertyInPrototypeChain()
|
||||
|
||||
A helper method for calling [`v8::Object#GetRealNamedPropertyInPrototypeChain()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a8700b1862e6b4783716964ba4d5e6172) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Value> Nan::GetRealNamedPropertyInPrototypeChain(
|
||||
v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::String> key);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_get_real_named_property"></a>
|
||||
### Nan::GetRealNamedProperty()
|
||||
|
||||
A helper method for calling [`v8::Object#GetRealNamedProperty()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a84471a824576a5994fdd0ffcbf99ccc0) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Value> Nan::GetRealNamedProperty(v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::String> key);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_call_as_function"></a>
|
||||
### Nan::CallAsFunction()
|
||||
|
||||
A helper method for calling [`v8::Object#CallAsFunction()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ad3ffc36f3dfc3592ce2a96bc047ee2cd) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Value> Nan::CallAsFunction(v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::Object> recv,
|
||||
int argc,
|
||||
v8::Local<v8::Value> argv[]);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_call_as_constructor"></a>
|
||||
### Nan::CallAsConstructor()
|
||||
|
||||
A helper method for calling [`v8::Object#CallAsConstructor()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a50d571de50d0b0dfb28795619d07a01b) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Value> Nan::CallAsConstructor(v8::Local<v8::Object> obj,
|
||||
int argc,
|
||||
v8::Local<v8::Value> argv[]);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_get_source_line"></a>
|
||||
### Nan::GetSourceLine()
|
||||
|
||||
A helper method for calling [`v8::Message#GetSourceLine()`](https://v8docs.nodesource.com/node-8.16/d9/d28/classv8_1_1_message.html#a849f7a6c41549d83d8159825efccd23a) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::String> Nan::GetSourceLine(v8::Local<v8::Message> msg);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_get_line_number"></a>
|
||||
### Nan::GetLineNumber()
|
||||
|
||||
A helper method for calling [`v8::Message#GetLineNumber()`](https://v8docs.nodesource.com/node-8.16/d9/d28/classv8_1_1_message.html#adbe46c10a88a6565f2732a2d2adf99b9) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<int> Nan::GetLineNumber(v8::Local<v8::Message> msg);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_get_start_column"></a>
|
||||
### Nan::GetStartColumn()
|
||||
|
||||
A helper method for calling [`v8::Message#GetStartColumn()`](https://v8docs.nodesource.com/node-8.16/d9/d28/classv8_1_1_message.html#a60ede616ba3822d712e44c7a74487ba6) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<int> Nan::GetStartColumn(v8::Local<v8::Message> msg);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_get_end_column"></a>
|
||||
### Nan::GetEndColumn()
|
||||
|
||||
A helper method for calling [`v8::Message#GetEndColumn()`](https://v8docs.nodesource.com/node-8.16/d9/d28/classv8_1_1_message.html#aaa004cf19e529da980bc19fcb76d93be) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<int> Nan::GetEndColumn(v8::Local<v8::Message> msg);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_clone_element_at"></a>
|
||||
### Nan::CloneElementAt()
|
||||
|
||||
A helper method for calling [`v8::Array#CloneElementAt()`](https://v8docs.nodesource.com/node-4.8/d3/d32/classv8_1_1_array.html#a1d3a878d4c1c7cae974dd50a1639245e) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Object> Nan::CloneElementAt(v8::Local<v8::Array> array, uint32_t index);
|
||||
```
|
||||
|
||||
<a name="api_nan_has_private"></a>
|
||||
### Nan::HasPrivate()
|
||||
|
||||
A helper method for calling [`v8::Object#HasPrivate()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#af68a0b98066cfdeb8f943e98a40ba08d) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<bool> Nan::HasPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key);
|
||||
```
|
||||
|
||||
<a name="api_nan_get_private"></a>
|
||||
### Nan::GetPrivate()
|
||||
|
||||
A helper method for calling [`v8::Object#GetPrivate()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a169f2da506acbec34deadd9149a1925a) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Value> Nan::GetPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key);
|
||||
```
|
||||
|
||||
<a name="api_nan_set_private"></a>
|
||||
### Nan::SetPrivate()
|
||||
|
||||
A helper method for calling [`v8::Object#SetPrivate()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ace1769b0f3b86bfe9fda1010916360ee) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<bool> Nan::SetPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key, v8::Local<v8::Value> value);
|
||||
```
|
||||
|
||||
<a name="api_nan_delete_private"></a>
|
||||
### Nan::DeletePrivate()
|
||||
|
||||
A helper method for calling [`v8::Object#DeletePrivate()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a138bb32a304f3982be02ad499693b8fd) in a way compatible across supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::Maybe<bool> Nan::DeletePrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key);
|
||||
```
|
||||
|
||||
<a name="api_nan_make_maybe"></a>
|
||||
### Nan::MakeMaybe()
|
||||
|
||||
Wraps a `v8::Local<>` in a `Nan::MaybeLocal<>`. When called with a `Nan::MaybeLocal<>` it just returns its argument. This is useful in generic template code that builds on NAN.
|
||||
|
||||
Synopsis:
|
||||
|
||||
```c++
|
||||
MaybeLocal<v8::Number> someNumber = MakeMaybe(New<v8::Number>(3.141592654));
|
||||
MaybeLocal<v8::String> someString = MakeMaybe(New<v8::String>("probably"));
|
||||
```
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
template <typename T, template <typename> class MaybeMaybe>
|
||||
Nan::MaybeLocal<T> Nan::MakeMaybe(MaybeMaybe<T> v);
|
||||
```
|
||||
689
tasks/enduro-trails/prototype/node_modules/nan/doc/methods.md
generated
vendored
Normal file
689
tasks/enduro-trails/prototype/node_modules/nan/doc/methods.md
generated
vendored
Normal file
@@ -0,0 +1,689 @@
|
||||
## JavaScript-accessible methods
|
||||
|
||||
A _template_ is a blueprint for JavaScript functions and objects in a context. You can use a template to wrap C++ functions and data structures within JavaScript objects so that they can be manipulated from JavaScript. See the V8 Embedders Guide section on [Templates](https://github.com/v8/v8/wiki/Embedder%27s-Guide#templates) for further information.
|
||||
|
||||
In order to expose functionality to JavaScript via a template, you must provide it to V8 in a form that it understands. Across the versions of V8 supported by NAN, JavaScript-accessible method signatures vary widely, NAN fully abstracts method declaration and provides you with an interface that is similar to the most recent V8 API but is backward-compatible with older versions that still use the now-deceased `v8::Argument` type.
|
||||
|
||||
* **Method argument types**
|
||||
- <a href="#api_nan_function_callback_info"><b><code>Nan::FunctionCallbackInfo</code></b></a>
|
||||
- <a href="#api_nan_property_callback_info"><b><code>Nan::PropertyCallbackInfo</code></b></a>
|
||||
- <a href="#api_nan_return_value"><b><code>Nan::ReturnValue</code></b></a>
|
||||
* **Method declarations**
|
||||
- <a href="#api_nan_method"><b>Method declaration</b></a>
|
||||
- <a href="#api_nan_getter"><b>Getter declaration</b></a>
|
||||
- <a href="#api_nan_setter"><b>Setter declaration</b></a>
|
||||
- <a href="#api_nan_property_getter"><b>Property getter declaration</b></a>
|
||||
- <a href="#api_nan_property_setter"><b>Property setter declaration</b></a>
|
||||
- <a href="#api_nan_property_enumerator"><b>Property enumerator declaration</b></a>
|
||||
- <a href="#api_nan_property_deleter"><b>Property deleter declaration</b></a>
|
||||
- <a href="#api_nan_property_query"><b>Property query declaration</b></a>
|
||||
- <a href="#api_nan_index_getter"><b>Index getter declaration</b></a>
|
||||
- <a href="#api_nan_index_setter"><b>Index setter declaration</b></a>
|
||||
- <a href="#api_nan_index_enumerator"><b>Index enumerator declaration</b></a>
|
||||
- <a href="#api_nan_index_deleter"><b>Index deleter declaration</b></a>
|
||||
- <a href="#api_nan_index_query"><b>Index query declaration</b></a>
|
||||
* Method and template helpers
|
||||
- <a href="#api_nan_set_method"><b><code>Nan::SetMethod()</code></b></a>
|
||||
- <a href="#api_nan_set_prototype_method"><b><code>Nan::SetPrototypeMethod()</code></b></a>
|
||||
- <a href="#api_nan_set_accessor"><b><code>Nan::SetAccessor()</code></b></a>
|
||||
- <a href="#api_nan_set_named_property_handler"><b><code>Nan::SetNamedPropertyHandler()</code></b></a>
|
||||
- <a href="#api_nan_set_indexed_property_handler"><b><code>Nan::SetIndexedPropertyHandler()</code></b></a>
|
||||
- <a href="#api_nan_set_template"><b><code>Nan::SetTemplate()</code></b></a>
|
||||
- <a href="#api_nan_set_prototype_template"><b><code>Nan::SetPrototypeTemplate()</code></b></a>
|
||||
- <a href="#api_nan_set_instance_template"><b><code>Nan::SetInstanceTemplate()</code></b></a>
|
||||
- <a href="#api_nan_set_call_handler"><b><code>Nan::SetCallHandler()</code></b></a>
|
||||
- <a href="#api_nan_set_call_as_function_handler"><b><code>Nan::SetCallAsFunctionHandler()</code></b></a>
|
||||
|
||||
<a name="api_nan_function_callback_info"></a>
|
||||
### Nan::FunctionCallbackInfo
|
||||
|
||||
`Nan::FunctionCallbackInfo` should be used in place of [`v8::FunctionCallbackInfo`](https://v8docs.nodesource.com/node-8.16/dd/d0d/classv8_1_1_function_callback_info.html), even with older versions of Node where `v8::FunctionCallbackInfo` does not exist.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
template<typename T> class FunctionCallbackInfo {
|
||||
public:
|
||||
ReturnValue<T> GetReturnValue() const;
|
||||
v8::Local<v8::Function> Callee(); // NOTE: Not available in NodeJS >= 10.0.0
|
||||
v8::Local<v8::Value> Data();
|
||||
v8::Local<v8::Object> Holder();
|
||||
bool IsConstructCall();
|
||||
int Length() const;
|
||||
v8::Local<v8::Value> operator[](int i) const;
|
||||
v8::Local<v8::Object> This() const;
|
||||
v8::Isolate *GetIsolate() const;
|
||||
};
|
||||
```
|
||||
|
||||
See the [`v8::FunctionCallbackInfo`](https://v8docs.nodesource.com/node-8.16/dd/d0d/classv8_1_1_function_callback_info.html) documentation for usage details on these. See [`Nan::ReturnValue`](#api_nan_return_value) for further information on how to set a return value from methods.
|
||||
|
||||
**Note:** `FunctionCallbackInfo::Callee` is removed in Node.js after `10.0.0` because it is was deprecated in V8. Consider using `info.Data()` to pass any information you need.
|
||||
|
||||
<a name="api_nan_property_callback_info"></a>
|
||||
### Nan::PropertyCallbackInfo
|
||||
|
||||
`Nan::PropertyCallbackInfo` should be used in place of [`v8::PropertyCallbackInfo`](https://v8docs.nodesource.com/node-8.16/d7/dc5/classv8_1_1_property_callback_info.html), even with older versions of Node where `v8::PropertyCallbackInfo` does not exist.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
template<typename T> class PropertyCallbackInfo : public PropertyCallbackInfoBase<T> {
|
||||
public:
|
||||
ReturnValue<T> GetReturnValue() const;
|
||||
v8::Isolate* GetIsolate() const;
|
||||
v8::Local<v8::Value> Data() const;
|
||||
v8::Local<v8::Object> This() const;
|
||||
v8::Local<v8::Object> Holder() const;
|
||||
};
|
||||
```
|
||||
|
||||
See the [`v8::PropertyCallbackInfo`](https://v8docs.nodesource.com/node-8.16/d7/dc5/classv8_1_1_property_callback_info.html) documentation for usage details on these. See [`Nan::ReturnValue`](#api_nan_return_value) for further information on how to set a return value from property accessor methods.
|
||||
|
||||
<a name="api_nan_return_value"></a>
|
||||
### Nan::ReturnValue
|
||||
|
||||
`Nan::ReturnValue` is used in place of [`v8::ReturnValue`](https://v8docs.nodesource.com/node-8.16/da/da7/classv8_1_1_return_value.html) on both [`Nan::FunctionCallbackInfo`](#api_nan_function_callback_info) and [`Nan::PropertyCallbackInfo`](#api_nan_property_callback_info) as the return type of `GetReturnValue()`.
|
||||
|
||||
Example usage:
|
||||
|
||||
```c++
|
||||
void EmptyArray(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
||||
info.GetReturnValue().Set(Nan::New<v8::Array>());
|
||||
}
|
||||
```
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
template<typename T> class ReturnValue {
|
||||
public:
|
||||
// Handle setters
|
||||
template <typename S> void Set(const v8::Local<S> &handle);
|
||||
template <typename S> void Set(const Nan::Global<S> &handle);
|
||||
|
||||
// Fast primitive setters
|
||||
void Set(bool value);
|
||||
void Set(double i);
|
||||
void Set(int32_t i);
|
||||
void Set(uint32_t i);
|
||||
|
||||
// Fast JS primitive setters
|
||||
void SetNull();
|
||||
void SetUndefined();
|
||||
void SetEmptyString();
|
||||
|
||||
// Convenience getter for isolate
|
||||
v8::Isolate *GetIsolate() const;
|
||||
};
|
||||
```
|
||||
|
||||
See the documentation on [`v8::ReturnValue`](https://v8docs.nodesource.com/node-8.16/da/da7/classv8_1_1_return_value.html) for further information on this.
|
||||
|
||||
<a name="api_nan_method"></a>
|
||||
### Method declaration
|
||||
|
||||
JavaScript-accessible methods should be declared with the following signature to form a `Nan::FunctionCallback`:
|
||||
|
||||
```c++
|
||||
typedef void(*FunctionCallback)(const FunctionCallbackInfo<v8::Value>&);
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
void MethodName(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
You do not need to declare a new `HandleScope` within a method as one is implicitly created for you.
|
||||
|
||||
**Example usage**
|
||||
|
||||
```c++
|
||||
// .h:
|
||||
class Foo : public Nan::ObjectWrap {
|
||||
...
|
||||
|
||||
static void Bar(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
||||
static void Baz(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
||||
}
|
||||
|
||||
|
||||
// .cc:
|
||||
void Foo::Bar(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
||||
...
|
||||
}
|
||||
|
||||
void Foo::Baz(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
A helper macro `NAN_METHOD(methodname)` exists, compatible with NAN v1 method declarations.
|
||||
|
||||
**Example usage with `NAN_METHOD(methodname)`**
|
||||
|
||||
```c++
|
||||
// .h:
|
||||
class Foo : public Nan::ObjectWrap {
|
||||
...
|
||||
|
||||
static NAN_METHOD(Bar);
|
||||
static NAN_METHOD(Baz);
|
||||
}
|
||||
|
||||
|
||||
// .cc:
|
||||
NAN_METHOD(Foo::Bar) {
|
||||
...
|
||||
}
|
||||
|
||||
NAN_METHOD(Foo::Baz) {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Use [`Nan::SetPrototypeMethod`](#api_nan_set_prototype_method) to attach a method to a JavaScript function prototype or [`Nan::SetMethod`](#api_nan_set_method) to attach a method directly on a JavaScript object.
|
||||
|
||||
<a name="api_nan_getter"></a>
|
||||
### Getter declaration
|
||||
|
||||
JavaScript-accessible getters should be declared with the following signature to form a `Nan::GetterCallback`:
|
||||
|
||||
```c++
|
||||
typedef void(*GetterCallback)(v8::Local<v8::String>,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
void GetterName(v8::Local<v8::String> property,
|
||||
const Nan::PropertyCallbackInfo<v8::Value>& info) {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
You do not need to declare a new `HandleScope` within a getter as one is implicitly created for you.
|
||||
|
||||
A helper macro `NAN_GETTER(methodname)` exists, compatible with NAN v1 method declarations.
|
||||
|
||||
Also see the V8 Embedders Guide documentation on [Accessors](https://v8.dev/docs/embed#accessors).
|
||||
|
||||
<a name="api_nan_setter"></a>
|
||||
### Setter declaration
|
||||
|
||||
JavaScript-accessible setters should be declared with the following signature to form a <b><code>Nan::SetterCallback</code></b>:
|
||||
|
||||
```c++
|
||||
typedef void(*SetterCallback)(v8::Local<v8::String>,
|
||||
v8::Local<v8::Value>,
|
||||
const PropertyCallbackInfo<void>&);
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
void SetterName(v8::Local<v8::String> property,
|
||||
v8::Local<v8::Value> value,
|
||||
const Nan::PropertyCallbackInfo<void>& info) {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
You do not need to declare a new `HandleScope` within a setter as one is implicitly created for you.
|
||||
|
||||
A helper macro `NAN_SETTER(methodname)` exists, compatible with NAN v1 method declarations.
|
||||
|
||||
Also see the V8 Embedders Guide documentation on [Accessors](https://v8.dev/docs/embed#accessors).
|
||||
|
||||
<a name="api_nan_property_getter"></a>
|
||||
### Property getter declaration
|
||||
|
||||
JavaScript-accessible property getters should be declared with the following signature to form a <b><code>Nan::PropertyGetterCallback</code></b>:
|
||||
|
||||
```c++
|
||||
typedef void(*PropertyGetterCallback)(v8::Local<v8::String>,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
void PropertyGetterName(v8::Local<v8::String> property,
|
||||
const Nan::PropertyCallbackInfo<v8::Value>& info) {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
You do not need to declare a new `HandleScope` within a property getter as one is implicitly created for you.
|
||||
|
||||
A helper macro `NAN_PROPERTY_GETTER(methodname)` exists, compatible with NAN v1 method declarations.
|
||||
|
||||
Also see the V8 Embedders Guide documentation on named property [Interceptors](https://v8.dev/docs/embed#interceptors).
|
||||
|
||||
<a name="api_nan_property_setter"></a>
|
||||
### Property setter declaration
|
||||
|
||||
JavaScript-accessible property setters should be declared with the following signature to form a <b><code>Nan::PropertySetterCallback</code></b>:
|
||||
|
||||
```c++
|
||||
typedef void(*PropertySetterCallback)(v8::Local<v8::String>,
|
||||
v8::Local<v8::Value>,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
void PropertySetterName(v8::Local<v8::String> property,
|
||||
v8::Local<v8::Value> value,
|
||||
const Nan::PropertyCallbackInfo<v8::Value>& info);
|
||||
```
|
||||
|
||||
You do not need to declare a new `HandleScope` within a property setter as one is implicitly created for you.
|
||||
|
||||
A helper macro `NAN_PROPERTY_SETTER(methodname)` exists, compatible with NAN v1 method declarations.
|
||||
|
||||
Also see the V8 Embedders Guide documentation on named property [Interceptors](https://v8.dev/docs/embed#interceptors).
|
||||
|
||||
<a name="api_nan_property_enumerator"></a>
|
||||
### Property enumerator declaration
|
||||
|
||||
JavaScript-accessible property enumerators should be declared with the following signature to form a <b><code>Nan::PropertyEnumeratorCallback</code></b>:
|
||||
|
||||
```c++
|
||||
typedef void(*PropertyEnumeratorCallback)(const PropertyCallbackInfo<v8::Array>&);
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
void PropertyEnumeratorName(const Nan::PropertyCallbackInfo<v8::Array>& info);
|
||||
```
|
||||
|
||||
You do not need to declare a new `HandleScope` within a property enumerator as one is implicitly created for you.
|
||||
|
||||
A helper macro `NAN_PROPERTY_ENUMERATOR(methodname)` exists, compatible with NAN v1 method declarations.
|
||||
|
||||
Also see the V8 Embedders Guide documentation on named property [Interceptors](https://v8.dev/docs/embed#interceptors).
|
||||
|
||||
<a name="api_nan_property_deleter"></a>
|
||||
### Property deleter declaration
|
||||
|
||||
JavaScript-accessible property deleters should be declared with the following signature to form a <b><code>Nan::PropertyDeleterCallback</code></b>:
|
||||
|
||||
```c++
|
||||
typedef void(*PropertyDeleterCallback)(v8::Local<v8::String>,
|
||||
const PropertyCallbackInfo<v8::Boolean>&);
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
void PropertyDeleterName(v8::Local<v8::String> property,
|
||||
const Nan::PropertyCallbackInfo<v8::Boolean>& info);
|
||||
```
|
||||
|
||||
You do not need to declare a new `HandleScope` within a property deleter as one is implicitly created for you.
|
||||
|
||||
A helper macro `NAN_PROPERTY_DELETER(methodname)` exists, compatible with NAN v1 method declarations.
|
||||
|
||||
Also see the V8 Embedders Guide documentation on named property [Interceptors](https://v8.dev/docs/embed#interceptors).
|
||||
|
||||
<a name="api_nan_property_query"></a>
|
||||
### Property query declaration
|
||||
|
||||
JavaScript-accessible property query methods should be declared with the following signature to form a <b><code>Nan::PropertyQueryCallback</code></b>:
|
||||
|
||||
```c++
|
||||
typedef void(*PropertyQueryCallback)(v8::Local<v8::String>,
|
||||
const PropertyCallbackInfo<v8::Integer>&);
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
void PropertyQueryName(v8::Local<v8::String> property,
|
||||
const Nan::PropertyCallbackInfo<v8::Integer>& info);
|
||||
```
|
||||
|
||||
You do not need to declare a new `HandleScope` within a property query method as one is implicitly created for you.
|
||||
|
||||
A helper macro `NAN_PROPERTY_QUERY(methodname)` exists, compatible with NAN v1 method declarations.
|
||||
|
||||
Also see the V8 Embedders Guide documentation on named property [Interceptors](https://v8.dev/docs/embed#interceptors).
|
||||
|
||||
<a name="api_nan_index_getter"></a>
|
||||
### Index getter declaration
|
||||
|
||||
JavaScript-accessible index getter methods should be declared with the following signature to form a <b><code>Nan::IndexGetterCallback</code></b>:
|
||||
|
||||
```c++
|
||||
typedef void(*IndexGetterCallback)(uint32_t,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
void IndexGetterName(uint32_t index, const PropertyCallbackInfo<v8::Value>& info);
|
||||
```
|
||||
|
||||
You do not need to declare a new `HandleScope` within a index getter as one is implicitly created for you.
|
||||
|
||||
A helper macro `NAN_INDEX_GETTER(methodname)` exists, compatible with NAN v1 method declarations.
|
||||
|
||||
Also see the V8 Embedders Guide documentation on indexed property [Interceptors](https://v8.dev/docs/embed#interceptors).
|
||||
|
||||
<a name="api_nan_index_setter"></a>
|
||||
### Index setter declaration
|
||||
|
||||
JavaScript-accessible index setter methods should be declared with the following signature to form a <b><code>Nan::IndexSetterCallback</code></b>:
|
||||
|
||||
```c++
|
||||
typedef void(*IndexSetterCallback)(uint32_t,
|
||||
v8::Local<v8::Value>,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
void IndexSetterName(uint32_t index,
|
||||
v8::Local<v8::Value> value,
|
||||
const PropertyCallbackInfo<v8::Value>& info);
|
||||
```
|
||||
|
||||
You do not need to declare a new `HandleScope` within a index setter as one is implicitly created for you.
|
||||
|
||||
A helper macro `NAN_INDEX_SETTER(methodname)` exists, compatible with NAN v1 method declarations.
|
||||
|
||||
Also see the V8 Embedders Guide documentation on indexed property [Interceptors](https://v8.dev/docs/embed#interceptors).
|
||||
|
||||
<a name="api_nan_index_enumerator"></a>
|
||||
### Index enumerator declaration
|
||||
|
||||
JavaScript-accessible index enumerator methods should be declared with the following signature to form a <b><code>Nan::IndexEnumeratorCallback</code></b>:
|
||||
|
||||
```c++
|
||||
typedef void(*IndexEnumeratorCallback)(const PropertyCallbackInfo<v8::Array>&);
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
void IndexEnumeratorName(const PropertyCallbackInfo<v8::Array>& info);
|
||||
```
|
||||
|
||||
You do not need to declare a new `HandleScope` within a index enumerator as one is implicitly created for you.
|
||||
|
||||
A helper macro `NAN_INDEX_ENUMERATOR(methodname)` exists, compatible with NAN v1 method declarations.
|
||||
|
||||
Also see the V8 Embedders Guide documentation on indexed property [Interceptors](https://v8.dev/docs/embed#interceptors).
|
||||
|
||||
<a name="api_nan_index_deleter"></a>
|
||||
### Index deleter declaration
|
||||
|
||||
JavaScript-accessible index deleter methods should be declared with the following signature to form a <b><code>Nan::IndexDeleterCallback</code></b>:
|
||||
|
||||
```c++
|
||||
typedef void(*IndexDeleterCallback)(uint32_t,
|
||||
const PropertyCallbackInfo<v8::Boolean>&);
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
void IndexDeleterName(uint32_t index, const PropertyCallbackInfo<v8::Boolean>& info);
|
||||
```
|
||||
|
||||
You do not need to declare a new `HandleScope` within a index deleter as one is implicitly created for you.
|
||||
|
||||
A helper macro `NAN_INDEX_DELETER(methodname)` exists, compatible with NAN v1 method declarations.
|
||||
|
||||
Also see the V8 Embedders Guide documentation on indexed property [Interceptors](https://v8.dev/docs/embed#interceptors).
|
||||
|
||||
<a name="api_nan_index_query"></a>
|
||||
### Index query declaration
|
||||
|
||||
JavaScript-accessible index query methods should be declared with the following signature to form a <b><code>Nan::IndexQueryCallback</code></b>:
|
||||
|
||||
```c++
|
||||
typedef void(*IndexQueryCallback)(uint32_t,
|
||||
const PropertyCallbackInfo<v8::Integer>&);
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
void IndexQueryName(uint32_t index, const PropertyCallbackInfo<v8::Integer>& info);
|
||||
```
|
||||
|
||||
You do not need to declare a new `HandleScope` within a index query method as one is implicitly created for you.
|
||||
|
||||
A helper macro `NAN_INDEX_QUERY(methodname)` exists, compatible with NAN v1 method declarations.
|
||||
|
||||
Also see the V8 Embedders Guide documentation on indexed property [Interceptors](https://v8.dev/docs/embed#interceptors).
|
||||
|
||||
<a name="api_nan_set_method"></a>
|
||||
### Nan::SetMethod()
|
||||
|
||||
Sets a method with a given name directly on a JavaScript object where the method has the `Nan::FunctionCallback` signature (see <a href="#api_nan_method">Method declaration</a>).
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::SetMethod(v8::Local<v8::Object> recv,
|
||||
const char *name,
|
||||
Nan::FunctionCallback callback,
|
||||
v8::Local<v8::Value> data = v8::Local<v8::Value>())
|
||||
void Nan::SetMethod(v8::Local<v8::Template> templ,
|
||||
const char *name,
|
||||
Nan::FunctionCallback callback,
|
||||
v8::Local<v8::Value> data = v8::Local<v8::Value>())
|
||||
```
|
||||
|
||||
<a name="api_nan_set_prototype_method"></a>
|
||||
### Nan::SetPrototypeMethod()
|
||||
|
||||
Sets a method with a given name on a `FunctionTemplate`'s prototype where the method has the `Nan::FunctionCallback` signature (see <a href="#api_nan_method">Method declaration</a>).
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::SetPrototypeMethod(v8::Local<v8::FunctionTemplate> recv,
|
||||
const char* name,
|
||||
Nan::FunctionCallback callback,
|
||||
v8::Local<v8::Value> data = v8::Local<v8::Value>())
|
||||
```
|
||||
|
||||
<a name="api_nan_set_accessor"></a>
|
||||
### Nan::SetAccessor()
|
||||
|
||||
Sets getters and setters for a property with a given name on an `ObjectTemplate` or a plain `Object`. Accepts getters with the `Nan::GetterCallback` signature (see <a href="#api_nan_getter">Getter declaration</a>) and setters with the `Nan::SetterCallback` signature (see <a href="#api_nan_setter">Setter declaration</a>).
|
||||
|
||||
**Note** `v8::AccessControl` was deprectaed in v8 14.2 and subsequently removed. To maintain backward compatibility new enum `enum AccessControl {DEFAULT = 0};` was added. Nan will determine v8 version used and switch to a correct signature.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
// The signature parameter was deprecated in Node 16 and subsequently removed
|
||||
NAN_DEPRECATED void SetAccessor(v8::Local<v8::ObjectTemplate> tpl,
|
||||
v8::Local<v8::String> name,
|
||||
Nan::GetterCallback getter,
|
||||
Nan::SetterCallback setter = 0,
|
||||
v8::Local<v8::Value> data = v8::Local<v8::Value>(),
|
||||
v8::AccessControl settings = v8::DEFAULT,
|
||||
v8::PropertyAttribute attribute = v8::None,
|
||||
imp::Sig signature = imp::Sig());
|
||||
void SetAccessor(v8::Local<v8::ObjectTemplate> tpl,
|
||||
v8::Local<v8::String> name,
|
||||
Nan::GetterCallback getter,
|
||||
Nan::SetterCallback setter = 0,
|
||||
v8::Local<v8::Value> data = v8::Local<v8::Value>(),
|
||||
v8::AccessControl settings = v8::DEFAULT,
|
||||
v8::PropertyAttribute attribute = v8::None);
|
||||
bool SetAccessor(v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::String> name,
|
||||
Nan::GetterCallback getter,
|
||||
Nan::SetterCallback setter = 0,
|
||||
v8::Local<v8::Value> data = v8::Local<v8::Value>(),
|
||||
v8::AccessControl settings = v8::DEFAULT,
|
||||
v8::PropertyAttribute attribute = v8::None)
|
||||
// Starting from v8 14.2 new enum is used
|
||||
void SetAccessor(v8::Local<v8::ObjectTemplate> tpl,
|
||||
v8::Local<v8::String> name,
|
||||
Nan::GetterCallback getter,
|
||||
Nan::SetterCallback setter = 0,
|
||||
v8::Local<v8::Value> data = v8::Local<v8::Value>(),
|
||||
enum Nan::AccessControl settings = DEFAULT,
|
||||
v8::PropertyAttribute attribute = v8::None);
|
||||
bool SetAccessor(v8::Local<v8::Object> obj,
|
||||
v8::Local<v8::String> name,
|
||||
Nan::GetterCallback getter,
|
||||
Nan::SetterCallback setter = 0,
|
||||
v8::Local<v8::Value> data = v8::Local<v8::Value>(),
|
||||
enum Nan::AccessControl settings = DEFAULT,
|
||||
v8::PropertyAttribute attribute = v8::None)
|
||||
```
|
||||
|
||||
See the V8 [`ObjectTemplate#SetAccessor()`](https://v8docs.nodesource.com/node-8.16/db/d5f/classv8_1_1_object_template.html#aca0ed196f8a9adb1f68b1aadb6c9cd77) and [`Object#SetAccessor()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ae91b3b56b357f285288c89fbddc46d1b) for further information about how to use `Nan::SetAccessor()`.
|
||||
|
||||
<a name="api_nan_set_named_property_handler"></a>
|
||||
### Nan::SetNamedPropertyHandler()
|
||||
|
||||
Sets named property getters, setters, query, deleter and enumerator methods on an `ObjectTemplate`. Accepts:
|
||||
|
||||
* Property getters with the `Nan::PropertyGetterCallback` signature (see <a href="#api_nan_property_getter">Property getter declaration</a>)
|
||||
* Property setters with the `Nan::PropertySetterCallback` signature (see <a href="#api_nan_property_setter">Property setter declaration</a>)
|
||||
* Property query methods with the `Nan::PropertyQueryCallback` signature (see <a href="#api_nan_property_query">Property query declaration</a>)
|
||||
* Property deleters with the `Nan::PropertyDeleterCallback` signature (see <a href="#api_nan_property_deleter">Property deleter declaration</a>)
|
||||
* Property enumerators with the `Nan::PropertyEnumeratorCallback` signature (see <a href="#api_nan_property_enumerator">Property enumerator declaration</a>)
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void SetNamedPropertyHandler(v8::Local<v8::ObjectTemplate> tpl,
|
||||
Nan::PropertyGetterCallback getter,
|
||||
Nan::PropertySetterCallback setter = 0,
|
||||
Nan::PropertyQueryCallback query = 0,
|
||||
Nan::PropertyDeleterCallback deleter = 0,
|
||||
Nan::PropertyEnumeratorCallback enumerator = 0,
|
||||
v8::Local<v8::Value> data = v8::Local<v8::Value>())
|
||||
```
|
||||
|
||||
See the V8 [`ObjectTemplate#SetNamedPropertyHandler()`](https://v8docs.nodesource.com/node-8.16/db/d5f/classv8_1_1_object_template.html#a33b3ebd7de641f6cc6414b7de01fc1c7) for further information about how to use `Nan::SetNamedPropertyHandler()`.
|
||||
|
||||
<a name="api_nan_set_indexed_property_handler"></a>
|
||||
### Nan::SetIndexedPropertyHandler()
|
||||
|
||||
Sets indexed property getters, setters, query, deleter and enumerator methods on an `ObjectTemplate`. Accepts:
|
||||
|
||||
* Indexed property getters with the `Nan::IndexGetterCallback` signature (see <a href="#api_nan_index_getter">Index getter declaration</a>)
|
||||
* Indexed property setters with the `Nan::IndexSetterCallback` signature (see <a href="#api_nan_index_setter">Index setter declaration</a>)
|
||||
* Indexed property query methods with the `Nan::IndexQueryCallback` signature (see <a href="#api_nan_index_query">Index query declaration</a>)
|
||||
* Indexed property deleters with the `Nan::IndexDeleterCallback` signature (see <a href="#api_nan_index_deleter">Index deleter declaration</a>)
|
||||
* Indexed property enumerators with the `Nan::IndexEnumeratorCallback` signature (see <a href="#api_nan_index_enumerator">Index enumerator declaration</a>)
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void SetIndexedPropertyHandler(v8::Local<v8::ObjectTemplate> tpl,
|
||||
Nan::IndexGetterCallback getter,
|
||||
Nan::IndexSetterCallback setter = 0,
|
||||
Nan::IndexQueryCallback query = 0,
|
||||
Nan::IndexDeleterCallback deleter = 0,
|
||||
Nan::IndexEnumeratorCallback enumerator = 0,
|
||||
v8::Local<v8::Value> data = v8::Local<v8::Value>())
|
||||
```
|
||||
|
||||
See the V8 [`ObjectTemplate#SetIndexedPropertyHandler()`](https://v8docs.nodesource.com/node-8.16/db/d5f/classv8_1_1_object_template.html#ac89f06d634add0e890452033f7d17ff1) for further information about how to use `Nan::SetIndexedPropertyHandler()`.
|
||||
|
||||
<a name="api_nan_set_template"></a>
|
||||
### Nan::SetTemplate()
|
||||
|
||||
Adds properties on an `Object`'s or `Function`'s template.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::SetTemplate(v8::Local<v8::Template> templ,
|
||||
const char *name,
|
||||
v8::Local<v8::Data> value);
|
||||
void Nan::SetTemplate(v8::Local<v8::Template> templ,
|
||||
v8::Local<v8::String> name,
|
||||
v8::Local<v8::Data> value,
|
||||
v8::PropertyAttribute attributes)
|
||||
```
|
||||
|
||||
Calls the `Template`'s [`Set()`](https://v8docs.nodesource.com/node-8.16/db/df7/classv8_1_1_template.html#ae3fbaff137557aa6a0233bc7e52214ac).
|
||||
|
||||
<a name="api_nan_set_prototype_template"></a>
|
||||
### Nan::SetPrototypeTemplate()
|
||||
|
||||
Adds properties on an `Object`'s or `Function`'s prototype template.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::SetPrototypeTemplate(v8::Local<v8::FunctionTemplate> templ,
|
||||
const char *name,
|
||||
v8::Local<v8::Data> value);
|
||||
void Nan::SetPrototypeTemplate(v8::Local<v8::FunctionTemplate> templ,
|
||||
v8::Local<v8::String> name,
|
||||
v8::Local<v8::Data> value,
|
||||
v8::PropertyAttribute attributes)
|
||||
```
|
||||
|
||||
Calls the `FunctionTemplate`'s _PrototypeTemplate's_ [`Set()`](https://v8docs.nodesource.com/node-8.16/db/df7/classv8_1_1_template.html#a2db6a56597bf23c59659c0659e564ddf).
|
||||
|
||||
<a name="api_nan_set_instance_template"></a>
|
||||
### Nan::SetInstanceTemplate()
|
||||
|
||||
Use to add instance properties on `FunctionTemplate`'s.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::SetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ,
|
||||
const char *name,
|
||||
v8::Local<v8::Data> value);
|
||||
void Nan::SetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ,
|
||||
v8::Local<v8::String> name,
|
||||
v8::Local<v8::Data> value,
|
||||
v8::PropertyAttribute attributes)
|
||||
```
|
||||
|
||||
Calls the `FunctionTemplate`'s _InstanceTemplate's_ [`Set()`](https://v8docs.nodesource.com/node-8.16/db/df7/classv8_1_1_template.html#a2db6a56597bf23c59659c0659e564ddf).
|
||||
|
||||
<a name="api_nan_set_call_handler"></a>
|
||||
### Nan::SetCallHandler()
|
||||
|
||||
Set the call-handler callback for a `v8::FunctionTemplate`.
|
||||
This callback is called whenever the function created from this FunctionTemplate is called.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::SetCallHandler(v8::Local<v8::FunctionTemplate> templ, Nan::FunctionCallback callback, v8::Local<v8::Value> data = v8::Local<v8::Value>())
|
||||
```
|
||||
|
||||
Calls the `FunctionTemplate`'s [`SetCallHandler()`](https://v8docs.nodesource.com/node-8.16/d8/d83/classv8_1_1_function_template.html#ab7574b298db3c27fbc2ed465c08ea2f8).
|
||||
|
||||
<a name="api_nan_set_call_as_function_handler"></a>
|
||||
### Nan::SetCallAsFunctionHandler()
|
||||
|
||||
Sets the callback to be used when calling instances created from the `v8::ObjectTemplate` as a function.
|
||||
If no callback is set, instances behave like normal JavaScript objects that cannot be called as a function.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::SetCallAsFunctionHandler(v8::Local<v8::ObjectTemplate> templ, Nan::FunctionCallback callback, v8::Local<v8::Value> data = v8::Local<v8::Value>())
|
||||
```
|
||||
|
||||
Calls the `ObjectTemplate`'s [`SetCallAsFunctionHandler()`](https://v8docs.nodesource.com/node-8.16/db/d5f/classv8_1_1_object_template.html#a5e9612fc80bf6db8f2da199b9b0bd04e).
|
||||
|
||||
147
tasks/enduro-trails/prototype/node_modules/nan/doc/new.md
generated
vendored
Normal file
147
tasks/enduro-trails/prototype/node_modules/nan/doc/new.md
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
## New
|
||||
|
||||
NAN provides a `Nan::New()` helper for the creation of new JavaScript objects in a way that's compatible across the supported versions of V8.
|
||||
|
||||
- <a href="#api_nan_new"><b><code>Nan::New()</code></b></a>
|
||||
- <a href="#api_nan_undefined"><b><code>Nan::Undefined()</code></b></a>
|
||||
- <a href="#api_nan_null"><b><code>Nan::Null()</code></b></a>
|
||||
- <a href="#api_nan_true"><b><code>Nan::True()</code></b></a>
|
||||
- <a href="#api_nan_false"><b><code>Nan::False()</code></b></a>
|
||||
- <a href="#api_nan_empty_string"><b><code>Nan::EmptyString()</code></b></a>
|
||||
|
||||
|
||||
<a name="api_nan_new"></a>
|
||||
### Nan::New()
|
||||
|
||||
`Nan::New()` should be used to instantiate new JavaScript objects.
|
||||
|
||||
Refer to the specific V8 type in the [V8 documentation](https://v8docs.nodesource.com/node-8.16/d1/d83/classv8_1_1_data.html) for information on the types of arguments required for instantiation.
|
||||
|
||||
Signatures:
|
||||
|
||||
Return types are mostly omitted from the signatures for simplicity. In most cases the type will be contained within a `v8::Local<T>`. The following types will be contained within a `Nan::MaybeLocal<T>`: `v8::String`, `v8::Date`, `v8::RegExp`, `v8::Script`, `v8::UnboundScript`.
|
||||
|
||||
Empty objects:
|
||||
|
||||
```c++
|
||||
Nan::New<T>();
|
||||
```
|
||||
|
||||
Generic single and multiple-argument:
|
||||
|
||||
```c++
|
||||
Nan::New<T>(A0 arg0);
|
||||
Nan::New<T>(A0 arg0, A1 arg1);
|
||||
Nan::New<T>(A0 arg0, A1 arg1, A2 arg2);
|
||||
Nan::New<T>(A0 arg0, A1 arg1, A2 arg2, A3 arg3);
|
||||
```
|
||||
|
||||
For creating `v8::FunctionTemplate` and `v8::Function` objects:
|
||||
|
||||
_The definition of `Nan::FunctionCallback` can be found in the [Method declaration](./methods.md#api_nan_method) documentation._
|
||||
|
||||
```c++
|
||||
Nan::New<T>(Nan::FunctionCallback callback,
|
||||
v8::Local<v8::Value> data = v8::Local<v8::Value>());
|
||||
Nan::New<T>(Nan::FunctionCallback callback,
|
||||
v8::Local<v8::Value> data = v8::Local<v8::Value>(),
|
||||
A2 a2 = A2());
|
||||
```
|
||||
|
||||
Native number types:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Boolean> Nan::New<T>(bool value);
|
||||
v8::Local<v8::Int32> Nan::New<T>(int32_t value);
|
||||
v8::Local<v8::Uint32> Nan::New<T>(uint32_t value);
|
||||
v8::Local<v8::Number> Nan::New<T>(double value);
|
||||
```
|
||||
|
||||
String types:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::String> Nan::New<T>(std::string const& value);
|
||||
Nan::MaybeLocal<v8::String> Nan::New<T>(const char * value, int length);
|
||||
Nan::MaybeLocal<v8::String> Nan::New<T>(const char * value);
|
||||
Nan::MaybeLocal<v8::String> Nan::New<T>(const uint16_t * value);
|
||||
Nan::MaybeLocal<v8::String> Nan::New<T>(const uint16_t * value, int length);
|
||||
```
|
||||
|
||||
Specialized types:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::String> Nan::New<T>(v8::String::ExternalStringResource * value);
|
||||
v8::Local<v8::String> Nan::New<T>(Nan::ExternalOneByteStringResource * value);
|
||||
v8::Local<v8::RegExp> Nan::New<T>(v8::Local<v8::String> pattern, v8::RegExp::Flags flags);
|
||||
```
|
||||
|
||||
Note that `Nan::ExternalOneByteStringResource` maps to [`v8::String::ExternalOneByteStringResource`](https://v8docs.nodesource.com/node-8.16/d9/db3/classv8_1_1_string_1_1_external_one_byte_string_resource.html), and `v8::String::ExternalAsciiStringResource` in older versions of V8.
|
||||
|
||||
|
||||
<a name="api_nan_undefined"></a>
|
||||
### Nan::Undefined()
|
||||
|
||||
A helper method to reference the `v8::Undefined` object in a way that is compatible across all supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Primitive> Nan::Undefined()
|
||||
```
|
||||
|
||||
<a name="api_nan_null"></a>
|
||||
### Nan::Null()
|
||||
|
||||
A helper method to reference the `v8::Null` object in a way that is compatible across all supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Primitive> Nan::Null()
|
||||
```
|
||||
|
||||
<a name="api_nan_true"></a>
|
||||
### Nan::True()
|
||||
|
||||
A helper method to reference the `v8::Boolean` object representing the `true` value in a way that is compatible across all supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Boolean> Nan::True()
|
||||
```
|
||||
|
||||
<a name="api_nan_false"></a>
|
||||
### Nan::False()
|
||||
|
||||
A helper method to reference the `v8::Boolean` object representing the `false` value in a way that is compatible across all supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Boolean> Nan::False()
|
||||
```
|
||||
|
||||
<a name="api_nan_empty_string"></a>
|
||||
### Nan::EmptyString()
|
||||
|
||||
Call [`v8::String::Empty`](https://v8docs.nodesource.com/node-8.16/d2/db3/classv8_1_1_string.html#a7c1bc8886115d7ee46f1d571dd6ebc6d) to reference the empty string in a way that is compatible across all supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::String> Nan::EmptyString()
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_new_one_byte_string"></a>
|
||||
### Nan::NewOneByteString()
|
||||
|
||||
An implementation of [`v8::String::NewFromOneByte()`](https://v8docs.nodesource.com/node-8.16/d2/db3/classv8_1_1_string.html#a5264d50b96d2c896ce525a734dc10f09) provided for consistent availability and API across supported versions of V8. Allocates a new string from Latin-1 data.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::String> Nan::NewOneByteString(const uint8_t * value,
|
||||
int length = -1)
|
||||
```
|
||||
123
tasks/enduro-trails/prototype/node_modules/nan/doc/node_misc.md
generated
vendored
Normal file
123
tasks/enduro-trails/prototype/node_modules/nan/doc/node_misc.md
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
## Miscellaneous Node Helpers
|
||||
|
||||
- <a href="#api_nan_asyncresource"><b><code>Nan::AsyncResource</code></b></a>
|
||||
- <a href="#api_nan_make_callback"><b><code>Nan::MakeCallback()</code></b></a>
|
||||
- <a href="#api_nan_module_init"><b><code>NAN_MODULE_INIT()</code></b></a>
|
||||
- <a href="#api_nan_export"><b><code>Nan::Export()</code></b></a>
|
||||
|
||||
<a name="api_nan_asyncresource"></a>
|
||||
### Nan::AsyncResource
|
||||
|
||||
This class is analogous to the `AsyncResource` JavaScript class exposed by Node's [async_hooks][] API.
|
||||
|
||||
When calling back into JavaScript asynchronously, special care must be taken to ensure that the runtime can properly track
|
||||
async hops. `Nan::AsyncResource` is a class that provides an RAII wrapper around `node::EmitAsyncInit`, `node::EmitAsyncDestroy`,
|
||||
and `node::MakeCallback`. Using this mechanism to call back into JavaScript, as opposed to `Nan::MakeCallback` or
|
||||
`v8::Function::Call` ensures that the callback is executed in the correct async context. This ensures that async mechanisms
|
||||
such as domains and [async_hooks][] function correctly.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
class AsyncResource {
|
||||
public:
|
||||
AsyncResource(v8::Local<v8::String> name,
|
||||
v8::Local<v8::Object> resource = New<v8::Object>());
|
||||
AsyncResource(const char* name,
|
||||
v8::Local<v8::Object> resource = New<v8::Object>());
|
||||
~AsyncResource();
|
||||
|
||||
v8::MaybeLocal<v8::Value> runInAsyncScope(v8::Local<v8::Object> target,
|
||||
v8::Local<v8::Function> func,
|
||||
int argc,
|
||||
v8::Local<v8::Value>* argv);
|
||||
v8::MaybeLocal<v8::Value> runInAsyncScope(v8::Local<v8::Object> target,
|
||||
v8::Local<v8::String> symbol,
|
||||
int argc,
|
||||
v8::Local<v8::Value>* argv);
|
||||
v8::MaybeLocal<v8::Value> runInAsyncScope(v8::Local<v8::Object> target,
|
||||
const char* method,
|
||||
int argc,
|
||||
v8::Local<v8::Value>* argv);
|
||||
};
|
||||
```
|
||||
|
||||
* `name`: Identifier for the kind of resource that is being provided for diagnostics information exposed by the [async_hooks][]
|
||||
API. This will be passed to the possible `init` hook as the `type`. To avoid name collisions with other modules we recommend
|
||||
that the name include the name of the owning module as a prefix. For example `mysql` module could use something like
|
||||
`mysql:batch-db-query-resource`.
|
||||
* `resource`: An optional object associated with the async work that will be passed to the possible [async_hooks][]
|
||||
`init` hook. If this parameter is omitted, or an empty handle is provided, this object will be created automatically.
|
||||
* When calling JS on behalf of this resource, one can use `runInAsyncScope`. This will ensure that the callback runs in the
|
||||
correct async execution context.
|
||||
* `AsyncDestroy` is automatically called when an AsyncResource object is destroyed.
|
||||
|
||||
For more details, see the Node [async_hooks][] documentation. You might also want to take a look at the documentation for the
|
||||
[N-API counterpart][napi]. For example usage, see the `asyncresource.cpp` example in the `test/cpp` directory.
|
||||
|
||||
<a name="api_nan_make_callback"></a>
|
||||
### Nan::MakeCallback()
|
||||
|
||||
Deprecated wrappers around the legacy `node::MakeCallback()` APIs. Node.js 10+
|
||||
has deprecated these legacy APIs as they do not provide a mechanism to preserve
|
||||
async context.
|
||||
|
||||
We recommend that you use the `AsyncResource` class and `AsyncResource::runInAsyncScope` instead of using `Nan::MakeCallback` or
|
||||
`v8::Function#Call()` directly. `AsyncResource` properly takes care of running the callback in the correct async execution
|
||||
context – something that is essential for functionality like domains, async_hooks and async debugging.
|
||||
|
||||
Signatures:
|
||||
|
||||
```c++
|
||||
NAN_DEPRECATED
|
||||
v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object> target,
|
||||
v8::Local<v8::Function> func,
|
||||
int argc,
|
||||
v8::Local<v8::Value>* argv);
|
||||
NAN_DEPRECATED
|
||||
v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object> target,
|
||||
v8::Local<v8::String> symbol,
|
||||
int argc,
|
||||
v8::Local<v8::Value>* argv);
|
||||
NAN_DEPRECATED
|
||||
v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object> target,
|
||||
const char* method,
|
||||
int argc,
|
||||
v8::Local<v8::Value>* argv);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_module_init"></a>
|
||||
### NAN_MODULE_INIT()
|
||||
|
||||
Used to define the entry point function to a Node add-on. Creates a function with a given `name` that receives a `target` object representing the equivalent of the JavaScript `exports` object.
|
||||
|
||||
See example below.
|
||||
|
||||
<a name="api_nan_export"></a>
|
||||
### Nan::Export()
|
||||
|
||||
A simple helper to register a `v8::FunctionTemplate` from a JavaScript-accessible method (see [Methods](./methods.md)) as a property on an object. Can be used in a way similar to assigning properties to `module.exports` in JavaScript.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Export(v8::Local<v8::Object> target, const char *name, Nan::FunctionCallback f)
|
||||
```
|
||||
|
||||
Also available as the shortcut `NAN_EXPORT` macro.
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
NAN_METHOD(Foo) {
|
||||
...
|
||||
}
|
||||
|
||||
NAN_MODULE_INIT(Init) {
|
||||
NAN_EXPORT(target, Foo);
|
||||
}
|
||||
```
|
||||
|
||||
[async_hooks]: https://nodejs.org/dist/latest-v9.x/docs/api/async_hooks.html
|
||||
[napi]: https://nodejs.org/dist/latest-v9.x/docs/api/n-api.html#n_api_custom_asynchronous_operations
|
||||
263
tasks/enduro-trails/prototype/node_modules/nan/doc/object_wrappers.md
generated
vendored
Normal file
263
tasks/enduro-trails/prototype/node_modules/nan/doc/object_wrappers.md
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
## Object Wrappers
|
||||
|
||||
The `ObjectWrap` class can be used to make wrapped C++ objects and a factory of wrapped objects.
|
||||
|
||||
- <a href="#api_nan_object_wrap"><b><code>Nan::ObjectWrap</code></b></a>
|
||||
|
||||
|
||||
<a name="api_nan_object_wrap"></a>
|
||||
### Nan::ObjectWrap()
|
||||
|
||||
A reimplementation of `node::ObjectWrap` that adds some API not present in older versions of Node. Should be preferred over `node::ObjectWrap` in all cases for consistency.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
class ObjectWrap {
|
||||
public:
|
||||
ObjectWrap();
|
||||
|
||||
virtual ~ObjectWrap();
|
||||
|
||||
template <class T>
|
||||
static inline T* Unwrap(v8::Local<v8::Object> handle);
|
||||
|
||||
inline v8::Local<v8::Object> handle();
|
||||
|
||||
inline Nan::Persistent<v8::Object>& persistent();
|
||||
|
||||
protected:
|
||||
inline void Wrap(v8::Local<v8::Object> handle);
|
||||
|
||||
inline void MakeWeak();
|
||||
|
||||
/* Ref() marks the object as being attached to an event loop.
|
||||
* Refed objects will not be garbage collected, even if
|
||||
* all references are lost.
|
||||
*/
|
||||
virtual void Ref();
|
||||
|
||||
/* Unref() marks an object as detached from the event loop. This is its
|
||||
* default state. When an object with a "weak" reference changes from
|
||||
* attached to detached state it will be freed. Be careful not to access
|
||||
* the object after making this call as it might be gone!
|
||||
* (A "weak reference" means an object that only has a
|
||||
* persistent handle.)
|
||||
*
|
||||
* DO NOT CALL THIS FROM DESTRUCTOR
|
||||
*/
|
||||
virtual void Unref();
|
||||
|
||||
int refs_; // ro
|
||||
};
|
||||
```
|
||||
|
||||
See the Node documentation on [Wrapping C++ Objects](https://nodejs.org/api/addons.html#addons_wrapping_c_objects) for more details.
|
||||
|
||||
### This vs. Holder
|
||||
|
||||
When calling `Unwrap`, it is important that the argument is indeed some JavaScript object which got wrapped by a `Wrap` call for this class or any derived class.
|
||||
The `Signature` installed by [`Nan::SetPrototypeMethod()`](methods.md#api_nan_set_prototype_method) does ensure that `info.Holder()` is just such an instance.
|
||||
In Node 0.12 and later, `info.This()` will also be of such a type, since otherwise the invocation will get rejected.
|
||||
However, in Node 0.10 and before it was possible to invoke a method on a JavaScript object which just had the extension type in its prototype chain.
|
||||
In such a situation, calling `Unwrap` on `info.This()` will likely lead to a failed assertion causing a crash, but could lead to even more serious corruption.
|
||||
|
||||
On the other hand, calling `Unwrap` in an [accessor](methods.md#api_nan_set_accessor) should not use `Holder()` if the accessor is defined on the prototype.
|
||||
So either define your accessors on the instance template,
|
||||
or use `This()` after verifying that it is indeed a valid object.
|
||||
|
||||
### Examples
|
||||
|
||||
#### Basic
|
||||
|
||||
```c++
|
||||
class MyObject : public Nan::ObjectWrap {
|
||||
public:
|
||||
static NAN_MODULE_INIT(Init) {
|
||||
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
|
||||
tpl->SetClassName(Nan::New("MyObject").ToLocalChecked());
|
||||
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
|
||||
Nan::SetPrototypeMethod(tpl, "getHandle", GetHandle);
|
||||
Nan::SetPrototypeMethod(tpl, "getValue", GetValue);
|
||||
|
||||
constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked());
|
||||
Nan::Set(target, Nan::New("MyObject").ToLocalChecked(),
|
||||
Nan::GetFunction(tpl).ToLocalChecked());
|
||||
}
|
||||
|
||||
private:
|
||||
explicit MyObject(double value = 0) : value_(value) {}
|
||||
~MyObject() {}
|
||||
|
||||
static NAN_METHOD(New) {
|
||||
if (info.IsConstructCall()) {
|
||||
double value = info[0]->IsUndefined() ? 0 : Nan::To<double>(info[0]).FromJust();
|
||||
MyObject *obj = new MyObject(value);
|
||||
obj->Wrap(info.This());
|
||||
info.GetReturnValue().Set(info.This());
|
||||
} else {
|
||||
const int argc = 1;
|
||||
v8::Local<v8::Value> argv[argc] = {info[0]};
|
||||
v8::Local<v8::Function> cons = Nan::New(constructor());
|
||||
info.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
|
||||
}
|
||||
}
|
||||
|
||||
static NAN_METHOD(GetHandle) {
|
||||
MyObject* obj = Nan::ObjectWrap::Unwrap<MyObject>(info.Holder());
|
||||
info.GetReturnValue().Set(obj->handle());
|
||||
}
|
||||
|
||||
static NAN_METHOD(GetValue) {
|
||||
MyObject* obj = Nan::ObjectWrap::Unwrap<MyObject>(info.Holder());
|
||||
info.GetReturnValue().Set(obj->value_);
|
||||
}
|
||||
|
||||
static inline Nan::Persistent<v8::Function> & constructor() {
|
||||
static Nan::Persistent<v8::Function> my_constructor;
|
||||
return my_constructor;
|
||||
}
|
||||
|
||||
double value_;
|
||||
};
|
||||
|
||||
NODE_MODULE(objectwrapper, MyObject::Init)
|
||||
```
|
||||
|
||||
To use in Javascript:
|
||||
|
||||
```Javascript
|
||||
var objectwrapper = require('bindings')('objectwrapper');
|
||||
|
||||
var obj = new objectwrapper.MyObject(5);
|
||||
console.log('Should be 5: ' + obj.getValue());
|
||||
```
|
||||
|
||||
#### Factory of wrapped objects
|
||||
|
||||
```c++
|
||||
class MyFactoryObject : public Nan::ObjectWrap {
|
||||
public:
|
||||
static NAN_MODULE_INIT(Init) {
|
||||
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
|
||||
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
|
||||
Nan::SetPrototypeMethod(tpl, "getValue", GetValue);
|
||||
|
||||
constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked());
|
||||
}
|
||||
|
||||
static NAN_METHOD(NewInstance) {
|
||||
v8::Local<v8::Function> cons = Nan::New(constructor());
|
||||
double value = info[0]->IsNumber() ? Nan::To<double>(info[0]).FromJust() : 0;
|
||||
const int argc = 1;
|
||||
v8::Local<v8::Value> argv[1] = {Nan::New(value)};
|
||||
info.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
|
||||
}
|
||||
|
||||
// Needed for the next example:
|
||||
inline double value() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
private:
|
||||
explicit MyFactoryObject(double value = 0) : value_(value) {}
|
||||
~MyFactoryObject() {}
|
||||
|
||||
static NAN_METHOD(New) {
|
||||
if (info.IsConstructCall()) {
|
||||
double value = info[0]->IsNumber() ? Nan::To<double>(info[0]).FromJust() : 0;
|
||||
MyFactoryObject * obj = new MyFactoryObject(value);
|
||||
obj->Wrap(info.This());
|
||||
info.GetReturnValue().Set(info.This());
|
||||
} else {
|
||||
const int argc = 1;
|
||||
v8::Local<v8::Value> argv[argc] = {info[0]};
|
||||
v8::Local<v8::Function> cons = Nan::New(constructor());
|
||||
info.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
|
||||
}
|
||||
}
|
||||
|
||||
static NAN_METHOD(GetValue) {
|
||||
MyFactoryObject* obj = ObjectWrap::Unwrap<MyFactoryObject>(info.Holder());
|
||||
info.GetReturnValue().Set(obj->value_);
|
||||
}
|
||||
|
||||
static inline Nan::Persistent<v8::Function> & constructor() {
|
||||
static Nan::Persistent<v8::Function> my_constructor;
|
||||
return my_constructor;
|
||||
}
|
||||
|
||||
double value_;
|
||||
};
|
||||
|
||||
NAN_MODULE_INIT(Init) {
|
||||
MyFactoryObject::Init(target);
|
||||
Nan::Set(target,
|
||||
Nan::New<v8::String>("newFactoryObjectInstance").ToLocalChecked(),
|
||||
Nan::GetFunction(
|
||||
Nan::New<v8::FunctionTemplate>(MyFactoryObject::NewInstance)).ToLocalChecked()
|
||||
);
|
||||
}
|
||||
|
||||
NODE_MODULE(wrappedobjectfactory, Init)
|
||||
```
|
||||
|
||||
To use in Javascript:
|
||||
|
||||
```Javascript
|
||||
var wrappedobjectfactory = require('bindings')('wrappedobjectfactory');
|
||||
|
||||
var obj = wrappedobjectfactory.newFactoryObjectInstance(10);
|
||||
console.log('Should be 10: ' + obj.getValue());
|
||||
```
|
||||
|
||||
#### Passing wrapped objects around
|
||||
|
||||
Use the `MyFactoryObject` class above along with the following:
|
||||
|
||||
```c++
|
||||
static NAN_METHOD(Sum) {
|
||||
Nan::MaybeLocal<v8::Object> maybe1 = Nan::To<v8::Object>(info[0]);
|
||||
Nan::MaybeLocal<v8::Object> maybe2 = Nan::To<v8::Object>(info[1]);
|
||||
|
||||
// Quick check:
|
||||
if (maybe1.IsEmpty() || maybe2.IsEmpty()) {
|
||||
// return value is undefined by default
|
||||
return;
|
||||
}
|
||||
|
||||
MyFactoryObject* obj1 =
|
||||
Nan::ObjectWrap::Unwrap<MyFactoryObject>(maybe1.ToLocalChecked());
|
||||
MyFactoryObject* obj2 =
|
||||
Nan::ObjectWrap::Unwrap<MyFactoryObject>(maybe2.ToLocalChecked());
|
||||
|
||||
info.GetReturnValue().Set(Nan::New<v8::Number>(obj1->value() + obj2->value()));
|
||||
}
|
||||
|
||||
NAN_MODULE_INIT(Init) {
|
||||
MyFactoryObject::Init(target);
|
||||
Nan::Set(target,
|
||||
Nan::New<v8::String>("newFactoryObjectInstance").ToLocalChecked(),
|
||||
Nan::GetFunction(
|
||||
Nan::New<v8::FunctionTemplate>(MyFactoryObject::NewInstance)).ToLocalChecked()
|
||||
);
|
||||
Nan::Set(target,
|
||||
Nan::New<v8::String>("sum").ToLocalChecked(),
|
||||
Nan::GetFunction(Nan::New<v8::FunctionTemplate>(Sum)).ToLocalChecked()
|
||||
);
|
||||
}
|
||||
|
||||
NODE_MODULE(myaddon, Init)
|
||||
```
|
||||
|
||||
To use in Javascript:
|
||||
|
||||
```Javascript
|
||||
var myaddon = require('bindings')('myaddon');
|
||||
|
||||
var obj1 = myaddon.newFactoryObjectInstance(5);
|
||||
var obj2 = myaddon.newFactoryObjectInstance(10);
|
||||
console.log('sum of object values: ' + myaddon.sum(obj1, obj2));
|
||||
```
|
||||
296
tasks/enduro-trails/prototype/node_modules/nan/doc/persistent.md
generated
vendored
Normal file
296
tasks/enduro-trails/prototype/node_modules/nan/doc/persistent.md
generated
vendored
Normal file
@@ -0,0 +1,296 @@
|
||||
## Persistent references
|
||||
|
||||
An object reference that is independent of any `HandleScope` is a _persistent_ reference. Where a `Local` handle only lives as long as the `HandleScope` in which it was allocated, a `Persistent` handle remains valid until it is explicitly disposed.
|
||||
|
||||
Due to the evolution of the V8 API, it is necessary for NAN to provide a wrapper implementation of the `Persistent` classes to supply compatibility across the V8 versions supported.
|
||||
|
||||
- <a href="#api_nan_persistent_base"><b><code>Nan::PersistentBase & v8::PersistentBase</code></b></a>
|
||||
- <a href="#api_nan_non_copyable_persistent_traits"><b><code>Nan::NonCopyablePersistentTraits & v8::NonCopyablePersistentTraits</code></b></a>
|
||||
- <a href="#api_nan_copyable_persistent_traits"><b><code>Nan::CopyablePersistentTraits & v8::CopyablePersistentTraits</code></b></a>
|
||||
- <a href="#api_nan_persistent"><b><code>Nan::Persistent</code></b></a>
|
||||
- <a href="#api_nan_global"><b><code>Nan::Global</code></b></a>
|
||||
- <a href="#api_nan_weak_callback_info"><b><code>Nan::WeakCallbackInfo</code></b></a>
|
||||
- <a href="#api_nan_weak_callback_type"><b><code>Nan::WeakCallbackType</code></b></a>
|
||||
|
||||
Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://v8.dev/docs/embed#handles-and-garbage-collection).
|
||||
|
||||
<a name="api_nan_persistent_base"></a>
|
||||
### Nan::PersistentBase & v8::PersistentBase
|
||||
|
||||
A persistent handle contains a reference to a storage cell in V8 which holds an object value and which is updated by the garbage collector whenever the object is moved. A new storage cell can be created using the constructor or `Nan::PersistentBase::Reset()`. Existing handles can be disposed using an argument-less `Nan::PersistentBase::Reset()`.
|
||||
|
||||
Definition:
|
||||
|
||||
_(note: this is implemented as `Nan::PersistentBase` for older versions of V8 and the native `v8::PersistentBase` is used for newer versions of V8)_
|
||||
|
||||
```c++
|
||||
template<typename T> class PersistentBase {
|
||||
public:
|
||||
/**
|
||||
* If non-empty, destroy the underlying storage cell
|
||||
*/
|
||||
void Reset();
|
||||
|
||||
/**
|
||||
* If non-empty, destroy the underlying storage cell and create a new one with
|
||||
* the contents of another if it is also non-empty
|
||||
*/
|
||||
template<typename S> void Reset(const v8::Local<S> &other);
|
||||
|
||||
/**
|
||||
* If non-empty, destroy the underlying storage cell and create a new one with
|
||||
* the contents of another if it is also non-empty
|
||||
*/
|
||||
template<typename S> void Reset(const PersistentBase<S> &other);
|
||||
|
||||
/** Returns true if the handle is empty. */
|
||||
bool IsEmpty() const;
|
||||
|
||||
/**
|
||||
* If non-empty, destroy the underlying storage cell
|
||||
* IsEmpty() will return true after this call.
|
||||
*/
|
||||
void Empty();
|
||||
|
||||
template<typename S> bool operator==(const PersistentBase<S> &that);
|
||||
|
||||
template<typename S> bool operator==(const v8::Local<S> &that);
|
||||
|
||||
template<typename S> bool operator!=(const PersistentBase<S> &that);
|
||||
|
||||
template<typename S> bool operator!=(const v8::Local<S> &that);
|
||||
|
||||
/**
|
||||
* Install a finalization callback on this object.
|
||||
* NOTE: There is no guarantee as to *when* or even *if* the callback is
|
||||
* invoked. The invocation is performed solely on a best effort basis.
|
||||
* As always, GC-based finalization should *not* be relied upon for any
|
||||
* critical form of resource management! At the moment you can either
|
||||
* specify a parameter for the callback or the location of two internal
|
||||
* fields in the dying object.
|
||||
*/
|
||||
template<typename P>
|
||||
void SetWeak(P *parameter,
|
||||
typename WeakCallbackInfo<P>::Callback callback,
|
||||
WeakCallbackType type);
|
||||
|
||||
void ClearWeak();
|
||||
|
||||
/**
|
||||
* Marks the reference to this object independent. Garbage collector is free
|
||||
* to ignore any object groups containing this object. Weak callback for an
|
||||
* independent handle should not assume that it will be preceded by a global
|
||||
* GC prologue callback or followed by a global GC epilogue callback.
|
||||
*/
|
||||
void MarkIndependent() const;
|
||||
|
||||
bool IsIndependent() const;
|
||||
|
||||
/** Checks if the handle holds the only reference to an object. */
|
||||
bool IsNearDeath() const;
|
||||
|
||||
/** Returns true if the handle's reference is weak. */
|
||||
bool IsWeak() const
|
||||
};
|
||||
```
|
||||
|
||||
See the V8 documentation for [`PersistentBase`](https://v8docs.nodesource.com/node-8.16/d4/dca/classv8_1_1_persistent_base.html) for further information.
|
||||
|
||||
**Tip:** To get a `v8::Local` reference to the original object back from a `PersistentBase` or `Persistent` object:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Object> object = Nan::New(persistent);
|
||||
```
|
||||
|
||||
<a name="api_nan_non_copyable_persistent_traits"></a>
|
||||
### Nan::NonCopyablePersistentTraits & v8::NonCopyablePersistentTraits
|
||||
|
||||
Default traits for `Nan::Persistent`. This class does not allow use of the a copy constructor or assignment operator. At present `kResetInDestructor` is not set, but that will change in a future version.
|
||||
|
||||
Definition:
|
||||
|
||||
_(note: this is implemented as `Nan::NonCopyablePersistentTraits` for older versions of V8 and the native `v8::NonCopyablePersistentTraits` is used for newer versions of V8)_
|
||||
|
||||
```c++
|
||||
template<typename T> class NonCopyablePersistentTraits {
|
||||
public:
|
||||
typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent;
|
||||
|
||||
static const bool kResetInDestructor = false;
|
||||
|
||||
template<typename S, typename M>
|
||||
static void Copy(const Persistent<S, M> &source,
|
||||
NonCopyablePersistent *dest);
|
||||
|
||||
template<typename O> static void Uncompilable();
|
||||
};
|
||||
```
|
||||
|
||||
See the V8 documentation for [`NonCopyablePersistentTraits`](https://v8docs.nodesource.com/node-8.16/de/d73/classv8_1_1_non_copyable_persistent_traits.html) for further information.
|
||||
|
||||
<a name="api_nan_copyable_persistent_traits"></a>
|
||||
### Nan::CopyablePersistentTraits & v8::CopyablePersistentTraits
|
||||
|
||||
A helper class of traits to allow copying and assignment of `Persistent`. This will clone the contents of storage cell, but not any of the flags, etc..
|
||||
|
||||
Definition:
|
||||
|
||||
_(note: this is implemented as `Nan::CopyablePersistentTraits` for older versions of V8 and the native `v8::NonCopyablePersistentTraits` is used for newer versions of V8)_
|
||||
|
||||
```c++
|
||||
template<typename T>
|
||||
class CopyablePersistentTraits {
|
||||
public:
|
||||
typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
|
||||
|
||||
static const bool kResetInDestructor = true;
|
||||
|
||||
template<typename S, typename M>
|
||||
static void Copy(const Persistent<S, M> &source,
|
||||
CopyablePersistent *dest);
|
||||
};
|
||||
```
|
||||
|
||||
See the V8 documentation for [`CopyablePersistentTraits`](https://v8docs.nodesource.com/node-8.16/da/d5c/structv8_1_1_copyable_persistent_traits.html) for further information.
|
||||
|
||||
<a name="api_nan_persistent"></a>
|
||||
### Nan::Persistent
|
||||
|
||||
A type of `PersistentBase` which allows copy and assignment. Copy, assignment and destructor behavior is controlled by the traits class `M`.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
template<typename T, typename M = NonCopyablePersistentTraits<T> >
|
||||
class Persistent;
|
||||
|
||||
template<typename T, typename M> class Persistent : public PersistentBase<T> {
|
||||
public:
|
||||
/**
|
||||
* A Persistent with no storage cell.
|
||||
*/
|
||||
Persistent();
|
||||
|
||||
/**
|
||||
* Construct a Persistent from a v8::Local. When the v8::Local is non-empty, a
|
||||
* new storage cell is created pointing to the same object, and no flags are
|
||||
* set.
|
||||
*/
|
||||
template<typename S> Persistent(v8::Local<S> that);
|
||||
|
||||
/**
|
||||
* Construct a Persistent from a Persistent. When the Persistent is non-empty,
|
||||
* a new storage cell is created pointing to the same object, and no flags are
|
||||
* set.
|
||||
*/
|
||||
Persistent(const Persistent &that);
|
||||
|
||||
/**
|
||||
* The copy constructors and assignment operator create a Persistent exactly
|
||||
* as the Persistent constructor, but the Copy function from the traits class
|
||||
* is called, allowing the setting of flags based on the copied Persistent.
|
||||
*/
|
||||
Persistent &operator=(const Persistent &that);
|
||||
|
||||
template <typename S, typename M2>
|
||||
Persistent &operator=(const Persistent<S, M2> &that);
|
||||
|
||||
/**
|
||||
* The destructor will dispose the Persistent based on the kResetInDestructor
|
||||
* flags in the traits class. Since not calling dispose can result in a
|
||||
* memory leak, it is recommended to always set this flag.
|
||||
*/
|
||||
~Persistent();
|
||||
};
|
||||
```
|
||||
|
||||
See the V8 documentation for [`Persistent`](https://v8docs.nodesource.com/node-8.16/d2/d78/classv8_1_1_persistent.html) for further information.
|
||||
|
||||
<a name="api_nan_global"></a>
|
||||
### Nan::Global
|
||||
|
||||
A type of `PersistentBase` which has move semantics.
|
||||
|
||||
```c++
|
||||
template<typename T> class Global : public PersistentBase<T> {
|
||||
public:
|
||||
/**
|
||||
* A Global with no storage cell.
|
||||
*/
|
||||
Global();
|
||||
|
||||
/**
|
||||
* Construct a Global from a v8::Local. When the v8::Local is non-empty, a new
|
||||
* storage cell is created pointing to the same object, and no flags are set.
|
||||
*/
|
||||
template<typename S> Global(v8::Local<S> that);
|
||||
/**
|
||||
* Construct a Global from a PersistentBase. When the Persistent is non-empty,
|
||||
* a new storage cell is created pointing to the same object, and no flags are
|
||||
* set.
|
||||
*/
|
||||
template<typename S> Global(const PersistentBase<S> &that);
|
||||
|
||||
/**
|
||||
* Pass allows returning globals from functions, etc.
|
||||
*/
|
||||
Global Pass();
|
||||
};
|
||||
```
|
||||
|
||||
See the V8 documentation for [`Global`](https://v8docs.nodesource.com/node-8.16/d5/d40/classv8_1_1_global.html) for further information.
|
||||
|
||||
<a name="api_nan_weak_callback_info"></a>
|
||||
### Nan::WeakCallbackInfo
|
||||
|
||||
`Nan::WeakCallbackInfo` is used as an argument when setting a persistent reference as weak. You may need to free any external resources attached to the object. It is a mirror of `v8:WeakCallbackInfo` as found in newer versions of V8.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
template<typename T> class WeakCallbackInfo {
|
||||
public:
|
||||
typedef void (*Callback)(const WeakCallbackInfo<T>& data);
|
||||
|
||||
v8::Isolate *GetIsolate() const;
|
||||
|
||||
/**
|
||||
* Get the parameter that was associated with the weak handle.
|
||||
*/
|
||||
T *GetParameter() const;
|
||||
|
||||
/**
|
||||
* Get pointer from internal field, index can be 0 or 1.
|
||||
*/
|
||||
void *GetInternalField(int index) const;
|
||||
};
|
||||
```
|
||||
|
||||
Example usage:
|
||||
|
||||
```c++
|
||||
void weakCallback(const WeakCallbackInfo<int> &data) {
|
||||
int *parameter = data.GetParameter();
|
||||
delete parameter;
|
||||
}
|
||||
|
||||
Persistent<v8::Object> obj;
|
||||
int *data = new int(0);
|
||||
obj.SetWeak(data, callback, WeakCallbackType::kParameter);
|
||||
```
|
||||
|
||||
See the V8 documentation for [`WeakCallbackInfo`](https://v8docs.nodesource.com/node-8.16/d8/d06/classv8_1_1_weak_callback_info.html) for further information.
|
||||
|
||||
<a name="api_nan_weak_callback_type"></a>
|
||||
### Nan::WeakCallbackType
|
||||
|
||||
Represents the type of a weak callback.
|
||||
A weak callback of type `kParameter` makes the supplied parameter to `Nan::PersistentBase::SetWeak` available through `WeakCallbackInfo::GetParameter`.
|
||||
A weak callback of type `kInternalFields` uses up to two internal fields at indices 0 and 1 on the `Nan::PersistentBase<v8::Object>` being made weak.
|
||||
Note that only `v8::Object`s and derivatives can have internal fields.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
enum class WeakCallbackType { kParameter, kInternalFields };
|
||||
```
|
||||
73
tasks/enduro-trails/prototype/node_modules/nan/doc/scopes.md
generated
vendored
Normal file
73
tasks/enduro-trails/prototype/node_modules/nan/doc/scopes.md
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
## Scopes
|
||||
|
||||
A _local handle_ is a pointer to an object. All V8 objects are accessed using handles, they are necessary because of the way the V8 garbage collector works.
|
||||
|
||||
A handle scope can be thought of as a container for any number of handles. When you've finished with your handles, instead of deleting each one individually you can simply delete their scope.
|
||||
|
||||
The creation of `HandleScope` objects is different across the supported versions of V8. Therefore, NAN provides its own implementations that can be used safely across these.
|
||||
|
||||
- <a href="#api_nan_handle_scope"><b><code>Nan::HandleScope</code></b></a>
|
||||
- <a href="#api_nan_escapable_handle_scope"><b><code>Nan::EscapableHandleScope</code></b></a>
|
||||
|
||||
Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://github.com/v8/v8/wiki/Embedder%27s%20Guide#handles-and-garbage-collection).
|
||||
|
||||
<a name="api_nan_handle_scope"></a>
|
||||
### Nan::HandleScope
|
||||
|
||||
A simple wrapper around [`v8::HandleScope`](https://v8docs.nodesource.com/node-8.16/d3/d95/classv8_1_1_handle_scope.html).
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
class Nan::HandleScope {
|
||||
public:
|
||||
Nan::HandleScope();
|
||||
static int NumberOfHandles();
|
||||
};
|
||||
```
|
||||
|
||||
Allocate a new `Nan::HandleScope` whenever you are creating new V8 JavaScript objects. Note that an implicit `HandleScope` is created for you on JavaScript-accessible methods so you do not need to insert one yourself.
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
// new object is created, it needs a new scope:
|
||||
void Pointless() {
|
||||
Nan::HandleScope scope;
|
||||
v8::Local<v8::Object> obj = Nan::New<v8::Object>();
|
||||
}
|
||||
|
||||
// JavaScript-accessible method already has a HandleScope
|
||||
NAN_METHOD(Pointless2) {
|
||||
v8::Local<v8::Object> obj = Nan::New<v8::Object>();
|
||||
}
|
||||
```
|
||||
|
||||
<a name="api_nan_escapable_handle_scope"></a>
|
||||
### Nan::EscapableHandleScope
|
||||
|
||||
Similar to [`Nan::HandleScope`](#api_nan_handle_scope) but should be used in cases where a function needs to return a V8 JavaScript type that has been created within it.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
class Nan::EscapableHandleScope {
|
||||
public:
|
||||
Nan::EscapableHandleScope();
|
||||
static int NumberOfHandles();
|
||||
template<typename T> v8::Local<T> Escape(v8::Local<T> value);
|
||||
}
|
||||
```
|
||||
|
||||
Use `Escape(value)` to return the object.
|
||||
|
||||
Example:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Object> EmptyObj() {
|
||||
Nan::EscapableHandleScope scope;
|
||||
v8::Local<v8::Object> obj = Nan::New<v8::Object>();
|
||||
return scope.Escape(obj);
|
||||
}
|
||||
```
|
||||
|
||||
58
tasks/enduro-trails/prototype/node_modules/nan/doc/script.md
generated
vendored
Normal file
58
tasks/enduro-trails/prototype/node_modules/nan/doc/script.md
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
## Script
|
||||
|
||||
NAN provides `v8::Script` helpers as the API has changed over the supported versions of V8.
|
||||
|
||||
- <a href="#api_nan_compile_script"><b><code>Nan::CompileScript()</code></b></a>
|
||||
- <a href="#api_nan_run_script"><b><code>Nan::RunScript()</code></b></a>
|
||||
- <a href="#api_nan_script_origin"><b><code>Nan::ScriptOrigin</code></b></a>
|
||||
|
||||
|
||||
<a name="api_nan_compile_script"></a>
|
||||
### Nan::CompileScript()
|
||||
|
||||
A wrapper around [`v8::ScriptCompiler::Compile()`](https://v8docs.nodesource.com/node-8.16/da/da5/classv8_1_1_script_compiler.html#a93f5072a0db55d881b969e9fc98e564b).
|
||||
|
||||
Note that `Nan::BoundScript` is an alias for `v8::Script`.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<Nan::BoundScript> Nan::CompileScript(
|
||||
v8::Local<v8::String> s,
|
||||
const v8::ScriptOrigin& origin);
|
||||
Nan::MaybeLocal<Nan::BoundScript> Nan::CompileScript(v8::Local<v8::String> s);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_run_script"></a>
|
||||
### Nan::RunScript()
|
||||
|
||||
Calls `script->Run()` or `script->BindToCurrentContext()->Run(Nan::GetCurrentContext())`.
|
||||
|
||||
Note that `Nan::BoundScript` is an alias for `v8::Script` and `Nan::UnboundScript` is an alias for `v8::UnboundScript` where available and `v8::Script` on older versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Value> Nan::RunScript(v8::Local<Nan::UnboundScript> script)
|
||||
Nan::MaybeLocal<v8::Value> Nan::RunScript(v8::Local<Nan::BoundScript> script)
|
||||
```
|
||||
|
||||
<a name="api_nan_script_origin"></a>
|
||||
### Nan::ScriptOrigin
|
||||
|
||||
A class transparently extending [`v8::ScriptOrigin`](https://v8docs.nodesource.com/node-16.0/db/d84/classv8_1_1_script_origin.html#pub-methods)
|
||||
to provide backwards compatibility. Only the listed methods are guaranteed to
|
||||
be available on all versions of Node.
|
||||
|
||||
Declaration:
|
||||
|
||||
```c++
|
||||
class Nan::ScriptOrigin : public v8::ScriptOrigin {
|
||||
public:
|
||||
ScriptOrigin(v8::Local<v8::Value> name, v8::Local<v8::Integer> line = v8::Local<v8::Integer>(), v8::Local<v8::Integer> column = v8::Local<v8::Integer>())
|
||||
v8::Local<v8::Value> ResourceName() const;
|
||||
v8::Local<v8::Integer> ResourceLineOffset() const;
|
||||
v8::Local<v8::Integer> ResourceColumnOffset() const;
|
||||
}
|
||||
```
|
||||
81
tasks/enduro-trails/prototype/node_modules/nan/doc/string_bytes.md
generated
vendored
Normal file
81
tasks/enduro-trails/prototype/node_modules/nan/doc/string_bytes.md
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
## Strings & Bytes
|
||||
|
||||
Miscellaneous string & byte encoding and decoding functionality provided for compatibility across supported versions of V8 and Node. Implemented by NAN to ensure that all encoding types are supported, even for older versions of Node where they are missing.
|
||||
|
||||
- <a href="#api_nan_encoding"><b><code>Nan::Encoding</code></b></a>
|
||||
- <a href="#api_nan_encode"><b><code>Nan::Encode()</code></b></a>
|
||||
- <a href="#api_nan_try_encode"><b><code>Nan::TryEncode()</code></b></a>
|
||||
- <a href="#api_nan_decode_bytes"><b><code>Nan::DecodeBytes()</code></b></a>
|
||||
- <a href="#api_nan_decode_write"><b><code>Nan::DecodeWrite()</code></b></a>
|
||||
|
||||
|
||||
<a name="api_nan_encoding"></a>
|
||||
### Nan::Encoding
|
||||
|
||||
An enum representing the supported encoding types. A copy of `node::encoding` that is consistent across versions of Node.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
enum Nan::Encoding { ASCII, UTF8, BASE64, UCS2, BINARY, HEX, BUFFER }
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_encode"></a>
|
||||
### Nan::Encode()
|
||||
|
||||
A wrapper around `node::Encode()` that provides a consistent implementation across supported versions of Node.
|
||||
|
||||
**Note** `node::Encode()` was deprecated in Node 24 but will remain to maintain backwards compatibility. For Node 24 and higher consider using [`Nan::TryEncode()`](#api_nan_try_encode).
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Value> Nan::Encode(const void *buf,
|
||||
size_t len,
|
||||
enum Nan::Encoding encoding = BINARY);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_try_encode"></a>
|
||||
### Nan::TryEncode()
|
||||
|
||||
A wrapper around `node::TryEncode()` that provides a consistent implementation across supported versions of Node.
|
||||
|
||||
**Note** Only available in Node 24 and higher. For earlier versions use [`Nan::Encode()`](#api_nan_encode).
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
Nan::MaybeLocal<v8::Value> Nan::TryEncode(const void *buf,
|
||||
size_t len,
|
||||
enum Nan::Encoding encoding = BINARY);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_decode_bytes"></a>
|
||||
### Nan::DecodeBytes()
|
||||
|
||||
A wrapper around `node::DecodeBytes()` that provides a consistent implementation across supported versions of Node.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
ssize_t Nan::DecodeBytes(v8::Local<v8::Value> val,
|
||||
enum Nan::Encoding encoding = BINARY);
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_decode_write"></a>
|
||||
### Nan::DecodeWrite()
|
||||
|
||||
A wrapper around `node::DecodeWrite()` that provides a consistent implementation across supported versions of Node.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
ssize_t Nan::DecodeWrite(char *buf,
|
||||
size_t len,
|
||||
v8::Local<v8::Value> val,
|
||||
enum Nan::Encoding encoding = BINARY);
|
||||
```
|
||||
199
tasks/enduro-trails/prototype/node_modules/nan/doc/v8_internals.md
generated
vendored
Normal file
199
tasks/enduro-trails/prototype/node_modules/nan/doc/v8_internals.md
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
## V8 internals
|
||||
|
||||
The hooks to access V8 internals—including GC and statistics—are different across the supported versions of V8, therefore NAN provides its own hooks that call the appropriate V8 methods.
|
||||
|
||||
- <a href="#api_nan_gc_callback"><b><code>NAN_GC_CALLBACK()</code></b></a>
|
||||
- <a href="#api_nan_add_gc_epilogue_callback"><b><code>Nan::AddGCEpilogueCallback()</code></b></a>
|
||||
- <a href="#api_nan_remove_gc_epilogue_callback"><b><code>Nan::RemoveGCEpilogueCallback()</code></b></a>
|
||||
- <a href="#api_nan_add_gc_prologue_callback"><b><code>Nan::AddGCPrologueCallback()</code></b></a>
|
||||
- <a href="#api_nan_remove_gc_prologue_callback"><b><code>Nan::RemoveGCPrologueCallback()</code></b></a>
|
||||
- <a href="#api_nan_get_heap_statistics"><b><code>Nan::GetHeapStatistics()</code></b></a>
|
||||
- <a href="#api_nan_set_counter_function"><b><code>Nan::SetCounterFunction()</code></b></a>
|
||||
- <a href="#api_nan_set_create_histogram_function"><b><code>Nan::SetCreateHistogramFunction()</code></b></a>
|
||||
- <a href="#api_nan_set_add_histogram_sample_function"><b><code>Nan::SetAddHistogramSampleFunction()</code></b></a>
|
||||
- <a href="#api_nan_idle_notification"><del><b><code>Nan::IdleNotification()</code></b></del></a>
|
||||
- <a href="#api_nan_low_memory_notification"><b><code>Nan::LowMemoryNotification()</code></b></a>
|
||||
- <a href="#api_nan_context_disposed_notification"><b><code>Nan::ContextDisposedNotification()</code></b></a>
|
||||
- <a href="#api_nan_get_internal_field_pointer"><b><code>Nan::GetInternalFieldPointer()</code></b></a>
|
||||
- <a href="#api_nan_set_internal_field_pointer"><b><code>Nan::SetInternalFieldPointer()</code></b></a>
|
||||
- <a href="#api_nan_adjust_external_memory"><b><code>Nan::AdjustExternalMemory()</code></b></a>
|
||||
|
||||
|
||||
<a name="api_nan_gc_callback"></a>
|
||||
### NAN_GC_CALLBACK(callbackname)
|
||||
|
||||
Use `NAN_GC_CALLBACK` to declare your callbacks for `Nan::AddGCPrologueCallback()` and `Nan::AddGCEpilogueCallback()`. Your new method receives the arguments `v8::GCType type` and `v8::GCCallbackFlags flags`.
|
||||
|
||||
```c++
|
||||
static Nan::Persistent<Function> callback;
|
||||
|
||||
NAN_GC_CALLBACK(gcPrologueCallback) {
|
||||
v8::Local<Value> argv[] = { Nan::New("prologue").ToLocalChecked() };
|
||||
Nan::MakeCallback(Nan::GetCurrentContext()->Global(), Nan::New(callback), 1, argv);
|
||||
}
|
||||
|
||||
NAN_METHOD(Hook) {
|
||||
callback.Reset(To<Function>(args[0]).ToLocalChecked());
|
||||
Nan::AddGCPrologueCallback(gcPrologueCallback);
|
||||
info.GetReturnValue().Set(info.Holder());
|
||||
}
|
||||
```
|
||||
|
||||
<a name="api_nan_add_gc_epilogue_callback"></a>
|
||||
### Nan::AddGCEpilogueCallback()
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::AddGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback, v8::GCType gc_type_filter = v8::kGCTypeAll)
|
||||
```
|
||||
|
||||
Calls V8's [`AddGCEpilogueCallback()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a580f976e4290cead62c2fc4dd396be3e).
|
||||
|
||||
<a name="api_nan_remove_gc_epilogue_callback"></a>
|
||||
### Nan::RemoveGCEpilogueCallback()
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback)
|
||||
```
|
||||
|
||||
Calls V8's [`RemoveGCEpilogueCallback()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#adca9294555a3908e9f23c7bb0f0f284c).
|
||||
|
||||
<a name="api_nan_add_gc_prologue_callback"></a>
|
||||
### Nan::AddGCPrologueCallback()
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::AddGCPrologueCallback(v8::Isolate::GCPrologueCallback, v8::GCType gc_type_filter callback)
|
||||
```
|
||||
|
||||
Calls V8's [`AddGCPrologueCallback()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a6dbef303603ebdb03da6998794ea05b8).
|
||||
|
||||
<a name="api_nan_remove_gc_prologue_callback"></a>
|
||||
### Nan::RemoveGCPrologueCallback()
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::RemoveGCPrologueCallback(v8::Isolate::GCPrologueCallback callback)
|
||||
```
|
||||
|
||||
Calls V8's [`RemoveGCPrologueCallback()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a5f72c7cda21415ce062bbe5c58abe09e).
|
||||
|
||||
<a name="api_nan_get_heap_statistics"></a>
|
||||
### Nan::GetHeapStatistics()
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::GetHeapStatistics(v8::HeapStatistics *heap_statistics)
|
||||
```
|
||||
|
||||
Calls V8's [`GetHeapStatistics()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a5593ac74687b713095c38987e5950b34).
|
||||
|
||||
<a name="api_nan_set_counter_function"></a>
|
||||
### Nan::SetCounterFunction()
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::SetCounterFunction(v8::CounterLookupCallback cb)
|
||||
```
|
||||
|
||||
Calls V8's [`SetCounterFunction()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a045d7754e62fa0ec72ae6c259b29af94).
|
||||
|
||||
<a name="api_nan_set_create_histogram_function"></a>
|
||||
### Nan::SetCreateHistogramFunction()
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::SetCreateHistogramFunction(v8::CreateHistogramCallback cb)
|
||||
```
|
||||
|
||||
Calls V8's [`SetCreateHistogramFunction()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a542d67e85089cb3f92aadf032f99e732).
|
||||
|
||||
<a name="api_nan_set_add_histogram_sample_function"></a>
|
||||
### Nan::SetAddHistogramSampleFunction()
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::SetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb)
|
||||
```
|
||||
|
||||
Calls V8's [`SetAddHistogramSampleFunction()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#aeb420b690bc2c216882d6fdd00ddd3ea).
|
||||
|
||||
<a name="api_nan_idle_notification"></a>
|
||||
### <del>Nan::IdleNotification()</del>
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
NAN_DEPRECATED bool Nan::IdleNotification(int idle_time_in_ms)
|
||||
```
|
||||
|
||||
Calls V8's [`IdleNotification()` or `IdleNotificationDeadline()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#ad6a2a02657f5425ad460060652a5a118) depending on V8 version. Removed in V8 12.7.41.
|
||||
|
||||
<a name="api_nan_low_memory_notification"></a>
|
||||
### Nan::LowMemoryNotification()
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::LowMemoryNotification()
|
||||
```
|
||||
|
||||
Calls V8's [`LowMemoryNotification()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a24647f61d6b41f69668094bdcd6ea91f).
|
||||
|
||||
<a name="api_nan_context_disposed_notification"></a>
|
||||
### Nan::ContextDisposedNotification()
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::ContextDisposedNotification()
|
||||
```
|
||||
|
||||
Calls V8's [`ContextDisposedNotification()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#ad7f5dc559866343fe6cd8db1f134d48b).
|
||||
|
||||
<a name="api_nan_get_internal_field_pointer"></a>
|
||||
### Nan::GetInternalFieldPointer()
|
||||
|
||||
Gets a pointer to the internal field with at `index` from a V8 `Object` handle.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void* Nan::GetInternalFieldPointer(v8::Local<v8::Object> object, int index)
|
||||
```
|
||||
|
||||
Calls the Object's [`GetAlignedPointerFromInternalField()` or `GetPointerFromInternalField()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#a580ea84afb26c005d6762eeb9e3c308f) depending on the version of V8.
|
||||
|
||||
<a name="api_nan_set_internal_field_pointer"></a>
|
||||
### Nan::SetInternalFieldPointer()
|
||||
|
||||
Sets the value of the internal field at `index` on a V8 `Object` handle.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::SetInternalFieldPointer(v8::Local<v8::Object> object, int index, void* value)
|
||||
```
|
||||
|
||||
Calls the Object's [`SetAlignedPointerInInternalField()` or `SetPointerInInternalField()`](https://v8docs.nodesource.com/node-8.16/db/d85/classv8_1_1_object.html#ab3c57184263cf29963ef0017bec82281) depending on the version of V8.
|
||||
|
||||
<a name="api_nan_adjust_external_memory"></a>
|
||||
### Nan::AdjustExternalMemory()
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
int Nan::AdjustExternalMemory(int bytesChange)
|
||||
```
|
||||
|
||||
Calls V8's [`AdjustAmountOfExternalAllocatedMemory()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#ae1a59cac60409d3922582c4af675473e).
|
||||
|
||||
85
tasks/enduro-trails/prototype/node_modules/nan/doc/v8_misc.md
generated
vendored
Normal file
85
tasks/enduro-trails/prototype/node_modules/nan/doc/v8_misc.md
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
## Miscellaneous V8 Helpers
|
||||
|
||||
- <a href="#api_nan_utf8_string"><b><code>Nan::Utf8String</code></b></a>
|
||||
- <a href="#api_nan_get_current_context"><b><code>Nan::GetCurrentContext()</code></b></a>
|
||||
- <a href="#api_nan_set_isolate_data"><b><code>Nan::SetIsolateData()</code></b></a>
|
||||
- <a href="#api_nan_get_isolate_data"><b><code>Nan::GetIsolateData()</code></b></a>
|
||||
- <a href="#api_nan_typedarray_contents"><b><code>Nan::TypedArrayContents</code></b></a>
|
||||
|
||||
|
||||
<a name="api_nan_utf8_string"></a>
|
||||
### Nan::Utf8String
|
||||
|
||||
Converts an object to a UTF-8-encoded character array. If conversion to a string fails (e.g. due to an exception in the toString() method of the object) then the length() method returns 0 and the * operator returns NULL. The underlying memory used for this object is managed by the object.
|
||||
|
||||
An implementation of [`v8::String::Utf8Value`](https://v8docs.nodesource.com/node-8.16/d4/d1b/classv8_1_1_string_1_1_utf8_value.html) that is consistent across all supported versions of V8.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
class Nan::Utf8String {
|
||||
public:
|
||||
Nan::Utf8String(v8::Local<v8::Value> from);
|
||||
|
||||
int length() const;
|
||||
|
||||
char* operator*();
|
||||
const char* operator*() const;
|
||||
};
|
||||
```
|
||||
|
||||
<a name="api_nan_get_current_context"></a>
|
||||
### Nan::GetCurrentContext()
|
||||
|
||||
A call to [`v8::Isolate::GetCurrent()->GetCurrentContext()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a81c7a1ed7001ae2a65e89107f75fd053) that works across all supported versions of V8.
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
v8::Local<v8::Context> Nan::GetCurrentContext()
|
||||
```
|
||||
|
||||
<a name="api_nan_set_isolate_data"></a>
|
||||
### Nan::SetIsolateData()
|
||||
|
||||
A helper to provide a consistent API to [`v8::Isolate#SetData()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#a7acadfe7965997e9c386a05f098fbe36).
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
void Nan::SetIsolateData(v8::Isolate *isolate, T *data)
|
||||
```
|
||||
|
||||
|
||||
<a name="api_nan_get_isolate_data"></a>
|
||||
### Nan::GetIsolateData()
|
||||
|
||||
A helper to provide a consistent API to [`v8::Isolate#GetData()`](https://v8docs.nodesource.com/node-8.16/d5/dda/classv8_1_1_isolate.html#aabd223436bc1100a787dadaa024c6257).
|
||||
|
||||
Signature:
|
||||
|
||||
```c++
|
||||
T *Nan::GetIsolateData(v8::Isolate *isolate)
|
||||
```
|
||||
|
||||
<a name="api_nan_typedarray_contents"></a>
|
||||
### Nan::TypedArrayContents<T>
|
||||
|
||||
A helper class for accessing the contents of an ArrayBufferView (aka a typedarray) from C++. If the input array is not a valid typedarray, then the data pointer of TypedArrayContents will default to `NULL` and the length will be 0. If the data pointer is not compatible with the alignment requirements of type, an assertion error will fail.
|
||||
|
||||
Note that you must store a reference to the `array` object while you are accessing its contents.
|
||||
|
||||
Definition:
|
||||
|
||||
```c++
|
||||
template<typename T>
|
||||
class Nan::TypedArrayContents {
|
||||
public:
|
||||
TypedArrayContents(v8::Local<Value> array);
|
||||
|
||||
size_t length() const;
|
||||
|
||||
T* const operator*();
|
||||
const T* const operator*() const;
|
||||
};
|
||||
```
|
||||
1
tasks/enduro-trails/prototype/node_modules/nan/include_dirs.js
generated
vendored
Normal file
1
tasks/enduro-trails/prototype/node_modules/nan/include_dirs.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
console.log(require('path').relative('.', __dirname));
|
||||
3202
tasks/enduro-trails/prototype/node_modules/nan/nan.h
generated
vendored
Normal file
3202
tasks/enduro-trails/prototype/node_modules/nan/nan.h
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
141
tasks/enduro-trails/prototype/node_modules/nan/nan_callbacks.h
generated
vendored
Normal file
141
tasks/enduro-trails/prototype/node_modules/nan/nan_callbacks.h
generated
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_CALLBACKS_H_
|
||||
#define NAN_CALLBACKS_H_
|
||||
|
||||
template<typename T> class FunctionCallbackInfo;
|
||||
template<typename T> class PropertyCallbackInfo;
|
||||
template<typename T> class Global;
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 12 || \
|
||||
(V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION > 4))
|
||||
namespace Intercepted {
|
||||
constexpr v8::Intercepted No() { return v8::Intercepted::kNo; }
|
||||
constexpr v8::Intercepted Yes() { return v8::Intercepted::kYes; }
|
||||
};
|
||||
#else
|
||||
namespace Intercepted {
|
||||
inline void No() {}
|
||||
inline void Yes() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef void(*FunctionCallback)(const FunctionCallbackInfo<v8::Value>&);
|
||||
typedef void(*GetterCallback)
|
||||
(v8::Local<v8::String>, const PropertyCallbackInfo<v8::Value>&);
|
||||
typedef void(*SetterCallback)(
|
||||
v8::Local<v8::String>,
|
||||
v8::Local<v8::Value>,
|
||||
const PropertyCallbackInfo<void>&);
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 12 || \
|
||||
(V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION > 4))
|
||||
typedef v8::Intercepted(*PropertyGetterCallback)(
|
||||
v8::Local<v8::String>,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
typedef v8::Intercepted(*PropertySetterCallback)(
|
||||
v8::Local<v8::String>,
|
||||
v8::Local<v8::Value>,
|
||||
const PropertyCallbackInfo<void>&);
|
||||
#else
|
||||
typedef void(*PropertyGetterCallback)(
|
||||
v8::Local<v8::String>,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
typedef void(*PropertySetterCallback)(
|
||||
v8::Local<v8::String>,
|
||||
v8::Local<v8::Value>,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
#endif
|
||||
typedef void(*PropertyEnumeratorCallback)
|
||||
(const PropertyCallbackInfo<v8::Array>&);
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 12 || \
|
||||
(V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION > 4))
|
||||
typedef v8::Intercepted(*PropertyDeleterCallback)(
|
||||
v8::Local<v8::String>,
|
||||
const PropertyCallbackInfo<v8::Boolean>&);
|
||||
typedef v8::Intercepted(*PropertyQueryCallback)(
|
||||
v8::Local<v8::String>,
|
||||
const PropertyCallbackInfo<v8::Integer>&);
|
||||
typedef v8::Intercepted(*IndexGetterCallback)(
|
||||
uint32_t,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
typedef v8::Intercepted(*IndexSetterCallback)(
|
||||
uint32_t,
|
||||
v8::Local<v8::Value>,
|
||||
const PropertyCallbackInfo<void>&);
|
||||
typedef v8::Intercepted(*IndexEnumeratorCallback)
|
||||
(const PropertyCallbackInfo<v8::Array>&);
|
||||
typedef v8::Intercepted(*IndexDeleterCallback)(
|
||||
uint32_t,
|
||||
const PropertyCallbackInfo<v8::Boolean>&);
|
||||
typedef v8::Intercepted(*IndexQueryCallback)(
|
||||
uint32_t,
|
||||
const PropertyCallbackInfo<v8::Integer>&);
|
||||
#else
|
||||
typedef void(*PropertyDeleterCallback)(
|
||||
v8::Local<v8::String>,
|
||||
const PropertyCallbackInfo<v8::Boolean>&);
|
||||
typedef void(*PropertyQueryCallback)(
|
||||
v8::Local<v8::String>,
|
||||
const PropertyCallbackInfo<v8::Integer>&);
|
||||
typedef void(*IndexGetterCallback)(
|
||||
uint32_t,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
typedef void(*IndexSetterCallback)(
|
||||
uint32_t,
|
||||
v8::Local<v8::Value>,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
typedef void(*IndexEnumeratorCallback)
|
||||
(const PropertyCallbackInfo<v8::Array>&);
|
||||
typedef void(*IndexDeleterCallback)(
|
||||
uint32_t,
|
||||
const PropertyCallbackInfo<v8::Boolean>&);
|
||||
typedef void(*IndexQueryCallback)(
|
||||
uint32_t,
|
||||
const PropertyCallbackInfo<v8::Integer>&);
|
||||
#endif
|
||||
namespace imp {
|
||||
#if (NODE_MODULE_VERSION < NODE_16_0_MODULE_VERSION)
|
||||
typedef v8::Local<v8::AccessorSignature> Sig;
|
||||
#else
|
||||
typedef v8::Local<v8::Data> Sig;
|
||||
#endif
|
||||
|
||||
static const int kDataIndex = 0;
|
||||
|
||||
static const int kFunctionIndex = 1;
|
||||
static const int kFunctionFieldCount = 2;
|
||||
|
||||
static const int kGetterIndex = 1;
|
||||
static const int kSetterIndex = 2;
|
||||
static const int kAccessorFieldCount = 3;
|
||||
|
||||
static const int kPropertyGetterIndex = 1;
|
||||
static const int kPropertySetterIndex = 2;
|
||||
static const int kPropertyEnumeratorIndex = 3;
|
||||
static const int kPropertyDeleterIndex = 4;
|
||||
static const int kPropertyQueryIndex = 5;
|
||||
static const int kPropertyFieldCount = 6;
|
||||
|
||||
static const int kIndexPropertyGetterIndex = 1;
|
||||
static const int kIndexPropertySetterIndex = 2;
|
||||
static const int kIndexPropertyEnumeratorIndex = 3;
|
||||
static const int kIndexPropertyDeleterIndex = 4;
|
||||
static const int kIndexPropertyQueryIndex = 5;
|
||||
static const int kIndexPropertyFieldCount = 6;
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
# include "nan_callbacks_12_inl.h" // NOLINT(build/include)
|
||||
#else
|
||||
# include "nan_callbacks_pre_12_inl.h" // NOLINT(build/include)
|
||||
#endif
|
||||
|
||||
#endif // NAN_CALLBACKS_H_
|
||||
690
tasks/enduro-trails/prototype/node_modules/nan/nan_callbacks_12_inl.h
generated
vendored
Normal file
690
tasks/enduro-trails/prototype/node_modules/nan/nan_callbacks_12_inl.h
generated
vendored
Normal file
@@ -0,0 +1,690 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_CALLBACKS_12_INL_H_
|
||||
#define NAN_CALLBACKS_12_INL_H_
|
||||
|
||||
template<typename T>
|
||||
class ReturnValue {
|
||||
v8::ReturnValue<T> value_;
|
||||
|
||||
public:
|
||||
template <class S>
|
||||
explicit inline ReturnValue(const v8::ReturnValue<S> &value) :
|
||||
value_(value) {}
|
||||
template <class S>
|
||||
explicit inline ReturnValue(const ReturnValue<S>& that)
|
||||
: value_(that.value_) {
|
||||
TYPE_CHECK(T, S);
|
||||
}
|
||||
|
||||
// Handle setters
|
||||
template <typename S> inline void Set(const v8::Local<S> &handle) {
|
||||
TYPE_CHECK(T, S);
|
||||
value_.Set(handle);
|
||||
}
|
||||
|
||||
template <typename S> inline void Set(const Global<S> &handle) {
|
||||
TYPE_CHECK(T, S);
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && \
|
||||
(V8_MINOR_VERSION > 5 || (V8_MINOR_VERSION == 5 && \
|
||||
defined(V8_BUILD_NUMBER) && V8_BUILD_NUMBER >= 8))))
|
||||
value_.Set(handle);
|
||||
#else
|
||||
value_.Set(*reinterpret_cast<const v8::Persistent<S>*>(&handle));
|
||||
const_cast<Global<S> &>(handle).Reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Fast primitive setters
|
||||
inline void Set(bool value) {
|
||||
TYPE_CHECK(T, v8::Boolean);
|
||||
value_.Set(value);
|
||||
}
|
||||
|
||||
inline void Set(double i) {
|
||||
TYPE_CHECK(T, v8::Number);
|
||||
value_.Set(i);
|
||||
}
|
||||
|
||||
inline void Set(int32_t i) {
|
||||
TYPE_CHECK(T, v8::Integer);
|
||||
value_.Set(i);
|
||||
}
|
||||
|
||||
inline void Set(uint32_t i) {
|
||||
TYPE_CHECK(T, v8::Integer);
|
||||
value_.Set(i);
|
||||
}
|
||||
|
||||
// Fast JS primitive setters
|
||||
inline void SetNull() {
|
||||
TYPE_CHECK(T, v8::Primitive);
|
||||
value_.SetNull();
|
||||
}
|
||||
|
||||
inline void SetUndefined() {
|
||||
TYPE_CHECK(T, v8::Primitive);
|
||||
value_.SetUndefined();
|
||||
}
|
||||
|
||||
inline void SetEmptyString() {
|
||||
TYPE_CHECK(T, v8::String);
|
||||
value_.SetEmptyString();
|
||||
}
|
||||
|
||||
// Convenience getter for isolate
|
||||
inline v8::Isolate *GetIsolate() const {
|
||||
return value_.GetIsolate();
|
||||
}
|
||||
|
||||
// Pointer setter: Uncompilable to prevent inadvertent misuse.
|
||||
template<typename S>
|
||||
inline void Set(S *whatever) { TYPE_CHECK(S*, v8::Primitive); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class FunctionCallbackInfo {
|
||||
const v8::FunctionCallbackInfo<T> &info_;
|
||||
const v8::Local<v8::Value> data_;
|
||||
|
||||
public:
|
||||
explicit inline FunctionCallbackInfo(
|
||||
const v8::FunctionCallbackInfo<T> &info
|
||||
, v8::Local<v8::Value> data) :
|
||||
info_(info)
|
||||
, data_(data) {}
|
||||
|
||||
inline ReturnValue<T> GetReturnValue() const {
|
||||
return ReturnValue<T>(info_.GetReturnValue());
|
||||
}
|
||||
|
||||
#if NODE_MAJOR_VERSION < 10
|
||||
NAN_DEPRECATED inline v8::Local<v8::Function> Callee() const {
|
||||
return info_.Callee();
|
||||
}
|
||||
#endif
|
||||
inline v8::Local<v8::Value> Data() const { return data_; }
|
||||
inline v8::Local<v8::Object> Holder() const {
|
||||
#if defined(V8_MAJOR_VERSION) && \
|
||||
(V8_MAJOR_VERSION > 12 || \
|
||||
(V8_MAJOR_VERSION == 12 && \
|
||||
(defined(V8_MINOR_VERSION) && \
|
||||
(V8_MINOR_VERSION > 5 || \
|
||||
(V8_MINOR_VERSION == 5 && defined(V8_BUILD_NUMBER) && \
|
||||
V8_BUILD_NUMBER >= 214)))))
|
||||
return info_.This();
|
||||
#else
|
||||
return info_.Holder();
|
||||
#endif
|
||||
}
|
||||
inline bool IsConstructCall() const { return info_.IsConstructCall(); }
|
||||
inline int Length() const { return info_.Length(); }
|
||||
inline v8::Local<v8::Value> operator[](int i) const { return info_[i]; }
|
||||
inline v8::Local<v8::Object> This() const { return info_.This(); }
|
||||
inline v8::Isolate *GetIsolate() const { return info_.GetIsolate(); }
|
||||
|
||||
|
||||
protected:
|
||||
static const int kHolderIndex = 0;
|
||||
static const int kIsolateIndex = 1;
|
||||
static const int kReturnValueDefaultValueIndex = 2;
|
||||
static const int kReturnValueIndex = 3;
|
||||
static const int kDataIndex = 4;
|
||||
static const int kCalleeIndex = 5;
|
||||
static const int kContextSaveIndex = 6;
|
||||
static const int kArgsLength = 7;
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(FunctionCallbackInfo)
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class PropertyCallbackInfo {
|
||||
const v8::PropertyCallbackInfo<T> &info_;
|
||||
const v8::Local<v8::Value> data_;
|
||||
|
||||
public:
|
||||
explicit inline PropertyCallbackInfo(
|
||||
const v8::PropertyCallbackInfo<T> &info
|
||||
, const v8::Local<v8::Value> data) :
|
||||
info_(info)
|
||||
, data_(data) {}
|
||||
|
||||
inline v8::Isolate* GetIsolate() const { return info_.GetIsolate(); }
|
||||
inline v8::Local<v8::Value> Data() const { return data_; }
|
||||
inline v8::Local<v8::Object> This() const { return info_.This(); }
|
||||
inline v8::Local<v8::Object> Holder() const { return info_.Holder(); }
|
||||
inline ReturnValue<T> GetReturnValue() const {
|
||||
return ReturnValue<T>(info_.GetReturnValue());
|
||||
}
|
||||
|
||||
protected:
|
||||
static const int kHolderIndex = 0;
|
||||
static const int kIsolateIndex = 1;
|
||||
static const int kReturnValueDefaultValueIndex = 2;
|
||||
static const int kReturnValueIndex = 3;
|
||||
static const int kDataIndex = 4;
|
||||
static const int kThisIndex = 5;
|
||||
static const int kArgsLength = 6;
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(PropertyCallbackInfo)
|
||||
};
|
||||
|
||||
namespace imp {
|
||||
static
|
||||
void FunctionCallbackWrapper(const v8::FunctionCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
FunctionCallback callback = reinterpret_cast<FunctionCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kFunctionIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
FunctionCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
callback(cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeFunction)(const v8::FunctionCallbackInfo<v8::Value> &);
|
||||
|
||||
#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
|
||||
static
|
||||
void GetterCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
GetterCallback callback = reinterpret_cast<GetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kGetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(property.As<v8::String>(), cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeGetter)
|
||||
(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
void SetterCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::PropertyCallbackInfo<void> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<void>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
SetterCallback callback = reinterpret_cast<SetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kSetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(property.As<v8::String>(), value, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeSetter)(
|
||||
v8::Local<v8::Name>
|
||||
, v8::Local<v8::Value>
|
||||
, const v8::PropertyCallbackInfo<void> &);
|
||||
#else
|
||||
static
|
||||
void GetterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
GetterCallback callback = reinterpret_cast<GetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kGetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeGetter)
|
||||
(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
void SetterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::PropertyCallbackInfo<void> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<void>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
SetterCallback callback = reinterpret_cast<SetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kSetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(property, value, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeSetter)(
|
||||
v8::Local<v8::String>
|
||||
, v8::Local<v8::Value>
|
||||
, const v8::PropertyCallbackInfo<void> &);
|
||||
#endif
|
||||
|
||||
#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 12 || \
|
||||
(V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION > 4))
|
||||
static
|
||||
v8::Intercepted PropertyGetterCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertyGetterCallback callback = reinterpret_cast<PropertyGetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyGetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
return callback(property.As<v8::String>(), cbinfo);
|
||||
}
|
||||
|
||||
typedef v8::Intercepted (*NativePropertyGetter)
|
||||
(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
v8::Intercepted PropertySetterCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::PropertyCallbackInfo<void> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<void>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertySetterCallback callback = reinterpret_cast<PropertySetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertySetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
return callback(property.As<v8::String>(), value, cbinfo);
|
||||
}
|
||||
|
||||
typedef v8::Intercepted (*NativePropertySetter)(
|
||||
v8::Local<v8::Name>
|
||||
, v8::Local<v8::Value>
|
||||
, const v8::PropertyCallbackInfo<void> &);
|
||||
|
||||
#else
|
||||
static
|
||||
void PropertyGetterCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertyGetterCallback callback = reinterpret_cast<PropertyGetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyGetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(property.As<v8::String>(), cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertyGetter)
|
||||
(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
void PropertySetterCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertySetterCallback callback = reinterpret_cast<PropertySetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertySetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(property.As<v8::String>(), value, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertySetter)(
|
||||
v8::Local<v8::Name>
|
||||
, v8::Local<v8::Value>
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
#endif
|
||||
|
||||
static
|
||||
void PropertyEnumeratorCallbackWrapper(
|
||||
const v8::PropertyCallbackInfo<v8::Array> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Array>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertyEnumeratorCallback callback =
|
||||
reinterpret_cast<PropertyEnumeratorCallback>(reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyEnumeratorIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertyEnumerator)
|
||||
(const v8::PropertyCallbackInfo<v8::Array> &);
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 12 || \
|
||||
(V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION > 4))
|
||||
static
|
||||
v8::Intercepted PropertyDeleterCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, const v8::PropertyCallbackInfo<v8::Boolean> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Boolean>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertyDeleterCallback callback = reinterpret_cast<PropertyDeleterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyDeleterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
return callback(property.As<v8::String>(), cbinfo);
|
||||
}
|
||||
|
||||
typedef v8::Intercepted (NativePropertyDeleter)
|
||||
(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Boolean> &);
|
||||
|
||||
|
||||
static
|
||||
v8::Intercepted PropertyQueryCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, const v8::PropertyCallbackInfo<v8::Integer> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Integer>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertyQueryCallback callback = reinterpret_cast<PropertyQueryCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyQueryIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
return callback(property.As<v8::String>(), cbinfo);
|
||||
}
|
||||
|
||||
typedef v8::Intercepted (*NativePropertyQuery)
|
||||
(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Integer> &);
|
||||
#else
|
||||
static
|
||||
void PropertyDeleterCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, const v8::PropertyCallbackInfo<v8::Boolean> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Boolean>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertyDeleterCallback callback = reinterpret_cast<PropertyDeleterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyDeleterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(property.As<v8::String>(), cbinfo);
|
||||
}
|
||||
|
||||
typedef void (NativePropertyDeleter)
|
||||
(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Boolean> &);
|
||||
|
||||
static
|
||||
void PropertyQueryCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, const v8::PropertyCallbackInfo<v8::Integer> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Integer>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertyQueryCallback callback = reinterpret_cast<PropertyQueryCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyQueryIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(property.As<v8::String>(), cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertyQuery)
|
||||
(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Integer> &);
|
||||
#endif
|
||||
#else
|
||||
static
|
||||
void PropertyGetterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertyGetterCallback callback = reinterpret_cast<PropertyGetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyGetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertyGetter)
|
||||
(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
void PropertySetterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertySetterCallback callback = reinterpret_cast<PropertySetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertySetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(property, value, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertySetter)(
|
||||
v8::Local<v8::String>
|
||||
, v8::Local<v8::Value>
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
void PropertyEnumeratorCallbackWrapper(
|
||||
const v8::PropertyCallbackInfo<v8::Array> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Array>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertyEnumeratorCallback callback =
|
||||
reinterpret_cast<PropertyEnumeratorCallback>(reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyEnumeratorIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertyEnumerator)
|
||||
(const v8::PropertyCallbackInfo<v8::Array> &);
|
||||
|
||||
static
|
||||
void PropertyDeleterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, const v8::PropertyCallbackInfo<v8::Boolean> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Boolean>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertyDeleterCallback callback = reinterpret_cast<PropertyDeleterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyDeleterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (NativePropertyDeleter)
|
||||
(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Boolean> &);
|
||||
|
||||
static
|
||||
void PropertyQueryCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, const v8::PropertyCallbackInfo<v8::Integer> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Integer>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
PropertyQueryCallback callback = reinterpret_cast<PropertyQueryCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyQueryIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertyQuery)
|
||||
(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Integer> &);
|
||||
#endif
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 12 || \
|
||||
(V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION > 4))
|
||||
static
|
||||
v8::Intercepted IndexGetterCallbackWrapper(
|
||||
uint32_t index, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
IndexGetterCallback callback = reinterpret_cast<IndexGetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyGetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
return callback(index, cbinfo);
|
||||
}
|
||||
|
||||
typedef v8::Intercepted (*NativeIndexGetter)
|
||||
(uint32_t, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
v8::Intercepted IndexSetterCallbackWrapper(
|
||||
uint32_t index
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::PropertyCallbackInfo<void> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<void>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
IndexSetterCallback callback = reinterpret_cast<IndexSetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertySetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
return callback(index, value, cbinfo);
|
||||
}
|
||||
|
||||
typedef v8::Intercepted (*NativeIndexSetter)(
|
||||
uint32_t
|
||||
, v8::Local<v8::Value>
|
||||
, const v8::PropertyCallbackInfo<void> &);
|
||||
|
||||
#else
|
||||
static
|
||||
void IndexGetterCallbackWrapper(
|
||||
uint32_t index, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
IndexGetterCallback callback = reinterpret_cast<IndexGetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyGetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(index, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeIndexGetter)
|
||||
(uint32_t, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
static
|
||||
void IndexSetterCallbackWrapper(
|
||||
uint32_t index
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
IndexSetterCallback callback = reinterpret_cast<IndexSetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertySetterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(index, value, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeIndexSetter)(
|
||||
uint32_t
|
||||
, v8::Local<v8::Value>
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
#endif
|
||||
|
||||
static
|
||||
void IndexEnumeratorCallbackWrapper(
|
||||
const v8::PropertyCallbackInfo<v8::Array> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Array>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
IndexEnumeratorCallback callback = reinterpret_cast<IndexEnumeratorCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(
|
||||
kIndexPropertyEnumeratorIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeIndexEnumerator)
|
||||
(const v8::PropertyCallbackInfo<v8::Array> &);
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 12 || \
|
||||
(V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION > 4))
|
||||
static
|
||||
v8::Intercepted IndexDeleterCallbackWrapper(
|
||||
uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Boolean>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
IndexDeleterCallback callback = reinterpret_cast<IndexDeleterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyDeleterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
return callback(index, cbinfo);
|
||||
}
|
||||
|
||||
typedef v8::Intercepted (*NativeIndexDeleter)
|
||||
(uint32_t, const v8::PropertyCallbackInfo<v8::Boolean> &);
|
||||
|
||||
static
|
||||
v8::Intercepted IndexQueryCallbackWrapper(
|
||||
uint32_t index, const v8::PropertyCallbackInfo<v8::Integer> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Integer>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
IndexQueryCallback callback = reinterpret_cast<IndexQueryCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyQueryIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
return callback(index, cbinfo);
|
||||
}
|
||||
|
||||
typedef v8::Intercepted (*NativeIndexQuery)
|
||||
(uint32_t, const v8::PropertyCallbackInfo<v8::Integer> &);
|
||||
#else
|
||||
static
|
||||
void IndexDeleterCallbackWrapper(
|
||||
uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Boolean>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
IndexDeleterCallback callback = reinterpret_cast<IndexDeleterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyDeleterIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(index, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeIndexDeleter)
|
||||
(uint32_t, const v8::PropertyCallbackInfo<v8::Boolean> &);
|
||||
|
||||
static
|
||||
void IndexQueryCallbackWrapper(
|
||||
uint32_t index, const v8::PropertyCallbackInfo<v8::Integer> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Integer>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex).As<v8::Value>());
|
||||
IndexQueryCallback callback = reinterpret_cast<IndexQueryCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyQueryIndex)
|
||||
.As<v8::Value>().As<v8::External>()->Value()));
|
||||
callback(index, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeIndexQuery)
|
||||
(uint32_t, const v8::PropertyCallbackInfo<v8::Integer> &);
|
||||
|
||||
#endif
|
||||
} // end of namespace imp
|
||||
|
||||
#endif // NAN_CALLBACKS_12_INL_H_
|
||||
524
tasks/enduro-trails/prototype/node_modules/nan/nan_callbacks_pre_12_inl.h
generated
vendored
Normal file
524
tasks/enduro-trails/prototype/node_modules/nan/nan_callbacks_pre_12_inl.h
generated
vendored
Normal file
@@ -0,0 +1,524 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_CALLBACKS_PRE_12_INL_H_
|
||||
#define NAN_CALLBACKS_PRE_12_INL_H_
|
||||
|
||||
namespace imp {
|
||||
template<typename T> class ReturnValueImp;
|
||||
} // end of namespace imp
|
||||
|
||||
template<typename T>
|
||||
class ReturnValue {
|
||||
v8::Isolate *isolate_;
|
||||
v8::Persistent<T> *value_;
|
||||
friend class imp::ReturnValueImp<T>;
|
||||
|
||||
public:
|
||||
template <class S>
|
||||
explicit inline ReturnValue(v8::Isolate *isolate, v8::Persistent<S> *p) :
|
||||
isolate_(isolate), value_(p) {}
|
||||
template <class S>
|
||||
explicit inline ReturnValue(const ReturnValue<S>& that)
|
||||
: isolate_(that.isolate_), value_(that.value_) {
|
||||
TYPE_CHECK(T, S);
|
||||
}
|
||||
|
||||
// Handle setters
|
||||
template <typename S> inline void Set(const v8::Local<S> &handle) {
|
||||
TYPE_CHECK(T, S);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(handle);
|
||||
}
|
||||
|
||||
template <typename S> inline void Set(const Global<S> &handle) {
|
||||
TYPE_CHECK(T, S);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(handle.persistent);
|
||||
const_cast<Global<S> &>(handle).Reset();
|
||||
}
|
||||
|
||||
// Fast primitive setters
|
||||
inline void Set(bool value) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::Boolean);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::Boolean::New(value));
|
||||
}
|
||||
|
||||
inline void Set(double i) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::Number);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::Number::New(i));
|
||||
}
|
||||
|
||||
inline void Set(int32_t i) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::Integer);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::Int32::New(i));
|
||||
}
|
||||
|
||||
inline void Set(uint32_t i) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::Integer);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::Uint32::NewFromUnsigned(i));
|
||||
}
|
||||
|
||||
// Fast JS primitive setters
|
||||
inline void SetNull() {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::Primitive);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::Null());
|
||||
}
|
||||
|
||||
inline void SetUndefined() {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::Primitive);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::Undefined());
|
||||
}
|
||||
|
||||
inline void SetEmptyString() {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::String);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::String::Empty());
|
||||
}
|
||||
|
||||
// Convenience getter for isolate
|
||||
inline v8::Isolate *GetIsolate() const {
|
||||
return isolate_;
|
||||
}
|
||||
|
||||
// Pointer setter: Uncompilable to prevent inadvertent misuse.
|
||||
template<typename S>
|
||||
inline void Set(S *whatever) { TYPE_CHECK(S*, v8::Primitive); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class FunctionCallbackInfo {
|
||||
const v8::Arguments &args_;
|
||||
v8::Local<v8::Value> data_;
|
||||
ReturnValue<T> return_value_;
|
||||
v8::Persistent<T> retval_;
|
||||
|
||||
public:
|
||||
explicit inline FunctionCallbackInfo(
|
||||
const v8::Arguments &args
|
||||
, v8::Local<v8::Value> data) :
|
||||
args_(args)
|
||||
, data_(data)
|
||||
, return_value_(args.GetIsolate(), &retval_)
|
||||
, retval_(v8::Persistent<T>::New(v8::Undefined())) {}
|
||||
|
||||
inline ~FunctionCallbackInfo() {
|
||||
retval_.Dispose();
|
||||
retval_.Clear();
|
||||
}
|
||||
|
||||
inline ReturnValue<T> GetReturnValue() const {
|
||||
return ReturnValue<T>(return_value_);
|
||||
}
|
||||
|
||||
NAN_DEPRECATED inline v8::Local<v8::Function> Callee() const {
|
||||
return args_.Callee();
|
||||
}
|
||||
inline v8::Local<v8::Value> Data() const { return data_; }
|
||||
inline v8::Local<v8::Object> Holder() const {
|
||||
return args_.Holder();
|
||||
}
|
||||
inline bool IsConstructCall() const { return args_.IsConstructCall(); }
|
||||
inline int Length() const { return args_.Length(); }
|
||||
inline v8::Local<v8::Value> operator[](int i) const { return args_[i]; }
|
||||
inline v8::Local<v8::Object> This() const { return args_.This(); }
|
||||
inline v8::Isolate *GetIsolate() const { return args_.GetIsolate(); }
|
||||
|
||||
|
||||
protected:
|
||||
static const int kHolderIndex = 0;
|
||||
static const int kIsolateIndex = 1;
|
||||
static const int kReturnValueDefaultValueIndex = 2;
|
||||
static const int kReturnValueIndex = 3;
|
||||
static const int kDataIndex = 4;
|
||||
static const int kCalleeIndex = 5;
|
||||
static const int kContextSaveIndex = 6;
|
||||
static const int kArgsLength = 7;
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(FunctionCallbackInfo)
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class PropertyCallbackInfoBase {
|
||||
const v8::AccessorInfo &info_;
|
||||
const v8::Local<v8::Value> data_;
|
||||
|
||||
public:
|
||||
explicit inline PropertyCallbackInfoBase(
|
||||
const v8::AccessorInfo &info
|
||||
, const v8::Local<v8::Value> data) :
|
||||
info_(info)
|
||||
, data_(data) {}
|
||||
|
||||
inline v8::Isolate* GetIsolate() const { return info_.GetIsolate(); }
|
||||
inline v8::Local<v8::Value> Data() const { return data_; }
|
||||
inline v8::Local<v8::Object> This() const { return info_.This(); }
|
||||
inline v8::Local<v8::Object> Holder() const { return info_.Holder(); }
|
||||
|
||||
protected:
|
||||
static const int kHolderIndex = 0;
|
||||
static const int kIsolateIndex = 1;
|
||||
static const int kReturnValueDefaultValueIndex = 2;
|
||||
static const int kReturnValueIndex = 3;
|
||||
static const int kDataIndex = 4;
|
||||
static const int kThisIndex = 5;
|
||||
static const int kArgsLength = 6;
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(PropertyCallbackInfoBase)
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class PropertyCallbackInfo : public PropertyCallbackInfoBase<T> {
|
||||
ReturnValue<T> return_value_;
|
||||
v8::Persistent<T> retval_;
|
||||
|
||||
public:
|
||||
explicit inline PropertyCallbackInfo(
|
||||
const v8::AccessorInfo &info
|
||||
, const v8::Local<v8::Value> data) :
|
||||
PropertyCallbackInfoBase<T>(info, data)
|
||||
, return_value_(info.GetIsolate(), &retval_)
|
||||
, retval_(v8::Persistent<T>::New(v8::Undefined())) {}
|
||||
|
||||
inline ~PropertyCallbackInfo() {
|
||||
retval_.Dispose();
|
||||
retval_.Clear();
|
||||
}
|
||||
|
||||
inline ReturnValue<T> GetReturnValue() const { return return_value_; }
|
||||
};
|
||||
|
||||
template<>
|
||||
class PropertyCallbackInfo<v8::Array> :
|
||||
public PropertyCallbackInfoBase<v8::Array> {
|
||||
ReturnValue<v8::Array> return_value_;
|
||||
v8::Persistent<v8::Array> retval_;
|
||||
|
||||
public:
|
||||
explicit inline PropertyCallbackInfo(
|
||||
const v8::AccessorInfo &info
|
||||
, const v8::Local<v8::Value> data) :
|
||||
PropertyCallbackInfoBase<v8::Array>(info, data)
|
||||
, return_value_(info.GetIsolate(), &retval_)
|
||||
, retval_(v8::Persistent<v8::Array>::New(v8::Local<v8::Array>())) {}
|
||||
|
||||
inline ~PropertyCallbackInfo() {
|
||||
retval_.Dispose();
|
||||
retval_.Clear();
|
||||
}
|
||||
|
||||
inline ReturnValue<v8::Array> GetReturnValue() const {
|
||||
return return_value_;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class PropertyCallbackInfo<v8::Boolean> :
|
||||
public PropertyCallbackInfoBase<v8::Boolean> {
|
||||
ReturnValue<v8::Boolean> return_value_;
|
||||
v8::Persistent<v8::Boolean> retval_;
|
||||
|
||||
public:
|
||||
explicit inline PropertyCallbackInfo(
|
||||
const v8::AccessorInfo &info
|
||||
, const v8::Local<v8::Value> data) :
|
||||
PropertyCallbackInfoBase<v8::Boolean>(info, data)
|
||||
, return_value_(info.GetIsolate(), &retval_)
|
||||
, retval_(v8::Persistent<v8::Boolean>::New(v8::Local<v8::Boolean>())) {}
|
||||
|
||||
inline ~PropertyCallbackInfo() {
|
||||
retval_.Dispose();
|
||||
retval_.Clear();
|
||||
}
|
||||
|
||||
inline ReturnValue<v8::Boolean> GetReturnValue() const {
|
||||
return return_value_;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class PropertyCallbackInfo<v8::Integer> :
|
||||
public PropertyCallbackInfoBase<v8::Integer> {
|
||||
ReturnValue<v8::Integer> return_value_;
|
||||
v8::Persistent<v8::Integer> retval_;
|
||||
|
||||
public:
|
||||
explicit inline PropertyCallbackInfo(
|
||||
const v8::AccessorInfo &info
|
||||
, const v8::Local<v8::Value> data) :
|
||||
PropertyCallbackInfoBase<v8::Integer>(info, data)
|
||||
, return_value_(info.GetIsolate(), &retval_)
|
||||
, retval_(v8::Persistent<v8::Integer>::New(v8::Local<v8::Integer>())) {}
|
||||
|
||||
inline ~PropertyCallbackInfo() {
|
||||
retval_.Dispose();
|
||||
retval_.Clear();
|
||||
}
|
||||
|
||||
inline ReturnValue<v8::Integer> GetReturnValue() const {
|
||||
return return_value_;
|
||||
}
|
||||
};
|
||||
|
||||
namespace imp {
|
||||
template<typename T>
|
||||
class ReturnValueImp : public ReturnValue<T> {
|
||||
public:
|
||||
explicit ReturnValueImp(ReturnValue<T> that) :
|
||||
ReturnValue<T>(that) {}
|
||||
inline v8::Handle<T> Value() {
|
||||
return *ReturnValue<T>::value_;
|
||||
}
|
||||
};
|
||||
|
||||
static
|
||||
v8::Handle<v8::Value> FunctionCallbackWrapper(const v8::Arguments &args) {
|
||||
v8::Local<v8::Object> obj = args.Data().As<v8::Object>();
|
||||
FunctionCallback callback = reinterpret_cast<FunctionCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kFunctionIndex).As<v8::External>()->Value()));
|
||||
FunctionCallbackInfo<v8::Value>
|
||||
cbinfo(args, obj->GetInternalField(kDataIndex));
|
||||
callback(cbinfo);
|
||||
return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Value> (*NativeFunction)(const v8::Arguments &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Value> GetterCallbackWrapper(
|
||||
v8::Local<v8::String> property, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
GetterCallback callback = reinterpret_cast<GetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kGetterIndex).As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Value> (*NativeGetter)
|
||||
(v8::Local<v8::String>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
void SetterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<void>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
SetterCallback callback = reinterpret_cast<SetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kSetterIndex).As<v8::External>()->Value()));
|
||||
callback(property, value, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeSetter)
|
||||
(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Value> PropertyGetterCallbackWrapper(
|
||||
v8::Local<v8::String> property, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyGetterCallback callback = reinterpret_cast<PropertyGetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyGetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Value> (*NativePropertyGetter)
|
||||
(v8::Local<v8::String>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Value> PropertySetterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertySetterCallback callback = reinterpret_cast<PropertySetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertySetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property, value, cbinfo);
|
||||
return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Value> (*NativePropertySetter)
|
||||
(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Array> PropertyEnumeratorCallbackWrapper(
|
||||
const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Array>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyEnumeratorCallback callback =
|
||||
reinterpret_cast<PropertyEnumeratorCallback>(reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyEnumeratorIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(cbinfo);
|
||||
return ReturnValueImp<v8::Array>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Array> (*NativePropertyEnumerator)
|
||||
(const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Boolean> PropertyDeleterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Boolean>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyDeleterCallback callback = reinterpret_cast<PropertyDeleterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyDeleterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
return ReturnValueImp<v8::Boolean>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Boolean> (NativePropertyDeleter)
|
||||
(v8::Local<v8::String>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Integer> PropertyQueryCallbackWrapper(
|
||||
v8::Local<v8::String> property, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Integer>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyQueryCallback callback = reinterpret_cast<PropertyQueryCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyQueryIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
return ReturnValueImp<v8::Integer>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Integer> (*NativePropertyQuery)
|
||||
(v8::Local<v8::String>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Value> IndexGetterCallbackWrapper(
|
||||
uint32_t index, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexGetterCallback callback = reinterpret_cast<IndexGetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyGetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(index, cbinfo);
|
||||
return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Value> (*NativeIndexGetter)
|
||||
(uint32_t, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Value> IndexSetterCallbackWrapper(
|
||||
uint32_t index
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexSetterCallback callback = reinterpret_cast<IndexSetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertySetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(index, value, cbinfo);
|
||||
return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Value> (*NativeIndexSetter)
|
||||
(uint32_t, v8::Local<v8::Value>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Array> IndexEnumeratorCallbackWrapper(
|
||||
const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Array>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexEnumeratorCallback callback = reinterpret_cast<IndexEnumeratorCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyEnumeratorIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(cbinfo);
|
||||
return ReturnValueImp<v8::Array>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Array> (*NativeIndexEnumerator)
|
||||
(const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Boolean> IndexDeleterCallbackWrapper(
|
||||
uint32_t index, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Boolean>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexDeleterCallback callback = reinterpret_cast<IndexDeleterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyDeleterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(index, cbinfo);
|
||||
return ReturnValueImp<v8::Boolean>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Boolean> (*NativeIndexDeleter)
|
||||
(uint32_t, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Integer> IndexQueryCallbackWrapper(
|
||||
uint32_t index, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Integer>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexQueryCallback callback = reinterpret_cast<IndexQueryCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyQueryIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(index, cbinfo);
|
||||
return ReturnValueImp<v8::Integer>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Integer> (*NativeIndexQuery)
|
||||
(uint32_t, const v8::AccessorInfo &);
|
||||
} // end of namespace imp
|
||||
|
||||
#endif // NAN_CALLBACKS_PRE_12_INL_H_
|
||||
72
tasks/enduro-trails/prototype/node_modules/nan/nan_converters.h
generated
vendored
Normal file
72
tasks/enduro-trails/prototype/node_modules/nan/nan_converters.h
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_CONVERTERS_H_
|
||||
#define NAN_CONVERTERS_H_
|
||||
|
||||
namespace imp {
|
||||
template<typename T> struct ToFactoryBase {
|
||||
typedef MaybeLocal<T> return_t;
|
||||
};
|
||||
template<typename T> struct ValueFactoryBase { typedef Maybe<T> return_t; };
|
||||
|
||||
template<typename T> struct ToFactory;
|
||||
|
||||
template<>
|
||||
struct ToFactory<v8::Function> : ToFactoryBase<v8::Function> {
|
||||
static inline return_t convert(v8::Local<v8::Value> val) {
|
||||
if (val.IsEmpty() || !val->IsFunction()) return MaybeLocal<v8::Function>();
|
||||
return MaybeLocal<v8::Function>(val.As<v8::Function>());
|
||||
}
|
||||
};
|
||||
|
||||
#define X(TYPE) \
|
||||
template<> \
|
||||
struct ToFactory<v8::TYPE> : ToFactoryBase<v8::TYPE> { \
|
||||
static inline return_t convert(v8::Local<v8::Value> val); \
|
||||
};
|
||||
|
||||
X(Boolean)
|
||||
X(Number)
|
||||
X(String)
|
||||
X(Object)
|
||||
X(Integer)
|
||||
X(Uint32)
|
||||
X(Int32)
|
||||
|
||||
#undef X
|
||||
|
||||
#define X(TYPE) \
|
||||
template<> \
|
||||
struct ToFactory<TYPE> : ValueFactoryBase<TYPE> { \
|
||||
static inline return_t convert(v8::Local<v8::Value> val); \
|
||||
};
|
||||
|
||||
X(bool)
|
||||
X(double)
|
||||
X(int64_t)
|
||||
X(uint32_t)
|
||||
X(int32_t)
|
||||
|
||||
#undef X
|
||||
} // end of namespace imp
|
||||
|
||||
template<typename T>
|
||||
inline
|
||||
typename imp::ToFactory<T>::return_t To(v8::Local<v8::Value> val) {
|
||||
return imp::ToFactory<T>::convert(val);
|
||||
}
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
# include "nan_converters_43_inl.h"
|
||||
#else
|
||||
# include "nan_converters_pre_43_inl.h"
|
||||
#endif
|
||||
|
||||
#endif // NAN_CONVERTERS_H_
|
||||
68
tasks/enduro-trails/prototype/node_modules/nan/nan_converters_43_inl.h
generated
vendored
Normal file
68
tasks/enduro-trails/prototype/node_modules/nan/nan_converters_43_inl.h
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_CONVERTERS_43_INL_H_
|
||||
#define NAN_CONVERTERS_43_INL_H_
|
||||
|
||||
#define X(TYPE) \
|
||||
imp::ToFactory<v8::TYPE>::return_t \
|
||||
imp::ToFactory<v8::TYPE>::convert(v8::Local<v8::Value> val) { \
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
|
||||
v8::EscapableHandleScope scope(isolate); \
|
||||
return scope.Escape( \
|
||||
val->To ## TYPE(isolate->GetCurrentContext()) \
|
||||
.FromMaybe(v8::Local<v8::TYPE>())); \
|
||||
}
|
||||
|
||||
X(Number)
|
||||
X(String)
|
||||
X(Object)
|
||||
X(Integer)
|
||||
X(Uint32)
|
||||
X(Int32)
|
||||
// V8 <= 7.0
|
||||
#if V8_MAJOR_VERSION < 7 || (V8_MAJOR_VERSION == 7 && V8_MINOR_VERSION == 0)
|
||||
X(Boolean)
|
||||
#else
|
||||
imp::ToFactory<v8::Boolean>::return_t \
|
||||
imp::ToFactory<v8::Boolean>::convert(v8::Local<v8::Value> val) { \
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
|
||||
v8::EscapableHandleScope scope(isolate); \
|
||||
return scope.Escape(val->ToBoolean(isolate)); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef X
|
||||
|
||||
#define X(TYPE, NAME) \
|
||||
imp::ToFactory<TYPE>::return_t \
|
||||
imp::ToFactory<TYPE>::convert(v8::Local<v8::Value> val) { \
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
|
||||
v8::HandleScope scope(isolate); \
|
||||
return val->NAME ## Value(isolate->GetCurrentContext()); \
|
||||
}
|
||||
|
||||
X(double, Number)
|
||||
X(int64_t, Integer)
|
||||
X(uint32_t, Uint32)
|
||||
X(int32_t, Int32)
|
||||
// V8 <= 7.0
|
||||
#if V8_MAJOR_VERSION < 7 || (V8_MAJOR_VERSION == 7 && V8_MINOR_VERSION == 0)
|
||||
X(bool, Boolean)
|
||||
#else
|
||||
imp::ToFactory<bool>::return_t \
|
||||
imp::ToFactory<bool>::convert(v8::Local<v8::Value> val) { \
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
|
||||
v8::HandleScope scope(isolate); \
|
||||
return Just<bool>(val->BooleanValue(isolate)); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef X
|
||||
|
||||
#endif // NAN_CONVERTERS_43_INL_H_
|
||||
42
tasks/enduro-trails/prototype/node_modules/nan/nan_converters_pre_43_inl.h
generated
vendored
Normal file
42
tasks/enduro-trails/prototype/node_modules/nan/nan_converters_pre_43_inl.h
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_CONVERTERS_PRE_43_INL_H_
|
||||
#define NAN_CONVERTERS_PRE_43_INL_H_
|
||||
|
||||
#define X(TYPE) \
|
||||
imp::ToFactory<v8::TYPE>::return_t \
|
||||
imp::ToFactory<v8::TYPE>::convert(v8::Local<v8::Value> val) { \
|
||||
return val->To ## TYPE(); \
|
||||
}
|
||||
|
||||
X(Boolean)
|
||||
X(Number)
|
||||
X(String)
|
||||
X(Object)
|
||||
X(Integer)
|
||||
X(Uint32)
|
||||
X(Int32)
|
||||
|
||||
#undef X
|
||||
|
||||
#define X(TYPE, NAME) \
|
||||
imp::ToFactory<TYPE>::return_t \
|
||||
imp::ToFactory<TYPE>::convert(v8::Local<v8::Value> val) { \
|
||||
return Just(val->NAME ## Value()); \
|
||||
}
|
||||
|
||||
X(bool, Boolean)
|
||||
X(double, Number)
|
||||
X(int64_t, Integer)
|
||||
X(uint32_t, Uint32)
|
||||
X(int32_t, Int32)
|
||||
|
||||
#undef X
|
||||
|
||||
#endif // NAN_CONVERTERS_PRE_43_INL_H_
|
||||
29
tasks/enduro-trails/prototype/node_modules/nan/nan_define_own_property_helper.h
generated
vendored
Normal file
29
tasks/enduro-trails/prototype/node_modules/nan/nan_define_own_property_helper.h
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_DEFINE_OWN_PROPERTY_HELPER_H_
|
||||
#define NAN_DEFINE_OWN_PROPERTY_HELPER_H_
|
||||
|
||||
namespace imp {
|
||||
|
||||
inline Maybe<bool> DefineOwnPropertyHelper(
|
||||
v8::PropertyAttribute current
|
||||
, v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key
|
||||
, v8::Handle<v8::Value> value
|
||||
, v8::PropertyAttribute attribs = v8::None) {
|
||||
return !(current & v8::DontDelete) || // configurable OR
|
||||
(!(current & v8::ReadOnly) && // writable AND
|
||||
!((attribs ^ current) & ~v8::ReadOnly)) // same excluding RO
|
||||
? Just<bool>(obj->ForceSet(key, value, attribs))
|
||||
: Nothing<bool>();
|
||||
}
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
#endif // NAN_DEFINE_OWN_PROPERTY_HELPER_H_
|
||||
430
tasks/enduro-trails/prototype/node_modules/nan/nan_implementation_12_inl.h
generated
vendored
Normal file
430
tasks/enduro-trails/prototype/node_modules/nan/nan_implementation_12_inl.h
generated
vendored
Normal file
@@ -0,0 +1,430 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_IMPLEMENTATION_12_INL_H_
|
||||
#define NAN_IMPLEMENTATION_12_INL_H_
|
||||
//==============================================================================
|
||||
// node v0.11 implementation
|
||||
//==============================================================================
|
||||
|
||||
namespace imp {
|
||||
|
||||
//=== Array ====================================================================
|
||||
|
||||
Factory<v8::Array>::return_t
|
||||
Factory<v8::Array>::New() {
|
||||
return v8::Array::New(v8::Isolate::GetCurrent());
|
||||
}
|
||||
|
||||
Factory<v8::Array>::return_t
|
||||
Factory<v8::Array>::New(int length) {
|
||||
return v8::Array::New(v8::Isolate::GetCurrent(), length);
|
||||
}
|
||||
|
||||
//=== Boolean ==================================================================
|
||||
|
||||
Factory<v8::Boolean>::return_t
|
||||
Factory<v8::Boolean>::New(bool value) {
|
||||
return v8::Boolean::New(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
|
||||
//=== Boolean Object ===========================================================
|
||||
|
||||
Factory<v8::BooleanObject>::return_t
|
||||
Factory<v8::BooleanObject>::New(bool value) {
|
||||
#if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION)
|
||||
return v8::BooleanObject::New(
|
||||
v8::Isolate::GetCurrent(), value).As<v8::BooleanObject>();
|
||||
#else
|
||||
return v8::BooleanObject::New(value).As<v8::BooleanObject>();
|
||||
#endif
|
||||
}
|
||||
|
||||
//=== Context ==================================================================
|
||||
|
||||
Factory<v8::Context>::return_t
|
||||
Factory<v8::Context>::New( v8::ExtensionConfiguration* extensions
|
||||
, v8::Local<v8::ObjectTemplate> tmpl
|
||||
, v8::Local<v8::Value> obj) {
|
||||
return v8::Context::New(v8::Isolate::GetCurrent(), extensions, tmpl, obj);
|
||||
}
|
||||
|
||||
//=== Date =====================================================================
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
Factory<v8::Date>::return_t
|
||||
Factory<v8::Date>::New(double value) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(v8::Date::New(isolate->GetCurrentContext(), value)
|
||||
.FromMaybe(v8::Local<v8::Value>()).As<v8::Date>());
|
||||
}
|
||||
#else
|
||||
Factory<v8::Date>::return_t
|
||||
Factory<v8::Date>::New(double value) {
|
||||
return v8::Date::New(v8::Isolate::GetCurrent(), value).As<v8::Date>();
|
||||
}
|
||||
#endif
|
||||
|
||||
//=== External =================================================================
|
||||
|
||||
Factory<v8::External>::return_t
|
||||
Factory<v8::External>::New(void * value) {
|
||||
return v8::External::New(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
|
||||
//=== Function =================================================================
|
||||
|
||||
Factory<v8::Function>::return_t
|
||||
Factory<v8::Function>::New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New(isolate);
|
||||
tpl->SetInternalFieldCount(imp::kFunctionFieldCount);
|
||||
v8::Local<v8::Object> obj = NewInstance(tpl).ToLocalChecked();
|
||||
|
||||
obj->SetInternalField(
|
||||
imp::kFunctionIndex
|
||||
, v8::External::New(isolate, reinterpret_cast<void *>(callback)));
|
||||
|
||||
v8::Local<v8::Value> val = v8::Local<v8::Value>::New(isolate, data);
|
||||
|
||||
if (!val.IsEmpty()) {
|
||||
obj->SetInternalField(imp::kDataIndex, val);
|
||||
}
|
||||
|
||||
#if NODE_MAJOR_VERSION >= 10
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Local<v8::Function> function =
|
||||
v8::Function::New(context, imp::FunctionCallbackWrapper, obj)
|
||||
.ToLocalChecked();
|
||||
#else
|
||||
v8::Local<v8::Function> function =
|
||||
v8::Function::New(isolate, imp::FunctionCallbackWrapper, obj);
|
||||
#endif
|
||||
|
||||
return scope.Escape(function);
|
||||
}
|
||||
|
||||
//=== Function Template ========================================================
|
||||
|
||||
Factory<v8::FunctionTemplate>::return_t
|
||||
Factory<v8::FunctionTemplate>::New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data
|
||||
, v8::Local<v8::Signature> signature) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
if (callback) {
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New(isolate);
|
||||
tpl->SetInternalFieldCount(imp::kFunctionFieldCount);
|
||||
v8::Local<v8::Object> obj = NewInstance(tpl).ToLocalChecked();
|
||||
|
||||
obj->SetInternalField(
|
||||
imp::kFunctionIndex
|
||||
, v8::External::New(isolate, reinterpret_cast<void *>(callback)));
|
||||
v8::Local<v8::Value> val = v8::Local<v8::Value>::New(isolate, data);
|
||||
|
||||
if (!val.IsEmpty()) {
|
||||
obj->SetInternalField(imp::kDataIndex, val);
|
||||
}
|
||||
|
||||
return scope.Escape(v8::FunctionTemplate::New( isolate
|
||||
, imp::FunctionCallbackWrapper
|
||||
, obj
|
||||
, signature));
|
||||
} else {
|
||||
return v8::FunctionTemplate::New(isolate, 0, data, signature);
|
||||
}
|
||||
}
|
||||
|
||||
//=== Number ===================================================================
|
||||
|
||||
Factory<v8::Number>::return_t
|
||||
Factory<v8::Number>::New(double value) {
|
||||
return v8::Number::New(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
|
||||
//=== Number Object ============================================================
|
||||
|
||||
Factory<v8::NumberObject>::return_t
|
||||
Factory<v8::NumberObject>::New(double value) {
|
||||
return v8::NumberObject::New( v8::Isolate::GetCurrent()
|
||||
, value).As<v8::NumberObject>();
|
||||
}
|
||||
|
||||
//=== Integer, Int32 and Uint32 ================================================
|
||||
|
||||
template <typename T>
|
||||
typename IntegerFactory<T>::return_t
|
||||
IntegerFactory<T>::New(int32_t value) {
|
||||
return To<T>(T::New(v8::Isolate::GetCurrent(), value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename IntegerFactory<T>::return_t
|
||||
IntegerFactory<T>::New(uint32_t value) {
|
||||
return To<T>(T::NewFromUnsigned(v8::Isolate::GetCurrent(), value));
|
||||
}
|
||||
|
||||
Factory<v8::Uint32>::return_t
|
||||
Factory<v8::Uint32>::New(int32_t value) {
|
||||
return To<v8::Uint32>(
|
||||
v8::Uint32::NewFromUnsigned(v8::Isolate::GetCurrent(), value));
|
||||
}
|
||||
|
||||
Factory<v8::Uint32>::return_t
|
||||
Factory<v8::Uint32>::New(uint32_t value) {
|
||||
return To<v8::Uint32>(
|
||||
v8::Uint32::NewFromUnsigned(v8::Isolate::GetCurrent(), value));
|
||||
}
|
||||
|
||||
//=== Object ===================================================================
|
||||
|
||||
Factory<v8::Object>::return_t
|
||||
Factory<v8::Object>::New() {
|
||||
return v8::Object::New(v8::Isolate::GetCurrent());
|
||||
}
|
||||
|
||||
//=== Object Template ==========================================================
|
||||
|
||||
Factory<v8::ObjectTemplate>::return_t
|
||||
Factory<v8::ObjectTemplate>::New() {
|
||||
return v8::ObjectTemplate::New(v8::Isolate::GetCurrent());
|
||||
}
|
||||
|
||||
//=== RegExp ===================================================================
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
Factory<v8::RegExp>::return_t
|
||||
Factory<v8::RegExp>::New(
|
||||
v8::Local<v8::String> pattern
|
||||
, v8::RegExp::Flags flags) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(
|
||||
v8::RegExp::New(isolate->GetCurrentContext(), pattern, flags)
|
||||
.FromMaybe(v8::Local<v8::RegExp>()));
|
||||
}
|
||||
#else
|
||||
Factory<v8::RegExp>::return_t
|
||||
Factory<v8::RegExp>::New(
|
||||
v8::Local<v8::String> pattern
|
||||
, v8::RegExp::Flags flags) {
|
||||
return v8::RegExp::New(pattern, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
//=== Script ===================================================================
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
Factory<v8::Script>::return_t
|
||||
Factory<v8::Script>::New( v8::Local<v8::String> source) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
v8::ScriptCompiler::Source src(source);
|
||||
return scope.Escape(
|
||||
v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &src)
|
||||
.FromMaybe(v8::Local<v8::Script>()));
|
||||
}
|
||||
|
||||
Factory<v8::Script>::return_t
|
||||
Factory<v8::Script>::New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
v8::ScriptCompiler::Source src(source, origin);
|
||||
return scope.Escape(
|
||||
v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &src)
|
||||
.FromMaybe(v8::Local<v8::Script>()));
|
||||
}
|
||||
#else
|
||||
Factory<v8::Script>::return_t
|
||||
Factory<v8::Script>::New( v8::Local<v8::String> source) {
|
||||
v8::ScriptCompiler::Source src(source);
|
||||
return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src);
|
||||
}
|
||||
|
||||
Factory<v8::Script>::return_t
|
||||
Factory<v8::Script>::New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin) {
|
||||
v8::ScriptCompiler::Source src(source, origin);
|
||||
return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src);
|
||||
}
|
||||
#endif
|
||||
|
||||
//=== Signature ================================================================
|
||||
|
||||
Factory<v8::Signature>::return_t
|
||||
Factory<v8::Signature>::New(Factory<v8::Signature>::FTH receiver) {
|
||||
return v8::Signature::New(v8::Isolate::GetCurrent(), receiver);
|
||||
}
|
||||
|
||||
//=== String ===================================================================
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New() {
|
||||
return v8::String::Empty(v8::Isolate::GetCurrent());
|
||||
}
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(const char * value, int length) {
|
||||
return v8::String::NewFromUtf8(
|
||||
v8::Isolate::GetCurrent(), value, v8::NewStringType::kNormal, length);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(std::string const& value) {
|
||||
assert(value.size() <= INT_MAX && "string too long");
|
||||
return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(),
|
||||
value.data(), v8::NewStringType::kNormal, static_cast<int>(value.size()));
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(const uint16_t * value, int length) {
|
||||
return v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), value,
|
||||
v8::NewStringType::kNormal, length);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(v8::String::ExternalStringResource * value) {
|
||||
return v8::String::NewExternalTwoByte(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(ExternalOneByteStringResource * value) {
|
||||
return v8::String::NewExternalOneByte(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
#else
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(const char * value, int length) {
|
||||
return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), value,
|
||||
v8::String::kNormalString, length);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(
|
||||
std::string const& value) /* NOLINT(build/include_what_you_use) */ {
|
||||
assert(value.size() <= INT_MAX && "string too long");
|
||||
return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), value.data(),
|
||||
v8::String::kNormalString,
|
||||
static_cast<int>(value.size()));
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(const uint16_t * value, int length) {
|
||||
return v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), value,
|
||||
v8::String::kNormalString, length);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(v8::String::ExternalStringResource * value) {
|
||||
return v8::String::NewExternal(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(ExternalOneByteStringResource * value) {
|
||||
return v8::String::NewExternal(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
#endif
|
||||
|
||||
//=== String Object ============================================================
|
||||
|
||||
// See https://github.com/nodejs/nan/pull/811#discussion_r224594980.
|
||||
// Disable the warning as there is no way around it.
|
||||
// TODO(bnoordhuis) Use isolate-based version in Node.js v12.
|
||||
Factory<v8::StringObject>::return_t
|
||||
Factory<v8::StringObject>::New(v8::Local<v8::String> value) {
|
||||
// V8 > 7.0
|
||||
#if V8_MAJOR_VERSION > 7 || (V8_MAJOR_VERSION == 7 && V8_MINOR_VERSION > 0)
|
||||
return v8::StringObject::New(v8::Isolate::GetCurrent(), value)
|
||||
.As<v8::StringObject>();
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
return v8::StringObject::New(value).As<v8::StringObject>();
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
//=== Unbound Script ===========================================================
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
Factory<v8::UnboundScript>::return_t
|
||||
Factory<v8::UnboundScript>::New(v8::Local<v8::String> source) {
|
||||
v8::ScriptCompiler::Source src(source);
|
||||
return v8::ScriptCompiler::CompileUnboundScript(
|
||||
v8::Isolate::GetCurrent(), &src);
|
||||
}
|
||||
|
||||
Factory<v8::UnboundScript>::return_t
|
||||
Factory<v8::UnboundScript>::New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin) {
|
||||
v8::ScriptCompiler::Source src(source, origin);
|
||||
return v8::ScriptCompiler::CompileUnboundScript(
|
||||
v8::Isolate::GetCurrent(), &src);
|
||||
}
|
||||
#else
|
||||
Factory<v8::UnboundScript>::return_t
|
||||
Factory<v8::UnboundScript>::New(v8::Local<v8::String> source) {
|
||||
v8::ScriptCompiler::Source src(source);
|
||||
return v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src);
|
||||
}
|
||||
|
||||
Factory<v8::UnboundScript>::return_t
|
||||
Factory<v8::UnboundScript>::New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin) {
|
||||
v8::ScriptCompiler::Source src(source, origin);
|
||||
return v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
//=== Presistents and Handles ==================================================
|
||||
|
||||
#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
|
||||
template <typename T>
|
||||
inline v8::Local<T> New(v8::Handle<T> h) {
|
||||
return v8::Local<T>::New(v8::Isolate::GetCurrent(), h);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T, typename M>
|
||||
inline v8::Local<T> New(v8::Persistent<T, M> const& p) {
|
||||
return v8::Local<T>::New(v8::Isolate::GetCurrent(), p);
|
||||
}
|
||||
|
||||
template <typename T, typename M>
|
||||
inline v8::Local<T> New(Persistent<T, M> const& p) {
|
||||
return v8::Local<T>::New(v8::Isolate::GetCurrent(), p);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline v8::Local<T> New(Global<T> const& p) {
|
||||
return v8::Local<T>::New(v8::Isolate::GetCurrent(), p);
|
||||
}
|
||||
|
||||
#endif // NAN_IMPLEMENTATION_12_INL_H_
|
||||
263
tasks/enduro-trails/prototype/node_modules/nan/nan_implementation_pre_12_inl.h
generated
vendored
Normal file
263
tasks/enduro-trails/prototype/node_modules/nan/nan_implementation_pre_12_inl.h
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_IMPLEMENTATION_PRE_12_INL_H_
|
||||
#define NAN_IMPLEMENTATION_PRE_12_INL_H_
|
||||
|
||||
//==============================================================================
|
||||
// node v0.10 implementation
|
||||
//==============================================================================
|
||||
|
||||
namespace imp {
|
||||
|
||||
//=== Array ====================================================================
|
||||
|
||||
Factory<v8::Array>::return_t
|
||||
Factory<v8::Array>::New() {
|
||||
return v8::Array::New();
|
||||
}
|
||||
|
||||
Factory<v8::Array>::return_t
|
||||
Factory<v8::Array>::New(int length) {
|
||||
return v8::Array::New(length);
|
||||
}
|
||||
|
||||
//=== Boolean ==================================================================
|
||||
|
||||
Factory<v8::Boolean>::return_t
|
||||
Factory<v8::Boolean>::New(bool value) {
|
||||
return v8::Boolean::New(value)->ToBoolean();
|
||||
}
|
||||
|
||||
//=== Boolean Object ===========================================================
|
||||
|
||||
Factory<v8::BooleanObject>::return_t
|
||||
Factory<v8::BooleanObject>::New(bool value) {
|
||||
return v8::BooleanObject::New(value).As<v8::BooleanObject>();
|
||||
}
|
||||
|
||||
//=== Context ==================================================================
|
||||
|
||||
Factory<v8::Context>::return_t
|
||||
Factory<v8::Context>::New( v8::ExtensionConfiguration* extensions
|
||||
, v8::Local<v8::ObjectTemplate> tmpl
|
||||
, v8::Local<v8::Value> obj) {
|
||||
v8::Persistent<v8::Context> ctx = v8::Context::New(extensions, tmpl, obj);
|
||||
v8::Local<v8::Context> lctx = v8::Local<v8::Context>::New(ctx);
|
||||
ctx.Dispose();
|
||||
return lctx;
|
||||
}
|
||||
|
||||
//=== Date =====================================================================
|
||||
|
||||
Factory<v8::Date>::return_t
|
||||
Factory<v8::Date>::New(double value) {
|
||||
return v8::Date::New(value).As<v8::Date>();
|
||||
}
|
||||
|
||||
//=== External =================================================================
|
||||
|
||||
Factory<v8::External>::return_t
|
||||
Factory<v8::External>::New(void * value) {
|
||||
return v8::External::New(value);
|
||||
}
|
||||
|
||||
//=== Function =================================================================
|
||||
|
||||
Factory<v8::Function>::return_t
|
||||
Factory<v8::Function>::New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
return scope.Close(Factory<v8::FunctionTemplate>::New(
|
||||
callback, data, v8::Local<v8::Signature>())
|
||||
->GetFunction());
|
||||
}
|
||||
|
||||
|
||||
//=== FunctionTemplate =========================================================
|
||||
|
||||
Factory<v8::FunctionTemplate>::return_t
|
||||
Factory<v8::FunctionTemplate>::New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data
|
||||
, v8::Local<v8::Signature> signature) {
|
||||
if (callback) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New();
|
||||
tpl->SetInternalFieldCount(imp::kFunctionFieldCount);
|
||||
v8::Local<v8::Object> obj = tpl->NewInstance();
|
||||
|
||||
obj->SetInternalField(
|
||||
imp::kFunctionIndex
|
||||
, v8::External::New(reinterpret_cast<void *>(callback)));
|
||||
|
||||
v8::Local<v8::Value> val = v8::Local<v8::Value>::New(data);
|
||||
|
||||
if (!val.IsEmpty()) {
|
||||
obj->SetInternalField(imp::kDataIndex, val);
|
||||
}
|
||||
|
||||
// Note(agnat): Emulate length argument here. Unfortunately, I couldn't find
|
||||
// a way. Have at it though...
|
||||
return scope.Close(
|
||||
v8::FunctionTemplate::New(imp::FunctionCallbackWrapper
|
||||
, obj
|
||||
, signature));
|
||||
} else {
|
||||
return v8::FunctionTemplate::New(0, data, signature);
|
||||
}
|
||||
}
|
||||
|
||||
//=== Number ===================================================================
|
||||
|
||||
Factory<v8::Number>::return_t
|
||||
Factory<v8::Number>::New(double value) {
|
||||
return v8::Number::New(value);
|
||||
}
|
||||
|
||||
//=== Number Object ============================================================
|
||||
|
||||
Factory<v8::NumberObject>::return_t
|
||||
Factory<v8::NumberObject>::New(double value) {
|
||||
return v8::NumberObject::New(value).As<v8::NumberObject>();
|
||||
}
|
||||
|
||||
//=== Integer, Int32 and Uint32 ================================================
|
||||
|
||||
template <typename T>
|
||||
typename IntegerFactory<T>::return_t
|
||||
IntegerFactory<T>::New(int32_t value) {
|
||||
return To<T>(T::New(value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename IntegerFactory<T>::return_t
|
||||
IntegerFactory<T>::New(uint32_t value) {
|
||||
return To<T>(T::NewFromUnsigned(value));
|
||||
}
|
||||
|
||||
Factory<v8::Uint32>::return_t
|
||||
Factory<v8::Uint32>::New(int32_t value) {
|
||||
return To<v8::Uint32>(v8::Uint32::NewFromUnsigned(value));
|
||||
}
|
||||
|
||||
Factory<v8::Uint32>::return_t
|
||||
Factory<v8::Uint32>::New(uint32_t value) {
|
||||
return To<v8::Uint32>(v8::Uint32::NewFromUnsigned(value));
|
||||
}
|
||||
|
||||
|
||||
//=== Object ===================================================================
|
||||
|
||||
Factory<v8::Object>::return_t
|
||||
Factory<v8::Object>::New() {
|
||||
return v8::Object::New();
|
||||
}
|
||||
|
||||
//=== Object Template ==========================================================
|
||||
|
||||
Factory<v8::ObjectTemplate>::return_t
|
||||
Factory<v8::ObjectTemplate>::New() {
|
||||
return v8::ObjectTemplate::New();
|
||||
}
|
||||
|
||||
//=== RegExp ===================================================================
|
||||
|
||||
Factory<v8::RegExp>::return_t
|
||||
Factory<v8::RegExp>::New(
|
||||
v8::Local<v8::String> pattern
|
||||
, v8::RegExp::Flags flags) {
|
||||
return v8::RegExp::New(pattern, flags);
|
||||
}
|
||||
|
||||
//=== Script ===================================================================
|
||||
|
||||
Factory<v8::Script>::return_t
|
||||
Factory<v8::Script>::New( v8::Local<v8::String> source) {
|
||||
return v8::Script::New(source);
|
||||
}
|
||||
Factory<v8::Script>::return_t
|
||||
Factory<v8::Script>::New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin) {
|
||||
return v8::Script::New(source, const_cast<v8::ScriptOrigin*>(&origin));
|
||||
}
|
||||
|
||||
//=== Signature ================================================================
|
||||
|
||||
Factory<v8::Signature>::return_t
|
||||
Factory<v8::Signature>::New(Factory<v8::Signature>::FTH receiver) {
|
||||
return v8::Signature::New(receiver);
|
||||
}
|
||||
|
||||
//=== String ===================================================================
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New() {
|
||||
return v8::String::Empty();
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(const char * value, int length) {
|
||||
return v8::String::New(value, length);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(
|
||||
std::string const& value) /* NOLINT(build/include_what_you_use) */ {
|
||||
assert(value.size() <= INT_MAX && "string too long");
|
||||
return v8::String::New(value.data(), static_cast<int>(value.size()));
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(const uint16_t * value, int length) {
|
||||
return v8::String::New(value, length);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(v8::String::ExternalStringResource * value) {
|
||||
return v8::String::NewExternal(value);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(v8::String::ExternalAsciiStringResource * value) {
|
||||
return v8::String::NewExternal(value);
|
||||
}
|
||||
|
||||
//=== String Object ============================================================
|
||||
|
||||
Factory<v8::StringObject>::return_t
|
||||
Factory<v8::StringObject>::New(v8::Local<v8::String> value) {
|
||||
return v8::StringObject::New(value).As<v8::StringObject>();
|
||||
}
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
//=== Presistents and Handles ==================================================
|
||||
|
||||
template <typename T>
|
||||
inline v8::Local<T> New(v8::Handle<T> h) {
|
||||
return v8::Local<T>::New(h);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline v8::Local<T> New(v8::Persistent<T> const& p) {
|
||||
return v8::Local<T>::New(p);
|
||||
}
|
||||
|
||||
template <typename T, typename M>
|
||||
inline v8::Local<T> New(Persistent<T, M> const& p) {
|
||||
return v8::Local<T>::New(p.persistent);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline v8::Local<T> New(Global<T> const& p) {
|
||||
return v8::Local<T>::New(p.persistent);
|
||||
}
|
||||
|
||||
#endif // NAN_IMPLEMENTATION_PRE_12_INL_H_
|
||||
166
tasks/enduro-trails/prototype/node_modules/nan/nan_json.h
generated
vendored
Normal file
166
tasks/enduro-trails/prototype/node_modules/nan/nan_json.h
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_JSON_H_
|
||||
#define NAN_JSON_H_
|
||||
|
||||
#if NODE_MODULE_VERSION < NODE_0_12_MODULE_VERSION
|
||||
#define NAN_JSON_H_NEED_PARSE 1
|
||||
#else
|
||||
#define NAN_JSON_H_NEED_PARSE 0
|
||||
#endif // NODE_MODULE_VERSION < NODE_0_12_MODULE_VERSION
|
||||
|
||||
#if NODE_MODULE_VERSION >= NODE_7_0_MODULE_VERSION
|
||||
#define NAN_JSON_H_NEED_STRINGIFY 0
|
||||
#else
|
||||
#define NAN_JSON_H_NEED_STRINGIFY 1
|
||||
#endif // NODE_MODULE_VERSION >= NODE_7_0_MODULE_VERSION
|
||||
|
||||
class JSON {
|
||||
public:
|
||||
JSON() {
|
||||
#if NAN_JSON_H_NEED_PARSE + NAN_JSON_H_NEED_STRINGIFY
|
||||
Nan::HandleScope scope;
|
||||
|
||||
Nan::MaybeLocal<v8::Value> maybe_global_json = Nan::Get(
|
||||
Nan::GetCurrentContext()->Global(),
|
||||
Nan::New("JSON").ToLocalChecked()
|
||||
);
|
||||
|
||||
assert(!maybe_global_json.IsEmpty() && "global JSON is empty");
|
||||
v8::Local<v8::Value> val_global_json = maybe_global_json.ToLocalChecked();
|
||||
|
||||
assert(val_global_json->IsObject() && "global JSON is not an object");
|
||||
Nan::MaybeLocal<v8::Object> maybe_obj_global_json =
|
||||
Nan::To<v8::Object>(val_global_json);
|
||||
|
||||
assert(!maybe_obj_global_json.IsEmpty() && "global JSON object is empty");
|
||||
v8::Local<v8::Object> global_json = maybe_obj_global_json.ToLocalChecked();
|
||||
|
||||
#if NAN_JSON_H_NEED_PARSE
|
||||
Nan::MaybeLocal<v8::Value> maybe_parse_method = Nan::Get(
|
||||
global_json, Nan::New("parse").ToLocalChecked()
|
||||
);
|
||||
|
||||
assert(!maybe_parse_method.IsEmpty() && "JSON.parse is empty");
|
||||
v8::Local<v8::Value> parse_method = maybe_parse_method.ToLocalChecked();
|
||||
|
||||
assert(parse_method->IsFunction() && "JSON.parse is not a function");
|
||||
parse_cb_.Reset(parse_method.As<v8::Function>());
|
||||
#endif // NAN_JSON_H_NEED_PARSE
|
||||
|
||||
#if NAN_JSON_H_NEED_STRINGIFY
|
||||
Nan::MaybeLocal<v8::Value> maybe_stringify_method = Nan::Get(
|
||||
global_json, Nan::New("stringify").ToLocalChecked()
|
||||
);
|
||||
|
||||
assert(!maybe_stringify_method.IsEmpty() && "JSON.stringify is empty");
|
||||
v8::Local<v8::Value> stringify_method =
|
||||
maybe_stringify_method.ToLocalChecked();
|
||||
|
||||
assert(
|
||||
stringify_method->IsFunction() && "JSON.stringify is not a function"
|
||||
);
|
||||
stringify_cb_.Reset(stringify_method.As<v8::Function>());
|
||||
#endif // NAN_JSON_H_NEED_STRINGIFY
|
||||
#endif // NAN_JSON_H_NEED_PARSE + NAN_JSON_H_NEED_STRINGIFY
|
||||
}
|
||||
|
||||
inline
|
||||
Nan::MaybeLocal<v8::Value> Parse(v8::Local<v8::String> json_string) {
|
||||
Nan::EscapableHandleScope scope;
|
||||
#if NAN_JSON_H_NEED_PARSE
|
||||
return scope.Escape(parse(json_string));
|
||||
#else
|
||||
Nan::MaybeLocal<v8::Value> result;
|
||||
#if NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION && \
|
||||
NODE_MODULE_VERSION <= IOJS_2_0_MODULE_VERSION
|
||||
result = v8::JSON::Parse(json_string);
|
||||
#else
|
||||
#if NODE_MODULE_VERSION > NODE_6_0_MODULE_VERSION
|
||||
v8::Local<v8::Context> context_or_isolate = Nan::GetCurrentContext();
|
||||
#else
|
||||
v8::Isolate* context_or_isolate = v8::Isolate::GetCurrent();
|
||||
#endif // NODE_MODULE_VERSION > NODE_6_0_MODULE_VERSION
|
||||
result = v8::JSON::Parse(context_or_isolate, json_string);
|
||||
#endif // NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION &&
|
||||
// NODE_MODULE_VERSION <= IOJS_2_0_MODULE_VERSION
|
||||
if (result.IsEmpty()) return v8::Local<v8::Value>();
|
||||
return scope.Escape(result.ToLocalChecked());
|
||||
#endif // NAN_JSON_H_NEED_PARSE
|
||||
}
|
||||
|
||||
inline
|
||||
Nan::MaybeLocal<v8::String> Stringify(v8::Local<v8::Object> json_object) {
|
||||
Nan::EscapableHandleScope scope;
|
||||
Nan::MaybeLocal<v8::String> result =
|
||||
#if NAN_JSON_H_NEED_STRINGIFY
|
||||
Nan::To<v8::String>(stringify(json_object));
|
||||
#else
|
||||
v8::JSON::Stringify(Nan::GetCurrentContext(), json_object);
|
||||
#endif // NAN_JSON_H_NEED_STRINGIFY
|
||||
if (result.IsEmpty()) return v8::Local<v8::String>();
|
||||
return scope.Escape(result.ToLocalChecked());
|
||||
}
|
||||
|
||||
inline
|
||||
Nan::MaybeLocal<v8::String> Stringify(v8::Local<v8::Object> json_object,
|
||||
v8::Local<v8::String> gap) {
|
||||
Nan::EscapableHandleScope scope;
|
||||
Nan::MaybeLocal<v8::String> result =
|
||||
#if NAN_JSON_H_NEED_STRINGIFY
|
||||
Nan::To<v8::String>(stringify(json_object, gap));
|
||||
#else
|
||||
v8::JSON::Stringify(Nan::GetCurrentContext(), json_object, gap);
|
||||
#endif // NAN_JSON_H_NEED_STRINGIFY
|
||||
if (result.IsEmpty()) return v8::Local<v8::String>();
|
||||
return scope.Escape(result.ToLocalChecked());
|
||||
}
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(JSON)
|
||||
#if NAN_JSON_H_NEED_PARSE
|
||||
Nan::Callback parse_cb_;
|
||||
#endif // NAN_JSON_H_NEED_PARSE
|
||||
#if NAN_JSON_H_NEED_STRINGIFY
|
||||
Nan::Callback stringify_cb_;
|
||||
#endif // NAN_JSON_H_NEED_STRINGIFY
|
||||
|
||||
#if NAN_JSON_H_NEED_PARSE
|
||||
inline v8::Local<v8::Value> parse(v8::Local<v8::Value> arg) {
|
||||
assert(!parse_cb_.IsEmpty() && "parse_cb_ is empty");
|
||||
AsyncResource resource("nan:JSON.parse");
|
||||
return parse_cb_.Call(1, &arg, &resource).FromMaybe(v8::Local<v8::Value>());
|
||||
}
|
||||
#endif // NAN_JSON_H_NEED_PARSE
|
||||
|
||||
#if NAN_JSON_H_NEED_STRINGIFY
|
||||
inline v8::Local<v8::Value> stringify(v8::Local<v8::Value> arg) {
|
||||
assert(!stringify_cb_.IsEmpty() && "stringify_cb_ is empty");
|
||||
AsyncResource resource("nan:JSON.stringify");
|
||||
return stringify_cb_.Call(1, &arg, &resource)
|
||||
.FromMaybe(v8::Local<v8::Value>());
|
||||
}
|
||||
|
||||
inline v8::Local<v8::Value> stringify(v8::Local<v8::Value> arg,
|
||||
v8::Local<v8::String> gap) {
|
||||
assert(!stringify_cb_.IsEmpty() && "stringify_cb_ is empty");
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
arg,
|
||||
Nan::Null(),
|
||||
gap
|
||||
};
|
||||
AsyncResource resource("nan:JSON.stringify");
|
||||
return stringify_cb_.Call(3, argv, &resource)
|
||||
.FromMaybe(v8::Local<v8::Value>());
|
||||
}
|
||||
#endif // NAN_JSON_H_NEED_STRINGIFY
|
||||
};
|
||||
|
||||
#endif // NAN_JSON_H_
|
||||
360
tasks/enduro-trails/prototype/node_modules/nan/nan_maybe_43_inl.h
generated
vendored
Normal file
360
tasks/enduro-trails/prototype/node_modules/nan/nan_maybe_43_inl.h
generated
vendored
Normal file
@@ -0,0 +1,360 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_MAYBE_43_INL_H_
|
||||
#define NAN_MAYBE_43_INL_H_
|
||||
|
||||
template<typename T>
|
||||
using MaybeLocal = v8::MaybeLocal<T>;
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::String> ToDetailString(v8::Local<v8::Value> val) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(val->ToDetailString(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::String>()));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Uint32> ToArrayIndex(v8::Local<v8::Value> val) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(val->ToArrayIndex(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::Uint32>()));
|
||||
}
|
||||
|
||||
inline
|
||||
Maybe<bool> Equals(v8::Local<v8::Value> a, v8::Local<v8::Value>(b)) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return a->Equals(isolate->GetCurrentContext(), b);
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Object> NewInstance(v8::Local<v8::Function> h) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(h->NewInstance(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::Object>()));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Object> NewInstance(
|
||||
v8::Local<v8::Function> h
|
||||
, int argc
|
||||
, v8::Local<v8::Value> argv[]) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(h->NewInstance(isolate->GetCurrentContext(), argc, argv)
|
||||
.FromMaybe(v8::Local<v8::Object>()));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Object> NewInstance(v8::Local<v8::ObjectTemplate> h) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(h->NewInstance(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::Object>()));
|
||||
}
|
||||
|
||||
|
||||
inline MaybeLocal<v8::Function> GetFunction(
|
||||
v8::Local<v8::FunctionTemplate> t) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(t->GetFunction(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::Function>()));
|
||||
}
|
||||
|
||||
inline Maybe<bool> Set(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::Value> key
|
||||
, v8::Local<v8::Value> value) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->Set(isolate->GetCurrentContext(), key, value);
|
||||
}
|
||||
|
||||
inline Maybe<bool> Set(
|
||||
v8::Local<v8::Object> obj
|
||||
, uint32_t index
|
||||
, v8::Local<v8::Value> value) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->Set(isolate->GetCurrentContext(), index, value);
|
||||
}
|
||||
|
||||
#if NODE_MODULE_VERSION < NODE_4_0_MODULE_VERSION
|
||||
#include "nan_define_own_property_helper.h" // NOLINT(build/include_subdir)
|
||||
#endif
|
||||
|
||||
inline Maybe<bool> DefineOwnProperty(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key
|
||||
, v8::Local<v8::Value> value
|
||||
, v8::PropertyAttribute attribs = v8::None) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
#if NODE_MODULE_VERSION >= NODE_4_0_MODULE_VERSION
|
||||
return obj->DefineOwnProperty(isolate->GetCurrentContext(), key, value,
|
||||
attribs);
|
||||
#else
|
||||
Maybe<v8::PropertyAttribute> maybeCurrent =
|
||||
obj->GetPropertyAttributes(isolate->GetCurrentContext(), key);
|
||||
if (maybeCurrent.IsNothing()) {
|
||||
return Nothing<bool>();
|
||||
}
|
||||
v8::PropertyAttribute current = maybeCurrent.FromJust();
|
||||
return imp::DefineOwnPropertyHelper(current, obj, key, value, attribs);
|
||||
#endif
|
||||
}
|
||||
|
||||
NAN_DEPRECATED inline Maybe<bool> ForceSet(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::Value> key
|
||||
, v8::Local<v8::Value> value
|
||||
, v8::PropertyAttribute attribs = v8::None) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
|
||||
return key->IsName()
|
||||
? obj->DefineOwnProperty(isolate->GetCurrentContext(),
|
||||
key.As<v8::Name>(), value, attribs)
|
||||
: Nothing<bool>();
|
||||
#else
|
||||
return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> Get(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::Value> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(obj->Get(isolate->GetCurrentContext(), key)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Value> Get(v8::Local<v8::Object> obj, uint32_t index) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(obj->Get(isolate->GetCurrentContext(), index)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
inline v8::PropertyAttribute GetPropertyAttributes(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::Value> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->GetPropertyAttributes(isolate->GetCurrentContext(), key)
|
||||
.FromJust();
|
||||
}
|
||||
|
||||
inline Maybe<bool> Has(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->Has(isolate->GetCurrentContext(), key);
|
||||
}
|
||||
|
||||
inline Maybe<bool> Has(v8::Local<v8::Object> obj, uint32_t index) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->Has(isolate->GetCurrentContext(), index);
|
||||
}
|
||||
|
||||
inline Maybe<bool> Delete(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->Delete(isolate->GetCurrentContext(), key);
|
||||
}
|
||||
|
||||
inline
|
||||
Maybe<bool> Delete(v8::Local<v8::Object> obj, uint32_t index) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->Delete(isolate->GetCurrentContext(), index);
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Array> GetPropertyNames(v8::Local<v8::Object> obj) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(obj->GetPropertyNames(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::Array>()));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Array> GetOwnPropertyNames(v8::Local<v8::Object> obj) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(obj->GetOwnPropertyNames(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::Array>()));
|
||||
}
|
||||
|
||||
inline Maybe<bool> SetPrototype(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::Value> prototype) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION >= 14)
|
||||
return obj->SetPrototypeV2(isolate->GetCurrentContext(), prototype);
|
||||
#else
|
||||
return obj->SetPrototype(isolate->GetCurrentContext(), prototype);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::String> ObjectProtoToString(
|
||||
v8::Local<v8::Object> obj) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(obj->ObjectProtoToString(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::String>()));
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasOwnProperty(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->HasOwnProperty(isolate->GetCurrentContext(), key);
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasRealNamedProperty(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->HasRealNamedProperty(isolate->GetCurrentContext(), key);
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasRealIndexedProperty(
|
||||
v8::Local<v8::Object> obj
|
||||
, uint32_t index) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->HasRealIndexedProperty(isolate->GetCurrentContext(), index);
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasRealNamedCallbackProperty(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->HasRealNamedCallbackProperty(isolate->GetCurrentContext(), key);
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> GetRealNamedPropertyInPrototypeChain(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(obj->GetRealNamedPropertyInPrototypeChain(
|
||||
isolate->GetCurrentContext(), key)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> GetRealNamedProperty(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(
|
||||
obj->GetRealNamedProperty(isolate->GetCurrentContext(), key)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> CallAsFunction(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::Object> recv
|
||||
, int argc
|
||||
, v8::Local<v8::Value> argv[]) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(
|
||||
obj->CallAsFunction(isolate->GetCurrentContext(), recv, argc, argv)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> CallAsConstructor(
|
||||
v8::Local<v8::Object> obj
|
||||
, int argc, v8::Local<v8::Value> argv[]) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(
|
||||
obj->CallAsConstructor(isolate->GetCurrentContext(), argc, argv)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::String> GetSourceLine(v8::Local<v8::Message> msg) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(msg->GetSourceLine(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::String>()));
|
||||
}
|
||||
|
||||
inline Maybe<int> GetLineNumber(v8::Local<v8::Message> msg) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return msg->GetLineNumber(isolate->GetCurrentContext());
|
||||
}
|
||||
|
||||
inline Maybe<int> GetStartColumn(v8::Local<v8::Message> msg) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return msg->GetStartColumn(isolate->GetCurrentContext());
|
||||
}
|
||||
|
||||
inline Maybe<int> GetEndColumn(v8::Local<v8::Message> msg) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return msg->GetEndColumn(isolate->GetCurrentContext());
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Object> CloneElementAt(
|
||||
v8::Local<v8::Array> array
|
||||
, uint32_t index) {
|
||||
#if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION)
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Local<v8::Value> elem;
|
||||
v8::Local<v8::Object> obj;
|
||||
if (!array->Get(context, index).ToLocal(&elem)) {
|
||||
return scope.Escape(obj);
|
||||
}
|
||||
if (!elem->ToObject(context).ToLocal(&obj)) {
|
||||
return scope.Escape(v8::Local<v8::Object>());
|
||||
}
|
||||
return scope.Escape(obj->Clone());
|
||||
#else
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(array->CloneElementAt(isolate->GetCurrentContext(), index)
|
||||
.FromMaybe(v8::Local<v8::Object>()));
|
||||
#endif
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> Call(
|
||||
v8::Local<v8::Function> fun
|
||||
, v8::Local<v8::Object> recv
|
||||
, int argc
|
||||
, v8::Local<v8::Value> argv[]) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(fun->Call(isolate->GetCurrentContext(), recv, argc, argv)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
#endif // NAN_MAYBE_43_INL_H_
|
||||
268
tasks/enduro-trails/prototype/node_modules/nan/nan_maybe_pre_43_inl.h
generated
vendored
Normal file
268
tasks/enduro-trails/prototype/node_modules/nan/nan_maybe_pre_43_inl.h
generated
vendored
Normal file
@@ -0,0 +1,268 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_MAYBE_PRE_43_INL_H_
|
||||
#define NAN_MAYBE_PRE_43_INL_H_
|
||||
|
||||
template<typename T>
|
||||
class MaybeLocal {
|
||||
public:
|
||||
inline MaybeLocal() : val_(v8::Local<T>()) {}
|
||||
|
||||
template<typename S>
|
||||
# if NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION
|
||||
inline
|
||||
MaybeLocal(v8::Local<S> that) : val_(that) {} // NOLINT(runtime/explicit)
|
||||
# else
|
||||
inline
|
||||
MaybeLocal(v8::Local<S> that) : // NOLINT(runtime/explicit)
|
||||
val_(*reinterpret_cast<v8::Local<T>*>(&that)) {}
|
||||
# endif
|
||||
|
||||
inline bool IsEmpty() const { return val_.IsEmpty(); }
|
||||
|
||||
template<typename S>
|
||||
inline bool ToLocal(v8::Local<S> *out) const {
|
||||
*out = val_;
|
||||
return !IsEmpty();
|
||||
}
|
||||
|
||||
inline v8::Local<T> ToLocalChecked() const {
|
||||
#if defined(V8_ENABLE_CHECKS)
|
||||
assert(!IsEmpty() && "ToLocalChecked is Empty");
|
||||
#endif // V8_ENABLE_CHECKS
|
||||
return val_;
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
inline v8::Local<S> FromMaybe(v8::Local<S> default_value) const {
|
||||
return IsEmpty() ? default_value : v8::Local<S>(val_);
|
||||
}
|
||||
|
||||
private:
|
||||
v8::Local<T> val_;
|
||||
};
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::String> ToDetailString(v8::Handle<v8::Value> val) {
|
||||
return MaybeLocal<v8::String>(val->ToDetailString());
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Uint32> ToArrayIndex(v8::Handle<v8::Value> val) {
|
||||
return MaybeLocal<v8::Uint32>(val->ToArrayIndex());
|
||||
}
|
||||
|
||||
inline
|
||||
Maybe<bool> Equals(v8::Handle<v8::Value> a, v8::Handle<v8::Value>(b)) {
|
||||
return Just<bool>(a->Equals(b));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Object> NewInstance(v8::Handle<v8::Function> h) {
|
||||
return MaybeLocal<v8::Object>(h->NewInstance());
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Object> NewInstance(
|
||||
v8::Local<v8::Function> h
|
||||
, int argc
|
||||
, v8::Local<v8::Value> argv[]) {
|
||||
return MaybeLocal<v8::Object>(h->NewInstance(argc, argv));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Object> NewInstance(v8::Handle<v8::ObjectTemplate> h) {
|
||||
return MaybeLocal<v8::Object>(h->NewInstance());
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Function> GetFunction(v8::Handle<v8::FunctionTemplate> t) {
|
||||
return MaybeLocal<v8::Function>(t->GetFunction());
|
||||
}
|
||||
|
||||
inline Maybe<bool> Set(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::Value> key
|
||||
, v8::Handle<v8::Value> value) {
|
||||
return Just<bool>(obj->Set(key, value));
|
||||
}
|
||||
|
||||
inline Maybe<bool> Set(
|
||||
v8::Handle<v8::Object> obj
|
||||
, uint32_t index
|
||||
, v8::Handle<v8::Value> value) {
|
||||
return Just<bool>(obj->Set(index, value));
|
||||
}
|
||||
|
||||
#include "nan_define_own_property_helper.h" // NOLINT(build/include_subdir)
|
||||
|
||||
inline Maybe<bool> DefineOwnProperty(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key
|
||||
, v8::Handle<v8::Value> value
|
||||
, v8::PropertyAttribute attribs = v8::None) {
|
||||
v8::PropertyAttribute current = obj->GetPropertyAttributes(key);
|
||||
return imp::DefineOwnPropertyHelper(current, obj, key, value, attribs);
|
||||
}
|
||||
|
||||
NAN_DEPRECATED inline Maybe<bool> ForceSet(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::Value> key
|
||||
, v8::Handle<v8::Value> value
|
||||
, v8::PropertyAttribute attribs = v8::None) {
|
||||
return Just<bool>(obj->ForceSet(key, value, attribs));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> Get(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::Value> key) {
|
||||
return MaybeLocal<v8::Value>(obj->Get(key));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> Get(
|
||||
v8::Handle<v8::Object> obj
|
||||
, uint32_t index) {
|
||||
return MaybeLocal<v8::Value>(obj->Get(index));
|
||||
}
|
||||
|
||||
inline Maybe<v8::PropertyAttribute> GetPropertyAttributes(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::Value> key) {
|
||||
return Just<v8::PropertyAttribute>(obj->GetPropertyAttributes(key));
|
||||
}
|
||||
|
||||
inline Maybe<bool> Has(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return Just<bool>(obj->Has(key));
|
||||
}
|
||||
|
||||
inline Maybe<bool> Has(
|
||||
v8::Handle<v8::Object> obj
|
||||
, uint32_t index) {
|
||||
return Just<bool>(obj->Has(index));
|
||||
}
|
||||
|
||||
inline Maybe<bool> Delete(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return Just<bool>(obj->Delete(key));
|
||||
}
|
||||
|
||||
inline Maybe<bool> Delete(
|
||||
v8::Handle<v8::Object> obj
|
||||
, uint32_t index) {
|
||||
return Just<bool>(obj->Delete(index));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Array> GetPropertyNames(v8::Handle<v8::Object> obj) {
|
||||
return MaybeLocal<v8::Array>(obj->GetPropertyNames());
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Array> GetOwnPropertyNames(v8::Handle<v8::Object> obj) {
|
||||
return MaybeLocal<v8::Array>(obj->GetOwnPropertyNames());
|
||||
}
|
||||
|
||||
inline Maybe<bool> SetPrototype(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::Value> prototype) {
|
||||
return Just<bool>(obj->SetPrototype(prototype));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::String> ObjectProtoToString(
|
||||
v8::Handle<v8::Object> obj) {
|
||||
return MaybeLocal<v8::String>(obj->ObjectProtoToString());
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasOwnProperty(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return Just<bool>(obj->HasOwnProperty(key));
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasRealNamedProperty(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return Just<bool>(obj->HasRealNamedProperty(key));
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasRealIndexedProperty(
|
||||
v8::Handle<v8::Object> obj
|
||||
, uint32_t index) {
|
||||
return Just<bool>(obj->HasRealIndexedProperty(index));
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasRealNamedCallbackProperty(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return Just<bool>(obj->HasRealNamedCallbackProperty(key));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> GetRealNamedPropertyInPrototypeChain(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return MaybeLocal<v8::Value>(
|
||||
obj->GetRealNamedPropertyInPrototypeChain(key));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> GetRealNamedProperty(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return MaybeLocal<v8::Value>(obj->GetRealNamedProperty(key));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> CallAsFunction(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::Object> recv
|
||||
, int argc
|
||||
, v8::Handle<v8::Value> argv[]) {
|
||||
return MaybeLocal<v8::Value>(obj->CallAsFunction(recv, argc, argv));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> CallAsConstructor(
|
||||
v8::Handle<v8::Object> obj
|
||||
, int argc
|
||||
, v8::Local<v8::Value> argv[]) {
|
||||
return MaybeLocal<v8::Value>(obj->CallAsConstructor(argc, argv));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::String> GetSourceLine(v8::Handle<v8::Message> msg) {
|
||||
return MaybeLocal<v8::String>(msg->GetSourceLine());
|
||||
}
|
||||
|
||||
inline Maybe<int> GetLineNumber(v8::Handle<v8::Message> msg) {
|
||||
return Just<int>(msg->GetLineNumber());
|
||||
}
|
||||
|
||||
inline Maybe<int> GetStartColumn(v8::Handle<v8::Message> msg) {
|
||||
return Just<int>(msg->GetStartColumn());
|
||||
}
|
||||
|
||||
inline Maybe<int> GetEndColumn(v8::Handle<v8::Message> msg) {
|
||||
return Just<int>(msg->GetEndColumn());
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Object> CloneElementAt(
|
||||
v8::Handle<v8::Array> array
|
||||
, uint32_t index) {
|
||||
return MaybeLocal<v8::Object>(array->CloneElementAt(index));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> Call(
|
||||
v8::Local<v8::Function> fun
|
||||
, v8::Local<v8::Object> recv
|
||||
, int argc
|
||||
, v8::Local<v8::Value> argv[]) {
|
||||
return MaybeLocal<v8::Value>(fun->Call(recv, argc, argv));
|
||||
}
|
||||
|
||||
#endif // NAN_MAYBE_PRE_43_INL_H_
|
||||
340
tasks/enduro-trails/prototype/node_modules/nan/nan_new.h
generated
vendored
Normal file
340
tasks/enduro-trails/prototype/node_modules/nan/nan_new.h
generated
vendored
Normal file
@@ -0,0 +1,340 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_NEW_H_
|
||||
#define NAN_NEW_H_
|
||||
|
||||
namespace imp { // scnr
|
||||
|
||||
// TODO(agnat): Generalize
|
||||
template <typename T> v8::Local<T> To(v8::Local<v8::Integer> i);
|
||||
|
||||
template <>
|
||||
inline
|
||||
v8::Local<v8::Integer>
|
||||
To<v8::Integer>(v8::Local<v8::Integer> i) {
|
||||
return Nan::To<v8::Integer>(i).ToLocalChecked();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline
|
||||
v8::Local<v8::Int32>
|
||||
To<v8::Int32>(v8::Local<v8::Integer> i) {
|
||||
return Nan::To<v8::Int32>(i).ToLocalChecked();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline
|
||||
v8::Local<v8::Uint32>
|
||||
To<v8::Uint32>(v8::Local<v8::Integer> i) {
|
||||
return Nan::To<v8::Uint32>(i).ToLocalChecked();
|
||||
}
|
||||
|
||||
template <typename T> struct FactoryBase {
|
||||
typedef v8::Local<T> return_t;
|
||||
};
|
||||
|
||||
template <typename T> struct MaybeFactoryBase {
|
||||
typedef MaybeLocal<T> return_t;
|
||||
};
|
||||
|
||||
template <typename T> struct Factory;
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Array> : FactoryBase<v8::Array> {
|
||||
static inline return_t New();
|
||||
static inline return_t New(int length);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Boolean> : FactoryBase<v8::Boolean> {
|
||||
static inline return_t New(bool value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::BooleanObject> : FactoryBase<v8::BooleanObject> {
|
||||
static inline return_t New(bool value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Context> : FactoryBase<v8::Context> {
|
||||
static inline
|
||||
return_t
|
||||
New( v8::ExtensionConfiguration* extensions = NULL
|
||||
, v8::Local<v8::ObjectTemplate> tmpl = v8::Local<v8::ObjectTemplate>()
|
||||
, v8::Local<v8::Value> obj = v8::Local<v8::Value>());
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Date> : MaybeFactoryBase<v8::Date> {
|
||||
static inline return_t New(double value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::External> : FactoryBase<v8::External> {
|
||||
static inline return_t New(void *value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Function> : FactoryBase<v8::Function> {
|
||||
static inline
|
||||
return_t
|
||||
New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data = v8::Local<v8::Value>());
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::FunctionTemplate> : FactoryBase<v8::FunctionTemplate> {
|
||||
static inline
|
||||
return_t
|
||||
New( FunctionCallback callback = NULL
|
||||
, v8::Local<v8::Value> data = v8::Local<v8::Value>()
|
||||
, v8::Local<v8::Signature> signature = v8::Local<v8::Signature>());
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Number> : FactoryBase<v8::Number> {
|
||||
static inline return_t New(double value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::NumberObject> : FactoryBase<v8::NumberObject> {
|
||||
static inline return_t New(double value);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct IntegerFactory : FactoryBase<T> {
|
||||
typedef typename FactoryBase<T>::return_t return_t;
|
||||
static inline return_t New(int32_t value);
|
||||
static inline return_t New(uint32_t value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Integer> : IntegerFactory<v8::Integer> {};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Int32> : IntegerFactory<v8::Int32> {};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Uint32> : FactoryBase<v8::Uint32> {
|
||||
static inline return_t New(int32_t value);
|
||||
static inline return_t New(uint32_t value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Object> : FactoryBase<v8::Object> {
|
||||
static inline return_t New();
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::ObjectTemplate> : FactoryBase<v8::ObjectTemplate> {
|
||||
static inline return_t New();
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::RegExp> : MaybeFactoryBase<v8::RegExp> {
|
||||
static inline return_t New(
|
||||
v8::Local<v8::String> pattern, v8::RegExp::Flags flags);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Script> : MaybeFactoryBase<v8::Script> {
|
||||
static inline return_t New( v8::Local<v8::String> source);
|
||||
static inline return_t New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Signature> : FactoryBase<v8::Signature> {
|
||||
typedef v8::Local<v8::FunctionTemplate> FTH;
|
||||
static inline return_t New(FTH receiver = FTH());
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::String> : MaybeFactoryBase<v8::String> {
|
||||
static inline return_t New();
|
||||
static inline return_t New(const char *value, int length = -1);
|
||||
static inline return_t New(const uint16_t *value, int length = -1);
|
||||
static inline return_t New(std::string const& value);
|
||||
|
||||
static inline return_t New(v8::String::ExternalStringResource * value);
|
||||
static inline return_t New(ExternalOneByteStringResource * value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::StringObject> : FactoryBase<v8::StringObject> {
|
||||
static inline return_t New(v8::Local<v8::String> value);
|
||||
};
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
#if (NODE_MODULE_VERSION >= 12)
|
||||
|
||||
namespace imp {
|
||||
|
||||
template <>
|
||||
struct Factory<v8::UnboundScript> : MaybeFactoryBase<v8::UnboundScript> {
|
||||
static inline return_t New( v8::Local<v8::String> source);
|
||||
static inline return_t New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin);
|
||||
};
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
# include "nan_implementation_12_inl.h"
|
||||
|
||||
#else // NODE_MODULE_VERSION >= 12
|
||||
|
||||
# include "nan_implementation_pre_12_inl.h"
|
||||
|
||||
#endif
|
||||
|
||||
//=== API ======================================================================
|
||||
|
||||
template <typename T>
|
||||
typename imp::Factory<T>::return_t
|
||||
New() {
|
||||
return imp::Factory<T>::New();
|
||||
}
|
||||
|
||||
template <typename T, typename A0>
|
||||
typename imp::Factory<T>::return_t
|
||||
New(A0 arg0) {
|
||||
return imp::Factory<T>::New(arg0);
|
||||
}
|
||||
|
||||
template <typename T, typename A0, typename A1>
|
||||
typename imp::Factory<T>::return_t
|
||||
New(A0 arg0, A1 arg1) {
|
||||
return imp::Factory<T>::New(arg0, arg1);
|
||||
}
|
||||
|
||||
template <typename T, typename A0, typename A1, typename A2>
|
||||
typename imp::Factory<T>::return_t
|
||||
New(A0 arg0, A1 arg1, A2 arg2) {
|
||||
return imp::Factory<T>::New(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
template <typename T, typename A0, typename A1, typename A2, typename A3>
|
||||
typename imp::Factory<T>::return_t
|
||||
New(A0 arg0, A1 arg1, A2 arg2, A3 arg3) {
|
||||
return imp::Factory<T>::New(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
// Note(agnat): When passing overloaded function pointers to template functions
|
||||
// as generic arguments the compiler needs help in picking the right overload.
|
||||
// These two functions handle New<Function> and New<FunctionTemplate> with
|
||||
// all argument variations.
|
||||
|
||||
// v8::Function and v8::FunctionTemplate with one or two arguments
|
||||
template <typename T>
|
||||
typename imp::Factory<T>::return_t
|
||||
New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data = v8::Local<v8::Value>()) {
|
||||
return imp::Factory<T>::New(callback, data);
|
||||
}
|
||||
|
||||
// v8::Function and v8::FunctionTemplate with three arguments
|
||||
template <typename T, typename A2>
|
||||
typename imp::Factory<T>::return_t
|
||||
New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data = v8::Local<v8::Value>()
|
||||
, A2 a2 = A2()) {
|
||||
return imp::Factory<T>::New(callback, data, a2);
|
||||
}
|
||||
|
||||
// Convenience
|
||||
|
||||
#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
|
||||
template <typename T> inline v8::Local<T> New(v8::Handle<T> h);
|
||||
#endif
|
||||
|
||||
#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
template <typename T, typename M>
|
||||
inline v8::Local<T> New(v8::Persistent<T, M> const& p);
|
||||
#else
|
||||
template <typename T> inline v8::Local<T> New(v8::Persistent<T> const& p);
|
||||
#endif
|
||||
template <typename T, typename M>
|
||||
inline v8::Local<T> New(Persistent<T, M> const& p);
|
||||
template <typename T>
|
||||
inline v8::Local<T> New(Global<T> const& p);
|
||||
|
||||
inline
|
||||
imp::Factory<v8::Boolean>::return_t
|
||||
New(bool value) {
|
||||
return New<v8::Boolean>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::Int32>::return_t
|
||||
New(int32_t value) {
|
||||
return New<v8::Int32>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::Uint32>::return_t
|
||||
New(uint32_t value) {
|
||||
return New<v8::Uint32>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::Number>::return_t
|
||||
New(double value) {
|
||||
return New<v8::Number>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(std::string const& value) { // NOLINT(build/include_what_you_use)
|
||||
return New<v8::String>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(const char * value, int length) {
|
||||
return New<v8::String>(value, length);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(const uint16_t * value, int length) {
|
||||
return New<v8::String>(value, length);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(const char * value) {
|
||||
return New<v8::String>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(const uint16_t * value) {
|
||||
return New<v8::String>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(v8::String::ExternalStringResource * value) {
|
||||
return New<v8::String>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(ExternalOneByteStringResource * value) {
|
||||
return New<v8::String>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::RegExp>::return_t
|
||||
New(v8::Local<v8::String> pattern, v8::RegExp::Flags flags) {
|
||||
return New<v8::RegExp>(pattern, flags);
|
||||
}
|
||||
|
||||
#endif // NAN_NEW_H_
|
||||
156
tasks/enduro-trails/prototype/node_modules/nan/nan_object_wrap.h
generated
vendored
Normal file
156
tasks/enduro-trails/prototype/node_modules/nan/nan_object_wrap.h
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_OBJECT_WRAP_H_
|
||||
#define NAN_OBJECT_WRAP_H_
|
||||
|
||||
class ObjectWrap {
|
||||
public:
|
||||
ObjectWrap() {
|
||||
refs_ = 0;
|
||||
}
|
||||
|
||||
|
||||
virtual ~ObjectWrap() {
|
||||
if (persistent().IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
persistent().ClearWeak();
|
||||
persistent().Reset();
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
static inline T* Unwrap(v8::Local<v8::Object> object) {
|
||||
assert(!object.IsEmpty());
|
||||
assert(object->InternalFieldCount() > 0);
|
||||
// Cast to ObjectWrap before casting to T. A direct cast from void
|
||||
// to T won't work right when T has more than one base class.
|
||||
void* ptr = GetInternalFieldPointer(object, 0);
|
||||
ObjectWrap* wrap = static_cast<ObjectWrap*>(ptr);
|
||||
return static_cast<T*>(wrap);
|
||||
}
|
||||
|
||||
|
||||
inline v8::Local<v8::Object> handle() const {
|
||||
return New(handle_);
|
||||
}
|
||||
|
||||
|
||||
inline Persistent<v8::Object>& persistent() {
|
||||
return handle_;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
inline void Wrap(v8::Local<v8::Object> object) {
|
||||
assert(persistent().IsEmpty());
|
||||
assert(object->InternalFieldCount() > 0);
|
||||
SetInternalFieldPointer(object, 0, this);
|
||||
persistent().Reset(object);
|
||||
MakeWeak();
|
||||
}
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
|
||||
inline void MakeWeak() {
|
||||
persistent().v8::PersistentBase<v8::Object>::SetWeak(
|
||||
this, WeakCallback, v8::WeakCallbackType::kParameter);
|
||||
#if NODE_MAJOR_VERSION < 10
|
||||
// FIXME(bnoordhuis) Probably superfluous in older Node.js versions too.
|
||||
persistent().MarkIndependent();
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
|
||||
inline void MakeWeak() {
|
||||
persistent().v8::PersistentBase<v8::Object>::SetWeak(this, WeakCallback);
|
||||
persistent().MarkIndependent();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline void MakeWeak() {
|
||||
persistent().persistent.MakeWeak(this, WeakCallback);
|
||||
persistent().MarkIndependent();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Ref() marks the object as being attached to an event loop.
|
||||
* Refed objects will not be garbage collected, even if
|
||||
* all references are lost.
|
||||
*/
|
||||
virtual void Ref() {
|
||||
assert(!persistent().IsEmpty());
|
||||
persistent().ClearWeak();
|
||||
refs_++;
|
||||
}
|
||||
|
||||
/* Unref() marks an object as detached from the event loop. This is its
|
||||
* default state. When an object with a "weak" reference changes from
|
||||
* attached to detached state it will be freed. Be careful not to access
|
||||
* the object after making this call as it might be gone!
|
||||
* (A "weak reference" means an object that only has a
|
||||
* persistent handle.)
|
||||
*
|
||||
* DO NOT CALL THIS FROM DESTRUCTOR
|
||||
*/
|
||||
virtual void Unref() {
|
||||
assert(!persistent().IsEmpty());
|
||||
assert(!persistent().IsWeak());
|
||||
assert(refs_ > 0);
|
||||
if (--refs_ == 0)
|
||||
MakeWeak();
|
||||
}
|
||||
|
||||
int refs_; // ro
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(ObjectWrap)
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
|
||||
static void
|
||||
WeakCallback(v8::WeakCallbackInfo<ObjectWrap> const& info) {
|
||||
ObjectWrap* wrap = info.GetParameter();
|
||||
assert(wrap->refs_ == 0);
|
||||
wrap->handle_.Reset();
|
||||
delete wrap;
|
||||
}
|
||||
|
||||
#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
|
||||
static void
|
||||
WeakCallback(v8::WeakCallbackData<v8::Object, ObjectWrap> const& data) {
|
||||
ObjectWrap* wrap = data.GetParameter();
|
||||
assert(wrap->refs_ == 0);
|
||||
assert(wrap->handle_.IsNearDeath());
|
||||
wrap->handle_.Reset();
|
||||
delete wrap;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void WeakCallback(v8::Persistent<v8::Value> value, void *data) {
|
||||
ObjectWrap *wrap = static_cast<ObjectWrap*>(data);
|
||||
assert(wrap->refs_ == 0);
|
||||
assert(wrap->handle_.IsNearDeath());
|
||||
wrap->handle_.Reset();
|
||||
delete wrap;
|
||||
}
|
||||
|
||||
#endif
|
||||
Persistent<v8::Object> handle_;
|
||||
};
|
||||
|
||||
|
||||
#endif // NAN_OBJECT_WRAP_H_
|
||||
132
tasks/enduro-trails/prototype/node_modules/nan/nan_persistent_12_inl.h
generated
vendored
Normal file
132
tasks/enduro-trails/prototype/node_modules/nan/nan_persistent_12_inl.h
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_PERSISTENT_12_INL_H_
|
||||
#define NAN_PERSISTENT_12_INL_H_
|
||||
|
||||
template<typename T, typename M> class Persistent :
|
||||
public v8::Persistent<T, M> {
|
||||
public:
|
||||
inline Persistent() : v8::Persistent<T, M>() {}
|
||||
|
||||
template<typename S> inline Persistent(v8::Local<S> that) :
|
||||
v8::Persistent<T, M>(v8::Isolate::GetCurrent(), that) {}
|
||||
|
||||
template<typename S, typename M2>
|
||||
inline
|
||||
Persistent(const v8::Persistent<S, M2> &that) : // NOLINT(runtime/explicit)
|
||||
v8::Persistent<T, M2>(v8::Isolate::GetCurrent(), that) {}
|
||||
|
||||
inline void Reset() { v8::PersistentBase<T>::Reset(); }
|
||||
|
||||
template <typename S>
|
||||
inline void Reset(const v8::Local<S> &other) {
|
||||
v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
inline void Reset(const v8::PersistentBase<S> &other) {
|
||||
v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
|
||||
}
|
||||
|
||||
template<typename P>
|
||||
inline void SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type);
|
||||
|
||||
private:
|
||||
inline T *operator*() const { return *PersistentBase<T>::persistent; }
|
||||
|
||||
template<typename S, typename M2>
|
||||
inline void Copy(const Persistent<S, M2> &that) {
|
||||
TYPE_CHECK(T, S);
|
||||
|
||||
this->Reset();
|
||||
|
||||
if (!that.IsEmpty()) {
|
||||
this->Reset(that);
|
||||
M::Copy(that, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
template<typename T>
|
||||
class Global : public v8::Global<T> {
|
||||
public:
|
||||
inline Global() : v8::Global<T>() {}
|
||||
|
||||
template<typename S> inline Global(v8::Local<S> that) :
|
||||
v8::Global<T>(v8::Isolate::GetCurrent(), that) {}
|
||||
|
||||
template<typename S>
|
||||
inline
|
||||
Global(const v8::PersistentBase<S> &that) : // NOLINT(runtime/explicit)
|
||||
v8::Global<S>(v8::Isolate::GetCurrent(), that) {}
|
||||
|
||||
inline void Reset() { v8::PersistentBase<T>::Reset(); }
|
||||
|
||||
template <typename S>
|
||||
inline void Reset(const v8::Local<S> &other) {
|
||||
v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
inline void Reset(const v8::PersistentBase<S> &other) {
|
||||
v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
|
||||
}
|
||||
|
||||
template<typename P>
|
||||
inline void SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
reinterpret_cast<Persistent<T>*>(this)->SetWeak(
|
||||
parameter, callback, type);
|
||||
}
|
||||
};
|
||||
#else
|
||||
template<typename T>
|
||||
class Global : public v8::UniquePersistent<T> {
|
||||
public:
|
||||
inline Global() : v8::UniquePersistent<T>() {}
|
||||
|
||||
template<typename S> inline Global(v8::Local<S> that) :
|
||||
v8::UniquePersistent<T>(v8::Isolate::GetCurrent(), that) {}
|
||||
|
||||
template<typename S>
|
||||
inline
|
||||
Global(const v8::PersistentBase<S> &that) : // NOLINT(runtime/explicit)
|
||||
v8::UniquePersistent<S>(v8::Isolate::GetCurrent(), that) {}
|
||||
|
||||
inline void Reset() { v8::PersistentBase<T>::Reset(); }
|
||||
|
||||
template <typename S>
|
||||
inline void Reset(const v8::Local<S> &other) {
|
||||
v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
inline void Reset(const v8::PersistentBase<S> &other) {
|
||||
v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
|
||||
}
|
||||
|
||||
template<typename P>
|
||||
inline void SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
reinterpret_cast<Persistent<T>*>(this)->SetWeak(
|
||||
parameter, callback, type);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // NAN_PERSISTENT_12_INL_H_
|
||||
242
tasks/enduro-trails/prototype/node_modules/nan/nan_persistent_pre_12_inl.h
generated
vendored
Normal file
242
tasks/enduro-trails/prototype/node_modules/nan/nan_persistent_pre_12_inl.h
generated
vendored
Normal file
@@ -0,0 +1,242 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_PERSISTENT_PRE_12_INL_H_
|
||||
#define NAN_PERSISTENT_PRE_12_INL_H_
|
||||
|
||||
template<typename T>
|
||||
class PersistentBase {
|
||||
v8::Persistent<T> persistent;
|
||||
template<typename U>
|
||||
friend v8::Local<U> New(const PersistentBase<U> &p);
|
||||
template<typename U, typename M>
|
||||
friend v8::Local<U> New(const Persistent<U, M> &p);
|
||||
template<typename U>
|
||||
friend v8::Local<U> New(const Global<U> &p);
|
||||
template<typename S> friend class ReturnValue;
|
||||
|
||||
public:
|
||||
inline PersistentBase() :
|
||||
persistent() {}
|
||||
|
||||
inline void Reset() {
|
||||
persistent.Dispose();
|
||||
persistent.Clear();
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
inline void Reset(const v8::Local<S> &other) {
|
||||
TYPE_CHECK(T, S);
|
||||
|
||||
if (!persistent.IsEmpty()) {
|
||||
persistent.Dispose();
|
||||
}
|
||||
|
||||
if (other.IsEmpty()) {
|
||||
persistent.Clear();
|
||||
} else {
|
||||
persistent = v8::Persistent<T>::New(other);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
inline void Reset(const PersistentBase<S> &other) {
|
||||
TYPE_CHECK(T, S);
|
||||
|
||||
if (!persistent.IsEmpty()) {
|
||||
persistent.Dispose();
|
||||
}
|
||||
|
||||
if (other.IsEmpty()) {
|
||||
persistent.Clear();
|
||||
} else {
|
||||
persistent = v8::Persistent<T>::New(other.persistent);
|
||||
}
|
||||
}
|
||||
|
||||
inline bool IsEmpty() const { return persistent.IsEmpty(); }
|
||||
|
||||
inline void Empty() { persistent.Clear(); }
|
||||
|
||||
template<typename S>
|
||||
inline bool operator==(const PersistentBase<S> &that) const {
|
||||
return this->persistent == that.persistent;
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
inline bool operator==(const v8::Local<S> &that) const {
|
||||
return this->persistent == that;
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
inline bool operator!=(const PersistentBase<S> &that) const {
|
||||
return !operator==(that);
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
inline bool operator!=(const v8::Local<S> &that) const {
|
||||
return !operator==(that);
|
||||
}
|
||||
|
||||
template<typename P>
|
||||
inline void SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type);
|
||||
|
||||
inline void ClearWeak() { persistent.ClearWeak(); }
|
||||
|
||||
inline void MarkIndependent() { persistent.MarkIndependent(); }
|
||||
|
||||
inline bool IsIndependent() const { return persistent.IsIndependent(); }
|
||||
|
||||
inline bool IsNearDeath() const { return persistent.IsNearDeath(); }
|
||||
|
||||
inline bool IsWeak() const { return persistent.IsWeak(); }
|
||||
|
||||
private:
|
||||
inline explicit PersistentBase(v8::Persistent<T> that) :
|
||||
persistent(that) { }
|
||||
inline explicit PersistentBase(T *val) : persistent(val) {}
|
||||
template<typename S, typename M> friend class Persistent;
|
||||
template<typename S> friend class Global;
|
||||
friend class ObjectWrap;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class NonCopyablePersistentTraits {
|
||||
public:
|
||||
typedef Persistent<T, NonCopyablePersistentTraits<T> >
|
||||
NonCopyablePersistent;
|
||||
static const bool kResetInDestructor = false;
|
||||
template<typename S, typename M>
|
||||
inline static void Copy(const Persistent<S, M> &source,
|
||||
NonCopyablePersistent *dest) {
|
||||
Uncompilable<v8::Object>();
|
||||
}
|
||||
|
||||
template<typename O> inline static void Uncompilable() {
|
||||
TYPE_CHECK(O, v8::Primitive);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct CopyablePersistentTraits {
|
||||
typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
|
||||
static const bool kResetInDestructor = true;
|
||||
template<typename S, typename M>
|
||||
static inline void Copy(const Persistent<S, M> &source,
|
||||
CopyablePersistent *dest) {}
|
||||
};
|
||||
|
||||
template<typename T, typename M> class Persistent :
|
||||
public PersistentBase<T> {
|
||||
public:
|
||||
inline Persistent() {}
|
||||
|
||||
template<typename S> inline Persistent(v8::Handle<S> that)
|
||||
: PersistentBase<T>(v8::Persistent<T>::New(that)) {
|
||||
TYPE_CHECK(T, S);
|
||||
}
|
||||
|
||||
inline Persistent(const Persistent &that) : PersistentBase<T>() {
|
||||
Copy(that);
|
||||
}
|
||||
|
||||
template<typename S, typename M2>
|
||||
inline Persistent(const Persistent<S, M2> &that) :
|
||||
PersistentBase<T>() {
|
||||
Copy(that);
|
||||
}
|
||||
|
||||
inline Persistent &operator=(const Persistent &that) {
|
||||
Copy(that);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class S, class M2>
|
||||
inline Persistent &operator=(const Persistent<S, M2> &that) {
|
||||
Copy(that);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline ~Persistent() {
|
||||
if (M::kResetInDestructor) this->Reset();
|
||||
}
|
||||
|
||||
private:
|
||||
inline T *operator*() const { return *PersistentBase<T>::persistent; }
|
||||
|
||||
template<typename S, typename M2>
|
||||
inline void Copy(const Persistent<S, M2> &that) {
|
||||
TYPE_CHECK(T, S);
|
||||
|
||||
this->Reset();
|
||||
|
||||
if (!that.IsEmpty()) {
|
||||
this->persistent = v8::Persistent<T>::New(that.persistent);
|
||||
M::Copy(that, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class Global : public PersistentBase<T> {
|
||||
struct RValue {
|
||||
inline explicit RValue(Global* obj) : object(obj) {}
|
||||
Global* object;
|
||||
};
|
||||
|
||||
public:
|
||||
inline Global() : PersistentBase<T>(0) { }
|
||||
|
||||
template <typename S>
|
||||
inline Global(v8::Local<S> that) // NOLINT(runtime/explicit)
|
||||
: PersistentBase<T>(v8::Persistent<T>::New(that)) {
|
||||
TYPE_CHECK(T, S);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
inline Global(const PersistentBase<S> &that) // NOLINT(runtime/explicit)
|
||||
: PersistentBase<T>(that) {
|
||||
TYPE_CHECK(T, S);
|
||||
}
|
||||
/**
|
||||
* Move constructor.
|
||||
*/
|
||||
inline Global(RValue rvalue) // NOLINT(runtime/explicit)
|
||||
: PersistentBase<T>(rvalue.object->persistent) {
|
||||
rvalue.object->Reset();
|
||||
}
|
||||
inline ~Global() { this->Reset(); }
|
||||
/**
|
||||
* Move via assignment.
|
||||
*/
|
||||
template<typename S>
|
||||
inline Global &operator=(Global<S> rhs) {
|
||||
TYPE_CHECK(T, S);
|
||||
this->Reset(rhs.persistent);
|
||||
rhs.Reset();
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* Cast operator for moves.
|
||||
*/
|
||||
inline operator RValue() { return RValue(this); }
|
||||
/**
|
||||
* Pass allows returning uniques from functions, etc.
|
||||
*/
|
||||
Global Pass() { return Global(RValue(this)); }
|
||||
|
||||
private:
|
||||
Global(Global &);
|
||||
void operator=(Global &);
|
||||
template<typename S> friend class ReturnValue;
|
||||
};
|
||||
|
||||
#endif // NAN_PERSISTENT_PRE_12_INL_H_
|
||||
73
tasks/enduro-trails/prototype/node_modules/nan/nan_private.h
generated
vendored
Normal file
73
tasks/enduro-trails/prototype/node_modules/nan/nan_private.h
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_PRIVATE_H_
|
||||
#define NAN_PRIVATE_H_
|
||||
|
||||
inline Maybe<bool>
|
||||
HasPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key) {
|
||||
HandleScope scope;
|
||||
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
||||
return object->HasPrivate(context, private_key);
|
||||
#else
|
||||
return Just(!object->GetHiddenValue(key).IsEmpty());
|
||||
#endif
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value>
|
||||
GetPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key) {
|
||||
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
||||
v8::MaybeLocal<v8::Value> v = object->GetPrivate(context, private_key);
|
||||
return scope.Escape(v.ToLocalChecked());
|
||||
#else
|
||||
EscapableHandleScope scope;
|
||||
v8::Local<v8::Value> v = object->GetHiddenValue(key);
|
||||
if (v.IsEmpty()) {
|
||||
v = Undefined();
|
||||
}
|
||||
return scope.Escape(v);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline Maybe<bool> SetPrivate(
|
||||
v8::Local<v8::Object> object,
|
||||
v8::Local<v8::String> key,
|
||||
v8::Local<v8::Value> value) {
|
||||
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
||||
HandleScope scope;
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
||||
return object->SetPrivate(context, private_key, value);
|
||||
#else
|
||||
return Just(object->SetHiddenValue(key, value));
|
||||
#endif
|
||||
}
|
||||
|
||||
inline Maybe<bool> DeletePrivate(
|
||||
v8::Local<v8::Object> object,
|
||||
v8::Local<v8::String> key) {
|
||||
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
||||
HandleScope scope;
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
||||
return object->DeletePrivate(isolate->GetCurrentContext(), private_key);
|
||||
#else
|
||||
return Just(object->DeleteHiddenValue(key));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // NAN_PRIVATE_H_
|
||||
|
||||
97
tasks/enduro-trails/prototype/node_modules/nan/nan_scriptorigin.h
generated
vendored
Normal file
97
tasks/enduro-trails/prototype/node_modules/nan/nan_scriptorigin.h
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2021 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_SCRIPTORIGIN_H_
|
||||
#define NAN_SCRIPTORIGIN_H_
|
||||
|
||||
class ScriptOrigin : public v8::ScriptOrigin {
|
||||
public:
|
||||
#if defined(V8_MAJOR_VERSION) && \
|
||||
(V8_MAJOR_VERSION > 12 || \
|
||||
(V8_MAJOR_VERSION == 12 && \
|
||||
(defined(V8_MINOR_VERSION) && \
|
||||
(V8_MINOR_VERSION > 6 || \
|
||||
(V8_MINOR_VERSION == 6 && defined(V8_BUILD_NUMBER) && \
|
||||
V8_BUILD_NUMBER >= 175)))))
|
||||
explicit ScriptOrigin(v8::Local<v8::Value> name) :
|
||||
v8::ScriptOrigin(name) {}
|
||||
|
||||
ScriptOrigin(v8::Local<v8::Value> name
|
||||
, v8::Local<v8::Integer> line) :
|
||||
v8::ScriptOrigin(name
|
||||
, To<int32_t>(line).FromMaybe(0)) {}
|
||||
|
||||
ScriptOrigin(v8::Local<v8::Value> name
|
||||
, v8::Local<v8::Integer> line
|
||||
, v8::Local<v8::Integer> column) :
|
||||
v8::ScriptOrigin(name
|
||||
, To<int32_t>(line).FromMaybe(0)
|
||||
, To<int32_t>(column).FromMaybe(0)) {}
|
||||
#elif defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 9 || \
|
||||
(V8_MAJOR_VERSION == 9 && (defined(V8_MINOR_VERSION) && (V8_MINOR_VERSION > 0\
|
||||
|| (V8_MINOR_VERSION == 0 && defined(V8_BUILD_NUMBER) \
|
||||
&& V8_BUILD_NUMBER >= 1)))))
|
||||
explicit ScriptOrigin(v8::Local<v8::Value> name) :
|
||||
v8::ScriptOrigin(v8::Isolate::GetCurrent(), name) {}
|
||||
|
||||
ScriptOrigin(v8::Local<v8::Value> name
|
||||
, v8::Local<v8::Integer> line) :
|
||||
v8::ScriptOrigin(v8::Isolate::GetCurrent()
|
||||
, name
|
||||
, To<int32_t>(line).FromMaybe(0)) {}
|
||||
|
||||
ScriptOrigin(v8::Local<v8::Value> name
|
||||
, v8::Local<v8::Integer> line
|
||||
, v8::Local<v8::Integer> column) :
|
||||
v8::ScriptOrigin(v8::Isolate::GetCurrent()
|
||||
, name
|
||||
, To<int32_t>(line).FromMaybe(0)
|
||||
, To<int32_t>(column).FromMaybe(0)) {}
|
||||
#elif defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 8 || \
|
||||
(V8_MAJOR_VERSION == 8 && (defined(V8_MINOR_VERSION) && (V8_MINOR_VERSION > 9\
|
||||
|| (V8_MINOR_VERSION == 9 && defined(V8_BUILD_NUMBER) \
|
||||
&& V8_BUILD_NUMBER >= 45)))))
|
||||
explicit ScriptOrigin(v8::Local<v8::Value> name) : v8::ScriptOrigin(name) {}
|
||||
|
||||
ScriptOrigin(v8::Local<v8::Value> name
|
||||
, v8::Local<v8::Integer> line) :
|
||||
v8::ScriptOrigin(name, To<int32_t>(line).FromMaybe(0)) {}
|
||||
|
||||
ScriptOrigin(v8::Local<v8::Value> name
|
||||
, v8::Local<v8::Integer> line
|
||||
, v8::Local<v8::Integer> column) :
|
||||
v8::ScriptOrigin(name
|
||||
, To<int32_t>(line).FromMaybe(0)
|
||||
, To<int32_t>(column).FromMaybe(0)) {}
|
||||
#else
|
||||
explicit ScriptOrigin(v8::Local<v8::Value> name) : v8::ScriptOrigin(name) {}
|
||||
|
||||
ScriptOrigin(v8::Local<v8::Value> name
|
||||
, v8::Local<v8::Integer> line) : v8::ScriptOrigin(name, line) {}
|
||||
|
||||
ScriptOrigin(v8::Local<v8::Value> name
|
||||
, v8::Local<v8::Integer> line
|
||||
, v8::Local<v8::Integer> column) :
|
||||
v8::ScriptOrigin(name, line, column) {}
|
||||
#endif
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 8 || \
|
||||
(V8_MAJOR_VERSION == 8 && (defined(V8_MINOR_VERSION) && (V8_MINOR_VERSION > 9\
|
||||
|| (V8_MINOR_VERSION == 9 && defined(V8_BUILD_NUMBER) \
|
||||
&& V8_BUILD_NUMBER >= 45)))))
|
||||
v8::Local<v8::Integer> ResourceLineOffset() const {
|
||||
return New(LineOffset());
|
||||
}
|
||||
|
||||
v8::Local<v8::Integer> ResourceColumnOffset() const {
|
||||
return New(ColumnOffset());
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // NAN_SCRIPTORIGIN_H_
|
||||
305
tasks/enduro-trails/prototype/node_modules/nan/nan_string_bytes.h
generated
vendored
Normal file
305
tasks/enduro-trails/prototype/node_modules/nan/nan_string_bytes.h
generated
vendored
Normal file
@@ -0,0 +1,305 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef NAN_STRING_BYTES_H_
|
||||
#define NAN_STRING_BYTES_H_
|
||||
|
||||
// Decodes a v8::Local<v8::String> or Buffer to a raw char*
|
||||
|
||||
namespace imp {
|
||||
|
||||
using v8::Local;
|
||||
using v8::Object;
|
||||
using v8::String;
|
||||
using v8::Value;
|
||||
|
||||
|
||||
//// Base 64 ////
|
||||
|
||||
#define base64_encoded_size(size) ((size + 2 - ((size + 2) % 3)) / 3 * 4)
|
||||
|
||||
|
||||
|
||||
//// HEX ////
|
||||
|
||||
static bool contains_non_ascii_slow(const char* buf, size_t len) {
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
if (buf[i] & 0x80) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool contains_non_ascii(const char* src, size_t len) {
|
||||
if (len < 16) {
|
||||
return contains_non_ascii_slow(src, len);
|
||||
}
|
||||
|
||||
const unsigned bytes_per_word = sizeof(void*);
|
||||
const unsigned align_mask = bytes_per_word - 1;
|
||||
const unsigned unaligned = reinterpret_cast<uintptr_t>(src) & align_mask;
|
||||
|
||||
if (unaligned > 0) {
|
||||
const unsigned n = bytes_per_word - unaligned;
|
||||
if (contains_non_ascii_slow(src, n)) return true;
|
||||
src += n;
|
||||
len -= n;
|
||||
}
|
||||
|
||||
|
||||
#if defined(__x86_64__) || defined(_WIN64)
|
||||
const uintptr_t mask = 0x8080808080808080ll;
|
||||
#else
|
||||
const uintptr_t mask = 0x80808080l;
|
||||
#endif
|
||||
|
||||
const uintptr_t* srcw = reinterpret_cast<const uintptr_t*>(src);
|
||||
|
||||
for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) {
|
||||
if (srcw[i] & mask) return true;
|
||||
}
|
||||
|
||||
const unsigned remainder = len & align_mask;
|
||||
if (remainder > 0) {
|
||||
const size_t offset = len - remainder;
|
||||
if (contains_non_ascii_slow(src + offset, remainder)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static void force_ascii_slow(const char* src, char* dst, size_t len) {
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
dst[i] = src[i] & 0x7f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void force_ascii(const char* src, char* dst, size_t len) {
|
||||
if (len < 16) {
|
||||
force_ascii_slow(src, dst, len);
|
||||
return;
|
||||
}
|
||||
|
||||
const unsigned bytes_per_word = sizeof(void*);
|
||||
const unsigned align_mask = bytes_per_word - 1;
|
||||
const unsigned src_unalign = reinterpret_cast<uintptr_t>(src) & align_mask;
|
||||
const unsigned dst_unalign = reinterpret_cast<uintptr_t>(dst) & align_mask;
|
||||
|
||||
if (src_unalign > 0) {
|
||||
if (src_unalign == dst_unalign) {
|
||||
const unsigned unalign = bytes_per_word - src_unalign;
|
||||
force_ascii_slow(src, dst, unalign);
|
||||
src += unalign;
|
||||
dst += unalign;
|
||||
len -= src_unalign;
|
||||
} else {
|
||||
force_ascii_slow(src, dst, len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__x86_64__) || defined(_WIN64)
|
||||
const uintptr_t mask = ~0x8080808080808080ll;
|
||||
#else
|
||||
const uintptr_t mask = ~0x80808080l;
|
||||
#endif
|
||||
|
||||
const uintptr_t* srcw = reinterpret_cast<const uintptr_t*>(src);
|
||||
uintptr_t* dstw = reinterpret_cast<uintptr_t*>(dst);
|
||||
|
||||
for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) {
|
||||
dstw[i] = srcw[i] & mask;
|
||||
}
|
||||
|
||||
const unsigned remainder = len & align_mask;
|
||||
if (remainder > 0) {
|
||||
const size_t offset = len - remainder;
|
||||
force_ascii_slow(src + offset, dst + offset, remainder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static size_t base64_encode(const char* src,
|
||||
size_t slen,
|
||||
char* dst,
|
||||
size_t dlen) {
|
||||
// We know how much we'll write, just make sure that there's space.
|
||||
assert(dlen >= base64_encoded_size(slen) &&
|
||||
"not enough space provided for base64 encode");
|
||||
|
||||
dlen = base64_encoded_size(slen);
|
||||
|
||||
unsigned a;
|
||||
unsigned b;
|
||||
unsigned c;
|
||||
unsigned i;
|
||||
unsigned k;
|
||||
unsigned n;
|
||||
|
||||
static const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
|
||||
i = 0;
|
||||
k = 0;
|
||||
n = slen / 3 * 3;
|
||||
|
||||
while (i < n) {
|
||||
a = src[i + 0] & 0xff;
|
||||
b = src[i + 1] & 0xff;
|
||||
c = src[i + 2] & 0xff;
|
||||
|
||||
dst[k + 0] = table[a >> 2];
|
||||
dst[k + 1] = table[((a & 3) << 4) | (b >> 4)];
|
||||
dst[k + 2] = table[((b & 0x0f) << 2) | (c >> 6)];
|
||||
dst[k + 3] = table[c & 0x3f];
|
||||
|
||||
i += 3;
|
||||
k += 4;
|
||||
}
|
||||
|
||||
if (n != slen) {
|
||||
switch (slen - n) {
|
||||
case 1:
|
||||
a = src[i + 0] & 0xff;
|
||||
dst[k + 0] = table[a >> 2];
|
||||
dst[k + 1] = table[(a & 3) << 4];
|
||||
dst[k + 2] = '=';
|
||||
dst[k + 3] = '=';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
a = src[i + 0] & 0xff;
|
||||
b = src[i + 1] & 0xff;
|
||||
dst[k + 0] = table[a >> 2];
|
||||
dst[k + 1] = table[((a & 3) << 4) | (b >> 4)];
|
||||
dst[k + 2] = table[(b & 0x0f) << 2];
|
||||
dst[k + 3] = '=';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return dlen;
|
||||
}
|
||||
|
||||
|
||||
static size_t hex_encode(const char* src, size_t slen, char* dst, size_t dlen) {
|
||||
// We know how much we'll write, just make sure that there's space.
|
||||
assert(dlen >= slen * 2 &&
|
||||
"not enough space provided for hex encode");
|
||||
|
||||
dlen = slen * 2;
|
||||
for (uint32_t i = 0, k = 0; k < dlen; i += 1, k += 2) {
|
||||
static const char hex[] = "0123456789abcdef";
|
||||
uint8_t val = static_cast<uint8_t>(src[i]);
|
||||
dst[k + 0] = hex[val >> 4];
|
||||
dst[k + 1] = hex[val & 15];
|
||||
}
|
||||
|
||||
return dlen;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Local<Value> Encode(const char* buf,
|
||||
size_t buflen,
|
||||
enum Encoding encoding) {
|
||||
assert(buflen <= node::Buffer::kMaxLength);
|
||||
if (!buflen && encoding != BUFFER)
|
||||
return New("").ToLocalChecked();
|
||||
|
||||
Local<String> val;
|
||||
switch (encoding) {
|
||||
case BUFFER:
|
||||
return CopyBuffer(buf, buflen).ToLocalChecked();
|
||||
|
||||
case ASCII:
|
||||
if (contains_non_ascii(buf, buflen)) {
|
||||
char* out = new char[buflen];
|
||||
force_ascii(buf, out, buflen);
|
||||
val = New<String>(out, buflen).ToLocalChecked();
|
||||
delete[] out;
|
||||
} else {
|
||||
val = New<String>(buf, buflen).ToLocalChecked();
|
||||
}
|
||||
break;
|
||||
|
||||
case UTF8:
|
||||
val = New<String>(buf, buflen).ToLocalChecked();
|
||||
break;
|
||||
|
||||
case BINARY: {
|
||||
// TODO(isaacs) use ExternalTwoByteString?
|
||||
const unsigned char *cbuf = reinterpret_cast<const unsigned char*>(buf);
|
||||
uint16_t * twobytebuf = new uint16_t[buflen];
|
||||
for (size_t i = 0; i < buflen; i++) {
|
||||
// XXX is the following line platform independent?
|
||||
twobytebuf[i] = cbuf[i];
|
||||
}
|
||||
val = New<String>(twobytebuf, buflen).ToLocalChecked();
|
||||
delete[] twobytebuf;
|
||||
break;
|
||||
}
|
||||
|
||||
case BASE64: {
|
||||
size_t dlen = base64_encoded_size(buflen);
|
||||
char* dst = new char[dlen];
|
||||
|
||||
size_t written = base64_encode(buf, buflen, dst, dlen);
|
||||
assert(written == dlen);
|
||||
|
||||
val = New<String>(dst, dlen).ToLocalChecked();
|
||||
delete[] dst;
|
||||
break;
|
||||
}
|
||||
|
||||
case UCS2: {
|
||||
const uint16_t* data = reinterpret_cast<const uint16_t*>(buf);
|
||||
val = New<String>(data, buflen / 2).ToLocalChecked();
|
||||
break;
|
||||
}
|
||||
|
||||
case HEX: {
|
||||
size_t dlen = buflen * 2;
|
||||
char* dst = new char[dlen];
|
||||
size_t written = hex_encode(buf, buflen, dst, dlen);
|
||||
assert(written == dlen);
|
||||
|
||||
val = New<String>(dst, dlen).ToLocalChecked();
|
||||
delete[] dst;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
assert(0 && "unknown encoding");
|
||||
break;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
#undef base64_encoded_size
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
#endif // NAN_STRING_BYTES_H_
|
||||
96
tasks/enduro-trails/prototype/node_modules/nan/nan_typedarray_contents.h
generated
vendored
Normal file
96
tasks/enduro-trails/prototype/node_modules/nan/nan_typedarray_contents.h
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_TYPEDARRAY_CONTENTS_H_
|
||||
#define NAN_TYPEDARRAY_CONTENTS_H_
|
||||
|
||||
template<typename T>
|
||||
class TypedArrayContents {
|
||||
public:
|
||||
inline explicit TypedArrayContents(v8::Local<v8::Value> from) :
|
||||
length_(0), data_(NULL) {
|
||||
HandleScope scope;
|
||||
|
||||
size_t length = 0;
|
||||
void* data = NULL;
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
|
||||
if (from->IsArrayBufferView()) {
|
||||
v8::Local<v8::ArrayBufferView> array =
|
||||
v8::Local<v8::ArrayBufferView>::Cast(from);
|
||||
|
||||
const size_t byte_length = array->ByteLength();
|
||||
const ptrdiff_t byte_offset = array->ByteOffset();
|
||||
v8::Local<v8::ArrayBuffer> buffer = array->Buffer();
|
||||
|
||||
length = byte_length / sizeof(T);
|
||||
// Actually it's 7.9 here but this would lead to ABI issues with Node.js 13
|
||||
// using 7.8 till 13.2.0.
|
||||
#if (V8_MAJOR_VERSION >= 8)
|
||||
data = static_cast<char*>(buffer->GetBackingStore()->Data()) + byte_offset;
|
||||
#else
|
||||
data = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
if (from->IsObject() && !from->IsNull()) {
|
||||
v8::Local<v8::Object> array = v8::Local<v8::Object>::Cast(from);
|
||||
|
||||
MaybeLocal<v8::Value> buffer = Get(array,
|
||||
New<v8::String>("buffer").ToLocalChecked());
|
||||
MaybeLocal<v8::Value> byte_length = Get(array,
|
||||
New<v8::String>("byteLength").ToLocalChecked());
|
||||
MaybeLocal<v8::Value> byte_offset = Get(array,
|
||||
New<v8::String>("byteOffset").ToLocalChecked());
|
||||
|
||||
if (!buffer.IsEmpty() &&
|
||||
!byte_length.IsEmpty() && byte_length.ToLocalChecked()->IsUint32() &&
|
||||
!byte_offset.IsEmpty() && byte_offset.ToLocalChecked()->IsUint32()) {
|
||||
data = array->GetIndexedPropertiesExternalArrayData();
|
||||
if(data) {
|
||||
length = byte_length.ToLocalChecked()->Uint32Value() / sizeof(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1900 || __cplusplus >= 201103L
|
||||
assert(reinterpret_cast<uintptr_t>(data) % alignof (T) == 0);
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1600 || defined(__GNUC__)
|
||||
assert(reinterpret_cast<uintptr_t>(data) % __alignof(T) == 0);
|
||||
#else
|
||||
assert(reinterpret_cast<uintptr_t>(data) % sizeof (T) == 0);
|
||||
#endif
|
||||
|
||||
length_ = length;
|
||||
data_ = static_cast<T*>(data);
|
||||
}
|
||||
|
||||
inline size_t length() const { return length_; }
|
||||
inline T* operator*() { return data_; }
|
||||
inline const T* operator*() const { return data_; }
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(TypedArrayContents)
|
||||
|
||||
// Disable heap allocation
|
||||
void *operator new(size_t size);
|
||||
void operator delete(void *, size_t) {
|
||||
abort();
|
||||
}
|
||||
|
||||
size_t length_;
|
||||
T* data_;
|
||||
};
|
||||
|
||||
#endif // NAN_TYPEDARRAY_CONTENTS_H_
|
||||
453
tasks/enduro-trails/prototype/node_modules/nan/nan_weak.h
generated
vendored
Normal file
453
tasks/enduro-trails/prototype/node_modules/nan/nan_weak.h
generated
vendored
Normal file
@@ -0,0 +1,453 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_WEAK_H_
|
||||
#define NAN_WEAK_H_
|
||||
|
||||
static const int kInternalFieldsInWeakCallback = 2;
|
||||
static const int kNoInternalFieldIndex = -1;
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
# define NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ \
|
||||
v8::WeakCallbackInfo<WeakCallbackInfo<T> > const&
|
||||
# define NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ \
|
||||
NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
# define NAN_WEAK_PARAMETER_CALLBACK_SIG_ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
# define NAN_WEAK_TWOFIELD_CALLBACK_SIG_ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
|
||||
#elif NODE_MODULE_VERSION > IOJS_1_1_MODULE_VERSION
|
||||
# define NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ \
|
||||
v8::PhantomCallbackData<WeakCallbackInfo<T> > const&
|
||||
# define NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ \
|
||||
NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
# define NAN_WEAK_PARAMETER_CALLBACK_SIG_ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
# define NAN_WEAK_TWOFIELD_CALLBACK_SIG_ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
|
||||
#elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
|
||||
# define NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ \
|
||||
v8::PhantomCallbackData<WeakCallbackInfo<T> > const&
|
||||
# define NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ \
|
||||
v8::InternalFieldsCallbackData<WeakCallbackInfo<T>, void> const&
|
||||
# define NAN_WEAK_PARAMETER_CALLBACK_SIG_ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
# define NAN_WEAK_TWOFIELD_CALLBACK_SIG_ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
|
||||
#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
# define NAN_WEAK_CALLBACK_DATA_TYPE_ \
|
||||
v8::WeakCallbackData<S, WeakCallbackInfo<T> > const&
|
||||
# define NAN_WEAK_CALLBACK_SIG_ NAN_WEAK_CALLBACK_DATA_TYPE_
|
||||
#else
|
||||
# define NAN_WEAK_CALLBACK_DATA_TYPE_ void *
|
||||
# define NAN_WEAK_CALLBACK_SIG_ \
|
||||
v8::Persistent<v8::Value>, NAN_WEAK_CALLBACK_DATA_TYPE_
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
class WeakCallbackInfo {
|
||||
public:
|
||||
typedef void (*Callback)(const WeakCallbackInfo<T>& data);
|
||||
WeakCallbackInfo(
|
||||
Persistent<v8::Value> *persistent
|
||||
, Callback callback
|
||||
, void *parameter
|
||||
, void *field1 = 0
|
||||
, void *field2 = 0) :
|
||||
callback_(callback), isolate_(0), parameter_(parameter) {
|
||||
std::memcpy(&persistent_, persistent, sizeof (v8::Persistent<v8::Value>));
|
||||
internal_fields_[0] = field1;
|
||||
internal_fields_[1] = field2;
|
||||
}
|
||||
inline v8::Isolate *GetIsolate() const { return isolate_; }
|
||||
inline T *GetParameter() const { return static_cast<T*>(parameter_); }
|
||||
inline void *GetInternalField(int index) const {
|
||||
assert((index == 0 || index == 1) && "internal field index out of bounds");
|
||||
if (index == 0) {
|
||||
return internal_fields_[0];
|
||||
} else {
|
||||
return internal_fields_[1];
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(WeakCallbackInfo)
|
||||
Callback callback_;
|
||||
v8::Isolate *isolate_;
|
||||
void *parameter_;
|
||||
void *internal_fields_[kInternalFieldsInWeakCallback];
|
||||
v8::Persistent<v8::Value> persistent_;
|
||||
template<typename S, typename M> friend class Persistent;
|
||||
template<typename S> friend class PersistentBase;
|
||||
#if NODE_MODULE_VERSION <= NODE_0_12_MODULE_VERSION
|
||||
# if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
template<typename S>
|
||||
static void invoke(NAN_WEAK_CALLBACK_SIG_ data);
|
||||
template<typename S>
|
||||
static WeakCallbackInfo *unwrap(NAN_WEAK_CALLBACK_DATA_TYPE_ data);
|
||||
# else
|
||||
static void invoke(NAN_WEAK_CALLBACK_SIG_ data);
|
||||
static WeakCallbackInfo *unwrap(NAN_WEAK_CALLBACK_DATA_TYPE_ data);
|
||||
# endif
|
||||
#else
|
||||
# if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
template<bool isFirstPass>
|
||||
static void invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data);
|
||||
template<bool isFirstPass>
|
||||
static void invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data);
|
||||
# else
|
||||
static void invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data);
|
||||
static void invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data);
|
||||
# endif
|
||||
static WeakCallbackInfo *unwrapparameter(
|
||||
NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ data);
|
||||
static WeakCallbackInfo *unwraptwofield(
|
||||
NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ data);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
|
||||
template<typename T>
|
||||
template<bool isFirstPass>
|
||||
void
|
||||
WeakCallbackInfo<T>::invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo = unwrapparameter(data);
|
||||
if (isFirstPass) {
|
||||
cbinfo->persistent_.Reset();
|
||||
data.SetSecondPassCallback(invokeparameter<false>);
|
||||
} else {
|
||||
cbinfo->callback_(*cbinfo);
|
||||
delete cbinfo;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<bool isFirstPass>
|
||||
void
|
||||
WeakCallbackInfo<T>::invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo = unwraptwofield(data);
|
||||
if (isFirstPass) {
|
||||
cbinfo->persistent_.Reset();
|
||||
data.SetSecondPassCallback(invoketwofield<false>);
|
||||
} else {
|
||||
cbinfo->callback_(*cbinfo);
|
||||
delete cbinfo;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwrapparameter(
|
||||
NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo =
|
||||
static_cast<WeakCallbackInfo<T>*>(data.GetParameter());
|
||||
cbinfo->isolate_ = data.GetIsolate();
|
||||
return cbinfo;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwraptwofield(
|
||||
NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo =
|
||||
static_cast<WeakCallbackInfo<T>*>(data.GetInternalField(0));
|
||||
cbinfo->isolate_ = data.GetIsolate();
|
||||
return cbinfo;
|
||||
}
|
||||
|
||||
#undef NAN_WEAK_PARAMETER_CALLBACK_SIG_
|
||||
#undef NAN_WEAK_TWOFIELD_CALLBACK_SIG_
|
||||
#undef NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
#undef NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
|
||||
# elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
|
||||
|
||||
template<typename T>
|
||||
void
|
||||
WeakCallbackInfo<T>::invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo = unwrapparameter(data);
|
||||
cbinfo->persistent_.Reset();
|
||||
cbinfo->callback_(*cbinfo);
|
||||
delete cbinfo;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void
|
||||
WeakCallbackInfo<T>::invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo = unwraptwofield(data);
|
||||
cbinfo->persistent_.Reset();
|
||||
cbinfo->callback_(*cbinfo);
|
||||
delete cbinfo;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwrapparameter(
|
||||
NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo =
|
||||
static_cast<WeakCallbackInfo<T>*>(data.GetParameter());
|
||||
cbinfo->isolate_ = data.GetIsolate();
|
||||
return cbinfo;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwraptwofield(
|
||||
NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo =
|
||||
static_cast<WeakCallbackInfo<T>*>(data.GetInternalField1());
|
||||
cbinfo->isolate_ = data.GetIsolate();
|
||||
return cbinfo;
|
||||
}
|
||||
|
||||
#undef NAN_WEAK_PARAMETER_CALLBACK_SIG_
|
||||
#undef NAN_WEAK_TWOFIELD_CALLBACK_SIG_
|
||||
#undef NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
#undef NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
|
||||
#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
|
||||
template<typename T>
|
||||
template<typename S>
|
||||
void WeakCallbackInfo<T>::invoke(NAN_WEAK_CALLBACK_SIG_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo = unwrap(data);
|
||||
cbinfo->persistent_.Reset();
|
||||
cbinfo->callback_(*cbinfo);
|
||||
delete cbinfo;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename S>
|
||||
WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwrap(
|
||||
NAN_WEAK_CALLBACK_DATA_TYPE_ data) {
|
||||
void *parameter = data.GetParameter();
|
||||
WeakCallbackInfo<T> *cbinfo =
|
||||
static_cast<WeakCallbackInfo<T>*>(parameter);
|
||||
cbinfo->isolate_ = data.GetIsolate();
|
||||
return cbinfo;
|
||||
}
|
||||
|
||||
#undef NAN_WEAK_CALLBACK_SIG_
|
||||
#undef NAN_WEAK_CALLBACK_DATA_TYPE_
|
||||
#else
|
||||
|
||||
template<typename T>
|
||||
void WeakCallbackInfo<T>::invoke(NAN_WEAK_CALLBACK_SIG_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo = unwrap(data);
|
||||
cbinfo->persistent_.Dispose();
|
||||
cbinfo->persistent_.Clear();
|
||||
cbinfo->callback_(*cbinfo);
|
||||
delete cbinfo;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwrap(
|
||||
NAN_WEAK_CALLBACK_DATA_TYPE_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo =
|
||||
static_cast<WeakCallbackInfo<T>*>(data);
|
||||
cbinfo->isolate_ = v8::Isolate::GetCurrent();
|
||||
return cbinfo;
|
||||
}
|
||||
|
||||
#undef NAN_WEAK_CALLBACK_SIG_
|
||||
#undef NAN_WEAK_CALLBACK_DATA_TYPE_
|
||||
#endif
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
template<typename T, typename M>
|
||||
template<typename P>
|
||||
inline void Persistent<T, M>::SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
WeakCallbackInfo<P> *wcbd;
|
||||
if (type == WeakCallbackType::kParameter) {
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, parameter);
|
||||
v8::PersistentBase<T>::SetWeak(
|
||||
wcbd
|
||||
, WeakCallbackInfo<P>::template invokeparameter<true>
|
||||
, type);
|
||||
} else {
|
||||
v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
|
||||
assert((*self_v)->IsObject());
|
||||
v8::Local<v8::Object> self((*self_v).As<v8::Object>());
|
||||
int count = self->InternalFieldCount();
|
||||
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
|
||||
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
|
||||
#if (V8_MAJOR_VERSION > 14) || \
|
||||
(V8_MAJOR_VERSION == 14 && V8_MINOR_VERSION > 2) || \
|
||||
(V8_MAJOR_VERSION == 14 && V8_MINOR_VERSION == 2 && V8_BUILD_NUMBER >= 194)
|
||||
internal_fields[i] = self->GetAlignedPointerFromInternalField(
|
||||
i, v8::kEmbedderDataTypeTagDefault
|
||||
);
|
||||
# else
|
||||
internal_fields[i] = self->GetAlignedPointerFromInternalField(i);
|
||||
# endif
|
||||
}
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, 0
|
||||
, internal_fields[0]
|
||||
, internal_fields[1]);
|
||||
#if (V8_MAJOR_VERSION > 14) || \
|
||||
(V8_MAJOR_VERSION == 14 && V8_MINOR_VERSION > 2) || \
|
||||
(V8_MAJOR_VERSION == 14 && V8_MINOR_VERSION == 2 && V8_BUILD_NUMBER >= 194)
|
||||
self->SetAlignedPointerInInternalField(
|
||||
0, wcbd, v8::kEmbedderDataTypeTagDefault
|
||||
);
|
||||
# else
|
||||
self->SetAlignedPointerInInternalField(0, wcbd);
|
||||
# endif
|
||||
v8::PersistentBase<T>::SetWeak(
|
||||
static_cast<WeakCallbackInfo<P>*>(0)
|
||||
, WeakCallbackInfo<P>::template invoketwofield<true>
|
||||
, type);
|
||||
}
|
||||
}
|
||||
#elif NODE_MODULE_VERSION > IOJS_1_1_MODULE_VERSION
|
||||
template<typename T, typename M>
|
||||
template<typename P>
|
||||
inline void Persistent<T, M>::SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
WeakCallbackInfo<P> *wcbd;
|
||||
if (type == WeakCallbackType::kParameter) {
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, parameter);
|
||||
v8::PersistentBase<T>::SetPhantom(
|
||||
wcbd
|
||||
, WeakCallbackInfo<P>::invokeparameter);
|
||||
} else {
|
||||
v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
|
||||
assert((*self_v)->IsObject());
|
||||
v8::Local<v8::Object> self((*self_v).As<v8::Object>());
|
||||
int count = self->InternalFieldCount();
|
||||
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
|
||||
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
|
||||
internal_fields[i] = self->GetAlignedPointerFromInternalField(i);
|
||||
}
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, 0
|
||||
, internal_fields[0]
|
||||
, internal_fields[1]);
|
||||
self->SetAlignedPointerInInternalField(0, wcbd);
|
||||
v8::PersistentBase<T>::SetPhantom(
|
||||
static_cast<WeakCallbackInfo<P>*>(0)
|
||||
, WeakCallbackInfo<P>::invoketwofield
|
||||
, 0
|
||||
, count > 1 ? 1 : kNoInternalFieldIndex);
|
||||
}
|
||||
}
|
||||
#elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
|
||||
template<typename T, typename M>
|
||||
template<typename P>
|
||||
inline void Persistent<T, M>::SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
WeakCallbackInfo<P> *wcbd;
|
||||
if (type == WeakCallbackType::kParameter) {
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, parameter);
|
||||
v8::PersistentBase<T>::SetPhantom(
|
||||
wcbd
|
||||
, WeakCallbackInfo<P>::invokeparameter);
|
||||
} else {
|
||||
v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
|
||||
assert((*self_v)->IsObject());
|
||||
v8::Local<v8::Object> self((*self_v).As<v8::Object>());
|
||||
int count = self->InternalFieldCount();
|
||||
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
|
||||
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
|
||||
internal_fields[i] = self->GetAlignedPointerFromInternalField(i);
|
||||
}
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, 0
|
||||
, internal_fields[0]
|
||||
, internal_fields[1]);
|
||||
self->SetAlignedPointerInInternalField(0, wcbd);
|
||||
v8::PersistentBase<T>::SetPhantom(
|
||||
WeakCallbackInfo<P>::invoketwofield
|
||||
, 0
|
||||
, count > 1 ? 1 : kNoInternalFieldIndex);
|
||||
}
|
||||
}
|
||||
#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
template<typename T, typename M>
|
||||
template<typename P>
|
||||
inline void Persistent<T, M>::SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
WeakCallbackInfo<P> *wcbd;
|
||||
if (type == WeakCallbackType::kParameter) {
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, parameter);
|
||||
v8::PersistentBase<T>::SetWeak(wcbd, WeakCallbackInfo<P>::invoke);
|
||||
} else {
|
||||
v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
|
||||
assert((*self_v)->IsObject());
|
||||
v8::Local<v8::Object> self((*self_v).As<v8::Object>());
|
||||
int count = self->InternalFieldCount();
|
||||
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
|
||||
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
|
||||
internal_fields[i] = self->GetAlignedPointerFromInternalField(i);
|
||||
}
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, 0
|
||||
, internal_fields[0]
|
||||
, internal_fields[1]);
|
||||
v8::PersistentBase<T>::SetWeak(wcbd, WeakCallbackInfo<P>::invoke);
|
||||
}
|
||||
}
|
||||
#else
|
||||
template<typename T>
|
||||
template<typename P>
|
||||
inline void PersistentBase<T>::SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
WeakCallbackInfo<P> *wcbd;
|
||||
if (type == WeakCallbackType::kParameter) {
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, parameter);
|
||||
persistent.MakeWeak(wcbd, WeakCallbackInfo<P>::invoke);
|
||||
} else {
|
||||
v8::Local<v8::Value>* self_v(reinterpret_cast<v8::Local<v8::Value>*>(this));
|
||||
assert((*self_v)->IsObject());
|
||||
v8::Local<v8::Object> self((*self_v).As<v8::Object>());
|
||||
int count = self->InternalFieldCount();
|
||||
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
|
||||
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
|
||||
internal_fields[i] = self->GetPointerFromInternalField(i);
|
||||
}
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, 0
|
||||
, internal_fields[0]
|
||||
, internal_fields[1]);
|
||||
persistent.MakeWeak(wcbd, WeakCallbackInfo<P>::invoke);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NAN_WEAK_H_
|
||||
38
tasks/enduro-trails/prototype/node_modules/nan/package.json
generated
vendored
Normal file
38
tasks/enduro-trails/prototype/node_modules/nan/package.json
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "nan",
|
||||
"version": "2.26.2",
|
||||
"description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 25 compatibility",
|
||||
"main": "include_dirs.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/nodejs/nan.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap --gc --stderr test/js/*-test.js",
|
||||
"test:worker": "node --experimental-worker test/tap-as-worker.js --gc --stderr test/js/*-test.js",
|
||||
"rebuild-tests-2015": "node-gyp rebuild --msvs_version=2015 --directory test",
|
||||
"rebuild-tests": "node-gyp rebuild --directory test",
|
||||
"docs": "doc/.build.sh"
|
||||
},
|
||||
"contributors": [
|
||||
"Rod Vagg <r@va.gg> (https://github.com/rvagg)",
|
||||
"Benjamin Byholm <bbyholm@abo.fi> (https://github.com/kkoopa/)",
|
||||
"Trevor Norris <trev.norris@gmail.com> (https://github.com/trevnorris)",
|
||||
"Nathan Rajlich <nathan@tootallnate.net> (https://github.com/TooTallNate)",
|
||||
"Brett Lawson <brett19@gmail.com> (https://github.com/brett19)",
|
||||
"Ben Noordhuis <info@bnoordhuis.nl> (https://github.com/bnoordhuis)",
|
||||
"David Siegel <david@artcom.de> (https://github.com/agnat)",
|
||||
"Michael Ira Krufky <mkrufky@gmail.com> (https://github.com/mkrufky)"
|
||||
],
|
||||
"devDependencies": {
|
||||
"bindings": "~1.2.1",
|
||||
"commander": "^2.8.1",
|
||||
"glob": "^5.0.14",
|
||||
"request": "=2.81.0",
|
||||
"node-gyp": "~12.1.0",
|
||||
"readable-stream": "^2.1.4",
|
||||
"tap": "~0.7.1",
|
||||
"xtend": "~4.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
412
tasks/enduro-trails/prototype/node_modules/nan/tools/1to2.js
generated
vendored
Executable file
412
tasks/enduro-trails/prototype/node_modules/nan/tools/1to2.js
generated
vendored
Executable file
@@ -0,0 +1,412 @@
|
||||
#!/usr/bin/env node
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
var commander = require('commander'),
|
||||
fs = require('fs'),
|
||||
glob = require('glob'),
|
||||
groups = [],
|
||||
total = 0,
|
||||
warning1 = '/* ERROR: Rewrite using Buffer */\n',
|
||||
warning2 = '\\/\\* ERROR\\: Rewrite using Buffer \\*\\/\\n',
|
||||
length,
|
||||
i;
|
||||
|
||||
fs.readFile(__dirname + '/package.json', 'utf8', function (err, data) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
commander
|
||||
.version(JSON.parse(data).version)
|
||||
.usage('[options] <file ...>')
|
||||
.parse(process.argv);
|
||||
|
||||
if (!process.argv.slice(2).length) {
|
||||
commander.outputHelp();
|
||||
}
|
||||
});
|
||||
|
||||
/* construct strings representing regular expressions
|
||||
each expression contains a unique group allowing for identification of the match
|
||||
the index of this key group, relative to the regular expression in question,
|
||||
is indicated by the first array member */
|
||||
|
||||
/* simple substistutions, key group is the entire match, 0 */
|
||||
groups.push([0, [
|
||||
'_NAN_',
|
||||
'NODE_SET_METHOD',
|
||||
'NODE_SET_PROTOTYPE_METHOD',
|
||||
'NanAsciiString',
|
||||
'NanEscapeScope',
|
||||
'NanReturnValue',
|
||||
'NanUcs2String'].join('|')]);
|
||||
|
||||
/* substitutions of parameterless macros, key group is 1 */
|
||||
groups.push([1, ['(', [
|
||||
'NanEscapableScope',
|
||||
'NanReturnNull',
|
||||
'NanReturnUndefined',
|
||||
'NanScope'].join('|'), ')\\(\\)'].join('')]);
|
||||
|
||||
/* replace TryCatch with NanTryCatch once, gobbling possible namespace, key group 2 */
|
||||
groups.push([2, '(?:(?:v8\\:\\:)?|(Nan)?)(TryCatch)']);
|
||||
|
||||
/* NanNew("string") will likely not fail a ToLocalChecked(), key group 1 */
|
||||
groups.push([1, ['(NanNew)', '(\\("[^\\"]*"[^\\)]*\\))(?!\\.ToLocalChecked\\(\\))'].join('')]);
|
||||
|
||||
/* Removed v8 APIs, warn that the code needs rewriting using node::Buffer, key group 2 */
|
||||
groups.push([2, ['(', warning2, ')?', '^.*?(', [
|
||||
'GetIndexedPropertiesExternalArrayDataLength',
|
||||
'GetIndexedPropertiesExternalArrayData',
|
||||
'GetIndexedPropertiesExternalArrayDataType',
|
||||
'GetIndexedPropertiesPixelData',
|
||||
'GetIndexedPropertiesPixelDataLength',
|
||||
'HasIndexedPropertiesInExternalArrayData',
|
||||
'HasIndexedPropertiesInPixelData',
|
||||
'SetIndexedPropertiesToExternalArrayData',
|
||||
'SetIndexedPropertiesToPixelData'].join('|'), ')'].join('')]);
|
||||
|
||||
/* No need for NanScope in V8-exposed methods, key group 2 */
|
||||
groups.push([2, ['((', [
|
||||
'NAN_METHOD',
|
||||
'NAN_GETTER',
|
||||
'NAN_SETTER',
|
||||
'NAN_PROPERTY_GETTER',
|
||||
'NAN_PROPERTY_SETTER',
|
||||
'NAN_PROPERTY_ENUMERATOR',
|
||||
'NAN_PROPERTY_DELETER',
|
||||
'NAN_PROPERTY_QUERY',
|
||||
'NAN_INDEX_GETTER',
|
||||
'NAN_INDEX_SETTER',
|
||||
'NAN_INDEX_ENUMERATOR',
|
||||
'NAN_INDEX_DELETER',
|
||||
'NAN_INDEX_QUERY'].join('|'), ')\\([^\\)]*\\)\\s*\\{)\\s*NanScope\\(\\)\\s*;'].join('')]);
|
||||
|
||||
/* v8::Value::ToXXXXXXX returns v8::MaybeLocal<T>, key group 3 */
|
||||
groups.push([3, ['([\\s\\(\\)])([^\\s\\(\\)]+)->(', [
|
||||
'Boolean',
|
||||
'Number',
|
||||
'String',
|
||||
'Object',
|
||||
'Integer',
|
||||
'Uint32',
|
||||
'Int32'].join('|'), ')\\('].join('')]);
|
||||
|
||||
/* v8::Value::XXXXXXXValue returns v8::Maybe<T>, key group 3 */
|
||||
groups.push([3, ['([\\s\\(\\)])([^\\s\\(\\)]+)->((?:', [
|
||||
'Boolean',
|
||||
'Number',
|
||||
'Integer',
|
||||
'Uint32',
|
||||
'Int32'].join('|'), ')Value)\\('].join('')]);
|
||||
|
||||
/* NAN_WEAK_CALLBACK macro was removed, write out callback definition, key group 1 */
|
||||
groups.push([1, '(NAN_WEAK_CALLBACK)\\(([^\\s\\)]+)\\)']);
|
||||
|
||||
/* node::ObjectWrap and v8::Persistent have been replaced with Nan implementations, key group 1 */
|
||||
groups.push([1, ['(', [
|
||||
'NanDisposePersistent',
|
||||
'NanObjectWrapHandle'].join('|'), ')\\s*\\(\\s*([^\\s\\)]+)'].join('')]);
|
||||
|
||||
/* Since NanPersistent there is no need for NanMakeWeakPersistent, key group 1 */
|
||||
groups.push([1, '(NanMakeWeakPersistent)\\s*\\(\\s*([^\\s,]+)\\s*,\\s*']);
|
||||
|
||||
/* Many methods of v8::Object and others now return v8::MaybeLocal<T>, key group 3 */
|
||||
groups.push([3, ['([\\s])([^\\s]+)->(', [
|
||||
'GetEndColumn',
|
||||
'GetFunction',
|
||||
'GetLineNumber',
|
||||
'NewInstance',
|
||||
'GetPropertyNames',
|
||||
'GetOwnPropertyNames',
|
||||
'GetSourceLine',
|
||||
'GetStartColumn',
|
||||
'ObjectProtoToString',
|
||||
'ToArrayIndex',
|
||||
'ToDetailString',
|
||||
'CallAsConstructor',
|
||||
'CallAsFunction',
|
||||
'CloneElementAt',
|
||||
'Delete',
|
||||
'ForceSet',
|
||||
'Get',
|
||||
'GetPropertyAttributes',
|
||||
'GetRealNamedProperty',
|
||||
'GetRealNamedPropertyInPrototypeChain',
|
||||
'Has',
|
||||
'HasOwnProperty',
|
||||
'HasRealIndexedProperty',
|
||||
'HasRealNamedCallbackProperty',
|
||||
'HasRealNamedProperty',
|
||||
'Set',
|
||||
'SetAccessor',
|
||||
'SetIndexedPropertyHandler',
|
||||
'SetNamedPropertyHandler',
|
||||
'SetPrototype'].join('|'), ')\\('].join('')]);
|
||||
|
||||
/* You should get an error if any of these fail anyways,
|
||||
or handle the error better, it is indicated either way, key group 2 */
|
||||
groups.push([2, ['NanNew(<(?:v8\\:\\:)?(', ['Date', 'String', 'RegExp'].join('|'), ')>)(\\([^\\)]*\\))(?!\\.ToLocalChecked\\(\\))'].join('')]);
|
||||
|
||||
/* v8::Value::Equals now returns a v8::Maybe, key group 3 */
|
||||
groups.push([3, '([\\s\\(\\)])([^\\s\\(\\)]+)->(Equals)\\(([^\\s\\)]+)']);
|
||||
|
||||
/* NanPersistent makes this unnecessary, key group 1 */
|
||||
groups.push([1, '(NanAssignPersistent)(?:<v8\\:\\:[^>]+>)?\\(([^,]+),\\s*']);
|
||||
|
||||
/* args has been renamed to info, key group 2 */
|
||||
groups.push([2, '(\\W)(args)(\\W)'])
|
||||
|
||||
/* node::ObjectWrap was replaced with NanObjectWrap, key group 2 */
|
||||
groups.push([2, '(\\W)(?:node\\:\\:)?(ObjectWrap)(\\W)']);
|
||||
|
||||
/* v8::Persistent was replaced with NanPersistent, key group 2 */
|
||||
groups.push([2, '(\\W)(?:v8\\:\\:)?(Persistent)(\\W)']);
|
||||
|
||||
/* counts the number of capturing groups in a well-formed regular expression,
|
||||
ignoring non-capturing groups and escaped parentheses */
|
||||
function groupcount(s) {
|
||||
var positive = s.match(/\((?!\?)/g),
|
||||
negative = s.match(/\\\(/g);
|
||||
return (positive ? positive.length : 0) - (negative ? negative.length : 0);
|
||||
}
|
||||
|
||||
/* compute the absolute position of each key group in the joined master RegExp */
|
||||
for (i = 1, length = groups.length; i < length; i++) {
|
||||
total += groupcount(groups[i - 1][1]);
|
||||
groups[i][0] += total;
|
||||
}
|
||||
|
||||
/* create the master RegExp, which is the union of all the groups' expressions */
|
||||
master = new RegExp(groups.map(function (a) { return a[1]; }).join('|'), 'gm');
|
||||
|
||||
/* replacement function for String.replace, receives 21 arguments */
|
||||
function replace() {
|
||||
/* simple expressions */
|
||||
switch (arguments[groups[0][0]]) {
|
||||
case '_NAN_':
|
||||
return 'NAN_';
|
||||
case 'NODE_SET_METHOD':
|
||||
return 'NanSetMethod';
|
||||
case 'NODE_SET_PROTOTYPE_METHOD':
|
||||
return 'NanSetPrototypeMethod';
|
||||
case 'NanAsciiString':
|
||||
return 'NanUtf8String';
|
||||
case 'NanEscapeScope':
|
||||
return 'scope.Escape';
|
||||
case 'NanReturnNull':
|
||||
return 'info.GetReturnValue().SetNull';
|
||||
case 'NanReturnValue':
|
||||
return 'info.GetReturnValue().Set';
|
||||
case 'NanUcs2String':
|
||||
return 'v8::String::Value';
|
||||
default:
|
||||
}
|
||||
|
||||
/* macros without arguments */
|
||||
switch (arguments[groups[1][0]]) {
|
||||
case 'NanEscapableScope':
|
||||
return 'NanEscapableScope scope'
|
||||
case 'NanReturnUndefined':
|
||||
return 'return';
|
||||
case 'NanScope':
|
||||
return 'NanScope scope';
|
||||
default:
|
||||
}
|
||||
|
||||
/* TryCatch, emulate negative backref */
|
||||
if (arguments[groups[2][0]] === 'TryCatch') {
|
||||
return arguments[groups[2][0] - 1] ? arguments[0] : 'NanTryCatch';
|
||||
}
|
||||
|
||||
/* NanNew("foo") --> NanNew("foo").ToLocalChecked() */
|
||||
if (arguments[groups[3][0]] === 'NanNew') {
|
||||
return [arguments[0], '.ToLocalChecked()'].join('');
|
||||
}
|
||||
|
||||
/* insert warning for removed functions as comment on new line above */
|
||||
switch (arguments[groups[4][0]]) {
|
||||
case 'GetIndexedPropertiesExternalArrayData':
|
||||
case 'GetIndexedPropertiesExternalArrayDataLength':
|
||||
case 'GetIndexedPropertiesExternalArrayDataType':
|
||||
case 'GetIndexedPropertiesPixelData':
|
||||
case 'GetIndexedPropertiesPixelDataLength':
|
||||
case 'HasIndexedPropertiesInExternalArrayData':
|
||||
case 'HasIndexedPropertiesInPixelData':
|
||||
case 'SetIndexedPropertiesToExternalArrayData':
|
||||
case 'SetIndexedPropertiesToPixelData':
|
||||
return arguments[groups[4][0] - 1] ? arguments[0] : [warning1, arguments[0]].join('');
|
||||
default:
|
||||
}
|
||||
|
||||
/* remove unnecessary NanScope() */
|
||||
switch (arguments[groups[5][0]]) {
|
||||
case 'NAN_GETTER':
|
||||
case 'NAN_METHOD':
|
||||
case 'NAN_SETTER':
|
||||
case 'NAN_INDEX_DELETER':
|
||||
case 'NAN_INDEX_ENUMERATOR':
|
||||
case 'NAN_INDEX_GETTER':
|
||||
case 'NAN_INDEX_QUERY':
|
||||
case 'NAN_INDEX_SETTER':
|
||||
case 'NAN_PROPERTY_DELETER':
|
||||
case 'NAN_PROPERTY_ENUMERATOR':
|
||||
case 'NAN_PROPERTY_GETTER':
|
||||
case 'NAN_PROPERTY_QUERY':
|
||||
case 'NAN_PROPERTY_SETTER':
|
||||
return arguments[groups[5][0] - 1];
|
||||
default:
|
||||
}
|
||||
|
||||
/* Value conversion */
|
||||
switch (arguments[groups[6][0]]) {
|
||||
case 'Boolean':
|
||||
case 'Int32':
|
||||
case 'Integer':
|
||||
case 'Number':
|
||||
case 'Object':
|
||||
case 'String':
|
||||
case 'Uint32':
|
||||
return [arguments[groups[6][0] - 2], 'NanTo<v8::', arguments[groups[6][0]], '>(', arguments[groups[6][0] - 1]].join('');
|
||||
default:
|
||||
}
|
||||
|
||||
/* other value conversion */
|
||||
switch (arguments[groups[7][0]]) {
|
||||
case 'BooleanValue':
|
||||
return [arguments[groups[7][0] - 2], 'NanTo<bool>(', arguments[groups[7][0] - 1]].join('');
|
||||
case 'Int32Value':
|
||||
return [arguments[groups[7][0] - 2], 'NanTo<int32_t>(', arguments[groups[7][0] - 1]].join('');
|
||||
case 'IntegerValue':
|
||||
return [arguments[groups[7][0] - 2], 'NanTo<int64_t>(', arguments[groups[7][0] - 1]].join('');
|
||||
case 'Uint32Value':
|
||||
return [arguments[groups[7][0] - 2], 'NanTo<uint32_t>(', arguments[groups[7][0] - 1]].join('');
|
||||
default:
|
||||
}
|
||||
|
||||
/* NAN_WEAK_CALLBACK */
|
||||
if (arguments[groups[8][0]] === 'NAN_WEAK_CALLBACK') {
|
||||
return ['template<typename T>\nvoid ',
|
||||
arguments[groups[8][0] + 1], '(const NanWeakCallbackInfo<T> &data)'].join('');
|
||||
}
|
||||
|
||||
/* use methods on NAN classes instead */
|
||||
switch (arguments[groups[9][0]]) {
|
||||
case 'NanDisposePersistent':
|
||||
return [arguments[groups[9][0] + 1], '.Reset('].join('');
|
||||
case 'NanObjectWrapHandle':
|
||||
return [arguments[groups[9][0] + 1], '->handle('].join('');
|
||||
default:
|
||||
}
|
||||
|
||||
/* use method on NanPersistent instead */
|
||||
if (arguments[groups[10][0]] === 'NanMakeWeakPersistent') {
|
||||
return arguments[groups[10][0] + 1] + '.SetWeak(';
|
||||
}
|
||||
|
||||
/* These return Maybes, the upper ones take no arguments */
|
||||
switch (arguments[groups[11][0]]) {
|
||||
case 'GetEndColumn':
|
||||
case 'GetFunction':
|
||||
case 'GetLineNumber':
|
||||
case 'GetOwnPropertyNames':
|
||||
case 'GetPropertyNames':
|
||||
case 'GetSourceLine':
|
||||
case 'GetStartColumn':
|
||||
case 'NewInstance':
|
||||
case 'ObjectProtoToString':
|
||||
case 'ToArrayIndex':
|
||||
case 'ToDetailString':
|
||||
return [arguments[groups[11][0] - 2], 'Nan', arguments[groups[11][0]], '(', arguments[groups[11][0] - 1]].join('');
|
||||
case 'CallAsConstructor':
|
||||
case 'CallAsFunction':
|
||||
case 'CloneElementAt':
|
||||
case 'Delete':
|
||||
case 'ForceSet':
|
||||
case 'Get':
|
||||
case 'GetPropertyAttributes':
|
||||
case 'GetRealNamedProperty':
|
||||
case 'GetRealNamedPropertyInPrototypeChain':
|
||||
case 'Has':
|
||||
case 'HasOwnProperty':
|
||||
case 'HasRealIndexedProperty':
|
||||
case 'HasRealNamedCallbackProperty':
|
||||
case 'HasRealNamedProperty':
|
||||
case 'Set':
|
||||
case 'SetAccessor':
|
||||
case 'SetIndexedPropertyHandler':
|
||||
case 'SetNamedPropertyHandler':
|
||||
case 'SetPrototype':
|
||||
return [arguments[groups[11][0] - 2], 'Nan', arguments[groups[11][0]], '(', arguments[groups[11][0] - 1], ', '].join('');
|
||||
default:
|
||||
}
|
||||
|
||||
/* Automatic ToLocalChecked(), take it or leave it */
|
||||
switch (arguments[groups[12][0]]) {
|
||||
case 'Date':
|
||||
case 'String':
|
||||
case 'RegExp':
|
||||
return ['NanNew', arguments[groups[12][0] - 1], arguments[groups[12][0] + 1], '.ToLocalChecked()'].join('');
|
||||
default:
|
||||
}
|
||||
|
||||
/* NanEquals is now required for uniformity */
|
||||
if (arguments[groups[13][0]] === 'Equals') {
|
||||
return [arguments[groups[13][0] - 1], 'NanEquals(', arguments[groups[13][0] - 1], ', ', arguments[groups[13][0] + 1]].join('');
|
||||
}
|
||||
|
||||
/* use method on replacement class instead */
|
||||
if (arguments[groups[14][0]] === 'NanAssignPersistent') {
|
||||
return [arguments[groups[14][0] + 1], '.Reset('].join('');
|
||||
}
|
||||
|
||||
/* args --> info */
|
||||
if (arguments[groups[15][0]] === 'args') {
|
||||
return [arguments[groups[15][0] - 1], 'info', arguments[groups[15][0] + 1]].join('');
|
||||
}
|
||||
|
||||
/* ObjectWrap --> NanObjectWrap */
|
||||
if (arguments[groups[16][0]] === 'ObjectWrap') {
|
||||
return [arguments[groups[16][0] - 1], 'NanObjectWrap', arguments[groups[16][0] + 1]].join('');
|
||||
}
|
||||
|
||||
/* Persistent --> NanPersistent */
|
||||
if (arguments[groups[17][0]] === 'Persistent') {
|
||||
return [arguments[groups[17][0] - 1], 'NanPersistent', arguments[groups[17][0] + 1]].join('');
|
||||
}
|
||||
|
||||
/* This should not happen. A switch is probably missing a case if it does. */
|
||||
throw 'Unhandled match: ' + arguments[0];
|
||||
}
|
||||
|
||||
/* reads a file, runs replacement and writes it back */
|
||||
function processFile(file) {
|
||||
fs.readFile(file, {encoding: 'utf8'}, function (err, data) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
/* run replacement twice, might need more runs */
|
||||
fs.writeFile(file, data.replace(master, replace).replace(master, replace), function (err) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* process file names from command line and process the identified files */
|
||||
for (i = 2, length = process.argv.length; i < length; i++) {
|
||||
glob(process.argv[i], function (err, matches) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
matches.forEach(processFile);
|
||||
});
|
||||
}
|
||||
14
tasks/enduro-trails/prototype/node_modules/nan/tools/README.md
generated
vendored
Normal file
14
tasks/enduro-trails/prototype/node_modules/nan/tools/README.md
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
1to2 naively converts source code files from NAN 1 to NAN 2. There will be erroneous conversions,
|
||||
false positives and missed opportunities. The input files are rewritten in place. Make sure that
|
||||
you have backups. You will have to manually review the changes afterwards and do some touchups.
|
||||
|
||||
```sh
|
||||
$ tools/1to2.js
|
||||
|
||||
Usage: 1to2 [options] <file ...>
|
||||
|
||||
Options:
|
||||
|
||||
-h, --help output usage information
|
||||
-V, --version output the version number
|
||||
```
|
||||
19
tasks/enduro-trails/prototype/node_modules/nan/tools/package.json
generated
vendored
Normal file
19
tasks/enduro-trails/prototype/node_modules/nan/tools/package.json
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "1to2",
|
||||
"version": "1.0.0",
|
||||
"description": "NAN 1 -> 2 Migration Script",
|
||||
"main": "1to2.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/nodejs/nan.git"
|
||||
},
|
||||
"contributors": [
|
||||
"Benjamin Byholm <bbyholm@abo.fi> (https://github.com/kkoopa/)",
|
||||
"Mathias Küsel (https://github.com/mathiask88/)"
|
||||
],
|
||||
"dependencies": {
|
||||
"glob": "~5.0.10",
|
||||
"commander": "~2.8.1"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
21
tasks/enduro-trails/prototype/node_modules/safer-buffer/LICENSE
generated
vendored
Normal file
21
tasks/enduro-trails/prototype/node_modules/safer-buffer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Nikita Skovoroda <chalkerx@gmail.com>
|
||||
|
||||
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.
|
||||
268
tasks/enduro-trails/prototype/node_modules/safer-buffer/Porting-Buffer.md
generated
vendored
Normal file
268
tasks/enduro-trails/prototype/node_modules/safer-buffer/Porting-Buffer.md
generated
vendored
Normal file
@@ -0,0 +1,268 @@
|
||||
# Porting to the Buffer.from/Buffer.alloc API
|
||||
|
||||
<a id="overview"></a>
|
||||
## Overview
|
||||
|
||||
- [Variant 1: Drop support for Node.js ≤ 4.4.x and 5.0.0 — 5.9.x.](#variant-1) (*recommended*)
|
||||
- [Variant 2: Use a polyfill](#variant-2)
|
||||
- [Variant 3: manual detection, with safeguards](#variant-3)
|
||||
|
||||
### Finding problematic bits of code using grep
|
||||
|
||||
Just run `grep -nrE '[^a-zA-Z](Slow)?Buffer\s*\(' --exclude-dir node_modules`.
|
||||
|
||||
It will find all the potentially unsafe places in your own code (with some considerably unlikely
|
||||
exceptions).
|
||||
|
||||
### Finding problematic bits of code using Node.js 8
|
||||
|
||||
If you’re using Node.js ≥ 8.0.0 (which is recommended), Node.js exposes multiple options that help with finding the relevant pieces of code:
|
||||
|
||||
- `--trace-warnings` will make Node.js show a stack trace for this warning and other warnings that are printed by Node.js.
|
||||
- `--trace-deprecation` does the same thing, but only for deprecation warnings.
|
||||
- `--pending-deprecation` will show more types of deprecation warnings. In particular, it will show the `Buffer()` deprecation warning, even on Node.js 8.
|
||||
|
||||
You can set these flags using an environment variable:
|
||||
|
||||
```console
|
||||
$ export NODE_OPTIONS='--trace-warnings --pending-deprecation'
|
||||
$ cat example.js
|
||||
'use strict';
|
||||
const foo = new Buffer('foo');
|
||||
$ node example.js
|
||||
(node:7147) [DEP0005] DeprecationWarning: The Buffer() and new Buffer() constructors are not recommended for use due to security and usability concerns. Please use the new Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() construction methods instead.
|
||||
at showFlaggedDeprecation (buffer.js:127:13)
|
||||
at new Buffer (buffer.js:148:3)
|
||||
at Object.<anonymous> (/path/to/example.js:2:13)
|
||||
[... more stack trace lines ...]
|
||||
```
|
||||
|
||||
### Finding problematic bits of code using linters
|
||||
|
||||
Eslint rules [no-buffer-constructor](https://eslint.org/docs/rules/no-buffer-constructor)
|
||||
or
|
||||
[node/no-deprecated-api](https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-deprecated-api.md)
|
||||
also find calls to deprecated `Buffer()` API. Those rules are included in some pre-sets.
|
||||
|
||||
There is a drawback, though, that it doesn't always
|
||||
[work correctly](https://github.com/chalker/safer-buffer#why-not-safe-buffer) when `Buffer` is
|
||||
overriden e.g. with a polyfill, so recommended is a combination of this and some other method
|
||||
described above.
|
||||
|
||||
<a id="variant-1"></a>
|
||||
## Variant 1: Drop support for Node.js ≤ 4.4.x and 5.0.0 — 5.9.x.
|
||||
|
||||
This is the recommended solution nowadays that would imply only minimal overhead.
|
||||
|
||||
The Node.js 5.x release line has been unsupported since July 2016, and the Node.js 4.x release line reaches its End of Life in April 2018 (→ [Schedule](https://github.com/nodejs/Release#release-schedule)). This means that these versions of Node.js will *not* receive any updates, even in case of security issues, so using these release lines should be avoided, if at all possible.
|
||||
|
||||
What you would do in this case is to convert all `new Buffer()` or `Buffer()` calls to use `Buffer.alloc()` or `Buffer.from()`, in the following way:
|
||||
|
||||
- For `new Buffer(number)`, replace it with `Buffer.alloc(number)`.
|
||||
- For `new Buffer(string)` (or `new Buffer(string, encoding)`), replace it with `Buffer.from(string)` (or `Buffer.from(string, encoding)`).
|
||||
- For all other combinations of arguments (these are much rarer), also replace `new Buffer(...arguments)` with `Buffer.from(...arguments)`.
|
||||
|
||||
Note that `Buffer.alloc()` is also _faster_ on the current Node.js versions than
|
||||
`new Buffer(size).fill(0)`, which is what you would otherwise need to ensure zero-filling.
|
||||
|
||||
Enabling eslint rule [no-buffer-constructor](https://eslint.org/docs/rules/no-buffer-constructor)
|
||||
or
|
||||
[node/no-deprecated-api](https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-deprecated-api.md)
|
||||
is recommended to avoid accidential unsafe Buffer API usage.
|
||||
|
||||
There is also a [JSCodeshift codemod](https://github.com/joyeecheung/node-dep-codemod#dep005)
|
||||
for automatically migrating Buffer constructors to `Buffer.alloc()` or `Buffer.from()`.
|
||||
Note that it currently only works with cases where the arguments are literals or where the
|
||||
constructor is invoked with two arguments.
|
||||
|
||||
_If you currently support those older Node.js versions and dropping them would be a semver-major change
|
||||
for you, or if you support older branches of your packages, consider using [Variant 2](#variant-2)
|
||||
or [Variant 3](#variant-3) on older branches, so people using those older branches will also receive
|
||||
the fix. That way, you will eradicate potential issues caused by unguarded Buffer API usage and
|
||||
your users will not observe a runtime deprecation warning when running your code on Node.js 10._
|
||||
|
||||
<a id="variant-2"></a>
|
||||
## Variant 2: Use a polyfill
|
||||
|
||||
Utilize [safer-buffer](https://www.npmjs.com/package/safer-buffer) as a polyfill to support older
|
||||
Node.js versions.
|
||||
|
||||
You would take exacly the same steps as in [Variant 1](#variant-1), but with a polyfill
|
||||
`const Buffer = require('safer-buffer').Buffer` in all files where you use the new `Buffer` api.
|
||||
|
||||
Make sure that you do not use old `new Buffer` API — in any files where the line above is added,
|
||||
using old `new Buffer()` API will _throw_. It will be easy to notice that in CI, though.
|
||||
|
||||
Alternatively, you could use [buffer-from](https://www.npmjs.com/package/buffer-from) and/or
|
||||
[buffer-alloc](https://www.npmjs.com/package/buffer-alloc) [ponyfills](https://ponyfill.com/) —
|
||||
those are great, the only downsides being 4 deps in the tree and slightly more code changes to
|
||||
migrate off them (as you would be using e.g. `Buffer.from` under a different name). If you need only
|
||||
`Buffer.from` polyfilled — `buffer-from` alone which comes with no extra dependencies.
|
||||
|
||||
_Alternatively, you could use [safe-buffer](https://www.npmjs.com/package/safe-buffer) — it also
|
||||
provides a polyfill, but takes a different approach which has
|
||||
[it's drawbacks](https://github.com/chalker/safer-buffer#why-not-safe-buffer). It will allow you
|
||||
to also use the older `new Buffer()` API in your code, though — but that's arguably a benefit, as
|
||||
it is problematic, can cause issues in your code, and will start emitting runtime deprecation
|
||||
warnings starting with Node.js 10._
|
||||
|
||||
Note that in either case, it is important that you also remove all calls to the old Buffer
|
||||
API manually — just throwing in `safe-buffer` doesn't fix the problem by itself, it just provides
|
||||
a polyfill for the new API. I have seen people doing that mistake.
|
||||
|
||||
Enabling eslint rule [no-buffer-constructor](https://eslint.org/docs/rules/no-buffer-constructor)
|
||||
or
|
||||
[node/no-deprecated-api](https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-deprecated-api.md)
|
||||
is recommended.
|
||||
|
||||
_Don't forget to drop the polyfill usage once you drop support for Node.js < 4.5.0._
|
||||
|
||||
<a id="variant-3"></a>
|
||||
## Variant 3 — manual detection, with safeguards
|
||||
|
||||
This is useful if you create Buffer instances in only a few places (e.g. one), or you have your own
|
||||
wrapper around them.
|
||||
|
||||
### Buffer(0)
|
||||
|
||||
This special case for creating empty buffers can be safely replaced with `Buffer.concat([])`, which
|
||||
returns the same result all the way down to Node.js 0.8.x.
|
||||
|
||||
### Buffer(notNumber)
|
||||
|
||||
Before:
|
||||
|
||||
```js
|
||||
var buf = new Buffer(notNumber, encoding);
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```js
|
||||
var buf;
|
||||
if (Buffer.from && Buffer.from !== Uint8Array.from) {
|
||||
buf = Buffer.from(notNumber, encoding);
|
||||
} else {
|
||||
if (typeof notNumber === 'number')
|
||||
throw new Error('The "size" argument must be of type number.');
|
||||
buf = new Buffer(notNumber, encoding);
|
||||
}
|
||||
```
|
||||
|
||||
`encoding` is optional.
|
||||
|
||||
Note that the `typeof notNumber` before `new Buffer` is required (for cases when `notNumber` argument is not
|
||||
hard-coded) and _is not caused by the deprecation of Buffer constructor_ — it's exactly _why_ the
|
||||
Buffer constructor is deprecated. Ecosystem packages lacking this type-check caused numereous
|
||||
security issues — situations when unsanitized user input could end up in the `Buffer(arg)` create
|
||||
problems ranging from DoS to leaking sensitive information to the attacker from the process memory.
|
||||
|
||||
When `notNumber` argument is hardcoded (e.g. literal `"abc"` or `[0,1,2]`), the `typeof` check can
|
||||
be omitted.
|
||||
|
||||
Also note that using TypeScript does not fix this problem for you — when libs written in
|
||||
`TypeScript` are used from JS, or when user input ends up there — it behaves exactly as pure JS, as
|
||||
all type checks are translation-time only and are not present in the actual JS code which TS
|
||||
compiles to.
|
||||
|
||||
### Buffer(number)
|
||||
|
||||
For Node.js 0.10.x (and below) support:
|
||||
|
||||
```js
|
||||
var buf;
|
||||
if (Buffer.alloc) {
|
||||
buf = Buffer.alloc(number);
|
||||
} else {
|
||||
buf = new Buffer(number);
|
||||
buf.fill(0);
|
||||
}
|
||||
```
|
||||
|
||||
Otherwise (Node.js ≥ 0.12.x):
|
||||
|
||||
```js
|
||||
const buf = Buffer.alloc ? Buffer.alloc(number) : new Buffer(number).fill(0);
|
||||
```
|
||||
|
||||
## Regarding Buffer.allocUnsafe
|
||||
|
||||
Be extra cautious when using `Buffer.allocUnsafe`:
|
||||
* Don't use it if you don't have a good reason to
|
||||
* e.g. you probably won't ever see a performance difference for small buffers, in fact, those
|
||||
might be even faster with `Buffer.alloc()`,
|
||||
* if your code is not in the hot code path — you also probably won't notice a difference,
|
||||
* keep in mind that zero-filling minimizes the potential risks.
|
||||
* If you use it, make sure that you never return the buffer in a partially-filled state,
|
||||
* if you are writing to it sequentially — always truncate it to the actuall written length
|
||||
|
||||
Errors in handling buffers allocated with `Buffer.allocUnsafe` could result in various issues,
|
||||
ranged from undefined behaviour of your code to sensitive data (user input, passwords, certs)
|
||||
leaking to the remote attacker.
|
||||
|
||||
_Note that the same applies to `new Buffer` usage without zero-filling, depending on the Node.js
|
||||
version (and lacking type checks also adds DoS to the list of potential problems)._
|
||||
|
||||
<a id="faq"></a>
|
||||
## FAQ
|
||||
|
||||
<a id="design-flaws"></a>
|
||||
### What is wrong with the `Buffer` constructor?
|
||||
|
||||
The `Buffer` constructor could be used to create a buffer in many different ways:
|
||||
|
||||
- `new Buffer(42)` creates a `Buffer` of 42 bytes. Before Node.js 8, this buffer contained
|
||||
*arbitrary memory* for performance reasons, which could include anything ranging from
|
||||
program source code to passwords and encryption keys.
|
||||
- `new Buffer('abc')` creates a `Buffer` that contains the UTF-8-encoded version of
|
||||
the string `'abc'`. A second argument could specify another encoding: For example,
|
||||
`new Buffer(string, 'base64')` could be used to convert a Base64 string into the original
|
||||
sequence of bytes that it represents.
|
||||
- There are several other combinations of arguments.
|
||||
|
||||
This meant that, in code like `var buffer = new Buffer(foo);`, *it is not possible to tell
|
||||
what exactly the contents of the generated buffer are* without knowing the type of `foo`.
|
||||
|
||||
Sometimes, the value of `foo` comes from an external source. For example, this function
|
||||
could be exposed as a service on a web server, converting a UTF-8 string into its Base64 form:
|
||||
|
||||
```
|
||||
function stringToBase64(req, res) {
|
||||
// The request body should have the format of `{ string: 'foobar' }`
|
||||
const rawBytes = new Buffer(req.body.string)
|
||||
const encoded = rawBytes.toString('base64')
|
||||
res.end({ encoded: encoded })
|
||||
}
|
||||
```
|
||||
|
||||
Note that this code does *not* validate the type of `req.body.string`:
|
||||
|
||||
- `req.body.string` is expected to be a string. If this is the case, all goes well.
|
||||
- `req.body.string` is controlled by the client that sends the request.
|
||||
- If `req.body.string` is the *number* `50`, the `rawBytes` would be 50 bytes:
|
||||
- Before Node.js 8, the content would be uninitialized
|
||||
- After Node.js 8, the content would be `50` bytes with the value `0`
|
||||
|
||||
Because of the missing type check, an attacker could intentionally send a number
|
||||
as part of the request. Using this, they can either:
|
||||
|
||||
- Read uninitialized memory. This **will** leak passwords, encryption keys and other
|
||||
kinds of sensitive information. (Information leak)
|
||||
- Force the program to allocate a large amount of memory. For example, when specifying
|
||||
`500000000` as the input value, each request will allocate 500MB of memory.
|
||||
This can be used to either exhaust the memory available of a program completely
|
||||
and make it crash, or slow it down significantly. (Denial of Service)
|
||||
|
||||
Both of these scenarios are considered serious security issues in a real-world
|
||||
web server context.
|
||||
|
||||
when using `Buffer.from(req.body.string)` instead, passing a number will always
|
||||
throw an exception instead, giving a controlled behaviour that can always be
|
||||
handled by the program.
|
||||
|
||||
<a id="ecosystem-usage"></a>
|
||||
### The `Buffer()` constructor has been deprecated for a while. Is this really an issue?
|
||||
|
||||
Surveys of code in the `npm` ecosystem have shown that the `Buffer()` constructor is still
|
||||
widely used. This includes new code, and overall usage of such code has actually been
|
||||
*increasing*.
|
||||
156
tasks/enduro-trails/prototype/node_modules/safer-buffer/Readme.md
generated
vendored
Normal file
156
tasks/enduro-trails/prototype/node_modules/safer-buffer/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
# safer-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![javascript style guide][standard-image]][standard-url] [![Security Responsible Disclosure][secuirty-image]][secuirty-url]
|
||||
|
||||
[travis-image]: https://travis-ci.org/ChALkeR/safer-buffer.svg?branch=master
|
||||
[travis-url]: https://travis-ci.org/ChALkeR/safer-buffer
|
||||
[npm-image]: https://img.shields.io/npm/v/safer-buffer.svg
|
||||
[npm-url]: https://npmjs.org/package/safer-buffer
|
||||
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
|
||||
[standard-url]: https://standardjs.com
|
||||
[secuirty-image]: https://img.shields.io/badge/Security-Responsible%20Disclosure-green.svg
|
||||
[secuirty-url]: https://github.com/nodejs/security-wg/blob/master/processes/responsible_disclosure_template.md
|
||||
|
||||
Modern Buffer API polyfill without footguns, working on Node.js from 0.8 to current.
|
||||
|
||||
## How to use?
|
||||
|
||||
First, port all `Buffer()` and `new Buffer()` calls to `Buffer.alloc()` and `Buffer.from()` API.
|
||||
|
||||
Then, to achieve compatibility with outdated Node.js versions (`<4.5.0` and 5.x `<5.9.0`), use
|
||||
`const Buffer = require('safer-buffer').Buffer` in all files where you make calls to the new
|
||||
Buffer API. _Use `var` instead of `const` if you need that for your Node.js version range support._
|
||||
|
||||
Also, see the
|
||||
[porting Buffer](https://github.com/ChALkeR/safer-buffer/blob/master/Porting-Buffer.md) guide.
|
||||
|
||||
## Do I need it?
|
||||
|
||||
Hopefully, not — dropping support for outdated Node.js versions should be fine nowdays, and that
|
||||
is the recommended path forward. You _do_ need to port to the `Buffer.alloc()` and `Buffer.from()`
|
||||
though.
|
||||
|
||||
See the [porting guide](https://github.com/ChALkeR/safer-buffer/blob/master/Porting-Buffer.md)
|
||||
for a better description.
|
||||
|
||||
## Why not [safe-buffer](https://npmjs.com/safe-buffer)?
|
||||
|
||||
_In short: while `safe-buffer` serves as a polyfill for the new API, it allows old API usage and
|
||||
itself contains footguns._
|
||||
|
||||
`safe-buffer` could be used safely to get the new API while still keeping support for older
|
||||
Node.js versions (like this module), but while analyzing ecosystem usage of the old Buffer API
|
||||
I found out that `safe-buffer` is itself causing problems in some cases.
|
||||
|
||||
For example, consider the following snippet:
|
||||
|
||||
```console
|
||||
$ cat example.unsafe.js
|
||||
console.log(Buffer(20))
|
||||
$ ./node-v6.13.0-linux-x64/bin/node example.unsafe.js
|
||||
<Buffer 0a 00 00 00 00 00 00 00 28 13 de 02 00 00 00 00 05 00 00 00>
|
||||
$ standard example.unsafe.js
|
||||
standard: Use JavaScript Standard Style (https://standardjs.com)
|
||||
/home/chalker/repo/safer-buffer/example.unsafe.js:2:13: 'Buffer()' was deprecated since v6. Use 'Buffer.alloc()' or 'Buffer.from()' (use 'https://www.npmjs.com/package/safe-buffer' for '<4.5.0') instead.
|
||||
```
|
||||
|
||||
This is allocates and writes to console an uninitialized chunk of memory.
|
||||
[standard](https://www.npmjs.com/package/standard) linter (among others) catch that and warn people
|
||||
to avoid using unsafe API.
|
||||
|
||||
Let's now throw in `safe-buffer`!
|
||||
|
||||
```console
|
||||
$ cat example.safe-buffer.js
|
||||
const Buffer = require('safe-buffer').Buffer
|
||||
console.log(Buffer(20))
|
||||
$ standard example.safe-buffer.js
|
||||
$ ./node-v6.13.0-linux-x64/bin/node example.safe-buffer.js
|
||||
<Buffer 08 00 00 00 00 00 00 00 28 58 01 82 fe 7f 00 00 00 00 00 00>
|
||||
```
|
||||
|
||||
See the problem? Adding in `safe-buffer` _magically removes the lint warning_, but the behavior
|
||||
remains identiсal to what we had before, and when launched on Node.js 6.x LTS — this dumps out
|
||||
chunks of uninitialized memory.
|
||||
_And this code will still emit runtime warnings on Node.js 10.x and above._
|
||||
|
||||
That was done by design. I first considered changing `safe-buffer`, prohibiting old API usage or
|
||||
emitting warnings on it, but that significantly diverges from `safe-buffer` design. After some
|
||||
discussion, it was decided to move my approach into a separate package, and _this is that separate
|
||||
package_.
|
||||
|
||||
This footgun is not imaginary — I observed top-downloaded packages doing that kind of thing,
|
||||
«fixing» the lint warning by blindly including `safe-buffer` without any actual changes.
|
||||
|
||||
Also in some cases, even if the API _was_ migrated to use of safe Buffer API — a random pull request
|
||||
can bring unsafe Buffer API usage back to the codebase by adding new calls — and that could go
|
||||
unnoticed even if you have a linter prohibiting that (becase of the reason stated above), and even
|
||||
pass CI. _I also observed that being done in popular packages._
|
||||
|
||||
Some examples:
|
||||
* [webdriverio](https://github.com/webdriverio/webdriverio/commit/05cbd3167c12e4930f09ef7cf93b127ba4effae4#diff-124380949022817b90b622871837d56cR31)
|
||||
(a module with 548 759 downloads/month),
|
||||
* [websocket-stream](https://github.com/maxogden/websocket-stream/commit/c9312bd24d08271687d76da0fe3c83493871cf61)
|
||||
(218 288 d/m, fix in [maxogden/websocket-stream#142](https://github.com/maxogden/websocket-stream/pull/142)),
|
||||
* [node-serialport](https://github.com/node-serialport/node-serialport/commit/e8d9d2b16c664224920ce1c895199b1ce2def48c)
|
||||
(113 138 d/m, fix in [node-serialport/node-serialport#1510](https://github.com/node-serialport/node-serialport/pull/1510)),
|
||||
* [karma](https://github.com/karma-runner/karma/commit/3d94b8cf18c695104ca195334dc75ff054c74eec)
|
||||
(3 973 193 d/m, fix in [karma-runner/karma#2947](https://github.com/karma-runner/karma/pull/2947)),
|
||||
* [spdy-transport](https://github.com/spdy-http2/spdy-transport/commit/5375ac33f4a62a4f65bcfc2827447d42a5dbe8b1)
|
||||
(5 970 727 d/m, fix in [spdy-http2/spdy-transport#53](https://github.com/spdy-http2/spdy-transport/pull/53)).
|
||||
* And there are a lot more over the ecosystem.
|
||||
|
||||
I filed a PR at
|
||||
[mysticatea/eslint-plugin-node#110](https://github.com/mysticatea/eslint-plugin-node/pull/110) to
|
||||
partially fix that (for cases when that lint rule is used), but it is a semver-major change for
|
||||
linter rules and presets, so it would take significant time for that to reach actual setups.
|
||||
_It also hasn't been released yet (2018-03-20)._
|
||||
|
||||
Also, `safer-buffer` discourages the usage of `.allocUnsafe()`, which is often done by a mistake.
|
||||
It still supports it with an explicit concern barier, by placing it under
|
||||
`require('safer-buffer/dangereous')`.
|
||||
|
||||
## But isn't throwing bad?
|
||||
|
||||
Not really. It's an error that could be noticed and fixed early, instead of causing havoc later like
|
||||
unguarded `new Buffer()` calls that end up receiving user input can do.
|
||||
|
||||
This package affects only the files where `var Buffer = require('safer-buffer').Buffer` was done, so
|
||||
it is really simple to keep track of things and make sure that you don't mix old API usage with that.
|
||||
Also, CI should hint anything that you might have missed.
|
||||
|
||||
New commits, if tested, won't land new usage of unsafe Buffer API this way.
|
||||
_Node.js 10.x also deals with that by printing a runtime depecation warning._
|
||||
|
||||
### Would it affect third-party modules?
|
||||
|
||||
No, unless you explicitly do an awful thing like monkey-patching or overriding the built-in `Buffer`.
|
||||
Don't do that.
|
||||
|
||||
### But I don't want throwing…
|
||||
|
||||
That is also fine!
|
||||
|
||||
Also, it could be better in some cases when you don't comprehensive enough test coverage.
|
||||
|
||||
In that case — just don't override `Buffer` and use
|
||||
`var SaferBuffer = require('safer-buffer').Buffer` instead.
|
||||
|
||||
That way, everything using `Buffer` natively would still work, but there would be two drawbacks:
|
||||
|
||||
* `Buffer.from`/`Buffer.alloc` won't be polyfilled — use `SaferBuffer.from` and
|
||||
`SaferBuffer.alloc` instead.
|
||||
* You are still open to accidentally using the insecure deprecated API — use a linter to catch that.
|
||||
|
||||
Note that using a linter to catch accidential `Buffer` constructor usage in this case is strongly
|
||||
recommended. `Buffer` is not overriden in this usecase, so linters won't get confused.
|
||||
|
||||
## «Without footguns»?
|
||||
|
||||
Well, it is still possible to do _some_ things with `Buffer` API, e.g. accessing `.buffer` property
|
||||
on older versions and duping things from there. You shouldn't do that in your code, probabably.
|
||||
|
||||
The intention is to remove the most significant footguns that affect lots of packages in the
|
||||
ecosystem, and to do it in the proper way.
|
||||
|
||||
Also, this package doesn't protect against security issues affecting some Node.js versions, so for
|
||||
usage in your own production code, it is still recommended to update to a Node.js version
|
||||
[supported by upstream](https://github.com/nodejs/release#release-schedule).
|
||||
58
tasks/enduro-trails/prototype/node_modules/safer-buffer/dangerous.js
generated
vendored
Normal file
58
tasks/enduro-trails/prototype/node_modules/safer-buffer/dangerous.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/* eslint-disable node/no-deprecated-api */
|
||||
|
||||
'use strict'
|
||||
|
||||
var buffer = require('buffer')
|
||||
var Buffer = buffer.Buffer
|
||||
var safer = require('./safer.js')
|
||||
var Safer = safer.Buffer
|
||||
|
||||
var dangerous = {}
|
||||
|
||||
var key
|
||||
|
||||
for (key in safer) {
|
||||
if (!safer.hasOwnProperty(key)) continue
|
||||
dangerous[key] = safer[key]
|
||||
}
|
||||
|
||||
var Dangereous = dangerous.Buffer = {}
|
||||
|
||||
// Copy Safer API
|
||||
for (key in Safer) {
|
||||
if (!Safer.hasOwnProperty(key)) continue
|
||||
Dangereous[key] = Safer[key]
|
||||
}
|
||||
|
||||
// Copy those missing unsafe methods, if they are present
|
||||
for (key in Buffer) {
|
||||
if (!Buffer.hasOwnProperty(key)) continue
|
||||
if (Dangereous.hasOwnProperty(key)) continue
|
||||
Dangereous[key] = Buffer[key]
|
||||
}
|
||||
|
||||
if (!Dangereous.allocUnsafe) {
|
||||
Dangereous.allocUnsafe = function (size) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size)
|
||||
}
|
||||
if (size < 0 || size >= 2 * (1 << 30)) {
|
||||
throw new RangeError('The value "' + size + '" is invalid for option "size"')
|
||||
}
|
||||
return Buffer(size)
|
||||
}
|
||||
}
|
||||
|
||||
if (!Dangereous.allocUnsafeSlow) {
|
||||
Dangereous.allocUnsafeSlow = function (size) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size)
|
||||
}
|
||||
if (size < 0 || size >= 2 * (1 << 30)) {
|
||||
throw new RangeError('The value "' + size + '" is invalid for option "size"')
|
||||
}
|
||||
return buffer.SlowBuffer(size)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = dangerous
|
||||
34
tasks/enduro-trails/prototype/node_modules/safer-buffer/package.json
generated
vendored
Normal file
34
tasks/enduro-trails/prototype/node_modules/safer-buffer/package.json
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "safer-buffer",
|
||||
"version": "2.1.2",
|
||||
"description": "Modern Buffer API polyfill without footguns",
|
||||
"main": "safer.js",
|
||||
"scripts": {
|
||||
"browserify-test": "browserify --external tape tests.js > browserify-tests.js && tape browserify-tests.js",
|
||||
"test": "standard && tape tests.js"
|
||||
},
|
||||
"author": {
|
||||
"name": "Nikita Skovoroda",
|
||||
"email": "chalkerx@gmail.com",
|
||||
"url": "https://github.com/ChALkeR"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ChALkeR/safer-buffer.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/ChALkeR/safer-buffer/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"standard": "^11.0.1",
|
||||
"tape": "^4.9.0"
|
||||
},
|
||||
"files": [
|
||||
"Porting-Buffer.md",
|
||||
"Readme.md",
|
||||
"tests.js",
|
||||
"dangerous.js",
|
||||
"safer.js"
|
||||
]
|
||||
}
|
||||
77
tasks/enduro-trails/prototype/node_modules/safer-buffer/safer.js
generated
vendored
Normal file
77
tasks/enduro-trails/prototype/node_modules/safer-buffer/safer.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/* eslint-disable node/no-deprecated-api */
|
||||
|
||||
'use strict'
|
||||
|
||||
var buffer = require('buffer')
|
||||
var Buffer = buffer.Buffer
|
||||
|
||||
var safer = {}
|
||||
|
||||
var key
|
||||
|
||||
for (key in buffer) {
|
||||
if (!buffer.hasOwnProperty(key)) continue
|
||||
if (key === 'SlowBuffer' || key === 'Buffer') continue
|
||||
safer[key] = buffer[key]
|
||||
}
|
||||
|
||||
var Safer = safer.Buffer = {}
|
||||
for (key in Buffer) {
|
||||
if (!Buffer.hasOwnProperty(key)) continue
|
||||
if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue
|
||||
Safer[key] = Buffer[key]
|
||||
}
|
||||
|
||||
safer.Buffer.prototype = Buffer.prototype
|
||||
|
||||
if (!Safer.from || Safer.from === Uint8Array.from) {
|
||||
Safer.from = function (value, encodingOrOffset, length) {
|
||||
if (typeof value === 'number') {
|
||||
throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value)
|
||||
}
|
||||
if (value && typeof value.length === 'undefined') {
|
||||
throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value)
|
||||
}
|
||||
return Buffer(value, encodingOrOffset, length)
|
||||
}
|
||||
}
|
||||
|
||||
if (!Safer.alloc) {
|
||||
Safer.alloc = function (size, fill, encoding) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size)
|
||||
}
|
||||
if (size < 0 || size >= 2 * (1 << 30)) {
|
||||
throw new RangeError('The value "' + size + '" is invalid for option "size"')
|
||||
}
|
||||
var buf = Buffer(size)
|
||||
if (!fill || fill.length === 0) {
|
||||
buf.fill(0)
|
||||
} else if (typeof encoding === 'string') {
|
||||
buf.fill(fill, encoding)
|
||||
} else {
|
||||
buf.fill(fill)
|
||||
}
|
||||
return buf
|
||||
}
|
||||
}
|
||||
|
||||
if (!safer.kStringMaxLength) {
|
||||
try {
|
||||
safer.kStringMaxLength = process.binding('buffer').kStringMaxLength
|
||||
} catch (e) {
|
||||
// we can't determine kStringMaxLength in environments where process.binding
|
||||
// is unsupported, so let's not set it
|
||||
}
|
||||
}
|
||||
|
||||
if (!safer.constants) {
|
||||
safer.constants = {
|
||||
MAX_LENGTH: safer.kMaxLength
|
||||
}
|
||||
if (safer.kStringMaxLength) {
|
||||
safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = safer
|
||||
406
tasks/enduro-trails/prototype/node_modules/safer-buffer/tests.js
generated
vendored
Normal file
406
tasks/enduro-trails/prototype/node_modules/safer-buffer/tests.js
generated
vendored
Normal file
@@ -0,0 +1,406 @@
|
||||
/* eslint-disable node/no-deprecated-api */
|
||||
|
||||
'use strict'
|
||||
|
||||
var test = require('tape')
|
||||
|
||||
var buffer = require('buffer')
|
||||
|
||||
var index = require('./')
|
||||
var safer = require('./safer')
|
||||
var dangerous = require('./dangerous')
|
||||
|
||||
/* Inheritance tests */
|
||||
|
||||
test('Default is Safer', function (t) {
|
||||
t.equal(index, safer)
|
||||
t.notEqual(safer, dangerous)
|
||||
t.notEqual(index, dangerous)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Is not a function', function (t) {
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.equal(typeof impl, 'object')
|
||||
t.equal(typeof impl.Buffer, 'object')
|
||||
});
|
||||
[buffer].forEach(function (impl) {
|
||||
t.equal(typeof impl, 'object')
|
||||
t.equal(typeof impl.Buffer, 'function')
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Constructor throws', function (t) {
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.throws(function () { impl.Buffer() })
|
||||
t.throws(function () { impl.Buffer(0) })
|
||||
t.throws(function () { impl.Buffer('a') })
|
||||
t.throws(function () { impl.Buffer('a', 'utf-8') })
|
||||
t.throws(function () { return new impl.Buffer() })
|
||||
t.throws(function () { return new impl.Buffer(0) })
|
||||
t.throws(function () { return new impl.Buffer('a') })
|
||||
t.throws(function () { return new impl.Buffer('a', 'utf-8') })
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Safe methods exist', function (t) {
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.equal(typeof impl.Buffer.alloc, 'function', 'alloc')
|
||||
t.equal(typeof impl.Buffer.from, 'function', 'from')
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Unsafe methods exist only in Dangerous', function (t) {
|
||||
[index, safer].forEach(function (impl) {
|
||||
t.equal(typeof impl.Buffer.allocUnsafe, 'undefined')
|
||||
t.equal(typeof impl.Buffer.allocUnsafeSlow, 'undefined')
|
||||
});
|
||||
[dangerous].forEach(function (impl) {
|
||||
t.equal(typeof impl.Buffer.allocUnsafe, 'function')
|
||||
t.equal(typeof impl.Buffer.allocUnsafeSlow, 'function')
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Generic methods/properties are defined and equal', function (t) {
|
||||
['poolSize', 'isBuffer', 'concat', 'byteLength'].forEach(function (method) {
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.equal(impl.Buffer[method], buffer.Buffer[method], method)
|
||||
t.notEqual(typeof impl.Buffer[method], 'undefined', method)
|
||||
})
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Built-in buffer static methods/properties are inherited', function (t) {
|
||||
Object.keys(buffer).forEach(function (method) {
|
||||
if (method === 'SlowBuffer' || method === 'Buffer') return;
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.equal(impl[method], buffer[method], method)
|
||||
t.notEqual(typeof impl[method], 'undefined', method)
|
||||
})
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Built-in Buffer static methods/properties are inherited', function (t) {
|
||||
Object.keys(buffer.Buffer).forEach(function (method) {
|
||||
if (method === 'allocUnsafe' || method === 'allocUnsafeSlow') return;
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.equal(impl.Buffer[method], buffer.Buffer[method], method)
|
||||
t.notEqual(typeof impl.Buffer[method], 'undefined', method)
|
||||
})
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.prototype property of Buffer is inherited', function (t) {
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.equal(impl.Buffer.prototype, buffer.Buffer.prototype, 'prototype')
|
||||
t.notEqual(typeof impl.Buffer.prototype, 'undefined', 'prototype')
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('All Safer methods are present in Dangerous', function (t) {
|
||||
Object.keys(safer).forEach(function (method) {
|
||||
if (method === 'Buffer') return;
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.equal(impl[method], safer[method], method)
|
||||
if (method !== 'kStringMaxLength') {
|
||||
t.notEqual(typeof impl[method], 'undefined', method)
|
||||
}
|
||||
})
|
||||
})
|
||||
Object.keys(safer.Buffer).forEach(function (method) {
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.equal(impl.Buffer[method], safer.Buffer[method], method)
|
||||
t.notEqual(typeof impl.Buffer[method], 'undefined', method)
|
||||
})
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Safe methods from Dangerous methods are present in Safer', function (t) {
|
||||
Object.keys(dangerous).forEach(function (method) {
|
||||
if (method === 'Buffer') return;
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.equal(impl[method], dangerous[method], method)
|
||||
if (method !== 'kStringMaxLength') {
|
||||
t.notEqual(typeof impl[method], 'undefined', method)
|
||||
}
|
||||
})
|
||||
})
|
||||
Object.keys(dangerous.Buffer).forEach(function (method) {
|
||||
if (method === 'allocUnsafe' || method === 'allocUnsafeSlow') return;
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.equal(impl.Buffer[method], dangerous.Buffer[method], method)
|
||||
t.notEqual(typeof impl.Buffer[method], 'undefined', method)
|
||||
})
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
/* Behaviour tests */
|
||||
|
||||
test('Methods return Buffers', function (t) {
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.ok(buffer.Buffer.isBuffer(impl.Buffer.alloc(0)))
|
||||
t.ok(buffer.Buffer.isBuffer(impl.Buffer.alloc(0, 10)))
|
||||
t.ok(buffer.Buffer.isBuffer(impl.Buffer.alloc(0, 'a')))
|
||||
t.ok(buffer.Buffer.isBuffer(impl.Buffer.alloc(10)))
|
||||
t.ok(buffer.Buffer.isBuffer(impl.Buffer.alloc(10, 'x')))
|
||||
t.ok(buffer.Buffer.isBuffer(impl.Buffer.alloc(9, 'ab')))
|
||||
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from('')))
|
||||
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from('string')))
|
||||
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from('string', 'utf-8')))
|
||||
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from('b25ldHdvdGhyZWU=', 'base64')))
|
||||
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from([0, 42, 3])))
|
||||
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from(new Uint8Array([0, 42, 3]))))
|
||||
t.ok(buffer.Buffer.isBuffer(impl.Buffer.from([])))
|
||||
});
|
||||
['allocUnsafe', 'allocUnsafeSlow'].forEach(function (method) {
|
||||
t.ok(buffer.Buffer.isBuffer(dangerous.Buffer[method](0)))
|
||||
t.ok(buffer.Buffer.isBuffer(dangerous.Buffer[method](10)))
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Constructor is buffer.Buffer', function (t) {
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.equal(impl.Buffer.alloc(0).constructor, buffer.Buffer)
|
||||
t.equal(impl.Buffer.alloc(0, 10).constructor, buffer.Buffer)
|
||||
t.equal(impl.Buffer.alloc(0, 'a').constructor, buffer.Buffer)
|
||||
t.equal(impl.Buffer.alloc(10).constructor, buffer.Buffer)
|
||||
t.equal(impl.Buffer.alloc(10, 'x').constructor, buffer.Buffer)
|
||||
t.equal(impl.Buffer.alloc(9, 'ab').constructor, buffer.Buffer)
|
||||
t.equal(impl.Buffer.from('').constructor, buffer.Buffer)
|
||||
t.equal(impl.Buffer.from('string').constructor, buffer.Buffer)
|
||||
t.equal(impl.Buffer.from('string', 'utf-8').constructor, buffer.Buffer)
|
||||
t.equal(impl.Buffer.from('b25ldHdvdGhyZWU=', 'base64').constructor, buffer.Buffer)
|
||||
t.equal(impl.Buffer.from([0, 42, 3]).constructor, buffer.Buffer)
|
||||
t.equal(impl.Buffer.from(new Uint8Array([0, 42, 3])).constructor, buffer.Buffer)
|
||||
t.equal(impl.Buffer.from([]).constructor, buffer.Buffer)
|
||||
});
|
||||
[0, 10, 100].forEach(function (arg) {
|
||||
t.equal(dangerous.Buffer.allocUnsafe(arg).constructor, buffer.Buffer)
|
||||
t.equal(dangerous.Buffer.allocUnsafeSlow(arg).constructor, buffer.SlowBuffer(0).constructor)
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Invalid calls throw', function (t) {
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.throws(function () { impl.Buffer.from(0) })
|
||||
t.throws(function () { impl.Buffer.from(10) })
|
||||
t.throws(function () { impl.Buffer.from(10, 'utf-8') })
|
||||
t.throws(function () { impl.Buffer.from('string', 'invalid encoding') })
|
||||
t.throws(function () { impl.Buffer.from(-10) })
|
||||
t.throws(function () { impl.Buffer.from(1e90) })
|
||||
t.throws(function () { impl.Buffer.from(Infinity) })
|
||||
t.throws(function () { impl.Buffer.from(-Infinity) })
|
||||
t.throws(function () { impl.Buffer.from(NaN) })
|
||||
t.throws(function () { impl.Buffer.from(null) })
|
||||
t.throws(function () { impl.Buffer.from(undefined) })
|
||||
t.throws(function () { impl.Buffer.from() })
|
||||
t.throws(function () { impl.Buffer.from({}) })
|
||||
t.throws(function () { impl.Buffer.alloc('') })
|
||||
t.throws(function () { impl.Buffer.alloc('string') })
|
||||
t.throws(function () { impl.Buffer.alloc('string', 'utf-8') })
|
||||
t.throws(function () { impl.Buffer.alloc('b25ldHdvdGhyZWU=', 'base64') })
|
||||
t.throws(function () { impl.Buffer.alloc(-10) })
|
||||
t.throws(function () { impl.Buffer.alloc(1e90) })
|
||||
t.throws(function () { impl.Buffer.alloc(2 * (1 << 30)) })
|
||||
t.throws(function () { impl.Buffer.alloc(Infinity) })
|
||||
t.throws(function () { impl.Buffer.alloc(-Infinity) })
|
||||
t.throws(function () { impl.Buffer.alloc(null) })
|
||||
t.throws(function () { impl.Buffer.alloc(undefined) })
|
||||
t.throws(function () { impl.Buffer.alloc() })
|
||||
t.throws(function () { impl.Buffer.alloc([]) })
|
||||
t.throws(function () { impl.Buffer.alloc([0, 42, 3]) })
|
||||
t.throws(function () { impl.Buffer.alloc({}) })
|
||||
});
|
||||
['allocUnsafe', 'allocUnsafeSlow'].forEach(function (method) {
|
||||
t.throws(function () { dangerous.Buffer[method]('') })
|
||||
t.throws(function () { dangerous.Buffer[method]('string') })
|
||||
t.throws(function () { dangerous.Buffer[method]('string', 'utf-8') })
|
||||
t.throws(function () { dangerous.Buffer[method](2 * (1 << 30)) })
|
||||
t.throws(function () { dangerous.Buffer[method](Infinity) })
|
||||
if (dangerous.Buffer[method] === buffer.Buffer.allocUnsafe) {
|
||||
t.skip('Skipping, older impl of allocUnsafe coerced negative sizes to 0')
|
||||
} else {
|
||||
t.throws(function () { dangerous.Buffer[method](-10) })
|
||||
t.throws(function () { dangerous.Buffer[method](-1e90) })
|
||||
t.throws(function () { dangerous.Buffer[method](-Infinity) })
|
||||
}
|
||||
t.throws(function () { dangerous.Buffer[method](null) })
|
||||
t.throws(function () { dangerous.Buffer[method](undefined) })
|
||||
t.throws(function () { dangerous.Buffer[method]() })
|
||||
t.throws(function () { dangerous.Buffer[method]([]) })
|
||||
t.throws(function () { dangerous.Buffer[method]([0, 42, 3]) })
|
||||
t.throws(function () { dangerous.Buffer[method]({}) })
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Buffers have appropriate lengths', function (t) {
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.equal(impl.Buffer.alloc(0).length, 0)
|
||||
t.equal(impl.Buffer.alloc(10).length, 10)
|
||||
t.equal(impl.Buffer.from('').length, 0)
|
||||
t.equal(impl.Buffer.from('string').length, 6)
|
||||
t.equal(impl.Buffer.from('string', 'utf-8').length, 6)
|
||||
t.equal(impl.Buffer.from('b25ldHdvdGhyZWU=', 'base64').length, 11)
|
||||
t.equal(impl.Buffer.from([0, 42, 3]).length, 3)
|
||||
t.equal(impl.Buffer.from(new Uint8Array([0, 42, 3])).length, 3)
|
||||
t.equal(impl.Buffer.from([]).length, 0)
|
||||
});
|
||||
['allocUnsafe', 'allocUnsafeSlow'].forEach(function (method) {
|
||||
t.equal(dangerous.Buffer[method](0).length, 0)
|
||||
t.equal(dangerous.Buffer[method](10).length, 10)
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('Buffers have appropriate lengths (2)', function (t) {
|
||||
t.equal(index.Buffer.alloc, safer.Buffer.alloc)
|
||||
t.equal(index.Buffer.alloc, dangerous.Buffer.alloc)
|
||||
var ok = true;
|
||||
[ safer.Buffer.alloc,
|
||||
dangerous.Buffer.allocUnsafe,
|
||||
dangerous.Buffer.allocUnsafeSlow
|
||||
].forEach(function (method) {
|
||||
for (var i = 0; i < 1e2; i++) {
|
||||
var length = Math.round(Math.random() * 1e5)
|
||||
var buf = method(length)
|
||||
if (!buffer.Buffer.isBuffer(buf)) ok = false
|
||||
if (buf.length !== length) ok = false
|
||||
}
|
||||
})
|
||||
t.ok(ok)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.alloc(size) is zero-filled and has correct length', function (t) {
|
||||
t.equal(index.Buffer.alloc, safer.Buffer.alloc)
|
||||
t.equal(index.Buffer.alloc, dangerous.Buffer.alloc)
|
||||
var ok = true
|
||||
for (var i = 0; i < 1e2; i++) {
|
||||
var length = Math.round(Math.random() * 2e6)
|
||||
var buf = index.Buffer.alloc(length)
|
||||
if (!buffer.Buffer.isBuffer(buf)) ok = false
|
||||
if (buf.length !== length) ok = false
|
||||
var j
|
||||
for (j = 0; j < length; j++) {
|
||||
if (buf[j] !== 0) ok = false
|
||||
}
|
||||
buf.fill(1)
|
||||
for (j = 0; j < length; j++) {
|
||||
if (buf[j] !== 1) ok = false
|
||||
}
|
||||
}
|
||||
t.ok(ok)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.allocUnsafe / .allocUnsafeSlow are fillable and have correct lengths', function (t) {
|
||||
['allocUnsafe', 'allocUnsafeSlow'].forEach(function (method) {
|
||||
var ok = true
|
||||
for (var i = 0; i < 1e2; i++) {
|
||||
var length = Math.round(Math.random() * 2e6)
|
||||
var buf = dangerous.Buffer[method](length)
|
||||
if (!buffer.Buffer.isBuffer(buf)) ok = false
|
||||
if (buf.length !== length) ok = false
|
||||
buf.fill(0, 0, length)
|
||||
var j
|
||||
for (j = 0; j < length; j++) {
|
||||
if (buf[j] !== 0) ok = false
|
||||
}
|
||||
buf.fill(1, 0, length)
|
||||
for (j = 0; j < length; j++) {
|
||||
if (buf[j] !== 1) ok = false
|
||||
}
|
||||
}
|
||||
t.ok(ok, method)
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.alloc(size, fill) is `fill`-filled', function (t) {
|
||||
t.equal(index.Buffer.alloc, safer.Buffer.alloc)
|
||||
t.equal(index.Buffer.alloc, dangerous.Buffer.alloc)
|
||||
var ok = true
|
||||
for (var i = 0; i < 1e2; i++) {
|
||||
var length = Math.round(Math.random() * 2e6)
|
||||
var fill = Math.round(Math.random() * 255)
|
||||
var buf = index.Buffer.alloc(length, fill)
|
||||
if (!buffer.Buffer.isBuffer(buf)) ok = false
|
||||
if (buf.length !== length) ok = false
|
||||
for (var j = 0; j < length; j++) {
|
||||
if (buf[j] !== fill) ok = false
|
||||
}
|
||||
}
|
||||
t.ok(ok)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.alloc(size, fill) is `fill`-filled', function (t) {
|
||||
t.equal(index.Buffer.alloc, safer.Buffer.alloc)
|
||||
t.equal(index.Buffer.alloc, dangerous.Buffer.alloc)
|
||||
var ok = true
|
||||
for (var i = 0; i < 1e2; i++) {
|
||||
var length = Math.round(Math.random() * 2e6)
|
||||
var fill = Math.round(Math.random() * 255)
|
||||
var buf = index.Buffer.alloc(length, fill)
|
||||
if (!buffer.Buffer.isBuffer(buf)) ok = false
|
||||
if (buf.length !== length) ok = false
|
||||
for (var j = 0; j < length; j++) {
|
||||
if (buf[j] !== fill) ok = false
|
||||
}
|
||||
}
|
||||
t.ok(ok)
|
||||
t.deepEqual(index.Buffer.alloc(9, 'a'), index.Buffer.alloc(9, 97))
|
||||
t.notDeepEqual(index.Buffer.alloc(9, 'a'), index.Buffer.alloc(9, 98))
|
||||
|
||||
var tmp = new buffer.Buffer(2)
|
||||
tmp.fill('ok')
|
||||
if (tmp[1] === tmp[0]) {
|
||||
// Outdated Node.js
|
||||
t.deepEqual(index.Buffer.alloc(5, 'ok'), index.Buffer.from('ooooo'))
|
||||
} else {
|
||||
t.deepEqual(index.Buffer.alloc(5, 'ok'), index.Buffer.from('okoko'))
|
||||
}
|
||||
t.notDeepEqual(index.Buffer.alloc(5, 'ok'), index.Buffer.from('kokok'))
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('safer.Buffer.from returns results same as Buffer constructor', function (t) {
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.deepEqual(impl.Buffer.from(''), new buffer.Buffer(''))
|
||||
t.deepEqual(impl.Buffer.from('string'), new buffer.Buffer('string'))
|
||||
t.deepEqual(impl.Buffer.from('string', 'utf-8'), new buffer.Buffer('string', 'utf-8'))
|
||||
t.deepEqual(impl.Buffer.from('b25ldHdvdGhyZWU=', 'base64'), new buffer.Buffer('b25ldHdvdGhyZWU=', 'base64'))
|
||||
t.deepEqual(impl.Buffer.from([0, 42, 3]), new buffer.Buffer([0, 42, 3]))
|
||||
t.deepEqual(impl.Buffer.from(new Uint8Array([0, 42, 3])), new buffer.Buffer(new Uint8Array([0, 42, 3])))
|
||||
t.deepEqual(impl.Buffer.from([]), new buffer.Buffer([]))
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('safer.Buffer.from returns consistent results', function (t) {
|
||||
[index, safer, dangerous].forEach(function (impl) {
|
||||
t.deepEqual(impl.Buffer.from(''), impl.Buffer.alloc(0))
|
||||
t.deepEqual(impl.Buffer.from([]), impl.Buffer.alloc(0))
|
||||
t.deepEqual(impl.Buffer.from(new Uint8Array([])), impl.Buffer.alloc(0))
|
||||
t.deepEqual(impl.Buffer.from('string', 'utf-8'), impl.Buffer.from('string'))
|
||||
t.deepEqual(impl.Buffer.from('string'), impl.Buffer.from([115, 116, 114, 105, 110, 103]))
|
||||
t.deepEqual(impl.Buffer.from('string'), impl.Buffer.from(impl.Buffer.from('string')))
|
||||
t.deepEqual(impl.Buffer.from('b25ldHdvdGhyZWU=', 'base64'), impl.Buffer.from('onetwothree'))
|
||||
t.notDeepEqual(impl.Buffer.from('b25ldHdvdGhyZWU='), impl.Buffer.from('onetwothree'))
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
4
tasks/enduro-trails/prototype/node_modules/ssh2/.eslintignore
generated
vendored
Normal file
4
tasks/enduro-trails/prototype/node_modules/ssh2/.eslintignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
node_modules
|
||||
lib/protocol/crypto/poly1305.js
|
||||
.eslint-plugins
|
||||
!.eslintrc.js
|
||||
5
tasks/enduro-trails/prototype/node_modules/ssh2/.eslintrc.js
generated
vendored
Normal file
5
tasks/enduro-trails/prototype/node_modules/ssh2/.eslintrc.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
extends: '@mscdex/eslint-config',
|
||||
};
|
||||
110
tasks/enduro-trails/prototype/node_modules/ssh2/.github/workflows/ci.yml
generated
vendored
Normal file
110
tasks/enduro-trails/prototype/node_modules/ssh2/.github/workflows/ci.yml
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
env:
|
||||
CI_CHECK_FAIL: ssh2
|
||||
OPENSSL_CONF: /dev/null
|
||||
|
||||
jobs:
|
||||
tests-linux:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node-version: [10.16.0, 10.x, 12.x, 14.x, 16.x, 18.x, 20.x, 22.x, 24.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Check Node.js version
|
||||
run: node -pe process.versions
|
||||
- name: Check npm version
|
||||
run: npm -v
|
||||
- name: Install Python 2.7 (node <16.x)
|
||||
if: ${{ contains(fromJSON('["10.16.0", "10.x", "12.x", "14.x"]'), matrix.node-version) }}
|
||||
uses: LizardByte/setup-python-action@v2024.1105.190605
|
||||
with:
|
||||
python-version: '2.7'
|
||||
- name: Use Python 2.7 (node <16.x)
|
||||
if: ${{ contains(fromJSON('["10.16.0", "10.x", "12.x", "14.x"]'), matrix.node-version) }}
|
||||
run: echo "PYTHON=$(which python2.7)" >> "$GITHUB_ENV"
|
||||
- name: Install module
|
||||
run: npm install
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
tests-macos:
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node-version: [16.x, 18.x, 20.x, 22.x, 24.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Install Python 3.10
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- name: Check Node.js version
|
||||
run: node -pe process.versions
|
||||
- name: Check npm version
|
||||
run: npm -v
|
||||
- name: Install module
|
||||
run: npm install
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
tests-macos-homebrew:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Use Node.js (latest)
|
||||
run: brew install node
|
||||
- name: Install Python 3.10
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- name: Check Node.js version
|
||||
run: node -pe process.versions
|
||||
- name: Check npm version
|
||||
run: npm -v
|
||||
- name: Install module
|
||||
run: npm install
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
tests-windows:
|
||||
runs-on: windows-2022
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node-version: [16.x, 18.x, 20.x, 22.x, 24.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Check Node.js version
|
||||
run: node -pe process.versions
|
||||
- name: Check npm version
|
||||
run: npm -v
|
||||
- name: Install module
|
||||
run: npm install
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
27
tasks/enduro-trails/prototype/node_modules/ssh2/.github/workflows/lint.yml
generated
vendored
Normal file
27
tasks/enduro-trails/prototype/node_modules/ssh2/.github/workflows/lint.yml
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
name: lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
env:
|
||||
NODE_VERSION: 18.x
|
||||
|
||||
jobs:
|
||||
lint-js:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Use Node.js ${{ env.NODE_VERSION }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
- name: Check Node.js version
|
||||
run: node -pe process.versions
|
||||
- name: Install ESLint + ESLint configs/plugins
|
||||
run: npm install --only=dev
|
||||
- name: Lint files
|
||||
run: npm run lint
|
||||
19
tasks/enduro-trails/prototype/node_modules/ssh2/LICENSE
generated
vendored
Normal file
19
tasks/enduro-trails/prototype/node_modules/ssh2/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright Brian White. 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.
|
||||
1529
tasks/enduro-trails/prototype/node_modules/ssh2/README.md
generated
vendored
Normal file
1529
tasks/enduro-trails/prototype/node_modules/ssh2/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
413
tasks/enduro-trails/prototype/node_modules/ssh2/SFTP.md
generated
vendored
Normal file
413
tasks/enduro-trails/prototype/node_modules/ssh2/SFTP.md
generated
vendored
Normal file
@@ -0,0 +1,413 @@
|
||||
SFTP events
|
||||
-----------
|
||||
|
||||
**Client/Server events**
|
||||
|
||||
* **ready**() - Emitted after initial protocol version check has passed.
|
||||
|
||||
**Server-only events**
|
||||
|
||||
_Responses to these client requests are sent using one of the methods listed further in this document under `Server-only methods`. The valid response(s) for each request are documented below._
|
||||
|
||||
* **OPEN**(< _integer_ >reqID, < _string_ >filename, < _integer_ >flags, < _ATTRS_ >attrs)
|
||||
|
||||
`flags` is a bitfield containing any of the flags defined in `OPEN_MODE`.
|
||||
Use the static method `flagsToString()` to convert the value to a mode
|
||||
string to be used by `fs.open()` (e.g. `'r'`).
|
||||
|
||||
Respond using one of the following:
|
||||
|
||||
* `handle()` - This indicates a successful opening of the file and passes
|
||||
the given handle back to the client to use to refer to this open file for
|
||||
future operations (e.g. reading, writing, closing).
|
||||
|
||||
* `status()` - Use this to indicate a failure to open the requested file.
|
||||
|
||||
* **READ**(< _integer_ >reqID, < _Buffer_ >handle, < _integer_ >offset, < _integer_ >length)
|
||||
|
||||
Respond using one of the following:
|
||||
|
||||
* `data()` - Use this to send the requested chunk of data back to the client.
|
||||
The amount of data sent is allowed to be less than the `length` requested,
|
||||
for example if the file ends between `offset` and `offset + length`.
|
||||
|
||||
* `status()` - Use this to indicate either end of file (`STATUS_CODE.EOF`)
|
||||
has been reached (`offset` is past the end of the file) or if an error
|
||||
occurred while reading the requested part of the file.
|
||||
|
||||
* **WRITE**(< _integer_ >reqID, < _Buffer_ >handle, < _integer_ >offset, < _Buffer_ >data)
|
||||
|
||||
Respond using:
|
||||
|
||||
* `status()` - Use this to indicate success/failure of the write to the file.
|
||||
|
||||
* **FSTAT**(< _integer_ >reqID, < _Buffer_ >handle)
|
||||
|
||||
Respond using one of the following:
|
||||
|
||||
* `attrs()` - Use this to send the attributes for the requested
|
||||
file/directory back to the client.
|
||||
|
||||
* `status()` - Use this to indicate an error occurred while accessing the
|
||||
file/directory.
|
||||
|
||||
* **FSETSTAT**(< _integer_ >reqID, < _Buffer_ >handle, < _ATTRS_ >attrs)
|
||||
|
||||
Respond using:
|
||||
|
||||
* `status()` - Use this to indicates success/failure of the setting of the
|
||||
given file/directory attributes.
|
||||
|
||||
* **CLOSE**(< _integer_ >reqID, < _Buffer_ >handle)
|
||||
|
||||
Respond using:
|
||||
|
||||
* `status()` - Use this to indicate success (`STATUS_CODE.OK`) or failure of
|
||||
the closing of the file identified by `handle`.
|
||||
|
||||
* **OPENDIR**(< _integer_ >reqID, < _string_ >path)
|
||||
|
||||
Respond using one of the following:
|
||||
|
||||
* `handle()` - This indicates a successful opening of the directory and
|
||||
passes the given handle back to the client to use to refer to this open
|
||||
directory for future operations (e.g. reading directory contents, closing).
|
||||
|
||||
* `status()` - Use this to indicate a failure to open the requested
|
||||
directory.
|
||||
|
||||
* **READDIR**(< _integer_ >reqID, < _Buffer_ >handle)
|
||||
|
||||
Respond using one of the following:
|
||||
|
||||
* `name()` - Use this to send one or more directory listings for the open
|
||||
directory back to the client.
|
||||
|
||||
* `status()` - Use this to indicate either end of directory contents
|
||||
(`STATUS_CODE.EOF`) or if an error occurred while reading the directory
|
||||
contents.
|
||||
|
||||
* **LSTAT**(< _integer_ >reqID, < _string_ >path)
|
||||
|
||||
Respond using one of the following:
|
||||
|
||||
* `attrs()` - Use this to send the attributes for the requested
|
||||
file/directory back to the client.
|
||||
|
||||
* `status()` - Use this to indicate an error occurred while accessing the
|
||||
file/directory.
|
||||
|
||||
* **STAT**(< _integer_ >reqID, < _string_ >path)
|
||||
|
||||
Respond using one of the following:
|
||||
|
||||
* `attrs()` - Use this to send the attributes for the requested
|
||||
file/directory back to the client.
|
||||
|
||||
* `status()` - Use this to indicate an error occurred while accessing the
|
||||
file/directory.
|
||||
|
||||
* **REMOVE**(< _integer_ >reqID, < _string_ >path)
|
||||
|
||||
Respond using:
|
||||
|
||||
* `status()` - Use this to indicate success/failure of the removal of the
|
||||
file at `path`.
|
||||
|
||||
* **RMDIR**(< _integer_ >reqID, < _string_ >path)
|
||||
|
||||
Respond using:
|
||||
|
||||
* `status()` - Use this to indicate success/failure of the removal of the
|
||||
directory at `path`.
|
||||
|
||||
* **REALPATH**(< _integer_ >reqID, < _string_ >path)
|
||||
|
||||
Respond using one of the following:
|
||||
|
||||
* `name()` - Use this to respond with a normalized version of `path`.
|
||||
No file/directory attributes are required to be sent in this response.
|
||||
|
||||
* `status()` - Use this to indicate a failure in normalizing `path`.
|
||||
|
||||
* **READLINK**(< _integer_ >reqID, < _string_ >path)
|
||||
|
||||
Respond using one of the following:
|
||||
|
||||
* `name()` - Use this to respond with the target of the symlink at `path`.
|
||||
No file/directory attributes are required to be sent in this response.
|
||||
|
||||
* `status()` - Use this to indicate a failure in reading the symlink at
|
||||
`path`.
|
||||
|
||||
* **SETSTAT**(< _integer_ >reqID, < _string_ >path, < _ATTRS_ >attrs)
|
||||
|
||||
Respond using:
|
||||
|
||||
* `status()` - Use this to indicates success/failure of the setting of the
|
||||
given file/directory attributes.
|
||||
|
||||
* **MKDIR**(< _integer_ >reqID, < _string_ >path, < _ATTRS_ >attrs)
|
||||
|
||||
Respond using:
|
||||
|
||||
* `status()` - Use this to indicate success/failure of the creation of the
|
||||
directory at `path`.
|
||||
|
||||
* **RENAME**(< _integer_ >reqID, < _string_ >oldPath, < _string_ >newPath)
|
||||
|
||||
Respond using:
|
||||
|
||||
* `status()` - Use this to indicate success/failure of the renaming of the
|
||||
file/directory at `oldPath` to `newPath`.
|
||||
|
||||
* **SYMLINK**(< _integer_ >reqID, < _string_ >linkPath, < _string_ >targetPath)
|
||||
|
||||
Respond using:
|
||||
|
||||
* `status()` - Use this to indicate success/failure of the symlink creation.
|
||||
|
||||
|
||||
Useful standalone data structures
|
||||
---------------------------------
|
||||
|
||||
* **STATUS_CODE** - _object_ - Contains the various status codes (for use especially with `status()`):
|
||||
|
||||
* `OK`
|
||||
|
||||
* `EOF`
|
||||
|
||||
* `NO_SUCH_FILE`
|
||||
|
||||
* `PERMISSION_DENIED`
|
||||
|
||||
* `FAILURE`
|
||||
|
||||
* `BAD_MESSAGE`
|
||||
|
||||
* `OP_UNSUPPORTED`
|
||||
|
||||
* **OPEN_MODE** - _object_ - Contains the various open file flags:
|
||||
|
||||
* `READ`
|
||||
|
||||
* `WRITE`
|
||||
|
||||
* `APPEND`
|
||||
|
||||
* `CREAT`
|
||||
|
||||
* `TRUNC`
|
||||
|
||||
* `EXCL`
|
||||
|
||||
|
||||
Useful standalone methods
|
||||
-------------------------
|
||||
|
||||
* **stringToFlags**(< _string_ >flagsStr) - _integer_ - Converts string flags (e.g. `'r'`, `'a+'`, etc.) to the appropriate `OPEN_MODE` flag mask. Returns `null` if conversion failed.
|
||||
|
||||
* **flagsToString**(< _integer_ >flagsMask) - _string_ - Converts flag mask (e.g. number containing `OPEN_MODE` values) to the appropriate string value. Returns `null` if conversion failed.
|
||||
|
||||
|
||||
SFTP methods
|
||||
------------
|
||||
|
||||
* **(constructor)**(< _object_ >config[, < _string_ >remoteIdentRaw]) - Creates and returns a new SFTP instance. `remoteIdentRaw` can be the raw SSH identification string of the remote party. This is used to change internal behavior based on particular SFTP implementations. `config` can contain:
|
||||
|
||||
* **server** - _boolean_ - Set to `true` to create an instance in server mode. **Default:** `false`
|
||||
|
||||
* **debug** - _function_ - Set this to a function that receives a single string argument to get detailed (local) debug information. **Default:** (none)
|
||||
|
||||
|
||||
|
||||
**Client-only methods**
|
||||
|
||||
* **fastGet**(< _string_ >remotePath, < _string_ >localPath[, < _object_ >options], < _function_ >callback) - _(void)_ - Downloads a file at `remotePath` to `localPath` using parallel reads for faster throughput. `options` can have the following properties:
|
||||
|
||||
* **concurrency** - _integer_ - Number of concurrent reads **Default:** `64`
|
||||
|
||||
* **chunkSize** - _integer_ - Size of each read in bytes **Default:** `32768`
|
||||
|
||||
* **step** - _function_(< _integer_ >total_transferred, < _integer_ >chunk, < _integer_ >total) - Called every time a part of a file was transferred
|
||||
|
||||
`callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **fastPut**(< _string_ >localPath, < _string_ >remotePath[, < _object_ >options], < _function_ >callback) - _(void)_ - Uploads a file from `localPath` to `remotePath` using parallel reads for faster throughput. `options` can have the following properties:
|
||||
|
||||
* **concurrency** - _integer_ - Number of concurrent reads **Default:** `64`
|
||||
|
||||
* **chunkSize** - _integer_ - Size of each read in bytes **Default:** `32768`
|
||||
|
||||
* **step** - _function_(< _integer_ >total_transferred, < _integer_ >chunk, < _integer_ >total) - Called every time a part of a file was transferred
|
||||
|
||||
* **mode** - _mixed_ - Integer or string representing the file mode to set for the uploaded file.
|
||||
|
||||
`callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **createReadStream**(< _string_ >path[, < _object_ >options]) - _ReadStream_ - Returns a new readable stream for `path`. `options` has the following defaults:
|
||||
|
||||
```javascript
|
||||
{ flags: 'r',
|
||||
encoding: null,
|
||||
handle: null,
|
||||
mode: 0o666,
|
||||
autoClose: true
|
||||
}
|
||||
```
|
||||
|
||||
`options` can include `start` and `end` values to read a range of bytes from the file instead of the entire file. Both `start` and `end` are inclusive and start at 0. The `encoding` can be `'utf8'`, `'ascii'`, or `'base64'`.
|
||||
|
||||
If `autoClose` is false, then the file handle won't be closed, even if there's an error. It is your responsibility to close it and make sure there's no file handle leak. If `autoClose` is set to true (default behavior), on `error` or `end` the file handle will be closed automatically.
|
||||
|
||||
An example to read the last 10 bytes of a file which is 100 bytes long:
|
||||
|
||||
```javascript
|
||||
sftp.createReadStream('sample.txt', {start: 90, end: 99});
|
||||
```
|
||||
|
||||
* **createWriteStream**(< _string_ >path[, < _object_ >options]) - _WriteStream_ - Returns a new writable stream for `path`. `options` has the following defaults:
|
||||
|
||||
```javascript
|
||||
{
|
||||
flags: 'w',
|
||||
encoding: null,
|
||||
mode: 0o666,
|
||||
autoClose: true
|
||||
}
|
||||
```
|
||||
|
||||
`options` may also include a `start` option to allow writing data at some position past the beginning of the file. Modifying a file rather than replacing it may require a flags mode of 'r+' rather than the default mode 'w'.
|
||||
|
||||
If 'autoClose' is set to false and you pipe to this stream, this stream will not automatically close after there is no more data upstream -- allowing future pipes and/or manual writes.
|
||||
|
||||
* **open**(< _string_ >filename, < _string_ >flags, [< _mixed_ >attrs_mode, ]< _function_ >callback) - _(void)_ - Opens a file `filename` with `flags` with optional _ATTRS_ object or file mode `attrs_mode`. `flags` is any of the flags supported by `fs.open` (except sync flag). `callback` has 2 parameters: < _Error_ >err, < _Buffer_ >handle.
|
||||
|
||||
* **close**(< _Buffer_ >handle, < _function_ >callback) - _(void)_ - Closes the resource associated with `handle` given by open() or opendir(). `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **read**(< _Buffer_ >handle, < _Buffer_ >buffer, < _integer_ >offset, < _integer_ >length, < _integer_ >position, < _function_ >callback) - _(void)_ - Reads `length` bytes from the resource associated with `handle` starting at `position` and stores the bytes in `buffer` starting at `offset`. `callback` has 4 parameters: < _Error_ >err, < _integer_ >bytesRead, < _Buffer_ >buffer (offset adjusted), < _integer_ >position.
|
||||
|
||||
* **write**(< _Buffer_ >handle, < _Buffer_ >buffer, < _integer_ >offset, < _integer_ >length, < _integer_ >position, < _function_ >callback) - _(void)_ - Writes `length` bytes from `buffer` starting at `offset` to the resource associated with `handle` starting at `position`. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **fstat**(< _Buffer_ >handle, < _function_ >callback) - _(void)_ - Retrieves attributes for the resource associated with `handle`. `callback` has 2 parameters: < _Error_ >err, < _Stats_ >stats.
|
||||
|
||||
* **fsetstat**(< _Buffer_ >handle, < _ATTRS_ >attributes, < _function_ >callback) - _(void)_ - Sets the attributes defined in `attributes` for the resource associated with `handle`. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **futimes**(< _Buffer_ >handle, < _mixed_ >atime, < _mixed_ >mtime, < _function_ >callback) - _(void)_ - Sets the access time and modified time for the resource associated with `handle`. `atime` and `mtime` can be Date instances or UNIX timestamps. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **fchown**(< _Buffer_ >handle, < _integer_ >uid, < _integer_ >gid, < _function_ >callback) - _(void)_ - Sets the owner for the resource associated with `handle`. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **fchmod**(< _Buffer_ >handle, < _mixed_ >mode, < _function_ >callback) - _(void)_ - Sets the mode for the resource associated with `handle`. `mode` can be an integer or a string containing an octal number. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **opendir**(< _string_ >path, < _function_ >callback) - _(void)_ - Opens a directory `path`. `callback` has 2 parameters: < _Error_ >err, < _Buffer_ >handle.
|
||||
|
||||
* **readdir**(< _mixed_ >location, < _function_ >callback) - _(void)_ - Retrieves a directory listing. `location` can either be a _Buffer_ containing a valid directory handle from opendir() or a _string_ containing the path to a directory. `callback` has 2 parameters: < _Error_ >err, < _mixed_ >list. `list` is an _Array_ of `{ filename: 'foo', longname: '....', attrs: {...} }` style objects (attrs is of type _ATTR_). If `location` is a directory handle, this function may need to be called multiple times until `list` is boolean false, which indicates that no more directory entries are available for that directory handle.
|
||||
|
||||
* **unlink**(< _string_ >path, < _function_ >callback) - _(void)_ - Removes the file/symlink at `path`. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **rename**(< _string_ >srcPath, < _string_ >destPath, < _function_ >callback) - _(void)_ - Renames/moves `srcPath` to `destPath`. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **mkdir**(< _string_ >path, [< _ATTRS_ >attributes, ]< _function_ >callback) - _(void)_ - Creates a new directory `path`. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **rmdir**(< _string_ >path, < _function_ >callback) - _(void)_ - Removes the directory at `path`. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **stat**(< _string_ >path, < _function_ >callback) - _(void)_ - Retrieves attributes for `path`. `callback` has 2 parameter: < _Error_ >err, < _Stats_ >stats.
|
||||
|
||||
* **lstat**(< _string_ >path, < _function_ >callback) - _(void)_ - Retrieves attributes for `path`. If `path` is a symlink, the link itself is stat'ed instead of the resource it refers to. `callback` has 2 parameters: < _Error_ >err, < _Stats_ >stats.
|
||||
|
||||
* **setstat**(< _string_ >path, < _ATTRS_ >attributes, < _function_ >callback) - _(void)_ - Sets the attributes defined in `attributes` for `path`. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **utimes**(< _string_ >path, < _mixed_ >atime, < _mixed_ >mtime, < _function_ >callback) - _(void)_ - Sets the access time and modified time for `path`. `atime` and `mtime` can be Date instances or UNIX timestamps. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **chown**(< _string_ >path, < _integer_ >uid, < _integer_ >gid, < _function_ >callback) - _(void)_ - Sets the owner for `path`. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **chmod**(< _string_ >path, < _mixed_ >mode, < _function_ >callback) - _(void)_ - Sets the mode for `path`. `mode` can be an integer or a string containing an octal number. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **readlink**(< _string_ >path, < _function_ >callback) - _(void)_ - Retrieves the target for a symlink at `path`. `callback` has 2 parameters: < _Error_ >err, < _string_ >target.
|
||||
|
||||
* **symlink**(< _string_ >targetPath, < _string_ >linkPath, < _function_ >callback) - _(void)_ - Creates a symlink at `linkPath` to `targetPath`. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **realpath**(< _string_ >path, < _function_ >callback) - _(void)_ - Resolves `path` to an absolute path. `callback` has 2 parameters: < _Error_ >err, < _string_ >absPath.
|
||||
|
||||
* **ext_openssh_rename**(< _string_ >srcPath, < _string_ >destPath, < _function_ >callback) - _(void)_ - **OpenSSH extension** Performs POSIX rename(3) from `srcPath` to `destPath`. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **ext_openssh_statvfs**(< _string_ >path, < _function_ >callback) - _(void)_ - **OpenSSH extension** Performs POSIX statvfs(2) on `path`. `callback` has 2 parameters: < _Error_ >err, < _object_ >fsInfo. `fsInfo` contains the information as found in the [statvfs struct](http://linux.die.net/man/2/statvfs).
|
||||
|
||||
* **ext_openssh_fstatvfs**(< _Buffer_ >handle, < _function_ >callback) - _(void)_ - **OpenSSH extension** Performs POSIX fstatvfs(2) on open handle `handle`. `callback` has 2 parameters: < _Error_ >err, < _object_ >fsInfo. `fsInfo` contains the information as found in the [statvfs struct](http://linux.die.net/man/2/statvfs).
|
||||
|
||||
* **ext_openssh_hardlink**(< _string_ >targetPath, < _string_ >linkPath, < _function_ >callback) - _(void)_ - **OpenSSH extension** Performs POSIX link(2) to create a hard link to `targetPath` at `linkPath`. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **ext_openssh_fsync**(< _Buffer_ >handle, < _function_ >callback) - _(void)_ - **OpenSSH extension** Performs POSIX fsync(3) on the open handle `handle`. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **ext_openssh_lsetstat**(< _string_ >path, < _ATTRS_ >attributes, < _function_ >callback) - _(void)_ - **OpenSSH extension** Similar to `setstat()`, but instead sets attributes on symlinks. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **ext_openssh_expandPath**(< _string_ >path, < _function_ >callback) - _(void)_ - **OpenSSH extension** Similar to `realpath()`, but supports tilde-expansion, i.e. "\~", "\~/..." and "\~user/...". These paths are expanded using shell-like rules. `callback` has 2 parameters: < _Error_ >err, < _string_ >expandedPath.
|
||||
|
||||
* **ext_copy_data**(< _Buffer_ >srcHandle, < _number_ >srcOffset, < _number_ >length, < _Buffer_ >dstHandle, < _number_ >dstOffset, < _function_ >callback) - _(void)_ - Performs a remote file copy. If `length` is 0, then the server will read from `srcHandle` until EOF is reached. `callback` has 1 parameter: < _Error_ >err.
|
||||
|
||||
* **ext_home_dir**(< _string_ >username, < _function_ >callback) - _(void)_ - Retrieves the home directory of the user identified by `username`. Use an empty string to refer to the current user. `callback` has 2 parameters: < _Error_ >err, < _string_ >homeDirectory.
|
||||
|
||||
* **ext_users_groups**(< _array_ >uids, < _array_ >gids, < _function_ >callback) - _(void)_ - Retrieves the user names and group names associated with the user IDs in `uids` and group IDs in `gids` respectively. Either array can be empty or contain one or more 32-bit unsigned integers. The retrieved user names and group names match the same order as the IDs in `uids` and `gids` respectively. If the server was unable to find a name for a given ID, it will use an empty string. `callback` has 3 parameters: < _Error_ >err, < _array_ >userNames, < _array_ >groupNames.
|
||||
|
||||
|
||||
**Server-only methods**
|
||||
|
||||
* **status**(< _integer_ >reqID, < _integer_ >statusCode[, < _string_ >message]) - _(void)_ - Sends a status response for the request identified by `id`.
|
||||
|
||||
* **handle**(< _integer_ >reqID, < _Buffer_ >handle) - _(void)_ - Sends a handle response for the request identified by `id`. `handle` must be less than 256 bytes and is an opaque value that could merely contain the value of a backing file descriptor or some other unique, custom value.
|
||||
|
||||
* **data**(< _integer_ >reqID, < _mixed_ >data[, < _string_ >encoding]) - _(void)_ - Sends a data response for the request identified by `id`. `data` can be a _Buffer_ or _string_. If `data` is a string, `encoding` is the encoding of `data`.
|
||||
|
||||
* **name**(< _integer_ >reqID, < _array_ >names) - _(void)_ - Sends a name response for the request identified by `id`. `names` must be an _array_ of _object_ where each _object_ can contain:
|
||||
|
||||
* **filename** - _string_ - The entry's name.
|
||||
|
||||
* **longname** - _string_ - This is the `ls -l`-style format for the entry (e.g. `-rwxr--r-- 1 bar bar 718 Dec 8 2009 foo`)
|
||||
|
||||
* **attrs** - _ATTRS_ - This is an optional _ATTRS_ object that contains requested/available attributes for the entry.
|
||||
|
||||
* **attrs**(< _integer_ >reqID, < _ATTRS_ >attrs) - _(void)_ - Sends an attrs response for the request identified by `id`. `attrs` contains the requested/available attributes.
|
||||
|
||||
|
||||
ATTRS
|
||||
-----
|
||||
|
||||
An object with the following valid properties:
|
||||
|
||||
* **mode** - _integer_ - Mode/permissions for the resource.
|
||||
|
||||
* **uid** - _integer_ - User ID of the resource.
|
||||
|
||||
* **gid** - _integer_ - Group ID of the resource.
|
||||
|
||||
* **size** - _integer_ - Resource size in bytes.
|
||||
|
||||
* **atime** - _integer_ - UNIX timestamp of the access time of the resource.
|
||||
|
||||
* **mtime** - _integer_ - UNIX timestamp of the modified time of the resource.
|
||||
|
||||
When supplying an ATTRS object to one of the SFTP methods:
|
||||
|
||||
* `atime` and `mtime` can be either a Date instance or a UNIX timestamp.
|
||||
|
||||
* `mode` can either be an integer or a string containing an octal number.
|
||||
|
||||
|
||||
Stats
|
||||
-----
|
||||
|
||||
An object with the same attributes as an ATTRS object with the addition of the following methods:
|
||||
|
||||
* `stats.isDirectory()`
|
||||
|
||||
* `stats.isFile()`
|
||||
|
||||
* `stats.isBlockDevice()`
|
||||
|
||||
* `stats.isCharacterDevice()`
|
||||
|
||||
* `stats.isSymbolicLink()`
|
||||
|
||||
* `stats.isFIFO()`
|
||||
|
||||
* `stats.isSocket()`
|
||||
238
tasks/enduro-trails/prototype/node_modules/ssh2/examples/server-chat.js
generated
vendored
Normal file
238
tasks/enduro-trails/prototype/node_modules/ssh2/examples/server-chat.js
generated
vendored
Normal file
@@ -0,0 +1,238 @@
|
||||
// **BEFORE RUNNING THIS SCRIPT:**
|
||||
// 1. The server portion is best run on non-Windows systems because they have
|
||||
// terminfo databases which are needed to properly work with different
|
||||
// terminal types of client connections
|
||||
// 2. Install `blessed`: `npm install blessed`
|
||||
// 3. Create a server host key in this same directory and name it `host.key`
|
||||
'use strict';
|
||||
|
||||
const { readFileSync } = require('fs');
|
||||
|
||||
const blessed = require('blessed');
|
||||
const { Server } = require('ssh2');
|
||||
|
||||
const RE_SPECIAL =
|
||||
// eslint-disable-next-line no-control-regex
|
||||
/[\x00-\x1F\x7F]+|(?:\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K])/g;
|
||||
const MAX_MSG_LEN = 128;
|
||||
const MAX_NAME_LEN = 10;
|
||||
const PROMPT_NAME = `Enter a nickname to use (max ${MAX_NAME_LEN} chars): `;
|
||||
|
||||
const users = [];
|
||||
|
||||
function formatMessage(msg, output) {
|
||||
output.parseTags = true;
|
||||
msg = output._parseTags(msg);
|
||||
output.parseTags = false;
|
||||
return msg;
|
||||
}
|
||||
|
||||
function userBroadcast(msg, source) {
|
||||
const sourceMsg = `> ${msg}`;
|
||||
const name = `{cyan-fg}{bold}${source.name}{/}`;
|
||||
msg = `: ${msg}`;
|
||||
for (const user of users) {
|
||||
const output = user.output;
|
||||
if (source === user)
|
||||
output.add(sourceMsg);
|
||||
else
|
||||
output.add(formatMessage(name, output) + msg);
|
||||
}
|
||||
}
|
||||
|
||||
function localMessage(msg, source) {
|
||||
const output = source.output;
|
||||
output.add(formatMessage(msg, output));
|
||||
}
|
||||
|
||||
function noop(v) {}
|
||||
|
||||
new Server({
|
||||
hostKeys: [readFileSync('host.key')],
|
||||
}, (client) => {
|
||||
let stream;
|
||||
let name;
|
||||
|
||||
client.on('authentication', (ctx) => {
|
||||
let nick = ctx.username;
|
||||
let prompt = PROMPT_NAME;
|
||||
let lowered;
|
||||
|
||||
// Try to use username as nickname
|
||||
if (nick.length > 0 && nick.length <= MAX_NAME_LEN) {
|
||||
lowered = nick.toLowerCase();
|
||||
let ok = true;
|
||||
for (const user of users) {
|
||||
if (user.name.toLowerCase() === lowered) {
|
||||
ok = false;
|
||||
prompt = `That nickname is already in use.\n${PROMPT_NAME}`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
name = nick;
|
||||
return ctx.accept();
|
||||
}
|
||||
} else if (nick.length === 0) {
|
||||
prompt = 'A nickname is required.\n' + PROMPT_NAME;
|
||||
} else {
|
||||
prompt = 'That nickname is too long.\n' + PROMPT_NAME;
|
||||
}
|
||||
|
||||
if (ctx.method !== 'keyboard-interactive')
|
||||
return ctx.reject(['keyboard-interactive']);
|
||||
|
||||
ctx.prompt(prompt, function retryPrompt(answers) {
|
||||
if (answers.length === 0)
|
||||
return ctx.reject(['keyboard-interactive']);
|
||||
nick = answers[0];
|
||||
if (nick.length > MAX_NAME_LEN) {
|
||||
return ctx.prompt(`That nickname is too long.\n${PROMPT_NAME}`,
|
||||
retryPrompt);
|
||||
} else if (nick.length === 0) {
|
||||
return ctx.prompt(`A nickname is required.\n${PROMPT_NAME}`,
|
||||
retryPrompt);
|
||||
}
|
||||
lowered = nick.toLowerCase();
|
||||
for (const user of users) {
|
||||
if (user.name.toLowerCase() === lowered) {
|
||||
return ctx.prompt(`That nickname is already in use.\n${PROMPT_NAME}`,
|
||||
retryPrompt);
|
||||
}
|
||||
}
|
||||
name = nick;
|
||||
ctx.accept();
|
||||
});
|
||||
}).on('ready', () => {
|
||||
let rows;
|
||||
let cols;
|
||||
let term;
|
||||
client.once('session', (accept, reject) => {
|
||||
accept().once('pty', (accept, reject, info) => {
|
||||
rows = info.rows;
|
||||
cols = info.cols;
|
||||
term = info.term;
|
||||
accept && accept();
|
||||
}).on('window-change', (accept, reject, info) => {
|
||||
rows = info.rows;
|
||||
cols = info.cols;
|
||||
if (stream) {
|
||||
stream.rows = rows;
|
||||
stream.columns = cols;
|
||||
stream.emit('resize');
|
||||
}
|
||||
accept && accept();
|
||||
}).once('shell', (accept, reject) => {
|
||||
stream = accept();
|
||||
users.push(stream);
|
||||
|
||||
stream.name = name;
|
||||
stream.rows = rows || 24;
|
||||
stream.columns = cols || 80;
|
||||
stream.isTTY = true;
|
||||
stream.setRawMode = noop;
|
||||
stream.on('error', noop);
|
||||
|
||||
const screen = new blessed.screen({
|
||||
autoPadding: true,
|
||||
smartCSR: true,
|
||||
program: new blessed.program({
|
||||
input: stream,
|
||||
output: stream
|
||||
}),
|
||||
terminal: term || 'ansi'
|
||||
});
|
||||
|
||||
screen.title = 'SSH Chatting as ' + name;
|
||||
// Disable local echo
|
||||
screen.program.attr('invisible', true);
|
||||
|
||||
const output = stream.output = new blessed.log({
|
||||
screen: screen,
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: '100%',
|
||||
bottom: 2,
|
||||
scrollOnInput: true
|
||||
});
|
||||
screen.append(output);
|
||||
|
||||
screen.append(new blessed.box({
|
||||
screen: screen,
|
||||
height: 1,
|
||||
bottom: 1,
|
||||
left: 0,
|
||||
width: '100%',
|
||||
type: 'line',
|
||||
ch: '='
|
||||
}));
|
||||
|
||||
const input = new blessed.textbox({
|
||||
screen: screen,
|
||||
bottom: 0,
|
||||
height: 1,
|
||||
width: '100%',
|
||||
inputOnFocus: true
|
||||
});
|
||||
screen.append(input);
|
||||
|
||||
input.focus();
|
||||
|
||||
// Local greetings
|
||||
localMessage('{blue-bg}{white-fg}{bold}Welcome to SSH Chat!{/}\n'
|
||||
+ 'There are {bold}'
|
||||
+ (users.length - 1)
|
||||
+ '{/} other user(s) connected.\n'
|
||||
+ 'Type /quit or /exit to exit the chat.',
|
||||
stream);
|
||||
|
||||
// Let everyone else know that this user just joined
|
||||
for (const user of users) {
|
||||
const output = user.output;
|
||||
if (user === stream)
|
||||
continue;
|
||||
output.add(formatMessage('{green-fg}*** {bold}', output)
|
||||
+ name
|
||||
+ formatMessage('{/bold} has joined the chat{/}', output));
|
||||
}
|
||||
|
||||
screen.render();
|
||||
// XXX This fake resize event is needed for some terminals in order to
|
||||
// have everything display correctly
|
||||
screen.program.emit('resize');
|
||||
|
||||
// Read a line of input from the user
|
||||
input.on('submit', (line) => {
|
||||
input.clearValue();
|
||||
screen.render();
|
||||
if (!input.focused)
|
||||
input.focus();
|
||||
line = line.replace(RE_SPECIAL, '').trim();
|
||||
if (line.length > MAX_MSG_LEN)
|
||||
line = line.substring(0, MAX_MSG_LEN);
|
||||
if (line.length > 0) {
|
||||
if (line === '/quit' || line === '/exit')
|
||||
stream.end();
|
||||
else
|
||||
userBroadcast(line, stream);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}).on('close', () => {
|
||||
if (stream !== undefined) {
|
||||
users.splice(users.indexOf(stream), 1);
|
||||
// Let everyone else know that this user just left
|
||||
for (const user of users) {
|
||||
const output = user.output;
|
||||
output.add(formatMessage('{magenta-fg}*** {bold}', output)
|
||||
+ name
|
||||
+ formatMessage('{/bold} has left the chat{/}', output));
|
||||
}
|
||||
}
|
||||
}).on('error', (err) => {
|
||||
// Ignore errors
|
||||
});
|
||||
}).listen(0, function() {
|
||||
console.log('Listening on port ' + this.address().port);
|
||||
});
|
||||
134
tasks/enduro-trails/prototype/node_modules/ssh2/examples/sftp-server-download-only.js
generated
vendored
Normal file
134
tasks/enduro-trails/prototype/node_modules/ssh2/examples/sftp-server-download-only.js
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
'use strict';
|
||||
|
||||
const { timingSafeEqual } = require('crypto');
|
||||
const { constants, readFileSync } = require('fs');
|
||||
|
||||
const { Server, sftp: { OPEN_MODE, STATUS_CODE } } = require('ssh2');
|
||||
|
||||
const allowedUser = Buffer.from('foo');
|
||||
const allowedPassword = Buffer.from('bar');
|
||||
|
||||
function checkValue(input, allowed) {
|
||||
const autoReject = (input.length !== allowed.length);
|
||||
if (autoReject) {
|
||||
// Prevent leaking length information by always making a comparison with the
|
||||
// same input when lengths don't match what we expect ...
|
||||
allowed = input;
|
||||
}
|
||||
const isMatch = timingSafeEqual(input, allowed);
|
||||
return (!autoReject && isMatch);
|
||||
}
|
||||
|
||||
new Server({
|
||||
hostKeys: [readFileSync('host.key')]
|
||||
}, (client) => {
|
||||
console.log('Client connected!');
|
||||
|
||||
client.on('authentication', (ctx) => {
|
||||
let allowed = true;
|
||||
if (!checkValue(Buffer.from(ctx.username), allowedUser))
|
||||
allowed = false;
|
||||
|
||||
switch (ctx.method) {
|
||||
case 'password':
|
||||
if (!checkValue(Buffer.from(ctx.password), allowedPassword))
|
||||
return ctx.reject();
|
||||
break;
|
||||
default:
|
||||
return ctx.reject();
|
||||
}
|
||||
|
||||
if (allowed)
|
||||
ctx.accept();
|
||||
else
|
||||
ctx.reject();
|
||||
}).on('ready', () => {
|
||||
console.log('Client authenticated!');
|
||||
|
||||
client.on('session', (accept, reject) => {
|
||||
const session = accept();
|
||||
session.on('sftp', (accept, reject) => {
|
||||
console.log('Client SFTP session');
|
||||
|
||||
const openFiles = new Map();
|
||||
let handleCount = 0;
|
||||
const sftp = accept();
|
||||
sftp.on('OPEN', (reqid, filename, flags, attrs) => {
|
||||
// Only allow opening /tmp/foo.txt for writing
|
||||
if (filename !== '/tmp/foo.txt' || !(flags & OPEN_MODE.READ))
|
||||
return sftp.status(reqid, STATUS_CODE.FAILURE);
|
||||
|
||||
// Create a fake handle to return to the client, this could easily
|
||||
// be a real file descriptor number for example if actually opening
|
||||
// the file on the disk
|
||||
const handle = Buffer.alloc(4);
|
||||
openFiles.set(handleCount, { read: false });
|
||||
handle.writeUInt32BE(handleCount++, 0, true);
|
||||
|
||||
console.log('Opening file for read');
|
||||
sftp.handle(reqid, handle);
|
||||
}).on('READ', (reqid, handle, offset, length) => {
|
||||
let fnum;
|
||||
if (handle.length !== 4
|
||||
|| !openFiles.has(fnum = handle.readUInt32BE(0, true))) {
|
||||
return sftp.status(reqid, STATUS_CODE.FAILURE);
|
||||
}
|
||||
|
||||
// Fake the read
|
||||
const state = openFiles.get(fnum);
|
||||
if (state.read) {
|
||||
sftp.status(reqid, STATUS_CODE.EOF);
|
||||
} else {
|
||||
state.read = true;
|
||||
|
||||
console.log(
|
||||
'Read from file at offset %d, length %d', offset, length
|
||||
);
|
||||
sftp.data(reqid, 'bar');
|
||||
}
|
||||
}).on('CLOSE', (reqid, handle) => {
|
||||
let fnum;
|
||||
if (handle.length !== 4
|
||||
|| !openFiles.has(fnum = handle.readUInt32BE(0))) {
|
||||
return sftp.status(reqid, STATUS_CODE.FAILURE);
|
||||
}
|
||||
|
||||
openFiles.delete(fnum);
|
||||
|
||||
console.log('Closing file');
|
||||
sftp.status(reqid, STATUS_CODE.OK);
|
||||
}).on('REALPATH', function(reqid, path) {
|
||||
const name = [{
|
||||
filename: '/tmp/foo.txt',
|
||||
longname: '-rwxrwxrwx 1 foo foo 3 Dec 8 2009 foo.txt',
|
||||
attrs: {}
|
||||
}];
|
||||
sftp.name(reqid, name);
|
||||
}).on('STAT', onSTAT)
|
||||
.on('LSTAT', onSTAT);
|
||||
|
||||
function onSTAT(reqid, path) {
|
||||
if (path !== '/tmp/foo.txt')
|
||||
return sftp.status(reqid, STATUS_CODE.FAILURE);
|
||||
|
||||
let mode = constants.S_IFREG; // Regular file
|
||||
mode |= constants.S_IRWXU; // Read, write, execute for user
|
||||
mode |= constants.S_IRWXG; // Read, write, execute for group
|
||||
mode |= constants.S_IRWXO; // Read, write, execute for other
|
||||
sftp.attrs(reqid, {
|
||||
mode: mode,
|
||||
uid: 0,
|
||||
gid: 0,
|
||||
size: 3,
|
||||
atime: Date.now(),
|
||||
mtime: Date.now(),
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}).on('close', () => {
|
||||
console.log('Client disconnected');
|
||||
});
|
||||
}).listen(0, '127.0.0.1', function() {
|
||||
console.log(`Listening on port ${this.address().port}`);
|
||||
});
|
||||
27
tasks/enduro-trails/prototype/node_modules/ssh2/install.js
generated
vendored
Normal file
27
tasks/enduro-trails/prototype/node_modules/ssh2/install.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const forceFailOnNonZero = (process.env.CI_CHECK_FAIL === 'ssh2');
|
||||
|
||||
// Attempt to build the bundled optional binding
|
||||
const args = [
|
||||
`--target=${process.version}`,
|
||||
`--real_openssl_major=${/^\d+/.exec(process.versions.openssl)[0]}`,
|
||||
'rebuild',
|
||||
];
|
||||
const result = spawnSync('node-gyp', args, {
|
||||
cwd: 'lib/protocol/crypto',
|
||||
encoding: 'utf8',
|
||||
shell: true,
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
});
|
||||
if (result.error || result.status !== 0) {
|
||||
console.log('Failed to build optional crypto binding');
|
||||
if (forceFailOnNonZero)
|
||||
process.exit(1);
|
||||
} else {
|
||||
console.log('Succeeded in building optional crypto binding');
|
||||
}
|
||||
process.exit(0);
|
||||
295
tasks/enduro-trails/prototype/node_modules/ssh2/lib/Channel.js
generated
vendored
Normal file
295
tasks/enduro-trails/prototype/node_modules/ssh2/lib/Channel.js
generated
vendored
Normal file
@@ -0,0 +1,295 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
Duplex: DuplexStream,
|
||||
Readable: ReadableStream,
|
||||
Writable: WritableStream,
|
||||
} = require('stream');
|
||||
|
||||
const {
|
||||
CHANNEL_EXTENDED_DATATYPE: { STDERR },
|
||||
} = require('./protocol/constants.js');
|
||||
const { bufferSlice } = require('./protocol/utils.js');
|
||||
|
||||
const PACKET_SIZE = 32 * 1024;
|
||||
const MAX_WINDOW = 2 * 1024 * 1024;
|
||||
const WINDOW_THRESHOLD = MAX_WINDOW / 2;
|
||||
|
||||
class ClientStderr extends ReadableStream {
|
||||
constructor(channel, streamOpts) {
|
||||
super(streamOpts);
|
||||
|
||||
this._channel = channel;
|
||||
}
|
||||
_read(n) {
|
||||
if (this._channel._waitChanDrain) {
|
||||
this._channel._waitChanDrain = false;
|
||||
if (this._channel.incoming.window <= WINDOW_THRESHOLD)
|
||||
windowAdjust(this._channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ServerStderr extends WritableStream {
|
||||
constructor(channel) {
|
||||
super({ highWaterMark: MAX_WINDOW });
|
||||
|
||||
this._channel = channel;
|
||||
}
|
||||
|
||||
_write(data, encoding, cb) {
|
||||
const channel = this._channel;
|
||||
const protocol = channel._client._protocol;
|
||||
const outgoing = channel.outgoing;
|
||||
const packetSize = outgoing.packetSize;
|
||||
const id = outgoing.id;
|
||||
let window = outgoing.window;
|
||||
const len = data.length;
|
||||
let p = 0;
|
||||
|
||||
if (outgoing.state !== 'open')
|
||||
return;
|
||||
|
||||
while (len - p > 0 && window > 0) {
|
||||
let sliceLen = len - p;
|
||||
if (sliceLen > window)
|
||||
sliceLen = window;
|
||||
if (sliceLen > packetSize)
|
||||
sliceLen = packetSize;
|
||||
|
||||
if (p === 0 && sliceLen === len)
|
||||
protocol.channelExtData(id, data, STDERR);
|
||||
else
|
||||
protocol.channelExtData(id, bufferSlice(data, p, p + sliceLen), STDERR);
|
||||
|
||||
p += sliceLen;
|
||||
window -= sliceLen;
|
||||
}
|
||||
|
||||
outgoing.window = window;
|
||||
|
||||
if (len - p > 0) {
|
||||
if (window === 0)
|
||||
channel._waitWindow = true;
|
||||
if (p > 0)
|
||||
channel._chunkErr = bufferSlice(data, p, len);
|
||||
else
|
||||
channel._chunkErr = data;
|
||||
channel._chunkcbErr = cb;
|
||||
return;
|
||||
}
|
||||
|
||||
cb();
|
||||
}
|
||||
}
|
||||
|
||||
class Channel extends DuplexStream {
|
||||
constructor(client, info, opts) {
|
||||
const streamOpts = {
|
||||
highWaterMark: MAX_WINDOW,
|
||||
allowHalfOpen: (!opts || (opts && opts.allowHalfOpen !== false)),
|
||||
emitClose: false,
|
||||
};
|
||||
super(streamOpts);
|
||||
this.allowHalfOpen = streamOpts.allowHalfOpen;
|
||||
|
||||
const server = !!(opts && opts.server);
|
||||
|
||||
this.server = server;
|
||||
this.type = info.type;
|
||||
this.subtype = undefined;
|
||||
|
||||
/*
|
||||
incoming and outgoing contain these properties:
|
||||
{
|
||||
id: undefined,
|
||||
window: undefined,
|
||||
packetSize: undefined,
|
||||
state: 'closed'
|
||||
}
|
||||
*/
|
||||
this.incoming = info.incoming;
|
||||
this.outgoing = info.outgoing;
|
||||
this._callbacks = [];
|
||||
|
||||
this._client = client;
|
||||
this._hasX11 = false;
|
||||
this._exit = {
|
||||
code: undefined,
|
||||
signal: undefined,
|
||||
dump: undefined,
|
||||
desc: undefined,
|
||||
};
|
||||
|
||||
this.stdin = this.stdout = this;
|
||||
|
||||
if (server)
|
||||
this.stderr = new ServerStderr(this);
|
||||
else
|
||||
this.stderr = new ClientStderr(this, streamOpts);
|
||||
|
||||
// Outgoing data
|
||||
this._waitWindow = false; // SSH-level backpressure
|
||||
|
||||
// Incoming data
|
||||
this._waitChanDrain = false; // Channel Readable side backpressure
|
||||
|
||||
this._chunk = undefined;
|
||||
this._chunkcb = undefined;
|
||||
this._chunkErr = undefined;
|
||||
this._chunkcbErr = undefined;
|
||||
|
||||
this.on('finish', onFinish)
|
||||
.on('prefinish', onFinish); // For node v0.11+
|
||||
|
||||
this.on('end', onEnd).on('close', onEnd);
|
||||
}
|
||||
|
||||
_read(n) {
|
||||
if (this._waitChanDrain) {
|
||||
this._waitChanDrain = false;
|
||||
if (this.incoming.window <= WINDOW_THRESHOLD)
|
||||
windowAdjust(this);
|
||||
}
|
||||
}
|
||||
|
||||
_write(data, encoding, cb) {
|
||||
const protocol = this._client._protocol;
|
||||
const outgoing = this.outgoing;
|
||||
const packetSize = outgoing.packetSize;
|
||||
const id = outgoing.id;
|
||||
let window = outgoing.window;
|
||||
const len = data.length;
|
||||
let p = 0;
|
||||
|
||||
if (outgoing.state !== 'open')
|
||||
return;
|
||||
|
||||
while (len - p > 0 && window > 0) {
|
||||
let sliceLen = len - p;
|
||||
if (sliceLen > window)
|
||||
sliceLen = window;
|
||||
if (sliceLen > packetSize)
|
||||
sliceLen = packetSize;
|
||||
|
||||
if (p === 0 && sliceLen === len)
|
||||
protocol.channelData(id, data);
|
||||
else
|
||||
protocol.channelData(id, bufferSlice(data, p, p + sliceLen));
|
||||
|
||||
p += sliceLen;
|
||||
window -= sliceLen;
|
||||
}
|
||||
|
||||
outgoing.window = window;
|
||||
|
||||
if (len - p > 0) {
|
||||
if (window === 0)
|
||||
this._waitWindow = true;
|
||||
if (p > 0)
|
||||
this._chunk = bufferSlice(data, p, len);
|
||||
else
|
||||
this._chunk = data;
|
||||
this._chunkcb = cb;
|
||||
return;
|
||||
}
|
||||
|
||||
cb();
|
||||
}
|
||||
|
||||
eof() {
|
||||
if (this.outgoing.state === 'open') {
|
||||
this.outgoing.state = 'eof';
|
||||
this._client._protocol.channelEOF(this.outgoing.id);
|
||||
}
|
||||
}
|
||||
|
||||
close() {
|
||||
if (this.outgoing.state === 'open' || this.outgoing.state === 'eof') {
|
||||
this.outgoing.state = 'closing';
|
||||
this._client._protocol.channelClose(this.outgoing.id);
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.end();
|
||||
this.close();
|
||||
return this;
|
||||
}
|
||||
|
||||
// Session type-specific methods =============================================
|
||||
setWindow(rows, cols, height, width) {
|
||||
if (this.server)
|
||||
throw new Error('Client-only method called in server mode');
|
||||
|
||||
if (this.type === 'session'
|
||||
&& (this.subtype === 'shell' || this.subtype === 'exec')
|
||||
&& this.writable
|
||||
&& this.outgoing.state === 'open') {
|
||||
this._client._protocol.windowChange(this.outgoing.id,
|
||||
rows,
|
||||
cols,
|
||||
height,
|
||||
width);
|
||||
}
|
||||
}
|
||||
|
||||
signal(signalName) {
|
||||
if (this.server)
|
||||
throw new Error('Client-only method called in server mode');
|
||||
|
||||
if (this.type === 'session'
|
||||
&& this.writable
|
||||
&& this.outgoing.state === 'open') {
|
||||
this._client._protocol.signal(this.outgoing.id, signalName);
|
||||
}
|
||||
}
|
||||
|
||||
exit(statusOrSignal, coreDumped, msg) {
|
||||
if (!this.server)
|
||||
throw new Error('Server-only method called in client mode');
|
||||
|
||||
if (this.type === 'session'
|
||||
&& this.writable
|
||||
&& this.outgoing.state === 'open') {
|
||||
if (typeof statusOrSignal === 'number') {
|
||||
this._client._protocol.exitStatus(this.outgoing.id, statusOrSignal);
|
||||
} else {
|
||||
this._client._protocol.exitSignal(this.outgoing.id,
|
||||
statusOrSignal,
|
||||
coreDumped,
|
||||
msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onFinish() {
|
||||
this.eof();
|
||||
if (this.server || !this.allowHalfOpen)
|
||||
this.close();
|
||||
this.writable = false;
|
||||
}
|
||||
|
||||
function onEnd() {
|
||||
this.readable = false;
|
||||
}
|
||||
|
||||
function windowAdjust(self) {
|
||||
if (self.outgoing.state === 'closed')
|
||||
return;
|
||||
const amt = MAX_WINDOW - self.incoming.window;
|
||||
if (amt <= 0)
|
||||
return;
|
||||
self.incoming.window += amt;
|
||||
self._client._protocol.channelWindowAdjust(self.outgoing.id, amt);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Channel,
|
||||
MAX_WINDOW,
|
||||
PACKET_SIZE,
|
||||
windowAdjust,
|
||||
WINDOW_THRESHOLD,
|
||||
};
|
||||
1123
tasks/enduro-trails/prototype/node_modules/ssh2/lib/agent.js
generated
vendored
Normal file
1123
tasks/enduro-trails/prototype/node_modules/ssh2/lib/agent.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2176
tasks/enduro-trails/prototype/node_modules/ssh2/lib/client.js
generated
vendored
Normal file
2176
tasks/enduro-trails/prototype/node_modules/ssh2/lib/client.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
84
tasks/enduro-trails/prototype/node_modules/ssh2/lib/http-agents.js
generated
vendored
Normal file
84
tasks/enduro-trails/prototype/node_modules/ssh2/lib/http-agents.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
'use strict';
|
||||
|
||||
const { Agent: HttpAgent } = require('http');
|
||||
const { Agent: HttpsAgent } = require('https');
|
||||
const { connect: tlsConnect } = require('tls');
|
||||
|
||||
let Client;
|
||||
|
||||
for (const ctor of [HttpAgent, HttpsAgent]) {
|
||||
class SSHAgent extends ctor {
|
||||
constructor(connectCfg, agentOptions) {
|
||||
super(agentOptions);
|
||||
|
||||
this._connectCfg = connectCfg;
|
||||
this._defaultSrcIP = (agentOptions && agentOptions.srcIP) || 'localhost';
|
||||
}
|
||||
|
||||
createConnection(options, cb) {
|
||||
const srcIP = (options && options.localAddress) || this._defaultSrcIP;
|
||||
const srcPort = (options && options.localPort) || 0;
|
||||
const dstIP = options.host;
|
||||
const dstPort = options.port;
|
||||
|
||||
if (Client === undefined)
|
||||
Client = require('./client.js');
|
||||
|
||||
const client = new Client();
|
||||
let triedForward = false;
|
||||
client.on('ready', () => {
|
||||
client.forwardOut(srcIP, srcPort, dstIP, dstPort, (err, stream) => {
|
||||
triedForward = true;
|
||||
if (err) {
|
||||
client.end();
|
||||
return cb(err);
|
||||
}
|
||||
stream.once('close', () => client.end());
|
||||
cb(null, decorateStream(stream, ctor, options));
|
||||
});
|
||||
}).on('error', cb).on('close', () => {
|
||||
if (!triedForward)
|
||||
cb(new Error('Unexpected connection close'));
|
||||
}).connect(this._connectCfg);
|
||||
}
|
||||
}
|
||||
|
||||
exports[ctor === HttpAgent ? 'SSHTTPAgent' : 'SSHTTPSAgent'] = SSHAgent;
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
|
||||
function decorateStream(stream, ctor, options) {
|
||||
if (ctor === HttpAgent) {
|
||||
// HTTP
|
||||
stream.setKeepAlive = noop;
|
||||
stream.setNoDelay = noop;
|
||||
stream.setTimeout = noop;
|
||||
stream.ref = noop;
|
||||
stream.unref = noop;
|
||||
stream.destroySoon = stream.destroy;
|
||||
return stream;
|
||||
}
|
||||
|
||||
// HTTPS
|
||||
options.socket = stream;
|
||||
const wrapped = tlsConnect(options);
|
||||
|
||||
// This is a workaround for a regression in node v12.16.3+
|
||||
// https://github.com/nodejs/node/issues/35904
|
||||
const onClose = (() => {
|
||||
let called = false;
|
||||
return () => {
|
||||
if (called)
|
||||
return;
|
||||
called = true;
|
||||
if (stream.isPaused())
|
||||
stream.resume();
|
||||
};
|
||||
})();
|
||||
// 'end' listener is needed because 'close' is not emitted in some scenarios
|
||||
// in node v12.x for some unknown reason
|
||||
wrapped.on('end', onClose).on('close', onClose);
|
||||
|
||||
return wrapped;
|
||||
}
|
||||
44
tasks/enduro-trails/prototype/node_modules/ssh2/lib/index.js
generated
vendored
Normal file
44
tasks/enduro-trails/prototype/node_modules/ssh2/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
AgentProtocol,
|
||||
BaseAgent,
|
||||
createAgent,
|
||||
CygwinAgent,
|
||||
OpenSSHAgent,
|
||||
PageantAgent,
|
||||
} = require('./agent.js');
|
||||
const {
|
||||
SSHTTPAgent: HTTPAgent,
|
||||
SSHTTPSAgent: HTTPSAgent,
|
||||
} = require('./http-agents.js');
|
||||
const { parseKey } = require('./protocol/keyParser.js');
|
||||
const {
|
||||
flagsToString,
|
||||
OPEN_MODE,
|
||||
STATUS_CODE,
|
||||
stringToFlags,
|
||||
} = require('./protocol/SFTP.js');
|
||||
|
||||
module.exports = {
|
||||
AgentProtocol,
|
||||
BaseAgent,
|
||||
createAgent,
|
||||
Client: require('./client.js'),
|
||||
CygwinAgent,
|
||||
HTTPAgent,
|
||||
HTTPSAgent,
|
||||
OpenSSHAgent,
|
||||
PageantAgent,
|
||||
Server: require('./server.js'),
|
||||
utils: {
|
||||
parseKey,
|
||||
...require('./keygen.js'),
|
||||
sftp: {
|
||||
flagsToString,
|
||||
OPEN_MODE,
|
||||
STATUS_CODE,
|
||||
stringToFlags,
|
||||
},
|
||||
},
|
||||
};
|
||||
582
tasks/enduro-trails/prototype/node_modules/ssh2/lib/keygen.js
generated
vendored
Normal file
582
tasks/enduro-trails/prototype/node_modules/ssh2/lib/keygen.js
generated
vendored
Normal file
@@ -0,0 +1,582 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
createCipheriv,
|
||||
generateKeyPair: generateKeyPair_,
|
||||
generateKeyPairSync: generateKeyPairSync_,
|
||||
getCurves,
|
||||
randomBytes,
|
||||
} = require('crypto');
|
||||
|
||||
const { Ber } = require('asn1');
|
||||
const bcrypt_pbkdf = require('bcrypt-pbkdf').pbkdf;
|
||||
|
||||
const { CIPHER_INFO } = require('./protocol/crypto.js');
|
||||
|
||||
const SALT_LEN = 16;
|
||||
const DEFAULT_ROUNDS = 16;
|
||||
|
||||
const curves = getCurves();
|
||||
const ciphers = new Map(Object.entries(CIPHER_INFO));
|
||||
|
||||
function makeArgs(type, opts) {
|
||||
if (typeof type !== 'string')
|
||||
throw new TypeError('Key type must be a string');
|
||||
|
||||
const publicKeyEncoding = { type: 'spki', format: 'der' };
|
||||
const privateKeyEncoding = { type: 'pkcs8', format: 'der' };
|
||||
|
||||
switch (type.toLowerCase()) {
|
||||
case 'rsa': {
|
||||
if (typeof opts !== 'object' || opts === null)
|
||||
throw new TypeError('Missing options object for RSA key');
|
||||
const modulusLength = opts.bits;
|
||||
if (!Number.isInteger(modulusLength))
|
||||
throw new TypeError('RSA bits must be an integer');
|
||||
if (modulusLength <= 0 || modulusLength > 16384)
|
||||
throw new RangeError('RSA bits must be non-zero and <= 16384');
|
||||
return ['rsa', { modulusLength, publicKeyEncoding, privateKeyEncoding }];
|
||||
}
|
||||
case 'ecdsa': {
|
||||
if (typeof opts !== 'object' || opts === null)
|
||||
throw new TypeError('Missing options object for ECDSA key');
|
||||
if (!Number.isInteger(opts.bits))
|
||||
throw new TypeError('ECDSA bits must be an integer');
|
||||
let namedCurve;
|
||||
switch (opts.bits) {
|
||||
case 256:
|
||||
namedCurve = 'prime256v1';
|
||||
break;
|
||||
case 384:
|
||||
namedCurve = 'secp384r1';
|
||||
break;
|
||||
case 521:
|
||||
namedCurve = 'secp521r1';
|
||||
break;
|
||||
default:
|
||||
throw new Error('ECDSA bits must be 256, 384, or 521');
|
||||
}
|
||||
if (!curves.includes(namedCurve))
|
||||
throw new Error('Unsupported ECDSA bits value');
|
||||
return ['ec', { namedCurve, publicKeyEncoding, privateKeyEncoding }];
|
||||
}
|
||||
case 'ed25519':
|
||||
return ['ed25519', { publicKeyEncoding, privateKeyEncoding }];
|
||||
default:
|
||||
throw new Error(`Unsupported key type: ${type}`);
|
||||
}
|
||||
}
|
||||
|
||||
function parseDERs(keyType, pub, priv) {
|
||||
switch (keyType) {
|
||||
case 'rsa': {
|
||||
// Note: we don't need to parse the public key since the PKCS8 private key
|
||||
// already includes the public key parameters
|
||||
|
||||
// Parse private key
|
||||
let reader = new Ber.Reader(priv);
|
||||
reader.readSequence();
|
||||
|
||||
// - Version
|
||||
if (reader.readInt() !== 0)
|
||||
throw new Error('Unsupported version in RSA private key');
|
||||
|
||||
// - Algorithm
|
||||
reader.readSequence();
|
||||
if (reader.readOID() !== '1.2.840.113549.1.1.1')
|
||||
throw new Error('Bad RSA private OID');
|
||||
// - Algorithm parameters (RSA has none)
|
||||
if (reader.readByte() !== Ber.Null)
|
||||
throw new Error('Malformed RSA private key (expected null)');
|
||||
if (reader.readByte() !== 0x00) {
|
||||
throw new Error(
|
||||
'Malformed RSA private key (expected zero-length null)'
|
||||
);
|
||||
}
|
||||
|
||||
reader = new Ber.Reader(reader.readString(Ber.OctetString, true));
|
||||
reader.readSequence();
|
||||
if (reader.readInt() !== 0)
|
||||
throw new Error('Unsupported version in RSA private key');
|
||||
const n = reader.readString(Ber.Integer, true);
|
||||
const e = reader.readString(Ber.Integer, true);
|
||||
const d = reader.readString(Ber.Integer, true);
|
||||
const p = reader.readString(Ber.Integer, true);
|
||||
const q = reader.readString(Ber.Integer, true);
|
||||
reader.readString(Ber.Integer, true); // dmp1
|
||||
reader.readString(Ber.Integer, true); // dmq1
|
||||
const iqmp = reader.readString(Ber.Integer, true);
|
||||
|
||||
/*
|
||||
OpenSSH RSA private key:
|
||||
string "ssh-rsa"
|
||||
string n -- public
|
||||
string e -- public
|
||||
string d -- private
|
||||
string iqmp -- private
|
||||
string p -- private
|
||||
string q -- private
|
||||
*/
|
||||
const keyName = Buffer.from('ssh-rsa');
|
||||
const privBuf = Buffer.allocUnsafe(
|
||||
4 + keyName.length
|
||||
+ 4 + n.length
|
||||
+ 4 + e.length
|
||||
+ 4 + d.length
|
||||
+ 4 + iqmp.length
|
||||
+ 4 + p.length
|
||||
+ 4 + q.length
|
||||
);
|
||||
let pos = 0;
|
||||
|
||||
privBuf.writeUInt32BE(keyName.length, pos += 0);
|
||||
privBuf.set(keyName, pos += 4);
|
||||
privBuf.writeUInt32BE(n.length, pos += keyName.length);
|
||||
privBuf.set(n, pos += 4);
|
||||
privBuf.writeUInt32BE(e.length, pos += n.length);
|
||||
privBuf.set(e, pos += 4);
|
||||
privBuf.writeUInt32BE(d.length, pos += e.length);
|
||||
privBuf.set(d, pos += 4);
|
||||
privBuf.writeUInt32BE(iqmp.length, pos += d.length);
|
||||
privBuf.set(iqmp, pos += 4);
|
||||
privBuf.writeUInt32BE(p.length, pos += iqmp.length);
|
||||
privBuf.set(p, pos += 4);
|
||||
privBuf.writeUInt32BE(q.length, pos += p.length);
|
||||
privBuf.set(q, pos += 4);
|
||||
|
||||
/*
|
||||
OpenSSH RSA public key:
|
||||
string "ssh-rsa"
|
||||
string e -- public
|
||||
string n -- public
|
||||
*/
|
||||
const pubBuf = Buffer.allocUnsafe(
|
||||
4 + keyName.length
|
||||
+ 4 + e.length
|
||||
+ 4 + n.length
|
||||
);
|
||||
pos = 0;
|
||||
|
||||
pubBuf.writeUInt32BE(keyName.length, pos += 0);
|
||||
pubBuf.set(keyName, pos += 4);
|
||||
pubBuf.writeUInt32BE(e.length, pos += keyName.length);
|
||||
pubBuf.set(e, pos += 4);
|
||||
pubBuf.writeUInt32BE(n.length, pos += e.length);
|
||||
pubBuf.set(n, pos += 4);
|
||||
|
||||
return { sshName: keyName.toString(), priv: privBuf, pub: pubBuf };
|
||||
}
|
||||
case 'ec': {
|
||||
// Parse public key
|
||||
let reader = new Ber.Reader(pub);
|
||||
reader.readSequence();
|
||||
|
||||
reader.readSequence();
|
||||
if (reader.readOID() !== '1.2.840.10045.2.1')
|
||||
throw new Error('Bad ECDSA public OID');
|
||||
// Skip curve OID, we'll get it from the private key
|
||||
reader.readOID();
|
||||
let pubBin = reader.readString(Ber.BitString, true);
|
||||
{
|
||||
// Remove leading zero bytes
|
||||
let i = 0;
|
||||
for (; i < pubBin.length && pubBin[i] === 0x00; ++i);
|
||||
if (i > 0)
|
||||
pubBin = pubBin.slice(i);
|
||||
}
|
||||
|
||||
// Parse private key
|
||||
reader = new Ber.Reader(priv);
|
||||
reader.readSequence();
|
||||
|
||||
// - Version
|
||||
if (reader.readInt() !== 0)
|
||||
throw new Error('Unsupported version in ECDSA private key');
|
||||
|
||||
reader.readSequence();
|
||||
if (reader.readOID() !== '1.2.840.10045.2.1')
|
||||
throw new Error('Bad ECDSA private OID');
|
||||
const curveOID = reader.readOID();
|
||||
let sshCurveName;
|
||||
switch (curveOID) {
|
||||
case '1.2.840.10045.3.1.7':
|
||||
// prime256v1/secp256r1
|
||||
sshCurveName = 'nistp256';
|
||||
break;
|
||||
case '1.3.132.0.34':
|
||||
// secp384r1
|
||||
sshCurveName = 'nistp384';
|
||||
break;
|
||||
case '1.3.132.0.35':
|
||||
// secp521r1
|
||||
sshCurveName = 'nistp521';
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unsupported curve in ECDSA private key');
|
||||
}
|
||||
|
||||
reader = new Ber.Reader(reader.readString(Ber.OctetString, true));
|
||||
reader.readSequence();
|
||||
|
||||
// - Version
|
||||
if (reader.readInt() !== 1)
|
||||
throw new Error('Unsupported version in ECDSA private key');
|
||||
|
||||
// Add leading zero byte to prevent negative bignum in private key
|
||||
const privBin = Buffer.concat([
|
||||
Buffer.from([0x00]),
|
||||
reader.readString(Ber.OctetString, true)
|
||||
]);
|
||||
|
||||
/*
|
||||
OpenSSH ECDSA private key:
|
||||
string "ecdsa-sha2-<sshCurveName>"
|
||||
string curve name
|
||||
string Q -- public
|
||||
string d -- private
|
||||
*/
|
||||
const keyName = Buffer.from(`ecdsa-sha2-${sshCurveName}`);
|
||||
sshCurveName = Buffer.from(sshCurveName);
|
||||
const privBuf = Buffer.allocUnsafe(
|
||||
4 + keyName.length
|
||||
+ 4 + sshCurveName.length
|
||||
+ 4 + pubBin.length
|
||||
+ 4 + privBin.length
|
||||
);
|
||||
let pos = 0;
|
||||
|
||||
privBuf.writeUInt32BE(keyName.length, pos += 0);
|
||||
privBuf.set(keyName, pos += 4);
|
||||
privBuf.writeUInt32BE(sshCurveName.length, pos += keyName.length);
|
||||
privBuf.set(sshCurveName, pos += 4);
|
||||
privBuf.writeUInt32BE(pubBin.length, pos += sshCurveName.length);
|
||||
privBuf.set(pubBin, pos += 4);
|
||||
privBuf.writeUInt32BE(privBin.length, pos += pubBin.length);
|
||||
privBuf.set(privBin, pos += 4);
|
||||
|
||||
/*
|
||||
OpenSSH ECDSA public key:
|
||||
string "ecdsa-sha2-<sshCurveName>"
|
||||
string curve name
|
||||
string Q -- public
|
||||
*/
|
||||
const pubBuf = Buffer.allocUnsafe(
|
||||
4 + keyName.length
|
||||
+ 4 + sshCurveName.length
|
||||
+ 4 + pubBin.length
|
||||
);
|
||||
pos = 0;
|
||||
|
||||
pubBuf.writeUInt32BE(keyName.length, pos += 0);
|
||||
pubBuf.set(keyName, pos += 4);
|
||||
pubBuf.writeUInt32BE(sshCurveName.length, pos += keyName.length);
|
||||
pubBuf.set(sshCurveName, pos += 4);
|
||||
pubBuf.writeUInt32BE(pubBin.length, pos += sshCurveName.length);
|
||||
pubBuf.set(pubBin, pos += 4);
|
||||
|
||||
return { sshName: keyName.toString(), priv: privBuf, pub: pubBuf };
|
||||
}
|
||||
case 'ed25519': {
|
||||
// Parse public key
|
||||
let reader = new Ber.Reader(pub);
|
||||
reader.readSequence();
|
||||
|
||||
// - Algorithm
|
||||
reader.readSequence();
|
||||
if (reader.readOID() !== '1.3.101.112')
|
||||
throw new Error('Bad ED25519 public OID');
|
||||
// - Attributes (absent for ED25519)
|
||||
|
||||
let pubBin = reader.readString(Ber.BitString, true);
|
||||
{
|
||||
// Remove leading zero bytes
|
||||
let i = 0;
|
||||
for (; i < pubBin.length && pubBin[i] === 0x00; ++i);
|
||||
if (i > 0)
|
||||
pubBin = pubBin.slice(i);
|
||||
}
|
||||
|
||||
// Parse private key
|
||||
reader = new Ber.Reader(priv);
|
||||
reader.readSequence();
|
||||
|
||||
// - Version
|
||||
if (reader.readInt() !== 0)
|
||||
throw new Error('Unsupported version in ED25519 private key');
|
||||
|
||||
// - Algorithm
|
||||
reader.readSequence();
|
||||
if (reader.readOID() !== '1.3.101.112')
|
||||
throw new Error('Bad ED25519 private OID');
|
||||
// - Attributes (absent)
|
||||
|
||||
reader = new Ber.Reader(reader.readString(Ber.OctetString, true));
|
||||
const privBin = reader.readString(Ber.OctetString, true);
|
||||
|
||||
/*
|
||||
OpenSSH ed25519 private key:
|
||||
string "ssh-ed25519"
|
||||
string public key
|
||||
string private key + public key
|
||||
*/
|
||||
const keyName = Buffer.from('ssh-ed25519');
|
||||
const privBuf = Buffer.allocUnsafe(
|
||||
4 + keyName.length
|
||||
+ 4 + pubBin.length
|
||||
+ 4 + (privBin.length + pubBin.length)
|
||||
);
|
||||
let pos = 0;
|
||||
|
||||
privBuf.writeUInt32BE(keyName.length, pos += 0);
|
||||
privBuf.set(keyName, pos += 4);
|
||||
privBuf.writeUInt32BE(pubBin.length, pos += keyName.length);
|
||||
privBuf.set(pubBin, pos += 4);
|
||||
privBuf.writeUInt32BE(
|
||||
privBin.length + pubBin.length,
|
||||
pos += pubBin.length
|
||||
);
|
||||
privBuf.set(privBin, pos += 4);
|
||||
privBuf.set(pubBin, pos += privBin.length);
|
||||
|
||||
/*
|
||||
OpenSSH ed25519 public key:
|
||||
string "ssh-ed25519"
|
||||
string public key
|
||||
*/
|
||||
const pubBuf = Buffer.allocUnsafe(
|
||||
4 + keyName.length
|
||||
+ 4 + pubBin.length
|
||||
);
|
||||
pos = 0;
|
||||
|
||||
pubBuf.writeUInt32BE(keyName.length, pos += 0);
|
||||
pubBuf.set(keyName, pos += 4);
|
||||
pubBuf.writeUInt32BE(pubBin.length, pos += keyName.length);
|
||||
pubBuf.set(pubBin, pos += 4);
|
||||
|
||||
return { sshName: keyName.toString(), priv: privBuf, pub: pubBuf };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function convertKeys(keyType, pub, priv, opts) {
|
||||
let format = 'new';
|
||||
let encrypted;
|
||||
let comment = '';
|
||||
if (typeof opts === 'object' && opts !== null) {
|
||||
if (typeof opts.comment === 'string' && opts.comment)
|
||||
comment = opts.comment;
|
||||
if (typeof opts.format === 'string' && opts.format)
|
||||
format = opts.format;
|
||||
if (opts.passphrase) {
|
||||
let passphrase;
|
||||
if (typeof opts.passphrase === 'string')
|
||||
passphrase = Buffer.from(opts.passphrase);
|
||||
else if (Buffer.isBuffer(opts.passphrase))
|
||||
passphrase = opts.passphrase;
|
||||
else
|
||||
throw new Error('Invalid passphrase');
|
||||
|
||||
if (opts.cipher === undefined)
|
||||
throw new Error('Missing cipher name');
|
||||
const cipher = ciphers.get(opts.cipher);
|
||||
if (cipher === undefined)
|
||||
throw new Error('Invalid cipher name');
|
||||
|
||||
if (format === 'new') {
|
||||
let rounds = DEFAULT_ROUNDS;
|
||||
if (opts.rounds !== undefined) {
|
||||
if (!Number.isInteger(opts.rounds))
|
||||
throw new TypeError('rounds must be an integer');
|
||||
if (opts.rounds > 0)
|
||||
rounds = opts.rounds;
|
||||
}
|
||||
|
||||
const gen = Buffer.allocUnsafe(cipher.keyLen + cipher.ivLen);
|
||||
const salt = randomBytes(SALT_LEN);
|
||||
const r = bcrypt_pbkdf(
|
||||
passphrase,
|
||||
passphrase.length,
|
||||
salt,
|
||||
salt.length,
|
||||
gen,
|
||||
gen.length,
|
||||
rounds
|
||||
);
|
||||
if (r !== 0)
|
||||
return new Error('Failed to generate information to encrypt key');
|
||||
|
||||
/*
|
||||
string salt
|
||||
uint32 rounds
|
||||
*/
|
||||
const kdfOptions = Buffer.allocUnsafe(4 + salt.length + 4);
|
||||
{
|
||||
let pos = 0;
|
||||
kdfOptions.writeUInt32BE(salt.length, pos += 0);
|
||||
kdfOptions.set(salt, pos += 4);
|
||||
kdfOptions.writeUInt32BE(rounds, pos += salt.length);
|
||||
}
|
||||
|
||||
encrypted = {
|
||||
cipher,
|
||||
cipherName: opts.cipher,
|
||||
kdfName: 'bcrypt',
|
||||
kdfOptions,
|
||||
key: gen.slice(0, cipher.keyLen),
|
||||
iv: gen.slice(cipher.keyLen),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
case 'new': {
|
||||
let privateB64 = '-----BEGIN OPENSSH PRIVATE KEY-----\n';
|
||||
let publicB64;
|
||||
/*
|
||||
byte[] "openssh-key-v1\0"
|
||||
string ciphername
|
||||
string kdfname
|
||||
string kdfoptions
|
||||
uint32 number of keys N
|
||||
string publickey1
|
||||
string encrypted, padded list of private keys
|
||||
uint32 checkint
|
||||
uint32 checkint
|
||||
byte[] privatekey1
|
||||
string comment1
|
||||
byte 1
|
||||
byte 2
|
||||
byte 3
|
||||
...
|
||||
byte padlen % 255
|
||||
*/
|
||||
const cipherName = Buffer.from(encrypted ? encrypted.cipherName : 'none');
|
||||
const kdfName = Buffer.from(encrypted ? encrypted.kdfName : 'none');
|
||||
const kdfOptions = (encrypted ? encrypted.kdfOptions : Buffer.alloc(0));
|
||||
const blockLen = (encrypted ? encrypted.cipher.blockLen : 8);
|
||||
|
||||
const parsed = parseDERs(keyType, pub, priv);
|
||||
|
||||
const checkInt = randomBytes(4);
|
||||
const commentBin = Buffer.from(comment);
|
||||
const privBlobLen = (4 + 4 + parsed.priv.length + 4 + commentBin.length);
|
||||
let padding = [];
|
||||
for (let i = 1; ((privBlobLen + padding.length) % blockLen); ++i)
|
||||
padding.push(i & 0xFF);
|
||||
padding = Buffer.from(padding);
|
||||
|
||||
let privBlob = Buffer.allocUnsafe(privBlobLen + padding.length);
|
||||
let extra;
|
||||
{
|
||||
let pos = 0;
|
||||
privBlob.set(checkInt, pos += 0);
|
||||
privBlob.set(checkInt, pos += 4);
|
||||
privBlob.set(parsed.priv, pos += 4);
|
||||
privBlob.writeUInt32BE(commentBin.length, pos += parsed.priv.length);
|
||||
privBlob.set(commentBin, pos += 4);
|
||||
privBlob.set(padding, pos += commentBin.length);
|
||||
}
|
||||
|
||||
if (encrypted) {
|
||||
const options = { authTagLength: encrypted.cipher.authLen };
|
||||
const cipher = createCipheriv(
|
||||
encrypted.cipher.sslName,
|
||||
encrypted.key,
|
||||
encrypted.iv,
|
||||
options
|
||||
);
|
||||
cipher.setAutoPadding(false);
|
||||
privBlob = Buffer.concat([ cipher.update(privBlob), cipher.final() ]);
|
||||
if (encrypted.cipher.authLen > 0)
|
||||
extra = cipher.getAuthTag();
|
||||
else
|
||||
extra = Buffer.alloc(0);
|
||||
encrypted.key.fill(0);
|
||||
encrypted.iv.fill(0);
|
||||
} else {
|
||||
extra = Buffer.alloc(0);
|
||||
}
|
||||
|
||||
const magicBytes = Buffer.from('openssh-key-v1\0');
|
||||
const privBin = Buffer.allocUnsafe(
|
||||
magicBytes.length
|
||||
+ 4 + cipherName.length
|
||||
+ 4 + kdfName.length
|
||||
+ 4 + kdfOptions.length
|
||||
+ 4
|
||||
+ 4 + parsed.pub.length
|
||||
+ 4 + privBlob.length
|
||||
+ extra.length
|
||||
);
|
||||
{
|
||||
let pos = 0;
|
||||
privBin.set(magicBytes, pos += 0);
|
||||
privBin.writeUInt32BE(cipherName.length, pos += magicBytes.length);
|
||||
privBin.set(cipherName, pos += 4);
|
||||
privBin.writeUInt32BE(kdfName.length, pos += cipherName.length);
|
||||
privBin.set(kdfName, pos += 4);
|
||||
privBin.writeUInt32BE(kdfOptions.length, pos += kdfName.length);
|
||||
privBin.set(kdfOptions, pos += 4);
|
||||
privBin.writeUInt32BE(1, pos += kdfOptions.length);
|
||||
privBin.writeUInt32BE(parsed.pub.length, pos += 4);
|
||||
privBin.set(parsed.pub, pos += 4);
|
||||
privBin.writeUInt32BE(privBlob.length, pos += parsed.pub.length);
|
||||
privBin.set(privBlob, pos += 4);
|
||||
privBin.set(extra, pos += privBlob.length);
|
||||
}
|
||||
|
||||
{
|
||||
const b64 = privBin.base64Slice(0, privBin.length);
|
||||
let formatted = b64.replace(/.{64}/g, '$&\n');
|
||||
if (b64.length & 63)
|
||||
formatted += '\n';
|
||||
privateB64 += formatted;
|
||||
}
|
||||
|
||||
{
|
||||
const b64 = parsed.pub.base64Slice(0, parsed.pub.length);
|
||||
publicB64 = `${parsed.sshName} ${b64}${comment ? ` ${comment}` : ''}`;
|
||||
}
|
||||
|
||||
privateB64 += '-----END OPENSSH PRIVATE KEY-----\n';
|
||||
return {
|
||||
private: privateB64,
|
||||
public: publicB64,
|
||||
};
|
||||
}
|
||||
default:
|
||||
throw new Error('Invalid output key format');
|
||||
}
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
|
||||
module.exports = {
|
||||
generateKeyPair: (keyType, opts, cb) => {
|
||||
if (typeof opts === 'function') {
|
||||
cb = opts;
|
||||
opts = undefined;
|
||||
}
|
||||
if (typeof cb !== 'function')
|
||||
cb = noop;
|
||||
const args = makeArgs(keyType, opts);
|
||||
generateKeyPair_(...args, (err, pub, priv) => {
|
||||
if (err)
|
||||
return cb(err);
|
||||
let ret;
|
||||
try {
|
||||
ret = convertKeys(args[0], pub, priv, opts);
|
||||
} catch (ex) {
|
||||
return cb(ex);
|
||||
}
|
||||
cb(null, ret);
|
||||
});
|
||||
},
|
||||
generateKeyPairSync: (keyType, opts) => {
|
||||
const args = makeArgs(keyType, opts);
|
||||
const { publicKey: pub, privateKey: priv } = generateKeyPairSync_(...args);
|
||||
return convertKeys(args[0], pub, priv, opts);
|
||||
}
|
||||
};
|
||||
2136
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/Protocol.js
generated
vendored
Normal file
2136
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/Protocol.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4052
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/SFTP.js
generated
vendored
Normal file
4052
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/SFTP.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
356
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/constants.js
generated
vendored
Normal file
356
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/constants.js
generated
vendored
Normal file
@@ -0,0 +1,356 @@
|
||||
'use strict';
|
||||
|
||||
const crypto = require('crypto');
|
||||
|
||||
let cpuInfo;
|
||||
try {
|
||||
cpuInfo = require('cpu-features')();
|
||||
} catch {}
|
||||
|
||||
const { bindingAvailable, CIPHER_INFO, MAC_INFO } = require('./crypto.js');
|
||||
|
||||
const eddsaSupported = (() => {
|
||||
if (typeof crypto.sign === 'function'
|
||||
&& typeof crypto.verify === 'function') {
|
||||
const key =
|
||||
'-----BEGIN PRIVATE KEY-----\r\nMC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD'
|
||||
+ '/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r\n-----END PRIVATE KEY-----';
|
||||
const data = Buffer.from('a');
|
||||
let sig;
|
||||
let verified;
|
||||
try {
|
||||
sig = crypto.sign(null, data, key);
|
||||
verified = crypto.verify(null, data, key, sig);
|
||||
} catch {}
|
||||
return (Buffer.isBuffer(sig) && sig.length === 64 && verified === true);
|
||||
}
|
||||
|
||||
return false;
|
||||
})();
|
||||
|
||||
const curve25519Supported = (typeof crypto.diffieHellman === 'function'
|
||||
&& typeof crypto.generateKeyPairSync === 'function'
|
||||
&& typeof crypto.createPublicKey === 'function');
|
||||
|
||||
const DEFAULT_KEX = [
|
||||
// https://tools.ietf.org/html/rfc5656#section-10.1
|
||||
'ecdh-sha2-nistp256',
|
||||
'ecdh-sha2-nistp384',
|
||||
'ecdh-sha2-nistp521',
|
||||
|
||||
// https://tools.ietf.org/html/rfc4419#section-4
|
||||
'diffie-hellman-group-exchange-sha256',
|
||||
|
||||
// https://tools.ietf.org/html/rfc8268
|
||||
'diffie-hellman-group14-sha256',
|
||||
'diffie-hellman-group15-sha512',
|
||||
'diffie-hellman-group16-sha512',
|
||||
'diffie-hellman-group17-sha512',
|
||||
'diffie-hellman-group18-sha512',
|
||||
];
|
||||
if (curve25519Supported) {
|
||||
DEFAULT_KEX.unshift('curve25519-sha256');
|
||||
DEFAULT_KEX.unshift('curve25519-sha256@libssh.org');
|
||||
}
|
||||
const SUPPORTED_KEX = DEFAULT_KEX.concat([
|
||||
// https://tools.ietf.org/html/rfc4419#section-4
|
||||
'diffie-hellman-group-exchange-sha1',
|
||||
|
||||
'diffie-hellman-group14-sha1', // REQUIRED
|
||||
'diffie-hellman-group1-sha1', // REQUIRED
|
||||
]);
|
||||
|
||||
|
||||
const DEFAULT_SERVER_HOST_KEY = [
|
||||
'ecdsa-sha2-nistp256',
|
||||
'ecdsa-sha2-nistp384',
|
||||
'ecdsa-sha2-nistp521',
|
||||
'rsa-sha2-512', // RFC 8332
|
||||
'rsa-sha2-256', // RFC 8332
|
||||
'ssh-rsa',
|
||||
];
|
||||
if (eddsaSupported)
|
||||
DEFAULT_SERVER_HOST_KEY.unshift('ssh-ed25519');
|
||||
const SUPPORTED_SERVER_HOST_KEY = DEFAULT_SERVER_HOST_KEY.concat([
|
||||
'ssh-dss',
|
||||
]);
|
||||
|
||||
|
||||
const canUseCipher = (() => {
|
||||
const ciphers = crypto.getCiphers();
|
||||
return (name) => ciphers.includes(CIPHER_INFO[name].sslName);
|
||||
})();
|
||||
let DEFAULT_CIPHER = [
|
||||
// http://tools.ietf.org/html/rfc5647
|
||||
'aes128-gcm@openssh.com',
|
||||
'aes256-gcm@openssh.com',
|
||||
|
||||
// http://tools.ietf.org/html/rfc4344#section-4
|
||||
'aes128-ctr',
|
||||
'aes192-ctr',
|
||||
'aes256-ctr',
|
||||
];
|
||||
if (cpuInfo && cpuInfo.flags && !cpuInfo.flags.aes) {
|
||||
// We know for sure the CPU does not support AES acceleration
|
||||
if (bindingAvailable)
|
||||
DEFAULT_CIPHER.unshift('chacha20-poly1305@openssh.com');
|
||||
else
|
||||
DEFAULT_CIPHER.push('chacha20-poly1305@openssh.com');
|
||||
} else if (bindingAvailable && cpuInfo && cpuInfo.arch === 'x86') {
|
||||
// Places chacha20-poly1305 immediately after GCM ciphers since GCM ciphers
|
||||
// seem to outperform it on x86, but it seems to be faster than CTR ciphers
|
||||
DEFAULT_CIPHER.splice(4, 0, 'chacha20-poly1305@openssh.com');
|
||||
} else {
|
||||
DEFAULT_CIPHER.push('chacha20-poly1305@openssh.com');
|
||||
}
|
||||
DEFAULT_CIPHER = DEFAULT_CIPHER.filter(canUseCipher);
|
||||
const SUPPORTED_CIPHER = DEFAULT_CIPHER.concat([
|
||||
'aes256-cbc',
|
||||
'aes192-cbc',
|
||||
'aes128-cbc',
|
||||
'blowfish-cbc',
|
||||
'3des-cbc',
|
||||
'aes128-gcm',
|
||||
'aes256-gcm',
|
||||
|
||||
// http://tools.ietf.org/html/rfc4345#section-4:
|
||||
'arcfour256',
|
||||
'arcfour128',
|
||||
|
||||
'cast128-cbc',
|
||||
'arcfour',
|
||||
].filter(canUseCipher));
|
||||
|
||||
|
||||
const canUseMAC = (() => {
|
||||
const hashes = crypto.getHashes();
|
||||
return (name) => hashes.includes(MAC_INFO[name].sslName);
|
||||
})();
|
||||
const DEFAULT_MAC = [
|
||||
'hmac-sha2-256-etm@openssh.com',
|
||||
'hmac-sha2-512-etm@openssh.com',
|
||||
'hmac-sha1-etm@openssh.com',
|
||||
'hmac-sha2-256',
|
||||
'hmac-sha2-512',
|
||||
'hmac-sha1',
|
||||
].filter(canUseMAC);
|
||||
const SUPPORTED_MAC = DEFAULT_MAC.concat([
|
||||
'hmac-md5',
|
||||
'hmac-sha2-256-96', // first 96 bits of HMAC-SHA256
|
||||
'hmac-sha2-512-96', // first 96 bits of HMAC-SHA512
|
||||
'hmac-ripemd160',
|
||||
'hmac-sha1-96', // first 96 bits of HMAC-SHA1
|
||||
'hmac-md5-96', // first 96 bits of HMAC-MD5
|
||||
].filter(canUseMAC));
|
||||
|
||||
const DEFAULT_COMPRESSION = [
|
||||
'none',
|
||||
'zlib@openssh.com', // ZLIB (LZ77) compression, except
|
||||
// compression/decompression does not start until after
|
||||
// successful user authentication
|
||||
'zlib', // ZLIB (LZ77) compression
|
||||
];
|
||||
const SUPPORTED_COMPRESSION = DEFAULT_COMPRESSION.concat([
|
||||
]);
|
||||
|
||||
|
||||
const COMPAT = {
|
||||
BAD_DHGEX: 1 << 0,
|
||||
OLD_EXIT: 1 << 1,
|
||||
DYN_RPORT_BUG: 1 << 2,
|
||||
BUG_DHGEX_LARGE: 1 << 3,
|
||||
IMPLY_RSA_SHA2_SIGALGS: 1 << 4,
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
MESSAGE: {
|
||||
// Transport layer protocol -- generic (1-19)
|
||||
DISCONNECT: 1,
|
||||
IGNORE: 2,
|
||||
UNIMPLEMENTED: 3,
|
||||
DEBUG: 4,
|
||||
SERVICE_REQUEST: 5,
|
||||
SERVICE_ACCEPT: 6,
|
||||
EXT_INFO: 7, // RFC 8308
|
||||
|
||||
// Transport layer protocol -- algorithm negotiation (20-29)
|
||||
KEXINIT: 20,
|
||||
NEWKEYS: 21,
|
||||
|
||||
// Transport layer protocol -- key exchange method-specific (30-49)
|
||||
KEXDH_INIT: 30,
|
||||
KEXDH_REPLY: 31,
|
||||
|
||||
KEXDH_GEX_GROUP: 31,
|
||||
KEXDH_GEX_INIT: 32,
|
||||
KEXDH_GEX_REPLY: 33,
|
||||
KEXDH_GEX_REQUEST: 34,
|
||||
|
||||
KEXECDH_INIT: 30,
|
||||
KEXECDH_REPLY: 31,
|
||||
|
||||
// User auth protocol -- generic (50-59)
|
||||
USERAUTH_REQUEST: 50,
|
||||
USERAUTH_FAILURE: 51,
|
||||
USERAUTH_SUCCESS: 52,
|
||||
USERAUTH_BANNER: 53,
|
||||
|
||||
// User auth protocol -- user auth method-specific (60-79)
|
||||
USERAUTH_PASSWD_CHANGEREQ: 60,
|
||||
|
||||
USERAUTH_PK_OK: 60,
|
||||
|
||||
USERAUTH_INFO_REQUEST: 60,
|
||||
USERAUTH_INFO_RESPONSE: 61,
|
||||
|
||||
// Connection protocol -- generic (80-89)
|
||||
GLOBAL_REQUEST: 80,
|
||||
REQUEST_SUCCESS: 81,
|
||||
REQUEST_FAILURE: 82,
|
||||
|
||||
// Connection protocol -- channel-related (90-127)
|
||||
CHANNEL_OPEN: 90,
|
||||
CHANNEL_OPEN_CONFIRMATION: 91,
|
||||
CHANNEL_OPEN_FAILURE: 92,
|
||||
CHANNEL_WINDOW_ADJUST: 93,
|
||||
CHANNEL_DATA: 94,
|
||||
CHANNEL_EXTENDED_DATA: 95,
|
||||
CHANNEL_EOF: 96,
|
||||
CHANNEL_CLOSE: 97,
|
||||
CHANNEL_REQUEST: 98,
|
||||
CHANNEL_SUCCESS: 99,
|
||||
CHANNEL_FAILURE: 100
|
||||
|
||||
// Reserved for client protocols (128-191)
|
||||
|
||||
// Local extensions (192-155)
|
||||
},
|
||||
DISCONNECT_REASON: {
|
||||
HOST_NOT_ALLOWED_TO_CONNECT: 1,
|
||||
PROTOCOL_ERROR: 2,
|
||||
KEY_EXCHANGE_FAILED: 3,
|
||||
RESERVED: 4,
|
||||
MAC_ERROR: 5,
|
||||
COMPRESSION_ERROR: 6,
|
||||
SERVICE_NOT_AVAILABLE: 7,
|
||||
PROTOCOL_VERSION_NOT_SUPPORTED: 8,
|
||||
HOST_KEY_NOT_VERIFIABLE: 9,
|
||||
CONNECTION_LOST: 10,
|
||||
BY_APPLICATION: 11,
|
||||
TOO_MANY_CONNECTIONS: 12,
|
||||
AUTH_CANCELED_BY_USER: 13,
|
||||
NO_MORE_AUTH_METHODS_AVAILABLE: 14,
|
||||
ILLEGAL_USER_NAME: 15,
|
||||
},
|
||||
DISCONNECT_REASON_STR: undefined,
|
||||
CHANNEL_OPEN_FAILURE: {
|
||||
ADMINISTRATIVELY_PROHIBITED: 1,
|
||||
CONNECT_FAILED: 2,
|
||||
UNKNOWN_CHANNEL_TYPE: 3,
|
||||
RESOURCE_SHORTAGE: 4
|
||||
},
|
||||
TERMINAL_MODE: {
|
||||
TTY_OP_END: 0, // Indicates end of options.
|
||||
VINTR: 1, // Interrupt character; 255 if none. Similarly for the
|
||||
// other characters. Not all of these characters are
|
||||
// supported on all systems.
|
||||
VQUIT: 2, // The quit character (sends SIGQUIT signal on POSIX
|
||||
// systems).
|
||||
VERASE: 3, // Erase the character to left of the cursor.
|
||||
VKILL: 4, // Kill the current input line.
|
||||
VEOF: 5, // End-of-file character (sends EOF from the
|
||||
// terminal).
|
||||
VEOL: 6, // End-of-line character in addition to carriage
|
||||
// return and/or linefeed.
|
||||
VEOL2: 7, // Additional end-of-line character.
|
||||
VSTART: 8, // Continues paused output (normally control-Q).
|
||||
VSTOP: 9, // Pauses output (normally control-S).
|
||||
VSUSP: 10, // Suspends the current program.
|
||||
VDSUSP: 11, // Another suspend character.
|
||||
VREPRINT: 12, // Reprints the current input line.
|
||||
VWERASE: 13, // Erases a word left of cursor.
|
||||
VLNEXT: 14, // Enter the next character typed literally, even if
|
||||
// it is a special character
|
||||
VFLUSH: 15, // Character to flush output.
|
||||
VSWTCH: 16, // Switch to a different shell layer.
|
||||
VSTATUS: 17, // Prints system status line (load, command, pid,
|
||||
// etc).
|
||||
VDISCARD: 18, // Toggles the flushing of terminal output.
|
||||
IGNPAR: 30, // The ignore parity flag. The parameter SHOULD be 0
|
||||
// if this flag is FALSE, and 1 if it is TRUE.
|
||||
PARMRK: 31, // Mark parity and framing errors.
|
||||
INPCK: 32, // Enable checking of parity errors.
|
||||
ISTRIP: 33, // Strip 8th bit off characters.
|
||||
INLCR: 34, // Map NL into CR on input.
|
||||
IGNCR: 35, // Ignore CR on input.
|
||||
ICRNL: 36, // Map CR to NL on input.
|
||||
IUCLC: 37, // Translate uppercase characters to lowercase.
|
||||
IXON: 38, // Enable output flow control.
|
||||
IXANY: 39, // Any char will restart after stop.
|
||||
IXOFF: 40, // Enable input flow control.
|
||||
IMAXBEL: 41, // Ring bell on input queue full.
|
||||
ISIG: 50, // Enable signals INTR, QUIT, [D]SUSP.
|
||||
ICANON: 51, // Canonicalize input lines.
|
||||
XCASE: 52, // Enable input and output of uppercase characters by
|
||||
// preceding their lowercase equivalents with "\".
|
||||
ECHO: 53, // Enable echoing.
|
||||
ECHOE: 54, // Visually erase chars.
|
||||
ECHOK: 55, // Kill character discards current line.
|
||||
ECHONL: 56, // Echo NL even if ECHO is off.
|
||||
NOFLSH: 57, // Don't flush after interrupt.
|
||||
TOSTOP: 58, // Stop background jobs from output.
|
||||
IEXTEN: 59, // Enable extensions.
|
||||
ECHOCTL: 60, // Echo control characters as ^(Char).
|
||||
ECHOKE: 61, // Visual erase for line kill.
|
||||
PENDIN: 62, // Retype pending input.
|
||||
OPOST: 70, // Enable output processing.
|
||||
OLCUC: 71, // Convert lowercase to uppercase.
|
||||
ONLCR: 72, // Map NL to CR-NL.
|
||||
OCRNL: 73, // Translate carriage return to newline (output).
|
||||
ONOCR: 74, // Translate newline to carriage return-newline
|
||||
// (output).
|
||||
ONLRET: 75, // Newline performs a carriage return (output).
|
||||
CS7: 90, // 7 bit mode.
|
||||
CS8: 91, // 8 bit mode.
|
||||
PARENB: 92, // Parity enable.
|
||||
PARODD: 93, // Odd parity, else even.
|
||||
TTY_OP_ISPEED: 128, // Specifies the input baud rate in bits per second.
|
||||
TTY_OP_OSPEED: 129, // Specifies the output baud rate in bits per second.
|
||||
},
|
||||
CHANNEL_EXTENDED_DATATYPE: {
|
||||
STDERR: 1,
|
||||
},
|
||||
|
||||
SIGNALS: [
|
||||
'ABRT', 'ALRM', 'FPE', 'HUP', 'ILL', 'INT', 'QUIT', 'SEGV', 'TERM', 'USR1',
|
||||
'USR2', 'KILL', 'PIPE'
|
||||
].reduce((cur, val) => ({ ...cur, [val]: 1 }), {}),
|
||||
|
||||
COMPAT,
|
||||
COMPAT_CHECKS: [
|
||||
[ 'Cisco-1.25', COMPAT.BAD_DHGEX ],
|
||||
[ /^Cisco-1[.]/, COMPAT.BUG_DHGEX_LARGE ],
|
||||
[ /^[0-9.]+$/, COMPAT.OLD_EXIT ], // old SSH.com implementations
|
||||
[ /^OpenSSH_5[.][0-9]+/, COMPAT.DYN_RPORT_BUG ],
|
||||
[ /^OpenSSH_7[.]4/, COMPAT.IMPLY_RSA_SHA2_SIGALGS ],
|
||||
],
|
||||
|
||||
// KEX proposal-related
|
||||
DEFAULT_KEX,
|
||||
SUPPORTED_KEX,
|
||||
DEFAULT_SERVER_HOST_KEY,
|
||||
SUPPORTED_SERVER_HOST_KEY,
|
||||
DEFAULT_CIPHER,
|
||||
SUPPORTED_CIPHER,
|
||||
DEFAULT_MAC,
|
||||
SUPPORTED_MAC,
|
||||
DEFAULT_COMPRESSION,
|
||||
SUPPORTED_COMPRESSION,
|
||||
|
||||
curve25519Supported,
|
||||
eddsaSupported,
|
||||
};
|
||||
|
||||
module.exports.DISCONNECT_REASON_BY_VALUE =
|
||||
Array.from(Object.entries(module.exports.DISCONNECT_REASON))
|
||||
.reduce((obj, [key, value]) => ({ ...obj, [value]: key }), {});
|
||||
1602
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto.js
generated
vendored
Normal file
1602
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
23
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto/binding.gyp
generated
vendored
Normal file
23
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto/binding.gyp
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
'variables': {
|
||||
'real_openssl_major%': '0',
|
||||
},
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'sshcrypto',
|
||||
'include_dirs': [
|
||||
"<!(node -e \"require('nan')\")",
|
||||
],
|
||||
'sources': [
|
||||
'src/binding.cc'
|
||||
],
|
||||
'cflags': [ '-O3' ],
|
||||
|
||||
# Needed for OpenSSL 3.x/node.js v17.x+
|
||||
'defines': [
|
||||
'OPENSSL_API_COMPAT=0x10100000L',
|
||||
'REAL_OPENSSL_MAJOR=<(real_openssl_major)',
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
354
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto/build/Makefile
generated
vendored
Normal file
354
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto/build/Makefile
generated
vendored
Normal file
@@ -0,0 +1,354 @@
|
||||
# We borrow heavily from the kernel build setup, though we are simpler since
|
||||
# we don't have Kconfig tweaking settings on us.
|
||||
|
||||
# The implicit make rules have it looking for RCS files, among other things.
|
||||
# We instead explicitly write all the rules we care about.
|
||||
# It's even quicker (saves ~200ms) to pass -r on the command line.
|
||||
MAKEFLAGS=-r
|
||||
|
||||
# The source directory tree.
|
||||
srcdir := ..
|
||||
abs_srcdir := $(abspath $(srcdir))
|
||||
|
||||
# The name of the builddir.
|
||||
builddir_name ?= .
|
||||
|
||||
# The V=1 flag on command line makes us verbosely print command lines.
|
||||
ifdef V
|
||||
quiet=
|
||||
else
|
||||
quiet=quiet_
|
||||
endif
|
||||
|
||||
# Specify BUILDTYPE=Release on the command line for a release build.
|
||||
BUILDTYPE ?= Release
|
||||
|
||||
# Directory all our build output goes into.
|
||||
# Note that this must be two directories beneath src/ for unit tests to pass,
|
||||
# as they reach into the src/ directory for data with relative paths.
|
||||
builddir ?= $(builddir_name)/$(BUILDTYPE)
|
||||
abs_builddir := $(abspath $(builddir))
|
||||
depsdir := $(builddir)/.deps
|
||||
|
||||
# Object output directory.
|
||||
obj := $(builddir)/obj
|
||||
abs_obj := $(abspath $(obj))
|
||||
|
||||
# We build up a list of every single one of the targets so we can slurp in the
|
||||
# generated dependency rule Makefiles in one pass.
|
||||
all_deps :=
|
||||
|
||||
|
||||
|
||||
CC.target ?= $(CC)
|
||||
CFLAGS.target ?= $(CPPFLAGS) $(CFLAGS)
|
||||
CXX.target ?= $(CXX)
|
||||
CXXFLAGS.target ?= $(CPPFLAGS) $(CXXFLAGS)
|
||||
LINK.target ?= $(LINK)
|
||||
LDFLAGS.target ?= $(LDFLAGS)
|
||||
AR.target ?= $(AR)
|
||||
PLI.target ?= pli
|
||||
|
||||
# C++ apps need to be linked with g++.
|
||||
LINK ?= $(CXX.target)
|
||||
|
||||
# TODO(evan): move all cross-compilation logic to gyp-time so we don't need
|
||||
# to replicate this environment fallback in make as well.
|
||||
CC.host ?= gcc
|
||||
CFLAGS.host ?= $(CPPFLAGS_host) $(CFLAGS_host)
|
||||
CXX.host ?= g++
|
||||
CXXFLAGS.host ?= $(CPPFLAGS_host) $(CXXFLAGS_host)
|
||||
LINK.host ?= $(CXX.host)
|
||||
LDFLAGS.host ?= $(LDFLAGS_host)
|
||||
AR.host ?= ar
|
||||
PLI.host ?= pli
|
||||
|
||||
# Define a dir function that can handle spaces.
|
||||
# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions
|
||||
# "leading spaces cannot appear in the text of the first argument as written.
|
||||
# These characters can be put into the argument value by variable substitution."
|
||||
empty :=
|
||||
space := $(empty) $(empty)
|
||||
|
||||
# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces
|
||||
replace_spaces = $(subst $(space),?,$1)
|
||||
unreplace_spaces = $(subst ?,$(space),$1)
|
||||
dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1)))
|
||||
|
||||
# Flags to make gcc output dependency info. Note that you need to be
|
||||
# careful here to use the flags that ccache and distcc can understand.
|
||||
# We write to a dep file on the side first and then rename at the end
|
||||
# so we can't end up with a broken dep file.
|
||||
depfile = $(depsdir)/$(call replace_spaces,$@).d
|
||||
DEPFLAGS = -MMD -MF $(depfile).raw
|
||||
|
||||
# We have to fixup the deps output in a few ways.
|
||||
# (1) the file output should mention the proper .o file.
|
||||
# ccache or distcc lose the path to the target, so we convert a rule of
|
||||
# the form:
|
||||
# foobar.o: DEP1 DEP2
|
||||
# into
|
||||
# path/to/foobar.o: DEP1 DEP2
|
||||
# (2) we want missing files not to cause us to fail to build.
|
||||
# We want to rewrite
|
||||
# foobar.o: DEP1 DEP2 \
|
||||
# DEP3
|
||||
# to
|
||||
# DEP1:
|
||||
# DEP2:
|
||||
# DEP3:
|
||||
# so if the files are missing, they're just considered phony rules.
|
||||
# We have to do some pretty insane escaping to get those backslashes
|
||||
# and dollar signs past make, the shell, and sed at the same time.
|
||||
# Doesn't work with spaces, but that's fine: .d files have spaces in
|
||||
# their names replaced with other characters.
|
||||
define fixup_dep
|
||||
# The depfile may not exist if the input file didn't have any #includes.
|
||||
touch $(depfile).raw
|
||||
# Fixup path as in (1).
|
||||
sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)
|
||||
# Add extra rules as in (2).
|
||||
# We remove slashes and replace spaces with new lines;
|
||||
# remove blank lines;
|
||||
# delete the first line and append a colon to the remaining lines.
|
||||
sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\
|
||||
grep -v '^$$' |\
|
||||
sed -e 1d -e 's|$$|:|' \
|
||||
>> $(depfile)
|
||||
rm $(depfile).raw
|
||||
endef
|
||||
|
||||
# Command definitions:
|
||||
# - cmd_foo is the actual command to run;
|
||||
# - quiet_cmd_foo is the brief-output summary of the command.
|
||||
|
||||
quiet_cmd_cc = CC($(TOOLSET)) $@
|
||||
cmd_cc = $(CC.$(TOOLSET)) -o $@ $< $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c
|
||||
|
||||
quiet_cmd_cxx = CXX($(TOOLSET)) $@
|
||||
cmd_cxx = $(CXX.$(TOOLSET)) -o $@ $< $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c
|
||||
|
||||
quiet_cmd_touch = TOUCH $@
|
||||
cmd_touch = touch $@
|
||||
|
||||
quiet_cmd_copy = COPY $@
|
||||
# send stderr to /dev/null to ignore messages when linking directories.
|
||||
cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@")
|
||||
|
||||
quiet_cmd_symlink = SYMLINK $@
|
||||
cmd_symlink = ln -sf "$<" "$@"
|
||||
|
||||
quiet_cmd_alink = AR($(TOOLSET)) $@
|
||||
cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)
|
||||
|
||||
quiet_cmd_alink_thin = AR($(TOOLSET)) $@
|
||||
cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^)
|
||||
|
||||
# Due to circular dependencies between libraries :(, we wrap the
|
||||
# special "figure out circular dependencies" flags around the entire
|
||||
# input list during linking.
|
||||
quiet_cmd_link = LINK($(TOOLSET)) $@
|
||||
cmd_link = $(LINK.$(TOOLSET)) -o $@ $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,--start-group $(LD_INPUTS) $(LIBS) -Wl,--end-group
|
||||
|
||||
# Note: this does not handle spaces in paths
|
||||
define xargs
|
||||
$(1) $(word 1,$(2))
|
||||
$(if $(word 2,$(2)),$(call xargs,$(1),$(wordlist 2,$(words $(2)),$(2))))
|
||||
endef
|
||||
|
||||
define write-to-file
|
||||
@: >$(1)
|
||||
$(call xargs,@printf "%s\n" >>$(1),$(2))
|
||||
endef
|
||||
|
||||
OBJ_FILE_LIST := ar-file-list
|
||||
|
||||
define create_archive
|
||||
rm -f $(1) $(1).$(OBJ_FILE_LIST); mkdir -p `dirname $(1)`
|
||||
$(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2)))
|
||||
$(AR.$(TOOLSET)) crs $(1) @$(1).$(OBJ_FILE_LIST)
|
||||
endef
|
||||
|
||||
define create_thin_archive
|
||||
rm -f $(1) $(OBJ_FILE_LIST); mkdir -p `dirname $(1)`
|
||||
$(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2)))
|
||||
$(AR.$(TOOLSET)) crsT $(1) @$(1).$(OBJ_FILE_LIST)
|
||||
endef
|
||||
|
||||
# We support two kinds of shared objects (.so):
|
||||
# 1) shared_library, which is just bundling together many dependent libraries
|
||||
# into a link line.
|
||||
# 2) loadable_module, which is generating a module intended for dlopen().
|
||||
#
|
||||
# They differ only slightly:
|
||||
# In the former case, we want to package all dependent code into the .so.
|
||||
# In the latter case, we want to package just the API exposed by the
|
||||
# outermost module.
|
||||
# This means shared_library uses --whole-archive, while loadable_module doesn't.
|
||||
# (Note that --whole-archive is incompatible with the --start-group used in
|
||||
# normal linking.)
|
||||
|
||||
# Other shared-object link notes:
|
||||
# - Set SONAME to the library filename so our binaries don't reference
|
||||
# the local, absolute paths used on the link command-line.
|
||||
quiet_cmd_solink = SOLINK($(TOOLSET)) $@
|
||||
cmd_solink = $(LINK.$(TOOLSET)) -o $@ -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS)
|
||||
|
||||
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
|
||||
cmd_solink_module = $(LINK.$(TOOLSET)) -o $@ -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS)
|
||||
|
||||
|
||||
# Define an escape_quotes function to escape single quotes.
|
||||
# This allows us to handle quotes properly as long as we always use
|
||||
# use single quotes and escape_quotes.
|
||||
escape_quotes = $(subst ','\'',$(1))
|
||||
# This comment is here just to include a ' to unconfuse syntax highlighting.
|
||||
# Define an escape_vars function to escape '$' variable syntax.
|
||||
# This allows us to read/write command lines with shell variables (e.g.
|
||||
# $LD_LIBRARY_PATH), without triggering make substitution.
|
||||
escape_vars = $(subst $$,$$$$,$(1))
|
||||
# Helper that expands to a shell command to echo a string exactly as it is in
|
||||
# make. This uses printf instead of echo because printf's behaviour with respect
|
||||
# to escape sequences is more portable than echo's across different shells
|
||||
# (e.g., dash, bash).
|
||||
exact_echo = printf '%s\n' '$(call escape_quotes,$(1))'
|
||||
|
||||
# Helper to compare the command we're about to run against the command
|
||||
# we logged the last time we ran the command. Produces an empty
|
||||
# string (false) when the commands match.
|
||||
# Tricky point: Make has no string-equality test function.
|
||||
# The kernel uses the following, but it seems like it would have false
|
||||
# positives, where one string reordered its arguments.
|
||||
# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
|
||||
# $(filter-out $(cmd_$@), $(cmd_$(1))))
|
||||
# We instead substitute each for the empty string into the other, and
|
||||
# say they're equal if both substitutions produce the empty string.
|
||||
# .d files contain ? instead of spaces, take that into account.
|
||||
command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\
|
||||
$(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1))))
|
||||
|
||||
# Helper that is non-empty when a prerequisite changes.
|
||||
# Normally make does this implicitly, but we force rules to always run
|
||||
# so we can check their command lines.
|
||||
# $? -- new prerequisites
|
||||
# $| -- order-only dependencies
|
||||
prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?))
|
||||
|
||||
# Helper that executes all postbuilds until one fails.
|
||||
define do_postbuilds
|
||||
@E=0;\
|
||||
for p in $(POSTBUILDS); do\
|
||||
eval $$p;\
|
||||
E=$$?;\
|
||||
if [ $$E -ne 0 ]; then\
|
||||
break;\
|
||||
fi;\
|
||||
done;\
|
||||
if [ $$E -ne 0 ]; then\
|
||||
rm -rf "$@";\
|
||||
exit $$E;\
|
||||
fi
|
||||
endef
|
||||
|
||||
# do_cmd: run a command via the above cmd_foo names, if necessary.
|
||||
# Should always run for a given target to handle command-line changes.
|
||||
# Second argument, if non-zero, makes it do asm/C/C++ dependency munging.
|
||||
# Third argument, if non-zero, makes it do POSTBUILDS processing.
|
||||
# Note: We intentionally do NOT call dirx for depfile, since it contains ? for
|
||||
# spaces already and dirx strips the ? characters.
|
||||
define do_cmd
|
||||
$(if $(or $(command_changed),$(prereq_changed)),
|
||||
@$(call exact_echo, $($(quiet)cmd_$(1)))
|
||||
@mkdir -p "$(call dirx,$@)" "$(dir $(depfile))"
|
||||
$(if $(findstring flock,$(word 1,$(cmd_$1))),
|
||||
@$(cmd_$(1))
|
||||
@echo " $(quiet_cmd_$(1)): Finished",
|
||||
@$(cmd_$(1))
|
||||
)
|
||||
@$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile)
|
||||
@$(if $(2),$(fixup_dep))
|
||||
$(if $(and $(3), $(POSTBUILDS)),
|
||||
$(call do_postbuilds)
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# Declare the "all" target first so it is the default,
|
||||
# even though we don't have the deps yet.
|
||||
.PHONY: all
|
||||
all:
|
||||
|
||||
# make looks for ways to re-generate included makefiles, but in our case, we
|
||||
# don't have a direct way. Explicitly telling make that it has nothing to do
|
||||
# for them makes it go faster.
|
||||
%.d: ;
|
||||
|
||||
# Use FORCE_DO_CMD to force a target to run. Should be coupled with
|
||||
# do_cmd.
|
||||
.PHONY: FORCE_DO_CMD
|
||||
FORCE_DO_CMD:
|
||||
|
||||
TOOLSET := target
|
||||
# Suffix rules, putting all outputs into $(obj).
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
|
||||
# Try building from generated source, too.
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
|
||||
|
||||
ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
|
||||
$(findstring $(join ^,$(prefix)),\
|
||||
$(join ^,sshcrypto.target.mk)))),)
|
||||
include sshcrypto.target.mk
|
||||
endif
|
||||
|
||||
quiet_cmd_regen_makefile = ACTION Regenerating $@
|
||||
cmd_regen_makefile = cd $(srcdir); /usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/home/node/.cache/node-gyp/24.14.0" "-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp" "-Dnode_lib_file=/home/node/.cache/node-gyp/24.14.0/<(target_arch)/node.lib" "-Dmodule_root_dir=/home/node/.openclaw/workspace/tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto" "-Dnode_engine=v8" "--depth=." "-Goutput_dir=." "--generator-output=build" -I/home/node/.openclaw/workspace/tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto/build/config.gypi -I/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/home/node/.cache/node-gyp/24.14.0/include/node/common.gypi "--toplevel-dir=." binding.gyp
|
||||
Makefile: $(srcdir)/../../../../../../../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/../../../../../../../../../../.cache/node-gyp/24.14.0/include/node/common.gypi $(srcdir)/binding.gyp $(srcdir)/build/config.gypi
|
||||
$(call do_cmd,regen_makefile)
|
||||
|
||||
# "all" is a concatenation of the "all" targets from all the included
|
||||
# sub-makefiles. This is just here to clarify.
|
||||
all:
|
||||
|
||||
# Add in dependency-tracking rules. $(all_deps) is the list of every single
|
||||
# target in our tree. Only consider the ones with .d (dependency) info:
|
||||
d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d))
|
||||
ifneq ($(d_files),)
|
||||
include $(d_files)
|
||||
endif
|
||||
6
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto/build/binding.Makefile
generated
vendored
Normal file
6
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto/build/binding.Makefile
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
# This file is generated by gyp; do not edit.
|
||||
|
||||
export builddir_name ?= ./build/.
|
||||
.PHONY: all
|
||||
all:
|
||||
$(MAKE) sshcrypto
|
||||
532
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto/build/config.gypi
generated
vendored
Normal file
532
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto/build/config.gypi
generated
vendored
Normal file
@@ -0,0 +1,532 @@
|
||||
# Do not edit. File was generated by node-gyp's "configure" step
|
||||
{
|
||||
"variables": {
|
||||
"use_ccache_win": 0,
|
||||
"clang": 0,
|
||||
"llvm_version": "0.0",
|
||||
"gas_version": "2.38",
|
||||
"node_prefix": "/",
|
||||
"node_install_npm": "true",
|
||||
"node_install_corepack": "true",
|
||||
"control_flow_guard": "false",
|
||||
"node_use_amaro": "true",
|
||||
"debug_node": "false",
|
||||
"error_on_warn": "false",
|
||||
"suppress_all_error_on_warn": "false",
|
||||
"use_prefix_to_find_headers": "false",
|
||||
"host_arch": "x64",
|
||||
"target_arch": "x64",
|
||||
"node_byteorder": "little",
|
||||
"want_separate_host_toolset": 0,
|
||||
"node_use_node_snapshot": "true",
|
||||
"node_use_node_code_cache": "true",
|
||||
"node_write_snapshot_as_array_literals": "false",
|
||||
"node_enable_v8_vtunejit": "false",
|
||||
"enable_pgo_generate": "false",
|
||||
"enable_pgo_use": "false",
|
||||
"enable_lto": "false",
|
||||
"single_executable_application": "true",
|
||||
"node_with_ltcg": "false",
|
||||
"node_tag": "",
|
||||
"node_release_urlbase": "https://nodejs.org/download/release/",
|
||||
"node_debug_lib": "false",
|
||||
"debug_nghttp2": "false",
|
||||
"node_no_browser_globals": "false",
|
||||
"node_shared": "false",
|
||||
"libdir": "lib",
|
||||
"node_module_version": 137,
|
||||
"shlib_suffix": "so.137",
|
||||
"asan": 0,
|
||||
"ubsan": 0,
|
||||
"coverage": "false",
|
||||
"node_target_type": "executable",
|
||||
"node_library_files": [
|
||||
"lib/_http_agent.js",
|
||||
"lib/_http_client.js",
|
||||
"lib/_http_common.js",
|
||||
"lib/_http_incoming.js",
|
||||
"lib/_http_outgoing.js",
|
||||
"lib/_http_server.js",
|
||||
"lib/_stream_duplex.js",
|
||||
"lib/_stream_passthrough.js",
|
||||
"lib/_stream_readable.js",
|
||||
"lib/_stream_transform.js",
|
||||
"lib/_stream_wrap.js",
|
||||
"lib/_stream_writable.js",
|
||||
"lib/_tls_common.js",
|
||||
"lib/_tls_wrap.js",
|
||||
"lib/assert.js",
|
||||
"lib/assert/strict.js",
|
||||
"lib/async_hooks.js",
|
||||
"lib/buffer.js",
|
||||
"lib/child_process.js",
|
||||
"lib/cluster.js",
|
||||
"lib/console.js",
|
||||
"lib/constants.js",
|
||||
"lib/crypto.js",
|
||||
"lib/dgram.js",
|
||||
"lib/diagnostics_channel.js",
|
||||
"lib/dns.js",
|
||||
"lib/dns/promises.js",
|
||||
"lib/domain.js",
|
||||
"lib/events.js",
|
||||
"lib/fs.js",
|
||||
"lib/fs/promises.js",
|
||||
"lib/http.js",
|
||||
"lib/http2.js",
|
||||
"lib/https.js",
|
||||
"lib/inspector.js",
|
||||
"lib/inspector/promises.js",
|
||||
"lib/internal/abort_controller.js",
|
||||
"lib/internal/assert.js",
|
||||
"lib/internal/assert/assertion_error.js",
|
||||
"lib/internal/assert/calltracker.js",
|
||||
"lib/internal/assert/myers_diff.js",
|
||||
"lib/internal/assert/utils.js",
|
||||
"lib/internal/async_context_frame.js",
|
||||
"lib/internal/async_hooks.js",
|
||||
"lib/internal/async_local_storage/async_context_frame.js",
|
||||
"lib/internal/async_local_storage/async_hooks.js",
|
||||
"lib/internal/blob.js",
|
||||
"lib/internal/blocklist.js",
|
||||
"lib/internal/bootstrap/node.js",
|
||||
"lib/internal/bootstrap/realm.js",
|
||||
"lib/internal/bootstrap/shadow_realm.js",
|
||||
"lib/internal/bootstrap/switches/does_not_own_process_state.js",
|
||||
"lib/internal/bootstrap/switches/does_own_process_state.js",
|
||||
"lib/internal/bootstrap/switches/is_main_thread.js",
|
||||
"lib/internal/bootstrap/switches/is_not_main_thread.js",
|
||||
"lib/internal/bootstrap/web/exposed-wildcard.js",
|
||||
"lib/internal/bootstrap/web/exposed-window-or-worker.js",
|
||||
"lib/internal/buffer.js",
|
||||
"lib/internal/child_process.js",
|
||||
"lib/internal/child_process/serialization.js",
|
||||
"lib/internal/cli_table.js",
|
||||
"lib/internal/cluster/child.js",
|
||||
"lib/internal/cluster/primary.js",
|
||||
"lib/internal/cluster/round_robin_handle.js",
|
||||
"lib/internal/cluster/shared_handle.js",
|
||||
"lib/internal/cluster/utils.js",
|
||||
"lib/internal/cluster/worker.js",
|
||||
"lib/internal/console/constructor.js",
|
||||
"lib/internal/console/global.js",
|
||||
"lib/internal/constants.js",
|
||||
"lib/internal/crypto/aes.js",
|
||||
"lib/internal/crypto/argon2.js",
|
||||
"lib/internal/crypto/certificate.js",
|
||||
"lib/internal/crypto/cfrg.js",
|
||||
"lib/internal/crypto/chacha20_poly1305.js",
|
||||
"lib/internal/crypto/cipher.js",
|
||||
"lib/internal/crypto/diffiehellman.js",
|
||||
"lib/internal/crypto/ec.js",
|
||||
"lib/internal/crypto/hash.js",
|
||||
"lib/internal/crypto/hashnames.js",
|
||||
"lib/internal/crypto/hkdf.js",
|
||||
"lib/internal/crypto/kem.js",
|
||||
"lib/internal/crypto/keygen.js",
|
||||
"lib/internal/crypto/keys.js",
|
||||
"lib/internal/crypto/mac.js",
|
||||
"lib/internal/crypto/ml_dsa.js",
|
||||
"lib/internal/crypto/ml_kem.js",
|
||||
"lib/internal/crypto/pbkdf2.js",
|
||||
"lib/internal/crypto/random.js",
|
||||
"lib/internal/crypto/rsa.js",
|
||||
"lib/internal/crypto/scrypt.js",
|
||||
"lib/internal/crypto/sig.js",
|
||||
"lib/internal/crypto/util.js",
|
||||
"lib/internal/crypto/webcrypto.js",
|
||||
"lib/internal/crypto/webidl.js",
|
||||
"lib/internal/crypto/x509.js",
|
||||
"lib/internal/data_url.js",
|
||||
"lib/internal/debugger/inspect.js",
|
||||
"lib/internal/debugger/inspect_client.js",
|
||||
"lib/internal/debugger/inspect_repl.js",
|
||||
"lib/internal/dgram.js",
|
||||
"lib/internal/dns/callback_resolver.js",
|
||||
"lib/internal/dns/promises.js",
|
||||
"lib/internal/dns/utils.js",
|
||||
"lib/internal/encoding.js",
|
||||
"lib/internal/encoding/single-byte.js",
|
||||
"lib/internal/encoding/util.js",
|
||||
"lib/internal/error_serdes.js",
|
||||
"lib/internal/errors.js",
|
||||
"lib/internal/errors/error_source.js",
|
||||
"lib/internal/event_target.js",
|
||||
"lib/internal/events/abort_listener.js",
|
||||
"lib/internal/events/symbols.js",
|
||||
"lib/internal/file.js",
|
||||
"lib/internal/fixed_queue.js",
|
||||
"lib/internal/freelist.js",
|
||||
"lib/internal/freeze_intrinsics.js",
|
||||
"lib/internal/fs/cp/cp-sync.js",
|
||||
"lib/internal/fs/cp/cp.js",
|
||||
"lib/internal/fs/dir.js",
|
||||
"lib/internal/fs/glob.js",
|
||||
"lib/internal/fs/promises.js",
|
||||
"lib/internal/fs/read/context.js",
|
||||
"lib/internal/fs/recursive_watch.js",
|
||||
"lib/internal/fs/rimraf.js",
|
||||
"lib/internal/fs/streams.js",
|
||||
"lib/internal/fs/sync_write_stream.js",
|
||||
"lib/internal/fs/utils.js",
|
||||
"lib/internal/fs/watchers.js",
|
||||
"lib/internal/heap_utils.js",
|
||||
"lib/internal/histogram.js",
|
||||
"lib/internal/http.js",
|
||||
"lib/internal/http2/compat.js",
|
||||
"lib/internal/http2/core.js",
|
||||
"lib/internal/http2/util.js",
|
||||
"lib/internal/inspector/network.js",
|
||||
"lib/internal/inspector/network_http.js",
|
||||
"lib/internal/inspector/network_http2.js",
|
||||
"lib/internal/inspector/network_resources.js",
|
||||
"lib/internal/inspector/network_undici.js",
|
||||
"lib/internal/inspector_async_hook.js",
|
||||
"lib/internal/inspector_network_tracking.js",
|
||||
"lib/internal/js_stream_socket.js",
|
||||
"lib/internal/legacy/processbinding.js",
|
||||
"lib/internal/linkedlist.js",
|
||||
"lib/internal/locks.js",
|
||||
"lib/internal/main/check_syntax.js",
|
||||
"lib/internal/main/embedding.js",
|
||||
"lib/internal/main/eval_stdin.js",
|
||||
"lib/internal/main/eval_string.js",
|
||||
"lib/internal/main/inspect.js",
|
||||
"lib/internal/main/mksnapshot.js",
|
||||
"lib/internal/main/print_help.js",
|
||||
"lib/internal/main/prof_process.js",
|
||||
"lib/internal/main/repl.js",
|
||||
"lib/internal/main/run_main_module.js",
|
||||
"lib/internal/main/test_runner.js",
|
||||
"lib/internal/main/watch_mode.js",
|
||||
"lib/internal/main/worker_thread.js",
|
||||
"lib/internal/mime.js",
|
||||
"lib/internal/modules/cjs/loader.js",
|
||||
"lib/internal/modules/customization_hooks.js",
|
||||
"lib/internal/modules/esm/assert.js",
|
||||
"lib/internal/modules/esm/create_dynamic_module.js",
|
||||
"lib/internal/modules/esm/formats.js",
|
||||
"lib/internal/modules/esm/get_format.js",
|
||||
"lib/internal/modules/esm/hooks.js",
|
||||
"lib/internal/modules/esm/initialize_import_meta.js",
|
||||
"lib/internal/modules/esm/load.js",
|
||||
"lib/internal/modules/esm/loader.js",
|
||||
"lib/internal/modules/esm/module_job.js",
|
||||
"lib/internal/modules/esm/module_map.js",
|
||||
"lib/internal/modules/esm/resolve.js",
|
||||
"lib/internal/modules/esm/shared_constants.js",
|
||||
"lib/internal/modules/esm/translators.js",
|
||||
"lib/internal/modules/esm/utils.js",
|
||||
"lib/internal/modules/esm/worker.js",
|
||||
"lib/internal/modules/helpers.js",
|
||||
"lib/internal/modules/package_json_reader.js",
|
||||
"lib/internal/modules/run_main.js",
|
||||
"lib/internal/modules/typescript.js",
|
||||
"lib/internal/navigator.js",
|
||||
"lib/internal/net.js",
|
||||
"lib/internal/options.js",
|
||||
"lib/internal/per_context/domexception.js",
|
||||
"lib/internal/per_context/messageport.js",
|
||||
"lib/internal/per_context/primordials.js",
|
||||
"lib/internal/perf/event_loop_delay.js",
|
||||
"lib/internal/perf/event_loop_utilization.js",
|
||||
"lib/internal/perf/nodetiming.js",
|
||||
"lib/internal/perf/observe.js",
|
||||
"lib/internal/perf/performance.js",
|
||||
"lib/internal/perf/performance_entry.js",
|
||||
"lib/internal/perf/resource_timing.js",
|
||||
"lib/internal/perf/timerify.js",
|
||||
"lib/internal/perf/usertiming.js",
|
||||
"lib/internal/perf/utils.js",
|
||||
"lib/internal/priority_queue.js",
|
||||
"lib/internal/process/execution.js",
|
||||
"lib/internal/process/finalization.js",
|
||||
"lib/internal/process/per_thread.js",
|
||||
"lib/internal/process/permission.js",
|
||||
"lib/internal/process/pre_execution.js",
|
||||
"lib/internal/process/promises.js",
|
||||
"lib/internal/process/report.js",
|
||||
"lib/internal/process/signal.js",
|
||||
"lib/internal/process/task_queues.js",
|
||||
"lib/internal/process/warning.js",
|
||||
"lib/internal/process/worker_thread_only.js",
|
||||
"lib/internal/promise_hooks.js",
|
||||
"lib/internal/querystring.js",
|
||||
"lib/internal/quic/quic.js",
|
||||
"lib/internal/quic/state.js",
|
||||
"lib/internal/quic/stats.js",
|
||||
"lib/internal/quic/symbols.js",
|
||||
"lib/internal/readline/callbacks.js",
|
||||
"lib/internal/readline/emitKeypressEvents.js",
|
||||
"lib/internal/readline/interface.js",
|
||||
"lib/internal/readline/promises.js",
|
||||
"lib/internal/readline/utils.js",
|
||||
"lib/internal/repl.js",
|
||||
"lib/internal/repl/await.js",
|
||||
"lib/internal/repl/completion.js",
|
||||
"lib/internal/repl/history.js",
|
||||
"lib/internal/repl/utils.js",
|
||||
"lib/internal/socket_list.js",
|
||||
"lib/internal/socketaddress.js",
|
||||
"lib/internal/source_map/prepare_stack_trace.js",
|
||||
"lib/internal/source_map/source_map.js",
|
||||
"lib/internal/source_map/source_map_cache.js",
|
||||
"lib/internal/source_map/source_map_cache_map.js",
|
||||
"lib/internal/stream_base_commons.js",
|
||||
"lib/internal/streams/add-abort-signal.js",
|
||||
"lib/internal/streams/compose.js",
|
||||
"lib/internal/streams/destroy.js",
|
||||
"lib/internal/streams/duplex.js",
|
||||
"lib/internal/streams/duplexify.js",
|
||||
"lib/internal/streams/duplexpair.js",
|
||||
"lib/internal/streams/end-of-stream.js",
|
||||
"lib/internal/streams/fast-utf8-stream.js",
|
||||
"lib/internal/streams/from.js",
|
||||
"lib/internal/streams/lazy_transform.js",
|
||||
"lib/internal/streams/legacy.js",
|
||||
"lib/internal/streams/operators.js",
|
||||
"lib/internal/streams/passthrough.js",
|
||||
"lib/internal/streams/pipeline.js",
|
||||
"lib/internal/streams/readable.js",
|
||||
"lib/internal/streams/state.js",
|
||||
"lib/internal/streams/transform.js",
|
||||
"lib/internal/streams/utils.js",
|
||||
"lib/internal/streams/writable.js",
|
||||
"lib/internal/test/binding.js",
|
||||
"lib/internal/test/transfer.js",
|
||||
"lib/internal/test_runner/assert.js",
|
||||
"lib/internal/test_runner/coverage.js",
|
||||
"lib/internal/test_runner/harness.js",
|
||||
"lib/internal/test_runner/mock/loader.js",
|
||||
"lib/internal/test_runner/mock/mock.js",
|
||||
"lib/internal/test_runner/mock/mock_timers.js",
|
||||
"lib/internal/test_runner/reporter/dot.js",
|
||||
"lib/internal/test_runner/reporter/junit.js",
|
||||
"lib/internal/test_runner/reporter/lcov.js",
|
||||
"lib/internal/test_runner/reporter/rerun.js",
|
||||
"lib/internal/test_runner/reporter/spec.js",
|
||||
"lib/internal/test_runner/reporter/tap.js",
|
||||
"lib/internal/test_runner/reporter/utils.js",
|
||||
"lib/internal/test_runner/reporter/v8-serializer.js",
|
||||
"lib/internal/test_runner/runner.js",
|
||||
"lib/internal/test_runner/snapshot.js",
|
||||
"lib/internal/test_runner/test.js",
|
||||
"lib/internal/test_runner/tests_stream.js",
|
||||
"lib/internal/test_runner/utils.js",
|
||||
"lib/internal/timers.js",
|
||||
"lib/internal/tls/common.js",
|
||||
"lib/internal/tls/secure-context.js",
|
||||
"lib/internal/tls/wrap.js",
|
||||
"lib/internal/trace_events_async_hooks.js",
|
||||
"lib/internal/tty.js",
|
||||
"lib/internal/url.js",
|
||||
"lib/internal/util.js",
|
||||
"lib/internal/util/colors.js",
|
||||
"lib/internal/util/comparisons.js",
|
||||
"lib/internal/util/debuglog.js",
|
||||
"lib/internal/util/diff.js",
|
||||
"lib/internal/util/inspect.js",
|
||||
"lib/internal/util/inspector.js",
|
||||
"lib/internal/util/parse_args/parse_args.js",
|
||||
"lib/internal/util/parse_args/utils.js",
|
||||
"lib/internal/util/trace_sigint.js",
|
||||
"lib/internal/util/types.js",
|
||||
"lib/internal/v8/startup_snapshot.js",
|
||||
"lib/internal/v8_prof_polyfill.js",
|
||||
"lib/internal/v8_prof_processor.js",
|
||||
"lib/internal/validators.js",
|
||||
"lib/internal/vm.js",
|
||||
"lib/internal/vm/module.js",
|
||||
"lib/internal/wasm_web_api.js",
|
||||
"lib/internal/watch_mode/files_watcher.js",
|
||||
"lib/internal/watchdog.js",
|
||||
"lib/internal/webidl.js",
|
||||
"lib/internal/webstorage.js",
|
||||
"lib/internal/webstreams/adapters.js",
|
||||
"lib/internal/webstreams/compression.js",
|
||||
"lib/internal/webstreams/encoding.js",
|
||||
"lib/internal/webstreams/queuingstrategies.js",
|
||||
"lib/internal/webstreams/readablestream.js",
|
||||
"lib/internal/webstreams/transfer.js",
|
||||
"lib/internal/webstreams/transformstream.js",
|
||||
"lib/internal/webstreams/util.js",
|
||||
"lib/internal/webstreams/writablestream.js",
|
||||
"lib/internal/worker.js",
|
||||
"lib/internal/worker/clone_dom_exception.js",
|
||||
"lib/internal/worker/io.js",
|
||||
"lib/internal/worker/js_transferable.js",
|
||||
"lib/internal/worker/messaging.js",
|
||||
"lib/module.js",
|
||||
"lib/net.js",
|
||||
"lib/os.js",
|
||||
"lib/path.js",
|
||||
"lib/path/posix.js",
|
||||
"lib/path/win32.js",
|
||||
"lib/perf_hooks.js",
|
||||
"lib/process.js",
|
||||
"lib/punycode.js",
|
||||
"lib/querystring.js",
|
||||
"lib/quic.js",
|
||||
"lib/readline.js",
|
||||
"lib/readline/promises.js",
|
||||
"lib/repl.js",
|
||||
"lib/sea.js",
|
||||
"lib/sqlite.js",
|
||||
"lib/stream.js",
|
||||
"lib/stream/consumers.js",
|
||||
"lib/stream/promises.js",
|
||||
"lib/stream/web.js",
|
||||
"lib/string_decoder.js",
|
||||
"lib/sys.js",
|
||||
"lib/test.js",
|
||||
"lib/test/reporters.js",
|
||||
"lib/timers.js",
|
||||
"lib/timers/promises.js",
|
||||
"lib/tls.js",
|
||||
"lib/trace_events.js",
|
||||
"lib/tty.js",
|
||||
"lib/url.js",
|
||||
"lib/util.js",
|
||||
"lib/util/types.js",
|
||||
"lib/v8.js",
|
||||
"lib/vm.js",
|
||||
"lib/wasi.js",
|
||||
"lib/worker_threads.js",
|
||||
"lib/zlib.js"
|
||||
],
|
||||
"node_cctest_sources": [
|
||||
"src/node_snapshot_stub.cc",
|
||||
"test/cctest/inspector/test_network_requests_buffer.cc",
|
||||
"test/cctest/inspector/test_node_protocol.cc",
|
||||
"test/cctest/node_test_fixture.cc",
|
||||
"test/cctest/test_aliased_buffer.cc",
|
||||
"test/cctest/test_base64.cc",
|
||||
"test/cctest/test_base_object_ptr.cc",
|
||||
"test/cctest/test_cppgc.cc",
|
||||
"test/cctest/test_crypto_clienthello.cc",
|
||||
"test/cctest/test_dataqueue.cc",
|
||||
"test/cctest/test_environment.cc",
|
||||
"test/cctest/test_inspector_socket.cc",
|
||||
"test/cctest/test_inspector_socket_server.cc",
|
||||
"test/cctest/test_json_utils.cc",
|
||||
"test/cctest/test_linked_binding.cc",
|
||||
"test/cctest/test_lru_cache.cc",
|
||||
"test/cctest/test_node_api.cc",
|
||||
"test/cctest/test_node_crypto.cc",
|
||||
"test/cctest/test_node_crypto_env.cc",
|
||||
"test/cctest/test_node_postmortem_metadata.cc",
|
||||
"test/cctest/test_node_task_runner.cc",
|
||||
"test/cctest/test_path.cc",
|
||||
"test/cctest/test_per_process.cc",
|
||||
"test/cctest/test_platform.cc",
|
||||
"test/cctest/test_quic_cid.cc",
|
||||
"test/cctest/test_quic_error.cc",
|
||||
"test/cctest/test_quic_tokens.cc",
|
||||
"test/cctest/test_report.cc",
|
||||
"test/cctest/test_sockaddr.cc",
|
||||
"test/cctest/test_string_bytes.cc",
|
||||
"test/cctest/test_traced_value.cc",
|
||||
"test/cctest/test_util.cc",
|
||||
"test/cctest/node_test_fixture.h"
|
||||
],
|
||||
"napi_build_version": "10",
|
||||
"node_shared_zlib": "false",
|
||||
"node_shared_http_parser": "false",
|
||||
"node_shared_libuv": "false",
|
||||
"node_shared_ada": "false",
|
||||
"node_shared_simdjson": "false",
|
||||
"node_shared_simdutf": "false",
|
||||
"node_shared_brotli": "false",
|
||||
"node_shared_cares": "false",
|
||||
"node_shared_gtest": "false",
|
||||
"node_shared_hdr_histogram": "false",
|
||||
"node_shared_merve": "false",
|
||||
"node_shared_nbytes": "false",
|
||||
"node_shared_nghttp2": "false",
|
||||
"node_shared_nghttp3": "false",
|
||||
"node_shared_ngtcp2": "false",
|
||||
"node_use_sqlite": "true",
|
||||
"node_shared_sqlite": "false",
|
||||
"node_shared_uvwasi": "false",
|
||||
"node_shared_zstd": "false",
|
||||
"v8_enable_webassembly": 1,
|
||||
"v8_enable_javascript_promise_hooks": 1,
|
||||
"v8_enable_lite_mode": 0,
|
||||
"v8_enable_gdbjit": 0,
|
||||
"v8_optimized_debug": 1,
|
||||
"dcheck_always_on": 0,
|
||||
"v8_enable_object_print": 1,
|
||||
"v8_random_seed": 0,
|
||||
"v8_promise_internal_field_count": 1,
|
||||
"v8_use_siphash": 1,
|
||||
"v8_enable_maglev": 1,
|
||||
"v8_enable_pointer_compression": 0,
|
||||
"v8_enable_sandbox": 0,
|
||||
"v8_enable_pointer_compression_shared_cage": 0,
|
||||
"v8_enable_external_code_space": 0,
|
||||
"v8_enable_31bit_smis_on_64bit_arch": 0,
|
||||
"v8_enable_extensible_ro_snapshot": 0,
|
||||
"v8_trace_maps": 0,
|
||||
"node_use_v8_platform": "true",
|
||||
"node_use_bundled_v8": "true",
|
||||
"force_dynamic_crt": 0,
|
||||
"node_enable_d8": "false",
|
||||
"node_enable_v8windbg": "false",
|
||||
"v8_enable_hugepage": 0,
|
||||
"v8_enable_short_builtin_calls": 1,
|
||||
"v8_enable_wasm_simd256_revec": 1,
|
||||
"node_use_openssl": "true",
|
||||
"node_shared_openssl": "false",
|
||||
"openssl_is_fips": "false",
|
||||
"node_quic": "false",
|
||||
"node_fipsinstall": "false",
|
||||
"node_without_node_options": "false",
|
||||
"openssl_quic": "false",
|
||||
"icu_small": "false",
|
||||
"v8_enable_i18n_support": 1,
|
||||
"icu_gyp_path": "tools/icu/icu-generic.gyp",
|
||||
"icu_path": "deps/icu-small",
|
||||
"icu_ver_major": "78",
|
||||
"icu_endianness": "l",
|
||||
"icu_data_in": "../../deps/icu-tmp/icudt78l.dat",
|
||||
"v8_enable_inspector": 1,
|
||||
"node_section_ordering_info": "",
|
||||
"node_builtin_shareable_builtins": [
|
||||
"deps/undici/undici.js",
|
||||
"deps/amaro/dist/index.js"
|
||||
],
|
||||
"ossfuzz": "false",
|
||||
"nodedir": "/home/node/.cache/node-gyp/24.14.0",
|
||||
"python": "/usr/bin/python3",
|
||||
"standalone_static_library": 1,
|
||||
"target": "v24.14.0",
|
||||
"real_openssl_major": "3",
|
||||
"global_prefix": "/usr/local",
|
||||
"init_module": "/home/node/.npm-init.js",
|
||||
"globalconfig": "/usr/local/etc/npmrc",
|
||||
"node_gyp": "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",
|
||||
"cache": "/home/node/.npm",
|
||||
"npm_version": "11.9.0",
|
||||
"prefix": "/usr/local",
|
||||
"local_prefix": "/home/node/.openclaw/workspace/tasks/enduro-trails/prototype",
|
||||
"userconfig": "/home/node/.npmrc",
|
||||
"user_agent": "npm/11.9.0 node/v24.14.0 linux x64 workspaces/false"
|
||||
},
|
||||
"target_defaults": {
|
||||
"include_dirs": [],
|
||||
"libraries": [],
|
||||
"defines": [],
|
||||
"cflags": [],
|
||||
"default_configuration": "Release",
|
||||
"configurations": {
|
||||
"Release": {
|
||||
"variables": {},
|
||||
"v8_enable_v8_checks": 1
|
||||
},
|
||||
"Debug": {
|
||||
"variables": {},
|
||||
"v8_enable_v8_checks": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
164
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto/build/sshcrypto.target.mk
generated
vendored
Normal file
164
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto/build/sshcrypto.target.mk
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
# This file is generated by gyp; do not edit.
|
||||
|
||||
TOOLSET := target
|
||||
TARGET := sshcrypto
|
||||
DEFS_Debug := \
|
||||
'-DNODE_GYP_MODULE_NAME=sshcrypto' \
|
||||
'-DUSING_UV_SHARED=1' \
|
||||
'-DUSING_V8_SHARED=1' \
|
||||
'-DV8_DEPRECATION_WARNINGS=1' \
|
||||
'-D_GLIBCXX_USE_CXX11_ABI=1' \
|
||||
'-D_FILE_OFFSET_BITS=64' \
|
||||
'-D_LARGEFILE_SOURCE' \
|
||||
'-D__STDC_FORMAT_MACROS' \
|
||||
'-DOPENSSL_NO_PINSHARED' \
|
||||
'-DOPENSSL_THREADS' \
|
||||
'-DOPENSSL_API_COMPAT=0x10100000L' \
|
||||
'-DREAL_OPENSSL_MAJOR=3' \
|
||||
'-DBUILDING_NODE_EXTENSION' \
|
||||
'-DDEBUG' \
|
||||
'-D_DEBUG'
|
||||
|
||||
# Flags passed to all source files.
|
||||
CFLAGS_Debug := \
|
||||
-fPIC \
|
||||
-pthread \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wno-unused-parameter \
|
||||
-O3 \
|
||||
-m64 \
|
||||
-g \
|
||||
-O0
|
||||
|
||||
# Flags passed to only C files.
|
||||
CFLAGS_C_Debug :=
|
||||
|
||||
# Flags passed to only C++ files.
|
||||
CFLAGS_CC_Debug := \
|
||||
-fno-rtti \
|
||||
-fno-exceptions \
|
||||
-fno-strict-aliasing \
|
||||
-std=gnu++20
|
||||
|
||||
INCS_Debug := \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/include/node \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/src \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/deps/openssl/config \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/deps/openssl/openssl/include \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/deps/uv/include \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/deps/zlib \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/deps/v8/include \
|
||||
-I$(srcdir)/../../../../nan
|
||||
|
||||
DEFS_Release := \
|
||||
'-DNODE_GYP_MODULE_NAME=sshcrypto' \
|
||||
'-DUSING_UV_SHARED=1' \
|
||||
'-DUSING_V8_SHARED=1' \
|
||||
'-DV8_DEPRECATION_WARNINGS=1' \
|
||||
'-D_GLIBCXX_USE_CXX11_ABI=1' \
|
||||
'-D_FILE_OFFSET_BITS=64' \
|
||||
'-D_LARGEFILE_SOURCE' \
|
||||
'-D__STDC_FORMAT_MACROS' \
|
||||
'-DOPENSSL_NO_PINSHARED' \
|
||||
'-DOPENSSL_THREADS' \
|
||||
'-DOPENSSL_API_COMPAT=0x10100000L' \
|
||||
'-DREAL_OPENSSL_MAJOR=3' \
|
||||
'-DBUILDING_NODE_EXTENSION'
|
||||
|
||||
# Flags passed to all source files.
|
||||
CFLAGS_Release := \
|
||||
-fPIC \
|
||||
-pthread \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wno-unused-parameter \
|
||||
-O3 \
|
||||
-m64 \
|
||||
-O3 \
|
||||
-fno-omit-frame-pointer
|
||||
|
||||
# Flags passed to only C files.
|
||||
CFLAGS_C_Release :=
|
||||
|
||||
# Flags passed to only C++ files.
|
||||
CFLAGS_CC_Release := \
|
||||
-fno-rtti \
|
||||
-fno-exceptions \
|
||||
-fno-strict-aliasing \
|
||||
-std=gnu++20
|
||||
|
||||
INCS_Release := \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/include/node \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/src \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/deps/openssl/config \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/deps/openssl/openssl/include \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/deps/uv/include \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/deps/zlib \
|
||||
-I/home/node/.cache/node-gyp/24.14.0/deps/v8/include \
|
||||
-I$(srcdir)/../../../../nan
|
||||
|
||||
OBJS := \
|
||||
$(obj).target/$(TARGET)/src/binding.o
|
||||
|
||||
# Add to the list of files we specially track dependencies for.
|
||||
all_deps += $(OBJS)
|
||||
|
||||
# CFLAGS et al overrides must be target-local.
|
||||
# See "Target-specific Variable Values" in the GNU Make manual.
|
||||
$(OBJS): TOOLSET := $(TOOLSET)
|
||||
$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
|
||||
$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
|
||||
|
||||
# Suffix rules, putting all outputs into $(obj).
|
||||
|
||||
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
|
||||
# Try building from generated source, too.
|
||||
|
||||
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
|
||||
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
|
||||
# End of this set of suffix rules
|
||||
### Rules for final target.
|
||||
LDFLAGS_Debug := \
|
||||
-pthread \
|
||||
-rdynamic \
|
||||
-m64
|
||||
|
||||
LDFLAGS_Release := \
|
||||
-pthread \
|
||||
-rdynamic \
|
||||
-m64
|
||||
|
||||
LIBS :=
|
||||
|
||||
$(obj).target/sshcrypto.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
|
||||
$(obj).target/sshcrypto.node: LIBS := $(LIBS)
|
||||
$(obj).target/sshcrypto.node: TOOLSET := $(TOOLSET)
|
||||
$(obj).target/sshcrypto.node: $(OBJS) FORCE_DO_CMD
|
||||
$(call do_cmd,solink_module)
|
||||
|
||||
all_deps += $(obj).target/sshcrypto.node
|
||||
# Add target alias
|
||||
.PHONY: sshcrypto
|
||||
sshcrypto: $(builddir)/sshcrypto.node
|
||||
|
||||
# Copy this to the executable output path.
|
||||
$(builddir)/sshcrypto.node: TOOLSET := $(TOOLSET)
|
||||
$(builddir)/sshcrypto.node: $(obj).target/sshcrypto.node FORCE_DO_CMD
|
||||
$(call do_cmd,copy)
|
||||
|
||||
all_deps += $(builddir)/sshcrypto.node
|
||||
# Short alias for building this executable.
|
||||
.PHONY: sshcrypto.node
|
||||
sshcrypto.node: $(obj).target/sshcrypto.node $(builddir)/sshcrypto.node
|
||||
|
||||
# Add executable to "all" target.
|
||||
.PHONY: all
|
||||
all: $(builddir)/sshcrypto.node
|
||||
|
||||
43
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto/poly1305.js
generated
vendored
Normal file
43
tasks/enduro-trails/prototype/node_modules/ssh2/lib/protocol/crypto/poly1305.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user