Initial commit

This commit is contained in:
Spencer Pincott
2024-07-15 22:20:13 -04:00
commit 97737ca1ae
16618 changed files with 934131 additions and 0 deletions

9
themes/keepit/node_modules/draftlog/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,9 @@
language: node_js
node_js:
- 6
- 4
cache:
directories:
- node_modules

21
themes/keepit/node_modules/draftlog/LICENSE.txt generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 Ivan Seidel
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.

159
themes/keepit/node_modules/draftlog/README.md generated vendored Normal file
View File

@@ -0,0 +1,159 @@
![DraftLog](midia/draftlog.png)
<!-- [![NPM][npm-image]][npm-url] -->
[![Build Status][build-status-image]][build-status-url] [![Dependency Status][dependencies-image]][dependencies-url]
Because Logging can be pretty and fun
![DraftLog GIF](midia/draftlog.gif)
[build-status-image]: https://img.shields.io/travis/ivanseidel/node-draftlog.svg
[build-status-url]: http://travis-ci.org/ivanseidel/node-draftlog
[dependencies-image]: https://gemnasium.com/badges/github.com/ivanseidel/node-draftlog.svg
[dependencies-url]: https://gemnasium.com/github.com/ivanseidel/node-draftlog
[npm-image]: https://nodei.co/npm/draftlog.png?downloads=true&stars=true
[npm-url]: https://nodei.co/npm/draftlog
## Installation
```
$ npm install draftlog
```
## What it does
It allows you to re-write a line of your log after being written. Just like post 'updating'.
This is the building block for any dynamic element such as `progress bars`, `loading status`,
`animations`, `checkboxes` and so on.
It does that by keeping track of the current lines of code written through the `stream`, and
moving the cursor up to the line of the `LogDraft` you created previously, and updating its content.
Look in the examples folders to see how easy it is, to create anything. No strict and fixed
widgets are given to you. Instead, use your creativity with this tool to create anything you
want! Share the results later with an example ;)
Looking for CUTE Unicode chars? Check out [Unicute](https://github.com/ivanseidel/unicute).
How the
[HECK](http://ascii-table.com/ansi-escape-sequences-vt-100.php) is
[that](https://en.wikipedia.org/wiki/ANSI_escape_code) even
[possible](http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html)?
## Usage
```javascript
// Setup
const DraftLog = require('draftlog')
DraftLog(console)
// Or, in a single line:
require('draftlog').into(console)
// Account for manual line breaks with:
require('draftlog').into(console).addLineListener(process.stdin)
```
To create a updatable log, use the `draft` method injected into the provided `console`:
```javascript
// Create a Draft log
var update = console.draft('Hi, my name is')
// You can call logs after it
console.log('Something else')
// Use the received callback to update it as many times as you want
update('Hi, my name is Ivan!')
```
Here are some interesting examples:
```javascript
// Prints a clock incrementing one every second in the same line
var draft = console.draft()
var elapsed = 1
setInterval( () => {
draft('Elapsed', elapsed++, 'seconds')
}, 1000)
console.log('It doesn`t matter')
console.log('How \n many \n lines \n it uses')
```
Or maybe, to show an flow process?
```javascript
function someAsyncFunction(){
var TAG = '[someAsyncFunction]'
var log = console.draft(TAG, 'init')
function a() {
setTimeout(() => {
log(TAG, 'calling b')
b()
}, 500)
}
function b() {
setTimeout(() => {
log(TAG, 'finished')
})
}
}
```
You can create your own progress bar, just like "that":
```javascript
require('draftlog').into(console)
// Input progess goes from 0 to 100
function ProgressBar(progress) {
// Make it 50 characters length
var units = Math.round(progress / 2)
return '[' + '='.repeat(units) + ' '.repeat(50 - units) + '] ' + progress + '%'
}
var barLine = console.draft('Starting download...')
downloadFile(function (progress) {
barLine(ProgressBar(progress))
})
// Will show something like: (being updated in realtime)
// [============================ ] 56%
```
## Learn from examples!
We have a few of them ready for you to use! Take a look at [the examples folder](examples/).
Remember to replace `require('../')` with `require('draftlog')`.
Also, install [`chalk`](https://github.com/chalk/chalk) to get colors on your terminal ;)
## Important things to know
Because of the way Terminals are built, it is not possible to update a text outside the viewing area of the terminal.
That said, DraftLogs are setup to automagically be rewritten on a new line if they reach the end of the viewport.
Note that, you can disable that behavior, by setting `DraftLog.defaults.canReWrite = false`
Also, if the NodeJS environment cannot detect the number of rows of your terminal automatically, it will use
the default height on `DraftLog.defaults.maximumLinesUp`. Modify that if needed.
When using `into(console).addLineListener(process.stdin)`, your code will no longer exit
automatically, because the stream is being "read". To stop your own code, you can call
`process.exit(0)` or pause the stream when you want with: `process.stdin.pause()`.
## Discouragements
This library is awesome for development, `cli` tools and what ever you want to created, that is NOT an
optimized "slave" server. Please, disable it passing `true` as a second parameter to the DraftLog initialization:
```javascript
// Disable Initialization (true = production; false = development)
DraftLog(console, true)
// Or, with one line require-init:
require('draftlog').into(console, true)
```
### Creator
[Ivan Seidel](https://github.com/ivanseidel)

17
themes/keepit/node_modules/draftlog/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import { Readable } from 'stream';
declare global {
interface Console {
draft(message?: any, ...optionalParams: any[]): (message?: any, ...optionalParams: any[]) => void;
}
}
declare class LineCountStream {
addLineListener(inStream: Readable): void;
}
declare function DraftLog(console: Console, extra?: boolean): LineCountStream;
declare namespace DraftLog {
declare function into(console: Console, extra?: boolean): LineCountStream;
}
export = DraftLog;

1
themes/keepit/node_modules/draftlog/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./lib')

48
themes/keepit/node_modules/draftlog/lib/CSIHelper.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
/*
* CSIHelper, or "Control Sequence Introducer Helper" is the translator of actions into
* sequence of ANSI characters that will trigger some action in the Terminal.
*
* Note: CSI is not from the TV Series.
*
* More info:
* - https://en.wikipedia.org/wiki/ANSI_escape_code
* - http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html
* - http://ascii-table.com/ansi-escape-sequences-vt-100.php
*/
var CSIHelper = module.exports = {}
const ESC = CSIHelper.ESC = '\u001b'
/*
* Save current cursor position
*/
CSIHelper.save = function save() {
return '\u001b7'
}
/*
* Restore cursor position
*/
CSIHelper.restore = function restore() {
return '\u001b8'
}
/*
* Move cursor up `n` lines. Default is 1
*/
CSIHelper.up = function up(n) {
n = typeof n === 'number' ? n : 1
return n > 0 ? ESC + '[' + n + 'A' : ''
}
/*
* Move cursor down `n` lines. Default is 1
*/
CSIHelper.down = function down(n) {
n = typeof n === 'number' ? n : 1
return n > 0 ? ESC + '[' + n + 'B' : ''
}
CSIHelper.clearLine = function clearLine() {
return ESC + '[2K' + ESC + '[1G'
}

View File

@@ -0,0 +1,118 @@
'use strict'
const util = require('util')
const stream = require('stream')
const PassThrough = stream.PassThrough
// Expose
module.exports = LineCountStream
/*
* This is a PassThrough stream that keep track of how many lines have been logged.
*
* TODO: Account for terminal size changes/wrapping
*/
function LineCountStream(outStream) {
// Checks if the outStream is already a LineCountStream. If so, return it
if (outStream instanceof LineCountStream)
return outStream
// Make sure this is a new instance
if (!(this instanceof LineCountStream))
return new LineCountStream(outStream)
// Call super constructor
PassThrough.call(this)
// Save outStream
this._outStream = outStream
// Initialize line and logs (line starts as 1)
this._line = 1
this._logs = 0
// Flag indicating a change is being made not with current cursor
this._editing = false
// Pipe this data to output stream
outStream && this.pipe(outStream)
}
// Inherits from PassThrough
util.inherits(LineCountStream, PassThrough)
/*
* Get current line
*/
LineCountStream.prototype.line = function line() {
return this._line
}
/*
* Get log count
*/
LineCountStream.prototype.logs = function logs() {
return this._logs
}
/*
* On write, increment lines and logs
*
* Benchmark: http://jsperf.com/count-the-number-of-characters-in-a-string
*/
LineCountStream.prototype.write = function write(data) {
if (! this._editing) {
this.countLines(data)
}
this.push(data)
}
/*
* Binds a inputStream to this, in order to account for extra lines
* typed in the Terminal.
* This method will bind event 'data' into the stream, and call
* countLines(data) with the data. It will not account for '_editing',
* because there can be user input while editing.
*/
LineCountStream.prototype.addLineListener = function addLineListener(inStream) {
// Binds to 'data' event
inStream.on('data', this.countLines.bind(this))
}
/*
* Counts lines on the data and increment counters.
* Compensation for `_editing` mode should be done
* outside this method. Keep this as clean as possible
*/
LineCountStream.prototype.countLines = function countLines(data) {
var dataLines = (data.toString().split('\n').length - 1)
this._logs++
this._line += dataLines || 0
}
/*
* Call this to stop line counts (during some change of data in previous records)
*/
LineCountStream.prototype.stopLineCount = function stopLineCount() {
this._editing = true
}
/*
* Call this to resume line counts
*/
LineCountStream.prototype.resumeLineCount = function resumeLineCount() {
this._editing = false
}
/*
* Proxy rows from the stream
*/
LineCountStream.prototype.rows = function rows() {
return this._outStream.rows
}
/*
* Proxy columns from the stream
*/
LineCountStream.prototype.columns = function columns() {
return this._outStream.columns
}

95
themes/keepit/node_modules/draftlog/lib/LogDraft.js generated vendored Normal file
View File

@@ -0,0 +1,95 @@
'use strict'
const util = require('util')
const defaults = require('./defaults')
const CSIHelper = require('./CSIHelper')
// Expose
module.exports = LogDraft
/*
* This is a single Line object, that saves it's relative position
* in terminal. It is responsible by updating itself.
*/
function LogDraft(console, methodName) {
this._stream = console._stdout
this._styleFn = console[methodName]
// Valid flag. If set to false, should NOT write anymore
this.valid = true
// Save line where content will be saved
this.saveLine()
}
/*
* After creating a draft, you can call as many times as you want to update it
*/
LogDraft.prototype.update = function update(/* log arguments */) {
// Get line difference
var linesUp = this.linesUp()
// Check if is offscreen
if (this.isOffScreen()) {
if (defaults.canReWrite) {
// It can be rewritten, move line to current cursor line, and keep updating
this.saveLine(-1)
} else {
// Invalidate and prevent writting
this.valid = false
return;
}
}
// Start editing stream
this._stream.stopLineCount()
// Save state (if content is not null)
this._stream.write(CSIHelper.save())
// Move up cursor up
this._stream.write(CSIHelper.up(linesUp))
// Clear line
this._stream.write(CSIHelper.clearLine())
// Call write function
this.write.apply(this, arguments)
// Restore state
this._stream.write(CSIHelper.restore())
// Resume counting lines
this._stream.resumeLineCount()
}
/*
* Returns true if line is out of screen
*/
LogDraft.prototype.isOffScreen = function isOffScren() {
var rows = this._stream.rows() || defaults.maximumLinesUp
return this._stream.rows() <= this.linesUp()
}
/*
* Return how many lines past our current log
*/
LogDraft.prototype.linesUp = function linesUp() {
return this._stream.line() - this._line
}
/*
* Writes to the stream by calling the writeFn.
* Will not print if it's invalid
* Defaults to `_stream.write` (set on constructor)
*/
LogDraft.prototype.write = function write() {
this.valid && this._styleFn.apply(this._styleFn, arguments)
}
/*
* Saves current line number as the insertion point
*/
LogDraft.prototype.saveLine = function saveLine(relative) {
relative = relative || 0
this._line = this._stream.line() + relative
}

20
themes/keepit/node_modules/draftlog/lib/defaults.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
module.exports = {
/*
* Number of lines after log has been created, to stop updating Log
* Default value if console does not support rows counting
*/
maximumLinesUp: 30,
/*
* ReWrites the line if maximumLinesUp reached, and reset _line
*/
canReWrite: true,
/*
* Allows automatically binding to process.stdin as a input source.
* Set to false, because it prevents the process from exiting,
* and that's not cool. Let user decide if it's good to use or not.
* Calls lineCountStream.addLineListener(process.stdin) when true
*/
stdinAutoBind: false,
}

22
themes/keepit/node_modules/draftlog/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
'use strict'
// Lib main object is 'into' method
var Lib = require('./into')
// Expose injecter 'into' method
Lib.into = Lib
// Expose Defaults
Lib.defaults = require('./defaults')
// Expose CSIHelper
Lib.CSIHelper = require('./CSIHelper')
// Expose LogDraft
Lib.LogDraft = require('./LogDraft')
// Expose LineCountStream
Lib.LineCountStream = require('./LineCountStream')
// Expose API
module.exports = Lib

52
themes/keepit/node_modules/draftlog/lib/into.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
'use strict'
const defaults = require('./defaults')
const LogDraft = require('./LogDraft')
const LineCountStream = require('./LineCountStream')
/*
* Injects DrafLog into a console object
* call with a seccond parameter as 'true' to
* Mock instalation, and add only the `draft` method
* as a alias to `console.log`
*/
module.exports = function into(console, extra) {
// If extra is set to `true`, it's production mode
var production = (extra === true ? true : false)
// If production mode, mock api
if (production) {
// Mock draft and set is as console.log
console.draft = function draft() {
// Log this
console.log.apply(null, arguments)
// Return usual console.log method
return console.log.bind(console)
}
return
}
// Transform stdout from console to LineCounter
var lineCountStream = LineCountStream(console._stdout)
console._stdout = lineCountStream
// Can it bind to process.stdin automatically?
if (defaults.stdinAutoBind) {
lineCountStream.addLineListener(process.stdin)
}
// Add "draft" to console
console.draft = console.draft || function draft() {
// Create Draft at this point in time
var logDraft = new LogDraft(console, 'log')
// Log first
logDraft.write.apply(logDraft, arguments)
// Return update function
return logDraft.update.bind(logDraft)
}
// Return the created Transform Stream
return lineCountStream
}

32
themes/keepit/node_modules/draftlog/package.json generated vendored Normal file
View File

@@ -0,0 +1,32 @@
{
"name": "draftlog",
"version": "1.0.13",
"description": "Create updatable log lines into the terminal, and give life to your logs!",
"main": "index.js",
"scripts": {
"test": "node tests"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ivanseidel/node-draftlog.git"
},
"keywords": [
"logging",
"console",
"log",
"terminal",
"logger",
"ui",
"post",
"after"
],
"author": "Ivan Seidel Gomes",
"license": "MIT",
"bugs": {
"url": "https://github.com/ivanseidel/node-draftlog/issues"
},
"homepage": "https://github.com/ivanseidel/node-draftlog#readme",
"devDependencies": {
"chalk": "^1.1.3"
}
}