mepcli 2.0.0-beta.3 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +20 -0
- package/dist/base.d.ts +1 -0
- package/dist/core.d.ts +7 -1
- package/dist/core.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -1
- package/dist/types.d.ts +16 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +1 -1
- package/package.json +3 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -255,6 +255,26 @@ const result = await new Pipeline<Context>()
|
|
|
255
255
|
.run();
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
+
## Extensions (Custom Prompts)
|
|
259
|
+
|
|
260
|
+
Mep is fully extensible. You can register your own prompt components and access them through the unified `MepCLI.prompt()` API with full Type Safety.
|
|
261
|
+
|
|
262
|
+
```typescript
|
|
263
|
+
import { MepCLI } from 'mepcli';
|
|
264
|
+
import { MyPrompt } from './MyPrompt';
|
|
265
|
+
|
|
266
|
+
// 1. Register
|
|
267
|
+
MepCLI.register('custom', MyPrompt);
|
|
268
|
+
|
|
269
|
+
// 2. Use with full type support
|
|
270
|
+
const result = await MepCLI.prompt({
|
|
271
|
+
type: 'custom',
|
|
272
|
+
message: 'Hello from extension!'
|
|
273
|
+
});
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
See the **[Extension Registry Guide](./docs/guides/extension-registry.md)** for more details.
|
|
277
|
+
|
|
258
278
|
## Keyboard & Mouse Support
|
|
259
279
|
|
|
260
280
|
For a detailed list of shortcuts and mouse interactions, please refer to the **[Shortcuts Documentation](./docs/features/shortcuts.md)**.
|
package/dist/base.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { detectCapabilities } from './utils';
|
|
|
4
4
|
* Abstract base class for all prompts.
|
|
5
5
|
* Implements a Robust Linear Scan Diffing Engine.
|
|
6
6
|
*/
|
|
7
|
+
export type PromptConstructor<T, O> = new (options: O) => Prompt<T, O>;
|
|
7
8
|
export declare abstract class Prompt<T, O> {
|
|
8
9
|
protected options: O;
|
|
9
10
|
protected value: any;
|
package/dist/core.d.ts
CHANGED
|
@@ -5,12 +5,18 @@ import { ConnectionStringOptions, ConnectionStringResult } from './prompts/conne
|
|
|
5
5
|
import { CurlOptions, CurlResult } from './prompts/curl';
|
|
6
6
|
import { Pipeline } from './pipeline';
|
|
7
7
|
import { TaskRunner } from './tasks';
|
|
8
|
-
import { TaskGroupOptions } from './types';
|
|
8
|
+
import { TaskGroupOptions, ExtensionRegistry } from './types';
|
|
9
|
+
import { PromptConstructor } from './base';
|
|
9
10
|
/**
|
|
10
11
|
* Public Facade for Mep
|
|
11
12
|
*/
|
|
12
13
|
export declare class MepCLI {
|
|
13
14
|
static theme: ThemeConfig;
|
|
15
|
+
private static registry;
|
|
16
|
+
static register<K extends keyof ExtensionRegistry>(type: K, promptClass: PromptConstructor<ExtensionRegistry[K]["result"], ExtensionRegistry[K]["options"]>): void;
|
|
17
|
+
static prompt<K extends keyof ExtensionRegistry>(options: {
|
|
18
|
+
type: K;
|
|
19
|
+
} & ExtensionRegistry[K]["options"]): Promise<ExtensionRegistry[K]["result"]>;
|
|
14
20
|
/**
|
|
15
21
|
* Creates a new Spinner instance to indicate background activity.
|
|
16
22
|
* @example
|
package/dist/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"MepCLI",{enumerable:true,get:function(){return MepCLI}});const _theme=require("./theme");const _spinner=require("./spinner");const _text=require("./prompts/text");const _select=require("./prompts/select");const _checkbox=require("./prompts/checkbox");const _confirm=require("./prompts/confirm");const _toggle=require("./prompts/toggle");const _number=require("./prompts/number");const _list=require("./prompts/list");const _slider=require("./prompts/slider");const _range=require("./prompts/range");const _transfer=require("./prompts/transfer");const _cron=require("./prompts/cron");const _date=require("./prompts/date");const _file=require("./prompts/file");const _multiselect=require("./prompts/multi-select");const _rating=require("./prompts/rating");const _autocomplete=require("./prompts/autocomplete");const _sort=require("./prompts/sort");const _table=require("./prompts/table");const _editor=require("./prompts/editor");const _tree=require("./prompts/tree");const _keypress=require("./prompts/keypress");const _form=require("./prompts/form");const _snippet=require("./prompts/snippet");const _spam=require("./prompts/spam");const _wait=require("./prompts/wait");const _code=require("./prompts/code");const _treeselect=require("./prompts/tree-select");const _color=require("./prompts/color");const _grid=require("./prompts/grid");const _calendar=require("./prompts/calendar");const _map=require("./prompts/map");const _semver=require("./prompts/semver");const _ip=require("./prompts/ip");const _otp=require("./prompts/otp");const _quizselect=require("./prompts/quiz-select");const _quiztext=require("./prompts/quiz-text");const _kanban=require("./prompts/kanban");const _time=require("./prompts/time");const _heatmap=require("./prompts/heatmap");const _byte=require("./prompts/byte");const _slot=require("./prompts/slot");const _gauge=require("./prompts/gauge");const _calculator=require("./prompts/calculator");const _emoji=require("./prompts/emoji");const _match=require("./prompts/match");const _diff=require("./prompts/diff");const _dial=require("./prompts/dial");const _draw=require("./prompts/draw");const _multicolumnselect=require("./prompts/multi-column-select");const _fuzzy=require("./prompts/fuzzy");const _miller=require("./prompts/miller");const _pattern=require("./prompts/pattern");const _region=require("./prompts/region");const _spreadsheet=require("./prompts/spreadsheet");const _scroll=require("./prompts/scroll");const _breadcrumb=require("./prompts/breadcrumb");const _schedule=require("./prompts/schedule");const _datainspector=require("./prompts/data-inspector");const _exec=require("./prompts/exec");const _shortcut=require("./prompts/shortcut");const _seat=require("./prompts/seat");const _selectrange=require("./prompts/select-range");const _sortgrid=require("./prompts/sort-grid");const _dependency=require("./prompts/dependency");const _license=require("./prompts/license");const _regex=require("./prompts/regex");const _box=require("./prompts/box");const _phone=require("./prompts/phone");const _fuzzymulticolumn=require("./prompts/fuzzy-multi-column");const _multirange=require("./prompts/multi-range");const _breadcrumbsearch=require("./prompts/breadcrumb-search");const _connectionstring=require("./prompts/connection-string");const _curl=require("./prompts/curl");const _pipeline=require("./pipeline");const _tasks=require("./tasks");function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}let MepCLI=class MepCLI{static spinner(message){return new _spinner.Spinner(message)}static tasks(options){return new _tasks.TaskRunner(options)}static pipeline(){return new _pipeline.Pipeline}static text(options){return new _text.TextPrompt(options).run()}static select(options){return new _select.SelectPrompt(options).run()}static checkbox(options){return new _checkbox.CheckboxPrompt(options).run()}static confirm(options){return new _confirm.ConfirmPrompt(options).run()}static password(options){return new _text.TextPrompt({...options,isPassword:true}).run()}static secret(options){return new _text.TextPrompt({...options,mask:""}).run()}static number(options){return new _number.NumberPrompt(options).run()}static toggle(options){return new _toggle.TogglePrompt(options).run()}static list(options){return new _list.ListPrompt(options).run()}static slider(options){return new _slider.SliderPrompt(options).run()}static range(options){return new _range.RangePrompt(options).run()}static transfer(options){return new _transfer.TransferPrompt(options).run()}static cron(options){return new _cron.CronPrompt(options).run()}static date(options){return new _date.DatePrompt(options).run()}static file(options){return new _file.FilePrompt(options).run()}static multiSelect(options){return new _multiselect.MultiSelectPrompt(options).run()}static rating(options){return new _rating.RatingPrompt(options).run()}static autocomplete(options){return new _autocomplete.AutocompletePrompt(options).run()}static sort(options){return new _sort.SortPrompt(options).run()}static table(options){return new _table.TablePrompt(options).run()}static editor(options){return new _editor.EditorPrompt(options).run()}static tree(options){return new _tree.TreePrompt(options).run()}static keypress(options){return new _keypress.KeypressPrompt(options).run()}static form(options){return new _form.FormPrompt(options).run()}static snippet(options){return new _snippet.SnippetPrompt(options).run()}static spam(options){return new _spam.SpamPrompt(options).run()}static wait(options){return new _wait.WaitPrompt(options).run()}static code(options){return new _code.CodePrompt(options).run()}static treeSelect(options){return new _treeselect.TreeSelectPrompt(options).run()}static color(options){return new _color.ColorPrompt(options).run()}static grid(options){return new _grid.GridPrompt(options).run()}static calendar(options){return new _calendar.CalendarPrompt(options).run()}static map(options){return new _map.MapPrompt(options).run()}static semver(options){return new _semver.SemVerPrompt(options).run()}static ip(options){return new _ip.IPPrompt(options).run()}static otp(options){return new _otp.OTPPrompt(options).run()}static quizSelect(options){return new _quizselect.QuizSelectPrompt(options).run()}static quizText(options){return new _quiztext.QuizTextPrompt(options).run()}static kanban(options){return new _kanban.KanbanPrompt(options).run()}static time(options){return new _time.TimePrompt(options).run()}static heatmap(options){return new _heatmap.HeatmapPrompt(options).run()}static byte(options){return new _byte.BytePrompt(options).run()}static slot(options){return new _slot.SlotPrompt(options).run()}static gauge(options){return new _gauge.GaugePrompt(options).run()}static calculator(options){return new _calculator.CalculatorPrompt(options).run()}static emoji(options){return new _emoji.EmojiPrompt(options).run()}static match(options){return new _match.MatchPrompt(options).run()}static diff(options){return new _diff.DiffPrompt(options).run()}static dial(options){return new _dial.DialPrompt(options).run()}static draw(options){return new _draw.DrawPrompt(options).run()}static multiColumnSelect(options){return new _multicolumnselect.MultiColumnSelectPrompt(options).run()}static fuzzySelect(options){return new _fuzzy.FuzzySelectPrompt(options).run()}static miller(options){return new _miller.MillerPrompt(options).run()}static pattern(options){return new _pattern.PatternPrompt(options).run()}static region(options){return new _region.RegionPrompt(options).run()}static spreadsheet(options){return new _spreadsheet.SpreadsheetPrompt(options).run()}static scroll(options){return new _scroll.ScrollPrompt(options).run()}static breadcrumb(options){return new _breadcrumb.BreadcrumbPrompt(options).run()}static schedule(options){return new _schedule.SchedulePrompt(options).run()}static inspector(options){return new _datainspector.DataInspectorPrompt(options).run()}static exec(options){return new _exec.ExecPrompt(options).run()}static shortcut(options){return new _shortcut.ShortcutPrompt(options).run()}static seat(options){return new _seat.SeatPrompt(options).run()}static selectRange(options){return new _selectrange.SelectRangePrompt(options).run()}static sortGrid(options){return new _sortgrid.SortGridPrompt(options).run()}static dependency(options){return new _dependency.DependencyPrompt(options).run()}static license(options){return new _license.LicensePrompt(options).run()}static regex(options){return new _regex.RegexPrompt(options).run()}static box(options){return new _box.BoxPrompt(options).run()}static connectionString(options){return(0,_connectionstring.connectionString)(options)}static curl(options){return new _curl.CurlPrompt(options).run()}static phone(options){return new _phone.PhonePrompt(options).run()}static fuzzyMultiColumn(options){return new _fuzzymulticolumn.FuzzyMultiColumnPrompt(options).run()}static multiRange(options){return new _multirange.MultiRangePrompt(options).run()}static breadcrumbSearch(options){return new _breadcrumbsearch.BreadcrumbSearchPrompt(options).run()}};_define_property(MepCLI,"theme",_theme.theme);
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"MepCLI",{enumerable:true,get:function(){return MepCLI}});const _theme=require("./theme");const _spinner=require("./spinner");const _text=require("./prompts/text");const _select=require("./prompts/select");const _checkbox=require("./prompts/checkbox");const _confirm=require("./prompts/confirm");const _toggle=require("./prompts/toggle");const _number=require("./prompts/number");const _list=require("./prompts/list");const _slider=require("./prompts/slider");const _range=require("./prompts/range");const _transfer=require("./prompts/transfer");const _cron=require("./prompts/cron");const _date=require("./prompts/date");const _file=require("./prompts/file");const _multiselect=require("./prompts/multi-select");const _rating=require("./prompts/rating");const _autocomplete=require("./prompts/autocomplete");const _sort=require("./prompts/sort");const _table=require("./prompts/table");const _editor=require("./prompts/editor");const _tree=require("./prompts/tree");const _keypress=require("./prompts/keypress");const _form=require("./prompts/form");const _snippet=require("./prompts/snippet");const _spam=require("./prompts/spam");const _wait=require("./prompts/wait");const _code=require("./prompts/code");const _treeselect=require("./prompts/tree-select");const _color=require("./prompts/color");const _grid=require("./prompts/grid");const _calendar=require("./prompts/calendar");const _map=require("./prompts/map");const _semver=require("./prompts/semver");const _ip=require("./prompts/ip");const _otp=require("./prompts/otp");const _quizselect=require("./prompts/quiz-select");const _quiztext=require("./prompts/quiz-text");const _kanban=require("./prompts/kanban");const _time=require("./prompts/time");const _heatmap=require("./prompts/heatmap");const _byte=require("./prompts/byte");const _slot=require("./prompts/slot");const _gauge=require("./prompts/gauge");const _calculator=require("./prompts/calculator");const _emoji=require("./prompts/emoji");const _match=require("./prompts/match");const _diff=require("./prompts/diff");const _dial=require("./prompts/dial");const _draw=require("./prompts/draw");const _multicolumnselect=require("./prompts/multi-column-select");const _fuzzy=require("./prompts/fuzzy");const _miller=require("./prompts/miller");const _pattern=require("./prompts/pattern");const _region=require("./prompts/region");const _spreadsheet=require("./prompts/spreadsheet");const _scroll=require("./prompts/scroll");const _breadcrumb=require("./prompts/breadcrumb");const _schedule=require("./prompts/schedule");const _datainspector=require("./prompts/data-inspector");const _exec=require("./prompts/exec");const _shortcut=require("./prompts/shortcut");const _seat=require("./prompts/seat");const _selectrange=require("./prompts/select-range");const _sortgrid=require("./prompts/sort-grid");const _dependency=require("./prompts/dependency");const _license=require("./prompts/license");const _regex=require("./prompts/regex");const _box=require("./prompts/box");const _phone=require("./prompts/phone");const _fuzzymulticolumn=require("./prompts/fuzzy-multi-column");const _multirange=require("./prompts/multi-range");const _breadcrumbsearch=require("./prompts/breadcrumb-search");const _connectionstring=require("./prompts/connection-string");const _curl=require("./prompts/curl");const _pipeline=require("./pipeline");const _tasks=require("./tasks");function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}let MepCLI=class MepCLI{static register(type,promptClass){const key=type;if(MepCLI.registry.has(key)){console.warn(`[MepCLI] Warning: Prompt type "${key}" is already registered. `+`The existing implementation will be overwritten.`)}MepCLI.registry.set(key,promptClass)}static prompt(options){const{type,...promptOptions}=options;const TargetClass=MepCLI.registry.get(type);if(!TargetClass)throw new Error(`Prompt type "${String(type)}" is not registered.`);const instance=new TargetClass(promptOptions);return instance.run()}static spinner(message){return new _spinner.Spinner(message)}static tasks(options){return new _tasks.TaskRunner(options)}static pipeline(){return new _pipeline.Pipeline}static text(options){return new _text.TextPrompt(options).run()}static select(options){return new _select.SelectPrompt(options).run()}static checkbox(options){return new _checkbox.CheckboxPrompt(options).run()}static confirm(options){return new _confirm.ConfirmPrompt(options).run()}static password(options){return new _text.TextPrompt({...options,isPassword:true}).run()}static secret(options){return new _text.TextPrompt({...options,mask:""}).run()}static number(options){return new _number.NumberPrompt(options).run()}static toggle(options){return new _toggle.TogglePrompt(options).run()}static list(options){return new _list.ListPrompt(options).run()}static slider(options){return new _slider.SliderPrompt(options).run()}static range(options){return new _range.RangePrompt(options).run()}static transfer(options){return new _transfer.TransferPrompt(options).run()}static cron(options){return new _cron.CronPrompt(options).run()}static date(options){return new _date.DatePrompt(options).run()}static file(options){return new _file.FilePrompt(options).run()}static multiSelect(options){return new _multiselect.MultiSelectPrompt(options).run()}static rating(options){return new _rating.RatingPrompt(options).run()}static autocomplete(options){return new _autocomplete.AutocompletePrompt(options).run()}static sort(options){return new _sort.SortPrompt(options).run()}static table(options){return new _table.TablePrompt(options).run()}static editor(options){return new _editor.EditorPrompt(options).run()}static tree(options){return new _tree.TreePrompt(options).run()}static keypress(options){return new _keypress.KeypressPrompt(options).run()}static form(options){return new _form.FormPrompt(options).run()}static snippet(options){return new _snippet.SnippetPrompt(options).run()}static spam(options){return new _spam.SpamPrompt(options).run()}static wait(options){return new _wait.WaitPrompt(options).run()}static code(options){return new _code.CodePrompt(options).run()}static treeSelect(options){return new _treeselect.TreeSelectPrompt(options).run()}static color(options){return new _color.ColorPrompt(options).run()}static grid(options){return new _grid.GridPrompt(options).run()}static calendar(options){return new _calendar.CalendarPrompt(options).run()}static map(options){return new _map.MapPrompt(options).run()}static semver(options){return new _semver.SemVerPrompt(options).run()}static ip(options){return new _ip.IPPrompt(options).run()}static otp(options){return new _otp.OTPPrompt(options).run()}static quizSelect(options){return new _quizselect.QuizSelectPrompt(options).run()}static quizText(options){return new _quiztext.QuizTextPrompt(options).run()}static kanban(options){return new _kanban.KanbanPrompt(options).run()}static time(options){return new _time.TimePrompt(options).run()}static heatmap(options){return new _heatmap.HeatmapPrompt(options).run()}static byte(options){return new _byte.BytePrompt(options).run()}static slot(options){return new _slot.SlotPrompt(options).run()}static gauge(options){return new _gauge.GaugePrompt(options).run()}static calculator(options){return new _calculator.CalculatorPrompt(options).run()}static emoji(options){return new _emoji.EmojiPrompt(options).run()}static match(options){return new _match.MatchPrompt(options).run()}static diff(options){return new _diff.DiffPrompt(options).run()}static dial(options){return new _dial.DialPrompt(options).run()}static draw(options){return new _draw.DrawPrompt(options).run()}static multiColumnSelect(options){return new _multicolumnselect.MultiColumnSelectPrompt(options).run()}static fuzzySelect(options){return new _fuzzy.FuzzySelectPrompt(options).run()}static miller(options){return new _miller.MillerPrompt(options).run()}static pattern(options){return new _pattern.PatternPrompt(options).run()}static region(options){return new _region.RegionPrompt(options).run()}static spreadsheet(options){return new _spreadsheet.SpreadsheetPrompt(options).run()}static scroll(options){return new _scroll.ScrollPrompt(options).run()}static breadcrumb(options){return new _breadcrumb.BreadcrumbPrompt(options).run()}static schedule(options){return new _schedule.SchedulePrompt(options).run()}static inspector(options){return new _datainspector.DataInspectorPrompt(options).run()}static exec(options){return new _exec.ExecPrompt(options).run()}static shortcut(options){return new _shortcut.ShortcutPrompt(options).run()}static seat(options){return new _seat.SeatPrompt(options).run()}static selectRange(options){return new _selectrange.SelectRangePrompt(options).run()}static sortGrid(options){return new _sortgrid.SortGridPrompt(options).run()}static dependency(options){return new _dependency.DependencyPrompt(options).run()}static license(options){return new _license.LicensePrompt(options).run()}static regex(options){return new _regex.RegexPrompt(options).run()}static box(options){return new _box.BoxPrompt(options).run()}static connectionString(options){return(0,_connectionstring.connectionString)(options)}static curl(options){return new _curl.CurlPrompt(options).run()}static phone(options){return new _phone.PhonePrompt(options).run()}static fuzzyMultiColumn(options){return new _fuzzymulticolumn.FuzzyMultiColumnPrompt(options).run()}static multiRange(options){return new _multirange.MultiRangePrompt(options).run()}static breadcrumbSearch(options){return new _breadcrumbsearch.BreadcrumbSearchPrompt(options).run()}};_define_property(MepCLI,"theme",_theme.theme);_define_property(MepCLI,"registry",new Map);
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export * from './types';
|
|
6
6
|
export * from './core';
|
|
7
|
+
export { ANSI } from './ansi';
|
|
8
|
+
export { InputParser } from './input';
|
|
9
|
+
export { Prompt, type PromptConstructor } from './base';
|
|
10
|
+
export { stringWidth, truncate, stripAnsi } from './utils';
|
|
7
11
|
export * from './prompts/map';
|
|
8
12
|
export * from './prompts/semver';
|
|
9
13
|
export * from './prompts/ip';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});_export_star(require("./types"),exports);_export_star(require("./core"),exports);_export_star(require("./prompts/map"),exports);_export_star(require("./prompts/semver"),exports);_export_star(require("./prompts/ip"),exports);_export_star(require("./prompts/kanban"),exports);_export_star(require("./prompts/time"),exports);_export_star(require("./prompts/heatmap"),exports);_export_star(require("./prompts/byte"),exports);_export_star(require("./prompts/slot"),exports);_export_star(require("./prompts/gauge"),exports);_export_star(require("./prompts/calculator"),exports);_export_star(require("./prompts/emoji"),exports);_export_star(require("./prompts/match"),exports);_export_star(require("./prompts/diff"),exports);_export_star(require("./prompts/dial"),exports);_export_star(require("./prompts/draw"),exports);_export_star(require("./prompts/multi-column-select"),exports);_export_star(require("./prompts/fuzzy"),exports);_export_star(require("./prompts/miller"),exports);_export_star(require("./prompts/pattern"),exports);_export_star(require("./prompts/region"),exports);_export_star(require("./prompts/spreadsheet"),exports);_export_star(require("./prompts/scroll"),exports);_export_star(require("./prompts/breadcrumb"),exports);_export_star(require("./prompts/schedule"),exports);_export_star(require("./prompts/data-inspector"),exports);_export_star(require("./prompts/exec"),exports);_export_star(require("./prompts/shortcut"),exports);_export_star(require("./prompts/seat"),exports);_export_star(require("./prompts/select-range"),exports);_export_star(require("./prompts/sort-grid"),exports);_export_star(require("./prompts/dependency"),exports);_export_star(require("./prompts/license"),exports);_export_star(require("./prompts/regex"),exports);_export_star(require("./prompts/box"),exports);_export_star(require("./prompts/connection-string"),exports);_export_star(require("./prompts/curl"),exports);_export_star(require("./prompts/phone"),exports);_export_star(require("./prompts/fuzzy-multi-column"),exports);_export_star(require("./prompts/multi-range"),exports);_export_star(require("./prompts/breadcrumb-search"),exports);_export_star(require("./pipeline"),exports);_export_star(require("./tasks"),exports);function _export_star(from,to){Object.keys(from).forEach(function(k){if(k!=="default"&&!Object.prototype.hasOwnProperty.call(to,k)){Object.defineProperty(to,k,{enumerable:true,get:function(){return from[k]}})}});return from}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get ANSI(){return _ansi.ANSI},get InputParser(){return _input.InputParser},get Prompt(){return _base.Prompt},get stringWidth(){return _utils.stringWidth},get stripAnsi(){return _utils.stripAnsi},get truncate(){return _utils.truncate}});_export_star(require("./types"),exports);_export_star(require("./core"),exports);const _ansi=require("./ansi");const _input=require("./input");const _base=require("./base");const _utils=require("./utils");_export_star(require("./prompts/map"),exports);_export_star(require("./prompts/semver"),exports);_export_star(require("./prompts/ip"),exports);_export_star(require("./prompts/kanban"),exports);_export_star(require("./prompts/time"),exports);_export_star(require("./prompts/heatmap"),exports);_export_star(require("./prompts/byte"),exports);_export_star(require("./prompts/slot"),exports);_export_star(require("./prompts/gauge"),exports);_export_star(require("./prompts/calculator"),exports);_export_star(require("./prompts/emoji"),exports);_export_star(require("./prompts/match"),exports);_export_star(require("./prompts/diff"),exports);_export_star(require("./prompts/dial"),exports);_export_star(require("./prompts/draw"),exports);_export_star(require("./prompts/multi-column-select"),exports);_export_star(require("./prompts/fuzzy"),exports);_export_star(require("./prompts/miller"),exports);_export_star(require("./prompts/pattern"),exports);_export_star(require("./prompts/region"),exports);_export_star(require("./prompts/spreadsheet"),exports);_export_star(require("./prompts/scroll"),exports);_export_star(require("./prompts/breadcrumb"),exports);_export_star(require("./prompts/schedule"),exports);_export_star(require("./prompts/data-inspector"),exports);_export_star(require("./prompts/exec"),exports);_export_star(require("./prompts/shortcut"),exports);_export_star(require("./prompts/seat"),exports);_export_star(require("./prompts/select-range"),exports);_export_star(require("./prompts/sort-grid"),exports);_export_star(require("./prompts/dependency"),exports);_export_star(require("./prompts/license"),exports);_export_star(require("./prompts/regex"),exports);_export_star(require("./prompts/box"),exports);_export_star(require("./prompts/connection-string"),exports);_export_star(require("./prompts/curl"),exports);_export_star(require("./prompts/phone"),exports);_export_star(require("./prompts/fuzzy-multi-column"),exports);_export_star(require("./prompts/multi-range"),exports);_export_star(require("./prompts/breadcrumb-search"),exports);_export_star(require("./pipeline"),exports);_export_star(require("./tasks"),exports);function _export_star(from,to){Object.keys(from).forEach(function(k){if(k!=="default"&&!Object.prototype.hasOwnProperty.call(to,k)){Object.defineProperty(to,k,{enumerable:true,get:function(){return from[k]}})}});return from}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type definitions for Mep CLI interactions.
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Extension registry for custom prompts.
|
|
6
|
+
* Extend this interface via declaration merging to register custom prompt types:
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* declare module 'mep' {
|
|
10
|
+
* interface ExtensionRegistry {
|
|
11
|
+
* myPrompt: { options: MyPromptOptions; result: string };
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* MepCLI.register('myPrompt', MyPromptClass);
|
|
15
|
+
* const result = await MepCLI.prompt({ type: 'myPrompt', message: '...' });
|
|
16
|
+
* @see {@link https://github.com/CodeTease/mep/blob/main/examples/extension-registry.ts}
|
|
17
|
+
*/
|
|
18
|
+
export interface ExtensionRegistry {
|
|
19
|
+
}
|
|
4
20
|
export interface ThemeConfig {
|
|
5
21
|
main: string;
|
|
6
22
|
success: string;
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get Graph(){return Graph},get Layout(){return Layout},get detectCapabilities(){return detectCapabilities},get fuzzyMatch(){return fuzzyMatch},get generateProgressBar(){return generateProgressBar},get safeSplit(){return safeSplit},get stringWidth(){return stringWidth},get stripAnsi(){return stripAnsi}});function detectCapabilities(){const env=process.env;const isCI=!!env.CI;const hasTrueColor=env.COLORTERM==="truecolor"||!!env.WT_SESSION;const isTTY=process.stdout.isTTY;const isWindows=process.platform==="win32";const isUnicodeSupported=()=>{if(isWindows){if(env.WT_SESSION)return true;if(env.TERM_PROGRAM==="vscode")return true;if(env.TERM==="xterm-256color"||env.TERM==="alacritty")return true;if(env.ConEmuTask)return true;if(isCI)return true;return false}if(env.TERM_PROGRAM==="Apple_Terminal")return true;const lang=env.LANG||"";const lcAll=env.LC_ALL||"";return lang&&lang.toUpperCase().endsWith("UTF-8")||lcAll&&lcAll.toUpperCase().endsWith("UTF-8")};return{isCI,hasTrueColor,hasUnicode:isTTY&&isUnicodeSupported(),hasMouse:isTTY&&!isCI}}function stripAnsi(str){return str.replace(/\x1b\[[0-9;]*m/g,"")}const WIDE_RANGES=[[4352,4607],[11904,12031],[12032,12255],[12288,12351],[12352,12447],[12448,12543],[12544,12591],[12592,12687],[12800,13055],[13056,13311],[13312,19903],[19968,40959],[43360,43391],[44032,55215],[55216,55295],[63744,64255],[65040,65055],[65072,65103],[65104,65135],[65281,65376],[65504,65510],[127744,128767],[129280,129535]];function isWideCodePoint(cp){let low=0;let high=WIDE_RANGES.length-1;while(low<=high){const mid=Math.floor((low+high)/2);const[start,end]=WIDE_RANGES[mid];if(cp>=start&&cp<=end){return true}else if(cp<start){high=mid-1}else{low=mid+1}}return false}function stringWidth(str){let width=0;let inAnsi=false;for(let i=0;i<str.length;i++){const code=str.charCodeAt(i);if(str[i]==="\x1b"){inAnsi=true;continue}if(inAnsi){if(str[i]==="["){continue}if(str[i]>="@"&&str[i]<="~"){inAnsi=false}continue}let cp=code;if(code>=55296&&code<=56319&&i+1<str.length){const next=str.charCodeAt(i+1);if(next>=56320&&next<=57343){cp=(code-55296)*1024+(next-56320)+65536;i++}}width+=isWideCodePoint(cp)?2:1}return width}function safeSplit(str){const segmenter=new Intl.Segmenter(undefined,{granularity:"grapheme"});const segments=segmenter.segment(str);const result=[];for(const segment of segments){result.push(segment.segment)}return result}function fuzzyMatch(query,target){if(!query)return{score:0,indices:[]};const queryLower=query.toLowerCase();const targetLower=target.toLowerCase();let queryIdx=0;let targetIdx=0;const indices=[];let score=0;let consecutive=0;let lastMatchIdx=-1;while(queryIdx<queryLower.length&&targetIdx<targetLower.length){const qChar=queryLower[queryIdx];const tChar=targetLower[targetIdx];if(qChar===tChar){indices.push(targetIdx);let charScore=1;if(lastMatchIdx!==-1&&targetIdx===lastMatchIdx+1){consecutive++;charScore+=consecutive*2}else{consecutive=0}if(targetIdx===0){charScore+=5}else if(targetIdx>0){const prevChar=target.charAt(targetIdx-1);if(/[\s_\-.]/.test(prevChar)||prevChar==="/"){charScore+=4}else if(prevChar!==prevChar.toUpperCase()&&target.charAt(targetIdx)===target.charAt(targetIdx).toUpperCase()){charScore+=3}}score+=charScore;lastMatchIdx=targetIdx;queryIdx++}targetIdx++}if(queryIdx<queryLower.length){return null}score-=target.length*.1;if(indices.length>1){const spread=indices[indices.length-1]-indices[0];score-=spread*.5}return{score,indices}}const Layout={truncate(str,width){const visualWidth=stringWidth(str);if(visualWidth<=width){return str}let currentWidth=0;let cutIndex=0;let inAnsi=false;for(let i=0;i<str.length;i++){if(str[i]==="\x1b")inAnsi=true;if(!inAnsi){const code=str.charCodeAt(i);if(code>=55296&&code<=56319&&i+1<str.length){const next=str.charCodeAt(i+1);if(next>=56320&&next<=57343){const cp=(code-55296)*1024+(next-56320)+65536;const w=isWideCodePoint(cp)?2:1;if(currentWidth+w>width)break;currentWidth+=w;cutIndex=i+2;i++;continue}}const w=isWideCodePoint(code)?2:1;if(currentWidth+w>width)break;currentWidth+=w}else{if(str[i]==="m"||str[i]>="A"&&str[i]<="Z")inAnsi=false}cutIndex=i+1}return str.substring(0,cutIndex)+"\x1b[0m"},pad(text,length,align="left"){const visualLen=stringWidth(text);if(visualLen>=length)return text;const padLen=Math.max(0,length-visualLen);if(align==="left"){return text+" ".repeat(padLen)}else if(align==="right"){return" ".repeat(padLen)+text}else{const leftPad=Math.floor(padLen/2);const rightPad=padLen-leftPad;return" ".repeat(leftPad)+text+" ".repeat(rightPad)}},split(left,right,width,options={}){const ratio=options.ratio??.5;const gap=options.gap??2;let leftWidth=Math.floor((width-gap)*ratio);let rightWidth=width-leftWidth-gap;if(leftWidth<1||rightWidth<1){leftWidth=Math.max(0,width);rightWidth=0}const leftLines=left.split("\n");const rightLines=right.split("\n");const maxLines=Math.max(leftLines.length,rightLines.length);const result=[];for(let i=0;i<maxLines;i++){const leftLine=leftLines[i]||"";const rightLine=rightLines[i]||"";const l=Layout.pad(Layout.truncate(leftLine,leftWidth),leftWidth);const r=Layout.pad(Layout.truncate(rightLine,rightWidth),rightWidth);result.push(`${l}${" ".repeat(gap)}${r}`)}return result.join("\n")},wrap(str,width){const paragraphs=str.split("\n");return paragraphs.map(para=>{const words=para.split(" ");let currentLine="";const lines=[];for(const word of words){const wordWidth=stringWidth(word);const currentWidth=stringWidth(currentLine);const spaceWidth=currentLine?1:0;if(currentWidth+spaceWidth+wordWidth<=width){currentLine+=(currentLine?" ":"")+word}else{if(currentLine)lines.push(currentLine);currentLine=word}}if(currentLine)lines.push(currentLine);return lines.join("\n")}).join("\n")}};const Graph={getDependencies(item,getDeps){const visited=new Set;const result=[];const visit=current=>{if(visited.has(current))return;visited.add(current);const deps=getDeps(current);for(const dep of deps){visit(dep)}if(current!==item){result.push(current)}};visit(item);return result},topologicalSort(items,getDeps){const visited=new Set;const temp=new Set;const order=[];const visit=node=>{if(temp.has(node)){throw new Error("Cyclic dependency detected")}if(visited.has(node))return;temp.add(node);const deps=getDeps(node);for(const dep of deps){visit(dep)}temp.delete(node);visited.add(node);order.push(node)};for(const item of items){if(!visited.has(item)){visit(item)}}return order}};function generateProgressBar(current,total,width=20){const percentage=Math.min(Math.max(current/total,0),1);const barWidth=width;const filledWidth=Math.round(barWidth*percentage);const emptyWidth=barWidth-filledWidth;const filled="█".repeat(filledWidth);const empty="-".repeat(emptyWidth);const percentStr=Math.round(percentage*100)+"%";return`[${filled}${empty}] ${percentStr}`}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get Graph(){return Graph},get Layout(){return Layout},get detectCapabilities(){return detectCapabilities},get fuzzyMatch(){return fuzzyMatch},get generateProgressBar(){return generateProgressBar},get safeSplit(){return safeSplit},get stringWidth(){return stringWidth},get stripAnsi(){return stripAnsi},get truncate(){return truncate}});function detectCapabilities(){const env=process.env;const isCI=!!env.CI;const hasTrueColor=env.COLORTERM==="truecolor"||!!env.WT_SESSION;const isTTY=process.stdout.isTTY;const isWindows=process.platform==="win32";const isUnicodeSupported=()=>{if(isWindows){if(env.WT_SESSION)return true;if(env.TERM_PROGRAM==="vscode")return true;if(env.TERM==="xterm-256color"||env.TERM==="alacritty")return true;if(env.ConEmuTask)return true;if(isCI)return true;return false}if(env.TERM_PROGRAM==="Apple_Terminal")return true;const lang=env.LANG||"";const lcAll=env.LC_ALL||"";return lang&&lang.toUpperCase().endsWith("UTF-8")||lcAll&&lcAll.toUpperCase().endsWith("UTF-8")};return{isCI,hasTrueColor,hasUnicode:isTTY&&isUnicodeSupported(),hasMouse:isTTY&&!isCI}}function stripAnsi(str){return str.replace(/\x1b\[[0-9;]*m/g,"")}const WIDE_RANGES=[[4352,4607],[11904,12031],[12032,12255],[12288,12351],[12352,12447],[12448,12543],[12544,12591],[12592,12687],[12800,13055],[13056,13311],[13312,19903],[19968,40959],[43360,43391],[44032,55215],[55216,55295],[63744,64255],[65040,65055],[65072,65103],[65104,65135],[65281,65376],[65504,65510],[127744,128767],[129280,129535]];function isWideCodePoint(cp){let low=0;let high=WIDE_RANGES.length-1;while(low<=high){const mid=Math.floor((low+high)/2);const[start,end]=WIDE_RANGES[mid];if(cp>=start&&cp<=end){return true}else if(cp<start){high=mid-1}else{low=mid+1}}return false}function stringWidth(str){let width=0;let inAnsi=false;for(let i=0;i<str.length;i++){const code=str.charCodeAt(i);if(str[i]==="\x1b"){inAnsi=true;continue}if(inAnsi){if(str[i]==="["){continue}if(str[i]>="@"&&str[i]<="~"){inAnsi=false}continue}let cp=code;if(code>=55296&&code<=56319&&i+1<str.length){const next=str.charCodeAt(i+1);if(next>=56320&&next<=57343){cp=(code-55296)*1024+(next-56320)+65536;i++}}width+=isWideCodePoint(cp)?2:1}return width}function safeSplit(str){const segmenter=new Intl.Segmenter(undefined,{granularity:"grapheme"});const segments=segmenter.segment(str);const result=[];for(const segment of segments){result.push(segment.segment)}return result}function fuzzyMatch(query,target){if(!query)return{score:0,indices:[]};const queryLower=query.toLowerCase();const targetLower=target.toLowerCase();let queryIdx=0;let targetIdx=0;const indices=[];let score=0;let consecutive=0;let lastMatchIdx=-1;while(queryIdx<queryLower.length&&targetIdx<targetLower.length){const qChar=queryLower[queryIdx];const tChar=targetLower[targetIdx];if(qChar===tChar){indices.push(targetIdx);let charScore=1;if(lastMatchIdx!==-1&&targetIdx===lastMatchIdx+1){consecutive++;charScore+=consecutive*2}else{consecutive=0}if(targetIdx===0){charScore+=5}else if(targetIdx>0){const prevChar=target.charAt(targetIdx-1);if(/[\s_\-.]/.test(prevChar)||prevChar==="/"){charScore+=4}else if(prevChar!==prevChar.toUpperCase()&&target.charAt(targetIdx)===target.charAt(targetIdx).toUpperCase()){charScore+=3}}score+=charScore;lastMatchIdx=targetIdx;queryIdx++}targetIdx++}if(queryIdx<queryLower.length){return null}score-=target.length*.1;if(indices.length>1){const spread=indices[indices.length-1]-indices[0];score-=spread*.5}return{score,indices}}const Layout={truncate(str,width){const visualWidth=stringWidth(str);if(visualWidth<=width){return str}let currentWidth=0;let cutIndex=0;let inAnsi=false;for(let i=0;i<str.length;i++){if(str[i]==="\x1b")inAnsi=true;if(!inAnsi){const code=str.charCodeAt(i);if(code>=55296&&code<=56319&&i+1<str.length){const next=str.charCodeAt(i+1);if(next>=56320&&next<=57343){const cp=(code-55296)*1024+(next-56320)+65536;const w=isWideCodePoint(cp)?2:1;if(currentWidth+w>width)break;currentWidth+=w;cutIndex=i+2;i++;continue}}const w=isWideCodePoint(code)?2:1;if(currentWidth+w>width)break;currentWidth+=w}else{if(str[i]==="m"||str[i]>="A"&&str[i]<="Z")inAnsi=false}cutIndex=i+1}return str.substring(0,cutIndex)+"\x1b[0m"},pad(text,length,align="left"){const visualLen=stringWidth(text);if(visualLen>=length)return text;const padLen=Math.max(0,length-visualLen);if(align==="left"){return text+" ".repeat(padLen)}else if(align==="right"){return" ".repeat(padLen)+text}else{const leftPad=Math.floor(padLen/2);const rightPad=padLen-leftPad;return" ".repeat(leftPad)+text+" ".repeat(rightPad)}},split(left,right,width,options={}){const ratio=options.ratio??.5;const gap=options.gap??2;let leftWidth=Math.floor((width-gap)*ratio);let rightWidth=width-leftWidth-gap;if(leftWidth<1||rightWidth<1){leftWidth=Math.max(0,width);rightWidth=0}const leftLines=left.split("\n");const rightLines=right.split("\n");const maxLines=Math.max(leftLines.length,rightLines.length);const result=[];for(let i=0;i<maxLines;i++){const leftLine=leftLines[i]||"";const rightLine=rightLines[i]||"";const l=Layout.pad(Layout.truncate(leftLine,leftWidth),leftWidth);const r=Layout.pad(Layout.truncate(rightLine,rightWidth),rightWidth);result.push(`${l}${" ".repeat(gap)}${r}`)}return result.join("\n")},wrap(str,width){const paragraphs=str.split("\n");return paragraphs.map(para=>{const words=para.split(" ");let currentLine="";const lines=[];for(const word of words){const wordWidth=stringWidth(word);const currentWidth=stringWidth(currentLine);const spaceWidth=currentLine?1:0;if(currentWidth+spaceWidth+wordWidth<=width){currentLine+=(currentLine?" ":"")+word}else{if(currentLine)lines.push(currentLine);currentLine=word}}if(currentLine)lines.push(currentLine);return lines.join("\n")}).join("\n")}};const Graph={getDependencies(item,getDeps){const visited=new Set;const result=[];const visit=current=>{if(visited.has(current))return;visited.add(current);const deps=getDeps(current);for(const dep of deps){visit(dep)}if(current!==item){result.push(current)}};visit(item);return result},topologicalSort(items,getDeps){const visited=new Set;const temp=new Set;const order=[];const visit=node=>{if(temp.has(node)){throw new Error("Cyclic dependency detected")}if(visited.has(node))return;temp.add(node);const deps=getDeps(node);for(const dep of deps){visit(dep)}temp.delete(node);visited.add(node);order.push(node)};for(const item of items){if(!visited.has(item)){visit(item)}}return order}};function generateProgressBar(current,total,width=20){const percentage=Math.min(Math.max(current/total,0),1);const barWidth=width;const filledWidth=Math.round(barWidth*percentage);const emptyWidth=barWidth-filledWidth;const filled="█".repeat(filledWidth);const empty="-".repeat(emptyWidth);const percentStr=Math.round(percentage*100)+"%";return`[${filled}${empty}] ${percentStr}`}const truncate=Layout.truncate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mepcli",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.4",
|
|
4
4
|
"description": "Zero-dependency interactive CLI prompt",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"@biomejs/biome": "^1.9.4",
|
|
51
51
|
"@swc/cli": "^0.8.0",
|
|
52
52
|
"@swc/core": "^1.15.18",
|
|
53
|
-
"@types/
|
|
53
|
+
"@types/jest": "^30.0.0",
|
|
54
|
+
"@types/node": "^22.19.15",
|
|
54
55
|
"typescript": "^5.9.3"
|
|
55
56
|
}
|
|
56
57
|
}
|