toiljs 0.0.85 → 0.0.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +2 -2
- package/build/cli/.tsbuildinfo +1 -1
- package/build/cli/index.js +303 -293
- package/build/compiler/.tsbuildinfo +1 -1
- package/build/compiler/config.d.ts +2 -0
- package/build/compiler/config.js +1 -0
- package/build/compiler/docs.js +8 -24
- package/build/compiler/generate.js +4 -2
- package/build/compiler/index.d.ts +1 -1
- package/build/compiler/index.js +69 -6
- package/build/compiler/toil-docs.generated.js +64 -22
- package/build/devserver/.tsbuildinfo +1 -1
- package/build/devserver/analytics/index.js +7 -3
- package/build/devserver/db/database.d.ts +4 -0
- package/build/devserver/db/database.js +43 -1
- package/build/devserver/db/index.d.ts +1 -1
- package/build/devserver/db/index.js +1 -1
- package/build/devserver/db/types.d.ts +3 -0
- package/build/devserver/db/types.js +2 -0
- package/build/devserver/runtime/module.js +4 -1
- package/docs/README.md +104 -65
- package/docs/auth/README.md +102 -0
- package/docs/auth/configuration.md +94 -0
- package/docs/auth/extending.md +202 -0
- package/docs/auth/how-it-works.md +138 -0
- package/docs/auth/usage.md +188 -0
- package/docs/backend/README.md +143 -0
- package/docs/backend/data.md +351 -0
- package/docs/backend/rest.md +402 -0
- package/docs/backend/rpc.md +226 -0
- package/docs/background/README.md +114 -0
- package/docs/background/daemons.md +230 -0
- package/docs/background/derive.md +179 -0
- package/docs/cli/README.md +377 -0
- package/docs/concepts/config.md +416 -0
- package/docs/concepts/decorators.md +127 -0
- package/docs/concepts/security.md +108 -0
- package/docs/concepts/tiers.md +166 -0
- package/docs/concepts/types.md +216 -0
- package/docs/database/README.md +143 -0
- package/docs/database/capacity.md +350 -0
- package/docs/database/counters.md +174 -0
- package/docs/database/documents.md +255 -0
- package/docs/database/events.md +307 -0
- package/docs/database/membership.md +246 -0
- package/docs/database/setup.md +155 -0
- package/docs/database/unique.md +216 -0
- package/docs/database/views.md +246 -0
- package/docs/frontend/README.md +101 -0
- package/docs/frontend/data-fetching.md +243 -0
- package/docs/frontend/images.md +148 -0
- package/docs/frontend/metadata.md +344 -0
- package/docs/frontend/rendering.md +236 -0
- package/docs/frontend/routing.md +344 -0
- package/docs/frontend/scripts.md +118 -0
- package/docs/frontend/search.md +191 -0
- package/docs/frontend/styling.md +147 -0
- package/docs/getting-started/README.md +81 -0
- package/docs/getting-started/create-project.md +131 -0
- package/docs/getting-started/deploy.md +101 -0
- package/docs/getting-started/first-app.md +215 -0
- package/docs/getting-started/installation.md +106 -0
- package/docs/getting-started/migrating.md +125 -0
- package/docs/getting-started/project-structure.md +163 -0
- package/docs/introduction/README.md +41 -0
- package/docs/introduction/design-principles.md +55 -0
- package/docs/introduction/distributed.md +74 -0
- package/docs/introduction/how-it-works.md +74 -0
- package/docs/introduction/hyperscale.md +51 -0
- package/docs/introduction/modern-stack.md +36 -0
- package/docs/introduction/vs-other-frameworks.md +48 -0
- package/docs/introduction/why-toil.md +93 -0
- package/docs/llms.txt +90 -0
- package/docs/realtime/README.md +102 -0
- package/docs/realtime/channels.md +211 -0
- package/docs/realtime/streams.md +369 -0
- package/docs/services/README.md +60 -0
- package/docs/services/analytics.md +268 -0
- package/docs/services/caching.md +175 -0
- package/docs/services/cookies.md +235 -0
- package/docs/services/crypto.md +209 -0
- package/docs/services/email.md +289 -0
- package/docs/services/environment.md +141 -0
- package/docs/services/ratelimit.md +174 -0
- package/docs/services/time.md +85 -0
- package/examples/basic/client/routes/analytics.tsx +13 -12
- package/examples/basic/server/models/SiteAnalytics.ts +29 -17
- package/examples/basic/server/routes/Analytics.ts +15 -17
- package/examples/basic/server/routes/UserId.ts +22 -0
- package/package.json +15 -11
- package/scripts/gen-toil-docs.mjs +24 -35
- package/server/auth/AuthController.ts +336 -0
- package/server/auth/AuthUser.ts +23 -0
- package/server/auth/index.ts +16 -0
- package/server/globals/auth.ts +31 -0
- package/server/globals/userid.ts +107 -0
- package/src/compiler/config.ts +13 -0
- package/src/compiler/docs.ts +16 -33
- package/src/compiler/generate.ts +6 -2
- package/src/compiler/index.ts +114 -6
- package/src/compiler/toil-docs.generated.ts +64 -22
- package/src/devserver/analytics/index.ts +10 -4
- package/src/devserver/db/database.ts +67 -1
- package/src/devserver/db/index.ts +1 -0
- package/src/devserver/db/types.ts +13 -0
- package/src/devserver/runtime/module.ts +7 -0
- package/test/analytics-dev.test.ts +2 -1
- package/test/devserver-database.test.ts +113 -0
- package/docs/auth-todo.md +0 -149
- package/docs/auth.md +0 -322
- package/docs/caching.md +0 -115
- package/docs/cli.md +0 -17
- package/docs/client.md +0 -39
- package/docs/cookies.md +0 -457
- package/docs/crypto.md +0 -130
- package/docs/daemon.md +0 -123
- package/docs/data.md +0 -131
- package/docs/derive.md +0 -159
- package/docs/email.md +0 -326
- package/docs/environment.md +0 -97
- package/docs/getting-started.md +0 -128
- package/docs/index.md +0 -30
- package/docs/ratelimit.md +0 -95
- package/docs/routing.md +0 -259
- package/docs/rpc.md +0 -149
- package/docs/server.md +0 -61
- package/docs/ssr.md +0 -632
- package/docs/streams.md +0 -178
- package/docs/styling.md +0 -22
- package/docs/tiers.md +0 -133
- package/docs/time.md +0 -43
package/build/cli/index.js
CHANGED
|
@@ -509,13 +509,13 @@ function wrapAnsi(string, columns, options) {
|
|
|
509
509
|
// node_modules/@clack/core/dist/index.mjs
|
|
510
510
|
var import_sisteransi = __toESM(require_src(), 1);
|
|
511
511
|
import { ReadStream } from "node:tty";
|
|
512
|
-
function findCursor(s,
|
|
512
|
+
function findCursor(s, o, l2) {
|
|
513
513
|
if (!l2.some((r2) => !r2.disabled))
|
|
514
514
|
return s;
|
|
515
|
-
const t2 = s +
|
|
516
|
-
return l2[e]
|
|
515
|
+
const t2 = s + o, n3 = Math.max(l2.length - 1, 0), e = t2 < 0 ? n3 : t2 > n3 ? 0 : t2;
|
|
516
|
+
return l2[e]?.disabled ? findCursor(e, o < 0 ? -1 : 1, l2) : e;
|
|
517
517
|
}
|
|
518
|
-
var a$
|
|
518
|
+
var a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
519
519
|
var t = [
|
|
520
520
|
"January",
|
|
521
521
|
"February",
|
|
@@ -531,7 +531,7 @@ var t = [
|
|
|
531
531
|
"December"
|
|
532
532
|
];
|
|
533
533
|
var settings = {
|
|
534
|
-
actions: new Set(a$
|
|
534
|
+
actions: new Set(a$1),
|
|
535
535
|
aliases: /* @__PURE__ */ new Map([
|
|
536
536
|
// vim support
|
|
537
537
|
["k", "up"],
|
|
@@ -552,16 +552,16 @@ var settings = {
|
|
|
552
552
|
messages: {
|
|
553
553
|
required: "Please enter a valid date",
|
|
554
554
|
invalidMonth: "There are only 12 months in a year",
|
|
555
|
-
invalidDay: (
|
|
556
|
-
afterMin: (
|
|
557
|
-
beforeMax: (
|
|
555
|
+
invalidDay: (n3, e) => `There are only ${n3} days in ${e}`,
|
|
556
|
+
afterMin: (n3) => `Date must be on or after ${n3.toISOString().slice(0, 10)}`,
|
|
557
|
+
beforeMax: (n3) => `Date must be on or before ${n3.toISOString().slice(0, 10)}`
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
560
|
};
|
|
561
|
-
function isActionKey(
|
|
562
|
-
if (typeof
|
|
563
|
-
return settings.aliases.get(
|
|
564
|
-
for (const s of
|
|
561
|
+
function isActionKey(n3, e) {
|
|
562
|
+
if (typeof n3 == "string")
|
|
563
|
+
return settings.aliases.get(n3) === e;
|
|
564
|
+
for (const s of n3)
|
|
565
565
|
if (s !== void 0 && isActionKey(s, e))
|
|
566
566
|
return true;
|
|
567
567
|
return false;
|
|
@@ -571,8 +571,8 @@ function diffLines(i2, s) {
|
|
|
571
571
|
const e = i2.split(`
|
|
572
572
|
`), t2 = s.split(`
|
|
573
573
|
`), r2 = Math.max(e.length, t2.length), f = [];
|
|
574
|
-
for (let
|
|
575
|
-
e[
|
|
574
|
+
for (let n3 = 0; n3 < r2; n3++)
|
|
575
|
+
e[n3] !== t2[n3] && f.push(n3);
|
|
576
576
|
return {
|
|
577
577
|
lines: f,
|
|
578
578
|
numLinesBefore: e.length,
|
|
@@ -586,13 +586,13 @@ function isCancel(e) {
|
|
|
586
586
|
return e === CANCEL_SYMBOL;
|
|
587
587
|
}
|
|
588
588
|
function setRawMode(e, r2) {
|
|
589
|
-
const
|
|
590
|
-
|
|
589
|
+
const o = e;
|
|
590
|
+
o.isTTY && o.setRawMode(r2);
|
|
591
591
|
}
|
|
592
592
|
function block({
|
|
593
593
|
input: e = stdin,
|
|
594
594
|
output: r2 = stdout,
|
|
595
|
-
overwrite:
|
|
595
|
+
overwrite: o = true,
|
|
596
596
|
hideCursor: t2 = true
|
|
597
597
|
} = {}) {
|
|
598
598
|
const s = l.createInterface({
|
|
@@ -602,48 +602,48 @@ function block({
|
|
|
602
602
|
tabSize: 1
|
|
603
603
|
});
|
|
604
604
|
l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
|
|
605
|
-
const
|
|
605
|
+
const n3 = (f, { name: a2, sequence: p }) => {
|
|
606
606
|
const c2 = String(f);
|
|
607
|
-
if (isActionKey([c2,
|
|
607
|
+
if (isActionKey([c2, a2, p], "cancel")) {
|
|
608
608
|
t2 && r2.write(import_sisteransi.cursor.show), process.exit(0);
|
|
609
609
|
return;
|
|
610
610
|
}
|
|
611
|
-
if (!
|
|
612
|
-
const i2 =
|
|
611
|
+
if (!o) return;
|
|
612
|
+
const i2 = a2 === "return" ? 0 : -1, m2 = a2 === "return" ? -1 : 0;
|
|
613
613
|
l.moveCursor(r2, i2, m2, () => {
|
|
614
614
|
l.clearLine(r2, 1, () => {
|
|
615
|
-
e.once("keypress",
|
|
615
|
+
e.once("keypress", n3);
|
|
616
616
|
});
|
|
617
617
|
});
|
|
618
618
|
};
|
|
619
|
-
return t2 && r2.write(import_sisteransi.cursor.hide), e.once("keypress",
|
|
620
|
-
e.off("keypress",
|
|
619
|
+
return t2 && r2.write(import_sisteransi.cursor.hide), e.once("keypress", n3), () => {
|
|
620
|
+
e.off("keypress", n3), t2 && r2.write(import_sisteransi.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
|
|
621
621
|
};
|
|
622
622
|
}
|
|
623
623
|
var getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
|
|
624
624
|
var getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
625
|
-
function wrapTextWithPrefix(e, r2,
|
|
625
|
+
function wrapTextWithPrefix(e, r2, o, t2 = o, s = o, n3) {
|
|
626
626
|
const f = getColumns(e ?? stdout);
|
|
627
|
-
return wrapAnsi(r2, f -
|
|
627
|
+
return wrapAnsi(r2, f - o.length, {
|
|
628
628
|
hard: true,
|
|
629
629
|
trim: false
|
|
630
630
|
}).split(`
|
|
631
631
|
`).map((c2, i2, m2) => {
|
|
632
|
-
const d =
|
|
633
|
-
return i2 === 0 ? `${t2}${d}` : i2 === m2.length - 1 ? `${s}${d}` : `${
|
|
632
|
+
const d = n3 ? n3(c2, i2) : c2;
|
|
633
|
+
return i2 === 0 ? `${t2}${d}` : i2 === m2.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
634
634
|
}).join(`
|
|
635
635
|
`);
|
|
636
636
|
}
|
|
637
|
-
function runValidation(e,
|
|
637
|
+
function runValidation(e, n3) {
|
|
638
638
|
if ("~standard" in e) {
|
|
639
|
-
const
|
|
640
|
-
if (
|
|
639
|
+
const a2 = e["~standard"].validate(n3);
|
|
640
|
+
if (a2 instanceof Promise)
|
|
641
641
|
throw new TypeError(
|
|
642
642
|
"Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic."
|
|
643
643
|
);
|
|
644
|
-
return
|
|
644
|
+
return a2.issues?.at(0)?.message;
|
|
645
645
|
}
|
|
646
|
-
return e(
|
|
646
|
+
return e(n3);
|
|
647
647
|
}
|
|
648
648
|
var V = class {
|
|
649
649
|
input;
|
|
@@ -661,8 +661,8 @@ var V = class {
|
|
|
661
661
|
value;
|
|
662
662
|
userInput = "";
|
|
663
663
|
constructor(t2, e = true) {
|
|
664
|
-
const { input: i2 = stdin, output:
|
|
665
|
-
this.opts =
|
|
664
|
+
const { input: i2 = stdin, output: n3 = stdout, render: s, signal: r2, ...o } = t2;
|
|
665
|
+
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r2, this.input = i2, this.output = n3;
|
|
666
666
|
}
|
|
667
667
|
/**
|
|
668
668
|
* Unsubscribe all listeners
|
|
@@ -700,10 +700,10 @@ var V = class {
|
|
|
700
700
|
* @param data - The data to pass to the callback
|
|
701
701
|
*/
|
|
702
702
|
emit(t2, ...e) {
|
|
703
|
-
const i2 = this._subscribers.get(t2) ?? [],
|
|
703
|
+
const i2 = this._subscribers.get(t2) ?? [], n3 = [];
|
|
704
704
|
for (const s of i2)
|
|
705
|
-
s.cb(...e), s.once &&
|
|
706
|
-
for (const s of
|
|
705
|
+
s.cb(...e), s.once && n3.push(() => i2.splice(i2.indexOf(s), 1));
|
|
706
|
+
for (const s of n3)
|
|
707
707
|
s();
|
|
708
708
|
}
|
|
709
709
|
prompt() {
|
|
@@ -777,21 +777,21 @@ var V = class {
|
|
|
777
777
|
else {
|
|
778
778
|
const e = diffLines(this._prevFrame, t2), i2 = getRows(this.output);
|
|
779
779
|
if (this.restoreCursor(), e) {
|
|
780
|
-
const
|
|
781
|
-
let r2 = e.lines.find((
|
|
780
|
+
const n3 = Math.max(0, e.numLinesAfter - i2), s = Math.max(0, e.numLinesBefore - i2);
|
|
781
|
+
let r2 = e.lines.find((o) => o >= n3);
|
|
782
782
|
if (r2 === void 0) {
|
|
783
783
|
this._prevFrame = t2;
|
|
784
784
|
return;
|
|
785
785
|
}
|
|
786
786
|
if (e.lines.length === 1) {
|
|
787
787
|
this.output.write(import_sisteransi.cursor.move(0, r2 - s)), this.output.write(import_sisteransi.erase.lines(1));
|
|
788
|
-
const
|
|
788
|
+
const o = t2.split(`
|
|
789
789
|
`);
|
|
790
|
-
this.output.write(
|
|
790
|
+
this.output.write(o[r2]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o.length - r2 - 1));
|
|
791
791
|
return;
|
|
792
792
|
} else if (e.lines.length > 1) {
|
|
793
|
-
if (
|
|
794
|
-
r2 =
|
|
793
|
+
if (n3 < s)
|
|
794
|
+
r2 = n3;
|
|
795
795
|
else {
|
|
796
796
|
const h2 = r2 - s;
|
|
797
797
|
h2 > 0 && this.output.write(import_sisteransi.cursor.move(0, h2));
|
|
@@ -827,11 +827,11 @@ var r = class extends V {
|
|
|
827
827
|
});
|
|
828
828
|
}
|
|
829
829
|
};
|
|
830
|
-
var a
|
|
830
|
+
var a = class extends V {
|
|
831
831
|
options;
|
|
832
832
|
cursor = 0;
|
|
833
833
|
get _value() {
|
|
834
|
-
return this.options[this.cursor]
|
|
834
|
+
return this.options[this.cursor]?.value;
|
|
835
835
|
}
|
|
836
836
|
get _enabledOptions() {
|
|
837
837
|
return this.options.filter((e) => e.disabled !== true);
|
|
@@ -858,7 +858,7 @@ var a$1 = class a extends V {
|
|
|
858
858
|
this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt),
|
|
859
859
|
0
|
|
860
860
|
);
|
|
861
|
-
this.cursor = this.options[i2]
|
|
861
|
+
this.cursor = this.options[i2]?.disabled ? findCursor(i2, 1, this.options) : i2, this.on("key", (t2, l2) => {
|
|
862
862
|
l2.name === "a" && this.toggleAll(), l2.name === "i" && this.toggleInvert();
|
|
863
863
|
}), this.on("cursor", (t2) => {
|
|
864
864
|
switch (t2) {
|
|
@@ -877,19 +877,20 @@ var a$1 = class a extends V {
|
|
|
877
877
|
});
|
|
878
878
|
}
|
|
879
879
|
};
|
|
880
|
-
var
|
|
880
|
+
var n$1 = class n extends V {
|
|
881
881
|
options;
|
|
882
882
|
cursor = 0;
|
|
883
883
|
get _selectedValue() {
|
|
884
884
|
return this.options[this.cursor];
|
|
885
885
|
}
|
|
886
886
|
changeValue() {
|
|
887
|
-
|
|
887
|
+
const e = this._selectedValue;
|
|
888
|
+
this.value = e === void 0 ? void 0 : e.value;
|
|
888
889
|
}
|
|
889
|
-
constructor(
|
|
890
|
-
super(
|
|
891
|
-
const
|
|
892
|
-
this.cursor = this.options[
|
|
890
|
+
constructor(e) {
|
|
891
|
+
super(e, false), this.options = e.options;
|
|
892
|
+
const o = this.options.findIndex(({ value: s }) => s === e.initialValue), t2 = o === -1 ? 0 : o;
|
|
893
|
+
this.cursor = this.options[t2]?.disabled ? findCursor(t2, 1, this.options) : t2, this.changeValue(), this.on("cursor", (s) => {
|
|
893
894
|
switch (s) {
|
|
894
895
|
case "left":
|
|
895
896
|
case "up":
|
|
@@ -904,15 +905,15 @@ var a2 = class extends V {
|
|
|
904
905
|
});
|
|
905
906
|
}
|
|
906
907
|
};
|
|
907
|
-
var
|
|
908
|
+
var n2 = class extends V {
|
|
908
909
|
get userInputWithCursor() {
|
|
909
910
|
if (this.state === "submit")
|
|
910
911
|
return this.userInput;
|
|
911
912
|
const t2 = this.userInput;
|
|
912
913
|
if (this.cursor >= t2.length)
|
|
913
914
|
return `${this.userInput}\u2588`;
|
|
914
|
-
const
|
|
915
|
-
return `${
|
|
915
|
+
const r2 = t2.slice(0, this.cursor), s = t2.slice(this.cursor, this.cursor + 1), e = t2.slice(this.cursor + 1);
|
|
916
|
+
return `${r2}${styleText("inverse", s)}${e}`;
|
|
916
917
|
}
|
|
917
918
|
get cursor() {
|
|
918
919
|
return this._cursor;
|
|
@@ -921,8 +922,8 @@ var n = class extends V {
|
|
|
921
922
|
super({
|
|
922
923
|
...t2,
|
|
923
924
|
initialUserInput: t2.initialUserInput ?? t2.initialValue
|
|
924
|
-
}), this.on("userInput", (
|
|
925
|
-
this._setValue(
|
|
925
|
+
}), this.on("userInput", (r2) => {
|
|
926
|
+
this._setValue(r2);
|
|
926
927
|
}), this.on("finalize", () => {
|
|
927
928
|
this.value || (this.value = t2.defaultValue), this.value === void 0 && (this.value = "");
|
|
928
929
|
});
|
|
@@ -941,7 +942,7 @@ function isUnicodeSupported() {
|
|
|
941
942
|
}
|
|
942
943
|
var unicode = isUnicodeSupported();
|
|
943
944
|
var isCI = () => process.env.CI === "true";
|
|
944
|
-
var unicodeOr = (
|
|
945
|
+
var unicodeOr = (o, e) => unicode ? o : e;
|
|
945
946
|
var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
|
|
946
947
|
var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
|
|
947
948
|
var S_STEP_ERROR = unicodeOr("\u25B2", "x");
|
|
@@ -967,8 +968,8 @@ var S_INFO = unicodeOr("\u25CF", "\u2022");
|
|
|
967
968
|
var S_SUCCESS = unicodeOr("\u25C6", "*");
|
|
968
969
|
var S_WARN = unicodeOr("\u25B2", "!");
|
|
969
970
|
var S_ERROR = unicodeOr("\u25A0", "x");
|
|
970
|
-
var symbol = (
|
|
971
|
-
switch (
|
|
971
|
+
var symbol = (o) => {
|
|
972
|
+
switch (o) {
|
|
972
973
|
case "initial":
|
|
973
974
|
case "active":
|
|
974
975
|
return styleText2("cyan", S_STEP_ACTIVE);
|
|
@@ -980,8 +981,8 @@ var symbol = (o2) => {
|
|
|
980
981
|
return styleText2("green", S_STEP_SUBMIT);
|
|
981
982
|
}
|
|
982
983
|
};
|
|
983
|
-
var symbolBar = (
|
|
984
|
-
switch (
|
|
984
|
+
var symbolBar = (o) => {
|
|
985
|
+
switch (o) {
|
|
985
986
|
case "initial":
|
|
986
987
|
case "active":
|
|
987
988
|
return styleText2("cyan", S_BAR);
|
|
@@ -993,76 +994,80 @@ var symbolBar = (o2) => {
|
|
|
993
994
|
return styleText2("green", S_BAR);
|
|
994
995
|
}
|
|
995
996
|
};
|
|
996
|
-
function formatInstructionFooter(
|
|
997
|
-
const r2 = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${
|
|
997
|
+
function formatInstructionFooter(o, e) {
|
|
998
|
+
const r2 = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o.join(" \u2022 ")}`];
|
|
998
999
|
return e && r2.push(styleText2("cyan", S_BAR_END)), r2;
|
|
999
1000
|
}
|
|
1000
|
-
var
|
|
1001
|
-
let r2 =
|
|
1002
|
-
if (
|
|
1003
|
-
for (let i2 =
|
|
1004
|
-
;
|
|
1001
|
+
var I = (l2, e, w, p, b, C2 = false) => {
|
|
1002
|
+
let r2 = e, O = 0;
|
|
1003
|
+
if (C2)
|
|
1004
|
+
for (let i2 = p - 1; i2 >= w; i2--) {
|
|
1005
|
+
const m2 = l2[i2];
|
|
1006
|
+
if (m2 && (r2 -= m2.length), O++, r2 <= b) break;
|
|
1007
|
+
}
|
|
1005
1008
|
else
|
|
1006
|
-
for (let i2 =
|
|
1007
|
-
;
|
|
1008
|
-
|
|
1009
|
+
for (let i2 = w; i2 < p; i2++) {
|
|
1010
|
+
const m2 = l2[i2];
|
|
1011
|
+
if (m2 && (r2 -= m2.length), O++, r2 <= b) break;
|
|
1012
|
+
}
|
|
1013
|
+
return { lineCount: r2, removals: O };
|
|
1009
1014
|
};
|
|
1010
1015
|
var limitOptions = ({
|
|
1011
1016
|
cursor: l2,
|
|
1012
|
-
options:
|
|
1013
|
-
style:
|
|
1014
|
-
output:
|
|
1015
|
-
maxItems:
|
|
1016
|
-
columnPadding:
|
|
1017
|
+
options: e,
|
|
1018
|
+
style: w,
|
|
1019
|
+
output: p = process.stdout,
|
|
1020
|
+
maxItems: b = Number.POSITIVE_INFINITY,
|
|
1021
|
+
columnPadding: C2 = 0,
|
|
1017
1022
|
rowPadding: r2 = 4
|
|
1018
1023
|
}) => {
|
|
1019
|
-
const i2 = getColumns(
|
|
1020
|
-
let
|
|
1021
|
-
l2 >=
|
|
1022
|
-
Math.min(l2 -
|
|
1024
|
+
const i2 = getColumns(p) - C2, m2 = getRows(p), M = styleText2("dim", "..."), v = Math.max(m2 - r2, 0), a2 = Math.max(Math.min(b, v), 5);
|
|
1025
|
+
let f = 0;
|
|
1026
|
+
l2 >= a2 - 3 && (f = Math.max(
|
|
1027
|
+
Math.min(l2 - a2 + 3, e.length - a2),
|
|
1023
1028
|
0
|
|
1024
1029
|
));
|
|
1025
|
-
let
|
|
1030
|
+
let d = a2 < e.length && f > 0, c2 = a2 < e.length && f + a2 < e.length;
|
|
1026
1031
|
const W2 = Math.min(
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
),
|
|
1030
|
-
let
|
|
1031
|
-
|
|
1032
|
-
const
|
|
1033
|
-
for (let t2 =
|
|
1034
|
-
const
|
|
1032
|
+
f + a2,
|
|
1033
|
+
e.length
|
|
1034
|
+
), s = [];
|
|
1035
|
+
let g = 0;
|
|
1036
|
+
d && g++, c2 && g++;
|
|
1037
|
+
const T = f + (d ? 1 : 0), y = W2 - (c2 ? 1 : 0);
|
|
1038
|
+
for (let t2 = T; t2 < y; t2++) {
|
|
1039
|
+
const n3 = e[t2], o = n3 ? w(n3, t2 === l2) : "", h2 = wrapAnsi(o, i2, {
|
|
1035
1040
|
hard: true,
|
|
1036
1041
|
trim: false
|
|
1037
1042
|
}).split(`
|
|
1038
1043
|
`);
|
|
1039
|
-
|
|
1040
|
-
}
|
|
1041
|
-
if (
|
|
1042
|
-
let t2 = 0,
|
|
1043
|
-
const
|
|
1044
|
-
let
|
|
1045
|
-
const
|
|
1046
|
-
e,
|
|
1044
|
+
s.push(h2), g += h2.length;
|
|
1045
|
+
}
|
|
1046
|
+
if (g > v) {
|
|
1047
|
+
let t2 = 0, n3 = 0, o = g;
|
|
1048
|
+
const h2 = l2 - T;
|
|
1049
|
+
let u3 = v;
|
|
1050
|
+
const L = () => I(s, o, 0, h2, u3), E = () => I(
|
|
1047
1051
|
s,
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1052
|
+
o,
|
|
1053
|
+
h2 + 1,
|
|
1054
|
+
s.length,
|
|
1055
|
+
u3,
|
|
1051
1056
|
true
|
|
1052
1057
|
);
|
|
1053
|
-
|
|
1054
|
-
}
|
|
1055
|
-
const
|
|
1056
|
-
|
|
1057
|
-
for (const t2 of
|
|
1058
|
-
for (const
|
|
1059
|
-
|
|
1060
|
-
return
|
|
1058
|
+
d ? ({ lineCount: o, removals: t2 } = L(), o > u3 && (c2 || (u3 -= 1), { lineCount: o, removals: n3 } = E())) : (c2 || (u3 -= 1), { lineCount: o, removals: n3 } = E(), o > u3 && (u3 -= 1, { lineCount: o, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n3 > 0 && (c2 = true, s.splice(s.length - n3, n3));
|
|
1059
|
+
}
|
|
1060
|
+
const x = [];
|
|
1061
|
+
d && x.push(M);
|
|
1062
|
+
for (const t2 of s)
|
|
1063
|
+
for (const n3 of t2)
|
|
1064
|
+
x.push(n3);
|
|
1065
|
+
return c2 && x.push(M), x;
|
|
1061
1066
|
};
|
|
1062
1067
|
var confirm = (i2) => {
|
|
1063
|
-
const
|
|
1068
|
+
const a2 = i2.active ?? "Yes", s = i2.inactive ?? "No";
|
|
1064
1069
|
return new r({
|
|
1065
|
-
active:
|
|
1070
|
+
active: a2,
|
|
1066
1071
|
inactive: s,
|
|
1067
1072
|
signal: i2.signal,
|
|
1068
1073
|
input: i2.input,
|
|
@@ -1074,22 +1079,22 @@ var confirm = (i2) => {
|
|
|
1074
1079
|
i2.message,
|
|
1075
1080
|
l2,
|
|
1076
1081
|
u3
|
|
1077
|
-
),
|
|
1082
|
+
), o = `${e ? `${styleText2("gray", S_BAR)}
|
|
1078
1083
|
` : ""}${f}
|
|
1079
|
-
`, c2 = this.value ?
|
|
1084
|
+
`, c2 = this.value ? a2 : s;
|
|
1080
1085
|
switch (this.state) {
|
|
1081
1086
|
case "submit": {
|
|
1082
1087
|
const r2 = e ? `${styleText2("gray", S_BAR)} ` : "";
|
|
1083
|
-
return `${
|
|
1088
|
+
return `${o}${r2}${styleText2("dim", c2)}`;
|
|
1084
1089
|
}
|
|
1085
1090
|
case "cancel": {
|
|
1086
1091
|
const r2 = e ? `${styleText2("gray", S_BAR)} ` : "";
|
|
1087
|
-
return `${
|
|
1092
|
+
return `${o}${r2}${styleText2(["strikethrough", "dim"], c2)}${e ? `
|
|
1088
1093
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1089
1094
|
}
|
|
1090
1095
|
default: {
|
|
1091
1096
|
const r2 = e ? `${styleText2("cyan", S_BAR)} ` : "", g = e ? styleText2("cyan", S_BAR_END) : "";
|
|
1092
|
-
return `${
|
|
1097
|
+
return `${o}${r2}${this.value ? `${styleText2("green", S_RADIO_ACTIVE)} ${a2}` : `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a2)}`}${i2.vertical ? e ? `
|
|
1093
1098
|
${styleText2("cyan", S_BAR)} ` : `
|
|
1094
1099
|
` : ` ${styleText2("dim", "/")} `}${this.value ? `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", s)}` : `${styleText2("green", S_RADIO_ACTIVE)} ${s}`}
|
|
1095
1100
|
${g}
|
|
@@ -1104,22 +1109,22 @@ var MULTISELECT_INSTRUCTIONS = [
|
|
|
1104
1109
|
`${styleText2("dim", "Space:")} select`,
|
|
1105
1110
|
`${styleText2("dim", "Enter:")} confirm`
|
|
1106
1111
|
];
|
|
1107
|
-
var m = (
|
|
1108
|
-
`).map((d) =>
|
|
1112
|
+
var m = (i2, u3) => i2.split(`
|
|
1113
|
+
`).map((d) => u3(d)).join(`
|
|
1109
1114
|
`);
|
|
1110
|
-
var multiselect = (
|
|
1111
|
-
const
|
|
1115
|
+
var multiselect = (i2) => {
|
|
1116
|
+
const u3 = (t2, a2) => {
|
|
1112
1117
|
const r2 = t2.label ?? String(t2.value);
|
|
1113
|
-
return
|
|
1114
|
-
}, d =
|
|
1115
|
-
return new a
|
|
1116
|
-
options:
|
|
1117
|
-
signal:
|
|
1118
|
-
input:
|
|
1119
|
-
output:
|
|
1120
|
-
initialValues:
|
|
1118
|
+
return a2 === "disabled" ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${m(r2, (o) => styleText2(["strikethrough", "gray"], o))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}` : a2 === "active" ? `${styleText2("cyan", S_CHECKBOX_ACTIVE)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${m(r2, (o) => styleText2("dim", o))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "cancelled" ? `${m(r2, (o) => styleText2(["strikethrough", "dim"], o))}` : a2 === "active-selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "submitted" ? `${m(r2, (o) => styleText2("dim", o))}` : `${styleText2("dim", S_CHECKBOX_INACTIVE)} ${m(r2, (o) => styleText2("dim", o))}`;
|
|
1119
|
+
}, d = i2.required ?? true, v = i2.showInstructions ?? true;
|
|
1120
|
+
return new a({
|
|
1121
|
+
options: i2.options,
|
|
1122
|
+
signal: i2.signal,
|
|
1123
|
+
input: i2.input,
|
|
1124
|
+
output: i2.output,
|
|
1125
|
+
initialValues: i2.initialValues,
|
|
1121
1126
|
required: d,
|
|
1122
|
-
cursorAt:
|
|
1127
|
+
cursorAt: i2.cursorAt,
|
|
1123
1128
|
validate(t2) {
|
|
1124
1129
|
if (d && (t2 === void 0 || t2.length === 0))
|
|
1125
1130
|
return `Please select at least one option.
|
|
@@ -1135,126 +1140,126 @@ ${styleText2(
|
|
|
1135
1140
|
)}`;
|
|
1136
1141
|
},
|
|
1137
1142
|
render() {
|
|
1138
|
-
const t2 =
|
|
1139
|
-
|
|
1140
|
-
|
|
1143
|
+
const t2 = i2.withGuide ?? settings.withGuide, a2 = wrapTextWithPrefix(
|
|
1144
|
+
i2.output,
|
|
1145
|
+
i2.message,
|
|
1141
1146
|
t2 ? `${symbolBar(this.state)} ` : "",
|
|
1142
1147
|
`${symbol(this.state)} `
|
|
1143
1148
|
), r2 = `${t2 ? `${styleText2("gray", S_BAR)}
|
|
1144
|
-
` : ""}${
|
|
1145
|
-
`,
|
|
1146
|
-
if (
|
|
1147
|
-
return
|
|
1148
|
-
const s =
|
|
1149
|
-
return
|
|
1149
|
+
` : ""}${a2}
|
|
1150
|
+
`, o = this.value ?? [], p = (n3, l2) => {
|
|
1151
|
+
if (n3.disabled)
|
|
1152
|
+
return u3(n3, "disabled");
|
|
1153
|
+
const s = o.includes(n3.value);
|
|
1154
|
+
return l2 && s ? u3(n3, "active-selected") : s ? u3(n3, "selected") : u3(n3, l2 ? "active" : "inactive");
|
|
1150
1155
|
};
|
|
1151
1156
|
switch (this.state) {
|
|
1152
1157
|
case "submit": {
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1155
|
-
|
|
1158
|
+
const n3 = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u3(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), l2 = wrapTextWithPrefix(
|
|
1159
|
+
i2.output,
|
|
1160
|
+
n3,
|
|
1156
1161
|
t2 ? `${styleText2("gray", S_BAR)} ` : ""
|
|
1157
1162
|
);
|
|
1158
|
-
return `${r2}${
|
|
1163
|
+
return `${r2}${l2}`;
|
|
1159
1164
|
}
|
|
1160
1165
|
case "cancel": {
|
|
1161
|
-
const
|
|
1162
|
-
if (
|
|
1166
|
+
const n3 = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u3(s, "cancelled")).join(styleText2("dim", ", "));
|
|
1167
|
+
if (n3.trim() === "")
|
|
1163
1168
|
return `${r2}${styleText2("gray", S_BAR)}`;
|
|
1164
|
-
const
|
|
1165
|
-
|
|
1166
|
-
|
|
1169
|
+
const l2 = wrapTextWithPrefix(
|
|
1170
|
+
i2.output,
|
|
1171
|
+
n3,
|
|
1167
1172
|
t2 ? `${styleText2("gray", S_BAR)} ` : ""
|
|
1168
1173
|
);
|
|
1169
|
-
return `${r2}${
|
|
1174
|
+
return `${r2}${l2}${t2 ? `
|
|
1170
1175
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1171
1176
|
}
|
|
1172
1177
|
case "error": {
|
|
1173
|
-
const
|
|
1178
|
+
const n3 = t2 ? `${styleText2("yellow", S_BAR)} ` : "", l2 = this.error.split(`
|
|
1174
1179
|
`).map(
|
|
1175
|
-
($,
|
|
1180
|
+
($, C2) => C2 === 0 ? `${t2 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", $)}` : ` ${$}`
|
|
1176
1181
|
).join(`
|
|
1177
1182
|
`), s = r2.split(`
|
|
1178
|
-
`).length,
|
|
1183
|
+
`).length, h2 = l2.split(`
|
|
1179
1184
|
`).length + 1;
|
|
1180
|
-
return `${r2}${
|
|
1181
|
-
output:
|
|
1185
|
+
return `${r2}${n3}${limitOptions({
|
|
1186
|
+
output: i2.output,
|
|
1182
1187
|
options: this.options,
|
|
1183
1188
|
cursor: this.cursor,
|
|
1184
|
-
maxItems:
|
|
1185
|
-
columnPadding:
|
|
1186
|
-
rowPadding: s +
|
|
1189
|
+
maxItems: i2.maxItems,
|
|
1190
|
+
columnPadding: n3.length,
|
|
1191
|
+
rowPadding: s + h2,
|
|
1187
1192
|
style: p
|
|
1188
1193
|
}).join(`
|
|
1189
|
-
${
|
|
1190
|
-
${
|
|
1194
|
+
${n3}`)}
|
|
1195
|
+
${l2}
|
|
1191
1196
|
`;
|
|
1192
1197
|
}
|
|
1193
1198
|
default: {
|
|
1194
|
-
const
|
|
1195
|
-
`).length, s = formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t2),
|
|
1199
|
+
const n3 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l2 = r2.split(`
|
|
1200
|
+
`).length, s = v ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t2) : t2 ? [styleText2("cyan", S_BAR_END)] : [], h2 = s.join(`
|
|
1196
1201
|
`), $ = s.length + 1;
|
|
1197
|
-
return `${r2}${
|
|
1198
|
-
output:
|
|
1202
|
+
return `${r2}${n3}${limitOptions({
|
|
1203
|
+
output: i2.output,
|
|
1199
1204
|
options: this.options,
|
|
1200
1205
|
cursor: this.cursor,
|
|
1201
|
-
maxItems:
|
|
1202
|
-
columnPadding:
|
|
1203
|
-
rowPadding:
|
|
1206
|
+
maxItems: i2.maxItems,
|
|
1207
|
+
columnPadding: n3.length,
|
|
1208
|
+
rowPadding: l2 + $,
|
|
1204
1209
|
style: p
|
|
1205
1210
|
}).join(`
|
|
1206
|
-
${
|
|
1207
|
-
${
|
|
1211
|
+
${n3}`)}
|
|
1212
|
+
${h2}
|
|
1208
1213
|
`;
|
|
1209
1214
|
}
|
|
1210
1215
|
}
|
|
1211
1216
|
}
|
|
1212
1217
|
}).prompt();
|
|
1213
1218
|
};
|
|
1214
|
-
var cancel = (
|
|
1219
|
+
var cancel = (o = "", t2) => {
|
|
1215
1220
|
const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_END)} ` : "";
|
|
1216
|
-
i2.write(`${e}${styleText2("red",
|
|
1221
|
+
i2.write(`${e}${styleText2("red", o)}
|
|
1217
1222
|
|
|
1218
1223
|
`);
|
|
1219
1224
|
};
|
|
1220
|
-
var intro = (
|
|
1225
|
+
var intro = (o = "", t2) => {
|
|
1221
1226
|
const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR_START)} ` : "";
|
|
1222
|
-
i2.write(`${e}${
|
|
1227
|
+
i2.write(`${e}${o}
|
|
1223
1228
|
`);
|
|
1224
1229
|
};
|
|
1225
|
-
var outro = (
|
|
1230
|
+
var outro = (o = "", t2) => {
|
|
1226
1231
|
const i2 = t2?.output ?? process.stdout, e = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)}
|
|
1227
1232
|
${styleText2("gray", S_BAR_END)} ` : "";
|
|
1228
|
-
i2.write(`${e}${
|
|
1233
|
+
i2.write(`${e}${o}
|
|
1229
1234
|
|
|
1230
1235
|
`);
|
|
1231
1236
|
};
|
|
1232
|
-
var W$1 = (
|
|
1233
|
-
var C = (
|
|
1234
|
-
const
|
|
1237
|
+
var W$1 = (o) => o;
|
|
1238
|
+
var C = (o, e, s) => {
|
|
1239
|
+
const a2 = {
|
|
1235
1240
|
hard: true,
|
|
1236
1241
|
trim: false
|
|
1237
|
-
}, i2 = wrapAnsi(
|
|
1238
|
-
`), c2 = i2.reduce((
|
|
1239
|
-
return wrapAnsi(
|
|
1242
|
+
}, i2 = wrapAnsi(o, e, a2).split(`
|
|
1243
|
+
`), c2 = i2.reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), u3 = i2.map(s).reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), g = e - (u3 - c2);
|
|
1244
|
+
return wrapAnsi(o, g, a2);
|
|
1240
1245
|
};
|
|
1241
|
-
var note = (
|
|
1242
|
-
const
|
|
1243
|
-
`).map(c2), ""],
|
|
1246
|
+
var note = (o = "", e = "", s) => {
|
|
1247
|
+
const a2 = s?.output ?? process$1.stdout, i2 = s?.withGuide ?? settings.withGuide, c2 = s?.format ?? W$1, g = ["", ...C(o, getColumns(a2) - 6, c2).split(`
|
|
1248
|
+
`).map(c2), ""], n3 = dist_default2(e), t2 = Math.max(
|
|
1244
1249
|
g.reduce((m2, F) => {
|
|
1245
1250
|
const O = dist_default2(F);
|
|
1246
1251
|
return O > m2 ? O : m2;
|
|
1247
1252
|
}, 0),
|
|
1248
|
-
|
|
1253
|
+
n3
|
|
1249
1254
|
) + 2, h2 = g.map(
|
|
1250
1255
|
(m2) => `${styleText2("gray", S_BAR)} ${m2}${" ".repeat(t2 - dist_default2(m2))}${styleText2("gray", S_BAR)}`
|
|
1251
1256
|
).join(`
|
|
1252
1257
|
`), T = i2 ? `${styleText2("gray", S_BAR)}
|
|
1253
1258
|
` : "", l$1 = i2 ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
|
|
1254
|
-
|
|
1259
|
+
a2.write(
|
|
1255
1260
|
`${T}${styleText2("green", S_STEP_SUBMIT)} ${styleText2("reset", e)} ${styleText2(
|
|
1256
1261
|
"gray",
|
|
1257
|
-
S_BAR_H.repeat(Math.max(t2 -
|
|
1262
|
+
S_BAR_H.repeat(Math.max(t2 - n3 - 1, 1)) + S_CORNER_TOP_RIGHT
|
|
1258
1263
|
)}
|
|
1259
1264
|
${h2}
|
|
1260
1265
|
${styleText2("gray", l$1 + S_BAR_H.repeat(t2 + 2) + S_CORNER_BOTTOM_RIGHT)}
|
|
@@ -1265,77 +1270,77 @@ var W = (l2) => styleText2("magenta", l2);
|
|
|
1265
1270
|
var spinner = ({
|
|
1266
1271
|
indicator: l2 = "dots",
|
|
1267
1272
|
onCancel: h2,
|
|
1268
|
-
output:
|
|
1273
|
+
output: n3 = process.stdout,
|
|
1269
1274
|
cancelMessage: G,
|
|
1270
1275
|
errorMessage: O,
|
|
1271
1276
|
frames: E = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
|
|
1272
1277
|
delay: F = unicode ? 80 : 120,
|
|
1273
1278
|
signal: m2,
|
|
1274
|
-
...
|
|
1279
|
+
...I2
|
|
1275
1280
|
} = {}) => {
|
|
1276
1281
|
const u3 = isCI();
|
|
1277
1282
|
let M, T, d = false, S = false, s = "", p, w = performance.now();
|
|
1278
|
-
const x = getColumns(
|
|
1283
|
+
const x = getColumns(n3), k = I2?.styleFrame ?? W, g = (e) => {
|
|
1279
1284
|
const r2 = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
|
|
1280
|
-
S = e === 1, d && (
|
|
1285
|
+
S = e === 1, d && (a2(r2, e), S && typeof h2 == "function" && h2());
|
|
1281
1286
|
}, f = () => g(2), i2 = () => g(1), A = () => {
|
|
1282
1287
|
process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i2), process.on("SIGTERM", i2), process.on("exit", g), m2 && m2.addEventListener("abort", i2);
|
|
1283
1288
|
}, H = () => {
|
|
1284
1289
|
process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i2), process.removeListener("SIGTERM", i2), process.removeListener("exit", g), m2 && m2.removeEventListener("abort", i2);
|
|
1285
1290
|
}, y = () => {
|
|
1286
1291
|
if (p === void 0) return;
|
|
1287
|
-
u3 &&
|
|
1292
|
+
u3 && n3.write(`
|
|
1288
1293
|
`);
|
|
1289
1294
|
const r2 = wrapAnsi(p, x, {
|
|
1290
1295
|
hard: true,
|
|
1291
1296
|
trim: false
|
|
1292
1297
|
}).split(`
|
|
1293
1298
|
`);
|
|
1294
|
-
r2.length > 1 &&
|
|
1299
|
+
r2.length > 1 && n3.write(import_sisteransi2.cursor.up(r2.length - 1)), n3.write(import_sisteransi2.cursor.to(0)), n3.write(import_sisteransi2.erase.down());
|
|
1295
1300
|
}, C2 = (e) => e.replace(/\.+$/, ""), _ = (e) => {
|
|
1296
|
-
const r2 = (performance.now() - e) / 1e3, t2 = Math.floor(r2 / 60),
|
|
1297
|
-
return t2 > 0 ? `[${t2}m ${
|
|
1298
|
-
}, N =
|
|
1299
|
-
d = true, M = block({ output:
|
|
1301
|
+
const r2 = (performance.now() - e) / 1e3, t2 = Math.floor(r2 / 60), o = Math.floor(r2 % 60);
|
|
1302
|
+
return t2 > 0 ? `[${t2}m ${o}s]` : `[${o}s]`;
|
|
1303
|
+
}, N = I2.withGuide ?? settings.withGuide, P = (e = "") => {
|
|
1304
|
+
d = true, M = block({ output: n3 }), s = C2(e), w = performance.now(), N && n3.write(`${styleText2("gray", S_BAR)}
|
|
1300
1305
|
`);
|
|
1301
1306
|
let r2 = 0, t2 = 0;
|
|
1302
1307
|
A(), T = setInterval(() => {
|
|
1303
1308
|
if (u3 && s === p)
|
|
1304
1309
|
return;
|
|
1305
1310
|
y(), p = s;
|
|
1306
|
-
const
|
|
1311
|
+
const o = k(E[r2]);
|
|
1307
1312
|
let v;
|
|
1308
1313
|
if (u3)
|
|
1309
|
-
v = `${
|
|
1314
|
+
v = `${o} ${s}...`;
|
|
1310
1315
|
else if (l2 === "timer")
|
|
1311
|
-
v = `${
|
|
1316
|
+
v = `${o} ${s} ${_(w)}`;
|
|
1312
1317
|
else {
|
|
1313
1318
|
const B = ".".repeat(Math.floor(t2)).slice(0, 3);
|
|
1314
|
-
v = `${
|
|
1319
|
+
v = `${o} ${s}${B}`;
|
|
1315
1320
|
}
|
|
1316
1321
|
const j = wrapAnsi(v, x, {
|
|
1317
1322
|
hard: true,
|
|
1318
1323
|
trim: false
|
|
1319
1324
|
});
|
|
1320
|
-
|
|
1325
|
+
n3.write(j), r2 = r2 + 1 < E.length ? r2 + 1 : 0, t2 = t2 < 4 ? t2 + 0.125 : 0;
|
|
1321
1326
|
}, F);
|
|
1322
|
-
},
|
|
1327
|
+
}, a2 = (e = "", r2 = 0, t2 = false) => {
|
|
1323
1328
|
if (!d) return;
|
|
1324
1329
|
d = false, clearInterval(T), y();
|
|
1325
|
-
const
|
|
1326
|
-
s = e ?? s, t2 || (l2 === "timer" ?
|
|
1327
|
-
`) :
|
|
1330
|
+
const o = r2 === 0 ? styleText2("green", S_STEP_SUBMIT) : r2 === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
|
|
1331
|
+
s = e ?? s, t2 || (l2 === "timer" ? n3.write(`${o} ${s} ${_(w)}
|
|
1332
|
+
`) : n3.write(`${o} ${s}
|
|
1328
1333
|
`)), H(), M();
|
|
1329
1334
|
};
|
|
1330
1335
|
return {
|
|
1331
1336
|
start: P,
|
|
1332
|
-
stop: (e = "") =>
|
|
1337
|
+
stop: (e = "") => a2(e, 0),
|
|
1333
1338
|
message: (e = "") => {
|
|
1334
1339
|
s = C2(e ?? s);
|
|
1335
1340
|
},
|
|
1336
|
-
cancel: (e = "") =>
|
|
1337
|
-
error: (e = "") =>
|
|
1338
|
-
clear: () =>
|
|
1341
|
+
cancel: (e = "") => a2(e, 1),
|
|
1342
|
+
error: (e = "") => a2(e, 2),
|
|
1343
|
+
clear: () => a2("", 0, true),
|
|
1339
1344
|
get isCancelled() {
|
|
1340
1345
|
return S;
|
|
1341
1346
|
}
|
|
@@ -1350,74 +1355,76 @@ var SELECT_INSTRUCTIONS = [
|
|
|
1350
1355
|
`${styleText2("dim", "\u2191/\u2193")} to navigate`,
|
|
1351
1356
|
`${styleText2("dim", "Enter:")} confirm`
|
|
1352
1357
|
];
|
|
1353
|
-
var c = (t2,
|
|
1358
|
+
var c = (t2, o) => t2.includes(`
|
|
1354
1359
|
`) ? t2.split(`
|
|
1355
|
-
`).map((
|
|
1356
|
-
`) :
|
|
1360
|
+
`).map((d) => o(d)).join(`
|
|
1361
|
+
`) : o(t2);
|
|
1357
1362
|
var select = (t2) => {
|
|
1358
|
-
const
|
|
1359
|
-
|
|
1363
|
+
const o = (n3, m2) => {
|
|
1364
|
+
if (n3 === void 0)
|
|
1365
|
+
return "";
|
|
1366
|
+
const s = n3.label ?? String(n3.value);
|
|
1360
1367
|
switch (m2) {
|
|
1361
1368
|
case "disabled":
|
|
1362
|
-
return `${styleText2("gray", S_RADIO_INACTIVE)} ${c(s, (
|
|
1369
|
+
return `${styleText2("gray", S_RADIO_INACTIVE)} ${c(s, (i2) => styleText2("gray", i2))}${n3.hint ? ` ${styleText2("dim", `(${n3.hint ?? "disabled"})`)}` : ""}`;
|
|
1363
1370
|
case "selected":
|
|
1364
|
-
return `${c(s, (
|
|
1371
|
+
return `${c(s, (i2) => styleText2("dim", i2))}`;
|
|
1365
1372
|
case "active":
|
|
1366
|
-
return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${
|
|
1373
|
+
return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`;
|
|
1367
1374
|
case "cancelled":
|
|
1368
|
-
return `${c(s, (
|
|
1375
|
+
return `${c(s, (i2) => styleText2(["strikethrough", "dim"], i2))}`;
|
|
1369
1376
|
default:
|
|
1370
|
-
return `${styleText2("dim", S_RADIO_INACTIVE)} ${c(s, (
|
|
1377
|
+
return `${styleText2("dim", S_RADIO_INACTIVE)} ${c(s, (i2) => styleText2("dim", i2))}`;
|
|
1371
1378
|
}
|
|
1372
|
-
};
|
|
1373
|
-
return new
|
|
1379
|
+
}, d = t2.showInstructions ?? true;
|
|
1380
|
+
return new n$1({
|
|
1374
1381
|
options: t2.options,
|
|
1375
1382
|
signal: t2.signal,
|
|
1376
1383
|
input: t2.input,
|
|
1377
1384
|
output: t2.output,
|
|
1378
1385
|
initialValue: t2.initialValue,
|
|
1379
1386
|
render() {
|
|
1380
|
-
const
|
|
1387
|
+
const n3 = t2.withGuide ?? settings.withGuide, m2 = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, i2 = wrapTextWithPrefix(
|
|
1381
1388
|
t2.output,
|
|
1382
1389
|
t2.message,
|
|
1383
1390
|
s,
|
|
1384
1391
|
m2
|
|
1385
|
-
), u3 = `${
|
|
1386
|
-
` : ""}${
|
|
1392
|
+
), u3 = `${n3 ? `${styleText2("gray", S_BAR)}
|
|
1393
|
+
` : ""}${i2}
|
|
1387
1394
|
`;
|
|
1388
1395
|
switch (this.state) {
|
|
1389
1396
|
case "submit": {
|
|
1390
|
-
const r2 =
|
|
1397
|
+
const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(
|
|
1391
1398
|
t2.output,
|
|
1392
|
-
|
|
1399
|
+
o(this.options[this.cursor], "selected"),
|
|
1393
1400
|
r2
|
|
1394
1401
|
);
|
|
1395
|
-
return `${u3}${
|
|
1402
|
+
return `${u3}${a2}`;
|
|
1396
1403
|
}
|
|
1397
1404
|
case "cancel": {
|
|
1398
|
-
const r2 =
|
|
1405
|
+
const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(
|
|
1399
1406
|
t2.output,
|
|
1400
|
-
|
|
1407
|
+
o(this.options[this.cursor], "cancelled"),
|
|
1401
1408
|
r2
|
|
1402
1409
|
);
|
|
1403
|
-
return `${u3}${
|
|
1410
|
+
return `${u3}${a2}${n3 ? `
|
|
1404
1411
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
1405
1412
|
}
|
|
1406
1413
|
default: {
|
|
1407
|
-
const r2 =
|
|
1408
|
-
`).length,
|
|
1409
|
-
`),
|
|
1414
|
+
const r2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", a2 = u3.split(`
|
|
1415
|
+
`).length, p = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], b = p.join(`
|
|
1416
|
+
`), f = p.length + 1;
|
|
1410
1417
|
return `${u3}${r2}${limitOptions({
|
|
1411
1418
|
output: t2.output,
|
|
1412
1419
|
cursor: this.cursor,
|
|
1413
1420
|
options: this.options,
|
|
1414
1421
|
maxItems: t2.maxItems,
|
|
1415
1422
|
columnPadding: r2.length,
|
|
1416
|
-
rowPadding:
|
|
1417
|
-
style: (
|
|
1423
|
+
rowPadding: a2 + f,
|
|
1424
|
+
style: (g, x) => o(g, g.disabled ? "disabled" : x ? "active" : "inactive")
|
|
1418
1425
|
}).join(`
|
|
1419
1426
|
${r2}`)}
|
|
1420
|
-
${
|
|
1427
|
+
${b}
|
|
1421
1428
|
`;
|
|
1422
1429
|
}
|
|
1423
1430
|
}
|
|
@@ -1425,38 +1432,41 @@ ${h2}
|
|
|
1425
1432
|
}).prompt();
|
|
1426
1433
|
};
|
|
1427
1434
|
var i = `${styleText2("gray", S_BAR)} `;
|
|
1428
|
-
var text = (
|
|
1429
|
-
validate:
|
|
1430
|
-
placeholder:
|
|
1431
|
-
defaultValue:
|
|
1432
|
-
initialValue:
|
|
1433
|
-
output:
|
|
1434
|
-
signal:
|
|
1435
|
-
input:
|
|
1435
|
+
var text = (e) => new n2({
|
|
1436
|
+
validate: e.validate,
|
|
1437
|
+
placeholder: e.placeholder,
|
|
1438
|
+
defaultValue: e.defaultValue,
|
|
1439
|
+
initialValue: e.initialValue,
|
|
1440
|
+
output: e.output,
|
|
1441
|
+
signal: e.signal,
|
|
1442
|
+
input: e.input,
|
|
1436
1443
|
render() {
|
|
1437
|
-
const i2 =
|
|
1438
|
-
` : ""}${symbol(this.state)} `}${
|
|
1439
|
-
`, c2 =
|
|
1444
|
+
const i2 = e?.withGuide ?? settings.withGuide, s = `${`${i2 ? `${styleText2("gray", S_BAR)}
|
|
1445
|
+
` : ""}${symbol(this.state)} `}${e.message}
|
|
1446
|
+
`, c2 = e.placeholder && e.placeholder.length > 0 ? (
|
|
1447
|
+
// biome-ignore lint/style/noNonNullAssertion: guarded by placeholder.length > 0
|
|
1448
|
+
styleText2("inverse", e.placeholder[0]) + styleText2("dim", e.placeholder.slice(1))
|
|
1449
|
+
) : styleText2(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : c2, l2 = this.value ?? "";
|
|
1440
1450
|
switch (this.state) {
|
|
1441
1451
|
case "error": {
|
|
1442
|
-
const
|
|
1452
|
+
const n3 = this.error ? ` ${styleText2("yellow", this.error)}` : "", r2 = i2 ? `${styleText2("yellow", S_BAR)} ` : "", d = i2 ? styleText2("yellow", S_BAR_END) : "";
|
|
1443
1453
|
return `${s.trim()}
|
|
1444
|
-
${r2}${
|
|
1445
|
-
${d}${
|
|
1454
|
+
${r2}${o}
|
|
1455
|
+
${d}${n3}
|
|
1446
1456
|
`;
|
|
1447
1457
|
}
|
|
1448
1458
|
case "submit": {
|
|
1449
|
-
const
|
|
1450
|
-
return `${s}${r2}${
|
|
1459
|
+
const n3 = l2 ? ` ${styleText2("dim", l2)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
|
|
1460
|
+
return `${s}${r2}${n3}`;
|
|
1451
1461
|
}
|
|
1452
1462
|
case "cancel": {
|
|
1453
|
-
const
|
|
1454
|
-
return `${s}${r2}${
|
|
1463
|
+
const n3 = l2 ? ` ${styleText2(["strikethrough", "dim"], l2)}` : "", r2 = i2 ? styleText2("gray", S_BAR) : "";
|
|
1464
|
+
return `${s}${r2}${n3}${l2.trim() ? `
|
|
1455
1465
|
${r2}` : ""}`;
|
|
1456
1466
|
}
|
|
1457
1467
|
default: {
|
|
1458
|
-
const
|
|
1459
|
-
return `${s}${
|
|
1468
|
+
const n3 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i2 ? styleText2("cyan", S_BAR_END) : "";
|
|
1469
|
+
return `${s}${n3}${o}
|
|
1460
1470
|
${r2}
|
|
1461
1471
|
`;
|
|
1462
1472
|
}
|
|
@@ -1652,23 +1662,23 @@ function success(s) {
|
|
|
1652
1662
|
}
|
|
1653
1663
|
var danger = import_picocolors.default.red;
|
|
1654
1664
|
var warn = import_picocolors.default.yellow;
|
|
1655
|
-
function lerp(
|
|
1656
|
-
return Math.round(
|
|
1665
|
+
function lerp(a2, b, t2) {
|
|
1666
|
+
return Math.round(a2 + (b - a2) * t2);
|
|
1657
1667
|
}
|
|
1658
1668
|
function gradientAt(t2) {
|
|
1659
1669
|
const segments = GRADIENT.length - 1;
|
|
1660
1670
|
const scaled = t2 * segments;
|
|
1661
1671
|
const i2 = Math.min(Math.floor(scaled), segments - 1);
|
|
1662
|
-
const
|
|
1672
|
+
const a2 = GRADIENT[i2];
|
|
1663
1673
|
const b = GRADIENT[i2 + 1];
|
|
1664
1674
|
const localT = scaled - i2;
|
|
1665
|
-
return [lerp(
|
|
1675
|
+
return [lerp(a2[0], b[0], localT), lerp(a2[1], b[1], localT), lerp(a2[2], b[2], localT)];
|
|
1666
1676
|
}
|
|
1667
1677
|
function gradientLine(line) {
|
|
1668
|
-
const
|
|
1678
|
+
const n3 = line.length;
|
|
1669
1679
|
let out2 = "";
|
|
1670
|
-
for (let i2 = 0; i2 <
|
|
1671
|
-
const [r2, g, b] = gradientAt(
|
|
1680
|
+
for (let i2 = 0; i2 < n3; i2++) {
|
|
1681
|
+
const [r2, g, b] = gradientAt(n3 > 1 ? i2 / (n3 - 1) : 0);
|
|
1672
1682
|
out2 += `\x1B[38;2;${r2};${g};${b}m${line[i2]}`;
|
|
1673
1683
|
}
|
|
1674
1684
|
return out2 + "\x1B[39m";
|
|
@@ -1703,26 +1713,26 @@ function box(lines, paint = (s) => s) {
|
|
|
1703
1713
|
].join("\n");
|
|
1704
1714
|
}
|
|
1705
1715
|
var TAGLINES = [
|
|
1706
|
-
(
|
|
1707
|
-
(
|
|
1708
|
-
(
|
|
1709
|
-
(
|
|
1710
|
-
(
|
|
1711
|
-
(
|
|
1712
|
-
(
|
|
1713
|
-
(
|
|
1714
|
-
(
|
|
1715
|
-
(
|
|
1716
|
-
(
|
|
1717
|
-
(
|
|
1718
|
-
(
|
|
1719
|
-
(
|
|
1720
|
-
(
|
|
1721
|
-
(
|
|
1722
|
-
(
|
|
1723
|
-
(
|
|
1724
|
-
(
|
|
1725
|
-
(
|
|
1716
|
+
(a2) => `bringing ${a2("hyper scale")} to anyone`,
|
|
1717
|
+
(a2) => `the first full-stack ${a2("application delivery network")}`,
|
|
1718
|
+
(a2) => `your app, ${a2("globally distributed")} by default`,
|
|
1719
|
+
(a2) => `one build, ${a2("the whole planet")}`,
|
|
1720
|
+
(a2) => `full stack, ${a2("zero distance")} to your users`,
|
|
1721
|
+
(a2) => `${a2("react")} up front, ${a2("wasm")} at every edge`,
|
|
1722
|
+
(a2) => `deployed where your ${a2("users")} are`,
|
|
1723
|
+
(a2) => `the framework with a ${a2("delivery network")} built in`,
|
|
1724
|
+
(a2) => `no regions, just ${a2("the world")}`,
|
|
1725
|
+
(a2) => `${a2("planet-scale")} apps from a single repo`,
|
|
1726
|
+
(a2) => `every request served ${a2("next door")}`,
|
|
1727
|
+
(a2) => `frontend, backend, ${a2("worldwide")}`,
|
|
1728
|
+
(a2) => `${a2("hyper scale")} without the ops team`,
|
|
1729
|
+
(a2) => `your backend, ${a2("compiled to wasm")}, running everywhere`,
|
|
1730
|
+
(a2) => `the internet is your ${a2("runtime")}`,
|
|
1731
|
+
(a2) => `the speed of light is the ${a2("only bottleneck")}`,
|
|
1732
|
+
(a2) => `static speed, ${a2("dynamic everything")}`,
|
|
1733
|
+
(a2) => `scale to ${a2("millions")} before lunch`,
|
|
1734
|
+
(a2) => `latency is a choice, choose ${a2("zero")}`,
|
|
1735
|
+
(a2) => `build ${a2("better")}, ship ${a2("faster")}`
|
|
1726
1736
|
];
|
|
1727
1737
|
function tagline() {
|
|
1728
1738
|
return TAGLINES[Math.floor(Math.random() * TAGLINES.length)](brand);
|
|
@@ -1875,7 +1885,7 @@ async function applyPackages(pkgPath, pkg, from, to) {
|
|
|
1875
1885
|
delete deps[name];
|
|
1876
1886
|
}
|
|
1877
1887
|
const sortedDev = Object.fromEntries(
|
|
1878
|
-
Object.entries(dev2).sort(([
|
|
1888
|
+
Object.entries(dev2).sort(([a2], [b]) => a2.localeCompare(b))
|
|
1879
1889
|
);
|
|
1880
1890
|
const next = { ...pkg, devDependencies: sortedDev };
|
|
1881
1891
|
if (Object.keys(deps).length) next.dependencies = deps;
|
|
@@ -2678,9 +2688,9 @@ function parseVersion(v) {
|
|
|
2678
2688
|
return [Number(m2[1]), Number(m2[2] ?? 0), Number(m2[3] ?? 0)];
|
|
2679
2689
|
}
|
|
2680
2690
|
function satisfiesMin(version2, range) {
|
|
2681
|
-
const [
|
|
2691
|
+
const [a2, b, c2] = parseVersion(version2);
|
|
2682
2692
|
const [x, y, z] = parseVersion(range);
|
|
2683
|
-
if (
|
|
2693
|
+
if (a2 !== x) return a2 > x;
|
|
2684
2694
|
if (b !== y) return b > y;
|
|
2685
2695
|
return c2 >= z;
|
|
2686
2696
|
}
|
|
@@ -3569,7 +3579,7 @@ async function runDoctor(opts) {
|
|
|
3569
3579
|
}
|
|
3570
3580
|
}
|
|
3571
3581
|
}
|
|
3572
|
-
const peerName = (
|
|
3582
|
+
const peerName = (n3) => checkPeer(n3, deps[n3] ?? null, meta.peers[n3] ?? "*");
|
|
3573
3583
|
const peerChecks = Object.keys(meta.peers).map(peerName);
|
|
3574
3584
|
const rpcFix = serverPresent && opts.fix ? applyRpcFix(root) : null;
|
|
3575
3585
|
const prettierFix = serverPresent && opts.fix ? applyPrettierFix(root, projectPkg) : null;
|
|
@@ -3735,7 +3745,7 @@ function buildRows(upgraded, currentDeps) {
|
|
|
3735
3745
|
return Object.entries(upgraded).map(([name, to]) => {
|
|
3736
3746
|
const from = currentDeps[name] ?? "?";
|
|
3737
3747
|
return { name, from, to, bump: classifyBump(from, to) };
|
|
3738
|
-
}).sort((
|
|
3748
|
+
}).sort((a2, b) => SEVERITY[a2.bump] - SEVERITY[b.bump] || a2.name.localeCompare(b.name));
|
|
3739
3749
|
}
|
|
3740
3750
|
|
|
3741
3751
|
// src/cli/update.ts
|
|
@@ -3893,9 +3903,9 @@ function parseCheckCache(raw) {
|
|
|
3893
3903
|
try {
|
|
3894
3904
|
const parsed = JSON.parse(raw);
|
|
3895
3905
|
if (typeof parsed !== "object" || parsed === null) return null;
|
|
3896
|
-
const
|
|
3897
|
-
const latest = typeof
|
|
3898
|
-
const checkedAt = typeof
|
|
3906
|
+
const o = parsed;
|
|
3907
|
+
const latest = typeof o.latest === "string" ? o.latest : null;
|
|
3908
|
+
const checkedAt = typeof o.checkedAt === "number" ? o.checkedAt : NaN;
|
|
3899
3909
|
if (!Number.isFinite(checkedAt)) return null;
|
|
3900
3910
|
return { latest, checkedAt };
|
|
3901
3911
|
} catch {
|
|
@@ -3910,8 +3920,8 @@ function parseSemver(v) {
|
|
|
3910
3920
|
if (!m2) return { nums: [0, 0, 0], pre: null };
|
|
3911
3921
|
return { nums: [Number(m2[1]), Number(m2[2]), Number(m2[3])], pre: m2[4] ?? null };
|
|
3912
3922
|
}
|
|
3913
|
-
function compareSemver(
|
|
3914
|
-
const pa = parseSemver(
|
|
3923
|
+
function compareSemver(a2, b) {
|
|
3924
|
+
const pa = parseSemver(a2);
|
|
3915
3925
|
const pb = parseSemver(b);
|
|
3916
3926
|
for (let i2 = 0; i2 < 3; i2++) {
|
|
3917
3927
|
if (pa.nums[i2] !== pb.nums[i2]) return pa.nums[i2] < pb.nums[i2] ? -1 : 1;
|