toolcraft-openapi 0.0.167 → 0.0.169
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/dist/composition.json
CHANGED
|
@@ -28,17 +28,24 @@ function stripAnsi(value) {
|
|
|
28
28
|
return value.replace(/\u001b\[[0-9;]*m/g, "");
|
|
29
29
|
}
|
|
30
30
|
function matchSubsequence(query, text) {
|
|
31
|
+
const queryCharacters = Array.from(query);
|
|
32
|
+
const textCharacters = Array.from(text);
|
|
31
33
|
let previousStates = [];
|
|
32
|
-
for (let queryIndex = 0; queryIndex <
|
|
34
|
+
for (let queryIndex = 0; queryIndex < queryCharacters.length; queryIndex += 1) {
|
|
33
35
|
const states = [];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
let offset = 0;
|
|
37
|
+
for (let textIndex = 0; textIndex < textCharacters.length; textIndex += 1) {
|
|
38
|
+
const character = textCharacters[textIndex];
|
|
39
|
+
const position = offset;
|
|
40
|
+
offset += character.length;
|
|
41
|
+
if (character !== queryCharacters[queryIndex]) {
|
|
36
42
|
continue;
|
|
37
43
|
}
|
|
44
|
+
const positions = character.length === 2 ? [position, position + 1] : [position];
|
|
38
45
|
if (queryIndex === 0) {
|
|
39
46
|
states[textIndex] = {
|
|
40
|
-
score: characterScore(
|
|
41
|
-
positions
|
|
47
|
+
score: characterScore(textCharacters, textIndex, undefined) + Math.max(0, EARLY_MATCH_BONUS - position),
|
|
48
|
+
positions
|
|
42
49
|
};
|
|
43
50
|
continue;
|
|
44
51
|
}
|
|
@@ -48,8 +55,8 @@ function matchSubsequence(query, text) {
|
|
|
48
55
|
continue;
|
|
49
56
|
}
|
|
50
57
|
const next = {
|
|
51
|
-
score: previous.score + characterScore(
|
|
52
|
-
positions: [...previous.positions,
|
|
58
|
+
score: previous.score + characterScore(textCharacters, textIndex, previousIndex),
|
|
59
|
+
positions: [...previous.positions, ...positions]
|
|
53
60
|
};
|
|
54
61
|
if (isBetterMatch(next, states[textIndex])) {
|
|
55
62
|
states[textIndex] = next;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
2
|
import * as readline from "node:readline";
|
|
3
|
+
import { Readable } from "node:stream";
|
|
4
|
+
import { StringDecoder } from "node:string_decoder";
|
|
3
5
|
import { graphemes } from "../../dashboard/terminal-width.js";
|
|
4
6
|
import { CANCEL } from "./cancel-symbol.js";
|
|
5
7
|
import { mapKey } from "./keys.js";
|
|
6
8
|
import { wrapFrame } from "./wrap.js";
|
|
9
|
+
const pendingCarriageReturns = new WeakMap();
|
|
7
10
|
const cursor = {
|
|
8
11
|
hide: "\x1b[?25l",
|
|
9
12
|
show: "\x1b[?25h",
|
|
@@ -128,6 +131,88 @@ export class Prompt extends EventEmitter {
|
|
|
128
131
|
this.state = "cancel";
|
|
129
132
|
return Promise.resolve(CANCEL);
|
|
130
133
|
}
|
|
134
|
+
const input = this.input;
|
|
135
|
+
if (input instanceof Readable) {
|
|
136
|
+
return new Promise((resolve, reject) => {
|
|
137
|
+
const decoder = new StringDecoder("utf8");
|
|
138
|
+
let line = "";
|
|
139
|
+
let settled = false;
|
|
140
|
+
const settle = (value, remainder) => {
|
|
141
|
+
if (settled)
|
|
142
|
+
return;
|
|
143
|
+
settled = true;
|
|
144
|
+
input.removeListener("data", onData);
|
|
145
|
+
input.removeListener("end", onEnd);
|
|
146
|
+
input.removeListener("close", onCancel);
|
|
147
|
+
input.removeListener("error", settle);
|
|
148
|
+
this.signal?.removeEventListener("abort", onCancel);
|
|
149
|
+
input.pause();
|
|
150
|
+
if (remainder?.length)
|
|
151
|
+
input.unshift(remainder, input.readableEncoding ?? undefined);
|
|
152
|
+
if (value instanceof Error)
|
|
153
|
+
reject(value);
|
|
154
|
+
else
|
|
155
|
+
resolve(value);
|
|
156
|
+
};
|
|
157
|
+
const onCancel = () => {
|
|
158
|
+
this.state = "cancel";
|
|
159
|
+
settle(CANCEL);
|
|
160
|
+
};
|
|
161
|
+
const onEnd = () => settle(line + decoder.end());
|
|
162
|
+
const onData = (chunk) => {
|
|
163
|
+
if (chunk.length === 0)
|
|
164
|
+
return;
|
|
165
|
+
if (settled) {
|
|
166
|
+
if (!input.destroyed)
|
|
167
|
+
input.unshift(chunk, input.readableEncoding ?? undefined);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
let offset = 0;
|
|
171
|
+
const previousCarriageReturn = pendingCarriageReturns.get(input);
|
|
172
|
+
if (previousCarriageReturn !== undefined) {
|
|
173
|
+
pendingCarriageReturns.delete(input);
|
|
174
|
+
const isLineFeed = typeof chunk === "string" ? chunk[0] === "\n" : chunk[0] === 10;
|
|
175
|
+
if (isLineFeed && Date.now() - previousCarriageReturn <= 100)
|
|
176
|
+
offset = 1;
|
|
177
|
+
}
|
|
178
|
+
for (; offset < chunk.length; offset += 1) {
|
|
179
|
+
const character = typeof chunk === "string" ? chunk[offset] : decoder.write(chunk.subarray(offset, offset + 1));
|
|
180
|
+
if (character.endsWith("\r") || character.endsWith("\n")) {
|
|
181
|
+
line += character.slice(0, -1);
|
|
182
|
+
offset += 1;
|
|
183
|
+
if (character.endsWith("\r")) {
|
|
184
|
+
if (offset === chunk.length) {
|
|
185
|
+
pendingCarriageReturns.set(input, Date.now());
|
|
186
|
+
}
|
|
187
|
+
else if (typeof chunk === "string" ? chunk[offset] === "\n" : chunk[offset] === 10) {
|
|
188
|
+
offset += 1;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
settle(line, chunk.slice(offset));
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
line += character;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
input.once("end", onEnd);
|
|
198
|
+
input.once("close", onCancel);
|
|
199
|
+
input.once("error", settle);
|
|
200
|
+
this.signal?.addEventListener("abort", onCancel, { once: true });
|
|
201
|
+
if (this.signal?.aborted)
|
|
202
|
+
onCancel();
|
|
203
|
+
else if (input.readableEnded)
|
|
204
|
+
onEnd();
|
|
205
|
+
else if (input.destroyed)
|
|
206
|
+
onCancel();
|
|
207
|
+
else if (!settled) {
|
|
208
|
+
input.on("data", onData);
|
|
209
|
+
if (!settled)
|
|
210
|
+
input.resume();
|
|
211
|
+
if (settled)
|
|
212
|
+
input.pause();
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
131
216
|
return new Promise((resolve, reject) => {
|
|
132
217
|
let rl = null;
|
|
133
218
|
let settled = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolcraft-openapi",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.169",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"toolcraft-openapi-generate": "dist/bin/generate.js"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"toolcraft": "0.0.
|
|
33
|
+
"toolcraft": "0.0.169",
|
|
34
34
|
"fast-string-width": "^3.0.2",
|
|
35
35
|
"fast-wrap-ansi": "^0.2.0",
|
|
36
36
|
"sisteransi": "^1.0.5",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"directory": "packages/toolcraft-openapi"
|
|
46
46
|
},
|
|
47
47
|
"optionalDependencies": {
|
|
48
|
-
"toolcraft-schema": "0.0.
|
|
48
|
+
"toolcraft-schema": "0.0.169",
|
|
49
49
|
"toolcraft-design": "*",
|
|
50
50
|
"@poe-code/frontmatter": "*"
|
|
51
51
|
},
|