New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ulixee/commons

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ulixee/commons - npm Package Compare versions

Comparing version 2.0.0-alpha.5 to 2.0.0-alpha.6

1

config/index.d.ts

@@ -13,3 +13,2 @@ export default class UlixeeConfig {

constructor(directoryPath: string);
setGlobalDefaults(): Promise<void>;
save(): Promise<void>;

@@ -16,0 +15,0 @@ private getData;

17

config/index.js

@@ -22,6 +22,2 @@ "use strict";

}
async setGlobalDefaults() {
this.serverHost ?? (this.serverHost = 'localhost:1337');
await this.save();
}
save() {

@@ -42,5 +38,6 @@ return (0, fileUtils_1.safeOverwriteFile)(this.configPath, JSON.stringify(this.getData(), null, 2));

return UlixeeConfig.global;
if (!this.isCacheEnabled)
return new UlixeeConfig(directory);
this.cachedConfigObjects[key] = new UlixeeConfig(directory);
const config = new UlixeeConfig(directory);
if (this.isCacheEnabled)
this.cachedConfigObjects[key] = config;
return config;
}

@@ -54,5 +51,5 @@ return this.cachedConfigObjects[key];

const configDirectory = this.traverseDirectories(runtimeLocation);
if (!this.isCacheEnabled)
return configDirectory;
this.cachedConfigLocations[key] = configDirectory;
if (this.isCacheEnabled)
this.cachedConfigLocations[key] = configDirectory;
return configDirectory;
}

@@ -59,0 +56,0 @@ return this.cachedConfigLocations[key];

@@ -28,3 +28,5 @@ "use strict";

}
catch (err) { }
catch (err) {
/* no-op */
}
this.hostByVersion[version] = {

@@ -31,0 +33,0 @@ host,

@@ -6,7 +6,2 @@ /// <reference types="node" />

import { IBoundLog } from '../interfaces/ILog';
export declare function addEventListener(emitter: EventEmitter, eventName: string | symbol, handler: (...args: any[]) => void): IRegisteredEventListener;
export declare function addEventListeners(emitter: EventEmitter, registrations: [string | symbol, (...args: any[]) => void, boolean?][]): IRegisteredEventListener[];
export declare function removeEventListeners(listeners: Array<IRegisteredEventListener>): void;
export declare function addTypedEventListener<T, K extends keyof T & (string | symbol)>(emitter: TypedEventEmitter<T>, eventName: K, handler: (this: TypedEventEmitter<T>, event?: T[K], initiator?: any) => any, includeUnhandledEvents?: boolean): IRegisteredEventListener;
export declare function addTypedEventListeners<T, K extends keyof T & (string | symbol)>(emitter: TypedEventEmitter<T>, registrations: [K, (this: TypedEventEmitter<T>, event?: T[K]) => any, boolean?][]): IRegisteredEventListener[];
export declare class TypedEventEmitter<T> extends EventEmitter implements ITypedEventEmitter<T> {

@@ -13,0 +8,0 @@ #private;

@@ -15,37 +15,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.TypedEventEmitter = exports.addTypedEventListeners = exports.addTypedEventListener = exports.removeEventListeners = exports.addEventListeners = exports.addEventListener = void 0;
exports.TypedEventEmitter = void 0;
const events_1 = require("events");
const utils_1 = require("./utils");
const IPendingWaitEvent_1 = require("../interfaces/IPendingWaitEvent");
function addEventListener(emitter, eventName, handler) {
emitter.on(eventName, handler);
return { emitter, eventName, handler };
}
exports.addEventListener = addEventListener;
function addEventListeners(emitter, registrations) {
return registrations.map(([eventName, handler]) => {
emitter.on(eventName, handler);
return { emitter, eventName, handler };
});
}
exports.addEventListeners = addEventListeners;
function removeEventListeners(listeners) {
for (const listener of listeners) {
listener.emitter.off(listener.eventName, listener.handler);
}
listeners.length = 0;
}
exports.removeEventListeners = removeEventListeners;
function addTypedEventListener(emitter, eventName, handler, includeUnhandledEvents) {
emitter.on(eventName, handler, includeUnhandledEvents);
return { emitter, eventName, handler };
}
exports.addTypedEventListener = addTypedEventListener;
function addTypedEventListeners(emitter, registrations) {
return registrations.map(([eventName, handler, includeUnhandled]) => {
emitter.on(eventName, handler, includeUnhandled);
return { emitter, eventName, handler };
});
}
exports.addTypedEventListeners = addTypedEventListeners;
class TypedEventEmitter extends events_1.EventEmitter {

@@ -143,4 +112,3 @@ constructor() {

return super.emit(eventType, event, sendInitiator);
else
return super.emit(eventType, event);
return super.emit(eventType, event);
}

@@ -147,0 +115,0 @@ addListener(eventType, listenerFn, includeUnhandledEvents = false) {

@@ -32,2 +32,7 @@ /// <reference types="node" />

};
declare global {
function UlixeeLogCreator(module: NodeModule): {
log: ILog;
};
}
export default function logger(module: NodeModule): ILogBuilder;

@@ -34,0 +39,0 @@ declare const loggerSessionIdNames: Map<string, string>;

@@ -9,2 +9,3 @@ "use strict";

const logFilters = {
envValue: null,
active: [],

@@ -148,3 +149,3 @@ skip: [],

const logLevels = { stats: 0, info: 1, warn: 2, error: 3 };
let logCreator = (module) => {
global.UlixeeLogCreator = (module) => {
const log = new Log(module);

@@ -156,3 +157,3 @@ return {

function logger(module) {
return logCreator(module);
return global.UlixeeLogCreator(module);
}

@@ -180,3 +181,3 @@ exports.default = logger;

function injectLogger(builder) {
logCreator = builder;
global.UlixeeLogCreator = builder;
}

@@ -195,2 +196,3 @@ exports.injectLogger = injectLogger;

function registerNamespaceMapping(onNamespaceFn) {
loadNamespaces(process.env.DEBUG);
for (const ns of logFilters.namespaces.active) {

@@ -207,2 +209,4 @@ onNamespaceFn(ns, logFilters.active, logFilters.skip);

}
if (logFilters.namespaces.active.has('*'))
return true;
for (const ns of logFilters.skip) {

@@ -223,4 +227,8 @@ if (ns.test(modulePath)) {

}
function enable(namespaces) {
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
function loadNamespaces(namespaces) {
if (logFilters.envValue === namespaces)
return;
namespaces ?? (namespaces = '');
logFilters.envValue = namespaces;
const split = namespaces.split(/[\s,]+/).map(x => x.trim());
for (const part of split) {

@@ -230,3 +238,3 @@ if (!part)

if (part[0] === '-') {
logFilters.namespaces.inactive.add(part);
logFilters.namespaces.inactive.add(part.slice(1));
}

@@ -238,3 +246,2 @@ else {

}
enable(process.env.DEBUG);
registerNamespaceMapping((ns, active, skip) => {

@@ -246,5 +253,5 @@ if (ns.includes('ubk:*') || ns.includes('ubk*')) {

active.push(/agent\/.*/);
skip.push(/DevtoolsSessionLogger/, /agent\/mitm.*/);
skip.push(/DevtoolsSessionLogger/, /agent[/-]mitm.*/);
}
else if (ns.includes('ubk:devtools')) {
else if (ns.includes('ubk:devtools') || ns === '*') {
active.push(/DevtoolsSessionLogger/);

@@ -255,11 +262,11 @@ }

if (ns.includes('ulx:*') || ns.includes('ulx*')) {
active.push(/^apps\/chromealive*/, /hero\/.*/, /net\/.*/, /databox\/.*/);
active.push(/^apps[/-]chromealive*/, /hero[/-].*/, /net\/.*/, /databox[/-].*/);
}
else if (ns.includes('hero')) {
active.push(/^hero\/.*/, /net\/.*/);
active.push(/^hero[/-].*/, /net\/.*/);
}
else if (ns.includes('databox')) {
active.push(/^databox\/.*/, /net\/.*/);
active.push(/^databox[/-].*/, /net\/.*/);
}
});
//# sourceMappingURL=Logger.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const SourceMapSupport_1 = require("./SourceMapSupport");
const url_1 = require("url");
const fs = require("fs");
const SourceMapSupport_1 = require("./SourceMapSupport");
class SourceLoader {

@@ -7,0 +7,0 @@ static resetCache() {

@@ -78,2 +78,3 @@ "use strict";

let match;
// eslint-disable-next-line no-cond-assign
while ((match = sourceMapUrlRegex.exec(fileData))) {

@@ -109,3 +110,3 @@ sourceMappingURL = match[1];

const message = error.message ?? '';
const errorString = name + ': ' + message;
const errorString = `${name}: ${message}`;
// track fn name as we go backwards through stack

@@ -200,6 +201,6 @@ const processedStack = [];

if (lineNumber != null) {
fileLocation += ':' + lineNumber;
fileLocation += `:${lineNumber}`;
const columnNumber = this.getColumnNumber();
if (columnNumber) {
fileLocation += ':' + columnNumber;
fileLocation += `:${columnNumber}`;
}

@@ -217,3 +218,3 @@ }

const promiseIndex = this.getPromiseIndex();
line += promiseIndex + ')';
line += `${promiseIndex})`;
}

@@ -229,17 +230,17 @@ }

if (functionName) {
if (typeName && functionName.indexOf(typeName) != 0) {
line += typeName + '.';
if (typeName && functionName.indexOf(typeName) !== 0) {
line += `${typeName}.`;
}
line += functionName;
if (methodName &&
functionName.indexOf('.' + methodName) != functionName.length - methodName.length - 1) {
line += ' [as ' + methodName + ']';
functionName.indexOf(`.${methodName}`) !== functionName.length - methodName.length - 1) {
line += ` [as ${methodName}]`;
}
}
else {
line += typeName + '.' + (methodName || '<anonymous>');
line += `${typeName}.${methodName || '<anonymous>'}`;
}
}
else if (isConstructor) {
line += 'new ' + (functionName || '<anonymous>');
line += `new ${functionName || '<anonymous>'}`;
}

@@ -254,3 +255,3 @@ else if (functionName) {

if (addSuffix) {
line += ' (' + fileLocation + ')';
line += ` (${fileLocation})`;
}

@@ -257,0 +258,0 @@ return line;

@@ -119,3 +119,3 @@ "use strict";

if (value instanceof CSSStyleDeclaration) {
const isNumber = new RegExp(/^\d+$/);
const isNumber = /^\d+$/;
const result = {};

@@ -122,0 +122,0 @@ for (const key of Object.keys(value)) {

{
"name": "@ulixee/commons",
"version": "2.0.0-alpha.5",
"version": "2.0.0-alpha.6",
"description": "Common utilities for Ulixee",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -5,3 +5,3 @@ "use strict";

const SourceLoader_1 = require("../lib/SourceLoader");
it('can lookup source code', function () {
it('can lookup source code', () => {
let callsite;

@@ -8,0 +8,0 @@ // run code like this so we can see the true load (?? will be translated by typescript)

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const SourceMapSupport_1 = require("../lib/SourceMapSupport");
const source_map_js_1 = require("source-map-js");
const fs = require("fs");
const path = require("path");
const SourceMapSupport_1 = require("../lib/SourceMapSupport");
const SourceLoader_1 = require("../lib/SourceLoader");

@@ -15,3 +15,3 @@ let counter = 0;

});
it('normal throw', function () {
it('normal throw', () => {
const { full, inline } = createStackTraces(createMultiLineSourceMap(), [

@@ -22,6 +22,6 @@ 'throw new Error("test");',

expect(stack[0]).toBe('Error: test');
expect(stack[1]).toMatch(/^ at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?line1\.js:1001:101\)$/);
expect(stack[1]).toMatch(/^ {4}at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?line1\.js:1001:101\)$/);
}
});
it('throw inside function', function () {
it('throw inside function', () => {
const { full, inline } = createStackTraces(createMultiLineSourceMap(), [

@@ -35,7 +35,7 @@ 'function foo() {',

expect(stack[0]).toBe('Error: test');
expect(stack[1]).toMatch(/^ at foo \((?:.*[/\\])?line2\.js:1002:102\)$/);
expect(stack[2]).toMatch(/^ at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?line4\.js:1004:104\)$/);
expect(stack[1]).toMatch(/^ {4}at foo \((?:.*[/\\])?line2\.js:1002:102\)$/);
expect(stack[2]).toMatch(/^ {4}at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?line4\.js:1004:104\)$/);
}
});
it('throw inside function inside function', function () {
it('throw inside function inside function', () => {
const { full, inline } = createStackTraces(createMultiLineSourceMap(), [

@@ -52,8 +52,8 @@ 'function foo() {',

expect(stack[0]).toBe('Error: test');
expect(stack[1]).toMatch(/^ at bar \((?:.*[/\\])?line3\.js:1003:103\)$/);
expect(stack[2]).toMatch(/^ at foo \((?:.*[/\\])?line5\.js:1005:105\)$/);
expect(stack[3]).toMatch(/^ at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?line7\.js:1007:107\)$/);
expect(stack[1]).toMatch(/^ {4}at bar \((?:.*[/\\])?line3\.js:1003:103\)$/);
expect(stack[2]).toMatch(/^ {4}at foo \((?:.*[/\\])?line5\.js:1005:105\)$/);
expect(stack[3]).toMatch(/^ {4}at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?line7\.js:1007:107\)$/);
}
});
it('native function', function () {
it('native function', () => {
const sourceMap = createEmptySourceMap();

@@ -74,3 +74,3 @@ sourceMap.addMapping({

});
it('function constructor', function () {
it('function constructor', () => {
const { full, inline } = createStackTraces(createMultiLineSourceMap(), [

@@ -83,10 +83,10 @@ 'throw new Function(")");',

});
it('throw with empty source map', function () {
it('throw with empty source map', () => {
const { full, inline } = createStackTraces(createEmptySourceMap(), ['throw new Error("test");']);
for (const stack of [full, inline]) {
expect(stack[0]).toBe('Error: test');
expect(stack[1]).toMatch(/^ at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?\.generated-\d+(?:-inline)?\.js:1:\d+\)$/);
expect(stack[1]).toMatch(/^ {4}at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?\.generated-\d+(?:-inline)?\.js:1:\d+\)$/);
}
});
it('throw with source map with gap', function () {
it('throw with source map with gap', () => {
const { full, inline } = createStackTraces(createSourceMapWithGap(), [

@@ -97,6 +97,6 @@ 'throw new Error("test");',

expect(stack[0]).toBe('Error: test');
expect(stack[1]).toMatch(/^ at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?\.generated-\d+(?:-inline)?\.js:1:\d+\)$/);
expect(stack[1]).toMatch(/^ {4}at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?\.generated-\d+(?:-inline)?\.js:1:\d+\)$/);
}
});
it('finds the last sourceMappingURL', function () {
it('finds the last sourceMappingURL', () => {
const { full, inline } = createStackTraces(createMultiLineSourceMapWithSourcesContent(), [

@@ -108,6 +108,6 @@ '//# sourceMappingURL=missing.map.js',

expect(stack[0]).toBe('Error: test');
expect(stack[1]).toMatch(/^ at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?original\.js:1002:5\)$/);
expect(stack[1]).toMatch(/^ {4}at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?original\.js:1002:5\)$/);
}
});
it('maps original name from source', function () {
it('maps original name from source', () => {
const sourceMap = createEmptySourceMap();

@@ -133,4 +133,4 @@ sourceMap.addMapping({

expect(stack[0]).toBe('Error: test');
expect(stack[1]).toMatch(/^ at myOriginalName \((?:.*[/\\])?\.original2.js:1000:11\)$/);
expect(stack[2]).toMatch(/^ at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?\.original2.js:1002:2\)$/);
expect(stack[1]).toMatch(/^ {4}at myOriginalName \((?:.*[/\\])?\.original2.js:1000:11\)$/);
expect(stack[2]).toMatch(/^ {4}at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?\.original2.js:1002:2\)$/);
}

@@ -142,10 +142,10 @@ });

*/
it('finds source maps with charset specified', function () {
it('finds source maps with charset specified', () => {
const sourceMap = createMultiLineSourceMap();
const file = `./.generated-${counter}.js`;
fs.writeFileSync(path.join(__dirname, file), 'exports.test = function() {' +
fs.writeFileSync(path.join(__dirname, file), `${'exports.test = function() {' +
'throw new Error("test");' +
'};//@ sourceMappingURL=data:application/json;charset=utf8;base64,' +
Buffer.from(sourceMap.toString()).toString('base64'));
'};//@ sourceMappingURL=data:application/json;charset=utf8;base64,'}${Buffer.from(sourceMap.toString()).toString('base64')}`);
try {
// eslint-disable-next-line import/no-dynamic-require
require(file).test();

@@ -156,3 +156,3 @@ }

expect(stack[0]).toBe('Error: test');
expect(stack[1]).toMatch(/^ at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?line1\.js:1001:101\)$/);
expect(stack[1]).toMatch(/^ {4}at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?line1\.js:1001:101\)$/);
}

@@ -165,11 +165,10 @@ fs.unlinkSync(path.join(__dirname, file));

*/
it('allows code/comments after sourceMappingURL', function () {
it('allows code/comments after sourceMappingURL', () => {
const sourceMap = createMultiLineSourceMap();
const file = `./.generated-${counter}.js`;
fs.writeFileSync(path.join(__dirname, file), 'exports.test = function() {' +
fs.writeFileSync(path.join(__dirname, file), `${'exports.test = function() {' +
'throw new Error("test");' +
'};//# sourceMappingURL=data:application/json;base64,' +
Buffer.from(sourceMap.toString()).toString('base64') +
'\n// Some comment below the sourceMappingURL\nvar foo = 0;');
'};//# sourceMappingURL=data:application/json;base64,'}${Buffer.from(sourceMap.toString()).toString('base64')}\n// Some comment below the sourceMappingURL\nvar foo = 0;`);
try {
// eslint-disable-next-line import/no-dynamic-require
require(file).test();

@@ -180,3 +179,3 @@ }

expect(stack[0]).toBe('Error: test');
expect(stack[1]).toMatch(/^ at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?line1\.js:1001:101\)$/);
expect(stack[1]).toMatch(/^ {4}at Object\.<anonymous>\.exports\.test \((?:.*[/\\])?line1\.js:1001:101\)$/);
}

@@ -206,3 +205,3 @@ fs.unlinkSync(path.join(__dirname, file));

original: { line: 1000 + i, column: 99 + i },
source: 'line' + i + '.js',
source: `line${i}.js`,
});

@@ -221,3 +220,3 @@ }

});
original += ' line ' + i + '\n';
original += ` line ${i}\n`;
}

@@ -230,7 +229,6 @@ sourceMap.setSourceContent('original.js', original);

fs.writeFileSync(`${__dirname}/.generated-${counter}.js.map`, sourceMap.toString());
fs.writeFileSync(`${__dirname}/.generated-${counter}.js`, 'exports.test = function() {' +
source.join('\n') +
`};//@ sourceMappingURL=.generated-${counter}.js.map`);
fs.writeFileSync(`${__dirname}/.generated-${counter}.js`, `exports.test = function() {${source.join('\n')}};//@ sourceMappingURL=.generated-${counter}.js.map`);
const response = { full: null, inline: null };
try {
// eslint-disable-next-line import/no-dynamic-require
require(`./.generated-${counter}`).test();

@@ -244,7 +242,5 @@ }

// Check again with an inline source map (in a data URL)
fs.writeFileSync(`${__dirname}/.generated-${counter}-inline.js`, 'exports.test = function() {' +
source.join('\n') +
'};//@ sourceMappingURL=data:application/json;base64,' +
Buffer.from(sourceMap.toString()).toString('base64'));
fs.writeFileSync(`${__dirname}/.generated-${counter}-inline.js`, `exports.test = function() {${source.join('\n')}};//@ sourceMappingURL=data:application/json;base64,${Buffer.from(sourceMap.toString()).toString('base64')}`);
try {
// eslint-disable-next-line import/no-dynamic-require
require(`./.generated-${counter}-inline`).test();

@@ -251,0 +247,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc