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