@hyperfrontend/questions 0.2.0 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -2,7 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## [0.2.0](https://github.com/AndrewRedican/hyperfrontend/compare/587d0dc108d5bb7f48c44a5a0065e349c774e4cf...67a22dd91c9e232145571c0070ed048d1965ae69) - 2026-04-25
5
+ ## [0.2.1](https://github.com/AndrewRedican/hyperfrontend/compare/926d40cab470e589fc30a1ef3a61ca764ff047bd...466c0388c4cd516b9c704214140b4df1004098e6) - 2026-06-23
6
+
7
+ ### Other
8
+
9
+ - **@hyperfrontend/workspace:** remove lib-builder and tool-package as implicit dependencies for all lib projects
10
+
11
+ ## [0.2.0](https://github.com/AndrewRedican/hyperfrontend/compare/587d0dc108d5bb7f48c44a5a0065e349c774e4cf...b5f254d41cb9549c783146db48eff78ed39e5bf5) - 2026-04-25
6
12
 
7
13
  ### Features
8
14
 
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const _Math = globalThis.Math;
4
+ const max = _Math.max;
5
+ const min = _Math.min;
6
+ exports.max = max;
7
+ exports.min = min;
@@ -0,0 +1,5 @@
1
+ const _Math = globalThis.Math;
2
+ const max = _Math.max;
3
+ const min = _Math.min;
4
+
5
+ export { max, min };
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const _Object = globalThis.Object;
4
+ const freeze = _Object.freeze;
5
+ exports.freeze = freeze;
@@ -0,0 +1,4 @@
1
+ const _Object = globalThis.Object;
2
+ const freeze = _Object.freeze;
3
+
4
+ export { freeze };
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ const _Promise = globalThis.Promise;
4
+ const _Reflect = globalThis.Reflect;
5
+ const createPromise = (executor) => _Reflect.construct(_Promise, [executor]);
6
+ exports.createPromise = createPromise;
@@ -0,0 +1,5 @@
1
+ const _Promise = globalThis.Promise;
2
+ const _Reflect = globalThis.Reflect;
3
+ const createPromise = (executor) => _Reflect.construct(_Promise, [executor]);
4
+
5
+ export { createPromise };
package/index.cjs.js CHANGED
@@ -1,68 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var node_readline = require('node:readline');
4
-
5
- /**
6
- * Safe copies of Object built-in methods.
7
- *
8
- * These references are captured at module initialization time to protect against
9
- * prototype pollution attacks. Import only what you need for tree-shaking.
10
- *
11
- * @module @hyperfrontend/immutable-api-utils/built-in-copy/object
12
- */
13
- const _Object = globalThis.Object;
14
- /**
15
- * (Safe copy) Prevents modification of existing property attributes and values,
16
- * and prevents the addition of new properties.
17
- */
18
- const freeze = _Object.freeze;
19
-
20
- /**
21
- * Safe Promise factory and bound static methods.
22
- *
23
- * @module @hyperfrontend/immutable-api-utils/built-in-copy/promise
24
- */
25
- /* eslint-disable workspace/lib-require-jsdoc-example */
26
- const _Promise = globalThis.Promise;
27
- const _Reflect = globalThis.Reflect;
28
- /**
29
- * (Safe copy) Creates a new Promise using the captured Promise constructor.
30
- * Use this instead of `new Promise()`.
31
- *
32
- * @param executor - The executor function.
33
- * @returns A new Promise instance.
34
- */
35
- const createPromise = (executor) => _Reflect.construct(_Promise, [executor]);
36
- /**
37
- * (Safe copy) Returns a Promise that resolves with the given value.
38
- */
39
- _Promise.resolve.bind(_Promise);
40
- /**
41
- * (Safe copy) Returns a Promise that rejects with the given reason.
42
- */
43
- _Promise.reject.bind(_Promise);
44
- /**
45
- * (Safe copy) Returns a Promise that resolves when all promises resolve.
46
- */
47
- _Promise.all.bind(_Promise);
48
- /**
49
- * (Safe copy) Returns a Promise that resolves/rejects with the first settled promise.
50
- */
51
- _Promise.race.bind(_Promise);
52
- /**
53
- * (Safe copy) Returns a Promise that resolves when all promises settle.
54
- */
55
- _Promise.allSettled.bind(_Promise);
56
- /**
57
- * (Safe copy) Returns a Promise that resolves with the first fulfilled promise.
58
- */
59
- _Promise.any.bind(_Promise);
60
- /**
61
- * (Safe copy) Creates a Promise along with its resolve and reject functions.
62
- * Note: Available only in ES2024+ environments.
63
- */
64
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
- _Promise.withResolvers?.bind(_Promise);
3
+ const index_cjs_js = require('./_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/object/index.cjs.js');
4
+ const node_readline = require('node:readline');
5
+ const index_cjs_js$1 = require('./_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/promise/index.cjs.js');
6
+ const index_cjs_js$2 = require('./_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/math/index.cjs.js');
66
7
 
67
8
  /**
68
9
  * Terminal I/O utilities using Node.js readline.
@@ -72,7 +13,7 @@ _Promise.withResolvers?.bind(_Promise);
72
13
  /**
73
14
  * Key codes for terminal navigation.
74
15
  */
75
- const Key = freeze({
16
+ const Key = index_cjs_js.freeze({
76
17
  Up: '\x1B[A',
77
18
  Down: '\x1B[B',
78
19
  Left: '\x1B[D',
@@ -88,7 +29,7 @@ const Key = freeze({
88
29
  /**
89
30
  * ANSI escape codes for terminal styling.
90
31
  */
91
- const Ansi = freeze({
32
+ const Ansi = index_cjs_js.freeze({
92
33
  /** Clear entire line */
93
34
  ClearLine: '\x1B[2K',
94
35
  /** Move cursor to start of line */
@@ -169,7 +110,7 @@ function createTerminal(config = {}) {
169
110
  const write = (text) => {
170
111
  output.write(text);
171
112
  };
172
- const readKey = () => createPromise((resolve) => {
113
+ const readKey = () => index_cjs_js$1.createPromise((resolve) => {
173
114
  const wasRaw = input.isRaw;
174
115
  if (input.setRawMode) {
175
116
  input.setRawMode(true);
@@ -187,7 +128,7 @@ function createTerminal(config = {}) {
187
128
  };
188
129
  input.once('data', onData);
189
130
  });
190
- const readLine = () => createPromise((resolve) => {
131
+ const readLine = () => index_cjs_js$1.createPromise((resolve) => {
191
132
  const readline = getReadline();
192
133
  readline.once('line', (line) => {
193
134
  resolve(line);
@@ -214,7 +155,7 @@ function createTerminal(config = {}) {
214
155
  }
215
156
  write(Ansi.ShowCursor);
216
157
  };
217
- return freeze({
158
+ return index_cjs_js.freeze({
218
159
  write,
219
160
  readKey,
220
161
  readLine,
@@ -235,7 +176,7 @@ function createTerminal(config = {}) {
235
176
  /**
236
177
  * Unicode symbols for prompt rendering.
237
178
  */
238
- const Symbol = freeze({
179
+ const Symbol = index_cjs_js.freeze({
239
180
  Pointer: '❯',
240
181
  Radio: '◯',
241
182
  RadioSelected: '◉',
@@ -249,7 +190,7 @@ const Symbol = freeze({
249
190
  /**
250
191
  * Style functions for ANSI text formatting.
251
192
  */
252
- const style = freeze({
193
+ const style = index_cjs_js.freeze({
253
194
  /**
254
195
  * Applies bold styling to text.
255
196
  *
@@ -353,7 +294,7 @@ function renderCancelled() {
353
294
  /**
354
295
  * Result state of a prompt interaction.
355
296
  */
356
- const PromptResult = freeze({
297
+ const PromptResult = index_cjs_js.freeze({
357
298
  /** User submitted a value */
358
299
  Submitted: 'submitted',
359
300
  /** User cancelled the prompt (Ctrl+C) */
@@ -419,22 +360,22 @@ async function confirm(config) {
419
360
  term.write(Ansi.CursorStart + Ansi.ClearLine);
420
361
  term.write(renderMessage(config.message) + renderCancelled() + '\n');
421
362
  term.close();
422
- return freeze({ result: PromptResult.Cancelled, value: undefined });
363
+ return index_cjs_js.freeze({ result: PromptResult.Cancelled, value: undefined });
423
364
  }
424
365
  if (lowerKey === 'y') {
425
366
  drawResult(true);
426
367
  term.close();
427
- return freeze({ result: PromptResult.Submitted, value: true });
368
+ return index_cjs_js.freeze({ result: PromptResult.Submitted, value: true });
428
369
  }
429
370
  if (lowerKey === 'n') {
430
371
  drawResult(false);
431
372
  term.close();
432
- return freeze({ result: PromptResult.Submitted, value: false });
373
+ return index_cjs_js.freeze({ result: PromptResult.Submitted, value: false });
433
374
  }
434
375
  if (key === Key.Enter && config.initial !== undefined) {
435
376
  drawResult(config.initial);
436
377
  term.close();
437
- return freeze({ result: PromptResult.Submitted, value: config.initial });
378
+ return index_cjs_js.freeze({ result: PromptResult.Submitted, value: config.initial });
438
379
  }
439
380
  }
440
381
  }
@@ -473,7 +414,7 @@ function filterChoices$1(choices, query) {
473
414
  indices.push(i);
474
415
  }
475
416
  });
476
- return freeze(indices);
417
+ return index_cjs_js.freeze(indices);
477
418
  }
478
419
  /**
479
420
  * Creates initial state for multiselect prompt.
@@ -483,7 +424,7 @@ function filterChoices$1(choices, query) {
483
424
  * @returns Initial multiselect state
484
425
  */
485
426
  function createInitialState$2(config) {
486
- return freeze({
427
+ return index_cjs_js.freeze({
487
428
  cursor: 0,
488
429
  selected: config.initial ? [...config.initial] : [],
489
430
  choices: config.choices,
@@ -635,7 +576,7 @@ function processKey$2(key, state, config) {
635
576
  if (newCursor < state.scrollOffset) {
636
577
  newScrollOffset = newCursor;
637
578
  }
638
- return freeze({ ...state, cursor: newCursor, scrollOffset: newScrollOffset });
579
+ return index_cjs_js.freeze({ ...state, cursor: newCursor, scrollOffset: newScrollOffset });
639
580
  }
640
581
  if (key === Key.Down) {
641
582
  let newCursor = state.cursor + 1;
@@ -648,7 +589,7 @@ function processKey$2(key, state, config) {
648
589
  if (newCursor >= state.scrollOffset + maxVisible) {
649
590
  newScrollOffset = newCursor - maxVisible + 1;
650
591
  }
651
- return freeze({ ...state, cursor: newCursor, scrollOffset: newScrollOffset });
592
+ return index_cjs_js.freeze({ ...state, cursor: newCursor, scrollOffset: newScrollOffset });
652
593
  }
653
594
  if (key === Key.Space) {
654
595
  const actualIndex = state.filteredIndices[state.cursor];
@@ -661,14 +602,14 @@ function processKey$2(key, state, config) {
661
602
  const isSelected = arrayIncludes(state.selected, actualIndex);
662
603
  if (isSelected) {
663
604
  const newSelected = state.selected.filter((i) => i !== actualIndex);
664
- return freeze({ ...state, selected: newSelected });
605
+ return index_cjs_js.freeze({ ...state, selected: newSelected });
665
606
  }
666
607
  else {
667
608
  if (config.max !== undefined && state.selected.length >= config.max) {
668
609
  return state;
669
610
  }
670
611
  const newSelected = [...state.selected, actualIndex];
671
- return freeze({ ...state, selected: newSelected });
612
+ return index_cjs_js.freeze({ ...state, selected: newSelected });
672
613
  }
673
614
  }
674
615
  if (config.searchable) {
@@ -676,7 +617,7 @@ function processKey$2(key, state, config) {
676
617
  if (state.searchQuery.length > 0) {
677
618
  const newQuery = state.searchQuery.slice(0, -1);
678
619
  const newFiltered = filterChoices$1(state.choices, newQuery);
679
- return freeze({
620
+ return index_cjs_js.freeze({
680
621
  ...state,
681
622
  searchQuery: newQuery,
682
623
  filteredIndices: newFiltered,
@@ -689,7 +630,7 @@ function processKey$2(key, state, config) {
689
630
  if (key.length === 1 && key >= ' ' && key !== Key.Space) {
690
631
  const newQuery = state.searchQuery + key;
691
632
  const newFiltered = filterChoices$1(state.choices, newQuery);
692
- return freeze({
633
+ return index_cjs_js.freeze({
693
634
  ...state,
694
635
  searchQuery: newQuery,
695
636
  filteredIndices: newFiltered,
@@ -789,7 +730,7 @@ async function multiselect(config) {
789
730
  term.write(renderMessage(config.message) + renderCancelled() + '\n');
790
731
  term.write(Ansi.ShowCursor);
791
732
  term.close();
792
- return freeze({ result: PromptResult.Cancelled, value: undefined });
733
+ return index_cjs_js.freeze({ result: PromptResult.Cancelled, value: undefined });
793
734
  }
794
735
  if (key === Key.Enter) {
795
736
  const validationError = validateSelection(state, config);
@@ -807,7 +748,7 @@ async function multiselect(config) {
807
748
  term.write('\n');
808
749
  term.write(Ansi.ShowCursor);
809
750
  term.close();
810
- return freeze({ result: PromptResult.Submitted, value: freeze(selectedValues) });
751
+ return index_cjs_js.freeze({ result: PromptResult.Submitted, value: index_cjs_js.freeze(selectedValues) });
811
752
  }
812
753
  errorMessage = undefined;
813
754
  state = processKey$2(key, state, config);
@@ -834,7 +775,7 @@ function filterChoices(choices, query) {
834
775
  indices.push(i);
835
776
  }
836
777
  });
837
- return freeze(indices);
778
+ return index_cjs_js.freeze(indices);
838
779
  }
839
780
  /**
840
781
  * Creates initial state for select prompt.
@@ -844,7 +785,7 @@ function filterChoices(choices, query) {
844
785
  * @returns Initial select state
845
786
  */
846
787
  function createInitialState$1(config) {
847
- return freeze({
788
+ return index_cjs_js.freeze({
848
789
  cursor: config.initial ?? 0,
849
790
  choices: config.choices,
850
791
  filteredIndices: config.choices.map((_, i) => i),
@@ -983,7 +924,7 @@ function processKey$1(key, state, config) {
983
924
  if (newCursor < state.scrollOffset) {
984
925
  newScrollOffset = newCursor;
985
926
  }
986
- return freeze({ ...state, cursor: newCursor, scrollOffset: newScrollOffset });
927
+ return index_cjs_js.freeze({ ...state, cursor: newCursor, scrollOffset: newScrollOffset });
987
928
  }
988
929
  if (key === Key.Down) {
989
930
  let newCursor = state.cursor + 1;
@@ -996,14 +937,14 @@ function processKey$1(key, state, config) {
996
937
  if (newCursor >= state.scrollOffset + maxVisible) {
997
938
  newScrollOffset = newCursor - maxVisible + 1;
998
939
  }
999
- return freeze({ ...state, cursor: newCursor, scrollOffset: newScrollOffset });
940
+ return index_cjs_js.freeze({ ...state, cursor: newCursor, scrollOffset: newScrollOffset });
1000
941
  }
1001
942
  if (config.searchable) {
1002
943
  if (key === Key.Backspace || key === '\b') {
1003
944
  if (state.searchQuery.length > 0) {
1004
945
  const newQuery = state.searchQuery.slice(0, -1);
1005
946
  const newFiltered = filterChoices(state.choices, newQuery);
1006
- return freeze({
947
+ return index_cjs_js.freeze({
1007
948
  ...state,
1008
949
  searchQuery: newQuery,
1009
950
  filteredIndices: newFiltered,
@@ -1016,7 +957,7 @@ function processKey$1(key, state, config) {
1016
957
  if (key.length === 1 && key >= ' ') {
1017
958
  const newQuery = state.searchQuery + key;
1018
959
  const newFiltered = filterChoices(state.choices, newQuery);
1019
- return freeze({
960
+ return index_cjs_js.freeze({
1020
961
  ...state,
1021
962
  searchQuery: newQuery,
1022
963
  filteredIndices: newFiltered,
@@ -1096,7 +1037,7 @@ async function select(config) {
1096
1037
  term.write(renderMessage(config.message) + renderCancelled() + '\n');
1097
1038
  term.write(Ansi.ShowCursor);
1098
1039
  term.close();
1099
- return freeze({ result: PromptResult.Cancelled, value: undefined });
1040
+ return index_cjs_js.freeze({ result: PromptResult.Cancelled, value: undefined });
1100
1041
  }
1101
1042
  if (key === Key.Enter) {
1102
1043
  const actualIndex = state.filteredIndices[state.cursor];
@@ -1115,31 +1056,13 @@ async function select(config) {
1115
1056
  term.write('\n');
1116
1057
  term.write(Ansi.ShowCursor);
1117
1058
  term.close();
1118
- return freeze({ result: PromptResult.Submitted, value: selectedChoice.value });
1059
+ return index_cjs_js.freeze({ result: PromptResult.Submitted, value: selectedChoice.value });
1119
1060
  }
1120
1061
  state = processKey$1(key, state, config);
1121
1062
  redraw();
1122
1063
  }
1123
1064
  }
1124
1065
 
1125
- /**
1126
- * Safe copies of Math built-in methods.
1127
- *
1128
- * These references are captured at module initialization time to protect against
1129
- * prototype pollution attacks. Import only what you need for tree-shaking.
1130
- *
1131
- * @module @hyperfrontend/immutable-api-utils/built-in-copy/math
1132
- */
1133
- const _Math = globalThis.Math;
1134
- /**
1135
- * (Safe copy) Returns the larger of zero or more numbers.
1136
- */
1137
- const max = _Math.max;
1138
- /**
1139
- * (Safe copy) Returns the smaller of zero or more numbers.
1140
- */
1141
- const min = _Math.min;
1142
-
1143
1066
  /**
1144
1067
  * Creates initial state for text prompt.
1145
1068
  *
@@ -1224,13 +1147,13 @@ function processKey(key, state) {
1224
1147
  if (key === Key.Left) {
1225
1148
  return {
1226
1149
  ...state,
1227
- cursorPos: max(0, state.cursorPos - 1),
1150
+ cursorPos: index_cjs_js$2.max(0, state.cursorPos - 1),
1228
1151
  };
1229
1152
  }
1230
1153
  if (key === Key.Right) {
1231
1154
  return {
1232
1155
  ...state,
1233
- cursorPos: min(state.value.length, state.cursorPos + 1),
1156
+ cursorPos: index_cjs_js$2.min(state.value.length, state.cursorPos + 1),
1234
1157
  };
1235
1158
  }
1236
1159
  return state;
@@ -1288,7 +1211,7 @@ async function text(config) {
1288
1211
  redraw();
1289
1212
  term.write(renderCancelled() + '\n');
1290
1213
  term.close();
1291
- return freeze({ result: PromptResult.Cancelled, value: undefined });
1214
+ return index_cjs_js.freeze({ result: PromptResult.Cancelled, value: undefined });
1292
1215
  }
1293
1216
  if (key === Key.Enter) {
1294
1217
  const value = state.value || config.initial || '';
@@ -1303,7 +1226,7 @@ async function text(config) {
1303
1226
  redraw(true);
1304
1227
  term.write('\n');
1305
1228
  term.close();
1306
- return freeze({ result: PromptResult.Submitted, value });
1229
+ return index_cjs_js.freeze({ result: PromptResult.Submitted, value });
1307
1230
  }
1308
1231
  state = processKey(key, state);
1309
1232
  redraw();
@@ -1316,4 +1239,3 @@ exports.multiselect = multiselect;
1316
1239
  exports.select = select;
1317
1240
  exports.style = style;
1318
1241
  exports.text = text;
1319
- //# sourceMappingURL=index.cjs.js.map