git-coco 0.21.0 → 0.21.2

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 (3) hide show
  1. package/dist/index.esm.mjs +22 -2031
  2. package/dist/index.js +23 -2032
  3. package/package.json +5 -18
@@ -5,7 +5,7 @@ import yargs from 'yargs';
5
5
  import chalk from 'chalk';
6
6
  import * as fs from 'fs';
7
7
  import fs__default, { promises, existsSync, readFileSync } from 'fs';
8
- import { confirm, editor, select, password, input, Separator, number, rawlist, expand, checkbox, search } from '@inquirer/prompts';
8
+ import { confirm, editor, select, password, input } from '@inquirer/prompts';
9
9
  import * as ini from 'ini';
10
10
  import * as os from 'os';
11
11
  import os__default from 'os';
@@ -39,8 +39,6 @@ import '@langchain/core/utils/env';
39
39
  import { minimatch } from 'minimatch';
40
40
  import { encoding_for_model } from 'tiktoken';
41
41
  import { exec } from 'child_process';
42
- import readline$1 from 'node:readline';
43
- import require$$0 from 'stream';
44
42
  import * as readline from 'readline';
45
43
  import { lint, load } from '@commitlint/core';
46
44
  import { pathToFileURL } from 'url';
@@ -50,7 +48,7 @@ import { pathToFileURL } from 'url';
50
48
  /**
51
49
  * Current build version from package.json
52
50
  */
53
- const BUILD_VERSION = "0.21.0";
51
+ const BUILD_VERSION = "0.21.2";
54
52
 
55
53
  const isInteractive = (config) => {
56
54
  return config?.mode === 'interactive' || !!config?.interactive;
@@ -7608,7 +7606,7 @@ const conventionalTypeRegex = /^(feat|fix|docs|style|refactor|perf|test|build|ci
7608
7606
  const CommitMessageResponseSchema = objectType({
7609
7607
  title: stringType().describe("Title of the commit message"),
7610
7608
  body: stringType().describe("Body of the commit message"),
7611
- });
7609
+ }).describe("Object with commit message 'title' and 'body'");
7612
7610
  // Conventional commit message schema with strict formatting rules
7613
7611
  const ConventionalCommitMessageResponseSchema = objectType({
7614
7612
  title: stringType()
@@ -7616,7 +7614,7 @@ const ConventionalCommitMessageResponseSchema = objectType({
7616
7614
  .refine((title) => conventionalTypeRegex.test(title), "Title must follow Conventional Commits format (e.g., 'feat: add new feature' or 'fix(scope): fix bug')").describe("Title of the commit message"),
7617
7615
  body: stringType().describe("Body of the commit message")
7618
7616
  // .max(280, "Body must be 280 characters or less"),
7619
- }).describe("Conventional commit message schema with strict formatting rules");
7617
+ }).describe("Object with Conventional Commit message 'title' and 'body' adhering to Conventional Commits specification");
7620
7618
  const command$3 = 'commit';
7621
7619
  /**
7622
7620
  * Command line options via yargs
@@ -10128,7 +10126,7 @@ var seq = new type('tag:yaml.org,2002:seq', {
10128
10126
  construct: function (data) { return data !== null ? data : []; }
10129
10127
  });
10130
10128
 
10131
- var map$1 = new type('tag:yaml.org,2002:map', {
10129
+ var map = new type('tag:yaml.org,2002:map', {
10132
10130
  kind: 'mapping',
10133
10131
  construct: function (data) { return data !== null ? data : {}; }
10134
10132
  });
@@ -10137,7 +10135,7 @@ var failsafe = new schema({
10137
10135
  explicit: [
10138
10136
  str,
10139
10137
  seq,
10140
- map$1
10138
+ map
10141
10139
  ]
10142
10140
  });
10143
10141
 
@@ -11222,13 +11220,19 @@ const handler$3 = async (argv, logger) => {
11222
11220
  }
11223
11221
  }
11224
11222
  async function parser(changes) {
11223
+ if (config.noDiff) {
11224
+ // When noDiff is enabled, just return a simple summary without parsing file contents
11225
+ const filesSummary = changes
11226
+ .map((change) => `${change.status}: ${change.filePath}`)
11227
+ .join('\n');
11228
+ return `Staged files:\n${filesSummary}`;
11229
+ }
11225
11230
  return await fileChangeParser({
11226
11231
  changes,
11227
11232
  commit: '--staged',
11228
11233
  options: { tokenizer, git, llm, logger },
11229
11234
  });
11230
11235
  }
11231
- logger.log(`Generating commit message...${JSON.stringify(config.prompt)}`, { color: 'blue' });
11232
11236
  const commitMsg = await generateAndReviewLoop({
11233
11237
  label: 'commit message',
11234
11238
  options: {
@@ -11261,7 +11265,11 @@ const handler$3 = async (argv, logger) => {
11261
11265
  ? ConventionalCommitMessageResponseSchema
11262
11266
  : CommitMessageResponseSchema;
11263
11267
  const formatInstructions = `You must always return valid JSON fenced by a markdown code block. Do not return any additional text. The JSON object you return should match the following schema:
11264
- ${schema.description}`;
11268
+ ${schema.description}
11269
+ {
11270
+ "title": "The commit title",
11271
+ "body": "The commit body"
11272
+ }`;
11265
11273
  // Use conventional commit prompt if enabled
11266
11274
  const promptTemplate = USE_CONVENTIONAL_COMMITS ? CONVENTIONAL_COMMIT_PROMPT : COMMIT_PROMPT;
11267
11275
  const prompt = getPrompt({
@@ -12304,2019 +12312,6 @@ const builder = (yargs) => {
12304
12312
  return yargs.options(options).usage(getCommandUsageHeader(command));
12305
12313
  };
12306
12314
 
12307
- /******************************************************************************
12308
- Copyright (c) Microsoft Corporation.
12309
-
12310
- Permission to use, copy, modify, and/or distribute this software for any
12311
- purpose with or without fee is hereby granted.
12312
-
12313
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12314
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12315
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12316
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12317
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12318
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
12319
- PERFORMANCE OF THIS SOFTWARE.
12320
- ***************************************************************************** */
12321
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
12322
-
12323
- var extendStatics = function(d, b) {
12324
- extendStatics = Object.setPrototypeOf ||
12325
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12326
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
12327
- return extendStatics(d, b);
12328
- };
12329
-
12330
- function __extends(d, b) {
12331
- if (typeof b !== "function" && b !== null)
12332
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12333
- extendStatics(d, b);
12334
- function __() { this.constructor = d; }
12335
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12336
- }
12337
-
12338
- function __awaiter(thisArg, _arguments, P, generator) {
12339
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
12340
- return new (P || (P = Promise))(function (resolve, reject) {
12341
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12342
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12343
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12344
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12345
- });
12346
- }
12347
-
12348
- function __generator(thisArg, body) {
12349
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12350
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12351
- function verb(n) { return function (v) { return step([n, v]); }; }
12352
- function step(op) {
12353
- if (f) throw new TypeError("Generator is already executing.");
12354
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
12355
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
12356
- if (y = 0, t) op = [op[0] & 2, t.value];
12357
- switch (op[0]) {
12358
- case 0: case 1: t = op; break;
12359
- case 4: _.label++; return { value: op[1], done: false };
12360
- case 5: _.label++; y = op[1]; op = [0]; continue;
12361
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
12362
- default:
12363
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
12364
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
12365
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
12366
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
12367
- if (t[2]) _.ops.pop();
12368
- _.trys.pop(); continue;
12369
- }
12370
- op = body.call(thisArg, _);
12371
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
12372
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
12373
- }
12374
- }
12375
-
12376
- function __values(o) {
12377
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
12378
- if (m) return m.call(o);
12379
- if (o && typeof o.length === "number") return {
12380
- next: function () {
12381
- if (o && i >= o.length) o = void 0;
12382
- return { value: o && o[i++], done: !o };
12383
- }
12384
- };
12385
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12386
- }
12387
-
12388
- function __read(o, n) {
12389
- var m = typeof Symbol === "function" && o[Symbol.iterator];
12390
- if (!m) return o;
12391
- var i = m.call(o), r, ar = [], e;
12392
- try {
12393
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12394
- }
12395
- catch (error) { e = { error: error }; }
12396
- finally {
12397
- try {
12398
- if (r && !r.done && (m = i["return"])) m.call(i);
12399
- }
12400
- finally { if (e) throw e.error; }
12401
- }
12402
- return ar;
12403
- }
12404
-
12405
- function __spreadArray(to, from, pack) {
12406
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
12407
- if (ar || !(i in from)) {
12408
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
12409
- ar[i] = from[i];
12410
- }
12411
- }
12412
- return to.concat(ar || Array.prototype.slice.call(from));
12413
- }
12414
-
12415
- function __await(v) {
12416
- return this instanceof __await ? (this.v = v, this) : new __await(v);
12417
- }
12418
-
12419
- function __asyncGenerator(thisArg, _arguments, generator) {
12420
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
12421
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
12422
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
12423
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
12424
- function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
12425
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
12426
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
12427
- function fulfill(value) { resume("next", value); }
12428
- function reject(value) { resume("throw", value); }
12429
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
12430
- }
12431
-
12432
- function __asyncValues(o) {
12433
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
12434
- var m = o[Symbol.asyncIterator], i;
12435
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
12436
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
12437
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
12438
- }
12439
-
12440
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
12441
- var e = new Error(message);
12442
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
12443
- };
12444
-
12445
- function isFunction(value) {
12446
- return typeof value === 'function';
12447
- }
12448
-
12449
- function createErrorClass(createImpl) {
12450
- var _super = function (instance) {
12451
- Error.call(instance);
12452
- instance.stack = new Error().stack;
12453
- };
12454
- var ctorFunc = createImpl(_super);
12455
- ctorFunc.prototype = Object.create(Error.prototype);
12456
- ctorFunc.prototype.constructor = ctorFunc;
12457
- return ctorFunc;
12458
- }
12459
-
12460
- var UnsubscriptionError = createErrorClass(function (_super) {
12461
- return function UnsubscriptionErrorImpl(errors) {
12462
- _super(this);
12463
- this.message = errors
12464
- ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
12465
- : '';
12466
- this.name = 'UnsubscriptionError';
12467
- this.errors = errors;
12468
- };
12469
- });
12470
-
12471
- function arrRemove(arr, item) {
12472
- if (arr) {
12473
- var index = arr.indexOf(item);
12474
- 0 <= index && arr.splice(index, 1);
12475
- }
12476
- }
12477
-
12478
- var Subscription = (function () {
12479
- function Subscription(initialTeardown) {
12480
- this.initialTeardown = initialTeardown;
12481
- this.closed = false;
12482
- this._parentage = null;
12483
- this._finalizers = null;
12484
- }
12485
- Subscription.prototype.unsubscribe = function () {
12486
- var e_1, _a, e_2, _b;
12487
- var errors;
12488
- if (!this.closed) {
12489
- this.closed = true;
12490
- var _parentage = this._parentage;
12491
- if (_parentage) {
12492
- this._parentage = null;
12493
- if (Array.isArray(_parentage)) {
12494
- try {
12495
- for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
12496
- var parent_1 = _parentage_1_1.value;
12497
- parent_1.remove(this);
12498
- }
12499
- }
12500
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
12501
- finally {
12502
- try {
12503
- if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
12504
- }
12505
- finally { if (e_1) throw e_1.error; }
12506
- }
12507
- }
12508
- else {
12509
- _parentage.remove(this);
12510
- }
12511
- }
12512
- var initialFinalizer = this.initialTeardown;
12513
- if (isFunction(initialFinalizer)) {
12514
- try {
12515
- initialFinalizer();
12516
- }
12517
- catch (e) {
12518
- errors = e instanceof UnsubscriptionError ? e.errors : [e];
12519
- }
12520
- }
12521
- var _finalizers = this._finalizers;
12522
- if (_finalizers) {
12523
- this._finalizers = null;
12524
- try {
12525
- for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
12526
- var finalizer = _finalizers_1_1.value;
12527
- try {
12528
- execFinalizer(finalizer);
12529
- }
12530
- catch (err) {
12531
- errors = errors !== null && errors !== void 0 ? errors : [];
12532
- if (err instanceof UnsubscriptionError) {
12533
- errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
12534
- }
12535
- else {
12536
- errors.push(err);
12537
- }
12538
- }
12539
- }
12540
- }
12541
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
12542
- finally {
12543
- try {
12544
- if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
12545
- }
12546
- finally { if (e_2) throw e_2.error; }
12547
- }
12548
- }
12549
- if (errors) {
12550
- throw new UnsubscriptionError(errors);
12551
- }
12552
- }
12553
- };
12554
- Subscription.prototype.add = function (teardown) {
12555
- var _a;
12556
- if (teardown && teardown !== this) {
12557
- if (this.closed) {
12558
- execFinalizer(teardown);
12559
- }
12560
- else {
12561
- if (teardown instanceof Subscription) {
12562
- if (teardown.closed || teardown._hasParent(this)) {
12563
- return;
12564
- }
12565
- teardown._addParent(this);
12566
- }
12567
- (this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
12568
- }
12569
- }
12570
- };
12571
- Subscription.prototype._hasParent = function (parent) {
12572
- var _parentage = this._parentage;
12573
- return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
12574
- };
12575
- Subscription.prototype._addParent = function (parent) {
12576
- var _parentage = this._parentage;
12577
- this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
12578
- };
12579
- Subscription.prototype._removeParent = function (parent) {
12580
- var _parentage = this._parentage;
12581
- if (_parentage === parent) {
12582
- this._parentage = null;
12583
- }
12584
- else if (Array.isArray(_parentage)) {
12585
- arrRemove(_parentage, parent);
12586
- }
12587
- };
12588
- Subscription.prototype.remove = function (teardown) {
12589
- var _finalizers = this._finalizers;
12590
- _finalizers && arrRemove(_finalizers, teardown);
12591
- if (teardown instanceof Subscription) {
12592
- teardown._removeParent(this);
12593
- }
12594
- };
12595
- Subscription.EMPTY = (function () {
12596
- var empty = new Subscription();
12597
- empty.closed = true;
12598
- return empty;
12599
- })();
12600
- return Subscription;
12601
- }());
12602
- Subscription.EMPTY;
12603
- function isSubscription(value) {
12604
- return (value instanceof Subscription ||
12605
- (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
12606
- }
12607
- function execFinalizer(finalizer) {
12608
- if (isFunction(finalizer)) {
12609
- finalizer();
12610
- }
12611
- else {
12612
- finalizer.unsubscribe();
12613
- }
12614
- }
12615
-
12616
- var config = {
12617
- onUnhandledError: null,
12618
- onStoppedNotification: null,
12619
- Promise: undefined,
12620
- useDeprecatedSynchronousErrorHandling: false,
12621
- useDeprecatedNextContext: false,
12622
- };
12623
-
12624
- var timeoutProvider = {
12625
- setTimeout: function (handler, timeout) {
12626
- var args = [];
12627
- for (var _i = 2; _i < arguments.length; _i++) {
12628
- args[_i - 2] = arguments[_i];
12629
- }
12630
- var delegate = timeoutProvider.delegate;
12631
- if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
12632
- return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));
12633
- }
12634
- return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
12635
- },
12636
- clearTimeout: function (handle) {
12637
- var delegate = timeoutProvider.delegate;
12638
- return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
12639
- },
12640
- delegate: undefined,
12641
- };
12642
-
12643
- function reportUnhandledError(err) {
12644
- timeoutProvider.setTimeout(function () {
12645
- {
12646
- throw err;
12647
- }
12648
- });
12649
- }
12650
-
12651
- function noop() { }
12652
-
12653
- function errorContext(cb) {
12654
- {
12655
- cb();
12656
- }
12657
- }
12658
-
12659
- var Subscriber = (function (_super) {
12660
- __extends(Subscriber, _super);
12661
- function Subscriber(destination) {
12662
- var _this = _super.call(this) || this;
12663
- _this.isStopped = false;
12664
- if (destination) {
12665
- _this.destination = destination;
12666
- if (isSubscription(destination)) {
12667
- destination.add(_this);
12668
- }
12669
- }
12670
- else {
12671
- _this.destination = EMPTY_OBSERVER;
12672
- }
12673
- return _this;
12674
- }
12675
- Subscriber.create = function (next, error, complete) {
12676
- return new SafeSubscriber(next, error, complete);
12677
- };
12678
- Subscriber.prototype.next = function (value) {
12679
- if (this.isStopped) ;
12680
- else {
12681
- this._next(value);
12682
- }
12683
- };
12684
- Subscriber.prototype.error = function (err) {
12685
- if (this.isStopped) ;
12686
- else {
12687
- this.isStopped = true;
12688
- this._error(err);
12689
- }
12690
- };
12691
- Subscriber.prototype.complete = function () {
12692
- if (this.isStopped) ;
12693
- else {
12694
- this.isStopped = true;
12695
- this._complete();
12696
- }
12697
- };
12698
- Subscriber.prototype.unsubscribe = function () {
12699
- if (!this.closed) {
12700
- this.isStopped = true;
12701
- _super.prototype.unsubscribe.call(this);
12702
- this.destination = null;
12703
- }
12704
- };
12705
- Subscriber.prototype._next = function (value) {
12706
- this.destination.next(value);
12707
- };
12708
- Subscriber.prototype._error = function (err) {
12709
- try {
12710
- this.destination.error(err);
12711
- }
12712
- finally {
12713
- this.unsubscribe();
12714
- }
12715
- };
12716
- Subscriber.prototype._complete = function () {
12717
- try {
12718
- this.destination.complete();
12719
- }
12720
- finally {
12721
- this.unsubscribe();
12722
- }
12723
- };
12724
- return Subscriber;
12725
- }(Subscription));
12726
- var _bind = Function.prototype.bind;
12727
- function bind(fn, thisArg) {
12728
- return _bind.call(fn, thisArg);
12729
- }
12730
- var ConsumerObserver = (function () {
12731
- function ConsumerObserver(partialObserver) {
12732
- this.partialObserver = partialObserver;
12733
- }
12734
- ConsumerObserver.prototype.next = function (value) {
12735
- var partialObserver = this.partialObserver;
12736
- if (partialObserver.next) {
12737
- try {
12738
- partialObserver.next(value);
12739
- }
12740
- catch (error) {
12741
- handleUnhandledError(error);
12742
- }
12743
- }
12744
- };
12745
- ConsumerObserver.prototype.error = function (err) {
12746
- var partialObserver = this.partialObserver;
12747
- if (partialObserver.error) {
12748
- try {
12749
- partialObserver.error(err);
12750
- }
12751
- catch (error) {
12752
- handleUnhandledError(error);
12753
- }
12754
- }
12755
- else {
12756
- handleUnhandledError(err);
12757
- }
12758
- };
12759
- ConsumerObserver.prototype.complete = function () {
12760
- var partialObserver = this.partialObserver;
12761
- if (partialObserver.complete) {
12762
- try {
12763
- partialObserver.complete();
12764
- }
12765
- catch (error) {
12766
- handleUnhandledError(error);
12767
- }
12768
- }
12769
- };
12770
- return ConsumerObserver;
12771
- }());
12772
- var SafeSubscriber = (function (_super) {
12773
- __extends(SafeSubscriber, _super);
12774
- function SafeSubscriber(observerOrNext, error, complete) {
12775
- var _this = _super.call(this) || this;
12776
- var partialObserver;
12777
- if (isFunction(observerOrNext) || !observerOrNext) {
12778
- partialObserver = {
12779
- next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
12780
- error: error !== null && error !== void 0 ? error : undefined,
12781
- complete: complete !== null && complete !== void 0 ? complete : undefined,
12782
- };
12783
- }
12784
- else {
12785
- var context_1;
12786
- if (_this && config.useDeprecatedNextContext) {
12787
- context_1 = Object.create(observerOrNext);
12788
- context_1.unsubscribe = function () { return _this.unsubscribe(); };
12789
- partialObserver = {
12790
- next: observerOrNext.next && bind(observerOrNext.next, context_1),
12791
- error: observerOrNext.error && bind(observerOrNext.error, context_1),
12792
- complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),
12793
- };
12794
- }
12795
- else {
12796
- partialObserver = observerOrNext;
12797
- }
12798
- }
12799
- _this.destination = new ConsumerObserver(partialObserver);
12800
- return _this;
12801
- }
12802
- return SafeSubscriber;
12803
- }(Subscriber));
12804
- function handleUnhandledError(error) {
12805
- {
12806
- reportUnhandledError(error);
12807
- }
12808
- }
12809
- function defaultErrorHandler(err) {
12810
- throw err;
12811
- }
12812
- var EMPTY_OBSERVER = {
12813
- closed: true,
12814
- next: noop,
12815
- error: defaultErrorHandler,
12816
- complete: noop,
12817
- };
12818
-
12819
- var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })();
12820
-
12821
- function identity(x) {
12822
- return x;
12823
- }
12824
-
12825
- function pipeFromArray(fns) {
12826
- if (fns.length === 0) {
12827
- return identity;
12828
- }
12829
- if (fns.length === 1) {
12830
- return fns[0];
12831
- }
12832
- return function piped(input) {
12833
- return fns.reduce(function (prev, fn) { return fn(prev); }, input);
12834
- };
12835
- }
12836
-
12837
- var Observable = (function () {
12838
- function Observable(subscribe) {
12839
- if (subscribe) {
12840
- this._subscribe = subscribe;
12841
- }
12842
- }
12843
- Observable.prototype.lift = function (operator) {
12844
- var observable = new Observable();
12845
- observable.source = this;
12846
- observable.operator = operator;
12847
- return observable;
12848
- };
12849
- Observable.prototype.subscribe = function (observerOrNext, error, complete) {
12850
- var _this = this;
12851
- var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
12852
- errorContext(function () {
12853
- var _a = _this, operator = _a.operator, source = _a.source;
12854
- subscriber.add(operator
12855
- ?
12856
- operator.call(subscriber, source)
12857
- : source
12858
- ?
12859
- _this._subscribe(subscriber)
12860
- :
12861
- _this._trySubscribe(subscriber));
12862
- });
12863
- return subscriber;
12864
- };
12865
- Observable.prototype._trySubscribe = function (sink) {
12866
- try {
12867
- return this._subscribe(sink);
12868
- }
12869
- catch (err) {
12870
- sink.error(err);
12871
- }
12872
- };
12873
- Observable.prototype.forEach = function (next, promiseCtor) {
12874
- var _this = this;
12875
- promiseCtor = getPromiseCtor(promiseCtor);
12876
- return new promiseCtor(function (resolve, reject) {
12877
- var subscriber = new SafeSubscriber({
12878
- next: function (value) {
12879
- try {
12880
- next(value);
12881
- }
12882
- catch (err) {
12883
- reject(err);
12884
- subscriber.unsubscribe();
12885
- }
12886
- },
12887
- error: reject,
12888
- complete: resolve,
12889
- });
12890
- _this.subscribe(subscriber);
12891
- });
12892
- };
12893
- Observable.prototype._subscribe = function (subscriber) {
12894
- var _a;
12895
- return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
12896
- };
12897
- Observable.prototype[observable] = function () {
12898
- return this;
12899
- };
12900
- Observable.prototype.pipe = function () {
12901
- var operations = [];
12902
- for (var _i = 0; _i < arguments.length; _i++) {
12903
- operations[_i] = arguments[_i];
12904
- }
12905
- return pipeFromArray(operations)(this);
12906
- };
12907
- Observable.prototype.toPromise = function (promiseCtor) {
12908
- var _this = this;
12909
- promiseCtor = getPromiseCtor(promiseCtor);
12910
- return new promiseCtor(function (resolve, reject) {
12911
- var value;
12912
- _this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
12913
- });
12914
- };
12915
- Observable.create = function (subscribe) {
12916
- return new Observable(subscribe);
12917
- };
12918
- return Observable;
12919
- }());
12920
- function getPromiseCtor(promiseCtor) {
12921
- var _a;
12922
- return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
12923
- }
12924
- function isObserver(value) {
12925
- return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
12926
- }
12927
- function isSubscriber(value) {
12928
- return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
12929
- }
12930
-
12931
- function hasLift(source) {
12932
- return isFunction(source === null || source === void 0 ? void 0 : source.lift);
12933
- }
12934
- function operate(init) {
12935
- return function (source) {
12936
- if (hasLift(source)) {
12937
- return source.lift(function (liftedSource) {
12938
- try {
12939
- return init(liftedSource, this);
12940
- }
12941
- catch (err) {
12942
- this.error(err);
12943
- }
12944
- });
12945
- }
12946
- throw new TypeError('Unable to lift unknown Observable type');
12947
- };
12948
- }
12949
-
12950
- function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
12951
- return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
12952
- }
12953
- var OperatorSubscriber = (function (_super) {
12954
- __extends(OperatorSubscriber, _super);
12955
- function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
12956
- var _this = _super.call(this, destination) || this;
12957
- _this.onFinalize = onFinalize;
12958
- _this.shouldUnsubscribe = shouldUnsubscribe;
12959
- _this._next = onNext
12960
- ? function (value) {
12961
- try {
12962
- onNext(value);
12963
- }
12964
- catch (err) {
12965
- destination.error(err);
12966
- }
12967
- }
12968
- : _super.prototype._next;
12969
- _this._error = onError
12970
- ? function (err) {
12971
- try {
12972
- onError(err);
12973
- }
12974
- catch (err) {
12975
- destination.error(err);
12976
- }
12977
- finally {
12978
- this.unsubscribe();
12979
- }
12980
- }
12981
- : _super.prototype._error;
12982
- _this._complete = onComplete
12983
- ? function () {
12984
- try {
12985
- onComplete();
12986
- }
12987
- catch (err) {
12988
- destination.error(err);
12989
- }
12990
- finally {
12991
- this.unsubscribe();
12992
- }
12993
- }
12994
- : _super.prototype._complete;
12995
- return _this;
12996
- }
12997
- OperatorSubscriber.prototype.unsubscribe = function () {
12998
- var _a;
12999
- if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
13000
- var closed_1 = this.closed;
13001
- _super.prototype.unsubscribe.call(this);
13002
- !closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
13003
- }
13004
- };
13005
- return OperatorSubscriber;
13006
- }(Subscriber));
13007
-
13008
- var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); });
13009
-
13010
- function isScheduler(value) {
13011
- return value && isFunction(value.schedule);
13012
- }
13013
-
13014
- function last(arr) {
13015
- return arr[arr.length - 1];
13016
- }
13017
- function popScheduler(args) {
13018
- return isScheduler(last(args)) ? args.pop() : undefined;
13019
- }
13020
-
13021
- var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
13022
-
13023
- function isPromise(value) {
13024
- return isFunction(value === null || value === void 0 ? void 0 : value.then);
13025
- }
13026
-
13027
- function isInteropObservable(input) {
13028
- return isFunction(input[observable]);
13029
- }
13030
-
13031
- function isAsyncIterable(obj) {
13032
- return Symbol.asyncIterator && isFunction(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);
13033
- }
13034
-
13035
- function createInvalidObservableTypeError(input) {
13036
- return new TypeError("You provided " + (input !== null && typeof input === 'object' ? 'an invalid object' : "'" + input + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
13037
- }
13038
-
13039
- function getSymbolIterator() {
13040
- if (typeof Symbol !== 'function' || !Symbol.iterator) {
13041
- return '@@iterator';
13042
- }
13043
- return Symbol.iterator;
13044
- }
13045
- var iterator = getSymbolIterator();
13046
-
13047
- function isIterable(input) {
13048
- return isFunction(input === null || input === void 0 ? void 0 : input[iterator]);
13049
- }
13050
-
13051
- function readableStreamLikeToAsyncGenerator(readableStream) {
13052
- return __asyncGenerator(this, arguments, function readableStreamLikeToAsyncGenerator_1() {
13053
- var reader, _a, value, done;
13054
- return __generator(this, function (_b) {
13055
- switch (_b.label) {
13056
- case 0:
13057
- reader = readableStream.getReader();
13058
- _b.label = 1;
13059
- case 1:
13060
- _b.trys.push([1, , 9, 10]);
13061
- _b.label = 2;
13062
- case 2:
13063
- return [4, __await(reader.read())];
13064
- case 3:
13065
- _a = _b.sent(), value = _a.value, done = _a.done;
13066
- if (!done) return [3, 5];
13067
- return [4, __await(void 0)];
13068
- case 4: return [2, _b.sent()];
13069
- case 5: return [4, __await(value)];
13070
- case 6: return [4, _b.sent()];
13071
- case 7:
13072
- _b.sent();
13073
- return [3, 2];
13074
- case 8: return [3, 10];
13075
- case 9:
13076
- reader.releaseLock();
13077
- return [7];
13078
- case 10: return [2];
13079
- }
13080
- });
13081
- });
13082
- }
13083
- function isReadableStreamLike(obj) {
13084
- return isFunction(obj === null || obj === void 0 ? void 0 : obj.getReader);
13085
- }
13086
-
13087
- function innerFrom(input) {
13088
- if (input instanceof Observable) {
13089
- return input;
13090
- }
13091
- if (input != null) {
13092
- if (isInteropObservable(input)) {
13093
- return fromInteropObservable(input);
13094
- }
13095
- if (isArrayLike(input)) {
13096
- return fromArrayLike(input);
13097
- }
13098
- if (isPromise(input)) {
13099
- return fromPromise(input);
13100
- }
13101
- if (isAsyncIterable(input)) {
13102
- return fromAsyncIterable(input);
13103
- }
13104
- if (isIterable(input)) {
13105
- return fromIterable(input);
13106
- }
13107
- if (isReadableStreamLike(input)) {
13108
- return fromReadableStreamLike(input);
13109
- }
13110
- }
13111
- throw createInvalidObservableTypeError(input);
13112
- }
13113
- function fromInteropObservable(obj) {
13114
- return new Observable(function (subscriber) {
13115
- var obs = obj[observable]();
13116
- if (isFunction(obs.subscribe)) {
13117
- return obs.subscribe(subscriber);
13118
- }
13119
- throw new TypeError('Provided object does not correctly implement Symbol.observable');
13120
- });
13121
- }
13122
- function fromArrayLike(array) {
13123
- return new Observable(function (subscriber) {
13124
- for (var i = 0; i < array.length && !subscriber.closed; i++) {
13125
- subscriber.next(array[i]);
13126
- }
13127
- subscriber.complete();
13128
- });
13129
- }
13130
- function fromPromise(promise) {
13131
- return new Observable(function (subscriber) {
13132
- promise
13133
- .then(function (value) {
13134
- if (!subscriber.closed) {
13135
- subscriber.next(value);
13136
- subscriber.complete();
13137
- }
13138
- }, function (err) { return subscriber.error(err); })
13139
- .then(null, reportUnhandledError);
13140
- });
13141
- }
13142
- function fromIterable(iterable) {
13143
- return new Observable(function (subscriber) {
13144
- var e_1, _a;
13145
- try {
13146
- for (var iterable_1 = __values(iterable), iterable_1_1 = iterable_1.next(); !iterable_1_1.done; iterable_1_1 = iterable_1.next()) {
13147
- var value = iterable_1_1.value;
13148
- subscriber.next(value);
13149
- if (subscriber.closed) {
13150
- return;
13151
- }
13152
- }
13153
- }
13154
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
13155
- finally {
13156
- try {
13157
- if (iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return)) _a.call(iterable_1);
13158
- }
13159
- finally { if (e_1) throw e_1.error; }
13160
- }
13161
- subscriber.complete();
13162
- });
13163
- }
13164
- function fromAsyncIterable(asyncIterable) {
13165
- return new Observable(function (subscriber) {
13166
- process$1(asyncIterable, subscriber).catch(function (err) { return subscriber.error(err); });
13167
- });
13168
- }
13169
- function fromReadableStreamLike(readableStream) {
13170
- return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
13171
- }
13172
- function process$1(asyncIterable, subscriber) {
13173
- var asyncIterable_1, asyncIterable_1_1;
13174
- var e_2, _a;
13175
- return __awaiter(this, void 0, void 0, function () {
13176
- var value, e_2_1;
13177
- return __generator(this, function (_b) {
13178
- switch (_b.label) {
13179
- case 0:
13180
- _b.trys.push([0, 5, 6, 11]);
13181
- asyncIterable_1 = __asyncValues(asyncIterable);
13182
- _b.label = 1;
13183
- case 1: return [4, asyncIterable_1.next()];
13184
- case 2:
13185
- if (!(asyncIterable_1_1 = _b.sent(), !asyncIterable_1_1.done)) return [3, 4];
13186
- value = asyncIterable_1_1.value;
13187
- subscriber.next(value);
13188
- if (subscriber.closed) {
13189
- return [2];
13190
- }
13191
- _b.label = 3;
13192
- case 3: return [3, 1];
13193
- case 4: return [3, 11];
13194
- case 5:
13195
- e_2_1 = _b.sent();
13196
- e_2 = { error: e_2_1 };
13197
- return [3, 11];
13198
- case 6:
13199
- _b.trys.push([6, , 9, 10]);
13200
- if (!(asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return))) return [3, 8];
13201
- return [4, _a.call(asyncIterable_1)];
13202
- case 7:
13203
- _b.sent();
13204
- _b.label = 8;
13205
- case 8: return [3, 10];
13206
- case 9:
13207
- if (e_2) throw e_2.error;
13208
- return [7];
13209
- case 10: return [7];
13210
- case 11:
13211
- subscriber.complete();
13212
- return [2];
13213
- }
13214
- });
13215
- });
13216
- }
13217
-
13218
- function executeSchedule(parentSubscription, scheduler, work, delay, repeat) {
13219
- if (delay === void 0) { delay = 0; }
13220
- if (repeat === void 0) { repeat = false; }
13221
- var scheduleSubscription = scheduler.schedule(function () {
13222
- work();
13223
- if (repeat) {
13224
- parentSubscription.add(this.schedule(null, delay));
13225
- }
13226
- else {
13227
- this.unsubscribe();
13228
- }
13229
- }, delay);
13230
- parentSubscription.add(scheduleSubscription);
13231
- if (!repeat) {
13232
- return scheduleSubscription;
13233
- }
13234
- }
13235
-
13236
- function observeOn(scheduler, delay) {
13237
- if (delay === void 0) { delay = 0; }
13238
- return operate(function (source, subscriber) {
13239
- source.subscribe(createOperatorSubscriber(subscriber, function (value) { return executeSchedule(subscriber, scheduler, function () { return subscriber.next(value); }, delay); }, function () { return executeSchedule(subscriber, scheduler, function () { return subscriber.complete(); }, delay); }, function (err) { return executeSchedule(subscriber, scheduler, function () { return subscriber.error(err); }, delay); }));
13240
- });
13241
- }
13242
-
13243
- function subscribeOn(scheduler, delay) {
13244
- if (delay === void 0) { delay = 0; }
13245
- return operate(function (source, subscriber) {
13246
- subscriber.add(scheduler.schedule(function () { return source.subscribe(subscriber); }, delay));
13247
- });
13248
- }
13249
-
13250
- function scheduleObservable(input, scheduler) {
13251
- return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
13252
- }
13253
-
13254
- function schedulePromise(input, scheduler) {
13255
- return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
13256
- }
13257
-
13258
- function scheduleArray(input, scheduler) {
13259
- return new Observable(function (subscriber) {
13260
- var i = 0;
13261
- return scheduler.schedule(function () {
13262
- if (i === input.length) {
13263
- subscriber.complete();
13264
- }
13265
- else {
13266
- subscriber.next(input[i++]);
13267
- if (!subscriber.closed) {
13268
- this.schedule();
13269
- }
13270
- }
13271
- });
13272
- });
13273
- }
13274
-
13275
- function scheduleIterable(input, scheduler) {
13276
- return new Observable(function (subscriber) {
13277
- var iterator$1;
13278
- executeSchedule(subscriber, scheduler, function () {
13279
- iterator$1 = input[iterator]();
13280
- executeSchedule(subscriber, scheduler, function () {
13281
- var _a;
13282
- var value;
13283
- var done;
13284
- try {
13285
- (_a = iterator$1.next(), value = _a.value, done = _a.done);
13286
- }
13287
- catch (err) {
13288
- subscriber.error(err);
13289
- return;
13290
- }
13291
- if (done) {
13292
- subscriber.complete();
13293
- }
13294
- else {
13295
- subscriber.next(value);
13296
- }
13297
- }, 0, true);
13298
- });
13299
- return function () { return isFunction(iterator$1 === null || iterator$1 === void 0 ? void 0 : iterator$1.return) && iterator$1.return(); };
13300
- });
13301
- }
13302
-
13303
- function scheduleAsyncIterable(input, scheduler) {
13304
- if (!input) {
13305
- throw new Error('Iterable cannot be null');
13306
- }
13307
- return new Observable(function (subscriber) {
13308
- executeSchedule(subscriber, scheduler, function () {
13309
- var iterator = input[Symbol.asyncIterator]();
13310
- executeSchedule(subscriber, scheduler, function () {
13311
- iterator.next().then(function (result) {
13312
- if (result.done) {
13313
- subscriber.complete();
13314
- }
13315
- else {
13316
- subscriber.next(result.value);
13317
- }
13318
- });
13319
- }, 0, true);
13320
- });
13321
- });
13322
- }
13323
-
13324
- function scheduleReadableStreamLike(input, scheduler) {
13325
- return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
13326
- }
13327
-
13328
- function scheduled(input, scheduler) {
13329
- if (input != null) {
13330
- if (isInteropObservable(input)) {
13331
- return scheduleObservable(input, scheduler);
13332
- }
13333
- if (isArrayLike(input)) {
13334
- return scheduleArray(input, scheduler);
13335
- }
13336
- if (isPromise(input)) {
13337
- return schedulePromise(input, scheduler);
13338
- }
13339
- if (isAsyncIterable(input)) {
13340
- return scheduleAsyncIterable(input, scheduler);
13341
- }
13342
- if (isIterable(input)) {
13343
- return scheduleIterable(input, scheduler);
13344
- }
13345
- if (isReadableStreamLike(input)) {
13346
- return scheduleReadableStreamLike(input, scheduler);
13347
- }
13348
- }
13349
- throw createInvalidObservableTypeError(input);
13350
- }
13351
-
13352
- function from(input, scheduler) {
13353
- return scheduler ? scheduled(input, scheduler) : innerFrom(input);
13354
- }
13355
-
13356
- function of() {
13357
- var args = [];
13358
- for (var _i = 0; _i < arguments.length; _i++) {
13359
- args[_i] = arguments[_i];
13360
- }
13361
- var scheduler = popScheduler(args);
13362
- return from(args, scheduler);
13363
- }
13364
-
13365
- function isObservable(obj) {
13366
- return !!obj && (obj instanceof Observable || (isFunction(obj.lift) && isFunction(obj.subscribe)));
13367
- }
13368
-
13369
- var EmptyError = createErrorClass(function (_super) {
13370
- return function EmptyErrorImpl() {
13371
- _super(this);
13372
- this.name = 'EmptyError';
13373
- this.message = 'no elements in sequence';
13374
- };
13375
- });
13376
-
13377
- function lastValueFrom(source, config) {
13378
- var hasConfig = typeof config === 'object';
13379
- return new Promise(function (resolve, reject) {
13380
- var _hasValue = false;
13381
- var _value;
13382
- source.subscribe({
13383
- next: function (value) {
13384
- _value = value;
13385
- _hasValue = true;
13386
- },
13387
- error: reject,
13388
- complete: function () {
13389
- if (_hasValue) {
13390
- resolve(_value);
13391
- }
13392
- else if (hasConfig) {
13393
- resolve(config.defaultValue);
13394
- }
13395
- else {
13396
- reject(new EmptyError());
13397
- }
13398
- },
13399
- });
13400
- });
13401
- }
13402
-
13403
- function map(project, thisArg) {
13404
- return operate(function (source, subscriber) {
13405
- var index = 0;
13406
- source.subscribe(createOperatorSubscriber(subscriber, function (value) {
13407
- subscriber.next(project.call(thisArg, value, index++));
13408
- }));
13409
- });
13410
- }
13411
-
13412
- function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
13413
- var buffer = [];
13414
- var active = 0;
13415
- var index = 0;
13416
- var isComplete = false;
13417
- var checkComplete = function () {
13418
- if (isComplete && !buffer.length && !active) {
13419
- subscriber.complete();
13420
- }
13421
- };
13422
- var outerNext = function (value) { return (active < concurrent ? doInnerSub(value) : buffer.push(value)); };
13423
- var doInnerSub = function (value) {
13424
- expand && subscriber.next(value);
13425
- active++;
13426
- var innerComplete = false;
13427
- innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, function (innerValue) {
13428
- onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);
13429
- if (expand) {
13430
- outerNext(innerValue);
13431
- }
13432
- else {
13433
- subscriber.next(innerValue);
13434
- }
13435
- }, function () {
13436
- innerComplete = true;
13437
- }, undefined, function () {
13438
- if (innerComplete) {
13439
- try {
13440
- active--;
13441
- var _loop_1 = function () {
13442
- var bufferedValue = buffer.shift();
13443
- if (innerSubScheduler) {
13444
- executeSchedule(subscriber, innerSubScheduler, function () { return doInnerSub(bufferedValue); });
13445
- }
13446
- else {
13447
- doInnerSub(bufferedValue);
13448
- }
13449
- };
13450
- while (buffer.length && active < concurrent) {
13451
- _loop_1();
13452
- }
13453
- checkComplete();
13454
- }
13455
- catch (err) {
13456
- subscriber.error(err);
13457
- }
13458
- }
13459
- }));
13460
- };
13461
- source.subscribe(createOperatorSubscriber(subscriber, outerNext, function () {
13462
- isComplete = true;
13463
- checkComplete();
13464
- }));
13465
- return function () {
13466
- additionalFinalizer === null || additionalFinalizer === void 0 ? void 0 : additionalFinalizer();
13467
- };
13468
- }
13469
-
13470
- function mergeMap(project, resultSelector, concurrent) {
13471
- if (concurrent === void 0) { concurrent = Infinity; }
13472
- if (isFunction(resultSelector)) {
13473
- return mergeMap(function (a, i) { return map(function (b, ii) { return resultSelector(a, b, i, ii); })(innerFrom(project(a, i))); }, concurrent);
13474
- }
13475
- else if (typeof resultSelector === 'number') {
13476
- concurrent = resultSelector;
13477
- }
13478
- return operate(function (source, subscriber) { return mergeInternals(source, subscriber, project, concurrent); });
13479
- }
13480
-
13481
- function defer(observableFactory) {
13482
- return new Observable(function (subscriber) {
13483
- innerFrom(observableFactory()).subscribe(subscriber);
13484
- });
13485
- }
13486
-
13487
- function filter(predicate, thisArg) {
13488
- return operate(function (source, subscriber) {
13489
- var index = 0;
13490
- source.subscribe(createOperatorSubscriber(subscriber, function (value) { return predicate.call(thisArg, value, index++) && subscriber.next(value); }));
13491
- });
13492
- }
13493
-
13494
- function scanInternals(accumulator, seed, hasSeed, emitOnNext, emitBeforeComplete) {
13495
- return function (source, subscriber) {
13496
- var hasState = hasSeed;
13497
- var state = seed;
13498
- var index = 0;
13499
- source.subscribe(createOperatorSubscriber(subscriber, function (value) {
13500
- var i = index++;
13501
- state = hasState
13502
- ?
13503
- accumulator(state, value, i)
13504
- :
13505
- ((hasState = true), value);
13506
- emitOnNext && subscriber.next(state);
13507
- }, emitBeforeComplete &&
13508
- (function () {
13509
- hasState && subscriber.next(state);
13510
- subscriber.complete();
13511
- })));
13512
- };
13513
- }
13514
-
13515
- function reduce(accumulator, seed) {
13516
- return operate(scanInternals(accumulator, seed, arguments.length >= 2, false, true));
13517
- }
13518
-
13519
- function concatMap(project, resultSelector) {
13520
- return isFunction(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1);
13521
- }
13522
-
13523
- function getDefaultExportFromCjs (x) {
13524
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
13525
- }
13526
-
13527
- var runAsync$1 = {exports: {}};
13528
-
13529
- var hasRequiredRunAsync;
13530
-
13531
- function requireRunAsync () {
13532
- if (hasRequiredRunAsync) return runAsync$1.exports;
13533
- hasRequiredRunAsync = 1;
13534
-
13535
- function isPromise(obj) {
13536
- return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
13537
- }
13538
-
13539
- /**
13540
- * Return a function that will run a function asynchronously or synchronously
13541
- *
13542
- * example:
13543
- * runAsync(wrappedFunction, callback)(...args);
13544
- *
13545
- * @param {Function} func Function to run
13546
- * @param {Function} [cb] Callback function passed the `func` returned value
13547
- * @param {string} [proxyProperty] `this` property to be used for the callback factory
13548
- * @return {Function(arguments)} Arguments to pass to `func`. This function will in turn
13549
- * return a Promise (Node >= 0.12) or call the callbacks.
13550
- */
13551
-
13552
- var runAsync = runAsync$1.exports = function (func, cb, proxyProperty = 'async') {
13553
- if (typeof cb === 'string') {
13554
- proxyProperty = cb;
13555
- cb = undefined;
13556
- }
13557
- cb = cb || function () {};
13558
-
13559
- return function () {
13560
-
13561
- var args = arguments;
13562
- var originalThis = this;
13563
-
13564
- var promise = new Promise(function (resolve, reject) {
13565
- var resolved = false;
13566
- const wrappedResolve = function (value) {
13567
- if (resolved) {
13568
- console.warn('Run-async promise already resolved.');
13569
- }
13570
- resolved = true;
13571
- resolve(value);
13572
- };
13573
-
13574
- var rejected = false;
13575
- const wrappedReject = function (value) {
13576
- if (rejected) {
13577
- console.warn('Run-async promise already rejected.');
13578
- }
13579
- rejected = true;
13580
- reject(value);
13581
- };
13582
-
13583
- var usingCallback = false;
13584
- var callbackConflict = false;
13585
- var contextEnded = false;
13586
-
13587
- var doneFactory = function () {
13588
- if (contextEnded) {
13589
- console.warn('Run-async async() called outside a valid run-async context, callback will be ignored.');
13590
- return function() {};
13591
- }
13592
- if (callbackConflict) {
13593
- console.warn('Run-async wrapped function (async) returned a promise.\nCalls to async() callback can have unexpected results.');
13594
- }
13595
- usingCallback = true;
13596
- return function (err, value) {
13597
- if (err) {
13598
- wrappedReject(err);
13599
- } else {
13600
- wrappedResolve(value);
13601
- }
13602
- };
13603
- };
13604
-
13605
- var _this;
13606
- if (originalThis && proxyProperty && Proxy) {
13607
- _this = new Proxy(originalThis, {
13608
- get(_target, prop) {
13609
- if (prop === proxyProperty) {
13610
- if (prop in _target) {
13611
- console.warn(`${proxyProperty} property is been shadowed by run-sync`);
13612
- }
13613
- return doneFactory;
13614
- }
13615
-
13616
- return Reflect.get(...arguments);
13617
- },
13618
- });
13619
- } else {
13620
- _this = { [proxyProperty]: doneFactory };
13621
- }
13622
-
13623
- var answer = func.apply(_this, Array.prototype.slice.call(args));
13624
-
13625
- if (usingCallback) {
13626
- if (isPromise(answer)) {
13627
- console.warn('Run-async wrapped function (sync) returned a promise but async() callback must be executed to resolve.');
13628
- }
13629
- } else {
13630
- if (isPromise(answer)) {
13631
- callbackConflict = true;
13632
- answer.then(wrappedResolve, wrappedReject);
13633
- } else {
13634
- wrappedResolve(answer);
13635
- }
13636
- }
13637
- contextEnded = true;
13638
- });
13639
-
13640
- promise.then(cb.bind(null, null), cb);
13641
-
13642
- return promise;
13643
- }
13644
- };
13645
-
13646
- runAsync.cb = function (func, cb) {
13647
- return runAsync(function () {
13648
- var args = Array.prototype.slice.call(arguments);
13649
- if (args.length === func.length - 1) {
13650
- args.push(this.async());
13651
- }
13652
- return func.apply(this, args);
13653
- }, cb);
13654
- };
13655
- return runAsync$1.exports;
13656
- }
13657
-
13658
- var runAsyncExports = requireRunAsync();
13659
- var runAsync = /*@__PURE__*/getDefaultExportFromCjs(runAsyncExports);
13660
-
13661
- var lib;
13662
- var hasRequiredLib;
13663
-
13664
- function requireLib () {
13665
- if (hasRequiredLib) return lib;
13666
- hasRequiredLib = 1;
13667
- const Stream = require$$0;
13668
-
13669
- class MuteStream extends Stream {
13670
- #isTTY = null
13671
-
13672
- constructor (opts = {}) {
13673
- super(opts);
13674
- this.writable = this.readable = true;
13675
- this.muted = false;
13676
- this.on('pipe', this._onpipe);
13677
- this.replace = opts.replace;
13678
-
13679
- // For readline-type situations
13680
- // This much at the start of a line being redrawn after a ctrl char
13681
- // is seen (such as backspace) won't be redrawn as the replacement
13682
- this._prompt = opts.prompt || null;
13683
- this._hadControl = false;
13684
- }
13685
-
13686
- #destSrc (key, def) {
13687
- if (this._dest) {
13688
- return this._dest[key]
13689
- }
13690
- if (this._src) {
13691
- return this._src[key]
13692
- }
13693
- return def
13694
- }
13695
-
13696
- #proxy (method, ...args) {
13697
- if (typeof this._dest?.[method] === 'function') {
13698
- this._dest[method](...args);
13699
- }
13700
- if (typeof this._src?.[method] === 'function') {
13701
- this._src[method](...args);
13702
- }
13703
- }
13704
-
13705
- get isTTY () {
13706
- if (this.#isTTY !== null) {
13707
- return this.#isTTY
13708
- }
13709
- return this.#destSrc('isTTY', false)
13710
- }
13711
-
13712
- // basically just get replace the getter/setter with a regular value
13713
- set isTTY (val) {
13714
- this.#isTTY = val;
13715
- }
13716
-
13717
- get rows () {
13718
- return this.#destSrc('rows')
13719
- }
13720
-
13721
- get columns () {
13722
- return this.#destSrc('columns')
13723
- }
13724
-
13725
- mute () {
13726
- this.muted = true;
13727
- }
13728
-
13729
- unmute () {
13730
- this.muted = false;
13731
- }
13732
-
13733
- _onpipe (src) {
13734
- this._src = src;
13735
- }
13736
-
13737
- pipe (dest, options) {
13738
- this._dest = dest;
13739
- return super.pipe(dest, options)
13740
- }
13741
-
13742
- pause () {
13743
- if (this._src) {
13744
- return this._src.pause()
13745
- }
13746
- }
13747
-
13748
- resume () {
13749
- if (this._src) {
13750
- return this._src.resume()
13751
- }
13752
- }
13753
-
13754
- write (c) {
13755
- if (this.muted) {
13756
- if (!this.replace) {
13757
- return true
13758
- }
13759
- // eslint-disable-next-line no-control-regex
13760
- if (c.match(/^\u001b/)) {
13761
- if (c.indexOf(this._prompt) === 0) {
13762
- c = c.slice(this._prompt.length);
13763
- c = c.replace(/./g, this.replace);
13764
- c = this._prompt + c;
13765
- }
13766
- this._hadControl = true;
13767
- return this.emit('data', c)
13768
- } else {
13769
- if (this._prompt && this._hadControl &&
13770
- c.indexOf(this._prompt) === 0) {
13771
- this._hadControl = false;
13772
- this.emit('data', this._prompt);
13773
- c = c.slice(this._prompt.length);
13774
- }
13775
- c = c.toString().replace(/./g, this.replace);
13776
- }
13777
- }
13778
- this.emit('data', c);
13779
- }
13780
-
13781
- end (c) {
13782
- if (this.muted) {
13783
- if (c && this.replace) {
13784
- c = c.toString().replace(/./g, this.replace);
13785
- } else {
13786
- c = null;
13787
- }
13788
- }
13789
- if (c) {
13790
- this.emit('data', c);
13791
- }
13792
- this.emit('end');
13793
- }
13794
-
13795
- destroy (...args) {
13796
- return this.#proxy('destroy', ...args)
13797
- }
13798
-
13799
- destroySoon (...args) {
13800
- return this.#proxy('destroySoon', ...args)
13801
- }
13802
-
13803
- close (...args) {
13804
- return this.#proxy('close', ...args)
13805
- }
13806
- }
13807
-
13808
- lib = MuteStream;
13809
- return lib;
13810
- }
13811
-
13812
- var libExports = requireLib();
13813
- var MuteStream = /*@__PURE__*/getDefaultExportFromCjs(libExports);
13814
-
13815
- class AbortPromptError extends Error {
13816
- name = 'AbortPromptError';
13817
- message = 'Prompt was aborted';
13818
- constructor(options) {
13819
- super();
13820
- this.cause = options?.cause;
13821
- }
13822
- }
13823
-
13824
- var ansiEscapes$1 = {exports: {}};
13825
-
13826
- var hasRequiredAnsiEscapes;
13827
-
13828
- function requireAnsiEscapes () {
13829
- if (hasRequiredAnsiEscapes) return ansiEscapes$1.exports;
13830
- hasRequiredAnsiEscapes = 1;
13831
- (function (module) {
13832
- const ansiEscapes = module.exports;
13833
- // TODO: remove this in the next major version
13834
- module.exports.default = ansiEscapes;
13835
-
13836
- const ESC = '\u001B[';
13837
- const OSC = '\u001B]';
13838
- const BEL = '\u0007';
13839
- const SEP = ';';
13840
- const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
13841
-
13842
- ansiEscapes.cursorTo = (x, y) => {
13843
- if (typeof x !== 'number') {
13844
- throw new TypeError('The `x` argument is required');
13845
- }
13846
-
13847
- if (typeof y !== 'number') {
13848
- return ESC + (x + 1) + 'G';
13849
- }
13850
-
13851
- return ESC + (y + 1) + ';' + (x + 1) + 'H';
13852
- };
13853
-
13854
- ansiEscapes.cursorMove = (x, y) => {
13855
- if (typeof x !== 'number') {
13856
- throw new TypeError('The `x` argument is required');
13857
- }
13858
-
13859
- let ret = '';
13860
-
13861
- if (x < 0) {
13862
- ret += ESC + (-x) + 'D';
13863
- } else if (x > 0) {
13864
- ret += ESC + x + 'C';
13865
- }
13866
-
13867
- if (y < 0) {
13868
- ret += ESC + (-y) + 'A';
13869
- } else if (y > 0) {
13870
- ret += ESC + y + 'B';
13871
- }
13872
-
13873
- return ret;
13874
- };
13875
-
13876
- ansiEscapes.cursorUp = (count = 1) => ESC + count + 'A';
13877
- ansiEscapes.cursorDown = (count = 1) => ESC + count + 'B';
13878
- ansiEscapes.cursorForward = (count = 1) => ESC + count + 'C';
13879
- ansiEscapes.cursorBackward = (count = 1) => ESC + count + 'D';
13880
-
13881
- ansiEscapes.cursorLeft = ESC + 'G';
13882
- ansiEscapes.cursorSavePosition = isTerminalApp ? '\u001B7' : ESC + 's';
13883
- ansiEscapes.cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC + 'u';
13884
- ansiEscapes.cursorGetPosition = ESC + '6n';
13885
- ansiEscapes.cursorNextLine = ESC + 'E';
13886
- ansiEscapes.cursorPrevLine = ESC + 'F';
13887
- ansiEscapes.cursorHide = ESC + '?25l';
13888
- ansiEscapes.cursorShow = ESC + '?25h';
13889
-
13890
- ansiEscapes.eraseLines = count => {
13891
- let clear = '';
13892
-
13893
- for (let i = 0; i < count; i++) {
13894
- clear += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : '');
13895
- }
13896
-
13897
- if (count) {
13898
- clear += ansiEscapes.cursorLeft;
13899
- }
13900
-
13901
- return clear;
13902
- };
13903
-
13904
- ansiEscapes.eraseEndLine = ESC + 'K';
13905
- ansiEscapes.eraseStartLine = ESC + '1K';
13906
- ansiEscapes.eraseLine = ESC + '2K';
13907
- ansiEscapes.eraseDown = ESC + 'J';
13908
- ansiEscapes.eraseUp = ESC + '1J';
13909
- ansiEscapes.eraseScreen = ESC + '2J';
13910
- ansiEscapes.scrollUp = ESC + 'S';
13911
- ansiEscapes.scrollDown = ESC + 'T';
13912
-
13913
- ansiEscapes.clearScreen = '\u001Bc';
13914
-
13915
- ansiEscapes.clearTerminal = process.platform === 'win32' ?
13916
- `${ansiEscapes.eraseScreen}${ESC}0f` :
13917
- // 1. Erases the screen (Only done in case `2` is not supported)
13918
- // 2. Erases the whole screen including scrollback buffer
13919
- // 3. Moves cursor to the top-left position
13920
- // More info: https://www.real-world-systems.com/docs/ANSIcode.html
13921
- `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
13922
-
13923
- ansiEscapes.beep = BEL;
13924
-
13925
- ansiEscapes.link = (text, url) => {
13926
- return [
13927
- OSC,
13928
- '8',
13929
- SEP,
13930
- SEP,
13931
- url,
13932
- BEL,
13933
- text,
13934
- OSC,
13935
- '8',
13936
- SEP,
13937
- SEP,
13938
- BEL
13939
- ].join('');
13940
- };
13941
-
13942
- ansiEscapes.image = (buffer, options = {}) => {
13943
- let ret = `${OSC}1337;File=inline=1`;
13944
-
13945
- if (options.width) {
13946
- ret += `;width=${options.width}`;
13947
- }
13948
-
13949
- if (options.height) {
13950
- ret += `;height=${options.height}`;
13951
- }
13952
-
13953
- if (options.preserveAspectRatio === false) {
13954
- ret += ';preserveAspectRatio=0';
13955
- }
13956
-
13957
- return ret + ':' + buffer.toString('base64') + BEL;
13958
- };
13959
-
13960
- ansiEscapes.iTerm = {
13961
- setCwd: (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
13962
-
13963
- annotation: (message, options = {}) => {
13964
- let ret = `${OSC}1337;`;
13965
-
13966
- const hasX = typeof options.x !== 'undefined';
13967
- const hasY = typeof options.y !== 'undefined';
13968
- if ((hasX || hasY) && !(hasX && hasY && typeof options.length !== 'undefined')) {
13969
- throw new Error('`x`, `y` and `length` must be defined when `x` or `y` is defined');
13970
- }
13971
-
13972
- message = message.replace(/\|/g, '');
13973
-
13974
- ret += options.isHidden ? 'AddHiddenAnnotation=' : 'AddAnnotation=';
13975
-
13976
- if (options.length > 0) {
13977
- ret +=
13978
- (hasX ?
13979
- [message, options.length, options.x, options.y] :
13980
- [options.length, message]).join('|');
13981
- } else {
13982
- ret += message;
13983
- }
13984
-
13985
- return ret + BEL;
13986
- }
13987
- };
13988
- } (ansiEscapes$1));
13989
- return ansiEscapes$1.exports;
13990
- }
13991
-
13992
- var ansiEscapesExports = requireAnsiEscapes();
13993
- var ansiEscapes = /*@__PURE__*/getDefaultExportFromCjs(ansiEscapesExports);
13994
-
13995
- /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-assignment */
13996
- const _ = {
13997
- set: (obj, path = '', value) => {
13998
- let pointer = obj;
13999
- path.split('.').forEach((key, index, arr) => {
14000
- if (key === '__proto__' || key === 'constructor')
14001
- return;
14002
- if (index === arr.length - 1) {
14003
- pointer[key] = value;
14004
- }
14005
- else if (!(key in pointer) || typeof pointer[key] !== 'object') {
14006
- pointer[key] = {};
14007
- }
14008
- pointer = pointer[key];
14009
- });
14010
- },
14011
- get: (obj, path = '', defaultValue) => {
14012
- const travel = (regexp) => String.prototype.split
14013
- .call(path, regexp)
14014
- .filter(Boolean)
14015
- .reduce(
14016
- // @ts-expect-error implicit any on res[key]
14017
- (res, key) => (res == null ? res : res[key]), obj);
14018
- const result = travel(/[,[\]]+?/) || travel(/[,.[\]]+?/);
14019
- return result === undefined || result === obj ? defaultValue : result;
14020
- },
14021
- };
14022
- /**
14023
- * Resolve a question property value if it is passed as a function.
14024
- * This method will overwrite the property on the question object with the received value.
14025
- */
14026
- async function fetchAsyncQuestionProperty(question, prop, answers) {
14027
- const propGetter = question[prop];
14028
- if (typeof propGetter === 'function') {
14029
- return runAsync(propGetter)(answers);
14030
- }
14031
- return propGetter;
14032
- }
14033
- class TTYError extends Error {
14034
- name = 'TTYError';
14035
- isTtyError = true;
14036
- }
14037
- function setupReadlineOptions(opt) {
14038
- // Inquirer 8.x:
14039
- // opt.skipTTYChecks = opt.skipTTYChecks === undefined ? opt.input !== undefined : opt.skipTTYChecks;
14040
- opt.skipTTYChecks = opt.skipTTYChecks === undefined ? true : opt.skipTTYChecks;
14041
- // Default `input` to stdin
14042
- const input = opt.input || process.stdin;
14043
- // Check if prompt is being called in TTY environment
14044
- // If it isn't return a failed promise
14045
- // @ts-expect-error: ignore isTTY type error
14046
- if (!opt.skipTTYChecks && !input.isTTY) {
14047
- throw new TTYError('Prompts can not be meaningfully rendered in non-TTY environments');
14048
- }
14049
- // Add mute capabilities to the output
14050
- const ms = new MuteStream();
14051
- ms.pipe(opt.output || process.stdout);
14052
- const output = ms;
14053
- return {
14054
- terminal: true,
14055
- ...opt,
14056
- input,
14057
- output,
14058
- };
14059
- }
14060
- function isQuestionArray(questions) {
14061
- return Array.isArray(questions);
14062
- }
14063
- function isQuestionMap(questions) {
14064
- return Object.values(questions).every((maybeQuestion) => typeof maybeQuestion === 'object' &&
14065
- !Array.isArray(maybeQuestion) &&
14066
- maybeQuestion != null);
14067
- }
14068
- function isPromptConstructor(prompt) {
14069
- return Boolean(prompt.prototype &&
14070
- 'run' in prompt.prototype &&
14071
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
14072
- typeof prompt.prototype.run === 'function');
14073
- }
14074
- /**
14075
- * Base interface class other can inherits from
14076
- */
14077
- class PromptsRunner {
14078
- prompts;
14079
- answers = {};
14080
- process = EMPTY;
14081
- abortController = new AbortController();
14082
- opt;
14083
- constructor(prompts, opt = {}) {
14084
- this.opt = opt;
14085
- this.prompts = prompts;
14086
- }
14087
- async run(questions, answers) {
14088
- this.abortController = new AbortController();
14089
- // Keep global reference to the answers
14090
- this.answers = typeof answers === 'object' ? { ...answers } : {};
14091
- let obs;
14092
- if (isQuestionArray(questions)) {
14093
- obs = from(questions);
14094
- }
14095
- else if (isObservable(questions)) {
14096
- obs = questions;
14097
- }
14098
- else if (isQuestionMap(questions)) {
14099
- // Case: Called with a set of { name: question }
14100
- obs = from(Object.entries(questions).map(([name, question]) => {
14101
- return Object.assign({}, question, { name });
14102
- }));
14103
- }
14104
- else {
14105
- // Case: Called with a single question config
14106
- obs = from([questions]);
14107
- }
14108
- this.process = obs.pipe(concatMap((question) => of(question).pipe(concatMap((question) => from(this.shouldRun(question).then((shouldRun) => {
14109
- if (shouldRun) {
14110
- return question;
14111
- }
14112
- return;
14113
- })).pipe(filter((val) => val != null))), concatMap((question) => defer(() => from(this.fetchAnswer(question)))))));
14114
- return lastValueFrom(this.process.pipe(reduce((answersObj, answer) => {
14115
- _.set(answersObj, answer.name, answer.answer);
14116
- return answersObj;
14117
- }, this.answers)))
14118
- .then(() => this.answers)
14119
- .finally(() => this.close());
14120
- }
14121
- prepareQuestion = async (question) => {
14122
- const [message, defaultValue, resolvedChoices] = await Promise.all([
14123
- fetchAsyncQuestionProperty(question, 'message', this.answers),
14124
- fetchAsyncQuestionProperty(question, 'default', this.answers),
14125
- fetchAsyncQuestionProperty(question, 'choices', this.answers),
14126
- ]);
14127
- let choices;
14128
- if (Array.isArray(resolvedChoices)) {
14129
- choices = resolvedChoices.map((choice) => {
14130
- const choiceObj = typeof choice !== 'object' || choice == null
14131
- ? { name: choice, value: choice }
14132
- : {
14133
- ...choice,
14134
- value: 'value' in choice
14135
- ? choice.value
14136
- : 'name' in choice
14137
- ? choice.name
14138
- : undefined,
14139
- };
14140
- if ('value' in choiceObj && Array.isArray(defaultValue)) {
14141
- // Add checked to question for backward compatibility. default was supported as alternative of per choice checked.
14142
- return {
14143
- checked: defaultValue.includes(choiceObj.value),
14144
- ...choiceObj,
14145
- };
14146
- }
14147
- return choiceObj;
14148
- });
14149
- }
14150
- return Object.assign({}, question, {
14151
- message,
14152
- default: defaultValue,
14153
- choices,
14154
- type: question.type in this.prompts ? question.type : 'input',
14155
- });
14156
- };
14157
- fetchAnswer = async (rawQuestion) => {
14158
- const question = await this.prepareQuestion(rawQuestion);
14159
- const prompt = this.prompts[question.type];
14160
- if (prompt == null) {
14161
- throw new Error(`Prompt for type ${question.type} not found`);
14162
- }
14163
- let cleanupSignal;
14164
- const promptFn = isPromptConstructor(prompt)
14165
- ? (q, opt) => new Promise((resolve, reject) => {
14166
- const { signal } = opt;
14167
- if (signal.aborted) {
14168
- reject(new AbortPromptError({ cause: signal.reason }));
14169
- return;
14170
- }
14171
- const rl = readline$1.createInterface(setupReadlineOptions(opt));
14172
- /**
14173
- * Handle the ^C exit
14174
- */
14175
- const onForceClose = () => {
14176
- this.close();
14177
- process.kill(process.pid, 'SIGINT');
14178
- console.log('');
14179
- };
14180
- const onClose = () => {
14181
- process.removeListener('exit', onForceClose);
14182
- rl.removeListener('SIGINT', onForceClose);
14183
- rl.setPrompt('');
14184
- rl.output.unmute();
14185
- rl.output.write(ansiEscapes.cursorShow);
14186
- rl.output.end();
14187
- rl.close();
14188
- };
14189
- // Make sure new prompt start on a newline when closing
14190
- process.on('exit', onForceClose);
14191
- rl.on('SIGINT', onForceClose);
14192
- const activePrompt = new prompt(q, rl, this.answers);
14193
- const cleanup = () => {
14194
- onClose();
14195
- cleanupSignal?.();
14196
- };
14197
- const abort = () => {
14198
- reject(new AbortPromptError({ cause: signal.reason }));
14199
- cleanup();
14200
- };
14201
- signal.addEventListener('abort', abort);
14202
- cleanupSignal = () => {
14203
- signal.removeEventListener('abort', abort);
14204
- cleanupSignal = undefined;
14205
- };
14206
- // eslint-disable-next-line @typescript-eslint/use-unknown-in-catch-callback-variable
14207
- activePrompt.run().then(resolve, reject).finally(cleanup);
14208
- })
14209
- : prompt;
14210
- let cleanupModuleSignal;
14211
- const { signal: moduleSignal } = this.opt;
14212
- if (moduleSignal?.aborted) {
14213
- this.abortController.abort(moduleSignal.reason);
14214
- }
14215
- else if (moduleSignal) {
14216
- const abort = () => this.abortController.abort(moduleSignal.reason);
14217
- moduleSignal.addEventListener('abort', abort);
14218
- cleanupModuleSignal = () => {
14219
- moduleSignal.removeEventListener('abort', abort);
14220
- };
14221
- }
14222
- const { filter = (value) => value } = question;
14223
- const { signal } = this.abortController;
14224
- return promptFn(question, { ...this.opt, signal })
14225
- .then((answer) => ({
14226
- name: question.name,
14227
- answer: filter(answer, this.answers),
14228
- }))
14229
- .finally(() => {
14230
- cleanupSignal?.();
14231
- cleanupModuleSignal?.();
14232
- });
14233
- };
14234
- /**
14235
- * Close the interface and cleanup listeners
14236
- */
14237
- close = () => {
14238
- this.abortController.abort();
14239
- };
14240
- shouldRun = async (question) => {
14241
- if (question.askAnswered !== true &&
14242
- _.get(this.answers, question.name) !== undefined) {
14243
- return false;
14244
- }
14245
- const { when } = question;
14246
- if (typeof when === 'function') {
14247
- const shouldRun = await runAsync(when)(this.answers);
14248
- return Boolean(shouldRun);
14249
- }
14250
- return when !== false;
14251
- };
14252
- }
14253
-
14254
- /**
14255
- * Inquirer.js
14256
- * A collection of common interactive command line user interfaces.
14257
- */
14258
- const builtInPrompts = {
14259
- input,
14260
- select,
14261
- /** @deprecated `list` is now named `select` */
14262
- list: select,
14263
- number,
14264
- confirm,
14265
- rawlist,
14266
- expand,
14267
- checkbox,
14268
- password,
14269
- editor,
14270
- search,
14271
- };
14272
- /**
14273
- * Create a new self-contained prompt module.
14274
- */
14275
- function createPromptModule(opt) {
14276
- function promptModule(questions, answers) {
14277
- const runner = new PromptsRunner(promptModule.prompts, opt);
14278
- const promptPromise = runner.run(questions, answers);
14279
- return Object.assign(promptPromise, { ui: runner });
14280
- }
14281
- promptModule.prompts = { ...builtInPrompts };
14282
- /**
14283
- * Register a prompt type
14284
- */
14285
- promptModule.registerPrompt = function (name, prompt) {
14286
- promptModule.prompts[name] = prompt;
14287
- return this;
14288
- };
14289
- /**
14290
- * Register the defaults provider prompts
14291
- */
14292
- promptModule.restoreDefaultPrompts = function () {
14293
- promptModule.prompts = { ...builtInPrompts };
14294
- };
14295
- return promptModule;
14296
- }
14297
- /**
14298
- * Public CLI helper interface
14299
- */
14300
- const prompt = createPromptModule();
14301
- // Expose helper functions on the top level for easiest usage by common users
14302
- function registerPrompt(name, newPrompt) {
14303
- prompt.registerPrompt(name, newPrompt);
14304
- }
14305
- function restoreDefaultPrompts() {
14306
- prompt.restoreDefaultPrompts();
14307
- }
14308
- const inquirer = {
14309
- prompt,
14310
- ui: {
14311
- Prompt: PromptsRunner,
14312
- },
14313
- createPromptModule,
14314
- registerPrompt,
14315
- restoreDefaultPrompts,
14316
- Separator,
14317
- };
14318
- var inquirer$1 = inquirer;
14319
-
14320
12315
  class TaskList {
14321
12316
  constructor(items) {
14322
12317
  this.currentIndex = 0;
@@ -14348,14 +12343,10 @@ class TaskList {
14348
12343
  ];
14349
12344
  }
14350
12345
  async promptAction() {
14351
- const { action } = await inquirer$1.prompt([
14352
- {
14353
- type: 'list',
14354
- name: 'action',
14355
- message: 'Choose an action:',
14356
- choices: this.getChoices(),
14357
- },
14358
- ]);
12346
+ const action = await select({
12347
+ message: 'Choose an action:',
12348
+ choices: this.getChoices(),
12349
+ });
14359
12350
  return action;
14360
12351
  }
14361
12352
  async openFile() {