🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@clack/core

Package Overview
Dependencies
Maintainers
7
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clack/core - npm Package Compare versions

Comparing version
1.4.1
to
1.4.2
+13
-0
CHANGELOG.md
# @clack/core
## 1.4.2
### Patch Changes
- [#561](https://github.com/bombshell-dev/clack/pull/561) [`2f2b52f`](https://github.com/bombshell-dev/clack/commit/2f2b52f77cbfa9af618c6d929249ab8395fc37a1) Thanks [@avallete](https://github.com/avallete)! - Fix `password` prompt resolving to `undefined` on empty submit. It now normalizes an empty submission to `""`, matching the `text` prompt behavior and the documented `Promise<string | symbol>` return type.
- [#569](https://github.com/bombshell-dev/clack/pull/569) [`e1b6ee7`](https://github.com/bombshell-dev/clack/commit/e1b6ee71a76e17a3c33ba7ee6e5fb34e886233bb) Thanks [@43081j](https://github.com/43081j)! - fix: only submit multi-line prompt when double-return happens at end of input.
Also fixes two minor things:
- Initial value is used as initial user input for multi-line prompts
- Cursor is placed at the end when there is initial input
## 1.4.1

@@ -4,0 +17,0 @@

+30
-21

@@ -736,4 +736,4 @@ import { styleText } from 'node:util';

class h extends V {
#s = false;
#t;
#t = false;
#s;
focused = "editor";

@@ -746,6 +746,6 @@ get userInputWithCursor() {

return `${t}\u2588`;
const s = t.slice(0, this.cursor), r = t[this.cursor], e = t.slice(this.cursor + 1);
const s = t.slice(0, this.cursor), r = t[this.cursor], i = t.slice(this.cursor + 1);
return r === `
` ? `${s}\u2588
${e}` : `${s}${styleText("inverse", r)}${e}`;
${i}` : `${s}${styleText("inverse", r)}${i}`;
}

@@ -782,7 +782,7 @@ get cursor() {

_shouldSubmit(t, s) {
if (this.#t)
if (this.#s)
return this.focused === "submit" ? true : (this.#r(`
`), this._cursor++, false);
const r = this.#s;
return this.#s = true, r ? (this.userInput[this.cursor - 1] === `
const r = this.#t;
return this.#t = true, r && this.cursor === this.userInput.length ? (this.userInput[this.cursor - 1] === `
` && (this._setUserInput(

@@ -794,13 +794,20 @@ this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)

constructor(t) {
super(t, false), this.#t = t.showSubmit ?? false, this.on("key", (s, r) => {
if (r?.name && o$1.has(r.name)) {
this.#i(r.name);
const s = t.initialUserInput ?? t.initialValue;
super(
{
...t,
initialUserInput: s
},
false
), s !== void 0 && (this._cursor = s.length), this.#s = t.showSubmit ?? false, this.on("key", (r, i) => {
if (i?.name && o$1.has(i.name)) {
this.#t = false, this.#i(i.name);
return;
}
if (s === " " && this.#t) {
if (r === " " && this.#s) {
this.focused = this.focused === "editor" ? "submit" : "editor";
return;
}
if (r?.name !== "return") {
if (this.#s = false, r?.name === "backspace" && this.cursor > 0) {
if (i?.name !== "return") {
if (this.#t = false, i?.name === "backspace" && this.cursor > 0) {
this._setUserInput(

@@ -811,3 +818,3 @@ this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)

}
if (r?.name === "delete" && this.cursor < this.userInput.length) {
if (i?.name === "delete" && this.cursor < this.userInput.length) {
this._setUserInput(

@@ -818,6 +825,6 @@ this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1)

}
s && (this.#t && this.focused === "submit" && (this.focused = "editor"), this.#r(s ?? ""), this._cursor++);
r && (this.#s && this.focused === "submit" && (this.focused = "editor"), this.#r(r ?? ""), this._cursor++);
}
}), this.on("userInput", (s) => {
this._setValue(s);
}), this.on("userInput", (r) => {
this._setValue(r);
}), this.on("finalize", () => {

@@ -894,4 +901,4 @@ this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");

return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
const s = this.masked, r = s.slice(0, this.cursor), e = s.slice(this.cursor);
return `${r}${styleText("inverse", e[0])}${e.slice(1)}`;
const s = this.masked, e = s.slice(0, this.cursor), r = s.slice(this.cursor);
return `${e}${styleText("inverse", r[0])}${r.slice(1)}`;
}

@@ -902,4 +909,6 @@ clear() {

constructor({ mask: t, ...s }) {
super(s), this._mask = t ?? "\u2022", this.on("userInput", (r) => {
this._setValue(r);
super(s), this._mask = t ?? "\u2022", this.on("userInput", (e) => {
this._setValue(e);
}), this.on("finalize", () => {
this.value === void 0 && (this.value = "");
});

@@ -906,0 +915,0 @@ }

{
"name": "@clack/core",
"version": "1.4.1",
"version": "1.4.2",
"type": "module",

@@ -5,0 +5,0 @@ "main": "./dist/index.mjs",