apex-dev 3.7.0 → 3.10.3
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/index.js +423 -725
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -29,8 +29,8 @@ var __export = (target, all) => {
|
|
|
29
29
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
30
|
var __require = import.meta.require;
|
|
31
31
|
|
|
32
|
-
// node_modules/@opentui/react/chunk-
|
|
33
|
-
var
|
|
32
|
+
// node_modules/@opentui/react/chunk-2mx7fq49.js
|
|
33
|
+
var init_chunk_2mx7fq49 = () => {};
|
|
34
34
|
|
|
35
35
|
// node_modules/react/cjs/react.production.js
|
|
36
36
|
var exports_react_production = {};
|
|
@@ -24044,11 +24044,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
24044
24044
|
});
|
|
24045
24045
|
});
|
|
24046
24046
|
|
|
24047
|
-
// node_modules/@opentui/react/chunk-
|
|
24048
|
-
var
|
|
24047
|
+
// node_modules/@opentui/react/chunk-bdqvmfwv.js
|
|
24048
|
+
var exports_chunk_bdqvmfwv = {};
|
|
24049
24049
|
var import_react_devtools_core, g;
|
|
24050
|
-
var
|
|
24051
|
-
|
|
24050
|
+
var init_chunk_bdqvmfwv = __esm(async () => {
|
|
24051
|
+
init_chunk_2mx7fq49();
|
|
24052
24052
|
import_react_devtools_core = __toESM(require_backend(), 1);
|
|
24053
24053
|
g = globalThis;
|
|
24054
24054
|
if (typeof g.WebSocket === "undefined") {
|
|
@@ -24714,11 +24714,11 @@ var require_shims = __commonJS((exports) => {
|
|
|
24714
24714
|
throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`");
|
|
24715
24715
|
}
|
|
24716
24716
|
function makeReadableStream(...args) {
|
|
24717
|
-
const
|
|
24718
|
-
if (typeof
|
|
24717
|
+
const ReadableStream2 = globalThis.ReadableStream;
|
|
24718
|
+
if (typeof ReadableStream2 === "undefined") {
|
|
24719
24719
|
throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");
|
|
24720
24720
|
}
|
|
24721
|
-
return new
|
|
24721
|
+
return new ReadableStream2(...args);
|
|
24722
24722
|
}
|
|
24723
24723
|
function ReadableStreamFrom(iterable) {
|
|
24724
24724
|
let iter = Symbol.asyncIterator in iterable ? iterable[Symbol.asyncIterator]() : iterable[Symbol.iterator]();
|
|
@@ -31674,12 +31674,12 @@ var require_openai = __commonJS((exports, module2) => {
|
|
|
31674
31674
|
var require_config = __commonJS((exports, module2) => {
|
|
31675
31675
|
var OpenAI = require_openai();
|
|
31676
31676
|
var NVIDIA_MODEL = "z-ai/glm4.7";
|
|
31677
|
-
var REVIEWER_MODEL = "nvidia/llama-3.3-nemotron-
|
|
31677
|
+
var REVIEWER_MODEL = "nvidia/llama-3.3-nemotron-super-49b-v1.5";
|
|
31678
31678
|
var FILE_PICKER_MODEL = "qwen/qwen3-coder-480b-a35b-instruct";
|
|
31679
31679
|
var THINKER_MODEL = "z-ai/glm4.7";
|
|
31680
|
-
var COMMANDER_MODEL = "nvidia/llama-3.3-nemotron-
|
|
31681
|
-
var CONTEXT_PRUNER_MODEL = "nvidia/llama-3.3-nemotron-
|
|
31682
|
-
var RESEARCHER_MODEL = "nvidia/llama-3.3-nemotron-
|
|
31680
|
+
var COMMANDER_MODEL = "nvidia/llama-3.3-nemotron-super-49b-v1.5";
|
|
31681
|
+
var CONTEXT_PRUNER_MODEL = "nvidia/llama-3.3-nemotron-super-49b-v1.5";
|
|
31682
|
+
var RESEARCHER_MODEL = "nvidia/llama-3.3-nemotron-super-49b-v1.5";
|
|
31683
31683
|
var GENERAL_AGENT_MODEL = "z-ai/glm4.7";
|
|
31684
31684
|
var MAX_TOOL_ITERATIONS = 50;
|
|
31685
31685
|
var MAX_OUTPUT_LEN = 12000;
|
|
@@ -31786,7 +31786,8 @@ Rules:
|
|
|
31786
31786
|
2. Be specific and actionable \u2014 code examples and exact details over generic advice.
|
|
31787
31787
|
3. If results don't contain the answer, say so clearly and share what you know from training data.
|
|
31788
31788
|
4. Prefer recent/authoritative sources. Note when information may be outdated.
|
|
31789
|
-
5. Keep answers concise but thorough \u2014 developers are your audience
|
|
31789
|
+
5. Keep answers concise but thorough \u2014 developers are your audience.
|
|
31790
|
+
6. Do NOT use <think> tags or internal reasoning blocks in your response. Output your answer directly.`;
|
|
31790
31791
|
var RESEARCHER_DOCS_SYSTEM_PROMPT = `You are a documentation research specialist embedded in a coding assistant. You receive documentation search results and synthesize them into a precise, practical answer.
|
|
31791
31792
|
|
|
31792
31793
|
Rules:
|
|
@@ -31794,7 +31795,8 @@ Rules:
|
|
|
31794
31795
|
2. Include code examples that can be used directly \u2014 prefer showing code over describing it.
|
|
31795
31796
|
3. Note version-specific behavior when relevant.
|
|
31796
31797
|
4. Highlight common pitfalls, gotchas, and deprecation warnings.
|
|
31797
|
-
5. If the docs don't cover the question, say so and provide your best guidance from training data
|
|
31798
|
+
5. If the docs don't cover the question, say so and provide your best guidance from training data.
|
|
31799
|
+
6. Do NOT use <think> tags or internal reasoning blocks in your response. Output your answer directly.`;
|
|
31798
31800
|
var GENERAL_AGENT_SYSTEM_PROMPT = `You are a general-purpose coding agent. You receive file contents and conversation context, then produce a thorough, actionable response.
|
|
31799
31801
|
|
|
31800
31802
|
Your strengths:
|
|
@@ -31804,8 +31806,8 @@ Your strengths:
|
|
|
31804
31806
|
|
|
31805
31807
|
Be direct and comprehensive. Provide actual solutions, not descriptions of what to do. If you identify issues or risks, flag them clearly with severity.`;
|
|
31806
31808
|
var nvidiaClient = new OpenAI({
|
|
31807
|
-
apiKey: process.env.
|
|
31808
|
-
baseURL: "https://
|
|
31809
|
+
apiKey: process.env.APEX_API_KEY || "local-proxy",
|
|
31810
|
+
baseURL: process.env.APEX_API_URL || "https://apex-api-ten.vercel.app/v1"
|
|
31809
31811
|
});
|
|
31810
31812
|
var session = {
|
|
31811
31813
|
conversationHistory: [],
|
|
@@ -32419,6 +32421,73 @@ var require_tools = __commonJS((exports, module2) => {
|
|
|
32419
32421
|
module2.exports = { toolDefs };
|
|
32420
32422
|
});
|
|
32421
32423
|
|
|
32424
|
+
// src/thinking.js
|
|
32425
|
+
var require_thinking = __commonJS((exports, module2) => {
|
|
32426
|
+
function parseThinkBlocks(text) {
|
|
32427
|
+
const thinkRegex = /<think>([\s\S]*?)(?:<\/think>|think>)/g;
|
|
32428
|
+
const thoughts = [];
|
|
32429
|
+
let match;
|
|
32430
|
+
while ((match = thinkRegex.exec(text)) !== null) {
|
|
32431
|
+
const content = match[1].trim();
|
|
32432
|
+
if (content)
|
|
32433
|
+
thoughts.push(content);
|
|
32434
|
+
}
|
|
32435
|
+
const cleaned = text.replace(/<think>[\s\S]*?(?:<\/think>|think>)/g, "").trim();
|
|
32436
|
+
return { thoughts, content: cleaned };
|
|
32437
|
+
}
|
|
32438
|
+
function findThinkClose(text) {
|
|
32439
|
+
const fullClose = text.indexOf("</think>");
|
|
32440
|
+
if (fullClose !== -1)
|
|
32441
|
+
return { pos: fullClose, len: 8 };
|
|
32442
|
+
let searchFrom = 0;
|
|
32443
|
+
while (searchFrom < text.length) {
|
|
32444
|
+
const idx = text.indexOf("think>", searchFrom);
|
|
32445
|
+
if (idx === -1)
|
|
32446
|
+
break;
|
|
32447
|
+
if (idx === 0 || text[idx - 1] !== "<")
|
|
32448
|
+
return { pos: idx, len: 6 };
|
|
32449
|
+
searchFrom = idx + 6;
|
|
32450
|
+
}
|
|
32451
|
+
return null;
|
|
32452
|
+
}
|
|
32453
|
+
function stripStrayCloseTag(text) {
|
|
32454
|
+
return text.replace(/<\/think>/g, "").replace(/(?<!<)think>/g, "");
|
|
32455
|
+
}
|
|
32456
|
+
function splitAtPartialTag(text) {
|
|
32457
|
+
const prefixes = [
|
|
32458
|
+
"</think>",
|
|
32459
|
+
"</think",
|
|
32460
|
+
"</thin",
|
|
32461
|
+
"</thi",
|
|
32462
|
+
"</th",
|
|
32463
|
+
"</t",
|
|
32464
|
+
"</",
|
|
32465
|
+
"<think>",
|
|
32466
|
+
"<think",
|
|
32467
|
+
"<thin",
|
|
32468
|
+
"<thi",
|
|
32469
|
+
"<th",
|
|
32470
|
+
"<t",
|
|
32471
|
+
"<"
|
|
32472
|
+
];
|
|
32473
|
+
for (const prefix of prefixes) {
|
|
32474
|
+
if (text.endsWith(prefix)) {
|
|
32475
|
+
if (prefix === "</think>" || prefix === "think>") {
|
|
32476
|
+
return { safe: text.slice(0, -prefix.length), pending: "" };
|
|
32477
|
+
}
|
|
32478
|
+
return { safe: text.slice(0, -prefix.length), pending: prefix };
|
|
32479
|
+
}
|
|
32480
|
+
}
|
|
32481
|
+
return { safe: text, pending: "" };
|
|
32482
|
+
}
|
|
32483
|
+
module2.exports = {
|
|
32484
|
+
parseThinkBlocks,
|
|
32485
|
+
findThinkClose,
|
|
32486
|
+
stripStrayCloseTag,
|
|
32487
|
+
splitAtPartialTag
|
|
32488
|
+
};
|
|
32489
|
+
});
|
|
32490
|
+
|
|
32422
32491
|
// src/toolExecutors.js
|
|
32423
32492
|
var require_toolExecutors = __commonJS((exports, module2) => {
|
|
32424
32493
|
var fs2 = __require("fs");
|
|
@@ -32451,6 +32520,7 @@ var require_toolExecutors = __commonJS((exports, module2) => {
|
|
|
32451
32520
|
resolvePath,
|
|
32452
32521
|
sleep
|
|
32453
32522
|
} = require_config();
|
|
32523
|
+
var { parseThinkBlocks } = require_thinking();
|
|
32454
32524
|
async function streamCompletion(params, onStream) {
|
|
32455
32525
|
for (let attempt = 0;attempt <= 2; attempt++) {
|
|
32456
32526
|
let content = "";
|
|
@@ -32458,24 +32528,46 @@ var require_toolExecutors = __commonJS((exports, module2) => {
|
|
|
32458
32528
|
try {
|
|
32459
32529
|
if (onStream) {
|
|
32460
32530
|
const stream = await nvidiaClient.chat.completions.create({ ...params, stream: true });
|
|
32531
|
+
let displayContent = "";
|
|
32461
32532
|
for await (const chunk of stream) {
|
|
32462
32533
|
const delta = chunk.choices?.[0]?.delta;
|
|
32463
32534
|
if (delta?.content) {
|
|
32464
32535
|
content += delta.content;
|
|
32465
|
-
|
|
32536
|
+
const lastOpen = content.lastIndexOf("<think>");
|
|
32537
|
+
const lastClose = content.lastIndexOf("</think>");
|
|
32538
|
+
if (lastOpen <= lastClose || lastOpen === -1) {
|
|
32539
|
+
displayContent = parseThinkBlocks(content).content;
|
|
32540
|
+
}
|
|
32541
|
+
onStream(displayContent || reasoning);
|
|
32466
32542
|
}
|
|
32467
32543
|
if (delta?.reasoning_content) {
|
|
32468
32544
|
reasoning += delta.reasoning_content;
|
|
32469
|
-
onStream(
|
|
32545
|
+
onStream(displayContent || reasoning);
|
|
32470
32546
|
}
|
|
32471
32547
|
}
|
|
32472
|
-
|
|
32548
|
+
let { content: cleaned } = parseThinkBlocks(content);
|
|
32549
|
+
const unclosedIdx = cleaned.lastIndexOf("<think>");
|
|
32550
|
+
if (unclosedIdx !== -1 && cleaned.indexOf("</think>", unclosedIdx) === -1) {
|
|
32551
|
+
cleaned = cleaned.slice(0, unclosedIdx).trim();
|
|
32552
|
+
}
|
|
32553
|
+
return cleaned || reasoning || "";
|
|
32473
32554
|
} else {
|
|
32474
32555
|
const response = await nvidiaClient.chat.completions.create(params);
|
|
32475
|
-
|
|
32556
|
+
const rawContent = response.choices[0]?.message?.content || "";
|
|
32557
|
+
const rawReasoning = response.choices[0]?.message?.reasoning_content || "";
|
|
32558
|
+
let { content: cleaned } = parseThinkBlocks(rawContent);
|
|
32559
|
+
const unclosedIdx = cleaned.lastIndexOf("<think>");
|
|
32560
|
+
if (unclosedIdx !== -1 && cleaned.indexOf("</think>", unclosedIdx) === -1) {
|
|
32561
|
+
cleaned = cleaned.slice(0, unclosedIdx).trim();
|
|
32562
|
+
}
|
|
32563
|
+
return cleaned || rawReasoning || "";
|
|
32476
32564
|
}
|
|
32477
32565
|
} catch (err) {
|
|
32478
|
-
if (
|
|
32566
|
+
if (err.status === 404 && params.model !== NVIDIA_MODEL && attempt < 2) {
|
|
32567
|
+
params = { ...params, model: NVIDIA_MODEL };
|
|
32568
|
+
continue;
|
|
32569
|
+
}
|
|
32570
|
+
if (attempt < 2 && (err.status === 429 || err.status >= 500)) {
|
|
32479
32571
|
await sleep(1000 * Math.pow(2, attempt));
|
|
32480
32572
|
continue;
|
|
32481
32573
|
}
|
|
@@ -33667,73 +33759,6 @@ var require_utils3 = __commonJS((exports, module2) => {
|
|
|
33667
33759
|
module2.exports = { toolDetailStr };
|
|
33668
33760
|
});
|
|
33669
33761
|
|
|
33670
|
-
// src/thinking.js
|
|
33671
|
-
var require_thinking = __commonJS((exports, module2) => {
|
|
33672
|
-
function parseThinkBlocks(text) {
|
|
33673
|
-
const thinkRegex = /<think>([\s\S]*?)(?:<\/think>|think>)/g;
|
|
33674
|
-
const thoughts = [];
|
|
33675
|
-
let match;
|
|
33676
|
-
while ((match = thinkRegex.exec(text)) !== null) {
|
|
33677
|
-
const content = match[1].trim();
|
|
33678
|
-
if (content)
|
|
33679
|
-
thoughts.push(content);
|
|
33680
|
-
}
|
|
33681
|
-
const cleaned = text.replace(/<think>[\s\S]*?(?:<\/think>|think>)/g, "").trim();
|
|
33682
|
-
return { thoughts, content: cleaned };
|
|
33683
|
-
}
|
|
33684
|
-
function findThinkClose(text) {
|
|
33685
|
-
const fullClose = text.indexOf("</think>");
|
|
33686
|
-
if (fullClose !== -1)
|
|
33687
|
-
return { pos: fullClose, len: 8 };
|
|
33688
|
-
let searchFrom = 0;
|
|
33689
|
-
while (searchFrom < text.length) {
|
|
33690
|
-
const idx = text.indexOf("think>", searchFrom);
|
|
33691
|
-
if (idx === -1)
|
|
33692
|
-
break;
|
|
33693
|
-
if (idx === 0 || text[idx - 1] !== "<")
|
|
33694
|
-
return { pos: idx, len: 6 };
|
|
33695
|
-
searchFrom = idx + 6;
|
|
33696
|
-
}
|
|
33697
|
-
return null;
|
|
33698
|
-
}
|
|
33699
|
-
function stripStrayCloseTag(text) {
|
|
33700
|
-
return text.replace(/<\/think>/g, "").replace(/(?<!<)think>/g, "");
|
|
33701
|
-
}
|
|
33702
|
-
function splitAtPartialTag(text) {
|
|
33703
|
-
const prefixes = [
|
|
33704
|
-
"</think>",
|
|
33705
|
-
"</think",
|
|
33706
|
-
"</thin",
|
|
33707
|
-
"</thi",
|
|
33708
|
-
"</th",
|
|
33709
|
-
"</t",
|
|
33710
|
-
"</",
|
|
33711
|
-
"<think>",
|
|
33712
|
-
"<think",
|
|
33713
|
-
"<thin",
|
|
33714
|
-
"<thi",
|
|
33715
|
-
"<th",
|
|
33716
|
-
"<t",
|
|
33717
|
-
"<"
|
|
33718
|
-
];
|
|
33719
|
-
for (const prefix of prefixes) {
|
|
33720
|
-
if (text.endsWith(prefix)) {
|
|
33721
|
-
if (prefix === "</think>" || prefix === "think>") {
|
|
33722
|
-
return { safe: text.slice(0, -prefix.length), pending: "" };
|
|
33723
|
-
}
|
|
33724
|
-
return { safe: text.slice(0, -prefix.length), pending: prefix };
|
|
33725
|
-
}
|
|
33726
|
-
}
|
|
33727
|
-
return { safe: text, pending: "" };
|
|
33728
|
-
}
|
|
33729
|
-
module2.exports = {
|
|
33730
|
-
parseThinkBlocks,
|
|
33731
|
-
findThinkClose,
|
|
33732
|
-
stripStrayCloseTag,
|
|
33733
|
-
splitAtPartialTag
|
|
33734
|
-
};
|
|
33735
|
-
});
|
|
33736
|
-
|
|
33737
33762
|
// src/agent.js
|
|
33738
33763
|
var require_agent = __commonJS((exports, module2) => {
|
|
33739
33764
|
var {
|
|
@@ -34263,7 +34288,101 @@ var require_jsx_runtime = __commonJS((exports, module2) => {
|
|
|
34263
34288
|
} else {}
|
|
34264
34289
|
});
|
|
34265
34290
|
|
|
34266
|
-
//
|
|
34291
|
+
// src/server.js
|
|
34292
|
+
var require_server = __commonJS((exports, module2) => {
|
|
34293
|
+
var OpenAI = require_openai();
|
|
34294
|
+
var NVIDIA_BASE_URL = "https://integrate.api.nvidia.com/v1";
|
|
34295
|
+
var PORT = process.env.APEX_SERVER_PORT || 3579;
|
|
34296
|
+
var serverInstance = null;
|
|
34297
|
+
async function startServer() {
|
|
34298
|
+
if (serverInstance)
|
|
34299
|
+
return serverInstance;
|
|
34300
|
+
const apiKey = process.env.NVIDIA_API_KEY || "";
|
|
34301
|
+
const upstream = new OpenAI({ apiKey, baseURL: NVIDIA_BASE_URL });
|
|
34302
|
+
serverInstance = Bun.serve({
|
|
34303
|
+
port: PORT,
|
|
34304
|
+
async fetch(req) {
|
|
34305
|
+
const url = new URL(req.url);
|
|
34306
|
+
if (url.pathname === "/health") {
|
|
34307
|
+
return new Response(JSON.stringify({ status: "ok" }), {
|
|
34308
|
+
headers: { "Content-Type": "application/json" }
|
|
34309
|
+
});
|
|
34310
|
+
}
|
|
34311
|
+
if (url.pathname === "/v1/chat/completions" && req.method === "POST") {
|
|
34312
|
+
try {
|
|
34313
|
+
const body = await req.json();
|
|
34314
|
+
const isStream = body.stream === true;
|
|
34315
|
+
if (isStream) {
|
|
34316
|
+
const stream = await upstream.chat.completions.create(body);
|
|
34317
|
+
const encoder2 = new TextEncoder;
|
|
34318
|
+
const readable = new ReadableStream({
|
|
34319
|
+
async start(controller) {
|
|
34320
|
+
try {
|
|
34321
|
+
for await (const chunk of stream) {
|
|
34322
|
+
controller.enqueue(encoder2.encode(`data: ${JSON.stringify(chunk)}
|
|
34323
|
+
|
|
34324
|
+
`));
|
|
34325
|
+
}
|
|
34326
|
+
controller.enqueue(encoder2.encode(`data: [DONE]
|
|
34327
|
+
|
|
34328
|
+
`));
|
|
34329
|
+
controller.close();
|
|
34330
|
+
} catch (err) {
|
|
34331
|
+
controller.enqueue(encoder2.encode(`data: ${JSON.stringify({ error: err.message })}
|
|
34332
|
+
|
|
34333
|
+
`));
|
|
34334
|
+
controller.close();
|
|
34335
|
+
}
|
|
34336
|
+
}
|
|
34337
|
+
});
|
|
34338
|
+
return new Response(readable, {
|
|
34339
|
+
headers: {
|
|
34340
|
+
"Content-Type": "text/event-stream",
|
|
34341
|
+
"Cache-Control": "no-cache",
|
|
34342
|
+
Connection: "keep-alive"
|
|
34343
|
+
}
|
|
34344
|
+
});
|
|
34345
|
+
}
|
|
34346
|
+
const result = await upstream.chat.completions.create(body);
|
|
34347
|
+
return new Response(JSON.stringify(result), {
|
|
34348
|
+
headers: { "Content-Type": "application/json" }
|
|
34349
|
+
});
|
|
34350
|
+
} catch (err) {
|
|
34351
|
+
const status = err.status || 500;
|
|
34352
|
+
return new Response(JSON.stringify({ error: { message: err.message, status } }), {
|
|
34353
|
+
status,
|
|
34354
|
+
headers: { "Content-Type": "application/json" }
|
|
34355
|
+
});
|
|
34356
|
+
}
|
|
34357
|
+
}
|
|
34358
|
+
if (url.pathname === "/v1/models" && req.method === "GET") {
|
|
34359
|
+
try {
|
|
34360
|
+
const models = await upstream.models.list();
|
|
34361
|
+
return new Response(JSON.stringify(models), {
|
|
34362
|
+
headers: { "Content-Type": "application/json" }
|
|
34363
|
+
});
|
|
34364
|
+
} catch (err) {
|
|
34365
|
+
return new Response(JSON.stringify({ error: err.message }), {
|
|
34366
|
+
status: 500,
|
|
34367
|
+
headers: { "Content-Type": "application/json" }
|
|
34368
|
+
});
|
|
34369
|
+
}
|
|
34370
|
+
}
|
|
34371
|
+
return new Response("Not Found", { status: 404 });
|
|
34372
|
+
}
|
|
34373
|
+
});
|
|
34374
|
+
return serverInstance;
|
|
34375
|
+
}
|
|
34376
|
+
function getServerURL() {
|
|
34377
|
+
return `http://localhost:${PORT}/v1`;
|
|
34378
|
+
}
|
|
34379
|
+
function getPort() {
|
|
34380
|
+
return PORT;
|
|
34381
|
+
}
|
|
34382
|
+
module2.exports = { startServer, getServerURL, getPort };
|
|
34383
|
+
});
|
|
34384
|
+
|
|
34385
|
+
// node_modules/@opentui/core/index-qr7b6cvh.js
|
|
34267
34386
|
import { Buffer as Buffer2 } from "buffer";
|
|
34268
34387
|
import { EventEmitter } from "events";
|
|
34269
34388
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
@@ -34304,7 +34423,7 @@ var highlights_default5 = "./highlights-hk7bwhj4.scm";
|
|
|
34304
34423
|
// node_modules/@opentui/core/assets/zig/tree-sitter-zig.wasm
|
|
34305
34424
|
var tree_sitter_zig_default = "./tree-sitter-zig-e78zbjpm.wasm";
|
|
34306
34425
|
|
|
34307
|
-
// node_modules/@opentui/core/index-
|
|
34426
|
+
// node_modules/@opentui/core/index-qr7b6cvh.js
|
|
34308
34427
|
import { resolve as resolve2, isAbsolute, parse } from "path";
|
|
34309
34428
|
import { existsSync } from "fs";
|
|
34310
34429
|
import { basename, join } from "path";
|
|
@@ -34328,13 +34447,17 @@ import { Writable } from "stream";
|
|
|
34328
34447
|
import { EventEmitter as EventEmitter7 } from "events";
|
|
34329
34448
|
import { EventEmitter as EventEmitter9 } from "events";
|
|
34330
34449
|
var __defProp2 = Object.defineProperty;
|
|
34450
|
+
var __returnValue = (v) => v;
|
|
34451
|
+
function __exportSetter(name, newValue) {
|
|
34452
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
34453
|
+
}
|
|
34331
34454
|
var __export2 = (target, all) => {
|
|
34332
34455
|
for (var name in all)
|
|
34333
34456
|
__defProp2(target, name, {
|
|
34334
34457
|
get: all[name],
|
|
34335
34458
|
enumerable: true,
|
|
34336
34459
|
configurable: true,
|
|
34337
|
-
set: (
|
|
34460
|
+
set: __exportSetter.bind(all, name)
|
|
34338
34461
|
});
|
|
34339
34462
|
};
|
|
34340
34463
|
var exports_src = {};
|
|
@@ -53743,604 +53866,6 @@ class LineNumberRenderable extends Renderable {
|
|
|
53743
53866
|
}
|
|
53744
53867
|
}
|
|
53745
53868
|
}
|
|
53746
|
-
|
|
53747
|
-
class Diff {
|
|
53748
|
-
diff(oldStr, newStr, options = {}) {
|
|
53749
|
-
let callback;
|
|
53750
|
-
if (typeof options === "function") {
|
|
53751
|
-
callback = options;
|
|
53752
|
-
options = {};
|
|
53753
|
-
} else if ("callback" in options) {
|
|
53754
|
-
callback = options.callback;
|
|
53755
|
-
}
|
|
53756
|
-
const oldString = this.castInput(oldStr, options);
|
|
53757
|
-
const newString = this.castInput(newStr, options);
|
|
53758
|
-
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
53759
|
-
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
53760
|
-
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
53761
|
-
}
|
|
53762
|
-
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
53763
|
-
var _a;
|
|
53764
|
-
const done = (value) => {
|
|
53765
|
-
value = this.postProcess(value, options);
|
|
53766
|
-
if (callback) {
|
|
53767
|
-
setTimeout(function() {
|
|
53768
|
-
callback(value);
|
|
53769
|
-
}, 0);
|
|
53770
|
-
return;
|
|
53771
|
-
} else {
|
|
53772
|
-
return value;
|
|
53773
|
-
}
|
|
53774
|
-
};
|
|
53775
|
-
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
53776
|
-
let editLength = 1;
|
|
53777
|
-
let maxEditLength = newLen + oldLen;
|
|
53778
|
-
if (options.maxEditLength != null) {
|
|
53779
|
-
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
53780
|
-
}
|
|
53781
|
-
const maxExecutionTime = (_a = options.timeout) !== null && _a !== undefined ? _a : Infinity;
|
|
53782
|
-
const abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
53783
|
-
const bestPath = [{ oldPos: -1, lastComponent: undefined }];
|
|
53784
|
-
let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
53785
|
-
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
53786
|
-
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
53787
|
-
}
|
|
53788
|
-
let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
53789
|
-
const execEditLength = () => {
|
|
53790
|
-
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength);diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
53791
|
-
let basePath;
|
|
53792
|
-
const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
53793
|
-
if (removePath) {
|
|
53794
|
-
bestPath[diagonalPath - 1] = undefined;
|
|
53795
|
-
}
|
|
53796
|
-
let canAdd = false;
|
|
53797
|
-
if (addPath) {
|
|
53798
|
-
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
53799
|
-
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
53800
|
-
}
|
|
53801
|
-
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
53802
|
-
if (!canAdd && !canRemove) {
|
|
53803
|
-
bestPath[diagonalPath] = undefined;
|
|
53804
|
-
continue;
|
|
53805
|
-
}
|
|
53806
|
-
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
53807
|
-
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
53808
|
-
} else {
|
|
53809
|
-
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
53810
|
-
}
|
|
53811
|
-
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
53812
|
-
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
53813
|
-
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
53814
|
-
} else {
|
|
53815
|
-
bestPath[diagonalPath] = basePath;
|
|
53816
|
-
if (basePath.oldPos + 1 >= oldLen) {
|
|
53817
|
-
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
53818
|
-
}
|
|
53819
|
-
if (newPos + 1 >= newLen) {
|
|
53820
|
-
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
53821
|
-
}
|
|
53822
|
-
}
|
|
53823
|
-
}
|
|
53824
|
-
editLength++;
|
|
53825
|
-
};
|
|
53826
|
-
if (callback) {
|
|
53827
|
-
(function exec() {
|
|
53828
|
-
setTimeout(function() {
|
|
53829
|
-
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
53830
|
-
return callback(undefined);
|
|
53831
|
-
}
|
|
53832
|
-
if (!execEditLength()) {
|
|
53833
|
-
exec();
|
|
53834
|
-
}
|
|
53835
|
-
}, 0);
|
|
53836
|
-
})();
|
|
53837
|
-
} else {
|
|
53838
|
-
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
53839
|
-
const ret = execEditLength();
|
|
53840
|
-
if (ret) {
|
|
53841
|
-
return ret;
|
|
53842
|
-
}
|
|
53843
|
-
}
|
|
53844
|
-
}
|
|
53845
|
-
}
|
|
53846
|
-
addToPath(path2, added, removed, oldPosInc, options) {
|
|
53847
|
-
const last = path2.lastComponent;
|
|
53848
|
-
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
53849
|
-
return {
|
|
53850
|
-
oldPos: path2.oldPos + oldPosInc,
|
|
53851
|
-
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
53852
|
-
};
|
|
53853
|
-
} else {
|
|
53854
|
-
return {
|
|
53855
|
-
oldPos: path2.oldPos + oldPosInc,
|
|
53856
|
-
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
53857
|
-
};
|
|
53858
|
-
}
|
|
53859
|
-
}
|
|
53860
|
-
extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
53861
|
-
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
53862
|
-
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
53863
|
-
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
53864
|
-
newPos++;
|
|
53865
|
-
oldPos++;
|
|
53866
|
-
commonCount++;
|
|
53867
|
-
if (options.oneChangePerToken) {
|
|
53868
|
-
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
53869
|
-
}
|
|
53870
|
-
}
|
|
53871
|
-
if (commonCount && !options.oneChangePerToken) {
|
|
53872
|
-
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
53873
|
-
}
|
|
53874
|
-
basePath.oldPos = oldPos;
|
|
53875
|
-
return newPos;
|
|
53876
|
-
}
|
|
53877
|
-
equals(left, right, options) {
|
|
53878
|
-
if (options.comparator) {
|
|
53879
|
-
return options.comparator(left, right);
|
|
53880
|
-
} else {
|
|
53881
|
-
return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
53882
|
-
}
|
|
53883
|
-
}
|
|
53884
|
-
removeEmpty(array) {
|
|
53885
|
-
const ret = [];
|
|
53886
|
-
for (let i = 0;i < array.length; i++) {
|
|
53887
|
-
if (array[i]) {
|
|
53888
|
-
ret.push(array[i]);
|
|
53889
|
-
}
|
|
53890
|
-
}
|
|
53891
|
-
return ret;
|
|
53892
|
-
}
|
|
53893
|
-
castInput(value, options) {
|
|
53894
|
-
return value;
|
|
53895
|
-
}
|
|
53896
|
-
tokenize(value, options) {
|
|
53897
|
-
return Array.from(value);
|
|
53898
|
-
}
|
|
53899
|
-
join(chars) {
|
|
53900
|
-
return chars.join("");
|
|
53901
|
-
}
|
|
53902
|
-
postProcess(changeObjects, options) {
|
|
53903
|
-
return changeObjects;
|
|
53904
|
-
}
|
|
53905
|
-
get useLongestToken() {
|
|
53906
|
-
return false;
|
|
53907
|
-
}
|
|
53908
|
-
buildValues(lastComponent, newTokens, oldTokens) {
|
|
53909
|
-
const components = [];
|
|
53910
|
-
let nextComponent;
|
|
53911
|
-
while (lastComponent) {
|
|
53912
|
-
components.push(lastComponent);
|
|
53913
|
-
nextComponent = lastComponent.previousComponent;
|
|
53914
|
-
delete lastComponent.previousComponent;
|
|
53915
|
-
lastComponent = nextComponent;
|
|
53916
|
-
}
|
|
53917
|
-
components.reverse();
|
|
53918
|
-
const componentLen = components.length;
|
|
53919
|
-
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
53920
|
-
for (;componentPos < componentLen; componentPos++) {
|
|
53921
|
-
const component = components[componentPos];
|
|
53922
|
-
if (!component.removed) {
|
|
53923
|
-
if (!component.added && this.useLongestToken) {
|
|
53924
|
-
let value = newTokens.slice(newPos, newPos + component.count);
|
|
53925
|
-
value = value.map(function(value2, i) {
|
|
53926
|
-
const oldValue = oldTokens[oldPos + i];
|
|
53927
|
-
return oldValue.length > value2.length ? oldValue : value2;
|
|
53928
|
-
});
|
|
53929
|
-
component.value = this.join(value);
|
|
53930
|
-
} else {
|
|
53931
|
-
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
53932
|
-
}
|
|
53933
|
-
newPos += component.count;
|
|
53934
|
-
if (!component.added) {
|
|
53935
|
-
oldPos += component.count;
|
|
53936
|
-
}
|
|
53937
|
-
} else {
|
|
53938
|
-
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
53939
|
-
oldPos += component.count;
|
|
53940
|
-
}
|
|
53941
|
-
}
|
|
53942
|
-
return components;
|
|
53943
|
-
}
|
|
53944
|
-
}
|
|
53945
|
-
|
|
53946
|
-
class CharacterDiff extends Diff {
|
|
53947
|
-
}
|
|
53948
|
-
var characterDiff = new CharacterDiff;
|
|
53949
|
-
function longestCommonPrefix(str1, str2) {
|
|
53950
|
-
let i;
|
|
53951
|
-
for (i = 0;i < str1.length && i < str2.length; i++) {
|
|
53952
|
-
if (str1[i] != str2[i]) {
|
|
53953
|
-
return str1.slice(0, i);
|
|
53954
|
-
}
|
|
53955
|
-
}
|
|
53956
|
-
return str1.slice(0, i);
|
|
53957
|
-
}
|
|
53958
|
-
function longestCommonSuffix(str1, str2) {
|
|
53959
|
-
let i;
|
|
53960
|
-
if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {
|
|
53961
|
-
return "";
|
|
53962
|
-
}
|
|
53963
|
-
for (i = 0;i < str1.length && i < str2.length; i++) {
|
|
53964
|
-
if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
|
|
53965
|
-
return str1.slice(-i);
|
|
53966
|
-
}
|
|
53967
|
-
}
|
|
53968
|
-
return str1.slice(-i);
|
|
53969
|
-
}
|
|
53970
|
-
function replacePrefix(string, oldPrefix, newPrefix) {
|
|
53971
|
-
if (string.slice(0, oldPrefix.length) != oldPrefix) {
|
|
53972
|
-
throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);
|
|
53973
|
-
}
|
|
53974
|
-
return newPrefix + string.slice(oldPrefix.length);
|
|
53975
|
-
}
|
|
53976
|
-
function replaceSuffix(string, oldSuffix, newSuffix) {
|
|
53977
|
-
if (!oldSuffix) {
|
|
53978
|
-
return string + newSuffix;
|
|
53979
|
-
}
|
|
53980
|
-
if (string.slice(-oldSuffix.length) != oldSuffix) {
|
|
53981
|
-
throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);
|
|
53982
|
-
}
|
|
53983
|
-
return string.slice(0, -oldSuffix.length) + newSuffix;
|
|
53984
|
-
}
|
|
53985
|
-
function removePrefix(string, oldPrefix) {
|
|
53986
|
-
return replacePrefix(string, oldPrefix, "");
|
|
53987
|
-
}
|
|
53988
|
-
function removeSuffix(string, oldSuffix) {
|
|
53989
|
-
return replaceSuffix(string, oldSuffix, "");
|
|
53990
|
-
}
|
|
53991
|
-
function maximumOverlap(string1, string2) {
|
|
53992
|
-
return string2.slice(0, overlapCount(string1, string2));
|
|
53993
|
-
}
|
|
53994
|
-
function overlapCount(a, b) {
|
|
53995
|
-
let startA = 0;
|
|
53996
|
-
if (a.length > b.length) {
|
|
53997
|
-
startA = a.length - b.length;
|
|
53998
|
-
}
|
|
53999
|
-
let endB = b.length;
|
|
54000
|
-
if (a.length < b.length) {
|
|
54001
|
-
endB = a.length;
|
|
54002
|
-
}
|
|
54003
|
-
const map = Array(endB);
|
|
54004
|
-
let k = 0;
|
|
54005
|
-
map[0] = 0;
|
|
54006
|
-
for (let j = 1;j < endB; j++) {
|
|
54007
|
-
if (b[j] == b[k]) {
|
|
54008
|
-
map[j] = map[k];
|
|
54009
|
-
} else {
|
|
54010
|
-
map[j] = k;
|
|
54011
|
-
}
|
|
54012
|
-
while (k > 0 && b[j] != b[k]) {
|
|
54013
|
-
k = map[k];
|
|
54014
|
-
}
|
|
54015
|
-
if (b[j] == b[k]) {
|
|
54016
|
-
k++;
|
|
54017
|
-
}
|
|
54018
|
-
}
|
|
54019
|
-
k = 0;
|
|
54020
|
-
for (let i = startA;i < a.length; i++) {
|
|
54021
|
-
while (k > 0 && a[i] != b[k]) {
|
|
54022
|
-
k = map[k];
|
|
54023
|
-
}
|
|
54024
|
-
if (a[i] == b[k]) {
|
|
54025
|
-
k++;
|
|
54026
|
-
}
|
|
54027
|
-
}
|
|
54028
|
-
return k;
|
|
54029
|
-
}
|
|
54030
|
-
function trailingWs(string) {
|
|
54031
|
-
let i;
|
|
54032
|
-
for (i = string.length - 1;i >= 0; i--) {
|
|
54033
|
-
if (!string[i].match(/\s/)) {
|
|
54034
|
-
break;
|
|
54035
|
-
}
|
|
54036
|
-
}
|
|
54037
|
-
return string.substring(i + 1);
|
|
54038
|
-
}
|
|
54039
|
-
function leadingWs(string) {
|
|
54040
|
-
const match = string.match(/^\s*/);
|
|
54041
|
-
return match ? match[0] : "";
|
|
54042
|
-
}
|
|
54043
|
-
var extendedWordChars = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
|
|
54044
|
-
var tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
|
|
54045
|
-
|
|
54046
|
-
class WordDiff extends Diff {
|
|
54047
|
-
equals(left, right, options) {
|
|
54048
|
-
if (options.ignoreCase) {
|
|
54049
|
-
left = left.toLowerCase();
|
|
54050
|
-
right = right.toLowerCase();
|
|
54051
|
-
}
|
|
54052
|
-
return left.trim() === right.trim();
|
|
54053
|
-
}
|
|
54054
|
-
tokenize(value, options = {}) {
|
|
54055
|
-
let parts;
|
|
54056
|
-
if (options.intlSegmenter) {
|
|
54057
|
-
const segmenter = options.intlSegmenter;
|
|
54058
|
-
if (segmenter.resolvedOptions().granularity != "word") {
|
|
54059
|
-
throw new Error('The segmenter passed must have a granularity of "word"');
|
|
54060
|
-
}
|
|
54061
|
-
parts = Array.from(segmenter.segment(value), (segment) => segment.segment);
|
|
54062
|
-
} else {
|
|
54063
|
-
parts = value.match(tokenizeIncludingWhitespace) || [];
|
|
54064
|
-
}
|
|
54065
|
-
const tokens = [];
|
|
54066
|
-
let prevPart = null;
|
|
54067
|
-
parts.forEach((part) => {
|
|
54068
|
-
if (/\s/.test(part)) {
|
|
54069
|
-
if (prevPart == null) {
|
|
54070
|
-
tokens.push(part);
|
|
54071
|
-
} else {
|
|
54072
|
-
tokens.push(tokens.pop() + part);
|
|
54073
|
-
}
|
|
54074
|
-
} else if (prevPart != null && /\s/.test(prevPart)) {
|
|
54075
|
-
if (tokens[tokens.length - 1] == prevPart) {
|
|
54076
|
-
tokens.push(tokens.pop() + part);
|
|
54077
|
-
} else {
|
|
54078
|
-
tokens.push(prevPart + part);
|
|
54079
|
-
}
|
|
54080
|
-
} else {
|
|
54081
|
-
tokens.push(part);
|
|
54082
|
-
}
|
|
54083
|
-
prevPart = part;
|
|
54084
|
-
});
|
|
54085
|
-
return tokens;
|
|
54086
|
-
}
|
|
54087
|
-
join(tokens) {
|
|
54088
|
-
return tokens.map((token, i) => {
|
|
54089
|
-
if (i == 0) {
|
|
54090
|
-
return token;
|
|
54091
|
-
} else {
|
|
54092
|
-
return token.replace(/^\s+/, "");
|
|
54093
|
-
}
|
|
54094
|
-
}).join("");
|
|
54095
|
-
}
|
|
54096
|
-
postProcess(changes, options) {
|
|
54097
|
-
if (!changes || options.oneChangePerToken) {
|
|
54098
|
-
return changes;
|
|
54099
|
-
}
|
|
54100
|
-
let lastKeep = null;
|
|
54101
|
-
let insertion = null;
|
|
54102
|
-
let deletion = null;
|
|
54103
|
-
changes.forEach((change) => {
|
|
54104
|
-
if (change.added) {
|
|
54105
|
-
insertion = change;
|
|
54106
|
-
} else if (change.removed) {
|
|
54107
|
-
deletion = change;
|
|
54108
|
-
} else {
|
|
54109
|
-
if (insertion || deletion) {
|
|
54110
|
-
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
|
|
54111
|
-
}
|
|
54112
|
-
lastKeep = change;
|
|
54113
|
-
insertion = null;
|
|
54114
|
-
deletion = null;
|
|
54115
|
-
}
|
|
54116
|
-
});
|
|
54117
|
-
if (insertion || deletion) {
|
|
54118
|
-
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
|
|
54119
|
-
}
|
|
54120
|
-
return changes;
|
|
54121
|
-
}
|
|
54122
|
-
}
|
|
54123
|
-
var wordDiff = new WordDiff;
|
|
54124
|
-
function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
|
|
54125
|
-
if (deletion && insertion) {
|
|
54126
|
-
const oldWsPrefix = leadingWs(deletion.value);
|
|
54127
|
-
const oldWsSuffix = trailingWs(deletion.value);
|
|
54128
|
-
const newWsPrefix = leadingWs(insertion.value);
|
|
54129
|
-
const newWsSuffix = trailingWs(insertion.value);
|
|
54130
|
-
if (startKeep) {
|
|
54131
|
-
const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
|
|
54132
|
-
startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
|
|
54133
|
-
deletion.value = removePrefix(deletion.value, commonWsPrefix);
|
|
54134
|
-
insertion.value = removePrefix(insertion.value, commonWsPrefix);
|
|
54135
|
-
}
|
|
54136
|
-
if (endKeep) {
|
|
54137
|
-
const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
|
|
54138
|
-
endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
|
|
54139
|
-
deletion.value = removeSuffix(deletion.value, commonWsSuffix);
|
|
54140
|
-
insertion.value = removeSuffix(insertion.value, commonWsSuffix);
|
|
54141
|
-
}
|
|
54142
|
-
} else if (insertion) {
|
|
54143
|
-
if (startKeep) {
|
|
54144
|
-
const ws = leadingWs(insertion.value);
|
|
54145
|
-
insertion.value = insertion.value.substring(ws.length);
|
|
54146
|
-
}
|
|
54147
|
-
if (endKeep) {
|
|
54148
|
-
const ws = leadingWs(endKeep.value);
|
|
54149
|
-
endKeep.value = endKeep.value.substring(ws.length);
|
|
54150
|
-
}
|
|
54151
|
-
} else if (startKeep && endKeep) {
|
|
54152
|
-
const newWsFull = leadingWs(endKeep.value), delWsStart = leadingWs(deletion.value), delWsEnd = trailingWs(deletion.value);
|
|
54153
|
-
const newWsStart = longestCommonPrefix(newWsFull, delWsStart);
|
|
54154
|
-
deletion.value = removePrefix(deletion.value, newWsStart);
|
|
54155
|
-
const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
|
|
54156
|
-
deletion.value = removeSuffix(deletion.value, newWsEnd);
|
|
54157
|
-
endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
|
|
54158
|
-
startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
|
|
54159
|
-
} else if (endKeep) {
|
|
54160
|
-
const endKeepWsPrefix = leadingWs(endKeep.value);
|
|
54161
|
-
const deletionWsSuffix = trailingWs(deletion.value);
|
|
54162
|
-
const overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
|
|
54163
|
-
deletion.value = removeSuffix(deletion.value, overlap);
|
|
54164
|
-
} else if (startKeep) {
|
|
54165
|
-
const startKeepWsSuffix = trailingWs(startKeep.value);
|
|
54166
|
-
const deletionWsPrefix = leadingWs(deletion.value);
|
|
54167
|
-
const overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
|
|
54168
|
-
deletion.value = removePrefix(deletion.value, overlap);
|
|
54169
|
-
}
|
|
54170
|
-
}
|
|
54171
|
-
|
|
54172
|
-
class WordsWithSpaceDiff extends Diff {
|
|
54173
|
-
tokenize(value) {
|
|
54174
|
-
const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug");
|
|
54175
|
-
return value.match(regex) || [];
|
|
54176
|
-
}
|
|
54177
|
-
}
|
|
54178
|
-
var wordsWithSpaceDiff = new WordsWithSpaceDiff;
|
|
54179
|
-
|
|
54180
|
-
class LineDiff extends Diff {
|
|
54181
|
-
constructor() {
|
|
54182
|
-
super(...arguments);
|
|
54183
|
-
this.tokenize = tokenize;
|
|
54184
|
-
}
|
|
54185
|
-
equals(left, right, options) {
|
|
54186
|
-
if (options.ignoreWhitespace) {
|
|
54187
|
-
if (!options.newlineIsToken || !left.includes(`
|
|
54188
|
-
`)) {
|
|
54189
|
-
left = left.trim();
|
|
54190
|
-
}
|
|
54191
|
-
if (!options.newlineIsToken || !right.includes(`
|
|
54192
|
-
`)) {
|
|
54193
|
-
right = right.trim();
|
|
54194
|
-
}
|
|
54195
|
-
} else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
54196
|
-
if (left.endsWith(`
|
|
54197
|
-
`)) {
|
|
54198
|
-
left = left.slice(0, -1);
|
|
54199
|
-
}
|
|
54200
|
-
if (right.endsWith(`
|
|
54201
|
-
`)) {
|
|
54202
|
-
right = right.slice(0, -1);
|
|
54203
|
-
}
|
|
54204
|
-
}
|
|
54205
|
-
return super.equals(left, right, options);
|
|
54206
|
-
}
|
|
54207
|
-
}
|
|
54208
|
-
var lineDiff = new LineDiff;
|
|
54209
|
-
function tokenize(value, options) {
|
|
54210
|
-
if (options.stripTrailingCr) {
|
|
54211
|
-
value = value.replace(/\r\n/g, `
|
|
54212
|
-
`);
|
|
54213
|
-
}
|
|
54214
|
-
const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
54215
|
-
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
54216
|
-
linesAndNewlines.pop();
|
|
54217
|
-
}
|
|
54218
|
-
for (let i = 0;i < linesAndNewlines.length; i++) {
|
|
54219
|
-
const line = linesAndNewlines[i];
|
|
54220
|
-
if (i % 2 && !options.newlineIsToken) {
|
|
54221
|
-
retLines[retLines.length - 1] += line;
|
|
54222
|
-
} else {
|
|
54223
|
-
retLines.push(line);
|
|
54224
|
-
}
|
|
54225
|
-
}
|
|
54226
|
-
return retLines;
|
|
54227
|
-
}
|
|
54228
|
-
function isSentenceEndPunct(char) {
|
|
54229
|
-
return char == "." || char == "!" || char == "?";
|
|
54230
|
-
}
|
|
54231
|
-
|
|
54232
|
-
class SentenceDiff extends Diff {
|
|
54233
|
-
tokenize(value) {
|
|
54234
|
-
var _a;
|
|
54235
|
-
const result = [];
|
|
54236
|
-
let tokenStartI = 0;
|
|
54237
|
-
for (let i = 0;i < value.length; i++) {
|
|
54238
|
-
if (i == value.length - 1) {
|
|
54239
|
-
result.push(value.slice(tokenStartI));
|
|
54240
|
-
break;
|
|
54241
|
-
}
|
|
54242
|
-
if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\s/)) {
|
|
54243
|
-
result.push(value.slice(tokenStartI, i + 1));
|
|
54244
|
-
i = tokenStartI = i + 1;
|
|
54245
|
-
while ((_a = value[i + 1]) === null || _a === undefined ? undefined : _a.match(/\s/)) {
|
|
54246
|
-
i++;
|
|
54247
|
-
}
|
|
54248
|
-
result.push(value.slice(tokenStartI, i + 1));
|
|
54249
|
-
tokenStartI = i + 1;
|
|
54250
|
-
}
|
|
54251
|
-
}
|
|
54252
|
-
return result;
|
|
54253
|
-
}
|
|
54254
|
-
}
|
|
54255
|
-
var sentenceDiff = new SentenceDiff;
|
|
54256
|
-
|
|
54257
|
-
class CssDiff extends Diff {
|
|
54258
|
-
tokenize(value) {
|
|
54259
|
-
return value.split(/([{}:;,]|\s+)/);
|
|
54260
|
-
}
|
|
54261
|
-
}
|
|
54262
|
-
var cssDiff = new CssDiff;
|
|
54263
|
-
|
|
54264
|
-
class JsonDiff extends Diff {
|
|
54265
|
-
constructor() {
|
|
54266
|
-
super(...arguments);
|
|
54267
|
-
this.tokenize = tokenize;
|
|
54268
|
-
}
|
|
54269
|
-
get useLongestToken() {
|
|
54270
|
-
return true;
|
|
54271
|
-
}
|
|
54272
|
-
castInput(value, options) {
|
|
54273
|
-
const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === "undefined" ? undefinedReplacement : v } = options;
|
|
54274
|
-
return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " ");
|
|
54275
|
-
}
|
|
54276
|
-
equals(left, right, options) {
|
|
54277
|
-
return super.equals(left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
|
|
54278
|
-
}
|
|
54279
|
-
}
|
|
54280
|
-
var jsonDiff = new JsonDiff;
|
|
54281
|
-
function canonicalize(obj, stack, replacementStack, replacer, key) {
|
|
54282
|
-
stack = stack || [];
|
|
54283
|
-
replacementStack = replacementStack || [];
|
|
54284
|
-
if (replacer) {
|
|
54285
|
-
obj = replacer(key === undefined ? "" : key, obj);
|
|
54286
|
-
}
|
|
54287
|
-
let i;
|
|
54288
|
-
for (i = 0;i < stack.length; i += 1) {
|
|
54289
|
-
if (stack[i] === obj) {
|
|
54290
|
-
return replacementStack[i];
|
|
54291
|
-
}
|
|
54292
|
-
}
|
|
54293
|
-
let canonicalizedObj;
|
|
54294
|
-
if (Object.prototype.toString.call(obj) === "[object Array]") {
|
|
54295
|
-
stack.push(obj);
|
|
54296
|
-
canonicalizedObj = new Array(obj.length);
|
|
54297
|
-
replacementStack.push(canonicalizedObj);
|
|
54298
|
-
for (i = 0;i < obj.length; i += 1) {
|
|
54299
|
-
canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
|
|
54300
|
-
}
|
|
54301
|
-
stack.pop();
|
|
54302
|
-
replacementStack.pop();
|
|
54303
|
-
return canonicalizedObj;
|
|
54304
|
-
}
|
|
54305
|
-
if (obj && obj.toJSON) {
|
|
54306
|
-
obj = obj.toJSON();
|
|
54307
|
-
}
|
|
54308
|
-
if (typeof obj === "object" && obj !== null) {
|
|
54309
|
-
stack.push(obj);
|
|
54310
|
-
canonicalizedObj = {};
|
|
54311
|
-
replacementStack.push(canonicalizedObj);
|
|
54312
|
-
const sortedKeys = [];
|
|
54313
|
-
let key2;
|
|
54314
|
-
for (key2 in obj) {
|
|
54315
|
-
if (Object.prototype.hasOwnProperty.call(obj, key2)) {
|
|
54316
|
-
sortedKeys.push(key2);
|
|
54317
|
-
}
|
|
54318
|
-
}
|
|
54319
|
-
sortedKeys.sort();
|
|
54320
|
-
for (i = 0;i < sortedKeys.length; i += 1) {
|
|
54321
|
-
key2 = sortedKeys[i];
|
|
54322
|
-
canonicalizedObj[key2] = canonicalize(obj[key2], stack, replacementStack, replacer, key2);
|
|
54323
|
-
}
|
|
54324
|
-
stack.pop();
|
|
54325
|
-
replacementStack.pop();
|
|
54326
|
-
} else {
|
|
54327
|
-
canonicalizedObj = obj;
|
|
54328
|
-
}
|
|
54329
|
-
return canonicalizedObj;
|
|
54330
|
-
}
|
|
54331
|
-
|
|
54332
|
-
class ArrayDiff extends Diff {
|
|
54333
|
-
tokenize(value) {
|
|
54334
|
-
return value.slice();
|
|
54335
|
-
}
|
|
54336
|
-
join(value) {
|
|
54337
|
-
return value;
|
|
54338
|
-
}
|
|
54339
|
-
removeEmpty(value) {
|
|
54340
|
-
return value;
|
|
54341
|
-
}
|
|
54342
|
-
}
|
|
54343
|
-
var arrayDiff = new ArrayDiff;
|
|
54344
53869
|
function parsePatch(uniDiff) {
|
|
54345
53870
|
const diffstr = uniDiff.split(/\n/), list = [];
|
|
54346
53871
|
let i = 0;
|
|
@@ -56753,6 +56278,7 @@ class TextTableRenderable extends Renderable {
|
|
|
56753
56278
|
_content;
|
|
56754
56279
|
_wrapMode;
|
|
56755
56280
|
_columnWidthMode;
|
|
56281
|
+
_columnFitter;
|
|
56756
56282
|
_cellPadding;
|
|
56757
56283
|
_showBorders;
|
|
56758
56284
|
_border;
|
|
@@ -56780,8 +56306,9 @@ class TextTableRenderable extends Renderable {
|
|
|
56780
56306
|
_cachedMeasureWidth = undefined;
|
|
56781
56307
|
_defaultOptions = {
|
|
56782
56308
|
content: [],
|
|
56783
|
-
wrapMode: "
|
|
56784
|
-
columnWidthMode: "
|
|
56309
|
+
wrapMode: "word",
|
|
56310
|
+
columnWidthMode: "full",
|
|
56311
|
+
columnFitter: "proportional",
|
|
56785
56312
|
cellPadding: 0,
|
|
56786
56313
|
showBorders: true,
|
|
56787
56314
|
border: true,
|
|
@@ -56798,10 +56325,11 @@ class TextTableRenderable extends Renderable {
|
|
|
56798
56325
|
attributes: 0
|
|
56799
56326
|
};
|
|
56800
56327
|
constructor(ctx, options = {}) {
|
|
56801
|
-
super(ctx, { ...options, buffered: true });
|
|
56328
|
+
super(ctx, { ...options, flexShrink: options.flexShrink ?? 0, buffered: true });
|
|
56802
56329
|
this._content = options.content ?? this._defaultOptions.content;
|
|
56803
56330
|
this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
|
|
56804
56331
|
this._columnWidthMode = options.columnWidthMode ?? this._defaultOptions.columnWidthMode;
|
|
56332
|
+
this._columnFitter = this.resolveColumnFitter(options.columnFitter);
|
|
56805
56333
|
this._cellPadding = this.resolveCellPadding(options.cellPadding);
|
|
56806
56334
|
this._showBorders = options.showBorders ?? this._defaultOptions.showBorders;
|
|
56807
56335
|
this._border = options.border ?? this._defaultOptions.border;
|
|
@@ -56850,6 +56378,16 @@ class TextTableRenderable extends Renderable {
|
|
|
56850
56378
|
this._columnWidthMode = value;
|
|
56851
56379
|
this.invalidateLayoutAndRaster();
|
|
56852
56380
|
}
|
|
56381
|
+
get columnFitter() {
|
|
56382
|
+
return this._columnFitter;
|
|
56383
|
+
}
|
|
56384
|
+
set columnFitter(value) {
|
|
56385
|
+
const next = this.resolveColumnFitter(value);
|
|
56386
|
+
if (this._columnFitter === next)
|
|
56387
|
+
return;
|
|
56388
|
+
this._columnFitter = next;
|
|
56389
|
+
this.invalidateLayoutAndRaster();
|
|
56390
|
+
}
|
|
56853
56391
|
get cellPadding() {
|
|
56854
56392
|
return this._cellPadding;
|
|
56855
56393
|
}
|
|
@@ -57003,7 +56541,7 @@ class TextTableRenderable extends Renderable {
|
|
|
57003
56541
|
super.destroySelf();
|
|
57004
56542
|
}
|
|
57005
56543
|
setupMeasureFunc() {
|
|
57006
|
-
const measureFunc = (width, widthMode,
|
|
56544
|
+
const measureFunc = (width, widthMode, _height, _heightMode) => {
|
|
57007
56545
|
const hasWidthConstraint = widthMode !== MeasureMode.Undefined && Number.isFinite(width);
|
|
57008
56546
|
const rawWidthConstraint = hasWidthConstraint ? Math.max(1, Math.floor(width)) : undefined;
|
|
57009
56547
|
const widthConstraint = this.resolveLayoutWidthConstraint(rawWidthConstraint);
|
|
@@ -57015,9 +56553,6 @@ class TextTableRenderable extends Renderable {
|
|
|
57015
56553
|
if (widthMode === MeasureMode.AtMost && rawWidthConstraint !== undefined && this._positionType !== "absolute") {
|
|
57016
56554
|
measuredWidth = Math.min(rawWidthConstraint, measuredWidth);
|
|
57017
56555
|
}
|
|
57018
|
-
if (heightMode === MeasureMode.AtMost && Number.isFinite(height) && this._positionType !== "absolute") {
|
|
57019
|
-
measuredHeight = Math.min(Math.max(1, Math.floor(height)), measuredHeight);
|
|
57020
|
-
}
|
|
57021
56556
|
return {
|
|
57022
56557
|
width: measuredWidth,
|
|
57023
56558
|
height: measuredHeight
|
|
@@ -57189,6 +56724,9 @@ class TextTableRenderable extends Renderable {
|
|
|
57189
56724
|
tableHeight: (rowOffsets[rowOffsets.length - 1] ?? 0) + 1
|
|
57190
56725
|
};
|
|
57191
56726
|
}
|
|
56727
|
+
isFullWidthMode() {
|
|
56728
|
+
return this._columnWidthMode === "full";
|
|
56729
|
+
}
|
|
57192
56730
|
computeColumnWidths(maxTableWidth, borderLayout) {
|
|
57193
56731
|
const horizontalPadding = this.getHorizontalCellPadding();
|
|
57194
56732
|
const intrinsicWidths = new Array(this._columnCount).fill(1 + horizontalPadding);
|
|
@@ -57211,7 +56749,7 @@ class TextTableRenderable extends Renderable {
|
|
|
57211
56749
|
return intrinsicWidths;
|
|
57212
56750
|
}
|
|
57213
56751
|
if (currentWidth < maxContentWidth) {
|
|
57214
|
-
if (this.
|
|
56752
|
+
if (this.isFullWidthMode()) {
|
|
57215
56753
|
return this.expandColumnWidths(intrinsicWidths, maxContentWidth);
|
|
57216
56754
|
}
|
|
57217
56755
|
return intrinsicWidths;
|
|
@@ -57241,6 +56779,12 @@ class TextTableRenderable extends Renderable {
|
|
|
57241
56779
|
return expanded;
|
|
57242
56780
|
}
|
|
57243
56781
|
fitColumnWidths(widths, targetContentWidth) {
|
|
56782
|
+
if (this._columnFitter === "balanced") {
|
|
56783
|
+
return this.fitColumnWidthsBalanced(widths, targetContentWidth);
|
|
56784
|
+
}
|
|
56785
|
+
return this.fitColumnWidthsProportional(widths, targetContentWidth);
|
|
56786
|
+
}
|
|
56787
|
+
fitColumnWidthsProportional(widths, targetContentWidth) {
|
|
57244
56788
|
const minWidth = 1 + this.getHorizontalCellPadding();
|
|
57245
56789
|
const hardMinWidths = new Array(widths.length).fill(minWidth);
|
|
57246
56790
|
const baseWidths = widths.map((width) => Math.max(1, Math.floor(width)));
|
|
@@ -57291,6 +56835,80 @@ class TextTableRenderable extends Renderable {
|
|
|
57291
56835
|
}
|
|
57292
56836
|
return baseWidths.map((width, idx) => Math.max(floorWidths[idx], width - integerShrink[idx]));
|
|
57293
56837
|
}
|
|
56838
|
+
fitColumnWidthsBalanced(widths, targetContentWidth) {
|
|
56839
|
+
const minWidth = 1 + this.getHorizontalCellPadding();
|
|
56840
|
+
const hardMinWidths = new Array(widths.length).fill(minWidth);
|
|
56841
|
+
const baseWidths = widths.map((width) => Math.max(1, Math.floor(width)));
|
|
56842
|
+
const totalBaseWidth = baseWidths.reduce((sum, width) => sum + width, 0);
|
|
56843
|
+
const columns = baseWidths.length;
|
|
56844
|
+
if (columns === 0 || totalBaseWidth <= targetContentWidth) {
|
|
56845
|
+
return baseWidths;
|
|
56846
|
+
}
|
|
56847
|
+
const evenShare = Math.max(minWidth, Math.floor(targetContentWidth / columns));
|
|
56848
|
+
const preferredMinWidths = baseWidths.map((width) => Math.min(width, evenShare));
|
|
56849
|
+
const preferredMinTotal = preferredMinWidths.reduce((sum, width) => sum + width, 0);
|
|
56850
|
+
const floorWidths = preferredMinTotal <= targetContentWidth ? preferredMinWidths : hardMinWidths;
|
|
56851
|
+
const floorTotal = floorWidths.reduce((sum, width) => sum + width, 0);
|
|
56852
|
+
const clampedTarget = Math.max(floorTotal, targetContentWidth);
|
|
56853
|
+
if (totalBaseWidth <= clampedTarget) {
|
|
56854
|
+
return baseWidths;
|
|
56855
|
+
}
|
|
56856
|
+
const shrinkable = baseWidths.map((width, idx) => width - floorWidths[idx]);
|
|
56857
|
+
const totalShrinkable = shrinkable.reduce((sum, value) => sum + value, 0);
|
|
56858
|
+
if (totalShrinkable <= 0) {
|
|
56859
|
+
return [...floorWidths];
|
|
56860
|
+
}
|
|
56861
|
+
const targetShrink = totalBaseWidth - clampedTarget;
|
|
56862
|
+
const shrink = this.allocateShrinkByWeight(shrinkable, targetShrink, "sqrt");
|
|
56863
|
+
return baseWidths.map((width, idx) => Math.max(floorWidths[idx], width - shrink[idx]));
|
|
56864
|
+
}
|
|
56865
|
+
allocateShrinkByWeight(shrinkable, targetShrink, mode) {
|
|
56866
|
+
const shrink = new Array(shrinkable.length).fill(0);
|
|
56867
|
+
if (targetShrink <= 0) {
|
|
56868
|
+
return shrink;
|
|
56869
|
+
}
|
|
56870
|
+
const weights = shrinkable.map((value) => {
|
|
56871
|
+
if (value <= 0) {
|
|
56872
|
+
return 0;
|
|
56873
|
+
}
|
|
56874
|
+
return mode === "sqrt" ? Math.sqrt(value) : value;
|
|
56875
|
+
});
|
|
56876
|
+
const totalWeight = weights.reduce((sum, value) => sum + value, 0);
|
|
56877
|
+
if (totalWeight <= 0) {
|
|
56878
|
+
return shrink;
|
|
56879
|
+
}
|
|
56880
|
+
const fractions = new Array(shrinkable.length).fill(0);
|
|
56881
|
+
let usedShrink = 0;
|
|
56882
|
+
for (let idx = 0;idx < shrinkable.length; idx++) {
|
|
56883
|
+
if (shrinkable[idx] <= 0 || weights[idx] <= 0)
|
|
56884
|
+
continue;
|
|
56885
|
+
const exact = weights[idx] / totalWeight * targetShrink;
|
|
56886
|
+
const whole = Math.min(shrinkable[idx], Math.floor(exact));
|
|
56887
|
+
shrink[idx] = whole;
|
|
56888
|
+
fractions[idx] = exact - whole;
|
|
56889
|
+
usedShrink += whole;
|
|
56890
|
+
}
|
|
56891
|
+
let remainingShrink = targetShrink - usedShrink;
|
|
56892
|
+
while (remainingShrink > 0) {
|
|
56893
|
+
let bestIdx = -1;
|
|
56894
|
+
let bestFraction = -1;
|
|
56895
|
+
for (let idx = 0;idx < shrinkable.length; idx++) {
|
|
56896
|
+
if (shrinkable[idx] - shrink[idx] <= 0)
|
|
56897
|
+
continue;
|
|
56898
|
+
if (bestIdx === -1 || fractions[idx] > bestFraction || fractions[idx] === bestFraction && shrinkable[idx] > shrinkable[bestIdx]) {
|
|
56899
|
+
bestIdx = idx;
|
|
56900
|
+
bestFraction = fractions[idx];
|
|
56901
|
+
}
|
|
56902
|
+
}
|
|
56903
|
+
if (bestIdx === -1) {
|
|
56904
|
+
break;
|
|
56905
|
+
}
|
|
56906
|
+
shrink[bestIdx] += 1;
|
|
56907
|
+
fractions[bestIdx] = 0;
|
|
56908
|
+
remainingShrink -= 1;
|
|
56909
|
+
}
|
|
56910
|
+
return shrink;
|
|
56911
|
+
}
|
|
57294
56912
|
computeRowHeights(columnWidths) {
|
|
57295
56913
|
const horizontalPadding = this.getHorizontalCellPadding();
|
|
57296
56914
|
const verticalPadding = this.getVerticalCellPadding();
|
|
@@ -57614,7 +57232,7 @@ class TextTableRenderable extends Renderable {
|
|
|
57614
57232
|
if (width === undefined || !Number.isFinite(width) || width <= 0) {
|
|
57615
57233
|
return;
|
|
57616
57234
|
}
|
|
57617
|
-
if (this._wrapMode !== "none" || this.
|
|
57235
|
+
if (this._wrapMode !== "none" || this.isFullWidthMode()) {
|
|
57618
57236
|
return Math.max(1, Math.floor(width));
|
|
57619
57237
|
}
|
|
57620
57238
|
return;
|
|
@@ -57625,6 +57243,12 @@ class TextTableRenderable extends Renderable {
|
|
|
57625
57243
|
getVerticalCellPadding() {
|
|
57626
57244
|
return this._cellPadding * 2;
|
|
57627
57245
|
}
|
|
57246
|
+
resolveColumnFitter(value) {
|
|
57247
|
+
if (value === undefined) {
|
|
57248
|
+
return this._defaultOptions.columnFitter;
|
|
57249
|
+
}
|
|
57250
|
+
return value === "balanced" ? "balanced" : "proportional";
|
|
57251
|
+
}
|
|
57628
57252
|
resolveCellPadding(value) {
|
|
57629
57253
|
if (value === undefined || !Number.isFinite(value)) {
|
|
57630
57254
|
return this._defaultOptions.cellPadding;
|
|
@@ -59400,8 +59024,9 @@ class MarkdownRenderable extends Renderable {
|
|
|
59400
59024
|
resolveTableRenderableOptions() {
|
|
59401
59025
|
const borders = this._tableOptions?.borders ?? true;
|
|
59402
59026
|
return {
|
|
59403
|
-
columnWidthMode: this._tableOptions?.widthMode ?? "
|
|
59404
|
-
|
|
59027
|
+
columnWidthMode: this._tableOptions?.widthMode ?? "full",
|
|
59028
|
+
columnFitter: this._tableOptions?.columnFitter ?? "proportional",
|
|
59029
|
+
wrapMode: this._tableOptions?.wrapMode ?? "word",
|
|
59405
59030
|
cellPadding: this._tableOptions?.cellPadding ?? 0,
|
|
59406
59031
|
border: borders,
|
|
59407
59032
|
outerBorder: this._tableOptions?.outerBorder ?? borders,
|
|
@@ -59413,6 +59038,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
59413
59038
|
}
|
|
59414
59039
|
applyTableRenderableOptions(tableRenderable, options) {
|
|
59415
59040
|
tableRenderable.columnWidthMode = options.columnWidthMode;
|
|
59041
|
+
tableRenderable.columnFitter = options.columnFitter;
|
|
59416
59042
|
tableRenderable.wrapMode = options.wrapMode;
|
|
59417
59043
|
tableRenderable.cellPadding = options.cellPadding;
|
|
59418
59044
|
tableRenderable.border = options.border;
|
|
@@ -59443,6 +59069,7 @@ class MarkdownRenderable extends Renderable {
|
|
|
59443
59069
|
width: "100%",
|
|
59444
59070
|
marginBottom,
|
|
59445
59071
|
columnWidthMode: options.columnWidthMode,
|
|
59072
|
+
columnFitter: options.columnFitter,
|
|
59446
59073
|
wrapMode: options.wrapMode,
|
|
59447
59074
|
cellPadding: options.cellPadding,
|
|
59448
59075
|
border: options.border,
|
|
@@ -60302,6 +59929,34 @@ class ContentRenderable extends BoxRenderable {
|
|
|
60302
59929
|
return this.getChildrenSortedByPrimaryAxis().map((child) => child.num);
|
|
60303
59930
|
}
|
|
60304
59931
|
}
|
|
59932
|
+
var SCROLLBOX_PADDING_KEYS = [
|
|
59933
|
+
"padding",
|
|
59934
|
+
"paddingX",
|
|
59935
|
+
"paddingY",
|
|
59936
|
+
"paddingTop",
|
|
59937
|
+
"paddingRight",
|
|
59938
|
+
"paddingBottom",
|
|
59939
|
+
"paddingLeft"
|
|
59940
|
+
];
|
|
59941
|
+
function pickScrollBoxPadding(options) {
|
|
59942
|
+
if (!options)
|
|
59943
|
+
return {};
|
|
59944
|
+
const picked = {};
|
|
59945
|
+
for (const key of SCROLLBOX_PADDING_KEYS) {
|
|
59946
|
+
const value = options[key];
|
|
59947
|
+
if (value !== undefined) {
|
|
59948
|
+
picked[key] = value;
|
|
59949
|
+
}
|
|
59950
|
+
}
|
|
59951
|
+
return picked;
|
|
59952
|
+
}
|
|
59953
|
+
function stripScrollBoxPadding(options) {
|
|
59954
|
+
const sanitized = { ...options };
|
|
59955
|
+
for (const key of SCROLLBOX_PADDING_KEYS) {
|
|
59956
|
+
delete sanitized[key];
|
|
59957
|
+
}
|
|
59958
|
+
return sanitized;
|
|
59959
|
+
}
|
|
60305
59960
|
|
|
60306
59961
|
class ScrollBoxRenderable extends BoxRenderable {
|
|
60307
59962
|
static idCounter = 0;
|
|
@@ -60449,27 +60104,38 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
60449
60104
|
this._isApplyingStickyScroll = wasApplyingStickyScroll;
|
|
60450
60105
|
}
|
|
60451
60106
|
}
|
|
60452
|
-
constructor(ctx, {
|
|
60453
|
-
|
|
60454
|
-
|
|
60455
|
-
|
|
60456
|
-
|
|
60457
|
-
|
|
60458
|
-
|
|
60459
|
-
|
|
60460
|
-
|
|
60461
|
-
|
|
60462
|
-
|
|
60463
|
-
|
|
60464
|
-
|
|
60465
|
-
|
|
60466
|
-
|
|
60467
|
-
|
|
60107
|
+
constructor(ctx, options) {
|
|
60108
|
+
const {
|
|
60109
|
+
wrapperOptions,
|
|
60110
|
+
viewportOptions,
|
|
60111
|
+
contentOptions,
|
|
60112
|
+
rootOptions,
|
|
60113
|
+
scrollbarOptions,
|
|
60114
|
+
verticalScrollbarOptions,
|
|
60115
|
+
horizontalScrollbarOptions,
|
|
60116
|
+
stickyScroll = false,
|
|
60117
|
+
stickyStart,
|
|
60118
|
+
scrollX = false,
|
|
60119
|
+
scrollY = true,
|
|
60120
|
+
scrollAcceleration,
|
|
60121
|
+
viewportCulling = true,
|
|
60122
|
+
...rootBoxOptions
|
|
60123
|
+
} = options;
|
|
60124
|
+
const forwardedContentPadding = {
|
|
60125
|
+
...pickScrollBoxPadding(rootBoxOptions),
|
|
60126
|
+
...pickScrollBoxPadding(rootOptions)
|
|
60127
|
+
};
|
|
60128
|
+
const sanitizedRootBoxOptions = stripScrollBoxPadding(rootBoxOptions);
|
|
60129
|
+
const sanitizedRootOptions = rootOptions ? stripScrollBoxPadding(rootOptions) : undefined;
|
|
60130
|
+
const mergedContentOptions = {
|
|
60131
|
+
...forwardedContentPadding,
|
|
60132
|
+
...contentOptions
|
|
60133
|
+
};
|
|
60468
60134
|
super(ctx, {
|
|
60469
60135
|
flexDirection: "row",
|
|
60470
60136
|
alignItems: "stretch",
|
|
60471
|
-
...
|
|
60472
|
-
...
|
|
60137
|
+
...sanitizedRootBoxOptions,
|
|
60138
|
+
...sanitizedRootOptions
|
|
60473
60139
|
});
|
|
60474
60140
|
this.internalId = ScrollBoxRenderable.idCounter++;
|
|
60475
60141
|
this._stickyScroll = stickyScroll;
|
|
@@ -60501,7 +60167,7 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
60501
60167
|
onSizeChange: () => {
|
|
60502
60168
|
this.recalculateBarProps();
|
|
60503
60169
|
},
|
|
60504
|
-
...
|
|
60170
|
+
...mergedContentOptions,
|
|
60505
60171
|
id: `scroll-box-content-${this.internalId}`
|
|
60506
60172
|
});
|
|
60507
60173
|
this.viewport.add(this.content);
|
|
@@ -60817,6 +60483,34 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
60817
60483
|
this.requestRender();
|
|
60818
60484
|
});
|
|
60819
60485
|
}
|
|
60486
|
+
set padding(value) {
|
|
60487
|
+
this.content.padding = value;
|
|
60488
|
+
this.requestRender();
|
|
60489
|
+
}
|
|
60490
|
+
set paddingX(value) {
|
|
60491
|
+
this.content.paddingX = value;
|
|
60492
|
+
this.requestRender();
|
|
60493
|
+
}
|
|
60494
|
+
set paddingY(value) {
|
|
60495
|
+
this.content.paddingY = value;
|
|
60496
|
+
this.requestRender();
|
|
60497
|
+
}
|
|
60498
|
+
set paddingTop(value) {
|
|
60499
|
+
this.content.paddingTop = value;
|
|
60500
|
+
this.requestRender();
|
|
60501
|
+
}
|
|
60502
|
+
set paddingRight(value) {
|
|
60503
|
+
this.content.paddingRight = value;
|
|
60504
|
+
this.requestRender();
|
|
60505
|
+
}
|
|
60506
|
+
set paddingBottom(value) {
|
|
60507
|
+
this.content.paddingBottom = value;
|
|
60508
|
+
this.requestRender();
|
|
60509
|
+
}
|
|
60510
|
+
set paddingLeft(value) {
|
|
60511
|
+
this.content.paddingLeft = value;
|
|
60512
|
+
this.requestRender();
|
|
60513
|
+
}
|
|
60820
60514
|
set rootOptions(options) {
|
|
60821
60515
|
Object.assign(this, options);
|
|
60822
60516
|
this.requestRender();
|
|
@@ -61578,8 +61272,8 @@ class TabSelectRenderable extends Renderable {
|
|
|
61578
61272
|
}
|
|
61579
61273
|
}
|
|
61580
61274
|
|
|
61581
|
-
// node_modules/@opentui/react/chunk-
|
|
61582
|
-
|
|
61275
|
+
// node_modules/@opentui/react/chunk-7v2hbtna.js
|
|
61276
|
+
init_chunk_2mx7fq49();
|
|
61583
61277
|
var import_react = __toESM(require_react(), 1);
|
|
61584
61278
|
var import_react2 = __toESM(require_react(), 1);
|
|
61585
61279
|
var import_react3 = __toESM(require_react(), 1);
|
|
@@ -61706,7 +61400,7 @@ class ErrorBoundary extends import_react3.default.Component {
|
|
|
61706
61400
|
}
|
|
61707
61401
|
var package_default = {
|
|
61708
61402
|
name: "@opentui/react",
|
|
61709
|
-
version: "0.1.
|
|
61403
|
+
version: "0.1.84",
|
|
61710
61404
|
description: "React renderer for building terminal user interfaces using OpenTUI core",
|
|
61711
61405
|
license: "MIT",
|
|
61712
61406
|
repository: {
|
|
@@ -62041,7 +61735,7 @@ var hostConfig = {
|
|
|
62041
61735
|
var reconciler = import_react_reconciler.default(hostConfig);
|
|
62042
61736
|
if (process.env["DEV"] === "true") {
|
|
62043
61737
|
try {
|
|
62044
|
-
await
|
|
61738
|
+
await init_chunk_bdqvmfwv().then(() => exports_chunk_bdqvmfwv);
|
|
62045
61739
|
} catch (error) {
|
|
62046
61740
|
if (error.code === "ERR_MODULE_NOT_FOUND") {
|
|
62047
61741
|
console.warn(`
|
|
@@ -62086,7 +61780,7 @@ function createRoot(renderer) {
|
|
|
62086
61780
|
}
|
|
62087
61781
|
|
|
62088
61782
|
// node_modules/@opentui/react/index.js
|
|
62089
|
-
|
|
61783
|
+
init_chunk_2mx7fq49();
|
|
62090
61784
|
var import_react5 = __toESM(require_react(), 1);
|
|
62091
61785
|
var import_react6 = __toESM(require_react(), 1);
|
|
62092
61786
|
var import_react7 = __toESM(require_react(), 1);
|
|
@@ -63074,6 +62768,10 @@ function App() {
|
|
|
63074
62768
|
// index.jsx
|
|
63075
62769
|
var jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
|
|
63076
62770
|
async function main2() {
|
|
62771
|
+
if (process.env.APEX_LOCAL_SERVER === "1") {
|
|
62772
|
+
const { startServer } = await Promise.resolve().then(() => __toESM(require_server(), 1));
|
|
62773
|
+
await startServer();
|
|
62774
|
+
}
|
|
63077
62775
|
const renderer = await createCliRenderer({
|
|
63078
62776
|
useAlternateScreen: true,
|
|
63079
62777
|
exitOnCtrlC: false,
|