keycloakify 11.8.18 → 11.8.19

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/bin/453.index.js CHANGED
@@ -38,7 +38,7 @@ __webpack_require__.r(__webpack_exports__);
38
38
 
39
39
  async function command(params) {
40
40
  const { buildContext } = params;
41
- const { hasBeenHandled } = (0,_shared_customHandler_delegate__WEBPACK_IMPORTED_MODULE_7__/* .maybeDelegateCommandToCustomHandler */ .q)({
41
+ const { hasBeenHandled } = await (0,_shared_customHandler_delegate__WEBPACK_IMPORTED_MODULE_7__/* .maybeDelegateCommandToCustomHandler */ .q)({
42
42
  commandName: "eject-page",
43
43
  buildContext
44
44
  });
@@ -233,838 +233,6 @@ async function command(params) {
233
233
  }
234
234
  //# sourceMappingURL=eject-page.js.map
235
235
 
236
- /***/ }),
237
-
238
- /***/ 72138:
239
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
240
-
241
-
242
- // EXPORTS
243
- __webpack_require__.d(__webpack_exports__, {
244
- "q": () => (/* binding */ maybeDelegateCommandToCustomHandler)
245
- });
246
-
247
- // EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
248
- var esm_assert = __webpack_require__(29041);
249
- // EXTERNAL MODULE: ./dist/bin/shared/constants.js
250
- var constants = __webpack_require__(173);
251
- ;// CONCATENATED MODULE: ./dist/bin/shared/customHandler.js
252
-
253
-
254
- const BIN_NAME = "_keycloakify-custom-handler";
255
- const NOT_IMPLEMENTED_EXIT_CODE = 78;
256
- function readParams(params) {
257
- const { apiVersion } = params;
258
- assert(apiVersion === "v1");
259
- const commandName = (() => {
260
- const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME];
261
- assert(envValue !== undefined);
262
- return envValue;
263
- })();
264
- const buildContext = (() => {
265
- const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT];
266
- assert(envValue !== undefined);
267
- return JSON.parse(envValue);
268
- })();
269
- return { commandName, buildContext };
270
- }
271
- //# sourceMappingURL=customHandler.js.map
272
- // EXTERNAL MODULE: external "child_process"
273
- var external_child_process_ = __webpack_require__(32081);
274
- // EXTERNAL MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js
275
- var tools_nodeModulesBinDirPath = __webpack_require__(73776);
276
- // EXTERNAL MODULE: external "fs"
277
- var external_fs_ = __webpack_require__(57147);
278
- ;// CONCATENATED MODULE: ./dist/bin/shared/customHandler_delegate.js
279
-
280
-
281
-
282
-
283
-
284
-
285
- (0,esm_assert/* assert */.h)();
286
- function maybeDelegateCommandToCustomHandler(params) {
287
- const { commandName, buildContext } = params;
288
- const nodeModulesBinDirPath = (0,tools_nodeModulesBinDirPath/* getNodeModulesBinDirPath */.K)();
289
- if (!external_fs_.readdirSync(nodeModulesBinDirPath).includes(BIN_NAME)) {
290
- return { hasBeenHandled: false };
291
- }
292
- try {
293
- external_child_process_.execSync(`npx ${BIN_NAME}`, {
294
- stdio: "inherit",
295
- env: Object.assign(Object.assign({}, process.env), { [constants/* CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME */._S.COMMAND_NAME]: commandName, [constants/* CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT */._S.BUILD_CONTEXT]: JSON.stringify(buildContext) })
296
- });
297
- }
298
- catch (error) {
299
- const status = error.status;
300
- if (status === NOT_IMPLEMENTED_EXIT_CODE) {
301
- return { hasBeenHandled: false };
302
- }
303
- process.exit(status);
304
- }
305
- return { hasBeenHandled: true };
306
- }
307
- //# sourceMappingURL=customHandler_delegate.js.map
308
-
309
- /***/ }),
310
-
311
- /***/ 17192:
312
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
313
-
314
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
315
- /* harmony export */ "A": () => (/* binding */ kebabCaseToCamelCase)
316
- /* harmony export */ });
317
- /* harmony import */ var tsafe_capitalize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14899);
318
-
319
- function kebabCaseToCamelCase(kebabCaseString) {
320
- const [first, ...rest] = kebabCaseString.split("-");
321
- return [first, ...rest.map(tsafe_capitalize__WEBPACK_IMPORTED_MODULE_0__/* .capitalize */ .k)].join("");
322
- }
323
- //# sourceMappingURL=kebabCaseToSnakeCase.js.map
324
-
325
- /***/ }),
326
-
327
- /***/ 73776:
328
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
329
-
330
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
331
- /* harmony export */ "K": () => (/* binding */ getNodeModulesBinDirPath)
332
- /* harmony export */ });
333
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71017);
334
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
335
-
336
- let cache = undefined;
337
- function getNodeModulesBinDirPath() {
338
- if (cache !== undefined) {
339
- return cache;
340
- }
341
- const binPath = process.argv[1];
342
- const segments = [".bin"];
343
- let foundNodeModules = false;
344
- for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
345
- skip_segment: {
346
- if (foundNodeModules) {
347
- break skip_segment;
348
- }
349
- if (segment === "node_modules") {
350
- foundNodeModules = true;
351
- break skip_segment;
352
- }
353
- continue;
354
- }
355
- segments.unshift(segment);
356
- }
357
- const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
358
- cache = nodeModulesBinDirPath;
359
- return nodeModulesBinDirPath;
360
- }
361
- //# sourceMappingURL=nodeModulesBinDirPath.js.map
362
-
363
- /***/ }),
364
-
365
- /***/ 48433:
366
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
367
-
368
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
369
- /* harmony export */ "LG": () => (/* binding */ getPrettier),
370
- /* harmony export */ "MT": () => (/* binding */ getIsPrettierAvailable),
371
- /* harmony export */ "eY": () => (/* binding */ runPrettier)
372
- /* harmony export */ });
373
- /* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73776);
374
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
375
- /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
376
- /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
377
- /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
378
- /* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
379
- /* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
380
- /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(78818);
381
- /* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_4__);
382
- /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6113);
383
- /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_5__);
384
- /* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(76030);
385
- /* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(64795);
386
-
387
-
388
-
389
-
390
-
391
-
392
-
393
-
394
-
395
- getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
396
- async function getIsPrettierAvailable() {
397
- var _a;
398
- if (getIsPrettierAvailable.cache !== undefined) {
399
- return getIsPrettierAvailable.cache;
400
- }
401
- const nodeModulesBinDirPath = (0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)();
402
- const prettierBinPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(nodeModulesBinDirPath, "prettier");
403
- const stats = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.stat(prettierBinPath).catch(() => undefined);
404
- const isPrettierAvailable = (_a = stats === null || stats === void 0 ? void 0 : stats.isFile()) !== null && _a !== void 0 ? _a : false;
405
- getIsPrettierAvailable.cache = isPrettierAvailable;
406
- return isPrettierAvailable;
407
- }
408
- getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
409
- async function getPrettier() {
410
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(getIsPrettierAvailable());
411
- if (getPrettier.cache !== undefined) {
412
- return getPrettier.cache;
413
- }
414
- let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
415
- import_prettier: {
416
- // NOTE: When module is linked we want to make sure we import the correct version
417
- // of prettier, that is the one of the project, not the one of this repo.
418
- // So we do a sketchy eval to bypass ncc.
419
- // We make sure to only do that when linking, otherwise we import properly.
420
- if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__/* .readThisNpmPackageVersion */ .K)().startsWith("0.0.0")) {
421
- eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .r)({ prettier })} = require("${(0,path__WEBPACK_IMPORTED_MODULE_1__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), "..", "prettier"))}")`);
422
- (0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__.is)(prettier));
423
- break import_prettier;
424
- }
425
- prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
426
- }
427
- const configHash = await (async () => {
428
- const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)(), ".."));
429
- if (configFilePath === null) {
430
- return "";
431
- }
432
- const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
433
- return crypto__WEBPACK_IMPORTED_MODULE_5__.createHash("sha256").update(data).digest("hex");
434
- })();
435
- const prettierAndConfig = {
436
- prettier,
437
- configHash
438
- };
439
- getPrettier.cache = prettierAndConfig;
440
- return prettierAndConfig;
441
- }
442
- async function runPrettier(params) {
443
- const { sourceCode, filePath } = params;
444
- let formattedSourceCode;
445
- try {
446
- const { prettier } = await getPrettier();
447
- const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
448
- resolveConfig: true
449
- });
450
- if (ignored || inferredParser === null) {
451
- return sourceCode;
452
- }
453
- const config = await prettier.resolveConfig(filePath);
454
- formattedSourceCode = await prettier.format(sourceCode, Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
455
- }
456
- catch (error) {
457
- console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
458
- throw error;
459
- }
460
- return formattedSourceCode;
461
- }
462
- //# sourceMappingURL=runPrettier.js.map
463
-
464
- /***/ }),
465
-
466
- /***/ 18512:
467
- /***/ ((module) => {
468
-
469
-
470
- const x = module.exports;
471
- const ESC = '\u001B[';
472
- const OSC = '\u001B]';
473
- const BEL = '\u0007';
474
- const SEP = ';';
475
- const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
476
-
477
- x.cursorTo = (x, y) => {
478
- if (typeof x !== 'number') {
479
- throw new TypeError('The `x` argument is required');
480
- }
481
-
482
- if (typeof y !== 'number') {
483
- return ESC + (x + 1) + 'G';
484
- }
485
-
486
- return ESC + (y + 1) + ';' + (x + 1) + 'H';
487
- };
488
-
489
- x.cursorMove = (x, y) => {
490
- if (typeof x !== 'number') {
491
- throw new TypeError('The `x` argument is required');
492
- }
493
-
494
- let ret = '';
495
-
496
- if (x < 0) {
497
- ret += ESC + (-x) + 'D';
498
- } else if (x > 0) {
499
- ret += ESC + x + 'C';
500
- }
501
-
502
- if (y < 0) {
503
- ret += ESC + (-y) + 'A';
504
- } else if (y > 0) {
505
- ret += ESC + y + 'B';
506
- }
507
-
508
- return ret;
509
- };
510
-
511
- x.cursorUp = count => ESC + (typeof count === 'number' ? count : 1) + 'A';
512
- x.cursorDown = count => ESC + (typeof count === 'number' ? count : 1) + 'B';
513
- x.cursorForward = count => ESC + (typeof count === 'number' ? count : 1) + 'C';
514
- x.cursorBackward = count => ESC + (typeof count === 'number' ? count : 1) + 'D';
515
-
516
- x.cursorLeft = ESC + 'G';
517
- x.cursorSavePosition = ESC + (isTerminalApp ? '7' : 's');
518
- x.cursorRestorePosition = ESC + (isTerminalApp ? '8' : 'u');
519
- x.cursorGetPosition = ESC + '6n';
520
- x.cursorNextLine = ESC + 'E';
521
- x.cursorPrevLine = ESC + 'F';
522
- x.cursorHide = ESC + '?25l';
523
- x.cursorShow = ESC + '?25h';
524
-
525
- x.eraseLines = count => {
526
- let clear = '';
527
-
528
- for (let i = 0; i < count; i++) {
529
- clear += x.eraseLine + (i < count - 1 ? x.cursorUp() : '');
530
- }
531
-
532
- if (count) {
533
- clear += x.cursorLeft;
534
- }
535
-
536
- return clear;
537
- };
538
-
539
- x.eraseEndLine = ESC + 'K';
540
- x.eraseStartLine = ESC + '1K';
541
- x.eraseLine = ESC + '2K';
542
- x.eraseDown = ESC + 'J';
543
- x.eraseUp = ESC + '1J';
544
- x.eraseScreen = ESC + '2J';
545
- x.scrollUp = ESC + 'S';
546
- x.scrollDown = ESC + 'T';
547
-
548
- x.clearScreen = '\u001Bc';
549
-
550
- x.clearTerminal = process.platform === 'win32' ?
551
- `${x.eraseScreen}${ESC}0f` :
552
- // 1. Erases the screen (Only done in case `2` is not supported)
553
- // 2. Erases the whole screen including scrollback buffer
554
- // 3. Moves cursor to the top-left position
555
- // More info: https://www.real-world-systems.com/docs/ANSIcode.html
556
- `${x.eraseScreen}${ESC}3J${ESC}H`;
557
-
558
- x.beep = BEL;
559
-
560
- x.link = (text, url) => {
561
- return [
562
- OSC,
563
- '8',
564
- SEP,
565
- SEP,
566
- url,
567
- BEL,
568
- text,
569
- OSC,
570
- '8',
571
- SEP,
572
- SEP,
573
- BEL
574
- ].join('');
575
- };
576
-
577
- x.image = (buf, opts) => {
578
- opts = opts || {};
579
-
580
- let ret = OSC + '1337;File=inline=1';
581
-
582
- if (opts.width) {
583
- ret += `;width=${opts.width}`;
584
- }
585
-
586
- if (opts.height) {
587
- ret += `;height=${opts.height}`;
588
- }
589
-
590
- if (opts.preserveAspectRatio === false) {
591
- ret += ';preserveAspectRatio=0';
592
- }
593
-
594
- return ret + ':' + buf.toString('base64') + BEL;
595
- };
596
-
597
- x.iTerm = {};
598
-
599
- x.iTerm.setCwd = cwd => OSC + '50;CurrentDir=' + (cwd || process.cwd()) + BEL;
600
-
601
-
602
- /***/ }),
603
-
604
- /***/ 39340:
605
- /***/ ((__unused_webpack_module, exports) => {
606
-
607
-
608
-
609
- Object.defineProperty(exports, "__esModule", ({
610
- value: true
611
- }));
612
- exports.withPromise = exports.withCallback = void 0;
613
-
614
- /**
615
- * Open the input with a normal callback function
616
- *
617
- * @param {Input} input - input object
618
- * @param {function} valueMapper - function which maps the resulting id and value back to the expected format
619
- * @param {function} callback - callback function
620
- */
621
- const withCallback = (input, valueMapper, callback) => {
622
- input.open();
623
- input.onSelect((id, value) => callback(valueMapper(id, value)));
624
- };
625
- /**
626
- * Open the input with a promise
627
- *
628
- * @param {Input} input - input object
629
- * @param {function} valueMapper - function which maps the resulting id and value back to the expected format
630
- */
631
-
632
-
633
- exports.withCallback = withCallback;
634
-
635
- const withPromise = (input, valueMapper) => {
636
- return new Promise((resolve, reject) => {
637
- input.open();
638
- input.onSelect((id, value) => {
639
- if (id === null) {
640
- reject();
641
- } else {
642
- resolve(valueMapper(id, value));
643
- }
644
- });
645
- });
646
- };
647
-
648
- exports.withPromise = withPromise;
649
-
650
- /***/ }),
651
-
652
- /***/ 99398:
653
- /***/ ((module, exports, __webpack_require__) => {
654
-
655
-
656
-
657
- Object.defineProperty(exports, "__esModule", ({
658
- value: true
659
- }));
660
- exports["default"] = void 0;
661
-
662
- var _input = _interopRequireDefault(__webpack_require__(25730));
663
-
664
- var _renderer = _interopRequireDefault(__webpack_require__(16059));
665
-
666
- var _callbackMappers = __webpack_require__(39340);
667
-
668
- var _valueMappers = __webpack_require__(26730);
669
-
670
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
671
-
672
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
673
-
674
- function _defineProperty(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; }
675
-
676
- /**
677
- * Default options
678
- */
679
- const defaultOptions = {
680
- outputStream: process.stdout,
681
- inputStream: process.stdin,
682
- values: [],
683
- defaultValue: 0,
684
- selected: '(x)',
685
- unselected: '( )',
686
- indentation: 0,
687
- cleanup: true,
688
- valueRenderer: value => value
689
- };
690
- /**
691
- * Create an instance of cli-select with the given options
692
- *
693
- * @param {object} options - options for cli-select
694
- * @param {function} callback - if specified, a callback will be used, otherwise a promise gets returned (optional)
695
- */
696
-
697
- const creator = (options, callback) => {
698
- // merge options with default options
699
- options = _objectSpread({}, defaultOptions, options); // create renderer and input instances
700
-
701
- const renderer = new _renderer.default(options, options.outputStream);
702
- const input = new _input.default(options.inputStream);
703
- input.setDefaultValue(options.defaultValue);
704
- input.attachRenderer(renderer); // handle array and object values
705
-
706
- let valueMapper;
707
-
708
- if (Array.isArray(options.values)) {
709
- valueMapper = (0, _valueMappers.withArrayValues)(options);
710
- } else {
711
- valueMapper = (0, _valueMappers.withObjectValues)(options);
712
- } // map values
713
-
714
-
715
- options.values = valueMapper.input;
716
- input.setValues(options.values); // handle different callback methods
717
-
718
- if (typeof callback === 'function') {
719
- return (0, _callbackMappers.withCallback)(input, valueMapper.output, callback);
720
- } else {
721
- return (0, _callbackMappers.withPromise)(input, valueMapper.output);
722
- }
723
- };
724
-
725
- exports = module.exports = creator;
726
- Object.defineProperty(exports, "__esModule", ({
727
- value: true
728
- }));
729
- var _default = creator;
730
- exports["default"] = _default;
731
-
732
- /***/ }),
733
-
734
- /***/ 25730:
735
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
736
-
737
-
738
-
739
- Object.defineProperty(exports, "__esModule", ({
740
- value: true
741
- }));
742
- exports["default"] = void 0;
743
-
744
- var _readline = _interopRequireDefault(__webpack_require__(14521));
745
-
746
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
747
-
748
- /**
749
- * Handle cli input
750
- */
751
- class Input {
752
- /**
753
- * Input constructor
754
- *
755
- * @param {any} stream - stream to catch (optional)
756
- */
757
- constructor(stream = process.stdin) {
758
- // set default values
759
- this.stream = stream;
760
- this.values = [];
761
- this.selectedValue = 0;
762
-
763
- this.onSelectListener = () => {};
764
-
765
- this.onKeyPress = this.onKeyPress.bind(this);
766
- }
767
- /**
768
- * Set the available values
769
- *
770
- * @param {array} values - all available values
771
- */
772
-
773
-
774
- setValues(values) {
775
- this.values = values;
776
-
777
- if (this.renderer) {
778
- this.renderer.setValues(values);
779
- }
780
- }
781
- /**
782
- * Set the default value
783
- *
784
- * @param {number} defaultValue - default value id
785
- */
786
-
787
-
788
- setDefaultValue(defaultValue) {
789
- this.selectedValue = defaultValue;
790
- }
791
- /**
792
- * Attach a renderer to the input catcher
793
- *
794
- * @param {Renderer} renderer - renderer to use for rendering responses
795
- */
796
-
797
-
798
- attachRenderer(renderer) {
799
- this.renderer = renderer;
800
- this.renderer.setValues(this.values);
801
- }
802
- /**
803
- * Register an on select listener
804
- *
805
- * @param {function} listener - listener function which receives two parameters: valueId and value
806
- */
807
-
808
-
809
- onSelect(listener) {
810
- this.onSelectListener = listener;
811
- }
812
- /**
813
- * Open the stream and listen for input
814
- */
815
-
816
-
817
- open() {
818
- // register keypress event
819
- _readline.default.emitKeypressEvents(this.stream); // handle keypress
820
-
821
-
822
- this.stream.on('keypress', this.onKeyPress); // initially render the response
823
-
824
- if (this.renderer) {
825
- this.renderer.render(this.selectedValue);
826
- } // hide pressed keys and start listening on input
827
-
828
-
829
- this.stream.setRawMode(true);
830
- this.stream.resume();
831
- }
832
- /**
833
- * Close the stream
834
- *
835
- * @param {boolean} cancelled - true if no value was selected (optional)
836
- */
837
-
838
-
839
- close(cancelled = false) {
840
- // reset stream properties
841
- this.stream.setRawMode(false);
842
- this.stream.pause(); // cleanup the output
843
-
844
- if (this.renderer) {
845
- this.renderer.cleanup();
846
- } // call the on select listener
847
-
848
-
849
- if (cancelled) {
850
- this.onSelectListener(null);
851
- } else {
852
- this.onSelectListener(this.selectedValue, this.values[this.selectedValue]);
853
- }
854
-
855
- this.stream.removeListener('keypress', this.onKeyPress);
856
- }
857
- /**
858
- * Render the response
859
- */
860
-
861
-
862
- render() {
863
- if (!this.renderer) {
864
- return;
865
- }
866
-
867
- this.renderer.render(this.selectedValue);
868
- }
869
- /**
870
- * Handle key press event
871
- *
872
- * @param {string} string - input string
873
- * @param {object} key - object containing information about the pressed key
874
- */
875
-
876
-
877
- onKeyPress(string, key) {
878
- if (key) {
879
- if (key.name === 'up' && this.selectedValue > 0) {
880
- this.selectedValue--;
881
- this.render();
882
- } else if (key.name === 'down' && this.selectedValue + 1 < this.values.length) {
883
- this.selectedValue++;
884
- this.render();
885
- } else if (key.name === 'return') {
886
- this.close();
887
- } else if (key.name === 'escape' || key.name === 'c' && key.ctrl) {
888
- this.close(true);
889
- }
890
- }
891
- }
892
-
893
- }
894
-
895
- exports["default"] = Input;
896
-
897
- /***/ }),
898
-
899
- /***/ 16059:
900
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
901
-
902
-
903
-
904
- Object.defineProperty(exports, "__esModule", ({
905
- value: true
906
- }));
907
- exports["default"] = void 0;
908
-
909
- var _readline = _interopRequireDefault(__webpack_require__(14521));
910
-
911
- var _ansiEscapes = __webpack_require__(18512);
912
-
913
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
914
-
915
- /**
916
- * Response renderer
917
- */
918
- class Renderer {
919
- /**
920
- * Renderer constructor
921
- *
922
- * @param {object} options - renderer options
923
- * @param {any} stream - stream to write to (optional)
924
- */
925
- constructor(options, stream = process.stdout) {
926
- this.options = options;
927
- this.stream = stream;
928
- this.values = [];
929
- this.initialRender = true;
930
- }
931
- /**
932
- * Set the available values
933
- *
934
- * @param {array} values - all available values
935
- */
936
-
937
-
938
- setValues(values) {
939
- this.values = values;
940
- }
941
- /**
942
- * Render the values
943
- *
944
- * @param {number} selectedValue - selected value (optional)
945
- */
946
-
947
-
948
- render(selectedValue = 0) {
949
- if (this.initialRender) {
950
- // hide the cursor initially
951
- this.initialRender = false;
952
- this.stream.write(_ansiEscapes.cursorHide);
953
- } else {
954
- // remove previous lines and values
955
- this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
956
- } // output the current values
957
-
958
-
959
- this.values.forEach((value, index) => {
960
- const symbol = selectedValue === index ? this.options.selected : this.options.unselected;
961
- const indentation = ' '.repeat(this.options.indentation);
962
- const renderedValue = this.options.valueRenderer(value, selectedValue === index);
963
- const end = index !== this.values.length - 1 ? '\n' : '';
964
- this.stream.write(indentation + symbol + ' ' + renderedValue + end);
965
- });
966
- }
967
- /**
968
- * Cleanup the console at the end
969
- */
970
-
971
-
972
- cleanup() {
973
- this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
974
- this.stream.write(_ansiEscapes.cursorShow);
975
- }
976
-
977
- }
978
-
979
- exports["default"] = Renderer;
980
-
981
- /***/ }),
982
-
983
- /***/ 26730:
984
- /***/ ((__unused_webpack_module, exports) => {
985
-
986
-
987
-
988
- Object.defineProperty(exports, "__esModule", ({
989
- value: true
990
- }));
991
- exports.withObjectValues = exports.withArrayValues = void 0;
992
-
993
- /**
994
- * Map incoming and outgoing values if the initial values are an array
995
- *
996
- * @param {object} options - cli-select options
997
- */
998
- const withArrayValues = options => {
999
- return {
1000
- input: options.values,
1001
- output: (id, value) => {
1002
- return {
1003
- id,
1004
- value
1005
- };
1006
- }
1007
- };
1008
- };
1009
- /**
1010
- * Map incoming and outgoing values if the initial values are an object
1011
- *
1012
- * @param {object} options - cli-select options
1013
- */
1014
-
1015
-
1016
- exports.withArrayValues = withArrayValues;
1017
-
1018
- const withObjectValues = options => {
1019
- const originalValues = options.values;
1020
- return {
1021
- input: Object.values(originalValues),
1022
- output: (id, value) => {
1023
- return {
1024
- id: Object.keys(originalValues)[id],
1025
- value
1026
- };
1027
- }
1028
- };
1029
- };
1030
-
1031
- exports.withObjectValues = withObjectValues;
1032
-
1033
- /***/ }),
1034
-
1035
- /***/ 14899:
1036
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1037
-
1038
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1039
- /* harmony export */ "k": () => (/* binding */ capitalize)
1040
- /* harmony export */ });
1041
- /** @see <https://docs.tsafe.dev/capitalize> */
1042
- function capitalize(str) {
1043
- return (str.charAt(0).toUpperCase() + str.slice(1));
1044
- }
1045
-
1046
-
1047
- //# sourceMappingURL=capitalize.mjs.map
1048
-
1049
-
1050
- /***/ }),
1051
-
1052
- /***/ 76030:
1053
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1054
-
1055
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1056
- /* harmony export */ "r": () => (/* binding */ symToStr)
1057
- /* harmony export */ });
1058
- /** @see <https://docs.tsafe.dev/main/symtostr> */
1059
- function symToStr(wrap) {
1060
- // @ts-expect-error: We know better
1061
- return Object.keys(wrap)[0];
1062
- }
1063
-
1064
-
1065
- //# sourceMappingURL=symToStr.mjs.map
1066
-
1067
-
1068
236
  /***/ })
1069
237
 
1070
238
  };