This commit is contained in:
2025-01-04 00:34:03 +01:00
parent 41829408dc
commit 0ca14bbc19
18111 changed files with 1871397 additions and 0 deletions

20
resources/app/node_modules/@dabh/diagnostics/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2015 Arnout Kazemier, Martijn Swaagman, the 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.

View File

@@ -0,0 +1,11 @@
var adapter = require('./');
/**
* Extracts the values from process.env.
*
* @type {Function}
* @public
*/
module.exports = adapter(function hash() {
return /(debug|diagnostics)=([^&]+)/i.exec(window.location.hash)[2];
});

View File

@@ -0,0 +1,18 @@
var enabled = require('enabled');
/**
* Creates a new Adapter.
*
* @param {Function} fn Function that returns the value.
* @returns {Function} The adapter logic.
* @public
*/
module.exports = function create(fn) {
return function adapter(namespace) {
try {
return enabled(namespace, fn());
} catch (e) { /* Any failure means that we found nothing */ }
return false;
};
}

View File

@@ -0,0 +1,11 @@
var adapter = require('./');
/**
* Extracts the values from process.env.
*
* @type {Function}
* @public
*/
module.exports = adapter(function storage() {
return localStorage.getItem('debug') || localStorage.getItem('diagnostics');
});

View File

@@ -0,0 +1,11 @@
var adapter = require('./');
/**
* Extracts the values from process.env.
*
* @type {Function}
* @public
*/
module.exports = adapter(function processenv() {
return process.env.DEBUG || process.env.DIAGNOSTICS;
});

View File

@@ -0,0 +1,35 @@
var create = require('../diagnostics');
/**
* Create a new diagnostics logger.
*
* @param {String} namespace The namespace it should enable.
* @param {Object} options Additional options.
* @returns {Function} The logger.
* @public
*/
var diagnostics = create(function dev(namespace, options) {
options = options || {};
options.namespace = namespace;
options.prod = false;
options.dev = true;
if (!dev.enabled(namespace) && !(options.force || dev.force)) {
return dev.nope(options);
}
return dev.yep(options);
});
//
// Configure the logger for the given environment.
//
diagnostics.modify(require('../modifiers/namespace'));
diagnostics.use(require('../adapters/localstorage'));
diagnostics.use(require('../adapters/hash'));
diagnostics.set(require('../logger/console'));
//
// Expose the diagnostics logger.
//
module.exports = diagnostics;

View File

@@ -0,0 +1,8 @@
//
// Select the correct build version depending on the environment.
//
if (process.env.NODE_ENV === 'production') {
module.exports = require('./production.js');
} else {
module.exports = require('./development.js');
}

View File

@@ -0,0 +1,6 @@
var diagnostics = require('./');
//
// No way to override `debug` with `diagnostics` in the browser.
//
module.exports = diagnostics;

View File

@@ -0,0 +1,24 @@
var create = require('../diagnostics');
/**
* Create a new diagnostics logger.
*
* @param {String} namespace The namespace it should enable.
* @param {Object} options Additional options.
* @returns {Function} The logger.
* @public
*/
var diagnostics = create(function prod(namespace, options) {
options = options || {};
options.namespace = namespace;
options.prod = true;
options.dev = false;
if (!(options.force || prod.force)) return prod.nope(options);
return prod.yep(options);
});
//
// Expose the diagnostics logger.
//
module.exports = diagnostics;

View File

@@ -0,0 +1,212 @@
/**
* Contains all configured adapters for the given environment.
*
* @type {Array}
* @public
*/
var adapters = [];
/**
* Contains all modifier functions.
*
* @typs {Array}
* @public
*/
var modifiers = [];
/**
* Our default logger.
*
* @public
*/
var logger = function devnull() {};
/**
* Register a new adapter that will used to find environments.
*
* @param {Function} adapter A function that will return the possible env.
* @returns {Boolean} Indication of a successful add.
* @public
*/
function use(adapter) {
if (~adapters.indexOf(adapter)) return false;
adapters.push(adapter);
return true;
}
/**
* Assign a new log method.
*
* @param {Function} custom The log method.
* @public
*/
function set(custom) {
logger = custom;
}
/**
* Check if the namespace is allowed by any of our adapters.
*
* @param {String} namespace The namespace that needs to be enabled
* @returns {Boolean|Promise} Indication if the namespace is enabled by our adapters.
* @public
*/
function enabled(namespace) {
var async = [];
for (var i = 0; i < adapters.length; i++) {
if (adapters[i].async) {
async.push(adapters[i]);
continue;
}
if (adapters[i](namespace)) return true;
}
if (!async.length) return false;
//
// Now that we know that we Async functions, we know we run in an ES6
// environment and can use all the API's that they offer, in this case
// we want to return a Promise so that we can `await` in React-Native
// for an async adapter.
//
return new Promise(function pinky(resolve) {
Promise.all(
async.map(function prebind(fn) {
return fn(namespace);
})
).then(function resolved(values) {
resolve(values.some(Boolean));
});
});
}
/**
* Add a new message modifier to the debugger.
*
* @param {Function} fn Modification function.
* @returns {Boolean} Indication of a successful add.
* @public
*/
function modify(fn) {
if (~modifiers.indexOf(fn)) return false;
modifiers.push(fn);
return true;
}
/**
* Write data to the supplied logger.
*
* @param {Object} meta Meta information about the log.
* @param {Array} args Arguments for console.log.
* @public
*/
function write() {
logger.apply(logger, arguments);
}
/**
* Process the message with the modifiers.
*
* @param {Mixed} message The message to be transformed by modifers.
* @returns {String} Transformed message.
* @public
*/
function process(message) {
for (var i = 0; i < modifiers.length; i++) {
message = modifiers[i].apply(modifiers[i], arguments);
}
return message;
}
/**
* Introduce options to the logger function.
*
* @param {Function} fn Calback function.
* @param {Object} options Properties to introduce on fn.
* @returns {Function} The passed function
* @public
*/
function introduce(fn, options) {
var has = Object.prototype.hasOwnProperty;
for (var key in options) {
if (has.call(options, key)) {
fn[key] = options[key];
}
}
return fn;
}
/**
* Nope, we're not allowed to write messages.
*
* @returns {Boolean} false
* @public
*/
function nope(options) {
options.enabled = false;
options.modify = modify;
options.set = set;
options.use = use;
return introduce(function diagnopes() {
return false;
}, options);
}
/**
* Yep, we're allowed to write debug messages.
*
* @param {Object} options The options for the process.
* @returns {Function} The function that does the logging.
* @public
*/
function yep(options) {
/**
* The function that receives the actual debug information.
*
* @returns {Boolean} indication that we're logging.
* @public
*/
function diagnostics() {
var args = Array.prototype.slice.call(arguments, 0);
write.call(write, options, process(args, options));
return true;
}
options.enabled = true;
options.modify = modify;
options.set = set;
options.use = use;
return introduce(diagnostics, options);
}
/**
* Simple helper function to introduce various of helper methods to our given
* diagnostics function.
*
* @param {Function} diagnostics The diagnostics function.
* @returns {Function} diagnostics
* @public
*/
module.exports = function create(diagnostics) {
diagnostics.introduce = introduce;
diagnostics.enabled = enabled;
diagnostics.process = process;
diagnostics.modify = modify;
diagnostics.write = write;
diagnostics.nope = nope;
diagnostics.yep = yep;
diagnostics.set = set;
diagnostics.use = use;
return diagnostics;
}

View File

@@ -0,0 +1,19 @@
/**
* An idiot proof logger to be used as default. We've wrapped it in a try/catch
* statement to ensure the environments without the `console` API do not crash
* as well as an additional fix for ancient browsers like IE8 where the
* `console.log` API doesn't have an `apply`, so we need to use the Function's
* apply functionality to apply the arguments.
*
* @param {Object} meta Options of the logger.
* @param {Array} messages The actuall message that needs to be logged.
* @public
*/
module.exports = function (meta, messages) {
//
// So yea. IE8 doesn't have an apply so we need a work around to puke the
// arguments in place.
//
try { Function.prototype.apply.call(console.log, console, messages); }
catch (e) {}
}

View File

@@ -0,0 +1,20 @@
var colorspace = require('colorspace');
var kuler = require('kuler');
/**
* Prefix the messages with a colored namespace.
*
* @param {Array} args The messages array that is getting written.
* @param {Object} options Options for diagnostics.
* @returns {Array} Altered messages array.
* @public
*/
module.exports = function ansiModifier(args, options) {
var namespace = options.namespace;
var ansi = options.colors !== false
? kuler(namespace +':', colorspace(namespace))
: namespace +':';
args[0] = ansi +' '+ args[0];
return args;
};

View File

@@ -0,0 +1,32 @@
var colorspace = require('colorspace');
/**
* Prefix the messages with a colored namespace.
*
* @param {Array} messages The messages array that is getting written.
* @param {Object} options Options for diagnostics.
* @returns {Array} Altered messages array.
* @public
*/
module.exports = function colorNamespace(args, options) {
var namespace = options.namespace;
if (options.colors === false) {
args[0] = namespace +': '+ args[0];
return args;
}
var color = colorspace(namespace);
//
// The console API supports a special %c formatter in browsers. This is used
// to style console messages with any CSS styling, in our case we want to
// use colorize the namespace for clarity. As these are formatters, and
// we need to inject our CSS string as second messages argument so it
// gets picked up correctly.
//
args[0] = '%c'+ namespace +':%c '+ args[0];
args.splice(1, 0, 'color:'+ color, 'color:inherit');
return args;
};

View File

@@ -0,0 +1,36 @@
var create = require('../diagnostics');
var tty = require('tty').isatty(1);
/**
* Create a new diagnostics logger.
*
* @param {String} namespace The namespace it should enable.
* @param {Object} options Additional options.
* @returns {Function} The logger.
* @public
*/
var diagnostics = create(function dev(namespace, options) {
options = options || {};
options.colors = 'colors' in options ? options.colors : tty;
options.namespace = namespace;
options.prod = false;
options.dev = true;
if (!dev.enabled(namespace) && !(options.force || dev.force)) {
return dev.nope(options);
}
return dev.yep(options);
});
//
// Configure the logger for the given environment.
//
diagnostics.modify(require('../modifiers/namespace-ansi'));
diagnostics.use(require('../adapters/process.env'));
diagnostics.set(require('../logger/console'));
//
// Expose the diagnostics logger.
//
module.exports = diagnostics;

View File

@@ -0,0 +1,8 @@
//
// Select the correct build version depending on the environment.
//
if (process.env.NODE_ENV === 'production') {
module.exports = require('./production.js');
} else {
module.exports = require('./development.js');
}

View File

@@ -0,0 +1,21 @@
const diagnostics = require('./');
//
// Override the existing `debug` call so it will use `diagnostics` instead
// of the `debug` module.
//
try {
var key = require.resolve('debug');
require.cache[key] = {
exports: diagnostics,
filename: key,
loaded: true,
id: key
};
} catch (e) { /* We don't really care if it fails */ }
//
// Export the default import as exports again.
//
module.exports = diagnostics;

View File

@@ -0,0 +1,24 @@
var create = require('../diagnostics');
/**
* Create a new diagnostics logger.
*
* @param {String} namespace The namespace it should enable.
* @param {Object} options Additional options.
* @returns {Function} The logger.
* @public
*/
var diagnostics = create(function prod(namespace, options) {
options = options || {};
options.namespace = namespace;
options.prod = true;
options.dev = false;
if (!(options.force || prod.force)) return prod.nope(options);
return prod.yep(options);
});
//
// Expose the diagnostics logger.
//
module.exports = diagnostics;

View File

@@ -0,0 +1,34 @@
{
"name": "@dabh/diagnostics",
"version": "2.0.3",
"description": "Tools for debugging your node.js modules and event loop",
"main": "./node",
"browser": "./browser",
"repository": {
"type": "git",
"url": "git://github.com/3rd-Eden/diagnostics.git"
},
"author": "Arnout Kazemier",
"license": "MIT",
"homepage": "https://github.com/3rd-Eden/diagnostics",
"devDependencies": {
"assume": "2.3.x",
"asyncstorageapi": "^1.0.2",
"mocha": "9.2.x",
"nyc": "^15.1.0",
"objstorage": "^1.0.0",
"pre-commit": "1.2.x",
"require-poisoning": "^2.0.0",
"webpack": "4.x",
"webpack-bundle-size-analyzer": "^3.0.0",
"webpack-cli": "3.x"
},
"dependencies": {
"colorspace": "1.1.x",
"enabled": "2.0.x",
"kuler": "^2.0.0"
},
"directories": {
"test": "test"
}
}