talented-args 0.2.4-beta → 0.3.0-beta

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.
Files changed (70) hide show
  1. package/README.md +497 -10
  2. package/dist/clipboard.d.ts +10 -0
  3. package/dist/clipboard.js +79 -0
  4. package/dist/clipboard.js.map +1 -0
  5. package/dist/compile.d.ts +67 -0
  6. package/dist/compile.js +188 -0
  7. package/dist/compile.js.map +1 -0
  8. package/dist/descriptors.d.ts +322 -0
  9. package/dist/descriptors.js +362 -0
  10. package/dist/descriptors.js.map +1 -0
  11. package/dist/display.d.ts +31 -0
  12. package/dist/display.js +235 -0
  13. package/dist/display.js.map +1 -0
  14. package/dist/errors.d.ts +34 -17
  15. package/dist/errors.js +61 -75
  16. package/dist/errors.js.map +1 -1
  17. package/dist/index.d.ts +10 -6
  18. package/dist/index.js +8 -9
  19. package/dist/index.js.map +1 -1
  20. package/dist/options.d.ts +69 -37
  21. package/dist/options.js +198 -31
  22. package/dist/options.js.map +1 -1
  23. package/dist/parse.d.ts +70 -0
  24. package/dist/parse.js +551 -0
  25. package/dist/parse.js.map +1 -0
  26. package/dist/program.d.ts +125 -0
  27. package/dist/program.js +337 -0
  28. package/dist/program.js.map +1 -0
  29. package/dist/remember.d.ts +71 -0
  30. package/dist/remember.js +216 -0
  31. package/dist/remember.js.map +1 -0
  32. package/dist/styling.d.ts +38 -9
  33. package/dist/styling.js +155 -75
  34. package/dist/styling.js.map +1 -1
  35. package/dist/terminal.d.ts +205 -0
  36. package/dist/terminal.js +152 -0
  37. package/dist/terminal.js.map +1 -0
  38. package/dist/tools.d.ts +35 -31
  39. package/dist/tools.js +68 -140
  40. package/dist/tools.js.map +1 -1
  41. package/dist/tui.d.ts +96 -0
  42. package/dist/tui.js +397 -0
  43. package/dist/tui.js.map +1 -0
  44. package/dist/tui_layout.d.ts +152 -0
  45. package/dist/tui_layout.js +554 -0
  46. package/dist/tui_layout.js.map +1 -0
  47. package/dist/tui_model.d.ts +149 -0
  48. package/dist/tui_model.js +666 -0
  49. package/dist/tui_model.js.map +1 -0
  50. package/package.json +18 -14
  51. package/.eslintrc.js +0 -24
  52. package/.idea/codeStyles/Project.xml +0 -364
  53. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  54. package/.idea/compiler.xml +0 -7
  55. package/.idea/encodings.xml +0 -6
  56. package/.idea/inspectionProfiles/Project_Default.xml +0 -12
  57. package/.idea/jsLibraryMappings.xml +0 -6
  58. package/.idea/modules.xml +0 -8
  59. package/.idea/prettier.xml +0 -8
  60. package/.idea/talented-args.iml +0 -11
  61. package/.idea/vcs.xml +0 -6
  62. package/.prettierrc.yaml +0 -4
  63. package/dist/definitions.d.ts +0 -70
  64. package/dist/definitions.js +0 -38
  65. package/dist/definitions.js.map +0 -1
  66. package/dist/main.d.ts +0 -33
  67. package/dist/main.js +0 -313
  68. package/dist/main.js.map +0 -1
  69. package/jest.config.js +0 -4
  70. package/tsconfig.json +0 -18
package/dist/tools.js CHANGED
@@ -1,163 +1,91 @@
1
1
  "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.deepSet = exports.deepMerge = exports.isPlainObject = exports.typedKeys = void 0;
13
- /**
14
- * Like Object.keys(), except preserves types
15
- */
16
- function typedKeys(target) {
17
- return Object.keys(target);
18
- }
19
- exports.typedKeys = typedKeys;
3
+ exports.isPlainObject = isPlainObject;
4
+ exports.fromKeys = fromKeys;
5
+ exports.getOrCreate = getOrCreate;
6
+ exports.createDeferred = createDeferred;
7
+ exports.quoteList = quoteList;
8
+ exports.isThenable = isThenable;
9
+ exports.describeThrown = describeThrown;
10
+ exports.padEnd = padEnd;
20
11
  // *********************************************************************************************************************
21
- function isObject(value) {
22
- var type = typeof value;
23
- return value != null && (type === 'object' || type === 'function');
24
- }
25
- function isObjectLike(value) {
26
- return value != null && typeof value == 'object';
27
- }
28
- var objectCtorString = Function.prototype.toString.call(Object);
12
+ const objectCtorString = Function.prototype.toString.call(Object);
29
13
  function isPlainObject(value) {
30
- if (!isObjectLike(value) || Object.prototype.toString.call(value) !== '[object Object]') {
14
+ if (value === null ||
15
+ typeof value !== 'object' ||
16
+ Object.prototype.toString.call(value) !== '[object Object]') {
31
17
  return false;
32
18
  }
33
- var proto = Object.getPrototypeOf(value);
19
+ const proto = Object.getPrototypeOf(value);
34
20
  if (proto === null) {
35
21
  return true;
36
22
  }
37
- var Ctor = Object.hasOwnProperty.call(proto, 'constructor') && proto.constructor;
23
+ const Ctor = typeof proto === 'object' &&
24
+ Object.prototype.hasOwnProperty.call(proto, 'constructor') &&
25
+ 'constructor' in proto &&
26
+ proto.constructor;
38
27
  return (typeof Ctor == 'function' &&
39
28
  Ctor instanceof Ctor &&
40
29
  Function.prototype.toString.call(Ctor) == objectCtorString);
41
30
  }
42
- exports.isPlainObject = isPlainObject;
43
31
  // *********************************************************************************************************************
44
- /**
45
- * Like lodash.merge(), except with a few custom properties.
46
- * - Do not add properties that don't already exist on target, if FORCE_CLEAN_MERGE is set on constructor
47
- * - Merge constructed objects which have static type deepMerge
48
- * - Arrays are not merged, new array overwrites the old one (unless MERGE_ARRAYS is set on constructor)
49
- * - Undefineds are ignored
50
- */
51
- function deepMerge(target) {
52
- var sources = [];
53
- for (var _i = 1; _i < arguments.length; _i++) {
54
- sources[_i - 1] = arguments[_i];
55
- }
56
- var forceCleanMerge = target.constructor && target.constructor[deepMerge.FORCE_CLEAN_MERGE];
57
- var mergeArrays = target.constructor && target.constructor[deepMerge.MERGE_ARRAYS];
58
- for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) {
59
- var source = sources_1[_a];
60
- if (Array.isArray(source)) {
61
- // We were given an array directly. Treat it as destructured argument
62
- deepMerge.apply(void 0, __spreadArray([target], source, false));
63
- continue;
64
- }
65
- if (!isObject(source)) {
66
- // We must have an object from here on
67
- continue;
68
- }
69
- for (var key in source) {
70
- if (!Object.prototype.hasOwnProperty.call(source, key)) {
71
- continue;
72
- }
73
- if (!(key in target) && forceCleanMerge) {
74
- // Skip this key, not found in target
75
- continue;
76
- }
77
- var sourceValue = source[key];
78
- if (sourceValue === undefined) {
79
- // Do not overwrite with undefineds
80
- continue;
81
- }
82
- var targetValue = target[key];
83
- if (targetValue && targetValue.constructor && targetValue.constructor.deepMerge) {
84
- // Perform customized deep merge
85
- target[key] = targetValue.constructor.deepMerge(targetValue, sourceValue);
86
- }
87
- else if (isPlainObject(targetValue) && isPlainObject(sourceValue)) {
88
- // Merge deeply as POJO-s
89
- target[key] = deepMerge({}, targetValue, sourceValue);
90
- }
91
- else if (mergeArrays && Array.isArray(targetValue) && Array.isArray(sourceValue)) {
92
- // Merge arrays
93
- target[key] = targetValue.concat(sourceValue);
94
- }
95
- else {
96
- // In all other cases, copy by reference
97
- target[key] = sourceValue;
98
- }
99
- }
32
+ /** Create an object with the supplied keys, using the callback to produce each value. */
33
+ function fromKeys(keys, create) {
34
+ const result = {};
35
+ for (const key of keys) {
36
+ result[key] = create(key);
100
37
  }
101
- return target;
38
+ // All keys have been assigned, although TypeScript cannot infer that from the loop.
39
+ return result;
102
40
  }
103
- exports.deepMerge = deepMerge;
104
- deepMerge.FORCE_CLEAN_MERGE = 'FORCE_CLEAN_MERGE';
105
- deepMerge.MERGE_ARRAYS = 'MERGE_ARRAYS';
106
- // *********************************************************************************************************************
107
- function pathToSegments(str) {
108
- var result = [];
109
- if (str.charCodeAt(0) === 46 /* . */) {
110
- result.push('');
41
+ /** Return a map's existing non-undefined value, or create and store one with the callback. */
42
+ function getOrCreate(map, key, create) {
43
+ const existing = map.get(key);
44
+ if (existing !== undefined) {
45
+ return existing;
111
46
  }
112
- str.replace(pathToSegments.rePropName, function (match, number, quote, subString) {
113
- result.push(quote ? subString.replace(pathToSegments.reEscapeChar, '$1') : number || match);
114
- return '';
47
+ const created = create();
48
+ map.set(key, created);
49
+ return created;
50
+ }
51
+ /** Create a promise with externally accessible `resolve` and `reject` functions. */
52
+ function createDeferred() {
53
+ let resolve = () => undefined;
54
+ let reject = () => undefined;
55
+ // The Promise constructor invokes its callback synchronously, assigning both functions before return.
56
+ const promise = new Promise((promiseResolve, promiseReject) => {
57
+ resolve = promiseResolve;
58
+ reject = promiseReject;
115
59
  });
116
- return result;
60
+ return { promise, resolve, reject };
117
61
  }
118
- pathToSegments.rePropName =
119
- /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
120
- pathToSegments.reEscapeChar = /\\(\\)?/g;
121
- /**
122
- * Set value at a deep path inside an object, creating the missing properties along the way.
123
- * Extracted from lodash.set().
124
- */
125
- function deepSet(object, path, value) {
126
- if (!isObject(object)) {
127
- return object;
62
+ /** Format a quoted list for a sentence: `"a", "b" and "c"`. */
63
+ function quoteList(items, conjunction = 'and') {
64
+ const quoted = items.map(item => `"${item}"`);
65
+ if (quoted.length <= 1) {
66
+ return quoted.join('');
128
67
  }
129
- var segments = pathToSegments(path);
130
- var index = -1;
131
- var length = segments.length;
132
- var lastIndex = length - 1;
133
- var nested = object;
134
- while (nested != null && ++index < length) {
135
- var key = String(segments[index]);
136
- if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
137
- return object;
138
- }
139
- if (index === lastIndex) {
140
- nested[key] = value;
141
- }
142
- else {
143
- var objValue = nested[key];
144
- var newValue = isObject(objValue)
145
- ? objValue
146
- : deepSet.isIndex(segments[index + 1])
147
- ? []
148
- : {};
149
- nested[key] = newValue;
150
- }
151
- nested = nested[key];
68
+ return `${quoted.slice(0, -1).join(', ')} ${conjunction} ${quoted[quoted.length - 1]}`;
69
+ }
70
+ function isThenable(value) {
71
+ return (typeof value === 'object' &&
72
+ value !== null &&
73
+ 'then' in value &&
74
+ typeof value.then === 'function');
75
+ }
76
+ /** Extract a string message from a thrown value, or convert the value to a string. */
77
+ function describeThrown(thrown) {
78
+ // Read message structurally because errors from another realm can fail instanceof Error.
79
+ if (typeof thrown === 'object' &&
80
+ thrown !== null &&
81
+ 'message' in thrown &&
82
+ typeof thrown.message === 'string') {
83
+ return thrown.message;
152
84
  }
153
- return object;
85
+ return String(thrown);
86
+ }
87
+ /** Pad text on the right with spaces to the specified terminal cell width. */
88
+ function padEnd(text, width, tools) {
89
+ return text + ' '.repeat(Math.max(0, width - tools.width(text)));
154
90
  }
155
- exports.deepSet = deepSet;
156
- deepSet.isIndex = function (value) {
157
- var type = typeof value;
158
- return ((type == 'number' || (type != 'symbol' && /^(?:0|[1-9]\d*)$/.test(value))) &&
159
- value > -1 &&
160
- value % 1 == 0 &&
161
- value < 9007199254740991);
162
- };
163
91
  //# sourceMappingURL=tools.js.map
package/dist/tools.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA;;GAEG;AACH,SAAgB,SAAS,CAAsB,MAAS;IACtD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAyB,CAAC;AACrD,CAAC;AAFD,8BAEC;AAiCD,wHAAwH;AAExH,SAAS,QAAQ,CAAC,KAAK;IACrB,IAAM,IAAI,GAAG,OAAO,KAAK,CAAC;IAC1B,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,UAAU,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,YAAY,CAAC,KAAK;IACzB,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,IAAI,QAAQ,CAAC;AACnD,CAAC;AAED,IAAM,gBAAgB,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,I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,UAAU,CACjC,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,SAAgB,cAAc,CAAC,MAAe;IAC5C,yFAAyF;IACzF,IACE,OAAO,MAAM,KAAK,QAAQ;QAC1B,MAAM,KAAK,IAAI;QACf,SAAS,IAAI,MAAM;QACnB,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,EAClC,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC;AAmBD,8EAA8E;AAC9E,SAAgB,MAAM,CAAC,IAAY,EAAE,KAAa,EAAE,KAAiB;IACnE,OAAO,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC"}
package/dist/tui.d.ts ADDED
@@ -0,0 +1,96 @@
1
+ import { ICompiledSchema } from './compile';
2
+ import { IAppInfo } from './options';
3
+ import { IBinding } from './parse';
4
+ import { IRemembered } from './remember';
5
+ import { IResolvedStyles } from './styling';
6
+ import { IDocument, ITerminalInput, ITerminalOutput, ITerminalSession } from './terminal';
7
+ import { ITuiOutcome, TuiModel } from './tui_model';
8
+ /**
9
+ * Terminal implementation of the interactive editor.
10
+ * Create and position terminal-kit widgets, and route unhandled keys to the model.
11
+ */
12
+ export interface ITuiOptions {
13
+ readonly schema: ICompiledSchema;
14
+ /** Command line binding used to prefill fields. */
15
+ readonly seed: IBinding;
16
+ /** An explicit command line selection starts the editor in its fields panel. */
17
+ readonly commandChosen: boolean;
18
+ /** Saved or initial interactive values. `null` when remembering is disabled or no state was loaded. */
19
+ readonly remembered: IRemembered | null;
20
+ readonly appInfo: IAppInfo;
21
+ readonly executable: string;
22
+ readonly styles: IResolvedStyles;
23
+ readonly stdin: ITerminalInput;
24
+ readonly stdout: ITerminalOutput;
25
+ readonly env: NodeJS.ProcessEnv;
26
+ }
27
+ /** Whether the configured locale indicates UTF-8 support for Unicode glyphs. */
28
+ export declare function supportsUnicode(env: NodeJS.ProcessEnv): boolean;
29
+ export declare class TuiScreen {
30
+ private readonly options;
31
+ private readonly session;
32
+ readonly model: TuiModel;
33
+ private readonly terminal;
34
+ private readonly kit;
35
+ private readonly document;
36
+ private readonly theme;
37
+ private readonly glyphs;
38
+ private readonly text;
39
+ private readonly scroll;
40
+ private elements;
41
+ private focusedBox;
42
+ private previewElement;
43
+ private messageElement;
44
+ private messageSignElement;
45
+ private hintElements;
46
+ private hintSignElements;
47
+ private renderPending;
48
+ private keyQueue;
49
+ private closed;
50
+ private restored;
51
+ private readonly cleanups;
52
+ private readonly result;
53
+ constructor(options: ITuiOptions, session: ITerminalSession);
54
+ /**
55
+ * Resolve with a run, copy, or cancel outcome after restoring the terminal.
56
+ * Reject on failure after terminal cleanup.
57
+ */
58
+ finished(): Promise<ITuiOutcome>;
59
+ /** Current rendered screen buffer, used by tests to inspect text and attributes. */
60
+ get screen(): IDocument['inputDst'];
61
+ /**
62
+ * Restore the terminal before process exit or signal termination,
63
+ * including input mode, cursor visibility, and the original screen.
64
+ */
65
+ private guardProcess;
66
+ private restoreTerminal;
67
+ private close;
68
+ private tearDown;
69
+ /**
70
+ * Run an event handler with cleanup on failure.
71
+ * Restore the terminal and reject the result if the handler throws.
72
+ */
73
+ private guarded;
74
+ /**
75
+ * Deliver queued keys until a redraw is required.
76
+ * Focus changes take effect when widgets are rebuilt, so subsequent typed or pasted keys
77
+ * must wait for that render before reaching the next field.
78
+ */
79
+ private drainKeys;
80
+ /** Handle a key not consumed by the focused widget. */
81
+ private onKey;
82
+ private scheduleRender;
83
+ private clearElements;
84
+ /** Rebuild widgets from the current model and draw the document. */
85
+ private render;
86
+ /** Show the cursor in the focused text field; hide it when no text field is focused. */
87
+ private placeCursor;
88
+ /**
89
+ * Update dependent text after a field widget edits and redraws itself.
90
+ * Avoid rebuilding the focused widget while it is handling text input.
91
+ */
92
+ private onTextChange;
93
+ private applyTextChange;
94
+ }
95
+ /** Open the interactive editor on the supplied streams and wait for a run, copy, or cancel outcome. */
96
+ export declare function runTui(options: ITuiOptions): Promise<ITuiOutcome>;