context-mode 2.0.0-next.15 → 2.0.0-next.17
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/SHA256SUMS +14 -14
- package/cli.mjs +13 -6
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +75 -73
- package/opencode/plugin.js +4113 -258
- package/package.json +1 -1
- package/pi/index.js +3991 -124
- package/qwen-extension.json +1 -1
- package/run.mjs +14 -10
- package/search.mjs +14 -10
- package/server.mjs +3988 -117
package/pi/index.js
CHANGED
|
@@ -11172,6 +11172,7 @@ function REPLACE_HANDLE_LINE(intent, handle, bytes4, prefix = "", asked = "") {
|
|
|
11172
11172
|
var HANDLE_PROMPT_WORDS = 3;
|
|
11173
11173
|
var MAX_CHUNK_BYTES = 4096;
|
|
11174
11174
|
var SEARCH_PAGE_SIZE = 20;
|
|
11175
|
+
var SEARCH_REPLY_HITS = 5;
|
|
11175
11176
|
var SNIPPET_MAX_BYTES = 800;
|
|
11176
11177
|
var SNIPPET_CODE_MAX_BYTES = 2048;
|
|
11177
11178
|
var MAX_CANDIDATES = 85;
|
|
@@ -11504,7 +11505,7 @@ var DECISION_OPTION_KEY = "option";
|
|
|
11504
11505
|
var DECISION_LABEL_JOIN = " | ";
|
|
11505
11506
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
11506
11507
|
var RELEASE_BRANCH = "release";
|
|
11507
|
-
var BUNDLE_SHA = true ? "
|
|
11508
|
+
var BUNDLE_SHA = true ? "d526f1e54835a809b09257c9587a22172141d4c3" : void 0;
|
|
11508
11509
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
11509
11510
|
var DOCTOR_LABEL = Object.freeze({
|
|
11510
11511
|
D1: "version",
|
|
@@ -13459,8 +13460,8 @@ function jqPath(s) {
|
|
|
13459
13460
|
}
|
|
13460
13461
|
return true;
|
|
13461
13462
|
}
|
|
13462
|
-
function jqWhitelisted(
|
|
13463
|
-
const s =
|
|
13463
|
+
function jqWhitelisted(filter2) {
|
|
13464
|
+
const s = filter2.trim();
|
|
13464
13465
|
if (s === JQ_WHITELIST.identity || s === JQ_WHITELIST.length) return true;
|
|
13465
13466
|
const bar = s.indexOf(JQ_WHITELIST.pipeLength.charAt(0));
|
|
13466
13467
|
if (bar < 0) return jqPath(s);
|
|
@@ -14317,15 +14318,15 @@ function matchesAnyDenyPattern(text, patterns, subject = BASH_SUBJECT) {
|
|
|
14317
14318
|
// src/prompt/_generated.ts
|
|
14318
14319
|
var INSTRUCTIONS = "context-mode keeps large output out of the conversation.\n\nWhen a step counts, sums, filters or finds something in over about 20 lines of data (logs, test or build output, big JSON or CSV, long files, web pages), use ctx_execute and print only the answer, not a raw Bash or Read result.\n\nA large tool result is indexed and cut to its best-matching parts; ctx_search finds the rest. A large file's Read is denied: use offset and limit, or ctx_execute with file set. Use normal tools for small output and edits.\n";
|
|
14319
14320
|
var TOOL_DESCRIPTIONS = Object.freeze({
|
|
14320
|
-
ctx_execute: "
|
|
14321
|
-
ctx_batch: "
|
|
14322
|
-
ctx_index: "
|
|
14323
|
-
ctx_search: "
|
|
14324
|
-
ctx_resume: "
|
|
14325
|
-
ctx_stats: "
|
|
14326
|
-
ctx_doctor: "
|
|
14327
|
-
ctx_upgrade: "
|
|
14328
|
-
ctx_purge: "
|
|
14321
|
+
ctx_execute: 'Example: `ctx_execute({language:"shell",code:"git log --oneline -5"})`. Required: language, code.\nRuns code in a sandboxed subprocess in the project directory (shell, powershell, javascript, typescript, python, or another runtime on PATH); only what the code prints comes back. For a large file, set `file` to its local path: the code gets it in the CTX_FILE environment variable. Set `intent` when output may be large: the matching sections come back and the full output is indexed for ctx_search. `timeoutMs` defaults to and caps at 600000; then the whole process tree is killed.',
|
|
14322
|
+
ctx_batch: 'Example: `ctx_batch({commands:["git log --oneline -5"],queries:["recent changes"]})`. Required: commands, queries.\nRuns several shell commands, then answers several search queries over their combined output, in one call. Use it to collect facts from more than one command at once, for example test results plus recent commits, when you need specific answers rather than the full text. Returns the matching sections and a one-line footer.',
|
|
14323
|
+
ctx_index: 'Example: `ctx_index({path:"docs/api.md"})`. Required: one of path, content, url.\nStores content so it can be searched later: a local file or folder (nested .gitignore files are respected), raw text, or a URL, which is fetched and converted to Markdown. Use it for documentation or large files you will query more than once, then use ctx_search instead of reading the content again. Returns the source label and how many chunks were stored.',
|
|
14324
|
+
ctx_search: 'Example: `ctx_search({queries:["auth middleware"]})`. Required: queries.\nSearches content stored with ctx_index and earlier sandbox output in this project. Pass several queries in one call. By default it searches the current worktree; set `scope` to `project` for all worktrees or `session` for this session only. Results from the current session rank first, then by relevance, ranked with measurably better recall than plain keyword search. Set `sort` to `timeline` for oldest-first order across this session, prior sessions and memory, paged with `after`; `offset` is for relevance order only. Set `source` to `decision` to search only rows where the user answered a question. Every hit names its source. When nothing matches, the reply states the scope and how many sources are indexed.',
|
|
14325
|
+
ctx_resume: "Example: `ctx_resume({})`. Required: none.\nReturns a summary of up to 2 KB for this session: the last task and user request, files changed, open errors, and search terms for ctx_search. A large row is shown as a pointer line instead of its full text; call `ctx_resume(seq: N)` with that line's number to read the full row. Call it with no `seq` to get the state block on demand. Use it after the conversation was compacted or resumed, before you repeat earlier work.",
|
|
14326
|
+
ctx_stats: "Example: `ctx_stats({})`. Required: none.\nReports how many bytes context-mode kept out of the conversation in this session and in this project, per agent, as a Markdown table. Show the table to the user as it is. Use it when the user asks what context-mode saved.",
|
|
14327
|
+
ctx_doctor: "Example: `ctx_doctor({})`. Required: none.\nChecks this context-mode install and reports a table with one row per check: version, Node and node:sqlite, host config and hooks for this agent, MCP connection, project and worktree, database health, index contents, and hook timing. Each failed row names its cause and the fix in one line. It changes nothing. Use it when the user asks whether context-mode works, or after a context-mode error.",
|
|
14328
|
+
ctx_upgrade: "Example: `ctx_upgrade({})`. Required: none.\nUpdates context-mode to the latest release for this agent and rewrites only context-mode's own entries in the host config. User entries and user settings such as hook timeouts are kept, and old entries are erased. Returns a table of what changed and whether a restart is needed. Use it only when the user asks to update context-mode.",
|
|
14329
|
+
ctx_purge: 'Example: `ctx_purge({source:"old-docs"})`. Required: one of session, source, project.\nDeletes stored data: one session, one indexed source, or everything stored for this project. This cannot be undone. Use it only when the user asks to forget or reset data.'
|
|
14329
14330
|
});
|
|
14330
14331
|
var READ_DENY_TEMPLATE = 'context-mode: {size}-byte file, over the one-read limit. Run ctx_execute(language, code, file="{path}") and print only the answer.';
|
|
14331
14332
|
|
|
@@ -14357,7 +14358,7 @@ var ALLOW = Object.freeze({ kind: "allow" });
|
|
|
14357
14358
|
var deny = (reason) => ({ kind: "deny", reason });
|
|
14358
14359
|
var str = (v) => typeof v === "string" ? v : void 0;
|
|
14359
14360
|
var present = (v) => v !== void 0 && v !== null;
|
|
14360
|
-
var has = (
|
|
14361
|
+
var has = (list4, v) => list4.includes(v);
|
|
14361
14362
|
function decide(ev, row5, userDeny) {
|
|
14362
14363
|
const tool = ev.tool;
|
|
14363
14364
|
if (tool === void 0) return ALLOW;
|
|
@@ -15374,7 +15375,7 @@ function buildSnippet(row5, given, maxBytes, codeMaxBytes = SNIPPET_CODE_MAX_BYT
|
|
|
15374
15375
|
if (blocks.length === 0) return clipLine(row5, 0, row5.length, -1, maxBytes);
|
|
15375
15376
|
const lower = row5.toLowerCase();
|
|
15376
15377
|
const hay = lower.length === row5.length ? lower : row5;
|
|
15377
|
-
const
|
|
15378
|
+
const find2 = (t) => {
|
|
15378
15379
|
const out = [];
|
|
15379
15380
|
if (t.text === "") return out;
|
|
15380
15381
|
for (let p = hay.indexOf(t.text); p >= 0 && out.length < MAX_POSITIONS; p = hay.indexOf(t.text, p + 1)) {
|
|
@@ -15384,10 +15385,10 @@ function buildSnippet(row5, given, maxBytes, codeMaxBytes = SNIPPET_CODE_MAX_BYT
|
|
|
15384
15385
|
return out;
|
|
15385
15386
|
};
|
|
15386
15387
|
let terms = given;
|
|
15387
|
-
let pos = terms.map(
|
|
15388
|
+
let pos = terms.map(find2);
|
|
15388
15389
|
if (pos.every((p) => p.length === 0)) {
|
|
15389
15390
|
terms = given.filter((t) => t.text.length >= 5).map((t) => ({ ...t, text: t.text.slice(0, Math.max(4, t.text.length - 2)) }));
|
|
15390
|
-
pos = terms.map(
|
|
15391
|
+
pos = terms.map(find2);
|
|
15391
15392
|
}
|
|
15392
15393
|
const count = (ti, a, b) => {
|
|
15393
15394
|
const ps = pos[ti];
|
|
@@ -17171,6 +17172,8 @@ RETURNING id`;
|
|
|
17171
17172
|
var INSERT_CHUNK = `
|
|
17172
17173
|
INSERT INTO chunks(source_id, session_id, worktree, agent, ord, body, title) VALUES (?, ?, ?, ?, ?, ?, ?)`;
|
|
17173
17174
|
var TITLE_WEIGHT = 1;
|
|
17175
|
+
var RAW_LABEL_SUFFIX = " (raw)";
|
|
17176
|
+
var NOT_RAW = `AND (:source IS NOT NULL OR substr(s.label, -${RAW_LABEL_SUFFIX.length}) <> '${RAW_LABEL_SUFFIX}')`;
|
|
17174
17177
|
var PORTER_MATCH = `
|
|
17175
17178
|
SELECT chunks.rowid AS rid, chunks.source_id AS source_id, chunks.session_id AS session_id,
|
|
17176
17179
|
chunks.worktree AS worktree, chunks.ord AS ord, s.created_ts AS created_ts,
|
|
@@ -17180,7 +17183,8 @@ var PORTER_MATCH = `
|
|
|
17180
17183
|
WHERE chunks MATCH :match
|
|
17181
17184
|
AND (:scope <> 'session' OR chunks.session_id = :session_id)
|
|
17182
17185
|
AND (:scope <> 'worktree' OR chunks.worktree = :worktree)
|
|
17183
|
-
AND (:source IS NULL OR s.label = :source)
|
|
17186
|
+
AND (:source IS NULL OR s.label = :source)
|
|
17187
|
+
${NOT_RAW}`;
|
|
17184
17188
|
var PORTER_ORDER = `
|
|
17185
17189
|
ORDER BY (session_id = :session_id) DESC, (worktree = :worktree) DESC, full DESC, score DESC, source_id DESC, ord ASC`;
|
|
17186
17190
|
var PORTER_RANK_PROJECT = `
|
|
@@ -17208,6 +17212,7 @@ WHERE chunks_tri MATCH :match
|
|
|
17208
17212
|
AND (:scope <> 'session' OR c.session_id = :session_id)
|
|
17209
17213
|
AND (:scope <> 'worktree' OR c.worktree = :worktree)
|
|
17210
17214
|
AND (:source IS NULL OR s.label = :source)
|
|
17215
|
+
${NOT_RAW}
|
|
17211
17216
|
ORDER BY bm25(chunks_tri, 1.0, ${TITLE_WEIGHT}) ASC, c.source_id DESC, c.ord ASC`;
|
|
17212
17217
|
var PAGE_ROWS = `
|
|
17213
17218
|
SELECT c.rowid AS rid, c.source_id AS source_id, c.ord AS ord, c.body AS body, s.label AS label
|
|
@@ -17482,16 +17487,16 @@ function typoTerms(db, words) {
|
|
|
17482
17487
|
function ftsQuery(db, q, scope, ctx, sessionId, limit, offset, source) {
|
|
17483
17488
|
const terms = searchTerms(q);
|
|
17484
17489
|
if (terms.length === 0) return [];
|
|
17485
|
-
const
|
|
17490
|
+
const filter2 = { scope, session_id: sessionId, worktree: ctx.worktree, source: source ?? null };
|
|
17486
17491
|
const rrf = scope === "project" ? { k: RRF_K } : {};
|
|
17487
|
-
const porter = (t) => stmt(db.raw, porterRankSql(scope)).all({ ...
|
|
17492
|
+
const porter = (t) => stmt(db.raw, porterRankSql(scope)).all({ ...filter2, match: t.join(" OR "), all: t.join(" "), ...rrf });
|
|
17488
17493
|
let pList = porter(terms);
|
|
17489
17494
|
if (pList.length === 0) {
|
|
17490
17495
|
const fixed = typoTerms(db, terms.map((t) => t.slice(1, -2).replaceAll('""', '"')));
|
|
17491
17496
|
if (fixed !== null) pList = porter(fixed);
|
|
17492
17497
|
}
|
|
17493
17498
|
const tm = trigramMatch(q);
|
|
17494
|
-
const tList = tm === "" ? [] : stmt(db.raw, TRI_RANK).all({ ...
|
|
17499
|
+
const tList = tm === "" ? [] : stmt(db.raw, TRI_RANK).all({ ...filter2, match: tm });
|
|
17495
17500
|
const fused = /* @__PURE__ */ new Map();
|
|
17496
17501
|
pList.forEach((r, i) => fused.set(Number(r.rid), { r, s: 1 / (RRF_K + i + 1), full: Number(r.full ?? 0), p: i }));
|
|
17497
17502
|
tList.forEach((r, i) => {
|
|
@@ -17589,7 +17594,7 @@ function timelineOrder(a, b) {
|
|
|
17589
17594
|
return pa < pb ? -1 : pa > pb ? 1 : 0;
|
|
17590
17595
|
}
|
|
17591
17596
|
function ftsQueryTimeline(db, scope, ctx, sessionId, limit, after, source, memory) {
|
|
17592
|
-
const
|
|
17597
|
+
const filter2 = {
|
|
17593
17598
|
scope,
|
|
17594
17599
|
session_id: sessionId,
|
|
17595
17600
|
worktree: ctx.worktree,
|
|
@@ -17599,7 +17604,7 @@ function ftsQueryTimeline(db, scope, ctx, sessionId, limit, after, source, memor
|
|
|
17599
17604
|
const reserved = DECISION_SOURCE;
|
|
17600
17605
|
const off = limit - 1;
|
|
17601
17606
|
const merged = [];
|
|
17602
|
-
for (const e of db.raw.prepare(TL_EVENTS).all({ ...
|
|
17607
|
+
for (const e of db.raw.prepare(TL_EVENTS).all({ ...filter2, after: from, off })) {
|
|
17603
17608
|
merged.push({
|
|
17604
17609
|
origin: "session",
|
|
17605
17610
|
ts: Number(e.created_at),
|
|
@@ -17610,7 +17615,7 @@ function ftsQueryTimeline(db, scope, ctx, sessionId, limit, after, source, memor
|
|
|
17610
17615
|
text: e.body ?? e.key ?? e.path ?? ""
|
|
17611
17616
|
});
|
|
17612
17617
|
}
|
|
17613
|
-
const srcRows = db.raw.prepare(TL_SOURCES).all({ ...
|
|
17618
|
+
const srcRows = db.raw.prepare(TL_SOURCES).all({ ...filter2, after: from, off, reserved });
|
|
17614
17619
|
if (srcRows.length > 0) {
|
|
17615
17620
|
const bodies = /* @__PURE__ */ new Map();
|
|
17616
17621
|
const ids = JSON.stringify(srcRows.map((r) => Number(r.id)));
|
|
@@ -17634,7 +17639,7 @@ function ftsQueryTimeline(db, scope, ctx, sessionId, limit, after, source, memor
|
|
|
17634
17639
|
const rows = merged.slice(0, end);
|
|
17635
17640
|
if (rows.length === 0) return { rows, more: false };
|
|
17636
17641
|
if (merged.length > end) return { rows, more: true };
|
|
17637
|
-
const res = db.raw.prepare(TL_MORE).get({ ...
|
|
17642
|
+
const res = db.raw.prepare(TL_MORE).get({ ...filter2, after: rows[rows.length - 1].ts, reserved });
|
|
17638
17643
|
return { rows, more: Number(res.more) === 1 };
|
|
17639
17644
|
}
|
|
17640
17645
|
var RANK_DDL = `CREATE VIRTUAL TABLE r USING fts5(body, ${FTS_TOKENIZE}, content='')`;
|
|
@@ -17758,8 +17763,8 @@ function make(section, row5, text, repeatCount, query) {
|
|
|
17758
17763
|
if (bytes4 < 1) throw new Error("compaction: empty candidate line (DECISIONS-r9 M9).");
|
|
17759
17764
|
return { section, seq: row5.seq, turn: row5.turn, text, bytes: bytes4, repeatCount, pinned: section === "last_request", query };
|
|
17760
17765
|
}
|
|
17761
|
-
function capSection(
|
|
17762
|
-
return
|
|
17766
|
+
function capSection(list4) {
|
|
17767
|
+
return list4.length > MAX_CANDIDATES ? list4.slice(list4.length - MAX_CANDIDATES) : list4;
|
|
17763
17768
|
}
|
|
17764
17769
|
function emptySet() {
|
|
17765
17770
|
return { lastRequest: null, openErrors: [], changedFiles: [], decisions: [], earlierRequests: [], indexedSources: [] };
|
|
@@ -18108,10 +18113,10 @@ function lineBlocks(src, md) {
|
|
|
18108
18113
|
heading = void 0;
|
|
18109
18114
|
fenceInfo = void 0;
|
|
18110
18115
|
};
|
|
18111
|
-
const add = (from, to,
|
|
18116
|
+
const add = (from, to, table2) => {
|
|
18112
18117
|
if (start < 0) start = from;
|
|
18113
18118
|
end = to;
|
|
18114
|
-
inTable =
|
|
18119
|
+
inTable = table2;
|
|
18115
18120
|
};
|
|
18116
18121
|
let pos = 0;
|
|
18117
18122
|
while (pos <= src.length) {
|
|
@@ -18132,9 +18137,9 @@ function lineBlocks(src, md) {
|
|
|
18132
18137
|
} else {
|
|
18133
18138
|
const opener = md ? fenceOf(line) : "";
|
|
18134
18139
|
const head = md && opener === "" ? headingOf(line) : void 0;
|
|
18135
|
-
const
|
|
18136
|
-
if (md && start >= 0 && (
|
|
18137
|
-
add(pos, eol,
|
|
18140
|
+
const table2 = md && opener === "" && head === void 0 && line.includes("|");
|
|
18141
|
+
if (md && start >= 0 && (table2 !== inTable || opener !== "" || head !== void 0)) close();
|
|
18142
|
+
add(pos, eol, table2);
|
|
18138
18143
|
fence = opener;
|
|
18139
18144
|
if (opener !== "") fenceInfo = { fence: opener, openEnd: eol, closeStart: -1 };
|
|
18140
18145
|
if (head !== void 0) {
|
|
@@ -18841,8 +18846,8 @@ function nodeTooOld(version4) {
|
|
|
18841
18846
|
}
|
|
18842
18847
|
return false;
|
|
18843
18848
|
}
|
|
18844
|
-
function has2(
|
|
18845
|
-
return
|
|
18849
|
+
function has2(list4, name) {
|
|
18850
|
+
return list4 !== void 0 && list4.some((n) => n.toLowerCase() === name);
|
|
18846
18851
|
}
|
|
18847
18852
|
function kindOf(row5, name) {
|
|
18848
18853
|
const n = name.toLowerCase();
|
|
@@ -19613,15 +19618,19 @@ function callText(queries, scope, source, cursor) {
|
|
|
19613
19618
|
function decisionQueries(input) {
|
|
19614
19619
|
return input.source === DECISION_SOURCE && input.queries.length === 0 ? [""] : input.queries;
|
|
19615
19620
|
}
|
|
19621
|
+
function pageSize(input) {
|
|
19622
|
+
return input.source === DECISION_SOURCE ? SEARCH_PAGE_SIZE : SEARCH_REPLY_HITS;
|
|
19623
|
+
}
|
|
19616
19624
|
function page(db, q, input, scope, ctx, offset) {
|
|
19625
|
+
const size = pageSize(input);
|
|
19617
19626
|
if (input.source === DECISION_SOURCE && q.trim() === "") {
|
|
19618
|
-
return ftsListSource(db, DECISION_SOURCE, scope, ctx.project, ctx.sessionId,
|
|
19627
|
+
return ftsListSource(db, DECISION_SOURCE, scope, ctx.project, ctx.sessionId, size, offset);
|
|
19619
19628
|
}
|
|
19620
|
-
const hits = ftsQuery(db, q, scope, ctx.project, ctx.sessionId,
|
|
19629
|
+
const hits = ftsQuery(db, q, scope, ctx.project, ctx.sessionId, size, offset, input.source);
|
|
19621
19630
|
if (hits.length > 0 || input.source === void 0) return hits;
|
|
19622
19631
|
const any3 = offset === 0 ? hits : ftsQuery(db, q, scope, ctx.project, ctx.sessionId, 1, 0, input.source);
|
|
19623
19632
|
if (any3.length > 0) return hits;
|
|
19624
|
-
return ftsListSource(db, input.source, scope, ctx.project, ctx.sessionId,
|
|
19633
|
+
return ftsListSource(db, input.source, scope, ctx.project, ctx.sessionId, size, offset);
|
|
19625
19634
|
}
|
|
19626
19635
|
var JSON_ROWS_PAGE = 5;
|
|
19627
19636
|
var JSON_SOURCE_MAX_BYTES = 8 * 1024 * 1024;
|
|
@@ -19665,12 +19674,13 @@ function jsonRowsReply(db, input, scope, ctx) {
|
|
|
19665
19674
|
function relevance(db, given, scope, ctx) {
|
|
19666
19675
|
const input = { ...given, queries: decisionQueries(given) };
|
|
19667
19676
|
const offset = input.offset ?? 0;
|
|
19677
|
+
const size = pageSize(input);
|
|
19668
19678
|
const seen = /* @__PURE__ */ new Set();
|
|
19669
19679
|
const entries = [];
|
|
19670
19680
|
const full = /* @__PURE__ */ new Set();
|
|
19671
19681
|
input.queries.forEach((q, qi) => {
|
|
19672
19682
|
const hits = page(db, q, input, scope, ctx, offset);
|
|
19673
|
-
if (hits.length ===
|
|
19683
|
+
if (hits.length === size) full.add(qi);
|
|
19674
19684
|
hits.forEach((hit, i) => {
|
|
19675
19685
|
const key = hit.sourceId + ":" + hit.ord;
|
|
19676
19686
|
if (seen.has(key)) return;
|
|
@@ -19681,7 +19691,7 @@ function relevance(db, given, scope, ctx) {
|
|
|
19681
19691
|
if (entries.length === 0) return zeroHits(db, scope, ctx, input.source);
|
|
19682
19692
|
const moreLine3 = (q, pos) => "More: " + callText([q], scope, input.source, "offset:" + pos);
|
|
19683
19693
|
let reserve = 0;
|
|
19684
|
-
for (const q of input.queries) reserve += bytes2(moreLine3(q, offset +
|
|
19694
|
+
for (const q of input.queries) reserve += bytes2(moreLine3(q, offset + size)) + 1;
|
|
19685
19695
|
const lines = [];
|
|
19686
19696
|
const more = [];
|
|
19687
19697
|
let used = 0;
|
|
@@ -19705,7 +19715,7 @@ function relevance(db, given, scope, ctx) {
|
|
|
19705
19715
|
lines.push(line);
|
|
19706
19716
|
used += bytes2(line) + 1;
|
|
19707
19717
|
}
|
|
19708
|
-
if (!stopped && full.has(qi)) more.push(moreLine3(q, offset +
|
|
19718
|
+
if (!stopped && full.has(qi)) more.push(moreLine3(q, offset + size));
|
|
19709
19719
|
});
|
|
19710
19720
|
return reply(lines.concat(more).join("\n"), false);
|
|
19711
19721
|
}
|
|
@@ -21925,17 +21935,17 @@ function generateConvertTOMLValue(convertValue) {
|
|
|
21925
21935
|
return baseTable;
|
|
21926
21936
|
},
|
|
21927
21937
|
TOMLTable(node3, baseTable = {}) {
|
|
21928
|
-
const
|
|
21929
|
-
for (const body of node3.body) resolveValue(body,
|
|
21938
|
+
const table2 = getTable(baseTable, resolveValue(node3.key), node3.kind === "array");
|
|
21939
|
+
for (const body of node3.body) resolveValue(body, table2);
|
|
21930
21940
|
return baseTable;
|
|
21931
21941
|
},
|
|
21932
21942
|
TOMLArray(node3) {
|
|
21933
21943
|
return node3.elements.map((e) => resolveValue(e));
|
|
21934
21944
|
},
|
|
21935
21945
|
TOMLInlineTable(node3) {
|
|
21936
|
-
const
|
|
21937
|
-
for (const body of node3.body) resolveValue(body,
|
|
21938
|
-
return
|
|
21946
|
+
const table2 = {};
|
|
21947
|
+
for (const body of node3.body) resolveValue(body, table2);
|
|
21948
|
+
return table2;
|
|
21939
21949
|
},
|
|
21940
21950
|
TOMLKey(node3) {
|
|
21941
21951
|
return node3.keys.map((key) => resolveValue(key));
|
|
@@ -22478,8 +22488,8 @@ function listTarget(key, own4, v1, alt = []) {
|
|
|
22478
22488
|
return {
|
|
22479
22489
|
key: [key],
|
|
22480
22490
|
next(current) {
|
|
22481
|
-
const
|
|
22482
|
-
return
|
|
22491
|
+
const list4 = Array.isArray(current) ? current.filter((x) => x !== v1) : [];
|
|
22492
|
+
return list4.includes(own4) || alt.some((a) => list4.includes(a)) ? list4 : [...list4, own4];
|
|
22483
22493
|
}
|
|
22484
22494
|
};
|
|
22485
22495
|
}
|
|
@@ -24117,6 +24127,3807 @@ async function safeFetch(url4, signal) {
|
|
|
24117
24127
|
}
|
|
24118
24128
|
}
|
|
24119
24129
|
|
|
24130
|
+
// node_modules/entities/dist/decode-codepoint.js
|
|
24131
|
+
var c1 = [
|
|
24132
|
+
8364,
|
|
24133
|
+
0,
|
|
24134
|
+
8218,
|
|
24135
|
+
402,
|
|
24136
|
+
8222,
|
|
24137
|
+
8230,
|
|
24138
|
+
8224,
|
|
24139
|
+
8225,
|
|
24140
|
+
710,
|
|
24141
|
+
8240,
|
|
24142
|
+
352,
|
|
24143
|
+
8249,
|
|
24144
|
+
338,
|
|
24145
|
+
0,
|
|
24146
|
+
381,
|
|
24147
|
+
0,
|
|
24148
|
+
0,
|
|
24149
|
+
8216,
|
|
24150
|
+
8217,
|
|
24151
|
+
8220,
|
|
24152
|
+
8221,
|
|
24153
|
+
8226,
|
|
24154
|
+
8211,
|
|
24155
|
+
8212,
|
|
24156
|
+
732,
|
|
24157
|
+
8482,
|
|
24158
|
+
353,
|
|
24159
|
+
8250,
|
|
24160
|
+
339,
|
|
24161
|
+
0,
|
|
24162
|
+
382,
|
|
24163
|
+
376
|
|
24164
|
+
];
|
|
24165
|
+
function isInvalidCodePoint(codePoint) {
|
|
24166
|
+
return codePoint === 0 || codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111;
|
|
24167
|
+
}
|
|
24168
|
+
function replaceCodePoint(codePoint) {
|
|
24169
|
+
if (isInvalidCodePoint(codePoint)) {
|
|
24170
|
+
return 65533;
|
|
24171
|
+
}
|
|
24172
|
+
if (codePoint >= 128 && codePoint <= 159) {
|
|
24173
|
+
return c1[codePoint - 128] || codePoint;
|
|
24174
|
+
}
|
|
24175
|
+
return codePoint;
|
|
24176
|
+
}
|
|
24177
|
+
function replaceCodePointXML(codePoint) {
|
|
24178
|
+
return isInvalidCodePoint(codePoint) ? 65533 : codePoint;
|
|
24179
|
+
}
|
|
24180
|
+
|
|
24181
|
+
// node_modules/entities/dist/internal/decode-shared.js
|
|
24182
|
+
var BASE91_INVERSE = /* @__PURE__ */ (() => {
|
|
24183
|
+
const table2 = new Uint8Array(127);
|
|
24184
|
+
let code = 0;
|
|
24185
|
+
for (let char = 33; char <= 126; char++) {
|
|
24186
|
+
if (char !== 34 && char !== 36 && char !== 92) {
|
|
24187
|
+
table2[char] = code++;
|
|
24188
|
+
}
|
|
24189
|
+
}
|
|
24190
|
+
return table2;
|
|
24191
|
+
})();
|
|
24192
|
+
function decodeTrieDict(input, resultLength, atomCount, dict1AtomCount, ngramCount, dictSize) {
|
|
24193
|
+
const base = 91;
|
|
24194
|
+
const inputLength = input.length;
|
|
24195
|
+
const twoCharBias = dictSize * (base - 1);
|
|
24196
|
+
let pos = 0;
|
|
24197
|
+
const readSlotCode = () => {
|
|
24198
|
+
const c12 = BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
24199
|
+
return c12 < dictSize ? c12 : c12 * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
24200
|
+
};
|
|
24201
|
+
const dict2AtomCount = atomCount - dict1AtomCount;
|
|
24202
|
+
const slotCount = atomCount + ngramCount;
|
|
24203
|
+
const single = new Int32Array(slotCount);
|
|
24204
|
+
single.fill(-1, dict1AtomCount, dictSize);
|
|
24205
|
+
single.fill(-1, dictSize + dict2AtomCount, slotCount);
|
|
24206
|
+
const start = new Int32Array(slotCount);
|
|
24207
|
+
const length = new Int32Array(slotCount);
|
|
24208
|
+
function decodeDelta(count, off) {
|
|
24209
|
+
let previous = 0;
|
|
24210
|
+
let slot = off;
|
|
24211
|
+
const end = off + count;
|
|
24212
|
+
while (slot < end) {
|
|
24213
|
+
const code = BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
24214
|
+
if (code < 89) {
|
|
24215
|
+
previous += code;
|
|
24216
|
+
single[slot++] = previous;
|
|
24217
|
+
} else if (code === 89) {
|
|
24218
|
+
let runLength = BASE91_INVERSE[input.charCodeAt(pos++)] + 2;
|
|
24219
|
+
while (runLength--)
|
|
24220
|
+
single[slot++] = ++previous;
|
|
24221
|
+
} else {
|
|
24222
|
+
const next = BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
24223
|
+
previous += 89 + // eslint-disable-next-line unicorn/prefer-minimal-ternary -- branches read a different number of side-effecting input bytes
|
|
24224
|
+
(next < 90 ? next * base + BASE91_INVERSE[input.charCodeAt(pos++)] : BASE91_INVERSE[input.charCodeAt(pos++)] * 8281 + BASE91_INVERSE[input.charCodeAt(pos++)] * base + BASE91_INVERSE[input.charCodeAt(pos++)]);
|
|
24225
|
+
single[slot++] = previous;
|
|
24226
|
+
}
|
|
24227
|
+
}
|
|
24228
|
+
}
|
|
24229
|
+
decodeDelta(dict1AtomCount, 0);
|
|
24230
|
+
decodeDelta(dict2AtomCount, dictSize);
|
|
24231
|
+
const references = new Int32Array(ngramCount * 2);
|
|
24232
|
+
let poolSize = 0;
|
|
24233
|
+
let ngramIndex = 0;
|
|
24234
|
+
function readNgramReferences(count, startSlot) {
|
|
24235
|
+
for (let index = 0; index < count; index++) {
|
|
24236
|
+
const slot = startSlot + index;
|
|
24237
|
+
const a = readSlotCode();
|
|
24238
|
+
const b = readSlotCode();
|
|
24239
|
+
references[ngramIndex * 2] = a;
|
|
24240
|
+
references[ngramIndex * 2 + 1] = b;
|
|
24241
|
+
ngramIndex += 1;
|
|
24242
|
+
start[slot] = poolSize;
|
|
24243
|
+
const entryLength = (single[a] < 0 ? length[a] : 1) + (single[b] < 0 ? length[b] : 1);
|
|
24244
|
+
length[slot] = entryLength;
|
|
24245
|
+
poolSize += entryLength;
|
|
24246
|
+
}
|
|
24247
|
+
}
|
|
24248
|
+
readNgramReferences(ngramCount - dictSize + dict1AtomCount, dictSize + dict2AtomCount);
|
|
24249
|
+
readNgramReferences(dictSize - dict1AtomCount, dict1AtomCount);
|
|
24250
|
+
const pool = new Uint16Array(poolSize);
|
|
24251
|
+
let write2 = 0;
|
|
24252
|
+
for (let index = 0; index < ngramIndex; index++) {
|
|
24253
|
+
for (let half = 0; half < 2; half++) {
|
|
24254
|
+
const source = references[index * 2 + half];
|
|
24255
|
+
const value = single[source];
|
|
24256
|
+
if (value < 0) {
|
|
24257
|
+
let read3 = start[source];
|
|
24258
|
+
const readEnd = read3 + length[source];
|
|
24259
|
+
while (read3 < readEnd)
|
|
24260
|
+
pool[write2++] = pool[read3++];
|
|
24261
|
+
} else {
|
|
24262
|
+
pool[write2++] = value;
|
|
24263
|
+
}
|
|
24264
|
+
}
|
|
24265
|
+
}
|
|
24266
|
+
const out = new Uint16Array(resultLength);
|
|
24267
|
+
let outIndex = 0;
|
|
24268
|
+
while (pos < inputLength) {
|
|
24269
|
+
let slot = BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
24270
|
+
if (slot >= dictSize) {
|
|
24271
|
+
slot = slot * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
24272
|
+
}
|
|
24273
|
+
const value = single[slot];
|
|
24274
|
+
if (value < 0) {
|
|
24275
|
+
let read3 = start[slot];
|
|
24276
|
+
const readEnd = read3 + length[slot];
|
|
24277
|
+
while (read3 < readEnd)
|
|
24278
|
+
out[outIndex++] = pool[read3++];
|
|
24279
|
+
} else {
|
|
24280
|
+
out[outIndex++] = value;
|
|
24281
|
+
}
|
|
24282
|
+
}
|
|
24283
|
+
return out;
|
|
24284
|
+
}
|
|
24285
|
+
|
|
24286
|
+
// node_modules/entities/dist/generated/decode-data-html.js
|
|
24287
|
+
var htmlDecodeTree = /* @__PURE__ */ decodeTrieDict("!}.&u%}'&}*'~!6*)%&,~!J~!J~%L~y<~!R,~~%Lu~~#GD~~#|)1#%}^%}2%+#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C2F|]i[vrv{z;h]eb?C2F|^iZu.vix,hZq3ah!.(?C2F|QOu!5ShXM:2<BaY?C2F|P", 13494, 2713, 49, 25, 61);
|
|
24288
|
+
|
|
24289
|
+
// node_modules/entities/dist/generated/decode-data-xml.js
|
|
24290
|
+
var xmlDecodeTree = /* @__PURE__ */ new Uint16Array([
|
|
24291
|
+
512,
|
|
24292
|
+
26465,
|
|
24293
|
+
29036,
|
|
24294
|
+
7,
|
|
24295
|
+
0,
|
|
24296
|
+
2,
|
|
24297
|
+
4,
|
|
24298
|
+
116,
|
|
24299
|
+
24638,
|
|
24300
|
+
116,
|
|
24301
|
+
24636,
|
|
24302
|
+
8693,
|
|
24303
|
+
29807,
|
|
24304
|
+
24610,
|
|
24305
|
+
621,
|
|
24306
|
+
1,
|
|
24307
|
+
0,
|
|
24308
|
+
0,
|
|
24309
|
+
3,
|
|
24310
|
+
112,
|
|
24311
|
+
24614,
|
|
24312
|
+
111,
|
|
24313
|
+
115,
|
|
24314
|
+
24615
|
|
24315
|
+
]);
|
|
24316
|
+
|
|
24317
|
+
// node_modules/entities/dist/internal/bin-trie-flags.js
|
|
24318
|
+
var BinTrieFlags;
|
|
24319
|
+
(function(BinTrieFlags2) {
|
|
24320
|
+
BinTrieFlags2[BinTrieFlags2["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
|
|
24321
|
+
BinTrieFlags2[BinTrieFlags2["FLAG13"] = 8192] = "FLAG13";
|
|
24322
|
+
BinTrieFlags2[BinTrieFlags2["BRANCH_LENGTH"] = 8064] = "BRANCH_LENGTH";
|
|
24323
|
+
BinTrieFlags2[BinTrieFlags2["JUMP_TABLE"] = 127] = "JUMP_TABLE";
|
|
24324
|
+
BinTrieFlags2[BinTrieFlags2["VALUE_MASK"] = 8191] = "VALUE_MASK";
|
|
24325
|
+
})(BinTrieFlags || (BinTrieFlags = {}));
|
|
24326
|
+
|
|
24327
|
+
// node_modules/entities/dist/decode.js
|
|
24328
|
+
var CharCodes;
|
|
24329
|
+
(function(CharCodes3) {
|
|
24330
|
+
CharCodes3[CharCodes3["AMP"] = 38] = "AMP";
|
|
24331
|
+
CharCodes3[CharCodes3["NUM"] = 35] = "NUM";
|
|
24332
|
+
CharCodes3[CharCodes3["SEMI"] = 59] = "SEMI";
|
|
24333
|
+
CharCodes3[CharCodes3["EQUALS"] = 61] = "EQUALS";
|
|
24334
|
+
CharCodes3[CharCodes3["ZERO"] = 48] = "ZERO";
|
|
24335
|
+
CharCodes3[CharCodes3["NINE"] = 57] = "NINE";
|
|
24336
|
+
CharCodes3[CharCodes3["LOWER_A"] = 97] = "LOWER_A";
|
|
24337
|
+
CharCodes3[CharCodes3["LOWER_X"] = 120] = "LOWER_X";
|
|
24338
|
+
})(CharCodes || (CharCodes = {}));
|
|
24339
|
+
var TO_LOWER_BIT = 32;
|
|
24340
|
+
function isNumber2(code) {
|
|
24341
|
+
return code - CharCodes.ZERO >>> 0 <= 9;
|
|
24342
|
+
}
|
|
24343
|
+
function isHexadecimalCharacter(code) {
|
|
24344
|
+
return (code | TO_LOWER_BIT) - CharCodes.LOWER_A >>> 0 <= 5;
|
|
24345
|
+
}
|
|
24346
|
+
function isAlpha2(code) {
|
|
24347
|
+
return (code | TO_LOWER_BIT) - CharCodes.LOWER_A >>> 0 <= 25;
|
|
24348
|
+
}
|
|
24349
|
+
function isEntityInAttributeInvalidEnd(code) {
|
|
24350
|
+
return code === CharCodes.EQUALS || isAlpha2(code) || isNumber2(code);
|
|
24351
|
+
}
|
|
24352
|
+
var EntityDecoderState;
|
|
24353
|
+
(function(EntityDecoderState2) {
|
|
24354
|
+
EntityDecoderState2[EntityDecoderState2["EntityStart"] = 0] = "EntityStart";
|
|
24355
|
+
EntityDecoderState2[EntityDecoderState2["NumericStart"] = 1] = "NumericStart";
|
|
24356
|
+
EntityDecoderState2[EntityDecoderState2["NumericDecimal"] = 2] = "NumericDecimal";
|
|
24357
|
+
EntityDecoderState2[EntityDecoderState2["NumericHex"] = 3] = "NumericHex";
|
|
24358
|
+
EntityDecoderState2[EntityDecoderState2["NamedEntity"] = 4] = "NamedEntity";
|
|
24359
|
+
})(EntityDecoderState || (EntityDecoderState = {}));
|
|
24360
|
+
var DecodingMode;
|
|
24361
|
+
(function(DecodingMode2) {
|
|
24362
|
+
DecodingMode2[DecodingMode2["Legacy"] = 0] = "Legacy";
|
|
24363
|
+
DecodingMode2[DecodingMode2["Strict"] = 1] = "Strict";
|
|
24364
|
+
DecodingMode2[DecodingMode2["Attribute"] = 2] = "Attribute";
|
|
24365
|
+
})(DecodingMode || (DecodingMode = {}));
|
|
24366
|
+
var EntityDecoder = class {
|
|
24367
|
+
decodeTree;
|
|
24368
|
+
emitCodePoint;
|
|
24369
|
+
errors;
|
|
24370
|
+
/** The current state of the decoder. */
|
|
24371
|
+
state = EntityDecoderState.EntityStart;
|
|
24372
|
+
/** Characters that were consumed while parsing an entity. */
|
|
24373
|
+
consumed = 1;
|
|
24374
|
+
/**
|
|
24375
|
+
* The result of the entity.
|
|
24376
|
+
*
|
|
24377
|
+
* For named entities: the trie index of the best legacy match so far
|
|
24378
|
+
* (0 = none). For numeric entities: the accumulated code point.
|
|
24379
|
+
*/
|
|
24380
|
+
result = 0;
|
|
24381
|
+
/** The current index in the decode tree. */
|
|
24382
|
+
treeIndex = 0;
|
|
24383
|
+
/**
|
|
24384
|
+
* Characters consumed since the last recorded legacy match, plus one.
|
|
24385
|
+
* Invariant at the top of the `stateNamedEntity` loop: `excess` equals
|
|
24386
|
+
* the number of unrecorded consumed characters + 1.
|
|
24387
|
+
*/
|
|
24388
|
+
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: False positive (read via destructuring)
|
|
24389
|
+
excess = 1;
|
|
24390
|
+
/** The mode in which the decoder is operating. */
|
|
24391
|
+
decodeMode = DecodingMode.Strict;
|
|
24392
|
+
/** The number of characters that have been consumed in the current run. */
|
|
24393
|
+
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: False positive
|
|
24394
|
+
runConsumed = 0;
|
|
24395
|
+
constructor(decodeTree, emitCodePoint, errors) {
|
|
24396
|
+
this.decodeTree = decodeTree;
|
|
24397
|
+
this.emitCodePoint = emitCodePoint;
|
|
24398
|
+
this.errors = errors;
|
|
24399
|
+
}
|
|
24400
|
+
/**
|
|
24401
|
+
* Resets the instance to make it reusable.
|
|
24402
|
+
* @param decodeMode Entity decoding mode to use.
|
|
24403
|
+
*/
|
|
24404
|
+
startEntity(decodeMode) {
|
|
24405
|
+
this.decodeMode = decodeMode;
|
|
24406
|
+
this.state = EntityDecoderState.EntityStart;
|
|
24407
|
+
this.result = 0;
|
|
24408
|
+
this.treeIndex = 0;
|
|
24409
|
+
this.excess = 1;
|
|
24410
|
+
this.consumed = 1;
|
|
24411
|
+
this.runConsumed = 0;
|
|
24412
|
+
}
|
|
24413
|
+
/**
|
|
24414
|
+
* Write an entity to the decoder. This can be called multiple times with partial entities.
|
|
24415
|
+
* If the entity is incomplete, the decoder will return -1.
|
|
24416
|
+
*
|
|
24417
|
+
* Mirrors the non-streaming `decodeWithTrie`, but with the ability to stop decoding if the
|
|
24418
|
+
* entity is incomplete, and resume when the next string is written.
|
|
24419
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
24420
|
+
* @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
|
|
24421
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
24422
|
+
*/
|
|
24423
|
+
write(input, offset) {
|
|
24424
|
+
switch (this.state) {
|
|
24425
|
+
case EntityDecoderState.EntityStart: {
|
|
24426
|
+
if (input.charCodeAt(offset) === CharCodes.NUM) {
|
|
24427
|
+
this.state = EntityDecoderState.NumericStart;
|
|
24428
|
+
this.consumed += 1;
|
|
24429
|
+
return this.stateNumericStart(input, offset + 1);
|
|
24430
|
+
}
|
|
24431
|
+
this.state = EntityDecoderState.NamedEntity;
|
|
24432
|
+
return this.stateNamedEntity(input, offset);
|
|
24433
|
+
}
|
|
24434
|
+
case EntityDecoderState.NumericStart: {
|
|
24435
|
+
return this.stateNumericStart(input, offset);
|
|
24436
|
+
}
|
|
24437
|
+
case EntityDecoderState.NumericDecimal: {
|
|
24438
|
+
return this.stateNumericDecimal(input, offset);
|
|
24439
|
+
}
|
|
24440
|
+
case EntityDecoderState.NumericHex: {
|
|
24441
|
+
return this.stateNumericHex(input, offset);
|
|
24442
|
+
}
|
|
24443
|
+
default: {
|
|
24444
|
+
return this.stateNamedEntity(input, offset);
|
|
24445
|
+
}
|
|
24446
|
+
}
|
|
24447
|
+
}
|
|
24448
|
+
/**
|
|
24449
|
+
* Switches between the numeric decimal and hexadecimal states.
|
|
24450
|
+
*
|
|
24451
|
+
* Equivalent to the `Numeric character reference state` in the HTML spec.
|
|
24452
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
24453
|
+
* @param offset The current offset.
|
|
24454
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
24455
|
+
*/
|
|
24456
|
+
// eslint-disable-next-line unicorn/consistent-class-member-order
|
|
24457
|
+
stateNumericStart(input, offset) {
|
|
24458
|
+
if (offset >= input.length) {
|
|
24459
|
+
return -1;
|
|
24460
|
+
}
|
|
24461
|
+
if ((input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
|
|
24462
|
+
this.state = EntityDecoderState.NumericHex;
|
|
24463
|
+
this.consumed += 1;
|
|
24464
|
+
return this.stateNumericHex(input, offset + 1);
|
|
24465
|
+
}
|
|
24466
|
+
this.state = EntityDecoderState.NumericDecimal;
|
|
24467
|
+
return this.stateNumericDecimal(input, offset);
|
|
24468
|
+
}
|
|
24469
|
+
/**
|
|
24470
|
+
* Parses a hexadecimal numeric entity.
|
|
24471
|
+
*
|
|
24472
|
+
* Equivalent to the `Hexademical character reference state` in the HTML
|
|
24473
|
+
* spec. Digit parsing matches the hex loop in `parseNumericEntity`.
|
|
24474
|
+
* The accumulated value is preserved for numeric validation callbacks.
|
|
24475
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
24476
|
+
* @param offset The current offset.
|
|
24477
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
24478
|
+
*/
|
|
24479
|
+
stateNumericHex(input, offset) {
|
|
24480
|
+
const inputLength = input.length;
|
|
24481
|
+
let { result } = this;
|
|
24482
|
+
let { consumed } = this;
|
|
24483
|
+
while (offset < inputLength) {
|
|
24484
|
+
const char = input.charCodeAt(offset);
|
|
24485
|
+
if (isNumber2(char) || isHexadecimalCharacter(char)) {
|
|
24486
|
+
const digit = char <= CharCodes.NINE ? char - CharCodes.ZERO : (char | TO_LOWER_BIT) - CharCodes.LOWER_A + 10;
|
|
24487
|
+
result = result * 16 + digit;
|
|
24488
|
+
consumed += 1;
|
|
24489
|
+
offset += 1;
|
|
24490
|
+
} else {
|
|
24491
|
+
this.result = result;
|
|
24492
|
+
this.consumed = consumed;
|
|
24493
|
+
return this.emitNumericEntity(char, 3);
|
|
24494
|
+
}
|
|
24495
|
+
}
|
|
24496
|
+
this.result = result;
|
|
24497
|
+
this.consumed = consumed;
|
|
24498
|
+
return -1;
|
|
24499
|
+
}
|
|
24500
|
+
/**
|
|
24501
|
+
* Parses a decimal numeric entity.
|
|
24502
|
+
*
|
|
24503
|
+
* Equivalent to the `Decimal character reference state` in the HTML
|
|
24504
|
+
* spec. Digit parsing matches the decimal loop in `parseNumericEntity`.
|
|
24505
|
+
* The accumulated value is preserved for numeric validation callbacks.
|
|
24506
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
24507
|
+
* @param offset The current offset.
|
|
24508
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
24509
|
+
*/
|
|
24510
|
+
stateNumericDecimal(input, offset) {
|
|
24511
|
+
const inputLength = input.length;
|
|
24512
|
+
let { result } = this;
|
|
24513
|
+
let { consumed } = this;
|
|
24514
|
+
while (offset < inputLength) {
|
|
24515
|
+
const digit = input.charCodeAt(offset) - CharCodes.ZERO;
|
|
24516
|
+
if (digit >>> 0 > 9) {
|
|
24517
|
+
this.result = result;
|
|
24518
|
+
this.consumed = consumed;
|
|
24519
|
+
return this.emitNumericEntity(digit + CharCodes.ZERO, 2);
|
|
24520
|
+
}
|
|
24521
|
+
result = result * 10 + digit;
|
|
24522
|
+
consumed += 1;
|
|
24523
|
+
offset += 1;
|
|
24524
|
+
}
|
|
24525
|
+
this.result = result;
|
|
24526
|
+
this.consumed = consumed;
|
|
24527
|
+
return -1;
|
|
24528
|
+
}
|
|
24529
|
+
/**
|
|
24530
|
+
* Validate and emit a numeric entity.
|
|
24531
|
+
*
|
|
24532
|
+
* Implements the logic from the `Hexademical character reference start
|
|
24533
|
+
* state` and `Numeric character reference end state` in the HTML spec.
|
|
24534
|
+
* @param lastCp The last code point of the entity. Used to see if the
|
|
24535
|
+
* entity was terminated with a semicolon.
|
|
24536
|
+
* @param expectedLength The minimum number of characters that should be
|
|
24537
|
+
* consumed. Used to validate that at least one digit
|
|
24538
|
+
* was consumed.
|
|
24539
|
+
* @returns The number of characters that were consumed.
|
|
24540
|
+
*/
|
|
24541
|
+
emitNumericEntity(lastCp, expectedLength) {
|
|
24542
|
+
if (this.consumed <= expectedLength) {
|
|
24543
|
+
this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
|
|
24544
|
+
return 0;
|
|
24545
|
+
}
|
|
24546
|
+
if (lastCp === CharCodes.SEMI) {
|
|
24547
|
+
this.consumed += 1;
|
|
24548
|
+
} else if (this.decodeMode === DecodingMode.Strict) {
|
|
24549
|
+
return 0;
|
|
24550
|
+
}
|
|
24551
|
+
this.emitCodePoint((this.decodeTree === xmlDecodeTree ? replaceCodePointXML : replaceCodePoint)(this.result), this.consumed);
|
|
24552
|
+
if (this.errors) {
|
|
24553
|
+
if (lastCp !== CharCodes.SEMI) {
|
|
24554
|
+
this.errors.missingSemicolonAfterCharacterReference();
|
|
24555
|
+
}
|
|
24556
|
+
this.errors.validateNumericCharacterReference(this.result);
|
|
24557
|
+
}
|
|
24558
|
+
return this.consumed;
|
|
24559
|
+
}
|
|
24560
|
+
/**
|
|
24561
|
+
* Flush locally-tracked walk state back to the fields, then emit the
|
|
24562
|
+
* recorded legacy match or reject (cold path — at most once per
|
|
24563
|
+
* entity). Called after failed navigation (leaf node, branch miss, or
|
|
24564
|
+
* compact-run mismatch). In attribute mode, reject if no legacy was
|
|
24565
|
+
* recorded at the current node, if we descended past it, or if the
|
|
24566
|
+
* pending input character is an invalid attribute terminator.
|
|
24567
|
+
* @param consumed Locally-tracked consumed count.
|
|
24568
|
+
* @param excess Locally-tracked excess count.
|
|
24569
|
+
* @param char Pending input character (may be the mismatching char).
|
|
24570
|
+
* @param valueLength Value length at the current trie node.
|
|
24571
|
+
*/
|
|
24572
|
+
flushAndEmitLegacyOrReject(consumed, excess, char, valueLength) {
|
|
24573
|
+
this.consumed = consumed;
|
|
24574
|
+
this.excess = excess;
|
|
24575
|
+
return this.result === 0 || this.decodeMode === DecodingMode.Attribute && (valueLength === 0 || excess > 1 || isEntityInAttributeInvalidEnd(char)) ? 0 : this.emitNotTerminatedNamedEntity();
|
|
24576
|
+
}
|
|
24577
|
+
/**
|
|
24578
|
+
* Parses a named entity.
|
|
24579
|
+
*
|
|
24580
|
+
* Equivalent to the `Named character reference state` in the HTML spec.
|
|
24581
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
24582
|
+
* @param offset The current offset.
|
|
24583
|
+
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
24584
|
+
*/
|
|
24585
|
+
stateNamedEntity(input, offset) {
|
|
24586
|
+
const { decodeTree } = this;
|
|
24587
|
+
const inputLength = input.length;
|
|
24588
|
+
const isStrict = this.decodeMode === DecodingMode.Strict;
|
|
24589
|
+
let { treeIndex } = this;
|
|
24590
|
+
let { excess } = this;
|
|
24591
|
+
let { consumed } = this;
|
|
24592
|
+
let current = decodeTree[treeIndex];
|
|
24593
|
+
while (offset < inputLength) {
|
|
24594
|
+
while ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === 0 && (current & BinTrieFlags.JUMP_TABLE) !== 0) {
|
|
24595
|
+
const char2 = input.charCodeAt(offset);
|
|
24596
|
+
const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
|
|
24597
|
+
const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
24598
|
+
if (branchCount === 0) {
|
|
24599
|
+
if (char2 !== jumpOffset) {
|
|
24600
|
+
return this.flushAndEmitLegacyOrReject(consumed, excess, char2, 0);
|
|
24601
|
+
}
|
|
24602
|
+
treeIndex += 1;
|
|
24603
|
+
} else {
|
|
24604
|
+
const slot = char2 - jumpOffset;
|
|
24605
|
+
if (slot >>> 0 >= branchCount) {
|
|
24606
|
+
return this.flushAndEmitLegacyOrReject(consumed, excess, char2, 0);
|
|
24607
|
+
}
|
|
24608
|
+
const stored = decodeTree[treeIndex + 1 + slot];
|
|
24609
|
+
if (stored === 0) {
|
|
24610
|
+
return this.flushAndEmitLegacyOrReject(consumed, excess, char2, 0);
|
|
24611
|
+
}
|
|
24612
|
+
treeIndex = treeIndex + branchCount + stored & 65535;
|
|
24613
|
+
}
|
|
24614
|
+
current = decodeTree[treeIndex];
|
|
24615
|
+
offset += 1;
|
|
24616
|
+
excess += 1;
|
|
24617
|
+
if (offset >= inputLength)
|
|
24618
|
+
break;
|
|
24619
|
+
}
|
|
24620
|
+
if (offset >= inputLength)
|
|
24621
|
+
break;
|
|
24622
|
+
if ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === BinTrieFlags.FLAG13) {
|
|
24623
|
+
const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
24624
|
+
let { runConsumed } = this;
|
|
24625
|
+
if (runConsumed === 0) {
|
|
24626
|
+
const char2 = input.charCodeAt(offset);
|
|
24627
|
+
if (char2 !== (current & BinTrieFlags.JUMP_TABLE)) {
|
|
24628
|
+
return this.flushAndEmitLegacyOrReject(consumed, excess, char2, 0);
|
|
24629
|
+
}
|
|
24630
|
+
offset += 1;
|
|
24631
|
+
excess += 1;
|
|
24632
|
+
runConsumed = 1;
|
|
24633
|
+
}
|
|
24634
|
+
while (runConsumed < runLength) {
|
|
24635
|
+
if (offset >= inputLength) {
|
|
24636
|
+
this.treeIndex = treeIndex;
|
|
24637
|
+
this.excess = excess;
|
|
24638
|
+
this.consumed = consumed;
|
|
24639
|
+
this.runConsumed = runConsumed;
|
|
24640
|
+
return -1;
|
|
24641
|
+
}
|
|
24642
|
+
const charIndexInPacked = runConsumed - 1;
|
|
24643
|
+
const packedWord = decodeTree[treeIndex + 1 + (charIndexInPacked >> 1)];
|
|
24644
|
+
const expectedChar = packedWord >> ((charIndexInPacked & 1) << 3) & 255;
|
|
24645
|
+
const char2 = input.charCodeAt(offset);
|
|
24646
|
+
if (char2 !== expectedChar) {
|
|
24647
|
+
this.runConsumed = 0;
|
|
24648
|
+
return this.flushAndEmitLegacyOrReject(consumed, excess, char2, 0);
|
|
24649
|
+
}
|
|
24650
|
+
offset += 1;
|
|
24651
|
+
excess += 1;
|
|
24652
|
+
runConsumed += 1;
|
|
24653
|
+
}
|
|
24654
|
+
this.runConsumed = 0;
|
|
24655
|
+
treeIndex += 1 + (runLength >> 1);
|
|
24656
|
+
current = decodeTree[treeIndex];
|
|
24657
|
+
continue;
|
|
24658
|
+
}
|
|
24659
|
+
const valueLength = current >>> 14;
|
|
24660
|
+
const char = input.charCodeAt(offset);
|
|
24661
|
+
if (valueLength !== 0) {
|
|
24662
|
+
if (!isStrict && (current & BinTrieFlags.FLAG13) === 0) {
|
|
24663
|
+
this.result = treeIndex;
|
|
24664
|
+
consumed += excess - 1;
|
|
24665
|
+
excess = 1;
|
|
24666
|
+
}
|
|
24667
|
+
if (char === CharCodes.SEMI) {
|
|
24668
|
+
return this.emitNamedEntityData(treeIndex, valueLength, consumed + excess);
|
|
24669
|
+
}
|
|
24670
|
+
if (valueLength === 1) {
|
|
24671
|
+
return this.flushAndEmitLegacyOrReject(consumed, excess, char, valueLength);
|
|
24672
|
+
}
|
|
24673
|
+
}
|
|
24674
|
+
const next = determineBranch(decodeTree, current, treeIndex + (valueLength || 1), char);
|
|
24675
|
+
if (next < 0) {
|
|
24676
|
+
return this.flushAndEmitLegacyOrReject(consumed, excess, char, valueLength);
|
|
24677
|
+
}
|
|
24678
|
+
treeIndex = next;
|
|
24679
|
+
current = decodeTree[treeIndex];
|
|
24680
|
+
offset += 1;
|
|
24681
|
+
excess += 1;
|
|
24682
|
+
}
|
|
24683
|
+
if (!isStrict && current >>> 14 !== 0 && (current & BinTrieFlags.FLAG13) === 0) {
|
|
24684
|
+
this.result = treeIndex;
|
|
24685
|
+
consumed += excess - 1;
|
|
24686
|
+
excess = 1;
|
|
24687
|
+
}
|
|
24688
|
+
this.treeIndex = treeIndex;
|
|
24689
|
+
this.excess = excess;
|
|
24690
|
+
this.consumed = consumed;
|
|
24691
|
+
return -1;
|
|
24692
|
+
}
|
|
24693
|
+
/**
|
|
24694
|
+
* Emit a named entity that was not terminated with a semicolon.
|
|
24695
|
+
* @returns The number of characters consumed.
|
|
24696
|
+
*/
|
|
24697
|
+
emitNotTerminatedNamedEntity() {
|
|
24698
|
+
const { result, decodeTree } = this;
|
|
24699
|
+
const valueLength = decodeTree[result] >>> 14;
|
|
24700
|
+
this.emitNamedEntityData(result, valueLength, this.consumed);
|
|
24701
|
+
this.errors?.missingSemicolonAfterCharacterReference();
|
|
24702
|
+
return this.consumed;
|
|
24703
|
+
}
|
|
24704
|
+
/**
|
|
24705
|
+
* Emit a named entity.
|
|
24706
|
+
* @param result The index of the entity in the decode tree.
|
|
24707
|
+
* @param valueLength Encoded value length (header plus any value words).
|
|
24708
|
+
* @param consumed The number of characters consumed.
|
|
24709
|
+
* @returns The number of characters consumed.
|
|
24710
|
+
*/
|
|
24711
|
+
emitNamedEntityData(result, valueLength, consumed) {
|
|
24712
|
+
const { decodeTree } = this;
|
|
24713
|
+
this.emitCodePoint(valueLength === 1 ? decodeTree[result] & BinTrieFlags.VALUE_MASK : decodeTree[result + 1], consumed);
|
|
24714
|
+
if (valueLength === 3) {
|
|
24715
|
+
this.emitCodePoint(decodeTree[result + 2], consumed);
|
|
24716
|
+
}
|
|
24717
|
+
return consumed;
|
|
24718
|
+
}
|
|
24719
|
+
/**
|
|
24720
|
+
* Signal to the parser that the end of the input was reached.
|
|
24721
|
+
*
|
|
24722
|
+
* Remaining data will be emitted and relevant errors will be produced.
|
|
24723
|
+
* @returns The number of characters consumed.
|
|
24724
|
+
*/
|
|
24725
|
+
end() {
|
|
24726
|
+
switch (this.state) {
|
|
24727
|
+
case EntityDecoderState.NamedEntity: {
|
|
24728
|
+
return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;
|
|
24729
|
+
}
|
|
24730
|
+
// Otherwise, emit a numeric entity if we have one.
|
|
24731
|
+
case EntityDecoderState.NumericDecimal: {
|
|
24732
|
+
return this.emitNumericEntity(0, 2);
|
|
24733
|
+
}
|
|
24734
|
+
case EntityDecoderState.NumericHex: {
|
|
24735
|
+
return this.emitNumericEntity(0, 3);
|
|
24736
|
+
}
|
|
24737
|
+
case EntityDecoderState.NumericStart: {
|
|
24738
|
+
this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
|
|
24739
|
+
return 0;
|
|
24740
|
+
}
|
|
24741
|
+
default: {
|
|
24742
|
+
return 0;
|
|
24743
|
+
}
|
|
24744
|
+
}
|
|
24745
|
+
}
|
|
24746
|
+
};
|
|
24747
|
+
function determineBranch(decodeTree, current, nodeIndex, char) {
|
|
24748
|
+
const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
24749
|
+
const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
|
|
24750
|
+
if (jumpOffset) {
|
|
24751
|
+
if (branchCount === 0) {
|
|
24752
|
+
return char === jumpOffset ? nodeIndex : -1;
|
|
24753
|
+
}
|
|
24754
|
+
const slot = char - jumpOffset;
|
|
24755
|
+
if (slot >>> 0 >= branchCount)
|
|
24756
|
+
return -1;
|
|
24757
|
+
const stored = decodeTree[nodeIndex + slot];
|
|
24758
|
+
return stored === 0 ? -1 : nodeIndex + branchCount + stored - 1 & 65535;
|
|
24759
|
+
}
|
|
24760
|
+
if (branchCount === 0)
|
|
24761
|
+
return -1;
|
|
24762
|
+
const packedKeySlots = branchCount + 1 >> 1;
|
|
24763
|
+
const branchEnd = nodeIndex + packedKeySlots + branchCount;
|
|
24764
|
+
for (let index = 0; index < branchCount; index++) {
|
|
24765
|
+
const packed = decodeTree[nodeIndex + (index >> 1)];
|
|
24766
|
+
const key = packed >> ((index & 1) << 3) & 255;
|
|
24767
|
+
if (key === char) {
|
|
24768
|
+
const pointerIndex = nodeIndex + packedKeySlots + index;
|
|
24769
|
+
return branchEnd + decodeTree[pointerIndex] & 65535;
|
|
24770
|
+
}
|
|
24771
|
+
if (key > char)
|
|
24772
|
+
return -1;
|
|
24773
|
+
}
|
|
24774
|
+
return -1;
|
|
24775
|
+
}
|
|
24776
|
+
|
|
24777
|
+
// node_modules/htmlparser2/dist/Tokenizer.js
|
|
24778
|
+
var CharCodes2;
|
|
24779
|
+
(function(CharCodes3) {
|
|
24780
|
+
CharCodes3[CharCodes3["Tab"] = 9] = "Tab";
|
|
24781
|
+
CharCodes3[CharCodes3["NewLine"] = 10] = "NewLine";
|
|
24782
|
+
CharCodes3[CharCodes3["FormFeed"] = 12] = "FormFeed";
|
|
24783
|
+
CharCodes3[CharCodes3["CarriageReturn"] = 13] = "CarriageReturn";
|
|
24784
|
+
CharCodes3[CharCodes3["Space"] = 32] = "Space";
|
|
24785
|
+
CharCodes3[CharCodes3["ExclamationMark"] = 33] = "ExclamationMark";
|
|
24786
|
+
CharCodes3[CharCodes3["Number"] = 35] = "Number";
|
|
24787
|
+
CharCodes3[CharCodes3["Amp"] = 38] = "Amp";
|
|
24788
|
+
CharCodes3[CharCodes3["SingleQuote"] = 39] = "SingleQuote";
|
|
24789
|
+
CharCodes3[CharCodes3["DoubleQuote"] = 34] = "DoubleQuote";
|
|
24790
|
+
CharCodes3[CharCodes3["Dash"] = 45] = "Dash";
|
|
24791
|
+
CharCodes3[CharCodes3["Slash"] = 47] = "Slash";
|
|
24792
|
+
CharCodes3[CharCodes3["Zero"] = 48] = "Zero";
|
|
24793
|
+
CharCodes3[CharCodes3["Nine"] = 57] = "Nine";
|
|
24794
|
+
CharCodes3[CharCodes3["Semi"] = 59] = "Semi";
|
|
24795
|
+
CharCodes3[CharCodes3["Lt"] = 60] = "Lt";
|
|
24796
|
+
CharCodes3[CharCodes3["Eq"] = 61] = "Eq";
|
|
24797
|
+
CharCodes3[CharCodes3["Gt"] = 62] = "Gt";
|
|
24798
|
+
CharCodes3[CharCodes3["Questionmark"] = 63] = "Questionmark";
|
|
24799
|
+
CharCodes3[CharCodes3["UpperA"] = 65] = "UpperA";
|
|
24800
|
+
CharCodes3[CharCodes3["LowerA"] = 97] = "LowerA";
|
|
24801
|
+
CharCodes3[CharCodes3["UpperF"] = 70] = "UpperF";
|
|
24802
|
+
CharCodes3[CharCodes3["LowerF"] = 102] = "LowerF";
|
|
24803
|
+
CharCodes3[CharCodes3["UpperZ"] = 90] = "UpperZ";
|
|
24804
|
+
CharCodes3[CharCodes3["LowerZ"] = 122] = "LowerZ";
|
|
24805
|
+
CharCodes3[CharCodes3["LowerX"] = 120] = "LowerX";
|
|
24806
|
+
CharCodes3[CharCodes3["OpeningSquareBracket"] = 91] = "OpeningSquareBracket";
|
|
24807
|
+
})(CharCodes2 || (CharCodes2 = {}));
|
|
24808
|
+
var State;
|
|
24809
|
+
(function(State2) {
|
|
24810
|
+
State2[State2["Text"] = 1] = "Text";
|
|
24811
|
+
State2[State2["BeforeTagName"] = 2] = "BeforeTagName";
|
|
24812
|
+
State2[State2["InTagName"] = 3] = "InTagName";
|
|
24813
|
+
State2[State2["InSelfClosingTag"] = 4] = "InSelfClosingTag";
|
|
24814
|
+
State2[State2["BeforeClosingTagName"] = 5] = "BeforeClosingTagName";
|
|
24815
|
+
State2[State2["InClosingTagName"] = 6] = "InClosingTagName";
|
|
24816
|
+
State2[State2["AfterClosingTagName"] = 7] = "AfterClosingTagName";
|
|
24817
|
+
State2[State2["BeforeAttributeName"] = 8] = "BeforeAttributeName";
|
|
24818
|
+
State2[State2["InAttributeName"] = 9] = "InAttributeName";
|
|
24819
|
+
State2[State2["AfterAttributeName"] = 10] = "AfterAttributeName";
|
|
24820
|
+
State2[State2["BeforeAttributeValue"] = 11] = "BeforeAttributeValue";
|
|
24821
|
+
State2[State2["InAttributeValueDq"] = 12] = "InAttributeValueDq";
|
|
24822
|
+
State2[State2["InAttributeValueSq"] = 13] = "InAttributeValueSq";
|
|
24823
|
+
State2[State2["InAttributeValueNq"] = 14] = "InAttributeValueNq";
|
|
24824
|
+
State2[State2["BeforeDeclaration"] = 15] = "BeforeDeclaration";
|
|
24825
|
+
State2[State2["InDeclaration"] = 16] = "InDeclaration";
|
|
24826
|
+
State2[State2["InProcessingInstruction"] = 17] = "InProcessingInstruction";
|
|
24827
|
+
State2[State2["BeforeComment"] = 18] = "BeforeComment";
|
|
24828
|
+
State2[State2["CDATASequence"] = 19] = "CDATASequence";
|
|
24829
|
+
State2[State2["DeclarationSequence"] = 20] = "DeclarationSequence";
|
|
24830
|
+
State2[State2["InSpecialComment"] = 21] = "InSpecialComment";
|
|
24831
|
+
State2[State2["InCommentLike"] = 22] = "InCommentLike";
|
|
24832
|
+
State2[State2["SpecialStartSequence"] = 23] = "SpecialStartSequence";
|
|
24833
|
+
State2[State2["InSpecialTag"] = 24] = "InSpecialTag";
|
|
24834
|
+
State2[State2["InPlainText"] = 25] = "InPlainText";
|
|
24835
|
+
State2[State2["InEntity"] = 26] = "InEntity";
|
|
24836
|
+
})(State || (State = {}));
|
|
24837
|
+
function isWhitespace2(c) {
|
|
24838
|
+
return c === CharCodes2.Space || c === CharCodes2.NewLine || c === CharCodes2.Tab || c === CharCodes2.FormFeed || c === CharCodes2.CarriageReturn;
|
|
24839
|
+
}
|
|
24840
|
+
function isEndOfTagSection(c) {
|
|
24841
|
+
return c === CharCodes2.Slash || c === CharCodes2.Gt || isWhitespace2(c);
|
|
24842
|
+
}
|
|
24843
|
+
function isASCIIAlpha(c) {
|
|
24844
|
+
return c >= CharCodes2.LowerA && c <= CharCodes2.LowerZ || c >= CharCodes2.UpperA && c <= CharCodes2.UpperZ;
|
|
24845
|
+
}
|
|
24846
|
+
var QuoteType;
|
|
24847
|
+
(function(QuoteType2) {
|
|
24848
|
+
QuoteType2[QuoteType2["NoValue"] = 0] = "NoValue";
|
|
24849
|
+
QuoteType2[QuoteType2["Unquoted"] = 1] = "Unquoted";
|
|
24850
|
+
QuoteType2[QuoteType2["Single"] = 2] = "Single";
|
|
24851
|
+
QuoteType2[QuoteType2["Double"] = 3] = "Double";
|
|
24852
|
+
})(QuoteType || (QuoteType = {}));
|
|
24853
|
+
var Sequences = {
|
|
24854
|
+
Empty: new Uint8Array(0),
|
|
24855
|
+
Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
|
|
24856
|
+
// CDATA[
|
|
24857
|
+
CdataEnd: new Uint8Array([93, 93, 62]),
|
|
24858
|
+
// ]]>
|
|
24859
|
+
CommentEnd: new Uint8Array([45, 45, 33, 62]),
|
|
24860
|
+
// `--!>`
|
|
24861
|
+
Doctype: new Uint8Array([100, 111, 99, 116, 121, 112, 101]),
|
|
24862
|
+
// `doctype`
|
|
24863
|
+
IframeEnd: new Uint8Array([60, 47, 105, 102, 114, 97, 109, 101]),
|
|
24864
|
+
// `</iframe`
|
|
24865
|
+
NoembedEnd: new Uint8Array([
|
|
24866
|
+
60,
|
|
24867
|
+
47,
|
|
24868
|
+
110,
|
|
24869
|
+
111,
|
|
24870
|
+
101,
|
|
24871
|
+
109,
|
|
24872
|
+
98,
|
|
24873
|
+
101,
|
|
24874
|
+
100
|
|
24875
|
+
]),
|
|
24876
|
+
// `</noembed`
|
|
24877
|
+
NoframesEnd: new Uint8Array([
|
|
24878
|
+
60,
|
|
24879
|
+
47,
|
|
24880
|
+
110,
|
|
24881
|
+
111,
|
|
24882
|
+
102,
|
|
24883
|
+
114,
|
|
24884
|
+
97,
|
|
24885
|
+
109,
|
|
24886
|
+
101,
|
|
24887
|
+
115
|
|
24888
|
+
]),
|
|
24889
|
+
// `</noframes`
|
|
24890
|
+
Plaintext: new Uint8Array([
|
|
24891
|
+
60,
|
|
24892
|
+
47,
|
|
24893
|
+
112,
|
|
24894
|
+
108,
|
|
24895
|
+
97,
|
|
24896
|
+
105,
|
|
24897
|
+
110,
|
|
24898
|
+
116,
|
|
24899
|
+
101,
|
|
24900
|
+
120,
|
|
24901
|
+
116
|
|
24902
|
+
]),
|
|
24903
|
+
// `</plaintext`
|
|
24904
|
+
ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
|
|
24905
|
+
// `</script`
|
|
24906
|
+
StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
|
|
24907
|
+
// `</style`
|
|
24908
|
+
TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
|
|
24909
|
+
// `</title`
|
|
24910
|
+
TextareaEnd: new Uint8Array([
|
|
24911
|
+
60,
|
|
24912
|
+
47,
|
|
24913
|
+
116,
|
|
24914
|
+
101,
|
|
24915
|
+
120,
|
|
24916
|
+
116,
|
|
24917
|
+
97,
|
|
24918
|
+
114,
|
|
24919
|
+
101,
|
|
24920
|
+
97
|
|
24921
|
+
]),
|
|
24922
|
+
// `</textarea`
|
|
24923
|
+
XmpEnd: new Uint8Array([60, 47, 120, 109, 112])
|
|
24924
|
+
// `</xmp`
|
|
24925
|
+
};
|
|
24926
|
+
var specialStartSequences = /* @__PURE__ */ new Map([
|
|
24927
|
+
[Sequences.IframeEnd[2], Sequences.IframeEnd],
|
|
24928
|
+
[Sequences.NoembedEnd[2], Sequences.NoembedEnd],
|
|
24929
|
+
[Sequences.Plaintext[2], Sequences.Plaintext],
|
|
24930
|
+
[Sequences.ScriptEnd[2], Sequences.ScriptEnd],
|
|
24931
|
+
[Sequences.TitleEnd[2], Sequences.TitleEnd],
|
|
24932
|
+
[Sequences.XmpEnd[2], Sequences.XmpEnd]
|
|
24933
|
+
]);
|
|
24934
|
+
var Tokenizer2 = class {
|
|
24935
|
+
cbs;
|
|
24936
|
+
/** The current state the tokenizer is in. */
|
|
24937
|
+
state = State.Text;
|
|
24938
|
+
/** The read buffer. */
|
|
24939
|
+
buffer = "";
|
|
24940
|
+
/** The beginning of the section that is currently being read. */
|
|
24941
|
+
sectionStart = 0;
|
|
24942
|
+
/** The index within the buffer that we are currently looking at. */
|
|
24943
|
+
index = 0;
|
|
24944
|
+
/** The start of the last entity. */
|
|
24945
|
+
entityStart = 0;
|
|
24946
|
+
/** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
|
|
24947
|
+
baseState = State.Text;
|
|
24948
|
+
/** For special parsing behavior inside of script and style tags. */
|
|
24949
|
+
isSpecial = false;
|
|
24950
|
+
/** Indicates whether the tokenizer has been paused. */
|
|
24951
|
+
running = true;
|
|
24952
|
+
/** The offset of the current buffer. */
|
|
24953
|
+
offset = 0;
|
|
24954
|
+
xmlMode;
|
|
24955
|
+
decodeEntities;
|
|
24956
|
+
recognizeSelfClosing;
|
|
24957
|
+
entityDecoder;
|
|
24958
|
+
constructor({ xmlMode = false, decodeEntities = true, recognizeSelfClosing = xmlMode }, cbs) {
|
|
24959
|
+
this.cbs = cbs;
|
|
24960
|
+
this.xmlMode = xmlMode;
|
|
24961
|
+
this.decodeEntities = decodeEntities;
|
|
24962
|
+
this.recognizeSelfClosing = recognizeSelfClosing;
|
|
24963
|
+
this.entityDecoder = new EntityDecoder(xmlMode ? xmlDecodeTree : htmlDecodeTree, (cp, consumed) => this.emitCodePoint(cp, consumed));
|
|
24964
|
+
}
|
|
24965
|
+
reset() {
|
|
24966
|
+
this.state = State.Text;
|
|
24967
|
+
this.buffer = "";
|
|
24968
|
+
this.sectionStart = 0;
|
|
24969
|
+
this.index = 0;
|
|
24970
|
+
this.baseState = State.Text;
|
|
24971
|
+
this.isSpecial = false;
|
|
24972
|
+
this.currentSequence = Sequences.Empty;
|
|
24973
|
+
this.sequenceIndex = 0;
|
|
24974
|
+
this.running = true;
|
|
24975
|
+
this.offset = 0;
|
|
24976
|
+
}
|
|
24977
|
+
write(chunk) {
|
|
24978
|
+
this.offset += this.buffer.length;
|
|
24979
|
+
this.buffer = chunk;
|
|
24980
|
+
this.parse();
|
|
24981
|
+
}
|
|
24982
|
+
end() {
|
|
24983
|
+
if (this.running)
|
|
24984
|
+
this.finish();
|
|
24985
|
+
}
|
|
24986
|
+
pause() {
|
|
24987
|
+
this.running = false;
|
|
24988
|
+
}
|
|
24989
|
+
resume() {
|
|
24990
|
+
this.running = true;
|
|
24991
|
+
if (this.index < this.buffer.length + this.offset) {
|
|
24992
|
+
this.parse();
|
|
24993
|
+
}
|
|
24994
|
+
}
|
|
24995
|
+
stateText(c) {
|
|
24996
|
+
if (c === CharCodes2.Lt || !this.decodeEntities && this.fastForwardTo(CharCodes2.Lt)) {
|
|
24997
|
+
if (this.index > this.sectionStart) {
|
|
24998
|
+
this.cbs.ontext(this.sectionStart, this.index);
|
|
24999
|
+
}
|
|
25000
|
+
this.state = State.BeforeTagName;
|
|
25001
|
+
this.sectionStart = this.index;
|
|
25002
|
+
} else if (this.decodeEntities && c === CharCodes2.Amp) {
|
|
25003
|
+
this.startEntity();
|
|
25004
|
+
}
|
|
25005
|
+
}
|
|
25006
|
+
currentSequence = Sequences.Empty;
|
|
25007
|
+
sequenceIndex = 0;
|
|
25008
|
+
enterTagBody() {
|
|
25009
|
+
if (this.currentSequence === Sequences.Plaintext) {
|
|
25010
|
+
this.currentSequence = Sequences.Empty;
|
|
25011
|
+
this.state = State.InPlainText;
|
|
25012
|
+
} else if (this.isSpecial) {
|
|
25013
|
+
this.state = State.InSpecialTag;
|
|
25014
|
+
this.sequenceIndex = 0;
|
|
25015
|
+
} else {
|
|
25016
|
+
this.state = State.Text;
|
|
25017
|
+
}
|
|
25018
|
+
}
|
|
25019
|
+
/**
|
|
25020
|
+
* Match the opening tag name against an HTML text-only tag sequence.
|
|
25021
|
+
*
|
|
25022
|
+
* Some tags share an initial prefix (`script`/`style`, `title`/`textarea`,
|
|
25023
|
+
* `noembed`/`noframes`), so we may switch to an alternate sequence at the
|
|
25024
|
+
* first distinguishing byte. On a successful full match we fall back to
|
|
25025
|
+
* the normal tag-name state; a later `>` will enter raw-text, RCDATA, or
|
|
25026
|
+
* plaintext mode based on `currentSequence` / `isSpecial`.
|
|
25027
|
+
* @param c Current character code point.
|
|
25028
|
+
*/
|
|
25029
|
+
stateSpecialStartSequence(c) {
|
|
25030
|
+
const lower = c | 32;
|
|
25031
|
+
if (this.sequenceIndex < this.currentSequence.length) {
|
|
25032
|
+
if (lower === this.currentSequence[this.sequenceIndex]) {
|
|
25033
|
+
this.sequenceIndex++;
|
|
25034
|
+
return;
|
|
25035
|
+
}
|
|
25036
|
+
if (this.sequenceIndex === 3) {
|
|
25037
|
+
if (this.currentSequence === Sequences.ScriptEnd && lower === Sequences.StyleEnd[3]) {
|
|
25038
|
+
this.currentSequence = Sequences.StyleEnd;
|
|
25039
|
+
this.sequenceIndex = 4;
|
|
25040
|
+
return;
|
|
25041
|
+
}
|
|
25042
|
+
if (this.currentSequence === Sequences.TitleEnd && lower === Sequences.TextareaEnd[3]) {
|
|
25043
|
+
this.currentSequence = Sequences.TextareaEnd;
|
|
25044
|
+
this.sequenceIndex = 4;
|
|
25045
|
+
return;
|
|
25046
|
+
}
|
|
25047
|
+
} else if (this.sequenceIndex === 4 && this.currentSequence === Sequences.NoembedEnd && lower === Sequences.NoframesEnd[4]) {
|
|
25048
|
+
this.currentSequence = Sequences.NoframesEnd;
|
|
25049
|
+
this.sequenceIndex = 5;
|
|
25050
|
+
return;
|
|
25051
|
+
}
|
|
25052
|
+
} else if (isEndOfTagSection(c)) {
|
|
25053
|
+
this.sequenceIndex = 0;
|
|
25054
|
+
this.state = State.InTagName;
|
|
25055
|
+
this.stateInTagName(c);
|
|
25056
|
+
return;
|
|
25057
|
+
}
|
|
25058
|
+
this.isSpecial = false;
|
|
25059
|
+
this.currentSequence = Sequences.Empty;
|
|
25060
|
+
this.sequenceIndex = 0;
|
|
25061
|
+
this.state = State.InTagName;
|
|
25062
|
+
this.stateInTagName(c);
|
|
25063
|
+
}
|
|
25064
|
+
stateCDATASequence(c) {
|
|
25065
|
+
if (c === Sequences.Cdata[this.sequenceIndex]) {
|
|
25066
|
+
if (++this.sequenceIndex === Sequences.Cdata.length) {
|
|
25067
|
+
this.state = State.InCommentLike;
|
|
25068
|
+
this.currentSequence = Sequences.CdataEnd;
|
|
25069
|
+
this.sequenceIndex = 0;
|
|
25070
|
+
this.sectionStart = this.index + 1;
|
|
25071
|
+
}
|
|
25072
|
+
} else {
|
|
25073
|
+
this.sequenceIndex = 0;
|
|
25074
|
+
if (this.xmlMode) {
|
|
25075
|
+
this.state = State.InDeclaration;
|
|
25076
|
+
this.stateInDeclaration(c);
|
|
25077
|
+
} else {
|
|
25078
|
+
this.state = State.InSpecialComment;
|
|
25079
|
+
this.stateInSpecialComment(c);
|
|
25080
|
+
}
|
|
25081
|
+
}
|
|
25082
|
+
}
|
|
25083
|
+
/**
|
|
25084
|
+
* When we wait for one specific character, we can speed things up
|
|
25085
|
+
* by skipping through the buffer until we find it.
|
|
25086
|
+
* @param c Current character code point.
|
|
25087
|
+
* @returns Whether the character was found.
|
|
25088
|
+
*/
|
|
25089
|
+
fastForwardTo(c) {
|
|
25090
|
+
while (++this.index < this.buffer.length + this.offset) {
|
|
25091
|
+
if (this.buffer.charCodeAt(this.index - this.offset) === c) {
|
|
25092
|
+
return true;
|
|
25093
|
+
}
|
|
25094
|
+
}
|
|
25095
|
+
this.index = this.buffer.length + this.offset - 1;
|
|
25096
|
+
return false;
|
|
25097
|
+
}
|
|
25098
|
+
/**
|
|
25099
|
+
* Emit a comment token and return to the text state.
|
|
25100
|
+
* @param offset Number of characters in the end sequence that have already been matched.
|
|
25101
|
+
*/
|
|
25102
|
+
emitComment(offset) {
|
|
25103
|
+
this.cbs.oncomment(this.sectionStart, this.index, offset);
|
|
25104
|
+
this.sequenceIndex = 0;
|
|
25105
|
+
this.sectionStart = this.index + 1;
|
|
25106
|
+
this.state = State.Text;
|
|
25107
|
+
}
|
|
25108
|
+
/**
|
|
25109
|
+
* Comments and CDATA end with `-->` and `]]>`.
|
|
25110
|
+
*
|
|
25111
|
+
* Their common qualities are:
|
|
25112
|
+
* - Their end sequences have a distinct character they start with.
|
|
25113
|
+
* - That character is then repeated, so we have to check multiple repeats.
|
|
25114
|
+
* - All characters but the start character of the sequence can be skipped.
|
|
25115
|
+
* @param c Current character code point.
|
|
25116
|
+
*/
|
|
25117
|
+
stateInCommentLike(c) {
|
|
25118
|
+
if (!this.xmlMode && this.currentSequence === Sequences.CommentEnd && this.sequenceIndex <= 1 && /*
|
|
25119
|
+
* We're still at the very start of the comment: the only
|
|
25120
|
+
* characters consumed since `<!--` are the dashes that
|
|
25121
|
+
* advanced sequenceIndex (0 for `<!-->`, 1 for `<!--->`).
|
|
25122
|
+
*/
|
|
25123
|
+
this.index === this.sectionStart + this.sequenceIndex && c === CharCodes2.Gt) {
|
|
25124
|
+
this.emitComment(this.sequenceIndex);
|
|
25125
|
+
} else if (this.currentSequence === Sequences.CommentEnd && this.sequenceIndex === 2 && c === CharCodes2.Gt) {
|
|
25126
|
+
this.emitComment(2);
|
|
25127
|
+
} else if (this.currentSequence === Sequences.CommentEnd && this.sequenceIndex === this.currentSequence.length - 1 && c !== CharCodes2.Gt) {
|
|
25128
|
+
this.sequenceIndex = Number(c === CharCodes2.Dash);
|
|
25129
|
+
} else if (c === this.currentSequence[this.sequenceIndex]) {
|
|
25130
|
+
if (++this.sequenceIndex === this.currentSequence.length) {
|
|
25131
|
+
if (this.currentSequence === Sequences.CdataEnd) {
|
|
25132
|
+
this.cbs.oncdata(this.sectionStart, this.index, 2);
|
|
25133
|
+
} else {
|
|
25134
|
+
this.cbs.oncomment(this.sectionStart, this.index, 3);
|
|
25135
|
+
}
|
|
25136
|
+
this.sequenceIndex = 0;
|
|
25137
|
+
this.sectionStart = this.index + 1;
|
|
25138
|
+
this.state = State.Text;
|
|
25139
|
+
}
|
|
25140
|
+
} else if (this.sequenceIndex === 0) {
|
|
25141
|
+
if (this.fastForwardTo(this.currentSequence[0])) {
|
|
25142
|
+
this.sequenceIndex = 1;
|
|
25143
|
+
}
|
|
25144
|
+
} else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
|
|
25145
|
+
this.sequenceIndex = 0;
|
|
25146
|
+
}
|
|
25147
|
+
}
|
|
25148
|
+
/**
|
|
25149
|
+
* HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name.
|
|
25150
|
+
*
|
|
25151
|
+
* XML allows a lot more characters here (@see https://www.w3.org/TR/REC-xml/#NT-NameStartChar).
|
|
25152
|
+
* We allow anything that wouldn't end the tag.
|
|
25153
|
+
* @param c Current character code point.
|
|
25154
|
+
*/
|
|
25155
|
+
isTagStartChar(c) {
|
|
25156
|
+
return this.xmlMode ? !isEndOfTagSection(c) : isASCIIAlpha(c);
|
|
25157
|
+
}
|
|
25158
|
+
/**
|
|
25159
|
+
* Scan raw-text / RCDATA content for the matching end tag.
|
|
25160
|
+
*
|
|
25161
|
+
* For RCDATA tags (`<title>`, `<textarea>`) entities are decoded inline.
|
|
25162
|
+
* For raw-text tags (`<script>`, `<style>`, etc.) we fast-forward to `<`.
|
|
25163
|
+
* @param c Current character code point.
|
|
25164
|
+
*/
|
|
25165
|
+
stateInSpecialTag(c) {
|
|
25166
|
+
if (this.sequenceIndex === this.currentSequence.length) {
|
|
25167
|
+
if (isEndOfTagSection(c)) {
|
|
25168
|
+
const endOfText = this.index - this.currentSequence.length;
|
|
25169
|
+
if (this.sectionStart < endOfText) {
|
|
25170
|
+
const actualIndex = this.index;
|
|
25171
|
+
this.index = endOfText;
|
|
25172
|
+
this.cbs.ontext(this.sectionStart, endOfText);
|
|
25173
|
+
this.index = actualIndex;
|
|
25174
|
+
}
|
|
25175
|
+
this.isSpecial = false;
|
|
25176
|
+
this.sectionStart = endOfText + 2;
|
|
25177
|
+
this.stateInClosingTagName(c);
|
|
25178
|
+
return;
|
|
25179
|
+
}
|
|
25180
|
+
this.sequenceIndex = 0;
|
|
25181
|
+
}
|
|
25182
|
+
if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
|
|
25183
|
+
this.sequenceIndex += 1;
|
|
25184
|
+
} else if (this.sequenceIndex === 0) {
|
|
25185
|
+
if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd) {
|
|
25186
|
+
if (this.decodeEntities && c === CharCodes2.Amp) {
|
|
25187
|
+
this.startEntity();
|
|
25188
|
+
}
|
|
25189
|
+
} else if (this.fastForwardTo(CharCodes2.Lt)) {
|
|
25190
|
+
this.sequenceIndex = 1;
|
|
25191
|
+
}
|
|
25192
|
+
} else {
|
|
25193
|
+
this.sequenceIndex = Number(c === CharCodes2.Lt);
|
|
25194
|
+
}
|
|
25195
|
+
}
|
|
25196
|
+
stateBeforeTagName(c) {
|
|
25197
|
+
if (c === CharCodes2.ExclamationMark) {
|
|
25198
|
+
this.state = State.BeforeDeclaration;
|
|
25199
|
+
this.sectionStart = this.index + 1;
|
|
25200
|
+
} else if (c === CharCodes2.Questionmark) {
|
|
25201
|
+
if (this.xmlMode) {
|
|
25202
|
+
this.state = State.InProcessingInstruction;
|
|
25203
|
+
this.sequenceIndex = 0;
|
|
25204
|
+
this.sectionStart = this.index + 1;
|
|
25205
|
+
} else {
|
|
25206
|
+
this.state = State.InSpecialComment;
|
|
25207
|
+
this.sectionStart = this.index;
|
|
25208
|
+
}
|
|
25209
|
+
} else if (this.isTagStartChar(c)) {
|
|
25210
|
+
this.sectionStart = this.index;
|
|
25211
|
+
const special = this.xmlMode || this.cbs.isInForeignContext?.() ? void 0 : specialStartSequences.get(c | 32);
|
|
25212
|
+
if (special === void 0) {
|
|
25213
|
+
this.state = State.InTagName;
|
|
25214
|
+
} else {
|
|
25215
|
+
this.isSpecial = true;
|
|
25216
|
+
this.currentSequence = special;
|
|
25217
|
+
this.sequenceIndex = 3;
|
|
25218
|
+
this.state = State.SpecialStartSequence;
|
|
25219
|
+
}
|
|
25220
|
+
} else if (c === CharCodes2.Slash) {
|
|
25221
|
+
this.state = State.BeforeClosingTagName;
|
|
25222
|
+
} else {
|
|
25223
|
+
this.state = State.Text;
|
|
25224
|
+
this.stateText(c);
|
|
25225
|
+
}
|
|
25226
|
+
}
|
|
25227
|
+
stateInTagName(c) {
|
|
25228
|
+
if (isEndOfTagSection(c)) {
|
|
25229
|
+
this.cbs.onopentagname(this.sectionStart, this.index);
|
|
25230
|
+
this.sectionStart = -1;
|
|
25231
|
+
this.state = State.BeforeAttributeName;
|
|
25232
|
+
this.stateBeforeAttributeName(c);
|
|
25233
|
+
}
|
|
25234
|
+
}
|
|
25235
|
+
stateBeforeClosingTagName(c) {
|
|
25236
|
+
if (isWhitespace2(c)) {
|
|
25237
|
+
if (this.xmlMode) {
|
|
25238
|
+
} else {
|
|
25239
|
+
this.state = State.InSpecialComment;
|
|
25240
|
+
this.sectionStart = this.index;
|
|
25241
|
+
}
|
|
25242
|
+
} else if (c === CharCodes2.Gt) {
|
|
25243
|
+
this.state = State.Text;
|
|
25244
|
+
if (!this.xmlMode) {
|
|
25245
|
+
this.sectionStart = this.index + 1;
|
|
25246
|
+
}
|
|
25247
|
+
} else {
|
|
25248
|
+
this.state = this.isTagStartChar(c) ? State.InClosingTagName : State.InSpecialComment;
|
|
25249
|
+
this.sectionStart = this.index;
|
|
25250
|
+
}
|
|
25251
|
+
}
|
|
25252
|
+
stateInClosingTagName(c) {
|
|
25253
|
+
if (isEndOfTagSection(c)) {
|
|
25254
|
+
this.cbs.onclosetag(this.sectionStart, this.index);
|
|
25255
|
+
this.sectionStart = -1;
|
|
25256
|
+
this.state = State.AfterClosingTagName;
|
|
25257
|
+
this.stateAfterClosingTagName(c);
|
|
25258
|
+
}
|
|
25259
|
+
}
|
|
25260
|
+
stateAfterClosingTagName(c) {
|
|
25261
|
+
if (c === CharCodes2.Gt || this.fastForwardTo(CharCodes2.Gt)) {
|
|
25262
|
+
this.state = State.Text;
|
|
25263
|
+
this.sectionStart = this.index + 1;
|
|
25264
|
+
}
|
|
25265
|
+
}
|
|
25266
|
+
stateBeforeAttributeName(c) {
|
|
25267
|
+
if (c === CharCodes2.Gt) {
|
|
25268
|
+
this.cbs.onopentagend(this.index);
|
|
25269
|
+
this.enterTagBody();
|
|
25270
|
+
this.sectionStart = this.index + 1;
|
|
25271
|
+
} else if (c === CharCodes2.Slash) {
|
|
25272
|
+
this.state = State.InSelfClosingTag;
|
|
25273
|
+
} else if (!isWhitespace2(c)) {
|
|
25274
|
+
this.state = State.InAttributeName;
|
|
25275
|
+
this.sectionStart = this.index;
|
|
25276
|
+
}
|
|
25277
|
+
}
|
|
25278
|
+
/**
|
|
25279
|
+
* Handle `/` before `>` in an opening tag.
|
|
25280
|
+
*
|
|
25281
|
+
* In HTML mode, text-only tags ignore the self-closing flag and still enter
|
|
25282
|
+
* their raw-text/RCDATA/plaintext state unless self-closing tags are being
|
|
25283
|
+
* recognized. In XML mode, or for ordinary tags, the tokenizer returns to
|
|
25284
|
+
* regular text parsing after emitting the self-closing callback.
|
|
25285
|
+
* @param c Current character code point.
|
|
25286
|
+
*/
|
|
25287
|
+
stateInSelfClosingTag(c) {
|
|
25288
|
+
if (c === CharCodes2.Gt) {
|
|
25289
|
+
this.cbs.onselfclosingtag(this.index);
|
|
25290
|
+
this.sectionStart = this.index + 1;
|
|
25291
|
+
if (!this.recognizeSelfClosing) {
|
|
25292
|
+
this.enterTagBody();
|
|
25293
|
+
return;
|
|
25294
|
+
}
|
|
25295
|
+
this.state = State.Text;
|
|
25296
|
+
this.isSpecial = false;
|
|
25297
|
+
this.currentSequence = Sequences.Empty;
|
|
25298
|
+
} else if (!isWhitespace2(c)) {
|
|
25299
|
+
this.state = State.BeforeAttributeName;
|
|
25300
|
+
this.stateBeforeAttributeName(c);
|
|
25301
|
+
}
|
|
25302
|
+
}
|
|
25303
|
+
stateInAttributeName(c) {
|
|
25304
|
+
if (c === CharCodes2.Eq || isEndOfTagSection(c)) {
|
|
25305
|
+
this.cbs.onattribname(this.sectionStart, this.index);
|
|
25306
|
+
this.sectionStart = this.index;
|
|
25307
|
+
this.state = State.AfterAttributeName;
|
|
25308
|
+
this.stateAfterAttributeName(c);
|
|
25309
|
+
}
|
|
25310
|
+
}
|
|
25311
|
+
stateAfterAttributeName(c) {
|
|
25312
|
+
if (c === CharCodes2.Eq) {
|
|
25313
|
+
this.state = State.BeforeAttributeValue;
|
|
25314
|
+
} else if (c === CharCodes2.Slash || c === CharCodes2.Gt) {
|
|
25315
|
+
this.cbs.onattribend(QuoteType.NoValue, this.sectionStart);
|
|
25316
|
+
this.sectionStart = -1;
|
|
25317
|
+
this.state = State.BeforeAttributeName;
|
|
25318
|
+
this.stateBeforeAttributeName(c);
|
|
25319
|
+
} else if (!isWhitespace2(c)) {
|
|
25320
|
+
this.cbs.onattribend(QuoteType.NoValue, this.sectionStart);
|
|
25321
|
+
this.state = State.InAttributeName;
|
|
25322
|
+
this.sectionStart = this.index;
|
|
25323
|
+
}
|
|
25324
|
+
}
|
|
25325
|
+
stateBeforeAttributeValue(c) {
|
|
25326
|
+
if (c === CharCodes2.DoubleQuote) {
|
|
25327
|
+
this.state = State.InAttributeValueDq;
|
|
25328
|
+
this.sectionStart = this.index + 1;
|
|
25329
|
+
} else if (c === CharCodes2.SingleQuote) {
|
|
25330
|
+
this.state = State.InAttributeValueSq;
|
|
25331
|
+
this.sectionStart = this.index + 1;
|
|
25332
|
+
} else if (!isWhitespace2(c)) {
|
|
25333
|
+
this.sectionStart = this.index;
|
|
25334
|
+
this.state = State.InAttributeValueNq;
|
|
25335
|
+
this.stateInAttributeValueNoQuotes(c);
|
|
25336
|
+
}
|
|
25337
|
+
}
|
|
25338
|
+
handleInAttributeValue(c, quote) {
|
|
25339
|
+
if (c === quote || !this.decodeEntities && this.fastForwardTo(quote)) {
|
|
25340
|
+
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
25341
|
+
this.sectionStart = -1;
|
|
25342
|
+
this.cbs.onattribend(quote === CharCodes2.DoubleQuote ? QuoteType.Double : QuoteType.Single, this.index + 1);
|
|
25343
|
+
this.state = State.BeforeAttributeName;
|
|
25344
|
+
} else if (this.decodeEntities && c === CharCodes2.Amp) {
|
|
25345
|
+
this.startEntity();
|
|
25346
|
+
}
|
|
25347
|
+
}
|
|
25348
|
+
stateInAttributeValueDoubleQuotes(c) {
|
|
25349
|
+
this.handleInAttributeValue(c, CharCodes2.DoubleQuote);
|
|
25350
|
+
}
|
|
25351
|
+
stateInAttributeValueSingleQuotes(c) {
|
|
25352
|
+
this.handleInAttributeValue(c, CharCodes2.SingleQuote);
|
|
25353
|
+
}
|
|
25354
|
+
stateInAttributeValueNoQuotes(c) {
|
|
25355
|
+
if (isWhitespace2(c) || c === CharCodes2.Gt) {
|
|
25356
|
+
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
25357
|
+
this.sectionStart = -1;
|
|
25358
|
+
this.cbs.onattribend(QuoteType.Unquoted, this.index);
|
|
25359
|
+
this.state = State.BeforeAttributeName;
|
|
25360
|
+
this.stateBeforeAttributeName(c);
|
|
25361
|
+
} else if (this.decodeEntities && c === CharCodes2.Amp) {
|
|
25362
|
+
this.startEntity();
|
|
25363
|
+
}
|
|
25364
|
+
}
|
|
25365
|
+
/**
|
|
25366
|
+
* Distinguish between CDATA, declarations, HTML comments, and HTML bogus
|
|
25367
|
+
* comments after `<!`.
|
|
25368
|
+
*
|
|
25369
|
+
* In HTML mode, only real comments and doctypes stay on declaration paths;
|
|
25370
|
+
* everything else becomes a bogus comment terminated by the next `>`.
|
|
25371
|
+
* @param c Current character code point.
|
|
25372
|
+
*/
|
|
25373
|
+
stateBeforeDeclaration(c) {
|
|
25374
|
+
if (c === CharCodes2.OpeningSquareBracket) {
|
|
25375
|
+
this.state = State.CDATASequence;
|
|
25376
|
+
this.sequenceIndex = 0;
|
|
25377
|
+
} else if (this.xmlMode) {
|
|
25378
|
+
this.state = c === CharCodes2.Dash ? State.BeforeComment : State.InDeclaration;
|
|
25379
|
+
} else if ((c | 32) === Sequences.Doctype[0]) {
|
|
25380
|
+
this.state = State.DeclarationSequence;
|
|
25381
|
+
this.currentSequence = Sequences.Doctype;
|
|
25382
|
+
this.sequenceIndex = 1;
|
|
25383
|
+
} else if (c === CharCodes2.Gt) {
|
|
25384
|
+
this.cbs.oncomment(this.sectionStart, this.index, 0);
|
|
25385
|
+
this.state = State.Text;
|
|
25386
|
+
this.sectionStart = this.index + 1;
|
|
25387
|
+
} else if (c === CharCodes2.Dash) {
|
|
25388
|
+
this.state = State.BeforeComment;
|
|
25389
|
+
} else {
|
|
25390
|
+
this.state = State.InSpecialComment;
|
|
25391
|
+
}
|
|
25392
|
+
}
|
|
25393
|
+
/**
|
|
25394
|
+
* Continue matching `doctype` after `<!d`.
|
|
25395
|
+
*
|
|
25396
|
+
* A full `doctype` match stays on the declaration path; any other name falls
|
|
25397
|
+
* back to an HTML bogus comment, which matches browser behavior for
|
|
25398
|
+
* non-doctype `<!...>` constructs.
|
|
25399
|
+
* @param c Current character code point.
|
|
25400
|
+
*/
|
|
25401
|
+
stateDeclarationSequence(c) {
|
|
25402
|
+
if (this.sequenceIndex === this.currentSequence.length) {
|
|
25403
|
+
this.state = State.InDeclaration;
|
|
25404
|
+
this.stateInDeclaration(c);
|
|
25405
|
+
} else if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
|
|
25406
|
+
this.sequenceIndex += 1;
|
|
25407
|
+
} else if (c === CharCodes2.Gt) {
|
|
25408
|
+
this.cbs.oncomment(this.sectionStart, this.index, 0);
|
|
25409
|
+
this.state = State.Text;
|
|
25410
|
+
this.sectionStart = this.index + 1;
|
|
25411
|
+
} else {
|
|
25412
|
+
this.state = State.InSpecialComment;
|
|
25413
|
+
}
|
|
25414
|
+
}
|
|
25415
|
+
stateInDeclaration(c) {
|
|
25416
|
+
if (c === CharCodes2.Gt || this.fastForwardTo(CharCodes2.Gt)) {
|
|
25417
|
+
this.cbs.ondeclaration(this.sectionStart, this.index);
|
|
25418
|
+
this.state = State.Text;
|
|
25419
|
+
this.sectionStart = this.index + 1;
|
|
25420
|
+
}
|
|
25421
|
+
}
|
|
25422
|
+
/**
|
|
25423
|
+
* XML processing instructions (`<?...?>`).
|
|
25424
|
+
*
|
|
25425
|
+
* In HTML mode `<?` is routed to `InSpecialComment` instead, so this
|
|
25426
|
+
* state is only reachable in XML mode.
|
|
25427
|
+
* @param c Current character code point.
|
|
25428
|
+
*/
|
|
25429
|
+
stateInProcessingInstruction(c) {
|
|
25430
|
+
if (c === CharCodes2.Questionmark) {
|
|
25431
|
+
this.sequenceIndex = 1;
|
|
25432
|
+
} else if (c === CharCodes2.Gt && this.sequenceIndex === 1) {
|
|
25433
|
+
this.cbs.onprocessinginstruction(this.sectionStart, this.index - 1);
|
|
25434
|
+
this.sequenceIndex = 0;
|
|
25435
|
+
this.state = State.Text;
|
|
25436
|
+
this.sectionStart = this.index + 1;
|
|
25437
|
+
} else {
|
|
25438
|
+
this.sequenceIndex = Number(this.fastForwardTo(CharCodes2.Questionmark));
|
|
25439
|
+
}
|
|
25440
|
+
}
|
|
25441
|
+
stateBeforeComment(c) {
|
|
25442
|
+
if (c === CharCodes2.Dash) {
|
|
25443
|
+
this.state = State.InCommentLike;
|
|
25444
|
+
this.currentSequence = Sequences.CommentEnd;
|
|
25445
|
+
this.sequenceIndex = 0;
|
|
25446
|
+
this.sectionStart = this.index + 1;
|
|
25447
|
+
} else if (this.xmlMode) {
|
|
25448
|
+
this.state = State.InDeclaration;
|
|
25449
|
+
} else if (c === CharCodes2.Gt) {
|
|
25450
|
+
this.cbs.oncomment(this.sectionStart, this.index, 0);
|
|
25451
|
+
this.state = State.Text;
|
|
25452
|
+
this.sectionStart = this.index + 1;
|
|
25453
|
+
} else {
|
|
25454
|
+
this.state = State.InSpecialComment;
|
|
25455
|
+
}
|
|
25456
|
+
}
|
|
25457
|
+
stateInSpecialComment(c) {
|
|
25458
|
+
if (c === CharCodes2.Gt || this.fastForwardTo(CharCodes2.Gt)) {
|
|
25459
|
+
this.cbs.oncomment(this.sectionStart, this.index, 0);
|
|
25460
|
+
this.state = State.Text;
|
|
25461
|
+
this.sectionStart = this.index + 1;
|
|
25462
|
+
}
|
|
25463
|
+
}
|
|
25464
|
+
startEntity() {
|
|
25465
|
+
this.baseState = this.state;
|
|
25466
|
+
this.state = State.InEntity;
|
|
25467
|
+
this.entityStart = this.index;
|
|
25468
|
+
this.entityDecoder.startEntity(this.xmlMode ? DecodingMode.Strict : this.baseState === State.Text || this.baseState === State.InSpecialTag ? DecodingMode.Legacy : DecodingMode.Attribute);
|
|
25469
|
+
}
|
|
25470
|
+
stateInEntity() {
|
|
25471
|
+
const indexInBuffer = this.index - this.offset;
|
|
25472
|
+
const length = this.entityDecoder.write(this.buffer, indexInBuffer);
|
|
25473
|
+
if (length >= 0) {
|
|
25474
|
+
this.state = this.baseState;
|
|
25475
|
+
if (length === 0) {
|
|
25476
|
+
this.index -= 1;
|
|
25477
|
+
}
|
|
25478
|
+
} else {
|
|
25479
|
+
if (indexInBuffer < this.buffer.length && this.buffer.charCodeAt(indexInBuffer) === CharCodes2.Amp) {
|
|
25480
|
+
this.state = this.baseState;
|
|
25481
|
+
this.index -= 1;
|
|
25482
|
+
return;
|
|
25483
|
+
}
|
|
25484
|
+
this.index = this.offset + this.buffer.length - 1;
|
|
25485
|
+
}
|
|
25486
|
+
}
|
|
25487
|
+
/**
|
|
25488
|
+
* Remove data that has already been consumed from the buffer.
|
|
25489
|
+
*/
|
|
25490
|
+
cleanup() {
|
|
25491
|
+
if (this.running && this.sectionStart !== this.index) {
|
|
25492
|
+
if (this.state === State.Text || this.state === State.InPlainText || this.state === State.InSpecialTag && this.sequenceIndex === 0) {
|
|
25493
|
+
this.cbs.ontext(this.sectionStart, this.index);
|
|
25494
|
+
this.sectionStart = this.index;
|
|
25495
|
+
} else if (this.state === State.InAttributeValueDq || this.state === State.InAttributeValueSq || this.state === State.InAttributeValueNq) {
|
|
25496
|
+
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
25497
|
+
this.sectionStart = this.index;
|
|
25498
|
+
}
|
|
25499
|
+
}
|
|
25500
|
+
}
|
|
25501
|
+
shouldContinue() {
|
|
25502
|
+
return this.index < this.buffer.length + this.offset && this.running;
|
|
25503
|
+
}
|
|
25504
|
+
/**
|
|
25505
|
+
* Iterates through the buffer, calling the function corresponding to the current state.
|
|
25506
|
+
*
|
|
25507
|
+
* States that are more likely to be hit are higher up, as a performance improvement.
|
|
25508
|
+
*/
|
|
25509
|
+
parse() {
|
|
25510
|
+
while (this.shouldContinue()) {
|
|
25511
|
+
const c = this.buffer.charCodeAt(this.index - this.offset);
|
|
25512
|
+
switch (this.state) {
|
|
25513
|
+
case State.Text: {
|
|
25514
|
+
this.stateText(c);
|
|
25515
|
+
break;
|
|
25516
|
+
}
|
|
25517
|
+
case State.InPlainText: {
|
|
25518
|
+
this.index = this.buffer.length + this.offset - 1;
|
|
25519
|
+
break;
|
|
25520
|
+
}
|
|
25521
|
+
case State.SpecialStartSequence: {
|
|
25522
|
+
this.stateSpecialStartSequence(c);
|
|
25523
|
+
break;
|
|
25524
|
+
}
|
|
25525
|
+
case State.InSpecialTag: {
|
|
25526
|
+
this.stateInSpecialTag(c);
|
|
25527
|
+
break;
|
|
25528
|
+
}
|
|
25529
|
+
case State.CDATASequence: {
|
|
25530
|
+
this.stateCDATASequence(c);
|
|
25531
|
+
break;
|
|
25532
|
+
}
|
|
25533
|
+
case State.DeclarationSequence: {
|
|
25534
|
+
this.stateDeclarationSequence(c);
|
|
25535
|
+
break;
|
|
25536
|
+
}
|
|
25537
|
+
case State.InAttributeValueDq: {
|
|
25538
|
+
this.stateInAttributeValueDoubleQuotes(c);
|
|
25539
|
+
break;
|
|
25540
|
+
}
|
|
25541
|
+
case State.InAttributeName: {
|
|
25542
|
+
this.stateInAttributeName(c);
|
|
25543
|
+
break;
|
|
25544
|
+
}
|
|
25545
|
+
case State.InCommentLike: {
|
|
25546
|
+
this.stateInCommentLike(c);
|
|
25547
|
+
break;
|
|
25548
|
+
}
|
|
25549
|
+
case State.InSpecialComment: {
|
|
25550
|
+
this.stateInSpecialComment(c);
|
|
25551
|
+
break;
|
|
25552
|
+
}
|
|
25553
|
+
case State.BeforeAttributeName: {
|
|
25554
|
+
this.stateBeforeAttributeName(c);
|
|
25555
|
+
break;
|
|
25556
|
+
}
|
|
25557
|
+
case State.InTagName: {
|
|
25558
|
+
this.stateInTagName(c);
|
|
25559
|
+
break;
|
|
25560
|
+
}
|
|
25561
|
+
case State.InClosingTagName: {
|
|
25562
|
+
this.stateInClosingTagName(c);
|
|
25563
|
+
break;
|
|
25564
|
+
}
|
|
25565
|
+
case State.BeforeTagName: {
|
|
25566
|
+
this.stateBeforeTagName(c);
|
|
25567
|
+
break;
|
|
25568
|
+
}
|
|
25569
|
+
case State.AfterAttributeName: {
|
|
25570
|
+
this.stateAfterAttributeName(c);
|
|
25571
|
+
break;
|
|
25572
|
+
}
|
|
25573
|
+
case State.InAttributeValueSq: {
|
|
25574
|
+
this.stateInAttributeValueSingleQuotes(c);
|
|
25575
|
+
break;
|
|
25576
|
+
}
|
|
25577
|
+
case State.BeforeAttributeValue: {
|
|
25578
|
+
this.stateBeforeAttributeValue(c);
|
|
25579
|
+
break;
|
|
25580
|
+
}
|
|
25581
|
+
case State.BeforeClosingTagName: {
|
|
25582
|
+
this.stateBeforeClosingTagName(c);
|
|
25583
|
+
break;
|
|
25584
|
+
}
|
|
25585
|
+
case State.AfterClosingTagName: {
|
|
25586
|
+
this.stateAfterClosingTagName(c);
|
|
25587
|
+
break;
|
|
25588
|
+
}
|
|
25589
|
+
case State.InAttributeValueNq: {
|
|
25590
|
+
this.stateInAttributeValueNoQuotes(c);
|
|
25591
|
+
break;
|
|
25592
|
+
}
|
|
25593
|
+
case State.InSelfClosingTag: {
|
|
25594
|
+
this.stateInSelfClosingTag(c);
|
|
25595
|
+
break;
|
|
25596
|
+
}
|
|
25597
|
+
case State.InDeclaration: {
|
|
25598
|
+
this.stateInDeclaration(c);
|
|
25599
|
+
break;
|
|
25600
|
+
}
|
|
25601
|
+
case State.BeforeDeclaration: {
|
|
25602
|
+
this.stateBeforeDeclaration(c);
|
|
25603
|
+
break;
|
|
25604
|
+
}
|
|
25605
|
+
case State.BeforeComment: {
|
|
25606
|
+
this.stateBeforeComment(c);
|
|
25607
|
+
break;
|
|
25608
|
+
}
|
|
25609
|
+
case State.InProcessingInstruction: {
|
|
25610
|
+
this.stateInProcessingInstruction(c);
|
|
25611
|
+
break;
|
|
25612
|
+
}
|
|
25613
|
+
case State.InEntity: {
|
|
25614
|
+
this.stateInEntity();
|
|
25615
|
+
break;
|
|
25616
|
+
}
|
|
25617
|
+
}
|
|
25618
|
+
this.index++;
|
|
25619
|
+
}
|
|
25620
|
+
this.cleanup();
|
|
25621
|
+
}
|
|
25622
|
+
finish() {
|
|
25623
|
+
if (this.state === State.InEntity) {
|
|
25624
|
+
this.entityDecoder.end();
|
|
25625
|
+
this.state = this.baseState;
|
|
25626
|
+
}
|
|
25627
|
+
this.handleTrailingData();
|
|
25628
|
+
this.cbs.onend();
|
|
25629
|
+
}
|
|
25630
|
+
handleTrailingCommentLikeData(endIndex) {
|
|
25631
|
+
if (this.state !== State.InCommentLike) {
|
|
25632
|
+
return false;
|
|
25633
|
+
}
|
|
25634
|
+
if (this.currentSequence === Sequences.CdataEnd) {
|
|
25635
|
+
if (this.xmlMode) {
|
|
25636
|
+
if (this.sectionStart < endIndex) {
|
|
25637
|
+
this.cbs.oncdata(this.sectionStart, endIndex, 0);
|
|
25638
|
+
}
|
|
25639
|
+
} else {
|
|
25640
|
+
const cdataStart = this.sectionStart - Sequences.Cdata.length - 1;
|
|
25641
|
+
this.cbs.oncomment(cdataStart, endIndex, 0);
|
|
25642
|
+
}
|
|
25643
|
+
} else {
|
|
25644
|
+
const offset = this.xmlMode ? 0 : Math.min(this.sequenceIndex, Sequences.CommentEnd.length - 1);
|
|
25645
|
+
this.cbs.oncomment(this.sectionStart, endIndex, offset);
|
|
25646
|
+
}
|
|
25647
|
+
return true;
|
|
25648
|
+
}
|
|
25649
|
+
handleTrailingMarkupDeclaration(endIndex) {
|
|
25650
|
+
if (this.xmlMode) {
|
|
25651
|
+
switch (this.state) {
|
|
25652
|
+
case State.InSpecialComment:
|
|
25653
|
+
case State.BeforeComment:
|
|
25654
|
+
case State.CDATASequence:
|
|
25655
|
+
case State.DeclarationSequence:
|
|
25656
|
+
case State.InDeclaration: {
|
|
25657
|
+
this.cbs.ontext(this.sectionStart, endIndex);
|
|
25658
|
+
return true;
|
|
25659
|
+
}
|
|
25660
|
+
default: {
|
|
25661
|
+
return false;
|
|
25662
|
+
}
|
|
25663
|
+
}
|
|
25664
|
+
}
|
|
25665
|
+
switch (this.state) {
|
|
25666
|
+
case State.BeforeDeclaration:
|
|
25667
|
+
case State.InSpecialComment:
|
|
25668
|
+
case State.BeforeComment:
|
|
25669
|
+
case State.CDATASequence: {
|
|
25670
|
+
this.cbs.oncomment(this.sectionStart, endIndex, 0);
|
|
25671
|
+
return true;
|
|
25672
|
+
}
|
|
25673
|
+
case State.DeclarationSequence: {
|
|
25674
|
+
if (this.sequenceIndex !== Sequences.Doctype.length) {
|
|
25675
|
+
this.cbs.oncomment(this.sectionStart, endIndex, 0);
|
|
25676
|
+
}
|
|
25677
|
+
return true;
|
|
25678
|
+
}
|
|
25679
|
+
case State.InDeclaration: {
|
|
25680
|
+
return true;
|
|
25681
|
+
}
|
|
25682
|
+
default: {
|
|
25683
|
+
return false;
|
|
25684
|
+
}
|
|
25685
|
+
}
|
|
25686
|
+
}
|
|
25687
|
+
/** Handle any trailing data. */
|
|
25688
|
+
handleTrailingData() {
|
|
25689
|
+
const endIndex = this.buffer.length + this.offset;
|
|
25690
|
+
if (this.handleTrailingCommentLikeData(endIndex) || this.handleTrailingMarkupDeclaration(endIndex)) {
|
|
25691
|
+
return;
|
|
25692
|
+
}
|
|
25693
|
+
if (this.sectionStart >= endIndex) {
|
|
25694
|
+
return;
|
|
25695
|
+
}
|
|
25696
|
+
switch (this.state) {
|
|
25697
|
+
case State.InTagName:
|
|
25698
|
+
case State.BeforeAttributeName:
|
|
25699
|
+
case State.BeforeAttributeValue:
|
|
25700
|
+
case State.AfterAttributeName:
|
|
25701
|
+
case State.InAttributeName:
|
|
25702
|
+
case State.InAttributeValueSq:
|
|
25703
|
+
case State.InAttributeValueDq:
|
|
25704
|
+
case State.InAttributeValueNq:
|
|
25705
|
+
case State.InClosingTagName: {
|
|
25706
|
+
break;
|
|
25707
|
+
}
|
|
25708
|
+
default: {
|
|
25709
|
+
this.cbs.ontext(this.sectionStart, endIndex);
|
|
25710
|
+
}
|
|
25711
|
+
}
|
|
25712
|
+
}
|
|
25713
|
+
emitCodePoint(cp, consumed) {
|
|
25714
|
+
if (this.baseState !== State.Text && this.baseState !== State.InSpecialTag) {
|
|
25715
|
+
if (this.sectionStart < this.entityStart) {
|
|
25716
|
+
this.cbs.onattribdata(this.sectionStart, this.entityStart);
|
|
25717
|
+
}
|
|
25718
|
+
this.sectionStart = this.entityStart + consumed;
|
|
25719
|
+
this.index = this.sectionStart - 1;
|
|
25720
|
+
this.cbs.onattribentity(cp);
|
|
25721
|
+
} else {
|
|
25722
|
+
if (this.sectionStart < this.entityStart) {
|
|
25723
|
+
this.cbs.ontext(this.sectionStart, this.entityStart);
|
|
25724
|
+
}
|
|
25725
|
+
this.sectionStart = this.entityStart + consumed;
|
|
25726
|
+
this.index = this.sectionStart - 1;
|
|
25727
|
+
this.cbs.ontextentity(cp, this.sectionStart);
|
|
25728
|
+
}
|
|
25729
|
+
}
|
|
25730
|
+
};
|
|
25731
|
+
|
|
25732
|
+
// node_modules/htmlparser2/dist/Parser.js
|
|
25733
|
+
var { fromCodePoint } = String;
|
|
25734
|
+
var formTags = /* @__PURE__ */ new Set([
|
|
25735
|
+
"input",
|
|
25736
|
+
"option",
|
|
25737
|
+
"optgroup",
|
|
25738
|
+
"select",
|
|
25739
|
+
"button",
|
|
25740
|
+
"datalist",
|
|
25741
|
+
"textarea"
|
|
25742
|
+
]);
|
|
25743
|
+
var pTag = /* @__PURE__ */ new Set(["p"]);
|
|
25744
|
+
var headingTags = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6", "p"]);
|
|
25745
|
+
var tableSectionTags = /* @__PURE__ */ new Set(["thead", "tbody"]);
|
|
25746
|
+
var ddtTags = /* @__PURE__ */ new Set(["dd", "dt"]);
|
|
25747
|
+
var rtpTags = /* @__PURE__ */ new Set(["rt", "rp"]);
|
|
25748
|
+
var openImpliesClose = /* @__PURE__ */ new Map([
|
|
25749
|
+
["tr", /* @__PURE__ */ new Set(["tr", "th", "td"])],
|
|
25750
|
+
["th", /* @__PURE__ */ new Set(["th"])],
|
|
25751
|
+
["td", /* @__PURE__ */ new Set(["thead", "th", "td"])],
|
|
25752
|
+
["body", /* @__PURE__ */ new Set(["head", "link", "script"])],
|
|
25753
|
+
["a", /* @__PURE__ */ new Set(["a"])],
|
|
25754
|
+
["li", /* @__PURE__ */ new Set(["li"])],
|
|
25755
|
+
["p", pTag],
|
|
25756
|
+
["h1", headingTags],
|
|
25757
|
+
["h2", headingTags],
|
|
25758
|
+
["h3", headingTags],
|
|
25759
|
+
["h4", headingTags],
|
|
25760
|
+
["h5", headingTags],
|
|
25761
|
+
["h6", headingTags],
|
|
25762
|
+
["select", formTags],
|
|
25763
|
+
["input", formTags],
|
|
25764
|
+
["output", formTags],
|
|
25765
|
+
["button", formTags],
|
|
25766
|
+
["datalist", formTags],
|
|
25767
|
+
["textarea", formTags],
|
|
25768
|
+
["option", /* @__PURE__ */ new Set(["option"])],
|
|
25769
|
+
["optgroup", /* @__PURE__ */ new Set(["optgroup", "option"])],
|
|
25770
|
+
["dd", ddtTags],
|
|
25771
|
+
["dt", ddtTags],
|
|
25772
|
+
["address", pTag],
|
|
25773
|
+
["article", pTag],
|
|
25774
|
+
["aside", pTag],
|
|
25775
|
+
["blockquote", pTag],
|
|
25776
|
+
["details", pTag],
|
|
25777
|
+
["div", pTag],
|
|
25778
|
+
["dl", pTag],
|
|
25779
|
+
["fieldset", pTag],
|
|
25780
|
+
["figcaption", pTag],
|
|
25781
|
+
["figure", pTag],
|
|
25782
|
+
["footer", pTag],
|
|
25783
|
+
["form", pTag],
|
|
25784
|
+
["header", pTag],
|
|
25785
|
+
["hr", pTag],
|
|
25786
|
+
["main", pTag],
|
|
25787
|
+
["nav", pTag],
|
|
25788
|
+
["ol", pTag],
|
|
25789
|
+
["pre", pTag],
|
|
25790
|
+
["section", pTag],
|
|
25791
|
+
["table", pTag],
|
|
25792
|
+
["ul", pTag],
|
|
25793
|
+
["rt", rtpTags],
|
|
25794
|
+
["rp", rtpTags],
|
|
25795
|
+
["tbody", tableSectionTags],
|
|
25796
|
+
["tfoot", tableSectionTags]
|
|
25797
|
+
]);
|
|
25798
|
+
var DOCUMENT_TYPE = "doctype";
|
|
25799
|
+
var voidElements = /* @__PURE__ */ new Set([
|
|
25800
|
+
"area",
|
|
25801
|
+
"base",
|
|
25802
|
+
"basefont",
|
|
25803
|
+
"br",
|
|
25804
|
+
"col",
|
|
25805
|
+
"command",
|
|
25806
|
+
"embed",
|
|
25807
|
+
"frame",
|
|
25808
|
+
"hr",
|
|
25809
|
+
"img",
|
|
25810
|
+
"input",
|
|
25811
|
+
"isindex",
|
|
25812
|
+
"keygen",
|
|
25813
|
+
"link",
|
|
25814
|
+
"meta",
|
|
25815
|
+
"param",
|
|
25816
|
+
"source",
|
|
25817
|
+
"track",
|
|
25818
|
+
"wbr"
|
|
25819
|
+
]);
|
|
25820
|
+
var foreignContextElements = /* @__PURE__ */ new Set(["math", "svg"]);
|
|
25821
|
+
var htmlIntegrationElements = /* @__PURE__ */ new Set([
|
|
25822
|
+
"mi",
|
|
25823
|
+
"mo",
|
|
25824
|
+
"mn",
|
|
25825
|
+
"ms",
|
|
25826
|
+
"mtext",
|
|
25827
|
+
"annotation-xml",
|
|
25828
|
+
"foreignObject",
|
|
25829
|
+
"desc",
|
|
25830
|
+
"title"
|
|
25831
|
+
]);
|
|
25832
|
+
var svgTagNameAdjustments = /* @__PURE__ */ new Map([
|
|
25833
|
+
["altglyph", "altGlyph"],
|
|
25834
|
+
["altglyphdef", "altGlyphDef"],
|
|
25835
|
+
["altglyphitem", "altGlyphItem"],
|
|
25836
|
+
["animatecolor", "animateColor"],
|
|
25837
|
+
["animatemotion", "animateMotion"],
|
|
25838
|
+
["animatetransform", "animateTransform"],
|
|
25839
|
+
["clippath", "clipPath"],
|
|
25840
|
+
["feblend", "feBlend"],
|
|
25841
|
+
["fecolormatrix", "feColorMatrix"],
|
|
25842
|
+
["fecomponenttransfer", "feComponentTransfer"],
|
|
25843
|
+
["fecomposite", "feComposite"],
|
|
25844
|
+
["feconvolvematrix", "feConvolveMatrix"],
|
|
25845
|
+
["fediffuselighting", "feDiffuseLighting"],
|
|
25846
|
+
["fedisplacementmap", "feDisplacementMap"],
|
|
25847
|
+
["fedistantlight", "feDistantLight"],
|
|
25848
|
+
["fedropshadow", "feDropShadow"],
|
|
25849
|
+
["feflood", "feFlood"],
|
|
25850
|
+
["fefunca", "feFuncA"],
|
|
25851
|
+
["fefuncb", "feFuncB"],
|
|
25852
|
+
["fefuncg", "feFuncG"],
|
|
25853
|
+
["fefuncr", "feFuncR"],
|
|
25854
|
+
["fegaussianblur", "feGaussianBlur"],
|
|
25855
|
+
["feimage", "feImage"],
|
|
25856
|
+
["femerge", "feMerge"],
|
|
25857
|
+
["femergenode", "feMergeNode"],
|
|
25858
|
+
["femorphology", "feMorphology"],
|
|
25859
|
+
["feoffset", "feOffset"],
|
|
25860
|
+
["fepointlight", "fePointLight"],
|
|
25861
|
+
["fespecularlighting", "feSpecularLighting"],
|
|
25862
|
+
["fespotlight", "feSpotLight"],
|
|
25863
|
+
["fetile", "feTile"],
|
|
25864
|
+
["feturbulence", "feTurbulence"],
|
|
25865
|
+
["foreignobject", "foreignObject"],
|
|
25866
|
+
["glyphref", "glyphRef"],
|
|
25867
|
+
["lineargradient", "linearGradient"],
|
|
25868
|
+
["radialgradient", "radialGradient"],
|
|
25869
|
+
["textpath", "textPath"]
|
|
25870
|
+
]);
|
|
25871
|
+
var ForeignContext;
|
|
25872
|
+
(function(ForeignContext2) {
|
|
25873
|
+
ForeignContext2[ForeignContext2["None"] = 0] = "None";
|
|
25874
|
+
ForeignContext2[ForeignContext2["Svg"] = 1] = "Svg";
|
|
25875
|
+
ForeignContext2[ForeignContext2["MathML"] = 2] = "MathML";
|
|
25876
|
+
})(ForeignContext || (ForeignContext = {}));
|
|
25877
|
+
var reNameEnd = /\s|\//;
|
|
25878
|
+
var Parser = class {
|
|
25879
|
+
options;
|
|
25880
|
+
/** The start index of the last event. */
|
|
25881
|
+
startIndex = 0;
|
|
25882
|
+
/** The end index of the last event. */
|
|
25883
|
+
endIndex = 0;
|
|
25884
|
+
/**
|
|
25885
|
+
* Store the start index of the current open tag,
|
|
25886
|
+
* so we can update the start index for attributes.
|
|
25887
|
+
*/
|
|
25888
|
+
openTagStart = 0;
|
|
25889
|
+
tagname = "";
|
|
25890
|
+
attribname = "";
|
|
25891
|
+
attribvalue = "";
|
|
25892
|
+
attribs = null;
|
|
25893
|
+
stack = [];
|
|
25894
|
+
foreignContext;
|
|
25895
|
+
cbs;
|
|
25896
|
+
lowerCaseTagNames;
|
|
25897
|
+
lowerCaseAttributeNames;
|
|
25898
|
+
recognizeSelfClosing;
|
|
25899
|
+
/** We are parsing HTML. Inverse of the `xmlMode` option. */
|
|
25900
|
+
htmlMode;
|
|
25901
|
+
tokenizer;
|
|
25902
|
+
buffers = [];
|
|
25903
|
+
bufferOffset = 0;
|
|
25904
|
+
/** The index of the last written buffer. Used when resuming after a `pause()`. */
|
|
25905
|
+
writeIndex = 0;
|
|
25906
|
+
/** Indicates whether the parser has finished running / `.end` has been called. */
|
|
25907
|
+
ended = false;
|
|
25908
|
+
constructor(cbs, options = {}) {
|
|
25909
|
+
this.options = options;
|
|
25910
|
+
this.cbs = cbs ?? {};
|
|
25911
|
+
this.htmlMode = !this.options.xmlMode;
|
|
25912
|
+
this.lowerCaseTagNames = options.lowerCaseTags ?? this.htmlMode;
|
|
25913
|
+
this.lowerCaseAttributeNames = options.lowerCaseAttributeNames ?? this.htmlMode;
|
|
25914
|
+
this.recognizeSelfClosing = options.recognizeSelfClosing ?? !this.htmlMode;
|
|
25915
|
+
this.tokenizer = new (options.Tokenizer ?? Tokenizer2)(this.options, this);
|
|
25916
|
+
this.foreignContext = [ForeignContext.None];
|
|
25917
|
+
this.cbs.onparserinit?.(this);
|
|
25918
|
+
}
|
|
25919
|
+
// Tokenizer event handlers
|
|
25920
|
+
/**
|
|
25921
|
+
* @param start Start index for the current parser event.
|
|
25922
|
+
* @param endIndex End index for the current parser event.
|
|
25923
|
+
* @internal
|
|
25924
|
+
*/
|
|
25925
|
+
ontext(start, endIndex) {
|
|
25926
|
+
const data = this.getSlice(start, endIndex);
|
|
25927
|
+
this.endIndex = endIndex - 1;
|
|
25928
|
+
this.cbs.ontext?.(data);
|
|
25929
|
+
this.startIndex = endIndex;
|
|
25930
|
+
}
|
|
25931
|
+
/**
|
|
25932
|
+
* @param cp Current Unicode code point.
|
|
25933
|
+
* @param endIndex End index for the current parser event.
|
|
25934
|
+
* @internal
|
|
25935
|
+
*/
|
|
25936
|
+
ontextentity(cp, endIndex) {
|
|
25937
|
+
this.endIndex = endIndex - 1;
|
|
25938
|
+
this.cbs.ontext?.(fromCodePoint(cp));
|
|
25939
|
+
this.startIndex = endIndex;
|
|
25940
|
+
}
|
|
25941
|
+
/** @internal */
|
|
25942
|
+
isInForeignContext() {
|
|
25943
|
+
return this.foreignContext[0] !== ForeignContext.None;
|
|
25944
|
+
}
|
|
25945
|
+
/**
|
|
25946
|
+
* Checks if the current tag is a void element. Override this if you want
|
|
25947
|
+
* to specify your own additional void elements.
|
|
25948
|
+
* @param name Name of the pseudo selector.
|
|
25949
|
+
*/
|
|
25950
|
+
isVoidElement(name) {
|
|
25951
|
+
return this.htmlMode && voidElements.has(name);
|
|
25952
|
+
}
|
|
25953
|
+
/**
|
|
25954
|
+
* Read a tag name from the buffer.
|
|
25955
|
+
*
|
|
25956
|
+
* When `lowerCaseTagNames` is enabled (the default in HTML mode), the name
|
|
25957
|
+
* is lowercased and may be adjusted for SVG casing or the `image` → `img`
|
|
25958
|
+
* alias.
|
|
25959
|
+
* @param start Start index of the tag name in the buffer.
|
|
25960
|
+
* @param endIndex End index of the tag name in the buffer.
|
|
25961
|
+
*/
|
|
25962
|
+
readTagName(start, endIndex) {
|
|
25963
|
+
const name = this.lowerCaseTagNames ? this.getSlice(start, endIndex).toLowerCase() : this.getSlice(start, endIndex);
|
|
25964
|
+
if (!(this.lowerCaseTagNames && this.htmlMode)) {
|
|
25965
|
+
return name;
|
|
25966
|
+
}
|
|
25967
|
+
if (this.foreignContext[0] === ForeignContext.Svg) {
|
|
25968
|
+
return svgTagNameAdjustments.get(name) ?? name;
|
|
25969
|
+
}
|
|
25970
|
+
if (this.foreignContext.length > 1) {
|
|
25971
|
+
const adjusted = svgTagNameAdjustments.get(name);
|
|
25972
|
+
if (adjusted !== void 0 && this.stack.includes(adjusted)) {
|
|
25973
|
+
return adjusted;
|
|
25974
|
+
}
|
|
25975
|
+
}
|
|
25976
|
+
if (!this.isInForeignContext()) {
|
|
25977
|
+
return name === "image" ? "img" : name;
|
|
25978
|
+
}
|
|
25979
|
+
return name;
|
|
25980
|
+
}
|
|
25981
|
+
/**
|
|
25982
|
+
* @param start Start index for the current parser event.
|
|
25983
|
+
* @param endIndex End index for the current parser event.
|
|
25984
|
+
* @internal
|
|
25985
|
+
*/
|
|
25986
|
+
onopentagname(start, endIndex) {
|
|
25987
|
+
this.endIndex = endIndex;
|
|
25988
|
+
this.emitOpenTag(this.readTagName(start, endIndex));
|
|
25989
|
+
}
|
|
25990
|
+
emitOpenTag(name) {
|
|
25991
|
+
this.openTagStart = this.startIndex;
|
|
25992
|
+
this.tagname = name;
|
|
25993
|
+
if (this.htmlMode && name === "form" && this.stack.includes("form")) {
|
|
25994
|
+
this.tagname = "";
|
|
25995
|
+
return;
|
|
25996
|
+
}
|
|
25997
|
+
const impliesClose = this.htmlMode && openImpliesClose.get(name);
|
|
25998
|
+
if (impliesClose) {
|
|
25999
|
+
while (this.stack.length > 0 && impliesClose.has(this.stack[0])) {
|
|
26000
|
+
this.popElement(true);
|
|
26001
|
+
}
|
|
26002
|
+
}
|
|
26003
|
+
if (!this.isVoidElement(name)) {
|
|
26004
|
+
this.stack.unshift(name);
|
|
26005
|
+
if (this.htmlMode) {
|
|
26006
|
+
if (name === "svg") {
|
|
26007
|
+
this.foreignContext.unshift(ForeignContext.Svg);
|
|
26008
|
+
} else if (name === "math") {
|
|
26009
|
+
this.foreignContext.unshift(ForeignContext.MathML);
|
|
26010
|
+
} else if (htmlIntegrationElements.has(name)) {
|
|
26011
|
+
this.foreignContext.unshift(ForeignContext.None);
|
|
26012
|
+
}
|
|
26013
|
+
}
|
|
26014
|
+
}
|
|
26015
|
+
this.cbs.onopentagname?.(name);
|
|
26016
|
+
if (this.cbs.onopentag)
|
|
26017
|
+
this.attribs = {};
|
|
26018
|
+
}
|
|
26019
|
+
endOpenTag(isImplied) {
|
|
26020
|
+
this.startIndex = this.openTagStart;
|
|
26021
|
+
if (this.attribs) {
|
|
26022
|
+
this.cbs.onopentag?.(this.tagname, this.attribs, isImplied);
|
|
26023
|
+
this.attribs = null;
|
|
26024
|
+
}
|
|
26025
|
+
if (this.cbs.onclosetag && this.isVoidElement(this.tagname)) {
|
|
26026
|
+
this.cbs.onclosetag(this.tagname, true);
|
|
26027
|
+
}
|
|
26028
|
+
this.tagname = "";
|
|
26029
|
+
}
|
|
26030
|
+
/**
|
|
26031
|
+
* @param endIndex End index for the current parser event.
|
|
26032
|
+
* @internal
|
|
26033
|
+
*/
|
|
26034
|
+
onopentagend(endIndex) {
|
|
26035
|
+
this.endIndex = endIndex;
|
|
26036
|
+
this.endOpenTag(false);
|
|
26037
|
+
this.startIndex = endIndex + 1;
|
|
26038
|
+
}
|
|
26039
|
+
/**
|
|
26040
|
+
* @param start Start index for the current parser event.
|
|
26041
|
+
* @param endIndex End index for the current parser event.
|
|
26042
|
+
* @internal
|
|
26043
|
+
*/
|
|
26044
|
+
onclosetag(start, endIndex) {
|
|
26045
|
+
this.endIndex = endIndex;
|
|
26046
|
+
const name = this.readTagName(start, endIndex);
|
|
26047
|
+
if (!this.isVoidElement(name)) {
|
|
26048
|
+
const pos = this.stack.indexOf(name);
|
|
26049
|
+
if (pos !== -1) {
|
|
26050
|
+
for (let index = 0; index < pos; index++) {
|
|
26051
|
+
this.popElement(true);
|
|
26052
|
+
}
|
|
26053
|
+
this.popElement(false);
|
|
26054
|
+
} else if (this.htmlMode && name === "p") {
|
|
26055
|
+
this.emitOpenTag("p");
|
|
26056
|
+
this.closeCurrentTag(true);
|
|
26057
|
+
}
|
|
26058
|
+
} else if (this.htmlMode && name === "br") {
|
|
26059
|
+
this.cbs.onopentagname?.("br");
|
|
26060
|
+
this.cbs.onopentag?.("br", {}, true);
|
|
26061
|
+
this.cbs.onclosetag?.("br", false);
|
|
26062
|
+
}
|
|
26063
|
+
this.startIndex = endIndex + 1;
|
|
26064
|
+
}
|
|
26065
|
+
/**
|
|
26066
|
+
* @param endIndex End index for the current parser event.
|
|
26067
|
+
* @internal
|
|
26068
|
+
*/
|
|
26069
|
+
onselfclosingtag(endIndex) {
|
|
26070
|
+
this.endIndex = endIndex;
|
|
26071
|
+
if (this.recognizeSelfClosing || this.isInForeignContext()) {
|
|
26072
|
+
this.closeCurrentTag(false);
|
|
26073
|
+
this.startIndex = endIndex + 1;
|
|
26074
|
+
} else {
|
|
26075
|
+
this.onopentagend(endIndex);
|
|
26076
|
+
}
|
|
26077
|
+
}
|
|
26078
|
+
/**
|
|
26079
|
+
* Pop the top element off the stack, emit a close event, and maintain
|
|
26080
|
+
* the foreign context stack.
|
|
26081
|
+
* @param implied Whether this close is implied (not from an explicit end tag).
|
|
26082
|
+
*/
|
|
26083
|
+
popElement(implied) {
|
|
26084
|
+
const element2 = this.stack.shift();
|
|
26085
|
+
if (this.htmlMode && (foreignContextElements.has(element2) || htmlIntegrationElements.has(element2))) {
|
|
26086
|
+
this.foreignContext.shift();
|
|
26087
|
+
}
|
|
26088
|
+
this.cbs.onclosetag?.(element2, implied);
|
|
26089
|
+
}
|
|
26090
|
+
closeCurrentTag(isOpenImplied) {
|
|
26091
|
+
const name = this.tagname;
|
|
26092
|
+
this.endOpenTag(isOpenImplied);
|
|
26093
|
+
if (this.stack[0] === name) {
|
|
26094
|
+
this.popElement(!isOpenImplied);
|
|
26095
|
+
}
|
|
26096
|
+
}
|
|
26097
|
+
/**
|
|
26098
|
+
* @param start Start index for the current parser event.
|
|
26099
|
+
* @param endIndex End index for the current parser event.
|
|
26100
|
+
* @internal
|
|
26101
|
+
*/
|
|
26102
|
+
onattribname(start, endIndex) {
|
|
26103
|
+
this.startIndex = start;
|
|
26104
|
+
const name = this.getSlice(start, endIndex);
|
|
26105
|
+
this.attribname = this.lowerCaseAttributeNames ? name.toLowerCase() : name;
|
|
26106
|
+
}
|
|
26107
|
+
/**
|
|
26108
|
+
* @param start Start index for the current parser event.
|
|
26109
|
+
* @param endIndex End index for the current parser event.
|
|
26110
|
+
* @internal
|
|
26111
|
+
*/
|
|
26112
|
+
onattribdata(start, endIndex) {
|
|
26113
|
+
this.attribvalue += this.getSlice(start, endIndex);
|
|
26114
|
+
}
|
|
26115
|
+
/**
|
|
26116
|
+
* @param cp Current Unicode code point.
|
|
26117
|
+
* @internal
|
|
26118
|
+
*/
|
|
26119
|
+
onattribentity(cp) {
|
|
26120
|
+
this.attribvalue += fromCodePoint(cp);
|
|
26121
|
+
}
|
|
26122
|
+
/**
|
|
26123
|
+
* @param quote Quote type used for the current attribute.
|
|
26124
|
+
* @param endIndex End index for the current parser event.
|
|
26125
|
+
* @internal
|
|
26126
|
+
*/
|
|
26127
|
+
onattribend(quote, endIndex) {
|
|
26128
|
+
this.endIndex = endIndex;
|
|
26129
|
+
this.cbs.onattribute?.(this.attribname, this.attribvalue, quote === QuoteType.Double ? '"' : quote === QuoteType.Single ? "'" : quote === QuoteType.NoValue ? void 0 : null);
|
|
26130
|
+
if (this.attribs && !Object.hasOwn(this.attribs, this.attribname)) {
|
|
26131
|
+
this.attribs[this.attribname] = this.attribvalue;
|
|
26132
|
+
}
|
|
26133
|
+
this.attribvalue = "";
|
|
26134
|
+
}
|
|
26135
|
+
getInstructionName(value) {
|
|
26136
|
+
const index = value.search(reNameEnd);
|
|
26137
|
+
let name = index < 0 ? value : value.substr(0, index);
|
|
26138
|
+
if (this.lowerCaseTagNames) {
|
|
26139
|
+
name = name.toLowerCase();
|
|
26140
|
+
}
|
|
26141
|
+
return name;
|
|
26142
|
+
}
|
|
26143
|
+
/**
|
|
26144
|
+
* @param start Start index for the current parser event.
|
|
26145
|
+
* @param endIndex End index for the current parser event.
|
|
26146
|
+
* @internal
|
|
26147
|
+
*/
|
|
26148
|
+
ondeclaration(start, endIndex) {
|
|
26149
|
+
this.endIndex = endIndex;
|
|
26150
|
+
const value = this.getSlice(start, endIndex);
|
|
26151
|
+
if (this.cbs.onprocessinginstruction) {
|
|
26152
|
+
const name = this.htmlMode ? this.lowerCaseTagNames ? DOCUMENT_TYPE : value.slice(0, DOCUMENT_TYPE.length) : this.getInstructionName(value);
|
|
26153
|
+
this.cbs.onprocessinginstruction(`!${name}`, `!${value}`);
|
|
26154
|
+
}
|
|
26155
|
+
this.startIndex = endIndex + 1;
|
|
26156
|
+
}
|
|
26157
|
+
/**
|
|
26158
|
+
* @param start Start index for the current parser event.
|
|
26159
|
+
* @param endIndex End index for the current parser event.
|
|
26160
|
+
* @internal
|
|
26161
|
+
*/
|
|
26162
|
+
onprocessinginstruction(start, endIndex) {
|
|
26163
|
+
this.endIndex = endIndex;
|
|
26164
|
+
const value = this.getSlice(start, endIndex);
|
|
26165
|
+
if (this.cbs.onprocessinginstruction) {
|
|
26166
|
+
const name = this.getInstructionName(value);
|
|
26167
|
+
this.cbs.onprocessinginstruction(`?${name}`, `?${value}`);
|
|
26168
|
+
}
|
|
26169
|
+
this.startIndex = endIndex + 1;
|
|
26170
|
+
}
|
|
26171
|
+
/**
|
|
26172
|
+
* @param start Start index for the current parser event.
|
|
26173
|
+
* @param endIndex End index for the current parser event.
|
|
26174
|
+
* @param offset Offset applied when computing parser indices.
|
|
26175
|
+
* @internal
|
|
26176
|
+
*/
|
|
26177
|
+
oncomment(start, endIndex, offset) {
|
|
26178
|
+
this.endIndex = endIndex;
|
|
26179
|
+
this.cbs.oncomment?.(this.getSlice(start, endIndex - offset));
|
|
26180
|
+
this.cbs.oncommentend?.();
|
|
26181
|
+
this.startIndex = endIndex + 1;
|
|
26182
|
+
}
|
|
26183
|
+
/**
|
|
26184
|
+
* @param start Start index for the current parser event.
|
|
26185
|
+
* @param endIndex End index for the current parser event.
|
|
26186
|
+
* @param offset Offset applied when computing parser indices.
|
|
26187
|
+
* @internal
|
|
26188
|
+
*/
|
|
26189
|
+
oncdata(start, endIndex, offset) {
|
|
26190
|
+
this.endIndex = endIndex;
|
|
26191
|
+
const value = this.getSlice(start, endIndex - offset);
|
|
26192
|
+
if (!this.htmlMode || this.options.recognizeCDATA) {
|
|
26193
|
+
this.cbs.oncdatastart?.();
|
|
26194
|
+
this.cbs.ontext?.(value);
|
|
26195
|
+
this.cbs.oncdataend?.();
|
|
26196
|
+
} else if (this.isInForeignContext()) {
|
|
26197
|
+
this.cbs.ontext?.(value);
|
|
26198
|
+
} else {
|
|
26199
|
+
this.cbs.oncomment?.(`[CDATA[${value}]]`);
|
|
26200
|
+
this.cbs.oncommentend?.();
|
|
26201
|
+
}
|
|
26202
|
+
this.startIndex = endIndex + 1;
|
|
26203
|
+
}
|
|
26204
|
+
/** @internal */
|
|
26205
|
+
onend() {
|
|
26206
|
+
if (this.cbs.onclosetag) {
|
|
26207
|
+
this.endIndex = this.startIndex;
|
|
26208
|
+
for (let index = 0; index < this.stack.length; index++) {
|
|
26209
|
+
this.cbs.onclosetag(this.stack[index], true);
|
|
26210
|
+
}
|
|
26211
|
+
}
|
|
26212
|
+
this.cbs.onend?.();
|
|
26213
|
+
}
|
|
26214
|
+
/**
|
|
26215
|
+
* Resets the parser to a blank state, ready to parse a new HTML document
|
|
26216
|
+
*/
|
|
26217
|
+
reset() {
|
|
26218
|
+
this.cbs.onreset?.();
|
|
26219
|
+
this.tokenizer.reset();
|
|
26220
|
+
this.tagname = "";
|
|
26221
|
+
this.attribname = "";
|
|
26222
|
+
this.attribvalue = "";
|
|
26223
|
+
this.attribs = null;
|
|
26224
|
+
this.stack.length = 0;
|
|
26225
|
+
this.startIndex = 0;
|
|
26226
|
+
this.endIndex = 0;
|
|
26227
|
+
this.cbs.onparserinit?.(this);
|
|
26228
|
+
this.buffers.length = 0;
|
|
26229
|
+
this.foreignContext.length = 0;
|
|
26230
|
+
this.foreignContext.unshift(ForeignContext.None);
|
|
26231
|
+
this.bufferOffset = 0;
|
|
26232
|
+
this.writeIndex = 0;
|
|
26233
|
+
this.ended = false;
|
|
26234
|
+
}
|
|
26235
|
+
/**
|
|
26236
|
+
* Resets the parser, then parses a complete document and
|
|
26237
|
+
* pushes it to the handler.
|
|
26238
|
+
* @param data Document to parse.
|
|
26239
|
+
*/
|
|
26240
|
+
parseComplete(data) {
|
|
26241
|
+
this.reset();
|
|
26242
|
+
this.end(data);
|
|
26243
|
+
}
|
|
26244
|
+
getSlice(start, end) {
|
|
26245
|
+
if (start === end) {
|
|
26246
|
+
return "";
|
|
26247
|
+
}
|
|
26248
|
+
while (start - this.bufferOffset >= this.buffers[0].length) {
|
|
26249
|
+
this.shiftBuffer();
|
|
26250
|
+
}
|
|
26251
|
+
let slice = this.buffers[0].slice(start - this.bufferOffset, end - this.bufferOffset);
|
|
26252
|
+
while (end - this.bufferOffset > this.buffers[0].length) {
|
|
26253
|
+
this.shiftBuffer();
|
|
26254
|
+
slice += this.buffers[0].slice(0, end - this.bufferOffset);
|
|
26255
|
+
}
|
|
26256
|
+
return slice;
|
|
26257
|
+
}
|
|
26258
|
+
shiftBuffer() {
|
|
26259
|
+
this.bufferOffset += this.buffers[0].length;
|
|
26260
|
+
this.writeIndex--;
|
|
26261
|
+
this.buffers.shift();
|
|
26262
|
+
}
|
|
26263
|
+
/**
|
|
26264
|
+
* Parses a chunk of data and calls the corresponding callbacks.
|
|
26265
|
+
* @param chunk Chunk to parse.
|
|
26266
|
+
*/
|
|
26267
|
+
write(chunk) {
|
|
26268
|
+
if (this.ended) {
|
|
26269
|
+
this.cbs.onerror?.(new Error(".write() after done!"));
|
|
26270
|
+
return;
|
|
26271
|
+
}
|
|
26272
|
+
this.buffers.push(chunk);
|
|
26273
|
+
if (this.tokenizer.running) {
|
|
26274
|
+
this.tokenizer.write(chunk);
|
|
26275
|
+
this.writeIndex++;
|
|
26276
|
+
}
|
|
26277
|
+
}
|
|
26278
|
+
/**
|
|
26279
|
+
* Parses the end of the buffer and clears the stack, calls onend.
|
|
26280
|
+
* @param chunk Optional final chunk to parse.
|
|
26281
|
+
*/
|
|
26282
|
+
end(chunk) {
|
|
26283
|
+
if (this.ended) {
|
|
26284
|
+
this.cbs.onerror?.(new Error(".end() after done!"));
|
|
26285
|
+
return;
|
|
26286
|
+
}
|
|
26287
|
+
if (chunk)
|
|
26288
|
+
this.write(chunk);
|
|
26289
|
+
this.ended = true;
|
|
26290
|
+
this.tokenizer.end();
|
|
26291
|
+
}
|
|
26292
|
+
/**
|
|
26293
|
+
* Pauses parsing. The parser won't emit events until `resume` is called.
|
|
26294
|
+
*/
|
|
26295
|
+
pause() {
|
|
26296
|
+
this.tokenizer.pause();
|
|
26297
|
+
}
|
|
26298
|
+
/**
|
|
26299
|
+
* Resumes parsing after `pause` was called.
|
|
26300
|
+
*/
|
|
26301
|
+
resume() {
|
|
26302
|
+
this.tokenizer.resume();
|
|
26303
|
+
while (this.tokenizer.running && this.writeIndex < this.buffers.length) {
|
|
26304
|
+
this.tokenizer.write(this.buffers[this.writeIndex++]);
|
|
26305
|
+
}
|
|
26306
|
+
if (this.ended)
|
|
26307
|
+
this.tokenizer.end();
|
|
26308
|
+
}
|
|
26309
|
+
};
|
|
26310
|
+
|
|
26311
|
+
// node_modules/domelementtype/dist/index.js
|
|
26312
|
+
var ElementType;
|
|
26313
|
+
(function(ElementType2) {
|
|
26314
|
+
ElementType2["Root"] = "root";
|
|
26315
|
+
ElementType2["Text"] = "text";
|
|
26316
|
+
ElementType2["Directive"] = "directive";
|
|
26317
|
+
ElementType2["Comment"] = "comment";
|
|
26318
|
+
ElementType2["Script"] = "script";
|
|
26319
|
+
ElementType2["Style"] = "style";
|
|
26320
|
+
ElementType2["Tag"] = "tag";
|
|
26321
|
+
ElementType2["CDATA"] = "cdata";
|
|
26322
|
+
ElementType2["Doctype"] = "doctype";
|
|
26323
|
+
})(ElementType || (ElementType = {}));
|
|
26324
|
+
function isTag(element2) {
|
|
26325
|
+
return element2.type === ElementType.Tag || element2.type === ElementType.Script || element2.type === ElementType.Style;
|
|
26326
|
+
}
|
|
26327
|
+
var Root = ElementType.Root;
|
|
26328
|
+
var Text = ElementType.Text;
|
|
26329
|
+
var Directive = ElementType.Directive;
|
|
26330
|
+
var Comment = ElementType.Comment;
|
|
26331
|
+
var Script = ElementType.Script;
|
|
26332
|
+
var Style = ElementType.Style;
|
|
26333
|
+
var Tag = ElementType.Tag;
|
|
26334
|
+
var CDATA = ElementType.CDATA;
|
|
26335
|
+
var Doctype = ElementType.Doctype;
|
|
26336
|
+
|
|
26337
|
+
// node_modules/domhandler/dist/node.js
|
|
26338
|
+
var Node = class {
|
|
26339
|
+
/** Parent of the node */
|
|
26340
|
+
parent = null;
|
|
26341
|
+
/** Previous sibling */
|
|
26342
|
+
prev = null;
|
|
26343
|
+
/** Next sibling */
|
|
26344
|
+
next = null;
|
|
26345
|
+
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
|
26346
|
+
startIndex = null;
|
|
26347
|
+
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
|
26348
|
+
endIndex = null;
|
|
26349
|
+
// Read-write aliases for properties
|
|
26350
|
+
/**
|
|
26351
|
+
* Same as {@link parent}.
|
|
26352
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
26353
|
+
*/
|
|
26354
|
+
get parentNode() {
|
|
26355
|
+
return this.parent;
|
|
26356
|
+
}
|
|
26357
|
+
set parentNode(parent) {
|
|
26358
|
+
this.parent = parent;
|
|
26359
|
+
}
|
|
26360
|
+
/**
|
|
26361
|
+
* Same as {@link prev}.
|
|
26362
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
26363
|
+
*/
|
|
26364
|
+
get previousSibling() {
|
|
26365
|
+
return this.prev;
|
|
26366
|
+
}
|
|
26367
|
+
set previousSibling(previous) {
|
|
26368
|
+
this.prev = previous;
|
|
26369
|
+
}
|
|
26370
|
+
/**
|
|
26371
|
+
* Same as {@link next}.
|
|
26372
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
26373
|
+
*/
|
|
26374
|
+
get nextSibling() {
|
|
26375
|
+
return this.next;
|
|
26376
|
+
}
|
|
26377
|
+
set nextSibling(next) {
|
|
26378
|
+
this.next = next;
|
|
26379
|
+
}
|
|
26380
|
+
/**
|
|
26381
|
+
* Clone this node, and optionally its children.
|
|
26382
|
+
* @param recursive Clone child nodes as well.
|
|
26383
|
+
* @returns A clone of the node.
|
|
26384
|
+
*/
|
|
26385
|
+
cloneNode(recursive3 = false) {
|
|
26386
|
+
return cloneNode(this, recursive3);
|
|
26387
|
+
}
|
|
26388
|
+
};
|
|
26389
|
+
var DataNode = class extends Node {
|
|
26390
|
+
data;
|
|
26391
|
+
/**
|
|
26392
|
+
* @param data The content of the data node
|
|
26393
|
+
*/
|
|
26394
|
+
constructor(data) {
|
|
26395
|
+
super();
|
|
26396
|
+
this.data = data;
|
|
26397
|
+
}
|
|
26398
|
+
/**
|
|
26399
|
+
* Same as {@link data}.
|
|
26400
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
26401
|
+
*/
|
|
26402
|
+
get nodeValue() {
|
|
26403
|
+
return this.data;
|
|
26404
|
+
}
|
|
26405
|
+
set nodeValue(data) {
|
|
26406
|
+
this.data = data;
|
|
26407
|
+
}
|
|
26408
|
+
};
|
|
26409
|
+
var Text2 = class extends DataNode {
|
|
26410
|
+
type = ElementType.Text;
|
|
26411
|
+
get nodeType() {
|
|
26412
|
+
return 3;
|
|
26413
|
+
}
|
|
26414
|
+
};
|
|
26415
|
+
var Comment2 = class extends DataNode {
|
|
26416
|
+
type = ElementType.Comment;
|
|
26417
|
+
get nodeType() {
|
|
26418
|
+
return 8;
|
|
26419
|
+
}
|
|
26420
|
+
};
|
|
26421
|
+
var ProcessingInstruction = class extends DataNode {
|
|
26422
|
+
type = ElementType.Directive;
|
|
26423
|
+
name;
|
|
26424
|
+
constructor(name, data) {
|
|
26425
|
+
super(data);
|
|
26426
|
+
this.name = name;
|
|
26427
|
+
}
|
|
26428
|
+
get nodeType() {
|
|
26429
|
+
return 1;
|
|
26430
|
+
}
|
|
26431
|
+
/** If this is a doctype, the document type name (parse5 only). */
|
|
26432
|
+
"x-name";
|
|
26433
|
+
/** If this is a doctype, the document type public identifier (parse5 only). */
|
|
26434
|
+
"x-publicId";
|
|
26435
|
+
/** If this is a doctype, the document type system identifier (parse5 only). */
|
|
26436
|
+
"x-systemId";
|
|
26437
|
+
};
|
|
26438
|
+
var NodeWithChildren = class extends Node {
|
|
26439
|
+
children;
|
|
26440
|
+
/**
|
|
26441
|
+
* @param children Children of the node. Only certain node types can have children.
|
|
26442
|
+
*/
|
|
26443
|
+
constructor(children) {
|
|
26444
|
+
super();
|
|
26445
|
+
this.children = children;
|
|
26446
|
+
}
|
|
26447
|
+
// Aliases
|
|
26448
|
+
/** First child of the node. */
|
|
26449
|
+
get firstChild() {
|
|
26450
|
+
return this.children[0] ?? null;
|
|
26451
|
+
}
|
|
26452
|
+
/** Last child of the node. */
|
|
26453
|
+
get lastChild() {
|
|
26454
|
+
return this.children.length > 0 ? this.children[this.children.length - 1] : null;
|
|
26455
|
+
}
|
|
26456
|
+
/**
|
|
26457
|
+
* Same as {@link children}.
|
|
26458
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
26459
|
+
*/
|
|
26460
|
+
get childNodes() {
|
|
26461
|
+
return this.children;
|
|
26462
|
+
}
|
|
26463
|
+
set childNodes(children) {
|
|
26464
|
+
this.children = children;
|
|
26465
|
+
}
|
|
26466
|
+
};
|
|
26467
|
+
var CDATA2 = class extends NodeWithChildren {
|
|
26468
|
+
type = ElementType.CDATA;
|
|
26469
|
+
get nodeType() {
|
|
26470
|
+
return 4;
|
|
26471
|
+
}
|
|
26472
|
+
};
|
|
26473
|
+
var Document = class extends NodeWithChildren {
|
|
26474
|
+
type = ElementType.Root;
|
|
26475
|
+
get nodeType() {
|
|
26476
|
+
return 9;
|
|
26477
|
+
}
|
|
26478
|
+
};
|
|
26479
|
+
var Element = class extends NodeWithChildren {
|
|
26480
|
+
name;
|
|
26481
|
+
attribs;
|
|
26482
|
+
type;
|
|
26483
|
+
/**
|
|
26484
|
+
* @param name Name of the tag, eg. `div`, `span`.
|
|
26485
|
+
* @param attribs Object mapping attribute names to attribute values.
|
|
26486
|
+
* @param children Children of the node.
|
|
26487
|
+
* @param type Node type used for the new node instance.
|
|
26488
|
+
*/
|
|
26489
|
+
constructor(name, attribs, children = [], type = name === "script" ? ElementType.Script : name === "style" ? ElementType.Style : ElementType.Tag) {
|
|
26490
|
+
super(children);
|
|
26491
|
+
this.name = name;
|
|
26492
|
+
this.attribs = attribs;
|
|
26493
|
+
this.type = type;
|
|
26494
|
+
}
|
|
26495
|
+
get nodeType() {
|
|
26496
|
+
return 1;
|
|
26497
|
+
}
|
|
26498
|
+
// DOM Level 1 aliases
|
|
26499
|
+
/**
|
|
26500
|
+
* Same as {@link name}.
|
|
26501
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
26502
|
+
*/
|
|
26503
|
+
get tagName() {
|
|
26504
|
+
return this.name;
|
|
26505
|
+
}
|
|
26506
|
+
set tagName(name) {
|
|
26507
|
+
this.name = name;
|
|
26508
|
+
}
|
|
26509
|
+
get attributes() {
|
|
26510
|
+
return Object.keys(this.attribs).map((name) => ({
|
|
26511
|
+
name,
|
|
26512
|
+
value: this.attribs[name],
|
|
26513
|
+
namespace: this["x-attribsNamespace"]?.[name],
|
|
26514
|
+
prefix: this["x-attribsPrefix"]?.[name]
|
|
26515
|
+
}));
|
|
26516
|
+
}
|
|
26517
|
+
/** Element namespace (parse5 only). */
|
|
26518
|
+
namespace;
|
|
26519
|
+
/** Element attribute namespaces (parse5 only). */
|
|
26520
|
+
"x-attribsNamespace";
|
|
26521
|
+
/** Element attribute namespace-related prefixes (parse5 only). */
|
|
26522
|
+
"x-attribsPrefix";
|
|
26523
|
+
};
|
|
26524
|
+
function isTag2(node3) {
|
|
26525
|
+
return isTag(node3);
|
|
26526
|
+
}
|
|
26527
|
+
function isCDATA(node3) {
|
|
26528
|
+
return node3.type === ElementType.CDATA;
|
|
26529
|
+
}
|
|
26530
|
+
function isText(node3) {
|
|
26531
|
+
return node3.type === ElementType.Text;
|
|
26532
|
+
}
|
|
26533
|
+
function isComment(node3) {
|
|
26534
|
+
return node3.type === ElementType.Comment;
|
|
26535
|
+
}
|
|
26536
|
+
function isDirective(node3) {
|
|
26537
|
+
return node3.type === ElementType.Directive;
|
|
26538
|
+
}
|
|
26539
|
+
function isDocument(node3) {
|
|
26540
|
+
return node3.type === ElementType.Root;
|
|
26541
|
+
}
|
|
26542
|
+
function hasChildren(node3) {
|
|
26543
|
+
return Object.hasOwn(node3, "children");
|
|
26544
|
+
}
|
|
26545
|
+
function cloneNode(node3, recursive3 = false) {
|
|
26546
|
+
let result;
|
|
26547
|
+
if (isText(node3)) {
|
|
26548
|
+
result = new Text2(node3.data);
|
|
26549
|
+
} else if (isComment(node3)) {
|
|
26550
|
+
result = new Comment2(node3.data);
|
|
26551
|
+
} else if (isTag2(node3)) {
|
|
26552
|
+
const children = recursive3 ? cloneChildren(node3.children) : [];
|
|
26553
|
+
const clone4 = new Element(node3.name, { ...node3.attribs }, children);
|
|
26554
|
+
for (const child of children) {
|
|
26555
|
+
child.parent = clone4;
|
|
26556
|
+
}
|
|
26557
|
+
if (node3.namespace != null) {
|
|
26558
|
+
clone4.namespace = node3.namespace;
|
|
26559
|
+
}
|
|
26560
|
+
if (node3["x-attribsNamespace"]) {
|
|
26561
|
+
clone4["x-attribsNamespace"] = { ...node3["x-attribsNamespace"] };
|
|
26562
|
+
}
|
|
26563
|
+
if (node3["x-attribsPrefix"]) {
|
|
26564
|
+
clone4["x-attribsPrefix"] = { ...node3["x-attribsPrefix"] };
|
|
26565
|
+
}
|
|
26566
|
+
result = clone4;
|
|
26567
|
+
} else if (isCDATA(node3)) {
|
|
26568
|
+
const children = recursive3 ? cloneChildren(node3.children) : [];
|
|
26569
|
+
const clone4 = new CDATA2(children);
|
|
26570
|
+
for (const child of children) {
|
|
26571
|
+
child.parent = clone4;
|
|
26572
|
+
}
|
|
26573
|
+
result = clone4;
|
|
26574
|
+
} else if (isDocument(node3)) {
|
|
26575
|
+
const children = recursive3 ? cloneChildren(node3.children) : [];
|
|
26576
|
+
const clone4 = new Document(children);
|
|
26577
|
+
for (const child of children) {
|
|
26578
|
+
child.parent = clone4;
|
|
26579
|
+
}
|
|
26580
|
+
if (node3["x-mode"]) {
|
|
26581
|
+
clone4["x-mode"] = node3["x-mode"];
|
|
26582
|
+
}
|
|
26583
|
+
result = clone4;
|
|
26584
|
+
} else if (isDirective(node3)) {
|
|
26585
|
+
const instruction = new ProcessingInstruction(node3.name, node3.data);
|
|
26586
|
+
if (node3["x-name"] != null) {
|
|
26587
|
+
instruction["x-name"] = node3["x-name"];
|
|
26588
|
+
instruction["x-publicId"] = node3["x-publicId"];
|
|
26589
|
+
instruction["x-systemId"] = node3["x-systemId"];
|
|
26590
|
+
}
|
|
26591
|
+
result = instruction;
|
|
26592
|
+
} else {
|
|
26593
|
+
throw new Error(`Not implemented yet: ${node3.type}`);
|
|
26594
|
+
}
|
|
26595
|
+
result.startIndex = node3.startIndex;
|
|
26596
|
+
result.endIndex = node3.endIndex;
|
|
26597
|
+
if (node3.sourceCodeLocation != null) {
|
|
26598
|
+
result.sourceCodeLocation = node3.sourceCodeLocation;
|
|
26599
|
+
}
|
|
26600
|
+
return result;
|
|
26601
|
+
}
|
|
26602
|
+
function cloneChildren(childs) {
|
|
26603
|
+
const children = childs.map((child) => cloneNode(child, true));
|
|
26604
|
+
for (let index = 1; index < children.length; index++) {
|
|
26605
|
+
children[index].prev = children[index - 1];
|
|
26606
|
+
children[index - 1].next = children[index];
|
|
26607
|
+
}
|
|
26608
|
+
return children;
|
|
26609
|
+
}
|
|
26610
|
+
|
|
26611
|
+
// node_modules/domhandler/dist/index.js
|
|
26612
|
+
var defaultOptions = {
|
|
26613
|
+
withStartIndices: false,
|
|
26614
|
+
withEndIndices: false,
|
|
26615
|
+
xmlMode: false
|
|
26616
|
+
};
|
|
26617
|
+
var DomHandler = class {
|
|
26618
|
+
/** The elements of the DOM */
|
|
26619
|
+
dom = [];
|
|
26620
|
+
/** The root element for the DOM */
|
|
26621
|
+
root = new Document(this.dom);
|
|
26622
|
+
/** Called once parsing has completed. */
|
|
26623
|
+
callback;
|
|
26624
|
+
/** Settings for the handler. */
|
|
26625
|
+
options;
|
|
26626
|
+
/** Callback whenever a tag is closed. */
|
|
26627
|
+
elementCB;
|
|
26628
|
+
/** Indicated whether parsing has been completed. */
|
|
26629
|
+
done = false;
|
|
26630
|
+
/** Stack of open tags. */
|
|
26631
|
+
tagStack = [this.root];
|
|
26632
|
+
/** A data node that is still being written to. */
|
|
26633
|
+
lastNode = null;
|
|
26634
|
+
/** Reference to the parser instance. Used for location information. */
|
|
26635
|
+
parser = null;
|
|
26636
|
+
/**
|
|
26637
|
+
* @param callback Called once parsing has completed.
|
|
26638
|
+
* @param options Settings for the handler.
|
|
26639
|
+
* @param elementCB Callback whenever a tag is closed.
|
|
26640
|
+
*/
|
|
26641
|
+
constructor(callback, options, elementCB) {
|
|
26642
|
+
if (typeof options === "function") {
|
|
26643
|
+
elementCB = options;
|
|
26644
|
+
options = defaultOptions;
|
|
26645
|
+
}
|
|
26646
|
+
if (typeof callback === "object") {
|
|
26647
|
+
options = callback;
|
|
26648
|
+
callback = void 0;
|
|
26649
|
+
}
|
|
26650
|
+
this.callback = callback ?? null;
|
|
26651
|
+
this.options = options ?? defaultOptions;
|
|
26652
|
+
this.elementCB = elementCB ?? null;
|
|
26653
|
+
}
|
|
26654
|
+
onparserinit(parser) {
|
|
26655
|
+
this.parser = parser;
|
|
26656
|
+
}
|
|
26657
|
+
// Resets the handler back to starting state
|
|
26658
|
+
onreset() {
|
|
26659
|
+
this.dom = [];
|
|
26660
|
+
this.root = new Document(this.dom);
|
|
26661
|
+
this.done = false;
|
|
26662
|
+
this.tagStack = [this.root];
|
|
26663
|
+
this.lastNode = null;
|
|
26664
|
+
this.parser = null;
|
|
26665
|
+
}
|
|
26666
|
+
// Signals the handler that parsing is done
|
|
26667
|
+
onend() {
|
|
26668
|
+
if (this.done)
|
|
26669
|
+
return;
|
|
26670
|
+
this.done = true;
|
|
26671
|
+
this.parser = null;
|
|
26672
|
+
this.handleCallback(null);
|
|
26673
|
+
}
|
|
26674
|
+
onerror(error42) {
|
|
26675
|
+
this.handleCallback(error42);
|
|
26676
|
+
}
|
|
26677
|
+
onclosetag() {
|
|
26678
|
+
this.lastNode = null;
|
|
26679
|
+
const element2 = this.tagStack.pop();
|
|
26680
|
+
if (this.options.withEndIndices && this.parser) {
|
|
26681
|
+
element2.endIndex = this.parser.endIndex;
|
|
26682
|
+
}
|
|
26683
|
+
if (this.elementCB)
|
|
26684
|
+
this.elementCB(element2);
|
|
26685
|
+
}
|
|
26686
|
+
onopentag(name, attribs) {
|
|
26687
|
+
const type = this.options.xmlMode ? ElementType.Tag : void 0;
|
|
26688
|
+
const element2 = new Element(name, attribs, void 0, type);
|
|
26689
|
+
this.addNode(element2);
|
|
26690
|
+
this.tagStack.push(element2);
|
|
26691
|
+
}
|
|
26692
|
+
ontext(data) {
|
|
26693
|
+
const { lastNode } = this;
|
|
26694
|
+
if (lastNode && lastNode.type === ElementType.Text) {
|
|
26695
|
+
lastNode.data += data;
|
|
26696
|
+
if (this.options.withEndIndices && this.parser) {
|
|
26697
|
+
lastNode.endIndex = this.parser.endIndex;
|
|
26698
|
+
}
|
|
26699
|
+
} else {
|
|
26700
|
+
const node3 = new Text2(data);
|
|
26701
|
+
this.addNode(node3);
|
|
26702
|
+
this.lastNode = node3;
|
|
26703
|
+
}
|
|
26704
|
+
}
|
|
26705
|
+
oncomment(data) {
|
|
26706
|
+
if (this.lastNode && this.lastNode.type === ElementType.Comment) {
|
|
26707
|
+
this.lastNode.data += data;
|
|
26708
|
+
return;
|
|
26709
|
+
}
|
|
26710
|
+
const node3 = new Comment2(data);
|
|
26711
|
+
this.addNode(node3);
|
|
26712
|
+
this.lastNode = node3;
|
|
26713
|
+
}
|
|
26714
|
+
oncommentend() {
|
|
26715
|
+
this.lastNode = null;
|
|
26716
|
+
}
|
|
26717
|
+
oncdatastart() {
|
|
26718
|
+
const text = new Text2("");
|
|
26719
|
+
const node3 = new CDATA2([text]);
|
|
26720
|
+
this.addNode(node3);
|
|
26721
|
+
text.parent = node3;
|
|
26722
|
+
this.lastNode = text;
|
|
26723
|
+
}
|
|
26724
|
+
oncdataend() {
|
|
26725
|
+
this.lastNode = null;
|
|
26726
|
+
}
|
|
26727
|
+
onprocessinginstruction(name, data) {
|
|
26728
|
+
const node3 = new ProcessingInstruction(name, data);
|
|
26729
|
+
this.addNode(node3);
|
|
26730
|
+
}
|
|
26731
|
+
handleCallback(error42) {
|
|
26732
|
+
if (typeof this.callback === "function") {
|
|
26733
|
+
this.callback(error42, this.dom);
|
|
26734
|
+
} else if (error42) {
|
|
26735
|
+
throw error42;
|
|
26736
|
+
}
|
|
26737
|
+
}
|
|
26738
|
+
addNode(node3) {
|
|
26739
|
+
const parent = this.tagStack[this.tagStack.length - 1];
|
|
26740
|
+
const previousSibling = parent.children[parent.children.length - 1];
|
|
26741
|
+
if (this.options.withStartIndices && this.parser) {
|
|
26742
|
+
node3.startIndex = this.parser.startIndex;
|
|
26743
|
+
}
|
|
26744
|
+
if (this.options.withEndIndices && this.parser) {
|
|
26745
|
+
node3.endIndex = this.parser.endIndex;
|
|
26746
|
+
}
|
|
26747
|
+
parent.children.push(node3);
|
|
26748
|
+
if (previousSibling) {
|
|
26749
|
+
node3.prev = previousSibling;
|
|
26750
|
+
previousSibling.next = node3;
|
|
26751
|
+
}
|
|
26752
|
+
node3.parent = parent;
|
|
26753
|
+
this.lastNode = null;
|
|
26754
|
+
}
|
|
26755
|
+
};
|
|
26756
|
+
|
|
26757
|
+
// node_modules/domutils/dist/index.js
|
|
26758
|
+
var dist_exports2 = {};
|
|
26759
|
+
__export(dist_exports2, {
|
|
26760
|
+
DocumentPosition: () => DocumentPosition,
|
|
26761
|
+
append: () => append,
|
|
26762
|
+
appendChild: () => appendChild,
|
|
26763
|
+
compareDocumentPosition: () => compareDocumentPosition,
|
|
26764
|
+
existsOne: () => existsOne,
|
|
26765
|
+
filter: () => filter,
|
|
26766
|
+
find: () => find,
|
|
26767
|
+
findAll: () => findAll,
|
|
26768
|
+
findOne: () => findOne,
|
|
26769
|
+
getAttributeValue: () => getAttributeValue,
|
|
26770
|
+
getChildren: () => getChildren,
|
|
26771
|
+
getElementById: () => getElementById,
|
|
26772
|
+
getElements: () => getElements,
|
|
26773
|
+
getElementsByClassName: () => getElementsByClassName,
|
|
26774
|
+
getElementsByTagName: () => getElementsByTagName,
|
|
26775
|
+
getElementsByTagType: () => getElementsByTagType,
|
|
26776
|
+
getFeed: () => getFeed,
|
|
26777
|
+
getInnerHTML: () => getInnerHTML,
|
|
26778
|
+
getName: () => getName,
|
|
26779
|
+
getOuterHTML: () => getOuterHTML,
|
|
26780
|
+
getParent: () => getParent,
|
|
26781
|
+
getSiblings: () => getSiblings,
|
|
26782
|
+
getText: () => getText,
|
|
26783
|
+
hasAttrib: () => hasAttrib,
|
|
26784
|
+
innerText: () => innerText,
|
|
26785
|
+
nextElementSibling: () => nextElementSibling,
|
|
26786
|
+
prepend: () => prepend,
|
|
26787
|
+
prependChild: () => prependChild,
|
|
26788
|
+
prevElementSibling: () => prevElementSibling,
|
|
26789
|
+
removeElement: () => removeElement,
|
|
26790
|
+
removeSubsets: () => removeSubsets,
|
|
26791
|
+
replaceElement: () => replaceElement,
|
|
26792
|
+
testElement: () => testElement,
|
|
26793
|
+
textContent: () => textContent,
|
|
26794
|
+
uniqueSort: () => uniqueSort
|
|
26795
|
+
});
|
|
26796
|
+
|
|
26797
|
+
// node_modules/domutils/dist/querying.js
|
|
26798
|
+
function filter(test, node3, recurse = true, limit = Number.POSITIVE_INFINITY) {
|
|
26799
|
+
return find(test, Array.isArray(node3) ? node3 : [node3], recurse, limit);
|
|
26800
|
+
}
|
|
26801
|
+
function find(test, nodes, recurse, limit) {
|
|
26802
|
+
const result = [];
|
|
26803
|
+
const nodeStack = [Array.isArray(nodes) ? nodes : [nodes]];
|
|
26804
|
+
const indexStack = [0];
|
|
26805
|
+
for (; ; ) {
|
|
26806
|
+
if (indexStack[0] >= nodeStack[0].length) {
|
|
26807
|
+
if (indexStack.length === 1) {
|
|
26808
|
+
return result;
|
|
26809
|
+
}
|
|
26810
|
+
nodeStack.shift();
|
|
26811
|
+
indexStack.shift();
|
|
26812
|
+
continue;
|
|
26813
|
+
}
|
|
26814
|
+
const element2 = nodeStack[0][indexStack[0]++];
|
|
26815
|
+
if (test(element2)) {
|
|
26816
|
+
result.push(element2);
|
|
26817
|
+
if (--limit <= 0)
|
|
26818
|
+
return result;
|
|
26819
|
+
}
|
|
26820
|
+
if (recurse && hasChildren(element2) && element2.children.length > 0) {
|
|
26821
|
+
indexStack.unshift(0);
|
|
26822
|
+
nodeStack.unshift(element2.children);
|
|
26823
|
+
}
|
|
26824
|
+
}
|
|
26825
|
+
}
|
|
26826
|
+
function findOne(test, nodes, recurse = true) {
|
|
26827
|
+
const searchedNodes = Array.isArray(nodes) ? nodes : [nodes];
|
|
26828
|
+
for (const node3 of searchedNodes) {
|
|
26829
|
+
if (isTag2(node3) && test(node3)) {
|
|
26830
|
+
return node3;
|
|
26831
|
+
}
|
|
26832
|
+
if (recurse && hasChildren(node3) && node3.children.length > 0) {
|
|
26833
|
+
const found = findOne(test, node3.children, true);
|
|
26834
|
+
if (found)
|
|
26835
|
+
return found;
|
|
26836
|
+
}
|
|
26837
|
+
}
|
|
26838
|
+
return null;
|
|
26839
|
+
}
|
|
26840
|
+
function existsOne(test, nodes) {
|
|
26841
|
+
return (Array.isArray(nodes) ? nodes : [nodes]).some((node3) => isTag2(node3) && test(node3) || hasChildren(node3) && existsOne(test, node3.children));
|
|
26842
|
+
}
|
|
26843
|
+
function findAll(test, nodes) {
|
|
26844
|
+
const result = [];
|
|
26845
|
+
const nodeStack = [Array.isArray(nodes) ? nodes : [nodes]];
|
|
26846
|
+
const indexStack = [0];
|
|
26847
|
+
for (; ; ) {
|
|
26848
|
+
if (indexStack[0] >= nodeStack[0].length) {
|
|
26849
|
+
if (nodeStack.length === 1) {
|
|
26850
|
+
return result;
|
|
26851
|
+
}
|
|
26852
|
+
nodeStack.shift();
|
|
26853
|
+
indexStack.shift();
|
|
26854
|
+
continue;
|
|
26855
|
+
}
|
|
26856
|
+
const element2 = nodeStack[0][indexStack[0]++];
|
|
26857
|
+
if (isTag2(element2) && test(element2))
|
|
26858
|
+
result.push(element2);
|
|
26859
|
+
if (hasChildren(element2) && element2.children.length > 0) {
|
|
26860
|
+
indexStack.unshift(0);
|
|
26861
|
+
nodeStack.unshift(element2.children);
|
|
26862
|
+
}
|
|
26863
|
+
}
|
|
26864
|
+
}
|
|
26865
|
+
|
|
26866
|
+
// node_modules/domutils/dist/legacy.js
|
|
26867
|
+
var Checks = {
|
|
26868
|
+
tag_name(name) {
|
|
26869
|
+
if (typeof name === "function") {
|
|
26870
|
+
return (element2) => isTag2(element2) && name(element2.name);
|
|
26871
|
+
}
|
|
26872
|
+
if (name === "*") {
|
|
26873
|
+
return isTag2;
|
|
26874
|
+
}
|
|
26875
|
+
return (element2) => isTag2(element2) && element2.name === name;
|
|
26876
|
+
},
|
|
26877
|
+
tag_type(type) {
|
|
26878
|
+
if (typeof type === "function") {
|
|
26879
|
+
return (element2) => type(element2.type);
|
|
26880
|
+
}
|
|
26881
|
+
return (element2) => element2.type === type;
|
|
26882
|
+
},
|
|
26883
|
+
tag_contains(data) {
|
|
26884
|
+
if (typeof data === "function") {
|
|
26885
|
+
return (element2) => isText(element2) && data(element2.data);
|
|
26886
|
+
}
|
|
26887
|
+
return (element2) => isText(element2) && element2.data === data;
|
|
26888
|
+
}
|
|
26889
|
+
};
|
|
26890
|
+
function getAttribCheck(attrib, value) {
|
|
26891
|
+
if (typeof value === "function") {
|
|
26892
|
+
return (element2) => isTag2(element2) && value(element2.attribs[attrib]);
|
|
26893
|
+
}
|
|
26894
|
+
return (element2) => isTag2(element2) && element2.attribs[attrib] === value;
|
|
26895
|
+
}
|
|
26896
|
+
function combineFuncs(a, b) {
|
|
26897
|
+
return (element2) => a(element2) || b(element2);
|
|
26898
|
+
}
|
|
26899
|
+
function compileTest(options) {
|
|
26900
|
+
const funcs = Object.keys(options).map((key) => {
|
|
26901
|
+
const value = options[key];
|
|
26902
|
+
return Object.hasOwn(Checks, key) ? Checks[key](value) : getAttribCheck(key, value);
|
|
26903
|
+
});
|
|
26904
|
+
return funcs.length === 0 ? null : funcs.reduce(combineFuncs);
|
|
26905
|
+
}
|
|
26906
|
+
function testElement(options, node3) {
|
|
26907
|
+
const test = compileTest(options);
|
|
26908
|
+
return test ? test(node3) : true;
|
|
26909
|
+
}
|
|
26910
|
+
function getElements(options, nodes, recurse, limit = Number.POSITIVE_INFINITY) {
|
|
26911
|
+
const test = compileTest(options);
|
|
26912
|
+
return test ? filter(test, nodes, recurse, limit) : [];
|
|
26913
|
+
}
|
|
26914
|
+
function getElementById(id, nodes, recurse = true) {
|
|
26915
|
+
if (!Array.isArray(nodes))
|
|
26916
|
+
nodes = [nodes];
|
|
26917
|
+
return findOne(getAttribCheck("id", id), nodes, recurse);
|
|
26918
|
+
}
|
|
26919
|
+
function getElementsByTagName(tagName, nodes, recurse = true, limit = Number.POSITIVE_INFINITY) {
|
|
26920
|
+
return filter(Checks["tag_name"](tagName), nodes, recurse, limit);
|
|
26921
|
+
}
|
|
26922
|
+
function getElementsByClassName(className, nodes, recurse = true, limit = Number.POSITIVE_INFINITY) {
|
|
26923
|
+
return filter(getAttribCheck("class", className), nodes, recurse, limit);
|
|
26924
|
+
}
|
|
26925
|
+
function getElementsByTagType(type, nodes, recurse = true, limit = Number.POSITIVE_INFINITY) {
|
|
26926
|
+
return filter(Checks["tag_type"](type), nodes, recurse, limit);
|
|
26927
|
+
}
|
|
26928
|
+
|
|
26929
|
+
// node_modules/entities/dist/escape.js
|
|
26930
|
+
function getEscape(char) {
|
|
26931
|
+
return char === 34 ? """ : char === 38 ? "&" : char === 39 ? "'" : char === 60 ? "<" : char === 62 ? ">" : " ";
|
|
26932
|
+
}
|
|
26933
|
+
var XML_BITSET_VALUE = 1342177476;
|
|
26934
|
+
var xmlEncodeRegex = /["&'<>\u0080-\uFFFF]/g;
|
|
26935
|
+
function isXmlEscapable(code) {
|
|
26936
|
+
return code >= 128 || code >= 32 && code < 64 && (XML_BITSET_VALUE >>> code & 1) === 1;
|
|
26937
|
+
}
|
|
26938
|
+
function encodeXML(input) {
|
|
26939
|
+
const { length } = input;
|
|
26940
|
+
let out;
|
|
26941
|
+
let last2 = 0;
|
|
26942
|
+
let index = 0;
|
|
26943
|
+
while (index < length) {
|
|
26944
|
+
const char = input.charCodeAt(index);
|
|
26945
|
+
if (!isXmlEscapable(char)) {
|
|
26946
|
+
const bound = Math.min(index + 32, length);
|
|
26947
|
+
let next = index + 1;
|
|
26948
|
+
while (next < bound && !isXmlEscapable(input.charCodeAt(next))) {
|
|
26949
|
+
next++;
|
|
26950
|
+
}
|
|
26951
|
+
if (next < bound) {
|
|
26952
|
+
index = next;
|
|
26953
|
+
continue;
|
|
26954
|
+
}
|
|
26955
|
+
if (next >= length)
|
|
26956
|
+
break;
|
|
26957
|
+
xmlEncodeRegex.lastIndex = next;
|
|
26958
|
+
if (!xmlEncodeRegex.test(input))
|
|
26959
|
+
break;
|
|
26960
|
+
index = xmlEncodeRegex.lastIndex - 1;
|
|
26961
|
+
continue;
|
|
26962
|
+
}
|
|
26963
|
+
if (out === void 0)
|
|
26964
|
+
out = input.substring(0, index);
|
|
26965
|
+
else if (last2 !== index)
|
|
26966
|
+
out += input.substring(last2, index);
|
|
26967
|
+
if (char < 64) {
|
|
26968
|
+
out += getEscape(char);
|
|
26969
|
+
last2 = index += 1;
|
|
26970
|
+
continue;
|
|
26971
|
+
}
|
|
26972
|
+
const cp = input.codePointAt(index);
|
|
26973
|
+
out += `&#x${cp.toString(16)};`;
|
|
26974
|
+
if (cp !== char)
|
|
26975
|
+
index++;
|
|
26976
|
+
last2 = index += 1;
|
|
26977
|
+
}
|
|
26978
|
+
if (out === void 0)
|
|
26979
|
+
return input;
|
|
26980
|
+
if (last2 < length)
|
|
26981
|
+
out += input.substr(last2);
|
|
26982
|
+
return out;
|
|
26983
|
+
}
|
|
26984
|
+
function escapeWithRegex(re, data) {
|
|
26985
|
+
re.lastIndex = 0;
|
|
26986
|
+
if (!re.test(data))
|
|
26987
|
+
return data;
|
|
26988
|
+
let out = "";
|
|
26989
|
+
let last2 = 0;
|
|
26990
|
+
do {
|
|
26991
|
+
const index = re.lastIndex - 1;
|
|
26992
|
+
if (last2 !== index)
|
|
26993
|
+
out += data.substring(last2, index);
|
|
26994
|
+
const char = data.charCodeAt(index);
|
|
26995
|
+
out += getEscape(char);
|
|
26996
|
+
last2 = index + 1;
|
|
26997
|
+
} while (re.test(data));
|
|
26998
|
+
return out + data.substring(last2);
|
|
26999
|
+
}
|
|
27000
|
+
var attributeEscapeRegex = /["&\u{A0}]/gu;
|
|
27001
|
+
function escapeAttribute(data) {
|
|
27002
|
+
return escapeWithRegex(attributeEscapeRegex, data);
|
|
27003
|
+
}
|
|
27004
|
+
var textEscapeRegex = /[&<>\u{A0}]/gu;
|
|
27005
|
+
function escapeText(data) {
|
|
27006
|
+
return escapeWithRegex(textEscapeRegex, data);
|
|
27007
|
+
}
|
|
27008
|
+
|
|
27009
|
+
// node_modules/entities/dist/index.js
|
|
27010
|
+
var EntityLevel;
|
|
27011
|
+
(function(EntityLevel2) {
|
|
27012
|
+
EntityLevel2[EntityLevel2["XML"] = 0] = "XML";
|
|
27013
|
+
EntityLevel2[EntityLevel2["HTML"] = 1] = "HTML";
|
|
27014
|
+
})(EntityLevel || (EntityLevel = {}));
|
|
27015
|
+
var EncodingMode;
|
|
27016
|
+
(function(EncodingMode2) {
|
|
27017
|
+
EncodingMode2[EncodingMode2["UTF8"] = 0] = "UTF8";
|
|
27018
|
+
EncodingMode2[EncodingMode2["ASCII"] = 1] = "ASCII";
|
|
27019
|
+
EncodingMode2[EncodingMode2["Extensive"] = 2] = "Extensive";
|
|
27020
|
+
EncodingMode2[EncodingMode2["Attribute"] = 3] = "Attribute";
|
|
27021
|
+
EncodingMode2[EncodingMode2["Text"] = 4] = "Text";
|
|
27022
|
+
})(EncodingMode || (EncodingMode = {}));
|
|
27023
|
+
|
|
27024
|
+
// node_modules/dom-serializer/dist/foreign-names.js
|
|
27025
|
+
var elementNames = new Map("altGlyph altGlyphDef altGlyphItem animateColor animateMotion animateTransform clipPath feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence foreignObject glyphRef linearGradient radialGradient textPath".split(" ").map((name) => [name.toLowerCase(), name]));
|
|
27026
|
+
var attributeNames = new Map("definitionURL attributeName attributeType baseFrequency baseProfile calcMode clipPathUnits diffuseConstant edgeMode filterUnits glyphRef gradientTransform gradientUnits kernelMatrix kernelUnitLength keyPoints keySplines keyTimes lengthAdjust limitingConeAngle markerHeight markerUnits markerWidth maskContentUnits maskUnits numOctaves pathLength patternContentUnits patternTransform patternUnits pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits refX refY repeatCount repeatDur requiredExtensions requiredFeatures specularConstant specularExponent spreadMethod startOffset stdDeviation stitchTiles surfaceScale systemLanguage tableValues targetX targetY textLength viewBox viewTarget xChannelSelector yChannelSelector zoomAndPan".split(" ").map((name) => [name.toLowerCase(), name]));
|
|
27027
|
+
|
|
27028
|
+
// node_modules/dom-serializer/dist/index.js
|
|
27029
|
+
var unencodedElements = new Set("style script xmp iframe noembed noframes plaintext noscript".split(" "));
|
|
27030
|
+
var voidElements2 = new Set("area base basefont br col command embed frame hr img input isindex keygen link meta param source track wbr".split(" "));
|
|
27031
|
+
var foreignElements = /* @__PURE__ */ new Set(["svg", "math"]);
|
|
27032
|
+
var foreignModeIntegrationPoints = new Set("mi mo mn ms mtext annotation-xml foreignObject desc title".split(" "));
|
|
27033
|
+
function render2(node3, options = {}) {
|
|
27034
|
+
const nodes = "length" in node3 ? node3 : [node3];
|
|
27035
|
+
const xmlMode = options.xmlMode ?? false;
|
|
27036
|
+
let output = "";
|
|
27037
|
+
for (let index = 0; index < nodes.length; index++) {
|
|
27038
|
+
output += renderNode(nodes[index], options, xmlMode);
|
|
27039
|
+
}
|
|
27040
|
+
return output;
|
|
27041
|
+
}
|
|
27042
|
+
var dist_default = render2;
|
|
27043
|
+
function renderChildren(children, options, xmlMode) {
|
|
27044
|
+
let output = "";
|
|
27045
|
+
for (let index = 0; index < children.length; index++) {
|
|
27046
|
+
output += renderNode(children[index], options, xmlMode);
|
|
27047
|
+
}
|
|
27048
|
+
return output;
|
|
27049
|
+
}
|
|
27050
|
+
function renderNode(node3, options, xmlMode) {
|
|
27051
|
+
switch (node3.type) {
|
|
27052
|
+
case Root: {
|
|
27053
|
+
return renderChildren(node3.children, options, xmlMode);
|
|
27054
|
+
}
|
|
27055
|
+
case Directive: {
|
|
27056
|
+
return `<${node3.data}>`;
|
|
27057
|
+
}
|
|
27058
|
+
case Comment: {
|
|
27059
|
+
return `<!--${node3.data}-->`;
|
|
27060
|
+
}
|
|
27061
|
+
case CDATA: {
|
|
27062
|
+
return `<![CDATA[${node3.children[0].data}]]>`;
|
|
27063
|
+
}
|
|
27064
|
+
case Script:
|
|
27065
|
+
case Style:
|
|
27066
|
+
case Tag: {
|
|
27067
|
+
return renderTag(node3, options, xmlMode);
|
|
27068
|
+
}
|
|
27069
|
+
case Text: {
|
|
27070
|
+
const element2 = node3;
|
|
27071
|
+
const data = element2.data || "";
|
|
27072
|
+
if ((options.encodeEntities ?? options.decodeEntities) !== false && !(!xmlMode && element2.parent && unencodedElements.has(element2.parent.name))) {
|
|
27073
|
+
return xmlMode || options.encodeEntities !== "utf8" ? encodeXML(data) : escapeText(data);
|
|
27074
|
+
}
|
|
27075
|
+
return data;
|
|
27076
|
+
}
|
|
27077
|
+
}
|
|
27078
|
+
}
|
|
27079
|
+
function renderTag(element2, options, xmlMode) {
|
|
27080
|
+
if (xmlMode === "foreign") {
|
|
27081
|
+
element2.name = elementNames.get(element2.name) ?? element2.name;
|
|
27082
|
+
if (element2.parent && foreignModeIntegrationPoints.has(element2.parent.name)) {
|
|
27083
|
+
xmlMode = false;
|
|
27084
|
+
}
|
|
27085
|
+
}
|
|
27086
|
+
if (!xmlMode && foreignElements.has(element2.name)) {
|
|
27087
|
+
xmlMode = "foreign";
|
|
27088
|
+
}
|
|
27089
|
+
const { name, children } = element2;
|
|
27090
|
+
const isVoid = !xmlMode && voidElements2.has(name);
|
|
27091
|
+
let tag2 = `<${name}${formatAttributes(element2.attribs, options, xmlMode)}`;
|
|
27092
|
+
if (children.length === 0 && (xmlMode ? options.selfClosingTags !== false : options.selfClosingTags && isVoid)) {
|
|
27093
|
+
tag2 += xmlMode ? "/>" : " />";
|
|
27094
|
+
} else {
|
|
27095
|
+
tag2 += ">";
|
|
27096
|
+
if (children.length > 0) {
|
|
27097
|
+
tag2 += renderChildren(children, options, xmlMode);
|
|
27098
|
+
}
|
|
27099
|
+
if (!isVoid) {
|
|
27100
|
+
tag2 += `</${name}>`;
|
|
27101
|
+
}
|
|
27102
|
+
}
|
|
27103
|
+
return tag2;
|
|
27104
|
+
}
|
|
27105
|
+
function replaceQuotes(value) {
|
|
27106
|
+
return value.replaceAll('"', """);
|
|
27107
|
+
}
|
|
27108
|
+
function formatAttributes(attributes, options, xmlMode) {
|
|
27109
|
+
if (!attributes)
|
|
27110
|
+
return "";
|
|
27111
|
+
const encode13 = (options.encodeEntities ?? options.decodeEntities) === false ? replaceQuotes : xmlMode || options.encodeEntities !== "utf8" ? encodeXML : escapeAttribute;
|
|
27112
|
+
const isForeign = xmlMode === "foreign";
|
|
27113
|
+
const showEmpty = !!(options.emptyAttrs ?? xmlMode);
|
|
27114
|
+
let result = "";
|
|
27115
|
+
for (const key in attributes) {
|
|
27116
|
+
if (!Object.hasOwn(attributes, key))
|
|
27117
|
+
continue;
|
|
27118
|
+
const value = attributes[key];
|
|
27119
|
+
const k = isForeign ? attributeNames.get(key) ?? key : key;
|
|
27120
|
+
result += !showEmpty && (value == null || value === "") ? ` ${k}` : ` ${k}="${encode13(value == null ? "" : String(value))}"`;
|
|
27121
|
+
}
|
|
27122
|
+
return result;
|
|
27123
|
+
}
|
|
27124
|
+
|
|
27125
|
+
// node_modules/domutils/dist/stringify.js
|
|
27126
|
+
function getOuterHTML(node3, options) {
|
|
27127
|
+
return dist_default(node3, options);
|
|
27128
|
+
}
|
|
27129
|
+
function getInnerHTML(node3, options) {
|
|
27130
|
+
return hasChildren(node3) ? node3.children.map((node4) => getOuterHTML(node4, options)).join("") : "";
|
|
27131
|
+
}
|
|
27132
|
+
function getText(node3) {
|
|
27133
|
+
if (Array.isArray(node3))
|
|
27134
|
+
return node3.map(getText).join("");
|
|
27135
|
+
if (isTag2(node3))
|
|
27136
|
+
return node3.name === "br" ? "\n" : getText(node3.children);
|
|
27137
|
+
if (isCDATA(node3))
|
|
27138
|
+
return getText(node3.children);
|
|
27139
|
+
if (isText(node3))
|
|
27140
|
+
return node3.data;
|
|
27141
|
+
return "";
|
|
27142
|
+
}
|
|
27143
|
+
function textContent(node3) {
|
|
27144
|
+
if (Array.isArray(node3))
|
|
27145
|
+
return node3.map(textContent).join("");
|
|
27146
|
+
if (hasChildren(node3) && !isComment(node3)) {
|
|
27147
|
+
return textContent(node3.children);
|
|
27148
|
+
}
|
|
27149
|
+
if (isText(node3))
|
|
27150
|
+
return node3.data;
|
|
27151
|
+
return "";
|
|
27152
|
+
}
|
|
27153
|
+
function innerText(node3) {
|
|
27154
|
+
if (Array.isArray(node3))
|
|
27155
|
+
return node3.map(innerText).join("");
|
|
27156
|
+
if (hasChildren(node3) && (node3.type === ElementType.Tag || isCDATA(node3))) {
|
|
27157
|
+
return innerText(node3.children);
|
|
27158
|
+
}
|
|
27159
|
+
if (isText(node3))
|
|
27160
|
+
return node3.data;
|
|
27161
|
+
return "";
|
|
27162
|
+
}
|
|
27163
|
+
|
|
27164
|
+
// node_modules/domutils/dist/feeds.js
|
|
27165
|
+
function getFeed(document) {
|
|
27166
|
+
const feedRoot = getOneElement(isValidFeed, document);
|
|
27167
|
+
return feedRoot ? feedRoot.name === "feed" ? getAtomFeed(feedRoot) : getRssFeed(feedRoot) : null;
|
|
27168
|
+
}
|
|
27169
|
+
function getAtomFeed(feedRoot) {
|
|
27170
|
+
const childs = feedRoot.children;
|
|
27171
|
+
const feed = {
|
|
27172
|
+
type: "atom",
|
|
27173
|
+
items: getElementsByTagName("entry", childs).map((item) => {
|
|
27174
|
+
const { children } = item;
|
|
27175
|
+
const entry = { media: getMediaElements(children) };
|
|
27176
|
+
addConditionally(entry, "id", "id", children);
|
|
27177
|
+
addConditionally(entry, "title", "title", children);
|
|
27178
|
+
const href2 = getOneElement("link", children)?.attribs["href"];
|
|
27179
|
+
if (href2) {
|
|
27180
|
+
entry.link = href2;
|
|
27181
|
+
}
|
|
27182
|
+
const description = fetch2("summary", children) || fetch2("content", children);
|
|
27183
|
+
if (description) {
|
|
27184
|
+
entry.description = description;
|
|
27185
|
+
}
|
|
27186
|
+
const pubDate = fetch2("updated", children);
|
|
27187
|
+
if (pubDate) {
|
|
27188
|
+
entry.pubDate = new Date(pubDate);
|
|
27189
|
+
}
|
|
27190
|
+
return entry;
|
|
27191
|
+
})
|
|
27192
|
+
};
|
|
27193
|
+
addConditionally(feed, "id", "id", childs);
|
|
27194
|
+
addConditionally(feed, "title", "title", childs);
|
|
27195
|
+
const href = getOneElement("link", childs)?.attribs["href"];
|
|
27196
|
+
if (href) {
|
|
27197
|
+
feed.link = href;
|
|
27198
|
+
}
|
|
27199
|
+
addConditionally(feed, "description", "subtitle", childs);
|
|
27200
|
+
const updated = fetch2("updated", childs);
|
|
27201
|
+
if (updated) {
|
|
27202
|
+
feed.updated = new Date(updated);
|
|
27203
|
+
}
|
|
27204
|
+
addConditionally(feed, "author", "email", childs, true);
|
|
27205
|
+
return feed;
|
|
27206
|
+
}
|
|
27207
|
+
function getRssFeed(feedRoot) {
|
|
27208
|
+
const childs = getOneElement("channel", feedRoot.children)?.children ?? [];
|
|
27209
|
+
const feed = {
|
|
27210
|
+
type: feedRoot.name.substr(0, 3),
|
|
27211
|
+
id: "",
|
|
27212
|
+
items: getElementsByTagName("item", feedRoot.children).map((item) => {
|
|
27213
|
+
const { children } = item;
|
|
27214
|
+
const entry = { media: getMediaElements(children) };
|
|
27215
|
+
addConditionally(entry, "id", "guid", children);
|
|
27216
|
+
addConditionally(entry, "title", "title", children);
|
|
27217
|
+
addConditionally(entry, "link", "link", children);
|
|
27218
|
+
addConditionally(entry, "description", "description", children);
|
|
27219
|
+
const pubDate = fetch2("pubDate", children) || fetch2("dc:date", children);
|
|
27220
|
+
if (pubDate)
|
|
27221
|
+
entry.pubDate = new Date(pubDate);
|
|
27222
|
+
return entry;
|
|
27223
|
+
})
|
|
27224
|
+
};
|
|
27225
|
+
addConditionally(feed, "title", "title", childs);
|
|
27226
|
+
addConditionally(feed, "link", "link", childs);
|
|
27227
|
+
addConditionally(feed, "description", "description", childs);
|
|
27228
|
+
const updated = fetch2("lastBuildDate", childs);
|
|
27229
|
+
if (updated) {
|
|
27230
|
+
feed.updated = new Date(updated);
|
|
27231
|
+
}
|
|
27232
|
+
addConditionally(feed, "author", "managingEditor", childs, true);
|
|
27233
|
+
return feed;
|
|
27234
|
+
}
|
|
27235
|
+
var MEDIA_KEYS_STRING = ["url", "type", "lang"];
|
|
27236
|
+
var MEDIA_KEYS_INT = [
|
|
27237
|
+
"fileSize",
|
|
27238
|
+
"bitrate",
|
|
27239
|
+
"framerate",
|
|
27240
|
+
"samplingrate",
|
|
27241
|
+
"channels",
|
|
27242
|
+
"duration",
|
|
27243
|
+
"height",
|
|
27244
|
+
"width"
|
|
27245
|
+
];
|
|
27246
|
+
function getMediaElements(where) {
|
|
27247
|
+
return getElementsByTagName("media:content", where).map((element2) => {
|
|
27248
|
+
const { attribs } = element2;
|
|
27249
|
+
const media = {
|
|
27250
|
+
medium: attribs["medium"],
|
|
27251
|
+
isDefault: !!attribs["isDefault"]
|
|
27252
|
+
};
|
|
27253
|
+
for (const attrib of MEDIA_KEYS_STRING) {
|
|
27254
|
+
if (attribs[attrib]) {
|
|
27255
|
+
media[attrib] = attribs[attrib];
|
|
27256
|
+
}
|
|
27257
|
+
}
|
|
27258
|
+
for (const attrib of MEDIA_KEYS_INT) {
|
|
27259
|
+
if (attribs[attrib]) {
|
|
27260
|
+
media[attrib] = Number.parseInt(attribs[attrib], 10);
|
|
27261
|
+
}
|
|
27262
|
+
}
|
|
27263
|
+
if (attribs["expression"]) {
|
|
27264
|
+
media.expression = attribs["expression"];
|
|
27265
|
+
}
|
|
27266
|
+
return media;
|
|
27267
|
+
});
|
|
27268
|
+
}
|
|
27269
|
+
function getOneElement(tagName, node3) {
|
|
27270
|
+
return getElementsByTagName(tagName, node3, true, 1)[0];
|
|
27271
|
+
}
|
|
27272
|
+
function fetch2(tagName, where, recurse = false) {
|
|
27273
|
+
return textContent(getElementsByTagName(tagName, where, recurse, 1)).trim();
|
|
27274
|
+
}
|
|
27275
|
+
function addConditionally(object4, property, tagName, where, recurse = false) {
|
|
27276
|
+
const value = fetch2(tagName, where, recurse);
|
|
27277
|
+
if (value)
|
|
27278
|
+
object4[property] = value;
|
|
27279
|
+
}
|
|
27280
|
+
function isValidFeed(value) {
|
|
27281
|
+
return value === "rss" || value === "feed" || value === "rdf:RDF";
|
|
27282
|
+
}
|
|
27283
|
+
|
|
27284
|
+
// node_modules/domutils/dist/helpers.js
|
|
27285
|
+
function removeSubsets(nodes) {
|
|
27286
|
+
let index = nodes.length;
|
|
27287
|
+
while (--index >= 0) {
|
|
27288
|
+
const node3 = nodes[index];
|
|
27289
|
+
if (index > 0 && nodes.lastIndexOf(node3, index - 1) >= 0) {
|
|
27290
|
+
nodes.splice(index, 1);
|
|
27291
|
+
continue;
|
|
27292
|
+
}
|
|
27293
|
+
for (let ancestor = node3.parent; ancestor; ancestor = ancestor.parent) {
|
|
27294
|
+
if (nodes.includes(ancestor)) {
|
|
27295
|
+
nodes.splice(index, 1);
|
|
27296
|
+
break;
|
|
27297
|
+
}
|
|
27298
|
+
}
|
|
27299
|
+
}
|
|
27300
|
+
return nodes;
|
|
27301
|
+
}
|
|
27302
|
+
var DocumentPosition;
|
|
27303
|
+
(function(DocumentPosition2) {
|
|
27304
|
+
DocumentPosition2[DocumentPosition2["DISCONNECTED"] = 1] = "DISCONNECTED";
|
|
27305
|
+
DocumentPosition2[DocumentPosition2["PRECEDING"] = 2] = "PRECEDING";
|
|
27306
|
+
DocumentPosition2[DocumentPosition2["FOLLOWING"] = 4] = "FOLLOWING";
|
|
27307
|
+
DocumentPosition2[DocumentPosition2["CONTAINS"] = 8] = "CONTAINS";
|
|
27308
|
+
DocumentPosition2[DocumentPosition2["CONTAINED_BY"] = 16] = "CONTAINED_BY";
|
|
27309
|
+
})(DocumentPosition || (DocumentPosition = {}));
|
|
27310
|
+
function compareDocumentPosition(nodeA, nodeB) {
|
|
27311
|
+
const aParents = [];
|
|
27312
|
+
const bParents = [];
|
|
27313
|
+
if (nodeA === nodeB) {
|
|
27314
|
+
return 0;
|
|
27315
|
+
}
|
|
27316
|
+
let current = hasChildren(nodeA) ? nodeA : nodeA.parent;
|
|
27317
|
+
while (current) {
|
|
27318
|
+
aParents.unshift(current);
|
|
27319
|
+
current = current.parent;
|
|
27320
|
+
}
|
|
27321
|
+
current = hasChildren(nodeB) ? nodeB : nodeB.parent;
|
|
27322
|
+
while (current) {
|
|
27323
|
+
bParents.unshift(current);
|
|
27324
|
+
current = current.parent;
|
|
27325
|
+
}
|
|
27326
|
+
const maxIndex = Math.min(aParents.length, bParents.length);
|
|
27327
|
+
let index = 0;
|
|
27328
|
+
while (index < maxIndex && aParents[index] === bParents[index]) {
|
|
27329
|
+
index++;
|
|
27330
|
+
}
|
|
27331
|
+
if (index === 0) {
|
|
27332
|
+
return DocumentPosition.DISCONNECTED;
|
|
27333
|
+
}
|
|
27334
|
+
const sharedParent = aParents[index - 1];
|
|
27335
|
+
const siblings = sharedParent.children;
|
|
27336
|
+
const aSibling = aParents[index];
|
|
27337
|
+
const bSibling = bParents[index];
|
|
27338
|
+
if (siblings.indexOf(aSibling) > siblings.indexOf(bSibling)) {
|
|
27339
|
+
if (sharedParent === nodeB) {
|
|
27340
|
+
return DocumentPosition.FOLLOWING | DocumentPosition.CONTAINED_BY;
|
|
27341
|
+
}
|
|
27342
|
+
return DocumentPosition.FOLLOWING;
|
|
27343
|
+
}
|
|
27344
|
+
if (sharedParent === nodeA) {
|
|
27345
|
+
return DocumentPosition.PRECEDING | DocumentPosition.CONTAINS;
|
|
27346
|
+
}
|
|
27347
|
+
return DocumentPosition.PRECEDING;
|
|
27348
|
+
}
|
|
27349
|
+
function uniqueSort(nodes) {
|
|
27350
|
+
nodes = nodes.filter((node3, index, array4) => !array4.includes(node3, index + 1));
|
|
27351
|
+
nodes.sort((a, b) => {
|
|
27352
|
+
const relative4 = compareDocumentPosition(a, b);
|
|
27353
|
+
if (relative4 & DocumentPosition.PRECEDING) {
|
|
27354
|
+
return -1;
|
|
27355
|
+
}
|
|
27356
|
+
if (relative4 & DocumentPosition.FOLLOWING) {
|
|
27357
|
+
return 1;
|
|
27358
|
+
}
|
|
27359
|
+
return 0;
|
|
27360
|
+
});
|
|
27361
|
+
return nodes;
|
|
27362
|
+
}
|
|
27363
|
+
|
|
27364
|
+
// node_modules/domutils/dist/manipulation.js
|
|
27365
|
+
function removeElement(element2) {
|
|
27366
|
+
if (element2.prev)
|
|
27367
|
+
element2.prev.next = element2.next;
|
|
27368
|
+
if (element2.next)
|
|
27369
|
+
element2.next.prev = element2.prev;
|
|
27370
|
+
if (element2.parent) {
|
|
27371
|
+
const childs = element2.parent.children;
|
|
27372
|
+
const childsIndex = childs.lastIndexOf(element2);
|
|
27373
|
+
if (childsIndex !== -1) {
|
|
27374
|
+
childs.splice(childsIndex, 1);
|
|
27375
|
+
}
|
|
27376
|
+
}
|
|
27377
|
+
element2.next = null;
|
|
27378
|
+
element2.prev = null;
|
|
27379
|
+
element2.parent = null;
|
|
27380
|
+
}
|
|
27381
|
+
function replaceElement(element2, replacement) {
|
|
27382
|
+
replacement.prev = element2.prev;
|
|
27383
|
+
if (replacement.prev) {
|
|
27384
|
+
replacement.prev.next = replacement;
|
|
27385
|
+
}
|
|
27386
|
+
replacement.next = element2.next;
|
|
27387
|
+
if (replacement.next) {
|
|
27388
|
+
replacement.next.prev = replacement;
|
|
27389
|
+
}
|
|
27390
|
+
replacement.parent = element2.parent;
|
|
27391
|
+
if (replacement.parent) {
|
|
27392
|
+
const { children } = replacement.parent;
|
|
27393
|
+
const elementIndex = children.lastIndexOf(element2);
|
|
27394
|
+
if (elementIndex === -1) {
|
|
27395
|
+
return;
|
|
27396
|
+
}
|
|
27397
|
+
children[elementIndex] = replacement;
|
|
27398
|
+
element2.parent = null;
|
|
27399
|
+
}
|
|
27400
|
+
}
|
|
27401
|
+
function appendChild(parent, child) {
|
|
27402
|
+
removeElement(child);
|
|
27403
|
+
child.next = null;
|
|
27404
|
+
child.parent = parent;
|
|
27405
|
+
if (parent.children.push(child) > 1) {
|
|
27406
|
+
const sibling = parent.children[parent.children.length - 2];
|
|
27407
|
+
sibling.next = child;
|
|
27408
|
+
child.prev = sibling;
|
|
27409
|
+
} else {
|
|
27410
|
+
child.prev = null;
|
|
27411
|
+
}
|
|
27412
|
+
}
|
|
27413
|
+
function append(element2, next) {
|
|
27414
|
+
removeElement(next);
|
|
27415
|
+
const { parent } = element2;
|
|
27416
|
+
const currentNext = element2.next;
|
|
27417
|
+
next.next = currentNext;
|
|
27418
|
+
next.prev = element2;
|
|
27419
|
+
element2.next = next;
|
|
27420
|
+
next.parent = parent;
|
|
27421
|
+
if (currentNext) {
|
|
27422
|
+
currentNext.prev = next;
|
|
27423
|
+
if (parent) {
|
|
27424
|
+
const childs = parent.children;
|
|
27425
|
+
childs.splice(childs.lastIndexOf(currentNext), 0, next);
|
|
27426
|
+
}
|
|
27427
|
+
} else if (parent) {
|
|
27428
|
+
parent.children.push(next);
|
|
27429
|
+
}
|
|
27430
|
+
}
|
|
27431
|
+
function prependChild(parent, child) {
|
|
27432
|
+
removeElement(child);
|
|
27433
|
+
child.parent = parent;
|
|
27434
|
+
child.prev = null;
|
|
27435
|
+
if (parent.children.unshift(child) === 1) {
|
|
27436
|
+
child.next = null;
|
|
27437
|
+
} else {
|
|
27438
|
+
const sibling = parent.children[1];
|
|
27439
|
+
sibling.prev = child;
|
|
27440
|
+
child.next = sibling;
|
|
27441
|
+
}
|
|
27442
|
+
}
|
|
27443
|
+
function prepend(element2, previous) {
|
|
27444
|
+
removeElement(previous);
|
|
27445
|
+
const { parent } = element2;
|
|
27446
|
+
if (parent) {
|
|
27447
|
+
const childs = parent.children;
|
|
27448
|
+
childs.splice(childs.indexOf(element2), 0, previous);
|
|
27449
|
+
}
|
|
27450
|
+
if (element2.prev) {
|
|
27451
|
+
element2.prev.next = previous;
|
|
27452
|
+
}
|
|
27453
|
+
previous.parent = parent;
|
|
27454
|
+
previous.prev = element2.prev;
|
|
27455
|
+
previous.next = element2;
|
|
27456
|
+
element2.prev = previous;
|
|
27457
|
+
}
|
|
27458
|
+
|
|
27459
|
+
// node_modules/domutils/dist/traversal.js
|
|
27460
|
+
function getChildren(element2) {
|
|
27461
|
+
return hasChildren(element2) ? element2.children : [];
|
|
27462
|
+
}
|
|
27463
|
+
function getParent(element2) {
|
|
27464
|
+
return element2.parent || null;
|
|
27465
|
+
}
|
|
27466
|
+
function getSiblings(element2) {
|
|
27467
|
+
const parent = getParent(element2);
|
|
27468
|
+
if (parent != null)
|
|
27469
|
+
return getChildren(parent);
|
|
27470
|
+
const siblings = [element2];
|
|
27471
|
+
let { prev, next } = element2;
|
|
27472
|
+
while (prev != null) {
|
|
27473
|
+
siblings.unshift(prev);
|
|
27474
|
+
({ prev } = prev);
|
|
27475
|
+
}
|
|
27476
|
+
while (next != null) {
|
|
27477
|
+
siblings.push(next);
|
|
27478
|
+
({ next } = next);
|
|
27479
|
+
}
|
|
27480
|
+
return siblings;
|
|
27481
|
+
}
|
|
27482
|
+
function getAttributeValue(element2, name) {
|
|
27483
|
+
const { attribs } = element2;
|
|
27484
|
+
return attribs?.[name];
|
|
27485
|
+
}
|
|
27486
|
+
function hasAttrib(element2, name) {
|
|
27487
|
+
const { attribs } = element2;
|
|
27488
|
+
return attribs != null && Object.hasOwn(attribs, name) && attribs[name] != null;
|
|
27489
|
+
}
|
|
27490
|
+
function getName(element2) {
|
|
27491
|
+
return element2.name;
|
|
27492
|
+
}
|
|
27493
|
+
function nextElementSibling(element2) {
|
|
27494
|
+
let { next } = element2;
|
|
27495
|
+
while (next !== null && !isTag2(next))
|
|
27496
|
+
({ next } = next);
|
|
27497
|
+
return next;
|
|
27498
|
+
}
|
|
27499
|
+
function prevElementSibling(element2) {
|
|
27500
|
+
let { prev } = element2;
|
|
27501
|
+
while (prev !== null && !isTag2(prev))
|
|
27502
|
+
({ prev } = prev);
|
|
27503
|
+
return prev;
|
|
27504
|
+
}
|
|
27505
|
+
|
|
27506
|
+
// node_modules/htmlparser2/dist/index.js
|
|
27507
|
+
function parseDocument(data, options) {
|
|
27508
|
+
const handler9 = new DomHandler(void 0, options);
|
|
27509
|
+
new Parser(handler9, options).end(data);
|
|
27510
|
+
return handler9.root;
|
|
27511
|
+
}
|
|
27512
|
+
|
|
27513
|
+
// src/core/index/html-text.ts
|
|
27514
|
+
function isText2(n) {
|
|
27515
|
+
return n.type === "text";
|
|
27516
|
+
}
|
|
27517
|
+
function isTag3(n) {
|
|
27518
|
+
return n.type === "tag" || n.type === "script" || n.type === "style";
|
|
27519
|
+
}
|
|
27520
|
+
var DROP = /* @__PURE__ */ new Set([
|
|
27521
|
+
"script",
|
|
27522
|
+
"style",
|
|
27523
|
+
"noscript",
|
|
27524
|
+
"template",
|
|
27525
|
+
"svg",
|
|
27526
|
+
"math",
|
|
27527
|
+
"iframe",
|
|
27528
|
+
"canvas",
|
|
27529
|
+
"object",
|
|
27530
|
+
"embed",
|
|
27531
|
+
"head",
|
|
27532
|
+
"title",
|
|
27533
|
+
"nav",
|
|
27534
|
+
"footer",
|
|
27535
|
+
"button",
|
|
27536
|
+
"select",
|
|
27537
|
+
"option",
|
|
27538
|
+
"textarea",
|
|
27539
|
+
"input",
|
|
27540
|
+
"dialog",
|
|
27541
|
+
"audio",
|
|
27542
|
+
"video",
|
|
27543
|
+
"picture",
|
|
27544
|
+
"img"
|
|
27545
|
+
]);
|
|
27546
|
+
var DROP_ROLES = /* @__PURE__ */ new Set(["navigation", "banner", "contentinfo", "search", "dialog", "tooltip"]);
|
|
27547
|
+
var LINE = /* @__PURE__ */ new Set(["div", "section", "article", "main", "header", "aside", "figure", "figcaption", "details", "summary", "address", "dl", "dt", "dd", "fieldset", "form", "center", "li", "tr", "body", "html", "caption"]);
|
|
27548
|
+
var PARA = /* @__PURE__ */ new Set(["p", "blockquote", "hr", "table", "ul", "ol", "pre", "h1", "h2", "h3", "h4", "h5", "h6"]);
|
|
27549
|
+
var PRE_LINE = /* @__PURE__ */ new Set(["div", "p", "li", "tr"]);
|
|
27550
|
+
var LANG_PREFIXES = ["language-", "lang-", "highlight-source-", "highlight-text-"];
|
|
27551
|
+
var BLOCK_INSIDE_LINK = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6", "p", "div", "pre", "ul", "ol", "table", "blockquote", "section", "article"]);
|
|
27552
|
+
function isSpace2(c) {
|
|
27553
|
+
return c === " " || c === " " || c === "\n" || c === "\r" || c === "\f" || c === "\xA0";
|
|
27554
|
+
}
|
|
27555
|
+
function isInvisible(c) {
|
|
27556
|
+
return c === "\u200B" || c === "\uFEFF" || c === "\xAD";
|
|
27557
|
+
}
|
|
27558
|
+
function collapse(s) {
|
|
27559
|
+
let out = "";
|
|
27560
|
+
let gap = false;
|
|
27561
|
+
for (const c of s) {
|
|
27562
|
+
if (isInvisible(c)) continue;
|
|
27563
|
+
if (isSpace2(c)) {
|
|
27564
|
+
gap = true;
|
|
27565
|
+
continue;
|
|
27566
|
+
}
|
|
27567
|
+
if (gap) {
|
|
27568
|
+
out += " ";
|
|
27569
|
+
gap = false;
|
|
27570
|
+
}
|
|
27571
|
+
out += c;
|
|
27572
|
+
}
|
|
27573
|
+
return gap ? out + " " : out;
|
|
27574
|
+
}
|
|
27575
|
+
function hidden(el) {
|
|
27576
|
+
const a = el.attribs;
|
|
27577
|
+
if (a.hidden !== void 0 || a["aria-hidden"] === "true") return true;
|
|
27578
|
+
if (a.role !== void 0 && DROP_ROLES.has(a.role.toLowerCase())) return true;
|
|
27579
|
+
if (a.style !== void 0) {
|
|
27580
|
+
let s = "";
|
|
27581
|
+
for (const c of a.style.toLowerCase()) if (!isSpace2(c)) s += c;
|
|
27582
|
+
if (s.includes("display:none")) return true;
|
|
27583
|
+
}
|
|
27584
|
+
return false;
|
|
27585
|
+
}
|
|
27586
|
+
function dropped(el) {
|
|
27587
|
+
return DROP.has(el.name) || hidden(el);
|
|
27588
|
+
}
|
|
27589
|
+
function plainText(node3) {
|
|
27590
|
+
let out = "";
|
|
27591
|
+
const visit2 = (n) => {
|
|
27592
|
+
if (isText2(n)) {
|
|
27593
|
+
out += n.data;
|
|
27594
|
+
return;
|
|
27595
|
+
}
|
|
27596
|
+
if (!isTag3(n) || dropped(n)) return;
|
|
27597
|
+
if (n.name === "br") {
|
|
27598
|
+
out += " ";
|
|
27599
|
+
return;
|
|
27600
|
+
}
|
|
27601
|
+
const block = LINE.has(n.name) || PARA.has(n.name);
|
|
27602
|
+
if (block) out += " ";
|
|
27603
|
+
for (const c of n.children) visit2(c);
|
|
27604
|
+
if (block) out += " ";
|
|
27605
|
+
};
|
|
27606
|
+
visit2(node3);
|
|
27607
|
+
return collapse(out).trim();
|
|
27608
|
+
}
|
|
27609
|
+
function preText(node3) {
|
|
27610
|
+
const buf = [];
|
|
27611
|
+
let last2 = "\n";
|
|
27612
|
+
const put = (s) => {
|
|
27613
|
+
if (s === "") return;
|
|
27614
|
+
buf.push(s);
|
|
27615
|
+
last2 = s[s.length - 1];
|
|
27616
|
+
};
|
|
27617
|
+
const visit2 = (n) => {
|
|
27618
|
+
if (isText2(n)) {
|
|
27619
|
+
let s = "";
|
|
27620
|
+
for (const c of n.data) {
|
|
27621
|
+
if (isInvisible(c)) continue;
|
|
27622
|
+
s += c === "\xA0" ? " " : c;
|
|
27623
|
+
}
|
|
27624
|
+
put(s);
|
|
27625
|
+
return;
|
|
27626
|
+
}
|
|
27627
|
+
if (!isTag3(n) || dropped(n)) return;
|
|
27628
|
+
if (n.name === "br") {
|
|
27629
|
+
put("\n");
|
|
27630
|
+
return;
|
|
27631
|
+
}
|
|
27632
|
+
for (const c of n.children) visit2(c);
|
|
27633
|
+
if (PRE_LINE.has(n.name) && last2 !== "\n") put("\n");
|
|
27634
|
+
};
|
|
27635
|
+
for (const c of node3.children) visit2(c);
|
|
27636
|
+
let code = "";
|
|
27637
|
+
for (const s of buf) code += s;
|
|
27638
|
+
const lines = code.split("\r\n").join("\n").split("\n");
|
|
27639
|
+
while (lines.length > 0 && lines[0].trim() === "") lines.shift();
|
|
27640
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === "") lines.pop();
|
|
27641
|
+
return lines.join("\n");
|
|
27642
|
+
}
|
|
27643
|
+
function langFrom(classes) {
|
|
27644
|
+
if (classes === void 0) return "";
|
|
27645
|
+
for (const token of classes.split(" ")) {
|
|
27646
|
+
for (const p of LANG_PREFIXES) {
|
|
27647
|
+
if (token.startsWith(p) && token.length > p.length) return token.slice(p.length);
|
|
27648
|
+
}
|
|
27649
|
+
}
|
|
27650
|
+
return "";
|
|
27651
|
+
}
|
|
27652
|
+
function langOf(pre) {
|
|
27653
|
+
const code = dist_exports2.findOne((e) => e.name === "code", pre.children, true);
|
|
27654
|
+
const chain = [pre];
|
|
27655
|
+
if (code !== null) chain.push(code);
|
|
27656
|
+
let up = pre.parent;
|
|
27657
|
+
for (let i = 0; i < 2 && up !== null && isTag3(up); i += 1) {
|
|
27658
|
+
chain.push(up);
|
|
27659
|
+
up = up.parent;
|
|
27660
|
+
}
|
|
27661
|
+
for (const el of chain) {
|
|
27662
|
+
const l = langFrom(el.attribs.class) || el.attribs["data-language"] || el.attribs["data-lang"] || "";
|
|
27663
|
+
if (l !== "") return safeLang(l);
|
|
27664
|
+
}
|
|
27665
|
+
return "";
|
|
27666
|
+
}
|
|
27667
|
+
function safeLang(l) {
|
|
27668
|
+
let out = "";
|
|
27669
|
+
for (const c of l.toLowerCase()) {
|
|
27670
|
+
const ok = c >= "a" && c <= "z" || c >= "0" && c <= "9" || c === "+" || c === "-" || c === "#" || c === "_" || c === ".";
|
|
27671
|
+
if (!ok) return out;
|
|
27672
|
+
out += c;
|
|
27673
|
+
}
|
|
27674
|
+
return out;
|
|
27675
|
+
}
|
|
27676
|
+
var Writer = class {
|
|
27677
|
+
parts = [];
|
|
27678
|
+
pending = 0;
|
|
27679
|
+
fresh = true;
|
|
27680
|
+
endsSpace = false;
|
|
27681
|
+
stack = [];
|
|
27682
|
+
depth() {
|
|
27683
|
+
return this.stack.length;
|
|
27684
|
+
}
|
|
27685
|
+
push(first, rest) {
|
|
27686
|
+
this.stack.push({ first, rest, used: false });
|
|
27687
|
+
}
|
|
27688
|
+
pop() {
|
|
27689
|
+
this.stack.pop();
|
|
27690
|
+
}
|
|
27691
|
+
line() {
|
|
27692
|
+
if (this.pending < 1) this.pending = 1;
|
|
27693
|
+
}
|
|
27694
|
+
block() {
|
|
27695
|
+
this.pending = 2;
|
|
27696
|
+
}
|
|
27697
|
+
prefix() {
|
|
27698
|
+
let p = "";
|
|
27699
|
+
for (const l of this.stack) {
|
|
27700
|
+
p += l.used ? l.rest : l.first;
|
|
27701
|
+
l.used = true;
|
|
27702
|
+
}
|
|
27703
|
+
return p;
|
|
27704
|
+
}
|
|
27705
|
+
flush() {
|
|
27706
|
+
if (this.parts.length > 0 && this.pending > 0) {
|
|
27707
|
+
const i = this.parts.length - 1;
|
|
27708
|
+
let end = this.parts[i].length;
|
|
27709
|
+
while (end > 0 && this.parts[i][end - 1] === " ") end -= 1;
|
|
27710
|
+
this.parts[i] = this.parts[i].slice(0, end);
|
|
27711
|
+
this.parts.push("\n".repeat(this.pending));
|
|
27712
|
+
this.fresh = true;
|
|
27713
|
+
this.endsSpace = false;
|
|
27714
|
+
}
|
|
27715
|
+
this.pending = 0;
|
|
27716
|
+
if (this.fresh) {
|
|
27717
|
+
this.parts.push(this.prefix());
|
|
27718
|
+
this.fresh = false;
|
|
27719
|
+
}
|
|
27720
|
+
}
|
|
27721
|
+
text(raw) {
|
|
27722
|
+
let s = raw;
|
|
27723
|
+
if ((this.fresh || this.pending > 0 || this.endsSpace) && s.startsWith(" ")) s = s.slice(1);
|
|
27724
|
+
if (s === "") return;
|
|
27725
|
+
this.flush();
|
|
27726
|
+
this.parts.push(s);
|
|
27727
|
+
this.endsSpace = s.endsWith(" ");
|
|
27728
|
+
}
|
|
27729
|
+
/** One whole line, white space kept (a code line, a table row). */
|
|
27730
|
+
emitLine(s) {
|
|
27731
|
+
this.line();
|
|
27732
|
+
this.flush();
|
|
27733
|
+
this.parts.push(s);
|
|
27734
|
+
this.endsSpace = false;
|
|
27735
|
+
this.line();
|
|
27736
|
+
}
|
|
27737
|
+
code(lang, code) {
|
|
27738
|
+
let run = 0;
|
|
27739
|
+
let most = 0;
|
|
27740
|
+
for (const c of code) {
|
|
27741
|
+
run = c === "`" ? run + 1 : 0;
|
|
27742
|
+
if (run > most) most = run;
|
|
27743
|
+
}
|
|
27744
|
+
const fence = "`".repeat(Math.max(3, most + 1));
|
|
27745
|
+
this.block();
|
|
27746
|
+
this.emitLine(fence + lang);
|
|
27747
|
+
for (const l of code.split("\n")) this.emitLine(l);
|
|
27748
|
+
this.emitLine(fence);
|
|
27749
|
+
this.block();
|
|
27750
|
+
}
|
|
27751
|
+
result() {
|
|
27752
|
+
let s = "";
|
|
27753
|
+
for (const p of this.parts) s += p;
|
|
27754
|
+
return s.trimEnd();
|
|
27755
|
+
}
|
|
27756
|
+
};
|
|
27757
|
+
function resolveHref(href, base) {
|
|
27758
|
+
if (href === void 0) return void 0;
|
|
27759
|
+
const h = href.trim();
|
|
27760
|
+
if (h === "" || h.startsWith("#")) return void 0;
|
|
27761
|
+
try {
|
|
27762
|
+
const u = base !== void 0 ? new URL(h, base) : new URL(h);
|
|
27763
|
+
return u.protocol === "http:" || u.protocol === "https:" ? u.href : void 0;
|
|
27764
|
+
} catch {
|
|
27765
|
+
return base === void 0 && !h.includes(":") ? h : void 0;
|
|
27766
|
+
}
|
|
27767
|
+
}
|
|
27768
|
+
function hasBlock(el) {
|
|
27769
|
+
return dist_exports2.findOne((e) => BLOCK_INSIDE_LINK.has(e.name), el.children, true) !== null;
|
|
27770
|
+
}
|
|
27771
|
+
function inlineCode(text) {
|
|
27772
|
+
let run = 0;
|
|
27773
|
+
let most = 0;
|
|
27774
|
+
for (const c of text) {
|
|
27775
|
+
run = c === "`" ? run + 1 : 0;
|
|
27776
|
+
if (run > most) most = run;
|
|
27777
|
+
}
|
|
27778
|
+
const tick = "`".repeat(most === 0 ? 1 : most + 1);
|
|
27779
|
+
const pad = text.startsWith("`") || text.endsWith("`") ? " " : "";
|
|
27780
|
+
return tick + pad + text + pad + tick;
|
|
27781
|
+
}
|
|
27782
|
+
function cell2(el) {
|
|
27783
|
+
const t = plainText(el);
|
|
27784
|
+
let out = "";
|
|
27785
|
+
for (const c of t) out += c === "|" ? "\\|" : c;
|
|
27786
|
+
return out;
|
|
27787
|
+
}
|
|
27788
|
+
function table(st, el) {
|
|
27789
|
+
const rows = dist_exports2.findAll((e) => e.name === "tr", el.children).map((tr) => tr.children.filter((c) => isTag3(c) && (c.name === "td" || c.name === "th")).map(cell2));
|
|
27790
|
+
const cols = rows.reduce((m, r) => Math.max(m, r.length), 0);
|
|
27791
|
+
if (cols === 0) return;
|
|
27792
|
+
st.w.block();
|
|
27793
|
+
rows.forEach((r, i) => {
|
|
27794
|
+
const padded = r.concat(Array.from({ length: cols - r.length }, () => ""));
|
|
27795
|
+
st.w.emitLine("| " + padded.join(" | ") + " |");
|
|
27796
|
+
if (i === 0) st.w.emitLine("|" + " --- |".repeat(cols));
|
|
27797
|
+
});
|
|
27798
|
+
st.w.block();
|
|
27799
|
+
}
|
|
27800
|
+
function list3(st, el) {
|
|
27801
|
+
const ordered = el.name === "ol";
|
|
27802
|
+
const start = Number.parseInt(el.attribs.start ?? "1", 10);
|
|
27803
|
+
let n = Number.isFinite(start) ? start : 1;
|
|
27804
|
+
if (st.w.depth() === 0) st.w.block();
|
|
27805
|
+
else st.w.line();
|
|
27806
|
+
for (const c of el.children) {
|
|
27807
|
+
if (isTag3(c) && c.name === "li" && !dropped(c)) {
|
|
27808
|
+
const marker = ordered ? String(n) + ". " : "- ";
|
|
27809
|
+
n += 1;
|
|
27810
|
+
st.w.line();
|
|
27811
|
+
st.w.push(marker, " ".repeat(marker.length));
|
|
27812
|
+
for (const k of c.children) walk(st, k);
|
|
27813
|
+
st.w.pop();
|
|
27814
|
+
st.w.line();
|
|
27815
|
+
} else {
|
|
27816
|
+
walk(st, c);
|
|
27817
|
+
}
|
|
27818
|
+
}
|
|
27819
|
+
if (st.w.depth() === 0) st.w.block();
|
|
27820
|
+
else st.w.line();
|
|
27821
|
+
}
|
|
27822
|
+
function walk(st, node3) {
|
|
27823
|
+
if (isText2(node3)) {
|
|
27824
|
+
st.w.text(collapse(node3.data));
|
|
27825
|
+
return;
|
|
27826
|
+
}
|
|
27827
|
+
if (!isTag3(node3) || dropped(node3)) return;
|
|
27828
|
+
const name = node3.name;
|
|
27829
|
+
if (name.length === 2 && name[0] === "h" && name[1] >= "1" && name[1] <= "6") {
|
|
27830
|
+
const t = plainText(node3);
|
|
27831
|
+
if (t === "") return;
|
|
27832
|
+
if (name === "h1") st.sawH1 = true;
|
|
27833
|
+
st.w.block();
|
|
27834
|
+
st.w.text("#".repeat(Number(name[1])) + " " + t);
|
|
27835
|
+
st.w.block();
|
|
27836
|
+
return;
|
|
27837
|
+
}
|
|
27838
|
+
switch (name) {
|
|
27839
|
+
case "pre": {
|
|
27840
|
+
const code = preText(node3);
|
|
27841
|
+
if (code !== "") st.w.code(langOf(node3), code);
|
|
27842
|
+
return;
|
|
27843
|
+
}
|
|
27844
|
+
case "ul":
|
|
27845
|
+
case "ol":
|
|
27846
|
+
list3(st, node3);
|
|
27847
|
+
return;
|
|
27848
|
+
case "table":
|
|
27849
|
+
table(st, node3);
|
|
27850
|
+
return;
|
|
27851
|
+
case "br":
|
|
27852
|
+
st.w.line();
|
|
27853
|
+
return;
|
|
27854
|
+
case "hr":
|
|
27855
|
+
st.w.block();
|
|
27856
|
+
st.w.text("---");
|
|
27857
|
+
st.w.block();
|
|
27858
|
+
return;
|
|
27859
|
+
case "blockquote":
|
|
27860
|
+
st.w.block();
|
|
27861
|
+
st.w.push("> ", "> ");
|
|
27862
|
+
for (const c of node3.children) walk(st, c);
|
|
27863
|
+
st.w.pop();
|
|
27864
|
+
st.w.block();
|
|
27865
|
+
return;
|
|
27866
|
+
case "code": {
|
|
27867
|
+
const t = plainText(node3);
|
|
27868
|
+
if (t !== "") st.w.text(inlineCode(t));
|
|
27869
|
+
return;
|
|
27870
|
+
}
|
|
27871
|
+
case "a": {
|
|
27872
|
+
if (hasBlock(node3)) break;
|
|
27873
|
+
const t = plainText(node3);
|
|
27874
|
+
if (t === "") return;
|
|
27875
|
+
const href = resolveHref(node3.attribs.href, st.base);
|
|
27876
|
+
st.w.text(href === void 0 ? t : "[" + t + "](" + href + ")");
|
|
27877
|
+
return;
|
|
27878
|
+
}
|
|
27879
|
+
default:
|
|
27880
|
+
}
|
|
27881
|
+
const para = PARA.has(name);
|
|
27882
|
+
const line = LINE.has(name);
|
|
27883
|
+
if (para) st.w.block();
|
|
27884
|
+
else if (line) st.w.line();
|
|
27885
|
+
for (const c of node3.children) walk(st, c);
|
|
27886
|
+
if (para) st.w.block();
|
|
27887
|
+
else if (line) st.w.line();
|
|
27888
|
+
}
|
|
27889
|
+
function isWordChar3(c) {
|
|
27890
|
+
return c.toLowerCase() !== c.toUpperCase() || c >= "0" && c <= "9";
|
|
27891
|
+
}
|
|
27892
|
+
function wordCount(text) {
|
|
27893
|
+
let n = 0;
|
|
27894
|
+
for (const w of text.split(" ").join("\n").split("\n")) {
|
|
27895
|
+
for (const c of w) if (isWordChar3(c)) {
|
|
27896
|
+
n += 1;
|
|
27897
|
+
break;
|
|
27898
|
+
}
|
|
27899
|
+
}
|
|
27900
|
+
return n;
|
|
27901
|
+
}
|
|
27902
|
+
var SPARSE_MAX_WORDS = 20;
|
|
27903
|
+
var SPARSE_RATIO = 20;
|
|
27904
|
+
function contentRoot(children) {
|
|
27905
|
+
const main = dist_exports2.findOne((e) => e.name === "main", children, true);
|
|
27906
|
+
if (main !== null) return [main];
|
|
27907
|
+
const articles = dist_exports2.findAll((e) => e.name === "article", children);
|
|
27908
|
+
if (articles.length === 1) return articles;
|
|
27909
|
+
const body = dist_exports2.findOne((e) => e.name === "body", children, true);
|
|
27910
|
+
return body !== null ? [body] : children;
|
|
27911
|
+
}
|
|
27912
|
+
function htmlToReadable(html, baseUrl) {
|
|
27913
|
+
const doc = parseDocument(html);
|
|
27914
|
+
const titleEl = dist_exports2.findOne((e) => e.name === "title", doc.children, true);
|
|
27915
|
+
const title = titleEl === null ? "" : collapse(titleEl.children.map((c) => isText2(c) ? c.data : "").join("")).trim();
|
|
27916
|
+
let base;
|
|
27917
|
+
try {
|
|
27918
|
+
base = baseUrl === void 0 ? void 0 : new URL(baseUrl);
|
|
27919
|
+
} catch {
|
|
27920
|
+
base = void 0;
|
|
27921
|
+
}
|
|
27922
|
+
const st = { w: new Writer(), base, sawH1: false };
|
|
27923
|
+
for (const n of contentRoot(doc.children)) walk(st, n);
|
|
27924
|
+
const body = st.w.result();
|
|
27925
|
+
const words = wordCount(body);
|
|
27926
|
+
const text = !st.sawH1 && title !== "" && words > 0 ? "# " + title + "\n\n" + body : body;
|
|
27927
|
+
const sparse = words < SPARSE_MAX_WORDS && html.length > SPARSE_RATIO * Math.max(text.length, 1);
|
|
27928
|
+
return { text: text === "" ? "" : text + "\n", title, words, sparse };
|
|
27929
|
+
}
|
|
27930
|
+
|
|
24120
27931
|
// src/core/tools/index.ts
|
|
24121
27932
|
var ctxIndexSchema = external_exports.object({
|
|
24122
27933
|
path: external_exports.string().optional(),
|
|
@@ -24181,7 +27992,7 @@ async function itemsOf(input, ctx) {
|
|
|
24181
27992
|
const res = await safeFetch(input.url ?? "", AbortSignal.any([ctx.signal, AbortSignal.timeout(EXEC_TIMEOUT_MS)]));
|
|
24182
27993
|
const text = res.body.toString("utf8");
|
|
24183
27994
|
const label = res.finalUrl;
|
|
24184
|
-
return { items: [{ sourceKind: "url", label, kind: kindOfType(res.contentType), read: () => text }], from: label };
|
|
27995
|
+
return { items: [{ sourceKind: "url", label, kind: kindOfType(res.contentType), read: () => text, base: label }], from: label };
|
|
24185
27996
|
}
|
|
24186
27997
|
async function handler4(input, ctx) {
|
|
24187
27998
|
const given = INPUT_FIELDS.filter((f) => input[f] !== void 0);
|
|
@@ -24195,21 +28006,45 @@ async function handler4(input, ctx) {
|
|
|
24195
28006
|
let chunks = 0;
|
|
24196
28007
|
let bytes4 = 0;
|
|
24197
28008
|
let lastId = 0;
|
|
28009
|
+
const notes = [];
|
|
24198
28010
|
try {
|
|
24199
28011
|
for (const it of items) {
|
|
24200
28012
|
const text = it.read();
|
|
24201
28013
|
if (text === void 0) continue;
|
|
28014
|
+
bytes4 += Buffer.byteLength(text, "utf8");
|
|
28015
|
+
if (it.kind === "html") {
|
|
28016
|
+
let readable;
|
|
28017
|
+
try {
|
|
28018
|
+
readable = htmlToReadable(text, it.base);
|
|
28019
|
+
} catch {
|
|
28020
|
+
readable = void 0;
|
|
28021
|
+
}
|
|
28022
|
+
if (readable !== void 0) {
|
|
28023
|
+
const rawLabel = it.label + RAW_LABEL_SUFFIX;
|
|
28024
|
+
const raw = storeText(db, ctx.project, ctx.sessionId, it.sourceKind, rawLabel, text, "text");
|
|
28025
|
+
notes.push('Raw HTML kept as "' + rawLabel + '" (' + raw.chunks + " chunk(s)); pass it as `source` to search the markup.");
|
|
28026
|
+
lastId = raw.sourceId;
|
|
28027
|
+
if (readable.words === 0 || readable.sparse) {
|
|
28028
|
+
notes.unshift("No readable text found in " + it.label + " (the page is client-rendered or empty); nothing was added to default search.");
|
|
28029
|
+
continue;
|
|
28030
|
+
}
|
|
28031
|
+
const stored2 = storeText(db, ctx.project, ctx.sessionId, it.sourceKind, it.label, readable.text, "md");
|
|
28032
|
+
chunks += stored2.chunks;
|
|
28033
|
+
lastId = stored2.sourceId;
|
|
28034
|
+
sources += 1;
|
|
28035
|
+
continue;
|
|
28036
|
+
}
|
|
28037
|
+
}
|
|
24202
28038
|
const stored = storeText(db, ctx.project, ctx.sessionId, it.sourceKind, it.label, text, it.kind);
|
|
24203
28039
|
chunks += stored.chunks;
|
|
24204
28040
|
lastId = stored.sourceId;
|
|
24205
|
-
bytes4 += Buffer.byteLength(text, "utf8");
|
|
24206
28041
|
sources += 1;
|
|
24207
28042
|
}
|
|
24208
28043
|
} finally {
|
|
24209
28044
|
closeDb(db);
|
|
24210
28045
|
}
|
|
24211
28046
|
const shown2 = Buffer.byteLength(from, "utf8") > ECHO_MAX_BYTES ? sourceHandle(lastId) : from;
|
|
24212
|
-
const line = "Indexed " + sources + " source(s), " + chunks + " chunk(s) from " + shown2 + ".";
|
|
28047
|
+
const line = ["Indexed " + sources + " source(s), " + chunks + " chunk(s) from " + shown2 + ".", ...notes].join("\n");
|
|
24213
28048
|
return {
|
|
24214
28049
|
text: capBytes(line, OUTPUT_CAP).text,
|
|
24215
28050
|
isError: false,
|
|
@@ -24372,7 +28207,7 @@ async function handler7(_input, ctx) {
|
|
|
24372
28207
|
const project = sum(groups);
|
|
24373
28208
|
const allTime = project;
|
|
24374
28209
|
const agentIds = [.../* @__PURE__ */ new Set([...groups.map((g) => g.agent), ctx.project.agent])].sort();
|
|
24375
|
-
const
|
|
28210
|
+
const table2 = [
|
|
24376
28211
|
"| " + STATS_COLUMNS.join(" | ") + " |",
|
|
24377
28212
|
"|" + STATS_COLUMNS.map(() => "---").join("|") + "|",
|
|
24378
28213
|
tableRow("session", session),
|
|
@@ -24381,7 +28216,7 @@ async function handler7(_input, ctx) {
|
|
|
24381
28216
|
...agentIds.map((a) => tableRow("agent " + a, sum(groups.filter((g) => g.agent === a))))
|
|
24382
28217
|
].join("\n");
|
|
24383
28218
|
const summary = STATS_SUMMARY(reductionPct(allTime), reductionPct(session));
|
|
24384
|
-
return { text: capBytes(summary + "\n\n" +
|
|
28219
|
+
return { text: capBytes(summary + "\n\n" + table2, OUTPUT_CAP).text, isError: false, sandboxBytes: 0 };
|
|
24385
28220
|
}
|
|
24386
28221
|
var ctxStats = Object.freeze({
|
|
24387
28222
|
name: "ctx_stats",
|
|
@@ -24416,11 +28251,11 @@ function hostConfigPath(agent, home, env) {
|
|
|
24416
28251
|
return join17(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
|
|
24417
28252
|
}
|
|
24418
28253
|
}
|
|
24419
|
-
function
|
|
28254
|
+
function cell3(value) {
|
|
24420
28255
|
return value === void 0 ? "" : JSON.stringify(value);
|
|
24421
28256
|
}
|
|
24422
28257
|
function toRow(file2, edit) {
|
|
24423
|
-
return { area: file2 + UPGRADE_AREA_KEY_SEP + edit.path, before:
|
|
28258
|
+
return { area: file2 + UPGRADE_AREA_KEY_SEP + edit.path, before: cell3(edit.before), after: cell3(edit.after) };
|
|
24424
28259
|
}
|
|
24425
28260
|
function writeWithRollback(file2, text, write2, atomic) {
|
|
24426
28261
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
@@ -24756,16 +28591,16 @@ function removeV1(agent, findings) {
|
|
|
24756
28591
|
} else done.set(f, UPGRADE_NOT_FOUND);
|
|
24757
28592
|
} else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
|
|
24758
28593
|
}
|
|
24759
|
-
for (const [file2,
|
|
28594
|
+
for (const [file2, list4] of entries) {
|
|
24760
28595
|
if (!existsSync17(file2)) {
|
|
24761
|
-
for (const f of
|
|
28596
|
+
for (const f of list4) done.set(f, UPGRADE_NOT_FOUND);
|
|
24762
28597
|
continue;
|
|
24763
28598
|
}
|
|
24764
28599
|
if (file2.endsWith(TOML_EXT)) {
|
|
24765
28600
|
const rawToml = readFileSync14(file2, "utf8");
|
|
24766
28601
|
const tomlLayout = hostLayout(rawToml);
|
|
24767
28602
|
let text = hostText(rawToml);
|
|
24768
|
-
for (const f of
|
|
28603
|
+
for (const f of list4) {
|
|
24769
28604
|
const next = cutTomlTable(text, f.path);
|
|
24770
28605
|
if (next === null) {
|
|
24771
28606
|
done.set(f, UPGRADE_NOT_FOUND);
|
|
@@ -24774,14 +28609,14 @@ function removeV1(agent, findings) {
|
|
|
24774
28609
|
text = next;
|
|
24775
28610
|
done.set(f, UPGRADE_REMOVED);
|
|
24776
28611
|
}
|
|
24777
|
-
if (
|
|
28612
|
+
if (list4.some((f) => done.get(f) === UPGRADE_REMOVED)) {
|
|
24778
28613
|
keepOriginal(file2, kept, undo);
|
|
24779
28614
|
writeAtomic(file2, withLayout(text, tomlLayout));
|
|
24780
28615
|
}
|
|
24781
28616
|
continue;
|
|
24782
28617
|
}
|
|
24783
|
-
const hit = stripJsonEntries(agent, file2,
|
|
24784
|
-
for (const f of
|
|
28618
|
+
const hit = stripJsonEntries(agent, file2, list4, kept, undo);
|
|
28619
|
+
for (const f of list4) done.set(f, hit.has(f) ? UPGRADE_REMOVED : UPGRADE_NOT_FOUND);
|
|
24785
28620
|
}
|
|
24786
28621
|
return {
|
|
24787
28622
|
rows: findings.map((f) => row3(f, done.get(f) ?? UPGRADE_NOT_FOUND)),
|
|
@@ -24818,12 +28653,12 @@ function parseSums(text) {
|
|
|
24818
28653
|
}
|
|
24819
28654
|
return sums;
|
|
24820
28655
|
}
|
|
24821
|
-
function
|
|
28656
|
+
function walk2(dir, prefix, out) {
|
|
24822
28657
|
for (const entry of readdirSync8(dir, { withFileTypes: true })) {
|
|
24823
28658
|
const rel = prefix === "" ? entry.name : prefix + "/" + entry.name;
|
|
24824
28659
|
if (prefix === "" && (entry.name === GIT_DIR_NAME || entry.name === RELEASE_SUMS_FILE)) continue;
|
|
24825
28660
|
const abs = join21(dir, entry.name);
|
|
24826
|
-
if (entry.isDirectory())
|
|
28661
|
+
if (entry.isDirectory()) walk2(abs, rel, out);
|
|
24827
28662
|
else if (entry.isFile()) out.set(rel, abs);
|
|
24828
28663
|
else throw mismatch();
|
|
24829
28664
|
}
|
|
@@ -24834,7 +28669,7 @@ function verifySums(dir) {
|
|
|
24834
28669
|
if (sumsStat === void 0 || !sumsStat.isFile()) throw mismatch();
|
|
24835
28670
|
const sums = parseSums(readFileSync15(sumsPath, "utf8"));
|
|
24836
28671
|
const files = /* @__PURE__ */ new Map();
|
|
24837
|
-
|
|
28672
|
+
walk2(dir, "", files);
|
|
24838
28673
|
if (files.size !== sums.size) throw mismatch();
|
|
24839
28674
|
for (const [rel, abs] of files) {
|
|
24840
28675
|
const want = sums.get(rel);
|
|
@@ -24904,12 +28739,12 @@ async function upgrade(adapter, deps, home) {
|
|
|
24904
28739
|
throw err;
|
|
24905
28740
|
}
|
|
24906
28741
|
}
|
|
24907
|
-
function
|
|
28742
|
+
function cell4(text) {
|
|
24908
28743
|
return text.split(TABLE_PIPE).join(TABLE_PIPE_ESCAPED);
|
|
24909
28744
|
}
|
|
24910
28745
|
function renderTable(rows) {
|
|
24911
28746
|
const lines = [UPGRADE_TABLE_HEADER, UPGRADE_TABLE_RULE];
|
|
24912
|
-
for (const r of rows) lines.push(TABLE_ROW_START + [r.area, r.before, r.after].map(
|
|
28747
|
+
for (const r of rows) lines.push(TABLE_ROW_START + [r.area, r.before, r.after].map(cell4).join(TABLE_CELL_SEP) + TABLE_ROW_END);
|
|
24913
28748
|
return lines.join("\n");
|
|
24914
28749
|
}
|
|
24915
28750
|
async function runUpgrade(input, deps) {
|
|
@@ -24965,6 +28800,26 @@ function define(name) {
|
|
|
24965
28800
|
};
|
|
24966
28801
|
}
|
|
24967
28802
|
var TOOLS = Object.freeze(TOOL_ORDER.map(define));
|
|
28803
|
+
function callExample(tool) {
|
|
28804
|
+
const a = tool.description.indexOf("`");
|
|
28805
|
+
const b = tool.description.indexOf("`", a + 1);
|
|
28806
|
+
return a < 0 || b < 0 ? tool.name + "({})" : tool.description.slice(a + 1, b);
|
|
28807
|
+
}
|
|
28808
|
+
function invalidCallLine(tool, issues) {
|
|
28809
|
+
const parts = [];
|
|
28810
|
+
for (const issue4 of issues.slice(0, 3)) {
|
|
28811
|
+
const where = issue4.path.length === 0 ? "" : issue4.path.map(String).join(".") + ": ";
|
|
28812
|
+
let one = (where + issue4.message).split("\n").join(" ").trim();
|
|
28813
|
+
while (one.endsWith(".")) one = one.slice(0, -1);
|
|
28814
|
+
parts.push(one);
|
|
28815
|
+
}
|
|
28816
|
+
const detail = parts.length === 0 ? "Invalid arguments" : parts.join("; ");
|
|
28817
|
+
return tool.name + ": " + detail + ". Correct call: " + callExample(tool);
|
|
28818
|
+
}
|
|
28819
|
+
function checkCall(tool, input) {
|
|
28820
|
+
const parsed = tool.schema.safeParse(input);
|
|
28821
|
+
return parsed.success ? { ok: true, data: parsed.data } : { ok: false, line: invalidCallLine(tool, parsed.error.issues) };
|
|
28822
|
+
}
|
|
24968
28823
|
|
|
24969
28824
|
// src/entries/server.ts
|
|
24970
28825
|
import { randomUUID } from "node:crypto";
|
|
@@ -25771,9 +29626,9 @@ var Class2 = class {
|
|
|
25771
29626
|
constructor(..._args) {
|
|
25772
29627
|
}
|
|
25773
29628
|
};
|
|
25774
|
-
function members(proto,
|
|
25775
|
-
for (const key in
|
|
25776
|
-
const desc = Object.getOwnPropertyDescriptor(
|
|
29629
|
+
function members(proto, table2) {
|
|
29630
|
+
for (const key in table2) {
|
|
29631
|
+
const desc = Object.getOwnPropertyDescriptor(table2, key);
|
|
25777
29632
|
if (desc.get)
|
|
25778
29633
|
Object.defineProperty(proto, key, { ...desc, enumerable: false });
|
|
25779
29634
|
else
|
|
@@ -25788,10 +29643,10 @@ function hide(inst, key, value) {
|
|
|
25788
29643
|
return own2(inst, key, value, false);
|
|
25789
29644
|
}
|
|
25790
29645
|
// @__NO_SIDE_EFFECTS__
|
|
25791
|
-
function derived(computes,
|
|
29646
|
+
function derived(computes, table2) {
|
|
25792
29647
|
for (const key in computes) {
|
|
25793
29648
|
const compute = computes[key];
|
|
25794
|
-
Object.defineProperty(
|
|
29649
|
+
Object.defineProperty(table2, key, {
|
|
25795
29650
|
configurable: true,
|
|
25796
29651
|
enumerable: true,
|
|
25797
29652
|
get() {
|
|
@@ -25802,7 +29657,7 @@ function derived(computes, table) {
|
|
|
25802
29657
|
}
|
|
25803
29658
|
});
|
|
25804
29659
|
}
|
|
25805
|
-
return
|
|
29660
|
+
return table2;
|
|
25806
29661
|
}
|
|
25807
29662
|
function defineBound(proto, key, fn) {
|
|
25808
29663
|
Object.defineProperty(proto, key, {
|
|
@@ -30023,8 +33878,8 @@ var contributors = {
|
|
|
30023
33878
|
function aggregateChecks(schema) {
|
|
30024
33879
|
const agg = {};
|
|
30025
33880
|
const def = schema._zod.def;
|
|
30026
|
-
const
|
|
30027
|
-
for (const ch of
|
|
33881
|
+
const list4 = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
33882
|
+
for (const ch of list4)
|
|
30028
33883
|
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
30029
33884
|
const bag = schema._zod.bag;
|
|
30030
33885
|
if (bag.minimum !== void 0)
|
|
@@ -33352,9 +37207,9 @@ var Class3 = class {
|
|
|
33352
37207
|
constructor(..._args) {
|
|
33353
37208
|
}
|
|
33354
37209
|
};
|
|
33355
|
-
function members2(proto,
|
|
33356
|
-
for (const key in
|
|
33357
|
-
const desc = Object.getOwnPropertyDescriptor(
|
|
37210
|
+
function members2(proto, table2) {
|
|
37211
|
+
for (const key in table2) {
|
|
37212
|
+
const desc = Object.getOwnPropertyDescriptor(table2, key);
|
|
33358
37213
|
if (desc.get)
|
|
33359
37214
|
Object.defineProperty(proto, key, { ...desc, enumerable: false });
|
|
33360
37215
|
else
|
|
@@ -33369,10 +37224,10 @@ function hide2(inst, key, value) {
|
|
|
33369
37224
|
return own3(inst, key, value, false);
|
|
33370
37225
|
}
|
|
33371
37226
|
// @__NO_SIDE_EFFECTS__
|
|
33372
|
-
function derived2(computes,
|
|
37227
|
+
function derived2(computes, table2) {
|
|
33373
37228
|
for (const key in computes) {
|
|
33374
37229
|
const compute = computes[key];
|
|
33375
|
-
Object.defineProperty(
|
|
37230
|
+
Object.defineProperty(table2, key, {
|
|
33376
37231
|
configurable: true,
|
|
33377
37232
|
enumerable: true,
|
|
33378
37233
|
get() {
|
|
@@ -33383,7 +37238,7 @@ function derived2(computes, table) {
|
|
|
33383
37238
|
}
|
|
33384
37239
|
});
|
|
33385
37240
|
}
|
|
33386
|
-
return
|
|
37241
|
+
return table2;
|
|
33387
37242
|
}
|
|
33388
37243
|
function defineBound2(proto, key, fn) {
|
|
33389
37244
|
Object.defineProperty(proto, key, {
|
|
@@ -37514,8 +41369,8 @@ var contributors2 = {
|
|
|
37514
41369
|
function aggregateChecks2(schema) {
|
|
37515
41370
|
const agg = {};
|
|
37516
41371
|
const def = schema._zod.def;
|
|
37517
|
-
const
|
|
37518
|
-
for (const ch of
|
|
41372
|
+
const list4 = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
|
|
41373
|
+
for (const ch of list4)
|
|
37519
41374
|
contributors2[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
37520
41375
|
const bag = schema._zod.bag;
|
|
37521
41376
|
if (bag.minimum !== void 0)
|
|
@@ -42366,11 +46221,11 @@ var LADDER_ERROR_HTTP_STATUS = {
|
|
|
42366
46221
|
[ProtocolErrorCode.MissingRequiredClientCapability]: 400,
|
|
42367
46222
|
[HEADER_MISMATCH_ERROR_CODE]: 400
|
|
42368
46223
|
};
|
|
42369
|
-
function rejection(rung,
|
|
46224
|
+
function rejection(rung, cell5, httpStatus, error42, settled) {
|
|
42370
46225
|
return {
|
|
42371
46226
|
kind: "reject",
|
|
42372
46227
|
rung,
|
|
42373
|
-
cell:
|
|
46228
|
+
cell: cell5,
|
|
42374
46229
|
httpStatus,
|
|
42375
46230
|
code: error42.code,
|
|
42376
46231
|
message: error42.message,
|
|
@@ -44006,8 +47861,8 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
44006
47861
|
}
|
|
44007
47862
|
if (typeof b == "string" && b[0] === '"' && !(a instanceof Name)) return `"${a}${b.slice(1)}`;
|
|
44008
47863
|
}
|
|
44009
|
-
function strConcat(
|
|
44010
|
-
return c2.emptyStr() ?
|
|
47864
|
+
function strConcat(c12, c2) {
|
|
47865
|
+
return c2.emptyStr() ? c12 : c12.emptyStr() ? c2 : str4`${c12}${c2}`;
|
|
44011
47866
|
}
|
|
44012
47867
|
exports.strConcat = strConcat;
|
|
44013
47868
|
function interpolate(x) {
|
|
@@ -44261,7 +48116,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
44261
48116
|
AND: new code_1._Code("&&"),
|
|
44262
48117
|
ADD: new code_1._Code("+")
|
|
44263
48118
|
};
|
|
44264
|
-
var
|
|
48119
|
+
var Node2 = class {
|
|
44265
48120
|
optimizeNodes() {
|
|
44266
48121
|
return this;
|
|
44267
48122
|
}
|
|
@@ -44269,7 +48124,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
44269
48124
|
return this;
|
|
44270
48125
|
}
|
|
44271
48126
|
};
|
|
44272
|
-
var Def = class extends
|
|
48127
|
+
var Def = class extends Node2 {
|
|
44273
48128
|
constructor(varKind, name, rhs) {
|
|
44274
48129
|
super();
|
|
44275
48130
|
this.varKind = varKind;
|
|
@@ -44290,7 +48145,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
44290
48145
|
return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {};
|
|
44291
48146
|
}
|
|
44292
48147
|
};
|
|
44293
|
-
var Assign = class extends
|
|
48148
|
+
var Assign = class extends Node2 {
|
|
44294
48149
|
constructor(lhs, rhs, sideEffects) {
|
|
44295
48150
|
super();
|
|
44296
48151
|
this.lhs = lhs;
|
|
@@ -44318,7 +48173,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
44318
48173
|
return `${this.lhs} ${this.op}= ${this.rhs};` + _n;
|
|
44319
48174
|
}
|
|
44320
48175
|
};
|
|
44321
|
-
var Label = class extends
|
|
48176
|
+
var Label = class extends Node2 {
|
|
44322
48177
|
constructor(label) {
|
|
44323
48178
|
super();
|
|
44324
48179
|
this.label = label;
|
|
@@ -44328,7 +48183,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
44328
48183
|
return `${this.label}:` + _n;
|
|
44329
48184
|
}
|
|
44330
48185
|
};
|
|
44331
|
-
var Break = class extends
|
|
48186
|
+
var Break = class extends Node2 {
|
|
44332
48187
|
constructor(label) {
|
|
44333
48188
|
super();
|
|
44334
48189
|
this.label = label;
|
|
@@ -44338,7 +48193,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
44338
48193
|
return `break${this.label ? ` ${this.label}` : ""};` + _n;
|
|
44339
48194
|
}
|
|
44340
48195
|
};
|
|
44341
|
-
var Throw = class extends
|
|
48196
|
+
var Throw = class extends Node2 {
|
|
44342
48197
|
constructor(error42) {
|
|
44343
48198
|
super();
|
|
44344
48199
|
this.error = error42;
|
|
@@ -44350,7 +48205,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
44350
48205
|
return this.error.names;
|
|
44351
48206
|
}
|
|
44352
48207
|
};
|
|
44353
|
-
var AnyCode = class extends
|
|
48208
|
+
var AnyCode = class extends Node2 {
|
|
44354
48209
|
constructor(code) {
|
|
44355
48210
|
super();
|
|
44356
48211
|
this.code = code;
|
|
@@ -44369,7 +48224,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
44369
48224
|
return this.code instanceof code_1._CodeOrName ? this.code.names : {};
|
|
44370
48225
|
}
|
|
44371
48226
|
};
|
|
44372
|
-
var ParentNode = class extends
|
|
48227
|
+
var ParentNode = class extends Node2 {
|
|
44373
48228
|
constructor(nodes = []) {
|
|
44374
48229
|
super();
|
|
44375
48230
|
this.nodes = nodes;
|
|
@@ -44408,7 +48263,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
44408
48263
|
return "{" + opts._n + super.render(opts) + "}" + opts._n;
|
|
44409
48264
|
}
|
|
44410
48265
|
};
|
|
44411
|
-
var
|
|
48266
|
+
var Root2 = class extends ParentNode {
|
|
44412
48267
|
};
|
|
44413
48268
|
var Else = class extends BlockNode {
|
|
44414
48269
|
};
|
|
@@ -44585,7 +48440,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
44585
48440
|
};
|
|
44586
48441
|
this._extScope = extScope;
|
|
44587
48442
|
this._scope = new scope_1.Scope({ parent: extScope });
|
|
44588
|
-
this._nodes = [new
|
|
48443
|
+
this._nodes = [new Root2()];
|
|
44589
48444
|
}
|
|
44590
48445
|
toString() {
|
|
44591
48446
|
return this._root.render(this.opts);
|
|
@@ -44965,8 +48820,8 @@ var require_util = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
44965
48820
|
})(Type || (exports.Type = Type = {}));
|
|
44966
48821
|
function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
|
|
44967
48822
|
if (dataProp instanceof codegen_1.Name) {
|
|
44968
|
-
const
|
|
44969
|
-
return jsPropertySyntax ?
|
|
48823
|
+
const isNumber3 = dataPropType === Type.Num;
|
|
48824
|
+
return jsPropertySyntax ? isNumber3 ? (0, codegen_1._)`"[" + ${dataProp} + "]"` : (0, codegen_1._)`"['" + ${dataProp} + "']"` : isNumber3 ? (0, codegen_1._)`"/" + ${dataProp}` : (0, codegen_1._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
|
|
44970
48825
|
}
|
|
44971
48826
|
return jsPropertySyntax ? (0, codegen_1.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
|
|
44972
48827
|
}
|
|
@@ -46197,17 +50052,17 @@ var require_validate = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
46197
50052
|
const { schemaCode } = this;
|
|
46198
50053
|
this.fail((0, codegen_1._)`${schemaCode} !== undefined && (${(0, codegen_1.or)(this.invalid$data(), condition)})`);
|
|
46199
50054
|
}
|
|
46200
|
-
error(
|
|
50055
|
+
error(append2, errorParams, errorPaths) {
|
|
46201
50056
|
if (errorParams) {
|
|
46202
50057
|
this.setParams(errorParams);
|
|
46203
|
-
this._error(
|
|
50058
|
+
this._error(append2, errorPaths);
|
|
46204
50059
|
this.setParams({});
|
|
46205
50060
|
return;
|
|
46206
50061
|
}
|
|
46207
|
-
this._error(
|
|
50062
|
+
this._error(append2, errorPaths);
|
|
46208
50063
|
}
|
|
46209
|
-
_error(
|
|
46210
|
-
(
|
|
50064
|
+
_error(append2, errorPaths) {
|
|
50065
|
+
(append2 ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
|
|
46211
50066
|
}
|
|
46212
50067
|
$dataError() {
|
|
46213
50068
|
(0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
|
|
@@ -50827,11 +54682,11 @@ var require_dist = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
50827
54682
|
if (!f) throw new Error(`Unknown format "${name}"`);
|
|
50828
54683
|
return f;
|
|
50829
54684
|
};
|
|
50830
|
-
function addFormats2(ajv,
|
|
54685
|
+
function addFormats2(ajv, list4, fs2, exportName) {
|
|
50831
54686
|
var _a5;
|
|
50832
54687
|
var _b;
|
|
50833
54688
|
(_a5 = (_b = ajv.opts.code).formats) !== null && _a5 !== void 0 || (_b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`);
|
|
50834
|
-
for (const f of
|
|
54689
|
+
for (const f of list4) ajv.addFormat(f, fs2[f]);
|
|
50835
54690
|
}
|
|
50836
54691
|
module.exports = exports = formatsPlugin;
|
|
50837
54692
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -50922,16 +54777,16 @@ function getCompleter(schema) {
|
|
|
50922
54777
|
return schema[COMPLETABLE_SYMBOL]?.complete;
|
|
50923
54778
|
}
|
|
50924
54779
|
var MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
|
|
50925
|
-
function listenFilterAccepts(
|
|
54780
|
+
function listenFilterAccepts(filter2, event) {
|
|
50926
54781
|
switch (event.kind) {
|
|
50927
54782
|
case "tools_list_changed":
|
|
50928
|
-
return
|
|
54783
|
+
return filter2.toolsListChanged === true;
|
|
50929
54784
|
case "prompts_list_changed":
|
|
50930
|
-
return
|
|
54785
|
+
return filter2.promptsListChanged === true;
|
|
50931
54786
|
case "resources_list_changed":
|
|
50932
|
-
return
|
|
54787
|
+
return filter2.resourcesListChanged === true;
|
|
50933
54788
|
case "resource_updated":
|
|
50934
|
-
return
|
|
54789
|
+
return filter2.resourceSubscriptions !== void 0 && filter2.resourceSubscriptions.includes(event.uri);
|
|
50935
54790
|
}
|
|
50936
54791
|
}
|
|
50937
54792
|
function honoredSubset(requested, capabilities) {
|
|
@@ -51022,8 +54877,8 @@ var StdioListenRouter = class {
|
|
|
51022
54877
|
message: "Subscription limit reached"
|
|
51023
54878
|
}
|
|
51024
54879
|
};
|
|
51025
|
-
const
|
|
51026
|
-
if (
|
|
54880
|
+
const filter2 = parseListenFilter(message3);
|
|
54881
|
+
if (filter2 === void 0) return {
|
|
51027
54882
|
jsonrpc: "2.0",
|
|
51028
54883
|
id: message3.id,
|
|
51029
54884
|
error: {
|
|
@@ -51031,7 +54886,7 @@ var StdioListenRouter = class {
|
|
|
51031
54886
|
message: "Invalid params: 'notifications' is required and must be a valid SubscriptionFilter"
|
|
51032
54887
|
}
|
|
51033
54888
|
};
|
|
51034
|
-
const honored = honoredSubset(
|
|
54889
|
+
const honored = honoredSubset(filter2, this._serverCapabilities);
|
|
51035
54890
|
this._subs.set(message3.id, honored);
|
|
51036
54891
|
return stampSubscriptionId({
|
|
51037
54892
|
method: "notifications/subscriptions/acknowledged",
|
|
@@ -51061,7 +54916,7 @@ var StdioListenRouter = class {
|
|
|
51061
54916
|
const uri = typeof uriParam === "string" ? uriParam : void 0;
|
|
51062
54917
|
const event = notificationToServerEvent(message3.method, uri);
|
|
51063
54918
|
const out = [];
|
|
51064
|
-
for (const [subscriptionId,
|
|
54919
|
+
for (const [subscriptionId, filter2] of this._subs) if (listenFilterAccepts(filter2, event)) out.push(stampSubscriptionId({
|
|
51065
54920
|
method: message3.method,
|
|
51066
54921
|
params: message3.params ?? {}
|
|
51067
54922
|
}, subscriptionId));
|
|
@@ -53154,6 +57009,17 @@ function versionAtLeast(have, min) {
|
|
|
53154
57009
|
const [lower] = [have, min].sort(NUMERIC.compare);
|
|
53155
57010
|
return lower === min;
|
|
53156
57011
|
}
|
|
57012
|
+
function passThrough(tool) {
|
|
57013
|
+
const json2 = () => external_exports.toJSONSchema(tool.schema, { target: "draft-2020-12", io: "input" });
|
|
57014
|
+
return {
|
|
57015
|
+
"~standard": {
|
|
57016
|
+
version: 1,
|
|
57017
|
+
vendor: "context-mode",
|
|
57018
|
+
validate: (value) => ({ value }),
|
|
57019
|
+
jsonSchema: { input: json2, output: json2 }
|
|
57020
|
+
}
|
|
57021
|
+
};
|
|
57022
|
+
}
|
|
53157
57023
|
async function isDegraded() {
|
|
53158
57024
|
if (!versionAtLeast(process.versions.node, NODE_MIN)) return true;
|
|
53159
57025
|
try {
|
|
@@ -53251,10 +57117,15 @@ async function startServer(argv, env) {
|
|
|
53251
57117
|
protocolVersion: server.server.getNegotiatedProtocolVersion() ?? ""
|
|
53252
57118
|
};
|
|
53253
57119
|
let reply4;
|
|
53254
|
-
|
|
53255
|
-
|
|
53256
|
-
|
|
53257
|
-
|
|
57120
|
+
const checked = checkCall(tool, input);
|
|
57121
|
+
if (!checked.ok) {
|
|
57122
|
+
reply4 = { text: checked.line, isError: true, sandboxBytes: 0 };
|
|
57123
|
+
} else {
|
|
57124
|
+
try {
|
|
57125
|
+
reply4 = await tool.handler(checked.data, ctx);
|
|
57126
|
+
} catch (err) {
|
|
57127
|
+
reply4 = errorReply(err);
|
|
57128
|
+
}
|
|
53258
57129
|
}
|
|
53259
57130
|
if (stopRequested()) {
|
|
53260
57131
|
setTimeout(stopSelf, UPGRADE_STOP_DELAY_MS);
|
|
@@ -53296,7 +57167,7 @@ async function startServer(argv, env) {
|
|
|
53296
57167
|
{
|
|
53297
57168
|
description: tool.description,
|
|
53298
57169
|
// zod 3.25 `zod/v4` has no ~standard.jsonSchema type; the SDK converts it with z.toJSONSchema (DEVIATIONS).
|
|
53299
|
-
inputSchema: tool
|
|
57170
|
+
inputSchema: passThrough(tool),
|
|
53300
57171
|
...tool.readOnly ? { annotations: { readOnlyHint: true } } : {},
|
|
53301
57172
|
...tool.alwaysLoad ? { _meta: { "anthropic/alwaysLoad": true } } : {}
|
|
53302
57173
|
},
|
|
@@ -53344,10 +57215,6 @@ function textOf2(content) {
|
|
|
53344
57215
|
function errorReply2(err) {
|
|
53345
57216
|
return { text: err instanceof CtxError ? err.toLine() : INTERNAL_ERROR_LINE, isError: true, sandboxBytes: 0 };
|
|
53346
57217
|
}
|
|
53347
|
-
function invalidArgs(tool, issue4) {
|
|
53348
|
-
const field = issue4.path.length === 0 ? tool.name : issue4.path.map(String).join(".");
|
|
53349
|
-
return { text: formatError2("INVALID_ARGS", { field, action: issue4.message }), isError: true, sandboxBytes: 0 };
|
|
53350
|
-
}
|
|
53351
57218
|
function toPi(reply4) {
|
|
53352
57219
|
if (reply4.isError) throw new Error(reply4.text);
|
|
53353
57220
|
return { content: [{ type: "text", text: reply4.text }], details: {} };
|
|
@@ -53374,8 +57241,8 @@ function piExtension(pi) {
|
|
|
53374
57241
|
return project;
|
|
53375
57242
|
}
|
|
53376
57243
|
async function runTool(tool, params, signal) {
|
|
53377
|
-
const
|
|
53378
|
-
if (!
|
|
57244
|
+
const checked = checkCall(tool, params);
|
|
57245
|
+
if (!checked.ok) return { text: checked.line, isError: true, sandboxBytes: 0 };
|
|
53379
57246
|
const ctx = {
|
|
53380
57247
|
get project() {
|
|
53381
57248
|
return projectOf();
|
|
@@ -53388,7 +57255,7 @@ function piExtension(pi) {
|
|
|
53388
57255
|
};
|
|
53389
57256
|
let reply4;
|
|
53390
57257
|
try {
|
|
53391
|
-
reply4 = await tool.handler(
|
|
57258
|
+
reply4 = await tool.handler(checked.data, ctx);
|
|
53392
57259
|
} catch (err) {
|
|
53393
57260
|
return errorReply2(err);
|
|
53394
57261
|
}
|