Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blipgloss

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blipgloss - npm Package Compare versions

Comparing version 0.1.9 to 0.2.0

175

dist/index.d.ts

@@ -1,95 +0,96 @@

type BlipglossColor = string | {
Light: string;
Dark: string;
// Generated by dts-bundle-generator v8.0.1
export type BlipglossColor = string | {
Light: string;
Dark: string;
};
declare enum Position {
Top = 0,
Bottom = 1,
Center = 0.5,
Left = 0,
Right = 1
export declare enum Position {
Top = 0,
Bottom = 1,
Center = 0.5,
Left = 0,
Right = 1
}
type CustomBorder = {
Top?: string;
Bottom?: string;
Left?: string;
Right?: string;
TopLeft?: string;
TopRight?: string;
BottomLeft?: string;
BottomRight?: string;
export type CustomBorder = {
Top?: string;
Bottom?: string;
Left?: string;
Right?: string;
TopLeft?: string;
TopRight?: string;
BottomLeft?: string;
BottomRight?: string;
};
type BorderStyle = 'rounded' | 'double' | 'normal' | 'hidden' | 'thick' | CustomBorder;
declare class Style {
#private;
constructor(handle: number);
static NewStyle(): Style;
private SetColorValue;
private SetBooleanValue;
private SetIntValue;
Bold(val: boolean): this;
Strikethrough(val: boolean): this;
Italic(val: boolean): this;
Width(val: number): this;
Foreground(color: BlipglossColor): this;
Background(color: BlipglossColor): this;
Padding(...values: number[]): this;
PaddingTop(padding: number): this;
PaddingBottom(padding: number): this;
PaddingLeft(padding: number): this;
PaddingRight(padding: number): this;
Margin(...values: number[]): this;
MarginTop(padding: number): this;
MarginBottom(padding: number): this;
MarginLeft(padding: number): this;
MarginRight(padding: number): this;
MarginBackground(color: BlipglossColor): this;
Blink(val: boolean): this;
BorderTopBackground(color: BlipglossColor): this;
BorderBottomBackground(color: BlipglossColor): this;
BorderLeftBackground(color: BlipglossColor): this;
BorderRightBackground(color: BlipglossColor): this;
BorderTopForeground(color: BlipglossColor): this;
BorderBottomForeground(color: BlipglossColor): this;
BorderLeftForeground(color: BlipglossColor): this;
BorderRightForeground(color: BlipglossColor): this;
BorderStyle(style: BorderStyle): this;
BorderTop(val: boolean): this;
BorderBottom(val: boolean): this;
BorderLeft(val: boolean): this;
BorderRight(val: boolean): this;
BorderForeground(color: BlipglossColor): this;
BorderBackground(color: BlipglossColor): this;
GetBoolValue(): any;
GetIntValue(): any;
GetBold(): boolean;
Reverse(val: boolean): this;
Align(position: Position | number): this;
Render(text: string): string;
Copy(): Style;
FreeHandle(): void;
private UnsetRule;
UnsetAlign(): this;
UnsetBackground(): this;
UnsetBlink(): this;
UnsetBold(): this;
UnsetBorderBackground(): this;
UnsetBorderBottom(): this;
UnsetBorderBottomBackground(): this;
UnsetBorderBottomForeground(): this;
UnsetBorderForeground(): this;
Inline(val: boolean): this;
MaxWidth(val: number): this;
MaxHeight(val: number): this;
export type BorderStyle = "rounded" | "double" | "normal" | "hidden" | "thick" | CustomBorder;
export declare class Style {
#private;
constructor(handle: number);
static NewStyle(): Style;
private SetColorValue;
private SetBooleanValue;
private SetIntValue;
Bold(val: boolean): this;
Strikethrough(val: boolean): this;
Italic(val: boolean): this;
Width(val: number): this;
Height(val: number): this;
Foreground(color: BlipglossColor): this;
Background(color: BlipglossColor): this;
Padding(...values: number[]): this;
PaddingTop(padding: number): this;
PaddingBottom(padding: number): this;
PaddingLeft(padding: number): this;
PaddingRight(padding: number): this;
Margin(...values: number[]): this;
MarginTop(padding: number): this;
MarginBottom(padding: number): this;
MarginLeft(padding: number): this;
MarginRight(padding: number): this;
MarginBackground(color: BlipglossColor): this;
Blink(val: boolean): this;
BorderTopBackground(color: BlipglossColor): this;
BorderBottomBackground(color: BlipglossColor): this;
BorderLeftBackground(color: BlipglossColor): this;
BorderRightBackground(color: BlipglossColor): this;
BorderTopForeground(color: BlipglossColor): this;
BorderBottomForeground(color: BlipglossColor): this;
BorderLeftForeground(color: BlipglossColor): this;
BorderRightForeground(color: BlipglossColor): this;
BorderStyle(style: BorderStyle): this;
BorderTop(val: boolean): this;
BorderBottom(val: boolean): this;
BorderLeft(val: boolean): this;
BorderRight(val: boolean): this;
BorderForeground(color: BlipglossColor): this;
BorderBackground(color: BlipglossColor): this;
GetBold(): boolean;
Reverse(val: boolean): this;
Align(position: Position | number): this;
Render(text: string): string;
Copy(): Style;
FreeHandle(): void;
private UnsetRule;
UnsetAlign(): this;
UnsetBackground(): this;
UnsetBlink(): this;
UnsetBold(): this;
UnsetBorderBackground(): this;
UnsetBorderBottom(): this;
UnsetBorderBottomBackground(): this;
UnsetBorderBottomForeground(): this;
UnsetBorderForeground(): this;
Inline(val: boolean): this;
MaxWidth(val: number): this;
MaxHeight(val: number): this;
}
declare function NewStyle(): Style;
export declare function NewStyle(): Style;
/**
* Returns whether or not the terminal has a dark background.
*/
declare function HasDarkBackground(): boolean;
declare function JoinHorizontal(position: Position | number, ...paragraphs: string[]): string;
declare function JoinVertical(position: Position | number, ...paragraphs: string[]): string;
declare function Width(text: string): number;
declare function Height(text: string): number;
export declare function HasDarkBackground(): boolean;
export declare function JoinHorizontal(position: Position | number, ...paragraphs: string[]): string;
export declare function JoinVertical(position: Position | number, ...paragraphs: string[]): string;
export declare function Width(text: string): number;
export declare function Height(text: string): number;
export { BorderStyle, CustomBorder, HasDarkBackground, Height, JoinHorizontal, JoinVertical, NewStyle, Position, Style, Width };
export {};

@@ -1,150 +0,98 @@

"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateSet = (obj, member, value, setter) => {
__accessCheck(obj, member, "write to private field");
setter ? setter.call(obj, value) : member.set(obj, value);
return value;
};
// src/index.ts
var src_exports = {};
__export(src_exports, {
HasDarkBackground: () => HasDarkBackground,
Height: () => Height,
JoinHorizontal: () => JoinHorizontal,
JoinVertical: () => JoinVertical,
NewStyle: () => NewStyle,
Position: () => Position,
Style: () => Style,
Width: () => Width
});
module.exports = __toCommonJS(src_exports);
// src/lib.ts
var import_bun_ffi3 = require("bun:ffi");
import {CString as CString2, ptr} from "bun:ffi";
// src/ffi.ts
var import_bun_ffi = require("bun:ffi");
var import_meta = {};
import {dlopen, FFIType, suffix} from "bun:ffi";
var { platform, arch } = process;
var filename;
if (arch === "x64") {
filename = `../release/blipgloss-${platform}-amd64.${import_bun_ffi.suffix}`;
filename = `../release/blipgloss-${platform}-amd64.${suffix}`;
} else {
filename = `../release/blipgloss-${platform}-${arch}.${import_bun_ffi.suffix}`;
filename = `../release/blipgloss-${platform}-${arch}.${suffix}`;
}
var location = new URL(filename, import_meta.url).pathname;
var { symbols } = (0, import_bun_ffi.dlopen)(location, {
var location = new URL(filename, import.meta.url).pathname;
var { symbols } = dlopen(location, {
NewStyle: {
args: [],
returns: import_bun_ffi.FFIType.ptr
returns: FFIType.ptr
},
Render: {
args: [import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.ptr
args: [FFIType.ptr, FFIType.ptr],
returns: FFIType.ptr
},
Copy: {
args: [import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.ptr
args: [FFIType.ptr],
returns: FFIType.ptr
},
SetColorValue: {
args: [import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.bool],
returns: import_bun_ffi.FFIType.void
args: [FFIType.ptr, FFIType.ptr, FFIType.ptr, FFIType.bool],
returns: FFIType.void
},
SetIntValue: {
args: [import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.int],
returns: import_bun_ffi.FFIType.void
args: [FFIType.ptr, FFIType.ptr, FFIType.int],
returns: FFIType.void
},
SetStringValue: {
args: [import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.void
args: [FFIType.ptr, FFIType.ptr, FFIType.ptr],
returns: FFIType.void
},
SetBooleanValue: {
args: [import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.bool],
returns: import_bun_ffi.FFIType.void
args: [FFIType.ptr, FFIType.ptr, FFIType.bool],
returns: FFIType.void
},
GetBoolValue: {
args: [import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.bool
args: [FFIType.ptr, FFIType.ptr],
returns: FFIType.bool
},
GetIntValue: {
args: [import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.int
args: [FFIType.ptr, FFIType.ptr],
returns: FFIType.int
},
HasDarkBackground: {
args: [],
returns: import_bun_ffi.FFIType.bool
returns: FFIType.bool
},
UnsetRule: {
args: [import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.void
args: [FFIType.ptr, FFIType.ptr],
returns: FFIType.void
},
JoinHorizontal: {
args: [import_bun_ffi.FFIType.f64, import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.ptr
args: [FFIType.f64, FFIType.ptr],
returns: FFIType.ptr
},
JoinVertical: {
args: [import_bun_ffi.FFIType.f64, import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.ptr
args: [FFIType.f64, FFIType.ptr],
returns: FFIType.ptr
},
Width: {
args: [import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.int
args: [FFIType.ptr],
returns: FFIType.int
},
Height: {
args: [import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.int
args: [FFIType.ptr],
returns: FFIType.int
},
Align: {
args: [import_bun_ffi.FFIType.float],
returns: import_bun_ffi.FFIType.void
args: [FFIType.ptr, FFIType.float],
returns: FFIType.void
},
Margin: {
args: [import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.void
args: [FFIType.ptr, FFIType.ptr],
returns: FFIType.void
},
Padding: {
args: [import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.void
args: [FFIType.ptr, FFIType.ptr],
returns: FFIType.void
},
BorderStyle: {
args: [import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.void
args: [FFIType.ptr, FFIType.ptr],
returns: FFIType.void
},
CustomBorder: {
args: [import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.void
args: [FFIType.ptr, FFIType.ptr],
returns: FFIType.void
},
FreeString: {
args: [import_bun_ffi.FFIType.ptr],
returns: import_bun_ffi.FFIType.void
args: [FFIType.ptr],
returns: FFIType.void
}

@@ -154,10 +102,38 @@ });

// src/utils.ts
var import_bun_ffi2 = require("bun:ffi");
var utf8e = new TextEncoder();
import {CString} from "bun:ffi";
function encode(data) {
return utf8e.encode(data + "\0");
}
var utf8e = new TextEncoder;
// src/lib.ts
var Position = /* @__PURE__ */ ((Position2) => {
function NewStyle() {
return Style.NewStyle();
}
function HasDarkBackground() {
return symbols.HasDarkBackground();
}
var combineArgs = function(args) {
return args.join(",");
};
function JoinHorizontal(position, ...paragraphs) {
const textPtr = symbols.JoinHorizontal(position, ptr(encode(combineArgs(paragraphs))));
const textStr = new CString2(textPtr);
symbols.FreeString(textStr.ptr);
return textStr.toString();
}
function JoinVertical(position, ...paragraphs) {
const textPtr = symbols.JoinVertical(position, ptr(encode(combineArgs(paragraphs))));
const textStr = new CString2(textPtr);
symbols.FreeString(textStr.ptr);
return textStr.toString();
}
function Width(text) {
return symbols.Width(ptr(encode(text)));
}
function Height(text) {
return symbols.Height(ptr(encode(text)));
}
var Position;
(function(Position2) {
Position2[Position2["Top"] = 0] = "Top";

@@ -168,25 +144,24 @@ Position2[Position2["Bottom"] = 1] = "Bottom";

Position2[Position2["Right"] = 1] = "Right";
return Position2;
})(Position || {});
var _handle;
var _Style = class {
})(Position || (Position = {}));
class Style {
#handle;
constructor(handle) {
__privateAdd(this, _handle, void 0);
__privateSet(this, _handle, handle);
this.#handle = handle;
}
static NewStyle() {
return new _Style(symbols.NewStyle());
return new Style(symbols.NewStyle());
}
SetColorValue(key, value) {
const adaptive = typeof value !== "string";
const color = adaptive ? (0, import_bun_ffi3.ptr)(encode(JSON.stringify(value))) : (0, import_bun_ffi3.ptr)(encode(value));
symbols.SetColorValue(__privateGet(this, _handle), (0, import_bun_ffi3.ptr)(encode(key)), color, adaptive);
const color = adaptive ? ptr(encode(JSON.stringify(value))) : ptr(encode(value));
symbols.SetColorValue(this.#handle, ptr(encode(key)), color, adaptive);
return this;
}
SetBooleanValue(key, value) {
symbols.SetBooleanValue(__privateGet(this, _handle), (0, import_bun_ffi3.ptr)(encode(key)), value ? 1 : 0);
symbols.SetBooleanValue(this.#handle, ptr(encode(key)), value);
return this;
}
SetIntValue(key, value) {
symbols.SetIntValue(__privateGet(this, _handle), (0, import_bun_ffi3.ptr)(encode(key)), value);
symbols.SetIntValue(this.#handle, ptr(encode(key)), value);
return this;

@@ -206,2 +181,5 @@ }

}
Height(val) {
return this.SetIntValue("Height", val);
}
Foreground(color) {

@@ -214,3 +192,3 @@ return this.SetColorValue("Foreground", color);

Padding(...values) {
symbols.Padding(__privateGet(this, _handle), (0, import_bun_ffi3.ptr)(encode(JSON.stringify(values))));
symbols.Padding(this.#handle, ptr(encode(JSON.stringify(values))));
return this;

@@ -231,3 +209,3 @@ }

Margin(...values) {
symbols.Margin(__privateGet(this, _handle), (0, import_bun_ffi3.ptr)(encode(JSON.stringify(values))));
symbols.Margin(this.#handle, ptr(encode(JSON.stringify(values))));
return this;

@@ -279,5 +257,5 @@ }

if (typeof style === "string") {
symbols.BorderStyle(__privateGet(this, _handle), (0, import_bun_ffi3.ptr)(encode(style)));
symbols.BorderStyle(this.#handle, ptr(encode(style)));
} else {
symbols.CustomBorder(__privateGet(this, _handle), (0, import_bun_ffi3.ptr)(encode(JSON.stringify(style))));
symbols.CustomBorder(this.#handle, ptr(encode(JSON.stringify(style))));
}

@@ -304,10 +282,4 @@ return this;

}
GetBoolValue() {
return symbols.GetBoolValue();
}
GetIntValue() {
return symbols.GetIntValue();
}
GetBold() {
return symbols.GetBoolValue(__privateGet(this, _handle), (0, import_bun_ffi3.ptr)(encode("GetBold")));
return symbols.GetBoolValue(this.#handle, ptr(encode("GetBold")));
}

@@ -318,8 +290,8 @@ Reverse(val) {

Align(position) {
symbols.Align(__privateGet(this, _handle), position);
symbols.Align(this.#handle, position);
return this;
}
Render(text) {
const textPtr = symbols.Render(__privateGet(this, _handle), (0, import_bun_ffi3.ptr)(encode(text)));
const textStr = new import_bun_ffi3.CString(textPtr);
const textPtr = symbols.Render(this.#handle, ptr(encode(text)));
const textStr = new CString2(textPtr);
symbols.FreeString(textStr.ptr);

@@ -329,9 +301,9 @@ return textStr.toString();

Copy() {
return new _Style(symbols.Copy(__privateGet(this, _handle)));
return new Style(symbols.Copy(this.#handle));
}
FreeHandle() {
symbols.FreeString(__privateGet(this, _handle));
symbols.FreeString(this.#handle);
}
UnsetRule(key) {
symbols.UnsetRule(__privateGet(this, _handle), (0, import_bun_ffi3.ptr)(encode(key)));
symbols.UnsetRule(this.#handle, ptr(encode(key)));
return this;

@@ -375,42 +347,12 @@ }

}
};
var Style = _Style;
_handle = new WeakMap();
function NewStyle() {
return Style.NewStyle();
}
function HasDarkBackground() {
return symbols.HasDarkBackground();
}
function combineArgs(args) {
return args.join(",");
}
function JoinHorizontal(position, ...paragraphs) {
const textPtr = symbols.JoinHorizontal(position, (0, import_bun_ffi3.ptr)(encode(combineArgs(paragraphs))));
const textStr = new import_bun_ffi3.CString(textPtr);
symbols.FreeString(textStr.ptr);
return textStr.toString();
}
function JoinVertical(position, ...paragraphs) {
const textPtr = symbols.JoinVertical(position, (0, import_bun_ffi3.ptr)(encode(combineArgs(paragraphs))));
const textStr = new import_bun_ffi3.CString(textPtr);
symbols.FreeString(textStr.ptr);
return textStr.toString();
}
function Width(text) {
return symbols.Width((0, import_bun_ffi3.ptr)(encode(text)));
}
function Height(text) {
return symbols.Height((0, import_bun_ffi3.ptr)(encode(text)));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
HasDarkBackground,
export {
Width,
Style,
Position,
NewStyle,
JoinVertical,
JoinHorizontal,
Height,
JoinHorizontal,
JoinVertical,
NewStyle,
Position,
Style,
Width
});
HasDarkBackground
};
{
"name": "blipgloss",
"version": "0.1.9",
"version": "0.2.0",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
}
},
"description": "",
"scripts": {
"build": "tsup",
"build": "bun run ./build.mjs",
"build:go": "./build.sh",

@@ -38,7 +30,6 @@ "release": "bumpp --commit --push --tag && npm publish",

"devDependencies": {
"bun-types": "^0.3.0",
"bumpp": "^8.2.1",
"typescript": "^4.7.4",
"tsup": "^6.5.0"
"bun-types": "^0.7.1",
"bun-plugin-dts": " ^0.1.0",
"typescript": "^5.1.6"
}
}

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