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

awesome-logging

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awesome-logging - npm Package Compare versions

Comparing version 0.0.1-pre-alpha9 to 0.0.1-pre1

2

lib/awesome-logger.d.ts

@@ -7,3 +7,3 @@ import { TextValue } from './models/text-object';

export declare class AwesomeLogger {
private static activeLogger;
private static activeLogger?;
private static _lastRenderedLines;

@@ -10,0 +10,0 @@ private static _lastScrollAmount;

@@ -51,4 +51,13 @@ "use strict";

};
AwesomeLogger.renderScrollWindow = function (allLines, scrollAmount) {
var _a, _b, _c;
AwesomeLogger.renderScrollWindow = function (allLines, scrollAmount, needsScroll) {
var _a, _b, _c, _d;
if (!needsScroll) {
for (var i = 0; i < allLines.length; i++) {
var line = allLines[i];
process.stdout.write(line.toLineString((_a = this._lastRenderedLines) === null || _a === void 0 ? void 0 : _a[i]));
ansi_utils_1.INSERT_LINE();
}
this._lastScrollAmount = scrollAmount;
return;
}
var preDots = scrollAmount > 0;

@@ -59,10 +68,10 @@ var postDots = scrollAmount < allLines.length - this.maxLinesInTerminal;

if (preDots && i === 0) {
process.stdout.write(new text_object_1.TextObject('...', 'GRAY').toLineString((_a = this._lastRenderedLines) === null || _a === void 0 ? void 0 : _a[0]));
process.stdout.write(new text_object_1.TextObject('...', 'GRAY').toLineString((_b = this._lastRenderedLines) === null || _b === void 0 ? void 0 : _b[0]));
}
else if (postDots && i === visibleLineCount - 1) {
process.stdout.write(new text_object_1.TextObject('...', 'GRAY').toLineString((_b = this._lastRenderedLines) === null || _b === void 0 ? void 0 : _b[this._lastRenderedLines.length - 1]));
process.stdout.write(new text_object_1.TextObject('...', 'GRAY').toLineString((_c = this._lastRenderedLines) === null || _c === void 0 ? void 0 : _c[this._lastRenderedLines.length - 1]));
}
else {
var line = allLines[i + scrollAmount];
process.stdout.write(line.toLineString((_c = this._lastRenderedLines) === null || _c === void 0 ? void 0 : _c[i + this._lastScrollAmount]));
process.stdout.write(line.toLineString((_d = this._lastRenderedLines) === null || _d === void 0 ? void 0 : _d[i + this._lastScrollAmount]));
}

@@ -77,3 +86,3 @@ ansi_utils_1.INSERT_LINE();

var renderedLines = logger.render().allLines();
this.renderScrollWindow(renderedLines, logger.scrollAmount);
this.renderScrollWindow(renderedLines, logger.scrollAmount, logger.needsScroll());
this._lastRenderedLines = renderedLines;

@@ -84,22 +93,25 @@ this.activeLogger = logger;

AwesomeLogger.interrupt = function (type, config) {
var _a;
var logger = this.create(type, config);
var renderedText = logger.render().toLineString();
var renderedLines = renderedText === null || renderedText === void 0 ? void 0 : renderedText.split(/[\r\n|\n|\r]/g);
if (!this.activeLogger || !this._lastRenderedLines) {
var noActiveLogger = !this.activeLogger;
var noLastRenderedLines = !this._lastRenderedLines;
this.log(type, config);
if (noLastRenderedLines) {
this._lastRenderedLines = undefined;
}
if (noActiveLogger) {
this.activeLogger = undefined;
}
return;
}
if (!renderedLines) {
var logger = this.create(type, config);
var interruptText = logger.render().toString();
if (!interruptText) {
return;
}
var visibleLines = this.visibleLineCount((_a = this._lastRenderedLines) !== null && _a !== void 0 ? _a : []);
renderedLines.forEach(function (renderedLine) {
ansi_utils_1.MOVE_UP(visibleLines);
ansi_utils_1.INSERT_NEW_LINE();
process.stdout.write(renderedLine);
ansi_utils_1.MOVE_LEFT();
ansi_utils_1.MOVE_DOWN(visibleLines);
ansi_utils_1.INSERT_LINE();
});
this._lastRenderedLines = undefined;
var renderedLines = this.activeLogger.render().allLines();
this.activeLogger.clean();
console.log(interruptText);
this.renderScrollWindow(renderedLines, this.activeLogger.scrollAmount, this.activeLogger.needsScroll());
this._lastRenderedLines = renderedLines;
};

@@ -138,3 +150,3 @@ AwesomeLogger.loggerChanged = function (calledFrom) {

ansi_utils_1.MOVE_UP(this.visibleLineCount(renderedLines));
this.renderScrollWindow(renderedLines, this.activeLogger.scrollAmount);
this.renderScrollWindow(renderedLines, this.activeLogger.scrollAmount, this.activeLogger.needsScroll());
this._lastRenderedLines = renderedLines;

@@ -159,3 +171,3 @@ };

var renderedLines = prompt.render().allLines();
this.renderScrollWindow(renderedLines, prompt.scrollAmount);
this.renderScrollWindow(renderedLines, prompt.scrollAmount, prompt.needsScroll());
this._lastRenderedLines = renderedLines;

@@ -162,0 +174,0 @@ prompt.init();

@@ -15,2 +15,3 @@ import { AwesomeLoggerBase } from '../../logger/models/logger-base';

canBeCalledFrom(calledFrom: AwesomeLoggerBase): boolean;
needsScroll(): boolean;
protected changed(): void;

@@ -17,0 +18,0 @@ render(): TextObject;

@@ -40,2 +40,5 @@ "use strict";

};
AwesomePromptBase.prototype.needsScroll = function () {
return true;
};
AwesomePromptBase.prototype.changed = function () {

@@ -42,0 +45,0 @@ this._hasChanges = true;

@@ -11,2 +11,3 @@ import { TextObject } from '../../models/text-object';

getNextLine(): TextObject;
needsScroll(): boolean;
changeState(index: number, state: AwesomeChecklistLoggerState, newText?: string): void;

@@ -13,0 +14,0 @@ private calculateLine;

@@ -44,2 +44,5 @@ "use strict";

};
AwesomeChecklistLogger.prototype.needsScroll = function () {
return true;
};
AwesomeChecklistLogger.prototype.changeState = function (index, state, newText) {

@@ -46,0 +49,0 @@ var item = this._options.items[index];

@@ -10,4 +10,7 @@ import { TextObject } from '../../models/text-object';

abstract canBeCalledFrom(calledFrom: AwesomeLoggerBase): boolean;
abstract needsScroll(): boolean;
protected changed(): void;
render(): TextObject;
clean(): void;
private static visibleLineCount;
}

@@ -27,2 +27,16 @@ "use strict";

};
AwesomeLoggerBase.prototype.clean = function () {
var _a;
if (!this._lastLine) {
return;
}
var visibleLines = AwesomeLoggerBase.visibleLineCount((_a = this._lastLine.allLines()) !== null && _a !== void 0 ? _a : []);
for (var i = 0; i < visibleLines; i++) {
ansi_utils_1.MOVE_UP(1);
ansi_utils_1.DELETE_LINE();
}
};
AwesomeLoggerBase.visibleLineCount = function (allLines) {
return Math.min(allLines.length, awesome_logger_1.AwesomeLogger.maxLinesInTerminal);
};
return AwesomeLoggerBase;

@@ -29,0 +43,0 @@ }());

@@ -7,2 +7,3 @@ import { TextObject } from '../../models/text-object';

constructor(config?: Partial<AwesomeLoggerMultiConfig>);
needsScroll(): boolean;
hasChanges(): boolean;

@@ -9,0 +10,0 @@ canBeCalledFrom(calledFrom: AwesomeLoggerBase): boolean;

@@ -26,2 +26,5 @@ "use strict";

}
AwesomeMultiLogger.prototype.needsScroll = function () {
return true;
};
AwesomeMultiLogger.prototype.hasChanges = function () {

@@ -28,0 +31,0 @@ return this._children.some(function (x) { return x.hasChanges(); });

@@ -7,2 +7,3 @@ import { TextObject } from '../../models/text-object';

private _currentProgress;
needsScroll(): boolean;
constructor(options?: Partial<AwesomeProgressLoggerConfig>);

@@ -9,0 +10,0 @@ hasChanges(): boolean;

@@ -39,2 +39,5 @@ "use strict";

}
AwesomeProgressLogger.prototype.needsScroll = function () {
return false;
};
AwesomeProgressLogger.prototype.hasChanges = function () {

@@ -41,0 +44,0 @@ return this._hasChanges;

@@ -16,2 +16,3 @@ import { TextObject } from '../../models/text-object';

canBeCalledFrom(calledFrom: AwesomeLoggerBase): boolean;
needsScroll(): boolean;
getNextLine(): TextObject;

@@ -18,0 +19,0 @@ stop(options: {

@@ -47,2 +47,5 @@ "use strict";

};
AwesomeSpinnerLogger.prototype.needsScroll = function () {
return false;
};
AwesomeSpinnerLogger.prototype.getNextLine = function () {

@@ -49,0 +52,0 @@ var _a, _b, _c;

@@ -8,2 +8,3 @@ import { TextObject, TextValue } from '../../models/text-object';

hasChanges(): boolean;
needsScroll(): boolean;
canBeCalledFrom(calledFrom: AwesomeLoggerBase): boolean;

@@ -10,0 +11,0 @@ getNextLine(): TextObject;

@@ -29,2 +29,5 @@ "use strict";

};
AwesomeTextLogger.prototype.needsScroll = function () {
return false;
};
AwesomeTextLogger.prototype.canBeCalledFrom = function (calledFrom) {

@@ -31,0 +34,0 @@ return calledFrom === this;

@@ -16,3 +16,3 @@ import { AwesomeLoggerColor } from '../types/logger-color';

static ensureTextValue(text: string | TextValue): TextValue;
append(textObject: TextObject): TextObject;
append(text: TextObject): TextObject;
append(text: string, color?: AwesomeLoggerColor, bgColor?: AwesomeLoggerColor): TextObject;

@@ -19,0 +19,0 @@ appendLine(child: TextObject): TextObject;

@@ -41,18 +41,14 @@ "use strict";

var _this = this;
if (typeof text === 'string') {
this._values.push({ text: text, color: color, bgColor: bgColor });
}
else {
text === null || text === void 0 ? void 0 : text._values.forEach(function (v) {
_this._values.push({ text: v.text, color: v.color, bgColor: v.bgColor });
});
if (text === null || text === void 0 ? void 0 : text._child) {
var parent_1 = this;
var child = this._child;
while (child) {
parent_1 = child;
child = parent_1._child;
}
parent_1._child = text._child;
var newChild = typeof text === 'string' ? new TextObject(text, color, bgColor) : text;
newChild._values.forEach(function (v) {
_this._values.push({ text: v.text, color: v.color, bgColor: v.bgColor });
});
if (newChild._child) {
var parent_1 = this;
var child = this._child;
while (child) {
parent_1 = child;
child = parent_1._child;
}
parent_1._child = newChild._child;
}

@@ -66,16 +62,16 @@ return this;

TextObject.prototype.toLineString = function (lastText) {
var res = this._values.map(function (x) { return logger_color_1.colorize(x.color, x.bgColor)(x.text); }).join('');
if (!lastText) {
return res;
}
var appendSpaces = '';
var textLength = this.length;
var newTextRenderLength = textLength;
if (lastText) {
var lastlength = lastText.length;
if (lastlength > textLength) {
appendSpaces = ' '.repeat(lastlength - textLength);
}
else if (lastlength === textLength) {
newTextRenderLength = TextObject.calculateLastChangedCharacterIndex(lastText, this) + 1;
}
var lastlength = lastText.length;
if (lastlength > textLength) {
appendSpaces = ' '.repeat(lastlength - textLength);
}
var res = '';
res += this._values.map(function (x) { return logger_color_1.colorize(x.color, x.bgColor)(x.text); }).join('');
else if (lastlength === textLength) {
newTextRenderLength = TextObject.calculateLastChangedCharacterIndex(lastText, this) + 1;
}
var changedText = (newTextRenderLength !== -1 ? slice_ansi_1.default(res, 0, newTextRenderLength) : res) + appendSpaces;

@@ -82,0 +78,0 @@ return changedText;

@@ -63,2 +63,5 @@ "use strict";

}, 100);
setInterval(function () {
awesome_logger_1.AwesomeLogger.interrupt('text', { text: { text: 'hi\nthis\nis\na\ntest' } });
}, 200);
//# sourceMappingURL=test.js.map
{
"name": "awesome-logging",
"version": "0.0.1-pre-alpha9",
"version": "0.0.1-pre1",
"description": "Advanced logging messages, interactive prompts, loading animations and more in TypeScript",

@@ -26,10 +26,10 @@ "main": "lib/index.js",

"@awdware/eslint-config-nodejs": "^0.0.6",
"@types/node": "^14.11.10",
"@types/node": "^14.14.20",
"@types/slice-ansi": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^4.7.0",
"@typescript-eslint/parser": "^4.7.0",
"eslint": "^7.13.0",
"legally": "^3.5.8",
"ts-node": "^9.0.0",
"typescript": "^4.1.2"
"@typescript-eslint/eslint-plugin": "^4.13.0",
"@typescript-eslint/parser": "^4.13.0",
"eslint": "^7.17.0",
"legally": "^3.5.9",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
},

@@ -36,0 +36,0 @@ "keywords": [

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

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