@kky42/pievo-server 2.3.0 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +1 -1
- package/.output/public/assets/MachinesModal-CSbnrUER.js +1 -0
- package/.output/public/assets/SignIn-0Tjqs-Ma.js +1 -0
- package/.output/public/assets/actionUi-DpwGIGpw.js +1 -0
- package/.output/public/assets/app-CaZpuwOS.css +2 -0
- package/.output/public/assets/index-CaS_SmDq.js +10 -0
- package/.output/public/assets/invite._token-Btg_0aLp.js +1 -0
- package/.output/public/assets/invite._token-KMD2JAgE.js +1 -0
- package/.output/public/assets/lifecycleUi-C7dwHtbw.js +1 -0
- package/.output/public/assets/loops._loopId-D5usF3DO.js +67 -0
- package/.output/public/assets/loops._loopId_.runs._runId-DRCgXaCq.js +3 -0
- package/.output/public/assets/preload-helper-DsxECZIS.js +5 -0
- package/.output/public/assets/routes-CtFgwdgW.js +1 -0
- package/.output/public/assets/routes-LDbnnQ3f.js +1 -0
- package/.output/public/assets/t._teamId-D41xcbsF.js +1 -0
- package/.output/public/assets/t._teamId-DUena1pV.js +1 -0
- package/.output/public/assets/ui-Do4gqMyP.js +1 -0
- package/.output/server/_libs/@base-ui/react+[...].mjs +4130 -4130
- package/.output/server/_libs/@tanstack/react-router+[...].mjs +1 -1
- package/.output/server/_libs/drizzle-orm+postgres.mjs +28 -1
- package/.output/server/_ssr/DashboardView-C2LdV6J0.mjs +914 -0
- package/.output/server/_ssr/{notifyFns-DuPR1zd7.mjs → MachinesModal-BjkcVjjx.mjs} +55 -35
- package/.output/server/_ssr/{SignIn-RmpWm9uy.mjs → SignIn-DEGrvJvb.mjs} +10 -24
- package/.output/server/_ssr/SocialLinks-Cm4H8pUJ.mjs +1044 -0
- package/.output/server/_ssr/{actionUi-BN55TNYE.mjs → actionUi-DJBWuNwr.mjs} +3 -3
- package/.output/server/_ssr/{artifactFiles-BCaIIrrT.mjs → artifactFiles-DtpRidFZ.mjs} +7 -8
- package/.output/server/_ssr/{artifactKind-BW0isV8L.mjs → artifactKind-FBYbgSuf.mjs} +27 -2
- package/.output/server/_ssr/artifacts-BR3jj0NC.mjs +2 -0
- package/.output/server/_ssr/{auth-30Z4lV1w.mjs → auth-C0zoZCGe.mjs} +16 -19
- package/.output/server/_ssr/boot-CdOO4xOo.mjs +2 -0
- package/.output/server/_ssr/{boot-3BNKujyp.mjs → boot-sNlIkoLe.mjs} +1331 -3927
- package/.output/server/_ssr/{bun-sqlite-dialect-BW9W1_Ps-_7tfuNRi.mjs → bun-sqlite-dialect-BW9W1_Ps-DmlZWqO7.mjs} +2 -2
- package/.output/server/_ssr/{d1-sqlite-dialect-BLC8LXE6-ucDUbeBk.mjs → d1-sqlite-dialect-BLC8LXE6-CCNzqZwZ.mjs} +2 -2
- package/.output/server/_ssr/db-CwLD-5w1.mjs +2 -0
- package/.output/server/_ssr/{dist-Cd6nlLlO.mjs → dist-B3SxDOpW.mjs} +2 -2
- package/.output/server/_ssr/{factory-CWWwV7XZ.mjs → factory-Dv3Zopis.mjs} +2 -2
- package/.output/server/_ssr/invite._token-CJ6-H-s3.mjs +20 -0
- package/.output/server/_ssr/{invite._token-SdWXemIc.mjs → invite._token-dLKDJKVs.mjs} +9 -17
- package/.output/server/_ssr/{invite._token-BKlz0R2f.mjs → invite._token-l1SjouDz.mjs} +6 -15
- package/.output/server/_ssr/{kysely-adapter-C8iS51DB.mjs → kysely-adapter-nL7WKSgw.mjs} +1 -1
- package/.output/server/_ssr/{lifecycleUi-DgBQAYzp.mjs → lifecycleUi-Dad3hvhm.mjs} +11 -11
- package/.output/server/_ssr/logger-B8m8F1Qu.mjs +2 -0
- package/.output/server/_ssr/loopApi-BKyFB4KM.mjs +342 -0
- package/.output/server/_ssr/{adapters-BoLkOf1T.mjs → loopProjection-B8a829ij.mjs} +25 -55
- package/.output/server/_ssr/loops._loopId-DS16Phmq.mjs +1271 -0
- package/.output/server/_ssr/{loops._loopId_.runs._runId-PUGBrD5q.mjs → loops._loopId_.runs._runId-BEJI6iK5.mjs} +23 -74
- package/.output/server/_ssr/{loops._loopId_.runs._runId-Ymy4lwee.mjs → loops._loopId_.runs._runId-CduETLqH.mjs} +4 -5
- package/.output/server/_ssr/{machineFns-BZ9puxDt.mjs → machineFns-ByMsgG12.mjs} +3 -5
- package/.output/server/_ssr/{node-sqlite-dialect-D_3JmkMo.mjs → node-sqlite-dialect-CjNineno.mjs} +2 -2
- package/.output/server/_ssr/router-CXyrnvx-.mjs +565 -0
- package/.output/server/_ssr/{routes-ClZEdsnB.mjs → routes-BulNEUEE.mjs} +6 -10
- package/.output/server/_ssr/{routes-ComqHvCL.mjs → routes-DD94baie.mjs} +3 -3
- package/.output/server/_ssr/{routes-D5jJJ-30.mjs → routes-Wjexi35W.mjs} +6 -6
- package/.output/server/_ssr/runDiff-Ba8Lg1vg.mjs +2 -0
- package/.output/server/_ssr/ssr.mjs +60 -100
- package/.output/server/_ssr/store-Cujtg2QE.mjs +2 -0
- package/.output/server/_ssr/{t._teamId-BgHV_KFP.mjs → t._teamId-1CreIlPV.mjs} +7 -11
- package/.output/server/_ssr/{t._teamId-DDERNgfn.mjs → t._teamId-Bd6-zZsy.mjs} +4 -4
- package/.output/server/_ssr/{t._teamId-DRJvKHZn.mjs → t._teamId-COuMKQ4r.mjs} +7 -7
- package/.output/server/_ssr/{teamFns-Bp81UO-x.mjs → teamFns-H438WnZC.mjs} +12 -30
- package/.output/server/_ssr/{teamFns-bm82twd5.mjs → teamFns-j2JKjorZ.mjs} +2 -2
- package/.output/server/_ssr/tokens-DgG_Syq3.mjs +2 -0
- package/.output/server/_ssr/{ui-Ww2tTM2u.mjs → ui-D5KWstlb.mjs} +26 -48
- package/.output/server/{_tanstack-start-manifest_v-DwKENYCN.mjs → _tanstack-start-manifest_v-3H7yBKLz.mjs} +25 -35
- package/{drizzle/0000_round_marauders.sql → .output/server/drizzle/0000_baseline.sql} +102 -44
- package/.output/server/drizzle/meta/_journal.json +3 -115
- package/.output/server/index.mjs +83 -132
- package/{.output/server/drizzle/0000_round_marauders.sql → drizzle/0000_baseline.sql} +102 -44
- package/drizzle/meta/_journal.json +3 -115
- package/package.json +2 -11
- package/scripts/pievo-server.mjs +3 -1
- package/scripts/server-cli-lib.mjs +23 -16
- package/.output/public/assets/CodeField-dOzyFQNH.js +0 -34
- package/.output/public/assets/LoopView-DjVHUyrR.js +0 -59
- package/.output/public/assets/Modal-CCRvx959.js +0 -1
- package/.output/public/assets/SignIn-Qxw5zDFq.js +0 -1
- package/.output/public/assets/actionUi-CXxhzYe2.js +0 -1
- package/.output/public/assets/app-D1cij_NJ.css +0 -2
- package/.output/public/assets/artifactView-Cd5wWPil.js +0 -66
- package/.output/public/assets/index-BRN_CQ8U.js +0 -12
- package/.output/public/assets/invite._token-BIxr8DlP.js +0 -1
- package/.output/public/assets/invite._token-j2BTCeG1.js +0 -1
- package/.output/public/assets/jsx-runtime-BseJUIpC.js +0 -1
- package/.output/public/assets/lifecycleUi-Qy_8beQK.js +0 -1
- package/.output/public/assets/loopApi-CT1mMhlb.js +0 -3
- package/.output/public/assets/loops._loopId-BRBQzioy.js +0 -4
- package/.output/public/assets/loops._loopId_.runs._runId-CMnOJkem.js +0 -3
- package/.output/public/assets/notifyFns-DYD4EKaG.js +0 -1
- package/.output/public/assets/preload-helper-DFkkpP6W.js +0 -3
- package/.output/public/assets/routes-3nuEJGdo.js +0 -1
- package/.output/public/assets/routes-DORLim-C.js +0 -1
- package/.output/public/assets/t._teamId-F5f4K8kd.js +0 -1
- package/.output/public/assets/t._teamId-XfE_S1Fo.js +0 -1
- package/.output/public/assets/ui-Dhsx6SW0.js +0 -1
- package/.output/public/assets/useRouter-DsjH8G0p.js +0 -1
- package/.output/server/_libs/@codemirror/autocomplete+[...].mjs +0 -19713
- package/.output/server/_libs/@codemirror/lang-css+[...].mjs +0 -2636
- package/.output/server/_libs/@codemirror/lang-html+[...].mjs +0 -2247
- package/.output/server/_libs/@codemirror/lang-json+[...].mjs +0 -79
- package/.output/server/_libs/@reduxjs/toolkit+[...].mjs +0 -1736
- package/.output/server/_libs/@uiw/codemirror-extensions-basic-setup+[...].mjs +0 -76
- package/.output/server/_libs/babel__runtime.mjs +0 -30
- package/.output/server/_libs/clsx.mjs +0 -16
- package/.output/server/_libs/codemirror__commands.mjs +0 -1725
- package/.output/server/_libs/codemirror__lint.mjs +0 -565
- package/.output/server/_libs/codemirror__search.mjs +0 -1138
- package/.output/server/_libs/codemirror__theme-one-dark.mjs +0 -161
- package/.output/server/_libs/d3-array.mjs +0 -231
- package/.output/server/_libs/d3-color.mjs +0 -330
- package/.output/server/_libs/d3-format.mjs +0 -252
- package/.output/server/_libs/d3-interpolate.mjs +0 -163
- package/.output/server/_libs/d3-path.mjs +0 -77
- package/.output/server/_libs/d3-scale+[...].mjs +0 -1907
- package/.output/server/_libs/d3-shape.mjs +0 -818
- package/.output/server/_libs/decimal.js-light.mjs +0 -884
- package/.output/server/_libs/dom-serializer+[...].mjs +0 -708
- package/.output/server/_libs/domhandler.mjs +0 -461
- package/.output/server/_libs/domutils.mjs +0 -868
- package/.output/server/_libs/es-toolkit.mjs +0 -1737
- package/.output/server/_libs/eventemitter3.mjs +0 -236
- package/.output/server/_libs/html-dom-parser+htmlparser2.mjs +0 -1560
- package/.output/server/_libs/html-react-parser+[...].mjs +0 -1360
- package/.output/server/_libs/react-is.mjs +0 -48
- package/.output/server/_libs/react-redux+[...].mjs +0 -205
- package/.output/server/_libs/recharts+victory-vendor.mjs +0 -17303
- package/.output/server/_libs/uiw__codemirror-themes.mjs +0 -32
- package/.output/server/_libs/uiw__react-codemirror.mjs +0 -354
- package/.output/server/_ssr/CodeField-B7oOmmwH.mjs +0 -143
- package/.output/server/_ssr/DashboardView-BF7PciP7.mjs +0 -2736
- package/.output/server/_ssr/LoopPlaybook-DC7QVvPY.mjs +0 -2105
- package/.output/server/_ssr/LoopView-DwSrm9Ja.mjs +0 -1300
- package/.output/server/_ssr/Modal-MaCG52Pv.mjs +0 -49
- package/.output/server/_ssr/artifactView-iuPsp5aa.mjs +0 -304
- package/.output/server/_ssr/artifacts-jQ-bfdhI.mjs +0 -2
- package/.output/server/_ssr/boot-CsEFT53K.mjs +0 -2
- package/.output/server/_ssr/db-CXownd1H.mjs +0 -2
- package/.output/server/_ssr/invite._token-CWl6kipD.mjs +0 -28
- package/.output/server/_ssr/logger-Gy-47z3k.mjs +0 -2
- package/.output/server/_ssr/loopApi-8_KgBapr.mjs +0 -109
- package/.output/server/_ssr/loopApi-ABi9SgWS.mjs +0 -564
- package/.output/server/_ssr/loops._loopId-SON_t43g.mjs +0 -30
- package/.output/server/_ssr/loops._loopId-p1KWsvMM.mjs +0 -1477
- package/.output/server/_ssr/notifyFns-BUCePuF3.mjs +0 -118
- package/.output/server/_ssr/router-Czxvra6l.mjs +0 -685
- package/.output/server/_ssr/runDiff--qLtU4FI.mjs +0 -2
- package/.output/server/_ssr/store-40eVzW1S.mjs +0 -2
- package/.output/server/_ssr/tokens-CbfoRC_s.mjs +0 -2
- package/.output/server/drizzle/0001_naive_silver_fox.sql +0 -25
- package/.output/server/drizzle/0002_funny_sage.sql +0 -12
- package/.output/server/drizzle/0003_optimal_slapstick.sql +0 -102
- package/.output/server/drizzle/0004_remove_grok_agent.sql +0 -5
- package/.output/server/drizzle/0005_heavy_gauntlet.sql +0 -8
- package/.output/server/drizzle/0006_tranquil_sharon_carter.sql +0 -1
- package/.output/server/drizzle/0007_faulty_starbolt.sql +0 -30
- package/.output/server/drizzle/0008_durable_lifecycle_evidence.sql +0 -15
- package/.output/server/drizzle/0009_ordinary_electro.sql +0 -1
- package/.output/server/drizzle/0010_workable_rage.sql +0 -14
- package/.output/server/drizzle/0011_steep_marvel_zombies.sql +0 -3
- package/.output/server/drizzle/0012_blocked_run_status.sql +0 -12
- package/.output/server/drizzle/0013_drop_run_outcome.sql +0 -2
- package/.output/server/drizzle/0014_luxuriant_scrambler.sql +0 -5
- package/.output/server/drizzle/0015_run_history_foundation.sql +0 -43
- package/.output/server/drizzle/0016_plural_machine_runs.sql +0 -4
- package/.output/server/drizzle/meta/0000_snapshot.json +0 -1333
- package/.output/server/drizzle/meta/0001_snapshot.json +0 -1498
- package/.output/server/drizzle/meta/0002_snapshot.json +0 -1576
- package/.output/server/drizzle/meta/0003_snapshot.json +0 -1666
- package/.output/server/drizzle/meta/0005_snapshot.json +0 -1666
- package/.output/server/drizzle/meta/0006_snapshot.json +0 -1672
- package/.output/server/drizzle/meta/0007_snapshot.json +0 -1787
- package/.output/server/drizzle/meta/0009_snapshot.json +0 -1793
- package/.output/server/drizzle/meta/0010_snapshot.json +0 -1891
- package/.output/server/drizzle/meta/0011_snapshot.json +0 -1872
- package/drizzle/0001_naive_silver_fox.sql +0 -25
- package/drizzle/0002_funny_sage.sql +0 -12
- package/drizzle/0003_optimal_slapstick.sql +0 -102
- package/drizzle/0004_remove_grok_agent.sql +0 -5
- package/drizzle/0005_heavy_gauntlet.sql +0 -8
- package/drizzle/0006_tranquil_sharon_carter.sql +0 -1
- package/drizzle/0007_faulty_starbolt.sql +0 -30
- package/drizzle/0008_durable_lifecycle_evidence.sql +0 -15
- package/drizzle/0009_ordinary_electro.sql +0 -1
- package/drizzle/0010_workable_rage.sql +0 -14
- package/drizzle/0011_steep_marvel_zombies.sql +0 -3
- package/drizzle/0012_blocked_run_status.sql +0 -12
- package/drizzle/0013_drop_run_outcome.sql +0 -2
- package/drizzle/0014_luxuriant_scrambler.sql +0 -5
- package/drizzle/0015_run_history_foundation.sql +0 -43
- package/drizzle/0016_plural_machine_runs.sql +0 -4
- package/drizzle/meta/0000_snapshot.json +0 -1333
- package/drizzle/meta/0001_snapshot.json +0 -1498
- package/drizzle/meta/0002_snapshot.json +0 -1576
- package/drizzle/meta/0003_snapshot.json +0 -1666
- package/drizzle/meta/0005_snapshot.json +0 -1666
- package/drizzle/meta/0006_snapshot.json +0 -1672
- package/drizzle/meta/0007_snapshot.json +0 -1787
- package/drizzle/meta/0009_snapshot.json +0 -1793
- package/drizzle/meta/0010_snapshot.json +0 -1891
- package/drizzle/meta/0011_snapshot.json +0 -1872
|
@@ -1,1560 +0,0 @@
|
|
|
1
|
-
import { a as __toCommonJS, n as __esmMin, r as __exportAll, t as __commonJSMin } from "../_runtime.mjs";
|
|
2
|
-
import { a as init_decode, c as htmlDecodeTree, d as dist_exports$1, f as init_dist$1, i as EntityDecoder, r as DecodingMode, s as xmlDecodeTree } from "./dom-serializer+[...].mjs";
|
|
3
|
-
import { n as dist_exports$2, r as init_dist$2, t as DomHandler } from "./domhandler.mjs";
|
|
4
|
-
import { n as init_dist$3, r as getFeed, t as dist_exports$3 } from "./domutils.mjs";
|
|
5
|
-
//#region ../../node_modules/.pnpm/html-dom-parser@8.0.0/node_modules/html-dom-parser/lib/server/utilities.js
|
|
6
|
-
var require_utilities$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
7
|
-
/**
|
|
8
|
-
* Sets root parent to null.
|
|
9
|
-
*
|
|
10
|
-
* @param nodes - Nodes.
|
|
11
|
-
* @returns - Nodes.
|
|
12
|
-
*/
|
|
13
|
-
function unsetRootParent(nodes) {
|
|
14
|
-
let index = 0;
|
|
15
|
-
const nodesLength = nodes.length;
|
|
16
|
-
for (; index < nodesLength; index++) {
|
|
17
|
-
const node = nodes[index];
|
|
18
|
-
node.parent = null;
|
|
19
|
-
}
|
|
20
|
-
return nodes;
|
|
21
|
-
}
|
|
22
|
-
exports.unsetRootParent = unsetRootParent;
|
|
23
|
-
}));
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region ../../node_modules/.pnpm/htmlparser2@12.0.0/node_modules/htmlparser2/dist/Tokenizer.js
|
|
26
|
-
function isWhitespace(c) {
|
|
27
|
-
return c === CharCodes.Space || c === CharCodes.NewLine || c === CharCodes.Tab || c === CharCodes.FormFeed || c === CharCodes.CarriageReturn;
|
|
28
|
-
}
|
|
29
|
-
function isEndOfTagSection(c) {
|
|
30
|
-
return c === CharCodes.Slash || c === CharCodes.Gt || isWhitespace(c);
|
|
31
|
-
}
|
|
32
|
-
function isASCIIAlpha(c) {
|
|
33
|
-
return c >= CharCodes.LowerA && c <= CharCodes.LowerZ || c >= CharCodes.UpperA && c <= CharCodes.UpperZ;
|
|
34
|
-
}
|
|
35
|
-
var CharCodes, State, QuoteType, Sequences, specialStartSequences, Tokenizer;
|
|
36
|
-
var init_Tokenizer = __esmMin((() => {
|
|
37
|
-
init_decode();
|
|
38
|
-
(function(CharCodes) {
|
|
39
|
-
CharCodes[CharCodes["Tab"] = 9] = "Tab";
|
|
40
|
-
CharCodes[CharCodes["NewLine"] = 10] = "NewLine";
|
|
41
|
-
CharCodes[CharCodes["FormFeed"] = 12] = "FormFeed";
|
|
42
|
-
CharCodes[CharCodes["CarriageReturn"] = 13] = "CarriageReturn";
|
|
43
|
-
CharCodes[CharCodes["Space"] = 32] = "Space";
|
|
44
|
-
CharCodes[CharCodes["ExclamationMark"] = 33] = "ExclamationMark";
|
|
45
|
-
CharCodes[CharCodes["Number"] = 35] = "Number";
|
|
46
|
-
CharCodes[CharCodes["Amp"] = 38] = "Amp";
|
|
47
|
-
CharCodes[CharCodes["SingleQuote"] = 39] = "SingleQuote";
|
|
48
|
-
CharCodes[CharCodes["DoubleQuote"] = 34] = "DoubleQuote";
|
|
49
|
-
CharCodes[CharCodes["Dash"] = 45] = "Dash";
|
|
50
|
-
CharCodes[CharCodes["Slash"] = 47] = "Slash";
|
|
51
|
-
CharCodes[CharCodes["Zero"] = 48] = "Zero";
|
|
52
|
-
CharCodes[CharCodes["Nine"] = 57] = "Nine";
|
|
53
|
-
CharCodes[CharCodes["Semi"] = 59] = "Semi";
|
|
54
|
-
CharCodes[CharCodes["Lt"] = 60] = "Lt";
|
|
55
|
-
CharCodes[CharCodes["Eq"] = 61] = "Eq";
|
|
56
|
-
CharCodes[CharCodes["Gt"] = 62] = "Gt";
|
|
57
|
-
CharCodes[CharCodes["Questionmark"] = 63] = "Questionmark";
|
|
58
|
-
CharCodes[CharCodes["UpperA"] = 65] = "UpperA";
|
|
59
|
-
CharCodes[CharCodes["LowerA"] = 97] = "LowerA";
|
|
60
|
-
CharCodes[CharCodes["UpperF"] = 70] = "UpperF";
|
|
61
|
-
CharCodes[CharCodes["LowerF"] = 102] = "LowerF";
|
|
62
|
-
CharCodes[CharCodes["UpperZ"] = 90] = "UpperZ";
|
|
63
|
-
CharCodes[CharCodes["LowerZ"] = 122] = "LowerZ";
|
|
64
|
-
CharCodes[CharCodes["LowerX"] = 120] = "LowerX";
|
|
65
|
-
CharCodes[CharCodes["OpeningSquareBracket"] = 91] = "OpeningSquareBracket";
|
|
66
|
-
})(CharCodes || (CharCodes = {}));
|
|
67
|
-
(function(State) {
|
|
68
|
-
State[State["Text"] = 1] = "Text";
|
|
69
|
-
State[State["BeforeTagName"] = 2] = "BeforeTagName";
|
|
70
|
-
State[State["InTagName"] = 3] = "InTagName";
|
|
71
|
-
State[State["InSelfClosingTag"] = 4] = "InSelfClosingTag";
|
|
72
|
-
State[State["BeforeClosingTagName"] = 5] = "BeforeClosingTagName";
|
|
73
|
-
State[State["InClosingTagName"] = 6] = "InClosingTagName";
|
|
74
|
-
State[State["AfterClosingTagName"] = 7] = "AfterClosingTagName";
|
|
75
|
-
State[State["BeforeAttributeName"] = 8] = "BeforeAttributeName";
|
|
76
|
-
State[State["InAttributeName"] = 9] = "InAttributeName";
|
|
77
|
-
State[State["AfterAttributeName"] = 10] = "AfterAttributeName";
|
|
78
|
-
State[State["BeforeAttributeValue"] = 11] = "BeforeAttributeValue";
|
|
79
|
-
State[State["InAttributeValueDq"] = 12] = "InAttributeValueDq";
|
|
80
|
-
State[State["InAttributeValueSq"] = 13] = "InAttributeValueSq";
|
|
81
|
-
State[State["InAttributeValueNq"] = 14] = "InAttributeValueNq";
|
|
82
|
-
State[State["BeforeDeclaration"] = 15] = "BeforeDeclaration";
|
|
83
|
-
State[State["InDeclaration"] = 16] = "InDeclaration";
|
|
84
|
-
State[State["InProcessingInstruction"] = 17] = "InProcessingInstruction";
|
|
85
|
-
State[State["BeforeComment"] = 18] = "BeforeComment";
|
|
86
|
-
State[State["CDATASequence"] = 19] = "CDATASequence";
|
|
87
|
-
State[State["DeclarationSequence"] = 20] = "DeclarationSequence";
|
|
88
|
-
State[State["InSpecialComment"] = 21] = "InSpecialComment";
|
|
89
|
-
State[State["InCommentLike"] = 22] = "InCommentLike";
|
|
90
|
-
State[State["SpecialStartSequence"] = 23] = "SpecialStartSequence";
|
|
91
|
-
State[State["InSpecialTag"] = 24] = "InSpecialTag";
|
|
92
|
-
State[State["InPlainText"] = 25] = "InPlainText";
|
|
93
|
-
State[State["InEntity"] = 26] = "InEntity";
|
|
94
|
-
})(State || (State = {}));
|
|
95
|
-
(function(QuoteType) {
|
|
96
|
-
QuoteType[QuoteType["NoValue"] = 0] = "NoValue";
|
|
97
|
-
QuoteType[QuoteType["Unquoted"] = 1] = "Unquoted";
|
|
98
|
-
QuoteType[QuoteType["Single"] = 2] = "Single";
|
|
99
|
-
QuoteType[QuoteType["Double"] = 3] = "Double";
|
|
100
|
-
})(QuoteType || (QuoteType = {}));
|
|
101
|
-
Sequences = {
|
|
102
|
-
Empty: new Uint8Array(0),
|
|
103
|
-
Cdata: new Uint8Array([
|
|
104
|
-
67,
|
|
105
|
-
68,
|
|
106
|
-
65,
|
|
107
|
-
84,
|
|
108
|
-
65,
|
|
109
|
-
91
|
|
110
|
-
]),
|
|
111
|
-
CdataEnd: new Uint8Array([
|
|
112
|
-
93,
|
|
113
|
-
93,
|
|
114
|
-
62
|
|
115
|
-
]),
|
|
116
|
-
CommentEnd: new Uint8Array([
|
|
117
|
-
45,
|
|
118
|
-
45,
|
|
119
|
-
33,
|
|
120
|
-
62
|
|
121
|
-
]),
|
|
122
|
-
Doctype: new Uint8Array([
|
|
123
|
-
100,
|
|
124
|
-
111,
|
|
125
|
-
99,
|
|
126
|
-
116,
|
|
127
|
-
121,
|
|
128
|
-
112,
|
|
129
|
-
101
|
|
130
|
-
]),
|
|
131
|
-
IframeEnd: new Uint8Array([
|
|
132
|
-
60,
|
|
133
|
-
47,
|
|
134
|
-
105,
|
|
135
|
-
102,
|
|
136
|
-
114,
|
|
137
|
-
97,
|
|
138
|
-
109,
|
|
139
|
-
101
|
|
140
|
-
]),
|
|
141
|
-
NoembedEnd: new Uint8Array([
|
|
142
|
-
60,
|
|
143
|
-
47,
|
|
144
|
-
110,
|
|
145
|
-
111,
|
|
146
|
-
101,
|
|
147
|
-
109,
|
|
148
|
-
98,
|
|
149
|
-
101,
|
|
150
|
-
100
|
|
151
|
-
]),
|
|
152
|
-
NoframesEnd: new Uint8Array([
|
|
153
|
-
60,
|
|
154
|
-
47,
|
|
155
|
-
110,
|
|
156
|
-
111,
|
|
157
|
-
102,
|
|
158
|
-
114,
|
|
159
|
-
97,
|
|
160
|
-
109,
|
|
161
|
-
101,
|
|
162
|
-
115
|
|
163
|
-
]),
|
|
164
|
-
Plaintext: new Uint8Array([
|
|
165
|
-
60,
|
|
166
|
-
47,
|
|
167
|
-
112,
|
|
168
|
-
108,
|
|
169
|
-
97,
|
|
170
|
-
105,
|
|
171
|
-
110,
|
|
172
|
-
116,
|
|
173
|
-
101,
|
|
174
|
-
120,
|
|
175
|
-
116
|
|
176
|
-
]),
|
|
177
|
-
ScriptEnd: new Uint8Array([
|
|
178
|
-
60,
|
|
179
|
-
47,
|
|
180
|
-
115,
|
|
181
|
-
99,
|
|
182
|
-
114,
|
|
183
|
-
105,
|
|
184
|
-
112,
|
|
185
|
-
116
|
|
186
|
-
]),
|
|
187
|
-
StyleEnd: new Uint8Array([
|
|
188
|
-
60,
|
|
189
|
-
47,
|
|
190
|
-
115,
|
|
191
|
-
116,
|
|
192
|
-
121,
|
|
193
|
-
108,
|
|
194
|
-
101
|
|
195
|
-
]),
|
|
196
|
-
TitleEnd: new Uint8Array([
|
|
197
|
-
60,
|
|
198
|
-
47,
|
|
199
|
-
116,
|
|
200
|
-
105,
|
|
201
|
-
116,
|
|
202
|
-
108,
|
|
203
|
-
101
|
|
204
|
-
]),
|
|
205
|
-
TextareaEnd: new Uint8Array([
|
|
206
|
-
60,
|
|
207
|
-
47,
|
|
208
|
-
116,
|
|
209
|
-
101,
|
|
210
|
-
120,
|
|
211
|
-
116,
|
|
212
|
-
97,
|
|
213
|
-
114,
|
|
214
|
-
101,
|
|
215
|
-
97
|
|
216
|
-
]),
|
|
217
|
-
XmpEnd: new Uint8Array([
|
|
218
|
-
60,
|
|
219
|
-
47,
|
|
220
|
-
120,
|
|
221
|
-
109,
|
|
222
|
-
112
|
|
223
|
-
])
|
|
224
|
-
};
|
|
225
|
-
specialStartSequences = new Map([
|
|
226
|
-
[Sequences.IframeEnd[2], Sequences.IframeEnd],
|
|
227
|
-
[Sequences.NoembedEnd[2], Sequences.NoembedEnd],
|
|
228
|
-
[Sequences.Plaintext[2], Sequences.Plaintext],
|
|
229
|
-
[Sequences.ScriptEnd[2], Sequences.ScriptEnd],
|
|
230
|
-
[Sequences.TitleEnd[2], Sequences.TitleEnd],
|
|
231
|
-
[Sequences.XmpEnd[2], Sequences.XmpEnd]
|
|
232
|
-
]);
|
|
233
|
-
Tokenizer = class {
|
|
234
|
-
cbs;
|
|
235
|
-
/** The current state the tokenizer is in. */
|
|
236
|
-
state = State.Text;
|
|
237
|
-
/** The read buffer. */
|
|
238
|
-
buffer = "";
|
|
239
|
-
/** The beginning of the section that is currently being read. */
|
|
240
|
-
sectionStart = 0;
|
|
241
|
-
/** The index within the buffer that we are currently looking at. */
|
|
242
|
-
index = 0;
|
|
243
|
-
/** The start of the last entity. */
|
|
244
|
-
entityStart = 0;
|
|
245
|
-
/** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
|
|
246
|
-
baseState = State.Text;
|
|
247
|
-
/** For special parsing behavior inside of script and style tags. */
|
|
248
|
-
isSpecial = false;
|
|
249
|
-
/** Indicates whether the tokenizer has been paused. */
|
|
250
|
-
running = true;
|
|
251
|
-
/** The offset of the current buffer. */
|
|
252
|
-
offset = 0;
|
|
253
|
-
xmlMode;
|
|
254
|
-
decodeEntities;
|
|
255
|
-
recognizeSelfClosing;
|
|
256
|
-
entityDecoder;
|
|
257
|
-
constructor({ xmlMode = false, decodeEntities = true, recognizeSelfClosing = xmlMode }, cbs) {
|
|
258
|
-
this.cbs = cbs;
|
|
259
|
-
this.xmlMode = xmlMode;
|
|
260
|
-
this.decodeEntities = decodeEntities;
|
|
261
|
-
this.recognizeSelfClosing = recognizeSelfClosing;
|
|
262
|
-
this.entityDecoder = new EntityDecoder(xmlMode ? xmlDecodeTree : htmlDecodeTree, (cp, consumed) => this.emitCodePoint(cp, consumed));
|
|
263
|
-
}
|
|
264
|
-
reset() {
|
|
265
|
-
this.state = State.Text;
|
|
266
|
-
this.buffer = "";
|
|
267
|
-
this.sectionStart = 0;
|
|
268
|
-
this.index = 0;
|
|
269
|
-
this.baseState = State.Text;
|
|
270
|
-
this.isSpecial = false;
|
|
271
|
-
this.currentSequence = Sequences.Empty;
|
|
272
|
-
this.sequenceIndex = 0;
|
|
273
|
-
this.running = true;
|
|
274
|
-
this.offset = 0;
|
|
275
|
-
}
|
|
276
|
-
write(chunk) {
|
|
277
|
-
this.offset += this.buffer.length;
|
|
278
|
-
this.buffer = chunk;
|
|
279
|
-
this.parse();
|
|
280
|
-
}
|
|
281
|
-
end() {
|
|
282
|
-
if (this.running) this.finish();
|
|
283
|
-
}
|
|
284
|
-
pause() {
|
|
285
|
-
this.running = false;
|
|
286
|
-
}
|
|
287
|
-
resume() {
|
|
288
|
-
this.running = true;
|
|
289
|
-
if (this.index < this.buffer.length + this.offset) this.parse();
|
|
290
|
-
}
|
|
291
|
-
stateText(c) {
|
|
292
|
-
if (c === CharCodes.Lt || !this.decodeEntities && this.fastForwardTo(CharCodes.Lt)) {
|
|
293
|
-
if (this.index > this.sectionStart) this.cbs.ontext(this.sectionStart, this.index);
|
|
294
|
-
this.state = State.BeforeTagName;
|
|
295
|
-
this.sectionStart = this.index;
|
|
296
|
-
} else if (this.decodeEntities && c === CharCodes.Amp) this.startEntity();
|
|
297
|
-
}
|
|
298
|
-
currentSequence = Sequences.Empty;
|
|
299
|
-
sequenceIndex = 0;
|
|
300
|
-
enterTagBody() {
|
|
301
|
-
if (this.currentSequence === Sequences.Plaintext) {
|
|
302
|
-
this.currentSequence = Sequences.Empty;
|
|
303
|
-
this.state = State.InPlainText;
|
|
304
|
-
} else if (this.isSpecial) {
|
|
305
|
-
this.state = State.InSpecialTag;
|
|
306
|
-
this.sequenceIndex = 0;
|
|
307
|
-
} else this.state = State.Text;
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Match the opening tag name against an HTML text-only tag sequence.
|
|
311
|
-
*
|
|
312
|
-
* Some tags share an initial prefix (`script`/`style`, `title`/`textarea`,
|
|
313
|
-
* `noembed`/`noframes`), so we may switch to an alternate sequence at the
|
|
314
|
-
* first distinguishing byte. On a successful full match we fall back to
|
|
315
|
-
* the normal tag-name state; a later `>` will enter raw-text, RCDATA, or
|
|
316
|
-
* plaintext mode based on `currentSequence` / `isSpecial`.
|
|
317
|
-
* @param c Current character code point.
|
|
318
|
-
*/
|
|
319
|
-
stateSpecialStartSequence(c) {
|
|
320
|
-
const lower = c | 32;
|
|
321
|
-
if (this.sequenceIndex < this.currentSequence.length) {
|
|
322
|
-
if (lower === this.currentSequence[this.sequenceIndex]) {
|
|
323
|
-
this.sequenceIndex++;
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
if (this.sequenceIndex === 3) {
|
|
327
|
-
if (this.currentSequence === Sequences.ScriptEnd && lower === Sequences.StyleEnd[3]) {
|
|
328
|
-
this.currentSequence = Sequences.StyleEnd;
|
|
329
|
-
this.sequenceIndex = 4;
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
if (this.currentSequence === Sequences.TitleEnd && lower === Sequences.TextareaEnd[3]) {
|
|
333
|
-
this.currentSequence = Sequences.TextareaEnd;
|
|
334
|
-
this.sequenceIndex = 4;
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
} else if (this.sequenceIndex === 4 && this.currentSequence === Sequences.NoembedEnd && lower === Sequences.NoframesEnd[4]) {
|
|
338
|
-
this.currentSequence = Sequences.NoframesEnd;
|
|
339
|
-
this.sequenceIndex = 5;
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
} else if (isEndOfTagSection(c)) {
|
|
343
|
-
this.sequenceIndex = 0;
|
|
344
|
-
this.state = State.InTagName;
|
|
345
|
-
this.stateInTagName(c);
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
this.isSpecial = false;
|
|
349
|
-
this.currentSequence = Sequences.Empty;
|
|
350
|
-
this.sequenceIndex = 0;
|
|
351
|
-
this.state = State.InTagName;
|
|
352
|
-
this.stateInTagName(c);
|
|
353
|
-
}
|
|
354
|
-
stateCDATASequence(c) {
|
|
355
|
-
if (c === Sequences.Cdata[this.sequenceIndex]) {
|
|
356
|
-
if (++this.sequenceIndex === Sequences.Cdata.length) {
|
|
357
|
-
this.state = State.InCommentLike;
|
|
358
|
-
this.currentSequence = Sequences.CdataEnd;
|
|
359
|
-
this.sequenceIndex = 0;
|
|
360
|
-
this.sectionStart = this.index + 1;
|
|
361
|
-
}
|
|
362
|
-
} else {
|
|
363
|
-
this.sequenceIndex = 0;
|
|
364
|
-
if (this.xmlMode) {
|
|
365
|
-
this.state = State.InDeclaration;
|
|
366
|
-
this.stateInDeclaration(c);
|
|
367
|
-
} else {
|
|
368
|
-
this.state = State.InSpecialComment;
|
|
369
|
-
this.stateInSpecialComment(c);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* When we wait for one specific character, we can speed things up
|
|
375
|
-
* by skipping through the buffer until we find it.
|
|
376
|
-
* @param c Current character code point.
|
|
377
|
-
* @returns Whether the character was found.
|
|
378
|
-
*/
|
|
379
|
-
fastForwardTo(c) {
|
|
380
|
-
while (++this.index < this.buffer.length + this.offset) if (this.buffer.charCodeAt(this.index - this.offset) === c) return true;
|
|
381
|
-
this.index = this.buffer.length + this.offset - 1;
|
|
382
|
-
return false;
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Emit a comment token and return to the text state.
|
|
386
|
-
* @param offset Number of characters in the end sequence that have already been matched.
|
|
387
|
-
*/
|
|
388
|
-
emitComment(offset) {
|
|
389
|
-
this.cbs.oncomment(this.sectionStart, this.index, offset);
|
|
390
|
-
this.sequenceIndex = 0;
|
|
391
|
-
this.sectionStart = this.index + 1;
|
|
392
|
-
this.state = State.Text;
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Comments and CDATA end with `-->` and `]]>`.
|
|
396
|
-
*
|
|
397
|
-
* Their common qualities are:
|
|
398
|
-
* - Their end sequences have a distinct character they start with.
|
|
399
|
-
* - That character is then repeated, so we have to check multiple repeats.
|
|
400
|
-
* - All characters but the start character of the sequence can be skipped.
|
|
401
|
-
* @param c Current character code point.
|
|
402
|
-
*/
|
|
403
|
-
stateInCommentLike(c) {
|
|
404
|
-
if (!this.xmlMode && this.currentSequence === Sequences.CommentEnd && this.sequenceIndex <= 1 && this.index === this.sectionStart + this.sequenceIndex && c === CharCodes.Gt) this.emitComment(this.sequenceIndex);
|
|
405
|
-
else if (this.currentSequence === Sequences.CommentEnd && this.sequenceIndex === 2 && c === CharCodes.Gt) this.emitComment(2);
|
|
406
|
-
else if (this.currentSequence === Sequences.CommentEnd && this.sequenceIndex === this.currentSequence.length - 1 && c !== CharCodes.Gt) this.sequenceIndex = Number(c === CharCodes.Dash);
|
|
407
|
-
else if (c === this.currentSequence[this.sequenceIndex]) {
|
|
408
|
-
if (++this.sequenceIndex === this.currentSequence.length) {
|
|
409
|
-
if (this.currentSequence === Sequences.CdataEnd) this.cbs.oncdata(this.sectionStart, this.index, 2);
|
|
410
|
-
else this.cbs.oncomment(this.sectionStart, this.index, 3);
|
|
411
|
-
this.sequenceIndex = 0;
|
|
412
|
-
this.sectionStart = this.index + 1;
|
|
413
|
-
this.state = State.Text;
|
|
414
|
-
}
|
|
415
|
-
} else if (this.sequenceIndex === 0) {
|
|
416
|
-
if (this.fastForwardTo(this.currentSequence[0])) this.sequenceIndex = 1;
|
|
417
|
-
} else if (c !== this.currentSequence[this.sequenceIndex - 1]) this.sequenceIndex = 0;
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name.
|
|
421
|
-
*
|
|
422
|
-
* XML allows a lot more characters here (@see https://www.w3.org/TR/REC-xml/#NT-NameStartChar).
|
|
423
|
-
* We allow anything that wouldn't end the tag.
|
|
424
|
-
* @param c Current character code point.
|
|
425
|
-
*/
|
|
426
|
-
isTagStartChar(c) {
|
|
427
|
-
return this.xmlMode ? !isEndOfTagSection(c) : isASCIIAlpha(c);
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* Scan raw-text / RCDATA content for the matching end tag.
|
|
431
|
-
*
|
|
432
|
-
* For RCDATA tags (`<title>`, `<textarea>`) entities are decoded inline.
|
|
433
|
-
* For raw-text tags (`<script>`, `<style>`, etc.) we fast-forward to `<`.
|
|
434
|
-
* @param c Current character code point.
|
|
435
|
-
*/
|
|
436
|
-
stateInSpecialTag(c) {
|
|
437
|
-
if (this.sequenceIndex === this.currentSequence.length) {
|
|
438
|
-
if (isEndOfTagSection(c)) {
|
|
439
|
-
const endOfText = this.index - this.currentSequence.length;
|
|
440
|
-
if (this.sectionStart < endOfText) {
|
|
441
|
-
const actualIndex = this.index;
|
|
442
|
-
this.index = endOfText;
|
|
443
|
-
this.cbs.ontext(this.sectionStart, endOfText);
|
|
444
|
-
this.index = actualIndex;
|
|
445
|
-
}
|
|
446
|
-
this.isSpecial = false;
|
|
447
|
-
this.sectionStart = endOfText + 2;
|
|
448
|
-
this.stateInClosingTagName(c);
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
this.sequenceIndex = 0;
|
|
452
|
-
}
|
|
453
|
-
if ((c | 32) === this.currentSequence[this.sequenceIndex]) this.sequenceIndex += 1;
|
|
454
|
-
else if (this.sequenceIndex === 0) {
|
|
455
|
-
if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd) {
|
|
456
|
-
if (this.decodeEntities && c === CharCodes.Amp) this.startEntity();
|
|
457
|
-
} else if (this.fastForwardTo(CharCodes.Lt)) this.sequenceIndex = 1;
|
|
458
|
-
} else this.sequenceIndex = Number(c === CharCodes.Lt);
|
|
459
|
-
}
|
|
460
|
-
stateBeforeTagName(c) {
|
|
461
|
-
if (c === CharCodes.ExclamationMark) {
|
|
462
|
-
this.state = State.BeforeDeclaration;
|
|
463
|
-
this.sectionStart = this.index + 1;
|
|
464
|
-
} else if (c === CharCodes.Questionmark) if (this.xmlMode) {
|
|
465
|
-
this.state = State.InProcessingInstruction;
|
|
466
|
-
this.sequenceIndex = 0;
|
|
467
|
-
this.sectionStart = this.index + 1;
|
|
468
|
-
} else {
|
|
469
|
-
this.state = State.InSpecialComment;
|
|
470
|
-
this.sectionStart = this.index;
|
|
471
|
-
}
|
|
472
|
-
else if (this.isTagStartChar(c)) {
|
|
473
|
-
this.sectionStart = this.index;
|
|
474
|
-
const special = this.xmlMode || this.cbs.isInForeignContext?.() ? void 0 : specialStartSequences.get(c | 32);
|
|
475
|
-
if (special === void 0) this.state = State.InTagName;
|
|
476
|
-
else {
|
|
477
|
-
this.isSpecial = true;
|
|
478
|
-
this.currentSequence = special;
|
|
479
|
-
this.sequenceIndex = 3;
|
|
480
|
-
this.state = State.SpecialStartSequence;
|
|
481
|
-
}
|
|
482
|
-
} else if (c === CharCodes.Slash) this.state = State.BeforeClosingTagName;
|
|
483
|
-
else {
|
|
484
|
-
this.state = State.Text;
|
|
485
|
-
this.stateText(c);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
stateInTagName(c) {
|
|
489
|
-
if (isEndOfTagSection(c)) {
|
|
490
|
-
this.cbs.onopentagname(this.sectionStart, this.index);
|
|
491
|
-
this.sectionStart = -1;
|
|
492
|
-
this.state = State.BeforeAttributeName;
|
|
493
|
-
this.stateBeforeAttributeName(c);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
stateBeforeClosingTagName(c) {
|
|
497
|
-
if (isWhitespace(c)) if (this.xmlMode) {} else {
|
|
498
|
-
this.state = State.InSpecialComment;
|
|
499
|
-
this.sectionStart = this.index;
|
|
500
|
-
}
|
|
501
|
-
else if (c === CharCodes.Gt) {
|
|
502
|
-
this.state = State.Text;
|
|
503
|
-
if (!this.xmlMode) this.sectionStart = this.index + 1;
|
|
504
|
-
} else {
|
|
505
|
-
this.state = this.isTagStartChar(c) ? State.InClosingTagName : State.InSpecialComment;
|
|
506
|
-
this.sectionStart = this.index;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
stateInClosingTagName(c) {
|
|
510
|
-
if (isEndOfTagSection(c)) {
|
|
511
|
-
this.cbs.onclosetag(this.sectionStart, this.index);
|
|
512
|
-
this.sectionStart = -1;
|
|
513
|
-
this.state = State.AfterClosingTagName;
|
|
514
|
-
this.stateAfterClosingTagName(c);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
stateAfterClosingTagName(c) {
|
|
518
|
-
if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
|
|
519
|
-
this.state = State.Text;
|
|
520
|
-
this.sectionStart = this.index + 1;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
stateBeforeAttributeName(c) {
|
|
524
|
-
if (c === CharCodes.Gt) {
|
|
525
|
-
this.cbs.onopentagend(this.index);
|
|
526
|
-
this.enterTagBody();
|
|
527
|
-
this.sectionStart = this.index + 1;
|
|
528
|
-
} else if (c === CharCodes.Slash) this.state = State.InSelfClosingTag;
|
|
529
|
-
else if (!isWhitespace(c)) {
|
|
530
|
-
this.state = State.InAttributeName;
|
|
531
|
-
this.sectionStart = this.index;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* Handle `/` before `>` in an opening tag.
|
|
536
|
-
*
|
|
537
|
-
* In HTML mode, text-only tags ignore the self-closing flag and still enter
|
|
538
|
-
* their raw-text/RCDATA/plaintext state unless self-closing tags are being
|
|
539
|
-
* recognized. In XML mode, or for ordinary tags, the tokenizer returns to
|
|
540
|
-
* regular text parsing after emitting the self-closing callback.
|
|
541
|
-
* @param c Current character code point.
|
|
542
|
-
*/
|
|
543
|
-
stateInSelfClosingTag(c) {
|
|
544
|
-
if (c === CharCodes.Gt) {
|
|
545
|
-
this.cbs.onselfclosingtag(this.index);
|
|
546
|
-
this.sectionStart = this.index + 1;
|
|
547
|
-
if (!this.recognizeSelfClosing) {
|
|
548
|
-
this.enterTagBody();
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
this.state = State.Text;
|
|
552
|
-
this.isSpecial = false;
|
|
553
|
-
this.currentSequence = Sequences.Empty;
|
|
554
|
-
} else if (!isWhitespace(c)) {
|
|
555
|
-
this.state = State.BeforeAttributeName;
|
|
556
|
-
this.stateBeforeAttributeName(c);
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
stateInAttributeName(c) {
|
|
560
|
-
if (c === CharCodes.Eq || isEndOfTagSection(c)) {
|
|
561
|
-
this.cbs.onattribname(this.sectionStart, this.index);
|
|
562
|
-
this.sectionStart = this.index;
|
|
563
|
-
this.state = State.AfterAttributeName;
|
|
564
|
-
this.stateAfterAttributeName(c);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
stateAfterAttributeName(c) {
|
|
568
|
-
if (c === CharCodes.Eq) this.state = State.BeforeAttributeValue;
|
|
569
|
-
else if (c === CharCodes.Slash || c === CharCodes.Gt) {
|
|
570
|
-
this.cbs.onattribend(QuoteType.NoValue, this.sectionStart);
|
|
571
|
-
this.sectionStart = -1;
|
|
572
|
-
this.state = State.BeforeAttributeName;
|
|
573
|
-
this.stateBeforeAttributeName(c);
|
|
574
|
-
} else if (!isWhitespace(c)) {
|
|
575
|
-
this.cbs.onattribend(QuoteType.NoValue, this.sectionStart);
|
|
576
|
-
this.state = State.InAttributeName;
|
|
577
|
-
this.sectionStart = this.index;
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
stateBeforeAttributeValue(c) {
|
|
581
|
-
if (c === CharCodes.DoubleQuote) {
|
|
582
|
-
this.state = State.InAttributeValueDq;
|
|
583
|
-
this.sectionStart = this.index + 1;
|
|
584
|
-
} else if (c === CharCodes.SingleQuote) {
|
|
585
|
-
this.state = State.InAttributeValueSq;
|
|
586
|
-
this.sectionStart = this.index + 1;
|
|
587
|
-
} else if (!isWhitespace(c)) {
|
|
588
|
-
this.sectionStart = this.index;
|
|
589
|
-
this.state = State.InAttributeValueNq;
|
|
590
|
-
this.stateInAttributeValueNoQuotes(c);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
handleInAttributeValue(c, quote) {
|
|
594
|
-
if (c === quote || !this.decodeEntities && this.fastForwardTo(quote)) {
|
|
595
|
-
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
596
|
-
this.sectionStart = -1;
|
|
597
|
-
this.cbs.onattribend(quote === CharCodes.DoubleQuote ? QuoteType.Double : QuoteType.Single, this.index + 1);
|
|
598
|
-
this.state = State.BeforeAttributeName;
|
|
599
|
-
} else if (this.decodeEntities && c === CharCodes.Amp) this.startEntity();
|
|
600
|
-
}
|
|
601
|
-
stateInAttributeValueDoubleQuotes(c) {
|
|
602
|
-
this.handleInAttributeValue(c, CharCodes.DoubleQuote);
|
|
603
|
-
}
|
|
604
|
-
stateInAttributeValueSingleQuotes(c) {
|
|
605
|
-
this.handleInAttributeValue(c, CharCodes.SingleQuote);
|
|
606
|
-
}
|
|
607
|
-
stateInAttributeValueNoQuotes(c) {
|
|
608
|
-
if (isWhitespace(c) || c === CharCodes.Gt) {
|
|
609
|
-
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
610
|
-
this.sectionStart = -1;
|
|
611
|
-
this.cbs.onattribend(QuoteType.Unquoted, this.index);
|
|
612
|
-
this.state = State.BeforeAttributeName;
|
|
613
|
-
this.stateBeforeAttributeName(c);
|
|
614
|
-
} else if (this.decodeEntities && c === CharCodes.Amp) this.startEntity();
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* Distinguish between CDATA, declarations, HTML comments, and HTML bogus
|
|
618
|
-
* comments after `<!`.
|
|
619
|
-
*
|
|
620
|
-
* In HTML mode, only real comments and doctypes stay on declaration paths;
|
|
621
|
-
* everything else becomes a bogus comment terminated by the next `>`.
|
|
622
|
-
* @param c Current character code point.
|
|
623
|
-
*/
|
|
624
|
-
stateBeforeDeclaration(c) {
|
|
625
|
-
if (c === CharCodes.OpeningSquareBracket) {
|
|
626
|
-
this.state = State.CDATASequence;
|
|
627
|
-
this.sequenceIndex = 0;
|
|
628
|
-
} else if (this.xmlMode) this.state = c === CharCodes.Dash ? State.BeforeComment : State.InDeclaration;
|
|
629
|
-
else if ((c | 32) === Sequences.Doctype[0]) {
|
|
630
|
-
this.state = State.DeclarationSequence;
|
|
631
|
-
this.currentSequence = Sequences.Doctype;
|
|
632
|
-
this.sequenceIndex = 1;
|
|
633
|
-
} else if (c === CharCodes.Gt) {
|
|
634
|
-
this.cbs.oncomment(this.sectionStart, this.index, 0);
|
|
635
|
-
this.state = State.Text;
|
|
636
|
-
this.sectionStart = this.index + 1;
|
|
637
|
-
} else if (c === CharCodes.Dash) this.state = State.BeforeComment;
|
|
638
|
-
else this.state = State.InSpecialComment;
|
|
639
|
-
}
|
|
640
|
-
/**
|
|
641
|
-
* Continue matching `doctype` after `<!d`.
|
|
642
|
-
*
|
|
643
|
-
* A full `doctype` match stays on the declaration path; any other name falls
|
|
644
|
-
* back to an HTML bogus comment, which matches browser behavior for
|
|
645
|
-
* non-doctype `<!...>` constructs.
|
|
646
|
-
* @param c Current character code point.
|
|
647
|
-
*/
|
|
648
|
-
stateDeclarationSequence(c) {
|
|
649
|
-
if (this.sequenceIndex === this.currentSequence.length) {
|
|
650
|
-
this.state = State.InDeclaration;
|
|
651
|
-
this.stateInDeclaration(c);
|
|
652
|
-
} else if ((c | 32) === this.currentSequence[this.sequenceIndex]) this.sequenceIndex += 1;
|
|
653
|
-
else if (c === CharCodes.Gt) {
|
|
654
|
-
this.cbs.oncomment(this.sectionStart, this.index, 0);
|
|
655
|
-
this.state = State.Text;
|
|
656
|
-
this.sectionStart = this.index + 1;
|
|
657
|
-
} else this.state = State.InSpecialComment;
|
|
658
|
-
}
|
|
659
|
-
stateInDeclaration(c) {
|
|
660
|
-
if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
|
|
661
|
-
this.cbs.ondeclaration(this.sectionStart, this.index);
|
|
662
|
-
this.state = State.Text;
|
|
663
|
-
this.sectionStart = this.index + 1;
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
/**
|
|
667
|
-
* XML processing instructions (`<?...?>`).
|
|
668
|
-
*
|
|
669
|
-
* In HTML mode `<?` is routed to `InSpecialComment` instead, so this
|
|
670
|
-
* state is only reachable in XML mode.
|
|
671
|
-
* @param c Current character code point.
|
|
672
|
-
*/
|
|
673
|
-
stateInProcessingInstruction(c) {
|
|
674
|
-
if (c === CharCodes.Questionmark) this.sequenceIndex = 1;
|
|
675
|
-
else if (c === CharCodes.Gt && this.sequenceIndex === 1) {
|
|
676
|
-
this.cbs.onprocessinginstruction(this.sectionStart, this.index - 1);
|
|
677
|
-
this.sequenceIndex = 0;
|
|
678
|
-
this.state = State.Text;
|
|
679
|
-
this.sectionStart = this.index + 1;
|
|
680
|
-
} else this.sequenceIndex = Number(this.fastForwardTo(CharCodes.Questionmark));
|
|
681
|
-
}
|
|
682
|
-
stateBeforeComment(c) {
|
|
683
|
-
if (c === CharCodes.Dash) {
|
|
684
|
-
this.state = State.InCommentLike;
|
|
685
|
-
this.currentSequence = Sequences.CommentEnd;
|
|
686
|
-
this.sequenceIndex = 0;
|
|
687
|
-
this.sectionStart = this.index + 1;
|
|
688
|
-
} else if (this.xmlMode) this.state = State.InDeclaration;
|
|
689
|
-
else if (c === CharCodes.Gt) {
|
|
690
|
-
this.cbs.oncomment(this.sectionStart, this.index, 0);
|
|
691
|
-
this.state = State.Text;
|
|
692
|
-
this.sectionStart = this.index + 1;
|
|
693
|
-
} else this.state = State.InSpecialComment;
|
|
694
|
-
}
|
|
695
|
-
stateInSpecialComment(c) {
|
|
696
|
-
if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
|
|
697
|
-
this.cbs.oncomment(this.sectionStart, this.index, 0);
|
|
698
|
-
this.state = State.Text;
|
|
699
|
-
this.sectionStart = this.index + 1;
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
startEntity() {
|
|
703
|
-
this.baseState = this.state;
|
|
704
|
-
this.state = State.InEntity;
|
|
705
|
-
this.entityStart = this.index;
|
|
706
|
-
this.entityDecoder.startEntity(this.xmlMode ? DecodingMode.Strict : this.baseState === State.Text || this.baseState === State.InSpecialTag ? DecodingMode.Legacy : DecodingMode.Attribute);
|
|
707
|
-
}
|
|
708
|
-
stateInEntity() {
|
|
709
|
-
const indexInBuffer = this.index - this.offset;
|
|
710
|
-
const length = this.entityDecoder.write(this.buffer, indexInBuffer);
|
|
711
|
-
if (length >= 0) {
|
|
712
|
-
this.state = this.baseState;
|
|
713
|
-
if (length === 0) this.index -= 1;
|
|
714
|
-
} else {
|
|
715
|
-
if (indexInBuffer < this.buffer.length && this.buffer.charCodeAt(indexInBuffer) === CharCodes.Amp) {
|
|
716
|
-
this.state = this.baseState;
|
|
717
|
-
this.index -= 1;
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
this.index = this.offset + this.buffer.length - 1;
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* Remove data that has already been consumed from the buffer.
|
|
725
|
-
*/
|
|
726
|
-
cleanup() {
|
|
727
|
-
if (this.running && this.sectionStart !== this.index) {
|
|
728
|
-
if (this.state === State.Text || this.state === State.InPlainText || this.state === State.InSpecialTag && this.sequenceIndex === 0) {
|
|
729
|
-
this.cbs.ontext(this.sectionStart, this.index);
|
|
730
|
-
this.sectionStart = this.index;
|
|
731
|
-
} else if (this.state === State.InAttributeValueDq || this.state === State.InAttributeValueSq || this.state === State.InAttributeValueNq) {
|
|
732
|
-
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
733
|
-
this.sectionStart = this.index;
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
shouldContinue() {
|
|
738
|
-
return this.index < this.buffer.length + this.offset && this.running;
|
|
739
|
-
}
|
|
740
|
-
/**
|
|
741
|
-
* Iterates through the buffer, calling the function corresponding to the current state.
|
|
742
|
-
*
|
|
743
|
-
* States that are more likely to be hit are higher up, as a performance improvement.
|
|
744
|
-
*/
|
|
745
|
-
parse() {
|
|
746
|
-
while (this.shouldContinue()) {
|
|
747
|
-
const c = this.buffer.charCodeAt(this.index - this.offset);
|
|
748
|
-
switch (this.state) {
|
|
749
|
-
case State.Text:
|
|
750
|
-
this.stateText(c);
|
|
751
|
-
break;
|
|
752
|
-
case State.InPlainText:
|
|
753
|
-
this.index = this.buffer.length + this.offset - 1;
|
|
754
|
-
break;
|
|
755
|
-
case State.SpecialStartSequence:
|
|
756
|
-
this.stateSpecialStartSequence(c);
|
|
757
|
-
break;
|
|
758
|
-
case State.InSpecialTag:
|
|
759
|
-
this.stateInSpecialTag(c);
|
|
760
|
-
break;
|
|
761
|
-
case State.CDATASequence:
|
|
762
|
-
this.stateCDATASequence(c);
|
|
763
|
-
break;
|
|
764
|
-
case State.DeclarationSequence:
|
|
765
|
-
this.stateDeclarationSequence(c);
|
|
766
|
-
break;
|
|
767
|
-
case State.InAttributeValueDq:
|
|
768
|
-
this.stateInAttributeValueDoubleQuotes(c);
|
|
769
|
-
break;
|
|
770
|
-
case State.InAttributeName:
|
|
771
|
-
this.stateInAttributeName(c);
|
|
772
|
-
break;
|
|
773
|
-
case State.InCommentLike:
|
|
774
|
-
this.stateInCommentLike(c);
|
|
775
|
-
break;
|
|
776
|
-
case State.InSpecialComment:
|
|
777
|
-
this.stateInSpecialComment(c);
|
|
778
|
-
break;
|
|
779
|
-
case State.BeforeAttributeName:
|
|
780
|
-
this.stateBeforeAttributeName(c);
|
|
781
|
-
break;
|
|
782
|
-
case State.InTagName:
|
|
783
|
-
this.stateInTagName(c);
|
|
784
|
-
break;
|
|
785
|
-
case State.InClosingTagName:
|
|
786
|
-
this.stateInClosingTagName(c);
|
|
787
|
-
break;
|
|
788
|
-
case State.BeforeTagName:
|
|
789
|
-
this.stateBeforeTagName(c);
|
|
790
|
-
break;
|
|
791
|
-
case State.AfterAttributeName:
|
|
792
|
-
this.stateAfterAttributeName(c);
|
|
793
|
-
break;
|
|
794
|
-
case State.InAttributeValueSq:
|
|
795
|
-
this.stateInAttributeValueSingleQuotes(c);
|
|
796
|
-
break;
|
|
797
|
-
case State.BeforeAttributeValue:
|
|
798
|
-
this.stateBeforeAttributeValue(c);
|
|
799
|
-
break;
|
|
800
|
-
case State.BeforeClosingTagName:
|
|
801
|
-
this.stateBeforeClosingTagName(c);
|
|
802
|
-
break;
|
|
803
|
-
case State.AfterClosingTagName:
|
|
804
|
-
this.stateAfterClosingTagName(c);
|
|
805
|
-
break;
|
|
806
|
-
case State.InAttributeValueNq:
|
|
807
|
-
this.stateInAttributeValueNoQuotes(c);
|
|
808
|
-
break;
|
|
809
|
-
case State.InSelfClosingTag:
|
|
810
|
-
this.stateInSelfClosingTag(c);
|
|
811
|
-
break;
|
|
812
|
-
case State.InDeclaration:
|
|
813
|
-
this.stateInDeclaration(c);
|
|
814
|
-
break;
|
|
815
|
-
case State.BeforeDeclaration:
|
|
816
|
-
this.stateBeforeDeclaration(c);
|
|
817
|
-
break;
|
|
818
|
-
case State.BeforeComment:
|
|
819
|
-
this.stateBeforeComment(c);
|
|
820
|
-
break;
|
|
821
|
-
case State.InProcessingInstruction:
|
|
822
|
-
this.stateInProcessingInstruction(c);
|
|
823
|
-
break;
|
|
824
|
-
case State.InEntity:
|
|
825
|
-
this.stateInEntity();
|
|
826
|
-
break;
|
|
827
|
-
}
|
|
828
|
-
this.index++;
|
|
829
|
-
}
|
|
830
|
-
this.cleanup();
|
|
831
|
-
}
|
|
832
|
-
finish() {
|
|
833
|
-
if (this.state === State.InEntity) {
|
|
834
|
-
this.entityDecoder.end();
|
|
835
|
-
this.state = this.baseState;
|
|
836
|
-
}
|
|
837
|
-
this.handleTrailingData();
|
|
838
|
-
this.cbs.onend();
|
|
839
|
-
}
|
|
840
|
-
handleTrailingCommentLikeData(endIndex) {
|
|
841
|
-
if (this.state !== State.InCommentLike) return false;
|
|
842
|
-
if (this.currentSequence === Sequences.CdataEnd) if (this.xmlMode) {
|
|
843
|
-
if (this.sectionStart < endIndex) this.cbs.oncdata(this.sectionStart, endIndex, 0);
|
|
844
|
-
} else {
|
|
845
|
-
const cdataStart = this.sectionStart - Sequences.Cdata.length - 1;
|
|
846
|
-
this.cbs.oncomment(cdataStart, endIndex, 0);
|
|
847
|
-
}
|
|
848
|
-
else {
|
|
849
|
-
const offset = this.xmlMode ? 0 : Math.min(this.sequenceIndex, Sequences.CommentEnd.length - 1);
|
|
850
|
-
this.cbs.oncomment(this.sectionStart, endIndex, offset);
|
|
851
|
-
}
|
|
852
|
-
return true;
|
|
853
|
-
}
|
|
854
|
-
handleTrailingMarkupDeclaration(endIndex) {
|
|
855
|
-
if (this.xmlMode) switch (this.state) {
|
|
856
|
-
case State.InSpecialComment:
|
|
857
|
-
case State.BeforeComment:
|
|
858
|
-
case State.CDATASequence:
|
|
859
|
-
case State.DeclarationSequence:
|
|
860
|
-
case State.InDeclaration:
|
|
861
|
-
this.cbs.ontext(this.sectionStart, endIndex);
|
|
862
|
-
return true;
|
|
863
|
-
default: return false;
|
|
864
|
-
}
|
|
865
|
-
switch (this.state) {
|
|
866
|
-
case State.BeforeDeclaration:
|
|
867
|
-
case State.InSpecialComment:
|
|
868
|
-
case State.BeforeComment:
|
|
869
|
-
case State.CDATASequence:
|
|
870
|
-
this.cbs.oncomment(this.sectionStart, endIndex, 0);
|
|
871
|
-
return true;
|
|
872
|
-
case State.DeclarationSequence:
|
|
873
|
-
if (this.sequenceIndex !== Sequences.Doctype.length) this.cbs.oncomment(this.sectionStart, endIndex, 0);
|
|
874
|
-
return true;
|
|
875
|
-
case State.InDeclaration: return true;
|
|
876
|
-
default: return false;
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
/** Handle any trailing data. */
|
|
880
|
-
handleTrailingData() {
|
|
881
|
-
const endIndex = this.buffer.length + this.offset;
|
|
882
|
-
if (this.handleTrailingCommentLikeData(endIndex) || this.handleTrailingMarkupDeclaration(endIndex)) return;
|
|
883
|
-
if (this.sectionStart >= endIndex) return;
|
|
884
|
-
switch (this.state) {
|
|
885
|
-
case State.InTagName:
|
|
886
|
-
case State.BeforeAttributeName:
|
|
887
|
-
case State.BeforeAttributeValue:
|
|
888
|
-
case State.AfterAttributeName:
|
|
889
|
-
case State.InAttributeName:
|
|
890
|
-
case State.InAttributeValueSq:
|
|
891
|
-
case State.InAttributeValueDq:
|
|
892
|
-
case State.InAttributeValueNq:
|
|
893
|
-
case State.InClosingTagName: break;
|
|
894
|
-
default: this.cbs.ontext(this.sectionStart, endIndex);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
emitCodePoint(cp, consumed) {
|
|
898
|
-
if (this.baseState !== State.Text && this.baseState !== State.InSpecialTag) {
|
|
899
|
-
if (this.sectionStart < this.entityStart) this.cbs.onattribdata(this.sectionStart, this.entityStart);
|
|
900
|
-
this.sectionStart = this.entityStart + consumed;
|
|
901
|
-
this.index = this.sectionStart - 1;
|
|
902
|
-
this.cbs.onattribentity(cp);
|
|
903
|
-
} else {
|
|
904
|
-
if (this.sectionStart < this.entityStart) this.cbs.ontext(this.sectionStart, this.entityStart);
|
|
905
|
-
this.sectionStart = this.entityStart + consumed;
|
|
906
|
-
this.index = this.sectionStart - 1;
|
|
907
|
-
this.cbs.ontextentity(cp, this.sectionStart);
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
};
|
|
911
|
-
}));
|
|
912
|
-
//#endregion
|
|
913
|
-
//#region ../../node_modules/.pnpm/htmlparser2@12.0.0/node_modules/htmlparser2/dist/Parser.js
|
|
914
|
-
var fromCodePoint, formTags, pTag, headingTags, tableSectionTags, ddtTags, rtpTags, openImpliesClose, DOCUMENT_TYPE, voidElements, foreignContextElements, htmlIntegrationElements, svgTagNameAdjustments, ForeignContext, reNameEnd, Parser;
|
|
915
|
-
var init_Parser = __esmMin((() => {
|
|
916
|
-
init_Tokenizer();
|
|
917
|
-
({fromCodePoint} = String);
|
|
918
|
-
formTags = new Set([
|
|
919
|
-
"input",
|
|
920
|
-
"option",
|
|
921
|
-
"optgroup",
|
|
922
|
-
"select",
|
|
923
|
-
"button",
|
|
924
|
-
"datalist",
|
|
925
|
-
"textarea"
|
|
926
|
-
]);
|
|
927
|
-
pTag = new Set(["p"]);
|
|
928
|
-
headingTags = new Set([
|
|
929
|
-
"h1",
|
|
930
|
-
"h2",
|
|
931
|
-
"h3",
|
|
932
|
-
"h4",
|
|
933
|
-
"h5",
|
|
934
|
-
"h6",
|
|
935
|
-
"p"
|
|
936
|
-
]);
|
|
937
|
-
tableSectionTags = new Set(["thead", "tbody"]);
|
|
938
|
-
ddtTags = new Set(["dd", "dt"]);
|
|
939
|
-
rtpTags = new Set(["rt", "rp"]);
|
|
940
|
-
openImpliesClose = new Map([
|
|
941
|
-
["tr", new Set([
|
|
942
|
-
"tr",
|
|
943
|
-
"th",
|
|
944
|
-
"td"
|
|
945
|
-
])],
|
|
946
|
-
["th", new Set(["th"])],
|
|
947
|
-
["td", new Set([
|
|
948
|
-
"thead",
|
|
949
|
-
"th",
|
|
950
|
-
"td"
|
|
951
|
-
])],
|
|
952
|
-
["body", new Set([
|
|
953
|
-
"head",
|
|
954
|
-
"link",
|
|
955
|
-
"script"
|
|
956
|
-
])],
|
|
957
|
-
["a", new Set(["a"])],
|
|
958
|
-
["li", new Set(["li"])],
|
|
959
|
-
["p", pTag],
|
|
960
|
-
["h1", headingTags],
|
|
961
|
-
["h2", headingTags],
|
|
962
|
-
["h3", headingTags],
|
|
963
|
-
["h4", headingTags],
|
|
964
|
-
["h5", headingTags],
|
|
965
|
-
["h6", headingTags],
|
|
966
|
-
["select", formTags],
|
|
967
|
-
["input", formTags],
|
|
968
|
-
["output", formTags],
|
|
969
|
-
["button", formTags],
|
|
970
|
-
["datalist", formTags],
|
|
971
|
-
["textarea", formTags],
|
|
972
|
-
["option", new Set(["option"])],
|
|
973
|
-
["optgroup", new Set(["optgroup", "option"])],
|
|
974
|
-
["dd", ddtTags],
|
|
975
|
-
["dt", ddtTags],
|
|
976
|
-
["address", pTag],
|
|
977
|
-
["article", pTag],
|
|
978
|
-
["aside", pTag],
|
|
979
|
-
["blockquote", pTag],
|
|
980
|
-
["details", pTag],
|
|
981
|
-
["div", pTag],
|
|
982
|
-
["dl", pTag],
|
|
983
|
-
["fieldset", pTag],
|
|
984
|
-
["figcaption", pTag],
|
|
985
|
-
["figure", pTag],
|
|
986
|
-
["footer", pTag],
|
|
987
|
-
["form", pTag],
|
|
988
|
-
["header", pTag],
|
|
989
|
-
["hr", pTag],
|
|
990
|
-
["main", pTag],
|
|
991
|
-
["nav", pTag],
|
|
992
|
-
["ol", pTag],
|
|
993
|
-
["pre", pTag],
|
|
994
|
-
["section", pTag],
|
|
995
|
-
["table", pTag],
|
|
996
|
-
["ul", pTag],
|
|
997
|
-
["rt", rtpTags],
|
|
998
|
-
["rp", rtpTags],
|
|
999
|
-
["tbody", tableSectionTags],
|
|
1000
|
-
["tfoot", tableSectionTags]
|
|
1001
|
-
]);
|
|
1002
|
-
DOCUMENT_TYPE = "doctype";
|
|
1003
|
-
voidElements = new Set([
|
|
1004
|
-
"area",
|
|
1005
|
-
"base",
|
|
1006
|
-
"basefont",
|
|
1007
|
-
"br",
|
|
1008
|
-
"col",
|
|
1009
|
-
"command",
|
|
1010
|
-
"embed",
|
|
1011
|
-
"frame",
|
|
1012
|
-
"hr",
|
|
1013
|
-
"img",
|
|
1014
|
-
"input",
|
|
1015
|
-
"isindex",
|
|
1016
|
-
"keygen",
|
|
1017
|
-
"link",
|
|
1018
|
-
"meta",
|
|
1019
|
-
"param",
|
|
1020
|
-
"source",
|
|
1021
|
-
"track",
|
|
1022
|
-
"wbr"
|
|
1023
|
-
]);
|
|
1024
|
-
foreignContextElements = new Set(["math", "svg"]);
|
|
1025
|
-
htmlIntegrationElements = new Set([
|
|
1026
|
-
"mi",
|
|
1027
|
-
"mo",
|
|
1028
|
-
"mn",
|
|
1029
|
-
"ms",
|
|
1030
|
-
"mtext",
|
|
1031
|
-
"annotation-xml",
|
|
1032
|
-
"foreignObject",
|
|
1033
|
-
"desc",
|
|
1034
|
-
"title"
|
|
1035
|
-
]);
|
|
1036
|
-
svgTagNameAdjustments = new Map([
|
|
1037
|
-
["altglyph", "altGlyph"],
|
|
1038
|
-
["altglyphdef", "altGlyphDef"],
|
|
1039
|
-
["altglyphitem", "altGlyphItem"],
|
|
1040
|
-
["animatecolor", "animateColor"],
|
|
1041
|
-
["animatemotion", "animateMotion"],
|
|
1042
|
-
["animatetransform", "animateTransform"],
|
|
1043
|
-
["clippath", "clipPath"],
|
|
1044
|
-
["feblend", "feBlend"],
|
|
1045
|
-
["fecolormatrix", "feColorMatrix"],
|
|
1046
|
-
["fecomponenttransfer", "feComponentTransfer"],
|
|
1047
|
-
["fecomposite", "feComposite"],
|
|
1048
|
-
["feconvolvematrix", "feConvolveMatrix"],
|
|
1049
|
-
["fediffuselighting", "feDiffuseLighting"],
|
|
1050
|
-
["fedisplacementmap", "feDisplacementMap"],
|
|
1051
|
-
["fedistantlight", "feDistantLight"],
|
|
1052
|
-
["fedropshadow", "feDropShadow"],
|
|
1053
|
-
["feflood", "feFlood"],
|
|
1054
|
-
["fefunca", "feFuncA"],
|
|
1055
|
-
["fefuncb", "feFuncB"],
|
|
1056
|
-
["fefuncg", "feFuncG"],
|
|
1057
|
-
["fefuncr", "feFuncR"],
|
|
1058
|
-
["fegaussianblur", "feGaussianBlur"],
|
|
1059
|
-
["feimage", "feImage"],
|
|
1060
|
-
["femerge", "feMerge"],
|
|
1061
|
-
["femergenode", "feMergeNode"],
|
|
1062
|
-
["femorphology", "feMorphology"],
|
|
1063
|
-
["feoffset", "feOffset"],
|
|
1064
|
-
["fepointlight", "fePointLight"],
|
|
1065
|
-
["fespecularlighting", "feSpecularLighting"],
|
|
1066
|
-
["fespotlight", "feSpotLight"],
|
|
1067
|
-
["fetile", "feTile"],
|
|
1068
|
-
["feturbulence", "feTurbulence"],
|
|
1069
|
-
["foreignobject", "foreignObject"],
|
|
1070
|
-
["glyphref", "glyphRef"],
|
|
1071
|
-
["lineargradient", "linearGradient"],
|
|
1072
|
-
["radialgradient", "radialGradient"],
|
|
1073
|
-
["textpath", "textPath"]
|
|
1074
|
-
]);
|
|
1075
|
-
(function(ForeignContext) {
|
|
1076
|
-
ForeignContext[ForeignContext["None"] = 0] = "None";
|
|
1077
|
-
ForeignContext[ForeignContext["Svg"] = 1] = "Svg";
|
|
1078
|
-
ForeignContext[ForeignContext["MathML"] = 2] = "MathML";
|
|
1079
|
-
})(ForeignContext || (ForeignContext = {}));
|
|
1080
|
-
reNameEnd = /\s|\//;
|
|
1081
|
-
Parser = class {
|
|
1082
|
-
options;
|
|
1083
|
-
/** The start index of the last event. */
|
|
1084
|
-
startIndex = 0;
|
|
1085
|
-
/** The end index of the last event. */
|
|
1086
|
-
endIndex = 0;
|
|
1087
|
-
/**
|
|
1088
|
-
* Store the start index of the current open tag,
|
|
1089
|
-
* so we can update the start index for attributes.
|
|
1090
|
-
*/
|
|
1091
|
-
openTagStart = 0;
|
|
1092
|
-
tagname = "";
|
|
1093
|
-
attribname = "";
|
|
1094
|
-
attribvalue = "";
|
|
1095
|
-
attribs = null;
|
|
1096
|
-
stack = [];
|
|
1097
|
-
foreignContext;
|
|
1098
|
-
cbs;
|
|
1099
|
-
lowerCaseTagNames;
|
|
1100
|
-
lowerCaseAttributeNames;
|
|
1101
|
-
recognizeSelfClosing;
|
|
1102
|
-
/** We are parsing HTML. Inverse of the `xmlMode` option. */
|
|
1103
|
-
htmlMode;
|
|
1104
|
-
tokenizer;
|
|
1105
|
-
buffers = [];
|
|
1106
|
-
bufferOffset = 0;
|
|
1107
|
-
/** The index of the last written buffer. Used when resuming after a `pause()`. */
|
|
1108
|
-
writeIndex = 0;
|
|
1109
|
-
/** Indicates whether the parser has finished running / `.end` has been called. */
|
|
1110
|
-
ended = false;
|
|
1111
|
-
constructor(cbs, options = {}) {
|
|
1112
|
-
this.options = options;
|
|
1113
|
-
this.cbs = cbs ?? {};
|
|
1114
|
-
this.htmlMode = !this.options.xmlMode;
|
|
1115
|
-
this.lowerCaseTagNames = options.lowerCaseTags ?? this.htmlMode;
|
|
1116
|
-
this.lowerCaseAttributeNames = options.lowerCaseAttributeNames ?? this.htmlMode;
|
|
1117
|
-
this.recognizeSelfClosing = options.recognizeSelfClosing ?? !this.htmlMode;
|
|
1118
|
-
this.tokenizer = new (options.Tokenizer ?? Tokenizer)(this.options, this);
|
|
1119
|
-
this.foreignContext = [ForeignContext.None];
|
|
1120
|
-
this.cbs.onparserinit?.(this);
|
|
1121
|
-
}
|
|
1122
|
-
/**
|
|
1123
|
-
* @param start Start index for the current parser event.
|
|
1124
|
-
* @param endIndex End index for the current parser event.
|
|
1125
|
-
* @internal
|
|
1126
|
-
*/
|
|
1127
|
-
ontext(start, endIndex) {
|
|
1128
|
-
const data = this.getSlice(start, endIndex);
|
|
1129
|
-
this.endIndex = endIndex - 1;
|
|
1130
|
-
this.cbs.ontext?.(data);
|
|
1131
|
-
this.startIndex = endIndex;
|
|
1132
|
-
}
|
|
1133
|
-
/**
|
|
1134
|
-
* @param cp Current Unicode code point.
|
|
1135
|
-
* @param endIndex End index for the current parser event.
|
|
1136
|
-
* @internal
|
|
1137
|
-
*/
|
|
1138
|
-
ontextentity(cp, endIndex) {
|
|
1139
|
-
this.endIndex = endIndex - 1;
|
|
1140
|
-
this.cbs.ontext?.(fromCodePoint(cp));
|
|
1141
|
-
this.startIndex = endIndex;
|
|
1142
|
-
}
|
|
1143
|
-
/** @internal */
|
|
1144
|
-
isInForeignContext() {
|
|
1145
|
-
return this.foreignContext[0] !== ForeignContext.None;
|
|
1146
|
-
}
|
|
1147
|
-
/**
|
|
1148
|
-
* Checks if the current tag is a void element. Override this if you want
|
|
1149
|
-
* to specify your own additional void elements.
|
|
1150
|
-
* @param name Name of the pseudo selector.
|
|
1151
|
-
*/
|
|
1152
|
-
isVoidElement(name) {
|
|
1153
|
-
return this.htmlMode && voidElements.has(name);
|
|
1154
|
-
}
|
|
1155
|
-
/**
|
|
1156
|
-
* Read a tag name from the buffer.
|
|
1157
|
-
*
|
|
1158
|
-
* When `lowerCaseTagNames` is enabled (the default in HTML mode), the name
|
|
1159
|
-
* is lowercased and may be adjusted for SVG casing or the `image` → `img`
|
|
1160
|
-
* alias.
|
|
1161
|
-
* @param start Start index of the tag name in the buffer.
|
|
1162
|
-
* @param endIndex End index of the tag name in the buffer.
|
|
1163
|
-
*/
|
|
1164
|
-
readTagName(start, endIndex) {
|
|
1165
|
-
const name = this.lowerCaseTagNames ? this.getSlice(start, endIndex).toLowerCase() : this.getSlice(start, endIndex);
|
|
1166
|
-
if (!(this.lowerCaseTagNames && this.htmlMode)) return name;
|
|
1167
|
-
if (this.foreignContext[0] === ForeignContext.Svg) return svgTagNameAdjustments.get(name) ?? name;
|
|
1168
|
-
if (this.foreignContext.length > 1) {
|
|
1169
|
-
const adjusted = svgTagNameAdjustments.get(name);
|
|
1170
|
-
if (adjusted !== void 0 && this.stack.includes(adjusted)) return adjusted;
|
|
1171
|
-
}
|
|
1172
|
-
if (!this.isInForeignContext()) return name === "image" ? "img" : name;
|
|
1173
|
-
return name;
|
|
1174
|
-
}
|
|
1175
|
-
/**
|
|
1176
|
-
* @param start Start index for the current parser event.
|
|
1177
|
-
* @param endIndex End index for the current parser event.
|
|
1178
|
-
* @internal
|
|
1179
|
-
*/
|
|
1180
|
-
onopentagname(start, endIndex) {
|
|
1181
|
-
this.endIndex = endIndex;
|
|
1182
|
-
this.emitOpenTag(this.readTagName(start, endIndex));
|
|
1183
|
-
}
|
|
1184
|
-
emitOpenTag(name) {
|
|
1185
|
-
this.openTagStart = this.startIndex;
|
|
1186
|
-
this.tagname = name;
|
|
1187
|
-
if (this.htmlMode && name === "form" && this.stack.includes("form")) {
|
|
1188
|
-
this.tagname = "";
|
|
1189
|
-
return;
|
|
1190
|
-
}
|
|
1191
|
-
const impliesClose = this.htmlMode && openImpliesClose.get(name);
|
|
1192
|
-
if (impliesClose) while (this.stack.length > 0 && impliesClose.has(this.stack[0])) this.popElement(true);
|
|
1193
|
-
if (!this.isVoidElement(name)) {
|
|
1194
|
-
this.stack.unshift(name);
|
|
1195
|
-
if (this.htmlMode) {
|
|
1196
|
-
if (name === "svg") this.foreignContext.unshift(ForeignContext.Svg);
|
|
1197
|
-
else if (name === "math") this.foreignContext.unshift(ForeignContext.MathML);
|
|
1198
|
-
else if (htmlIntegrationElements.has(name)) this.foreignContext.unshift(ForeignContext.None);
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
this.cbs.onopentagname?.(name);
|
|
1202
|
-
if (this.cbs.onopentag) this.attribs = {};
|
|
1203
|
-
}
|
|
1204
|
-
endOpenTag(isImplied) {
|
|
1205
|
-
this.startIndex = this.openTagStart;
|
|
1206
|
-
if (this.attribs) {
|
|
1207
|
-
this.cbs.onopentag?.(this.tagname, this.attribs, isImplied);
|
|
1208
|
-
this.attribs = null;
|
|
1209
|
-
}
|
|
1210
|
-
if (this.cbs.onclosetag && this.isVoidElement(this.tagname)) this.cbs.onclosetag(this.tagname, true);
|
|
1211
|
-
this.tagname = "";
|
|
1212
|
-
}
|
|
1213
|
-
/**
|
|
1214
|
-
* @param endIndex End index for the current parser event.
|
|
1215
|
-
* @internal
|
|
1216
|
-
*/
|
|
1217
|
-
onopentagend(endIndex) {
|
|
1218
|
-
this.endIndex = endIndex;
|
|
1219
|
-
this.endOpenTag(false);
|
|
1220
|
-
this.startIndex = endIndex + 1;
|
|
1221
|
-
}
|
|
1222
|
-
/**
|
|
1223
|
-
* @param start Start index for the current parser event.
|
|
1224
|
-
* @param endIndex End index for the current parser event.
|
|
1225
|
-
* @internal
|
|
1226
|
-
*/
|
|
1227
|
-
onclosetag(start, endIndex) {
|
|
1228
|
-
this.endIndex = endIndex;
|
|
1229
|
-
const name = this.readTagName(start, endIndex);
|
|
1230
|
-
if (!this.isVoidElement(name)) {
|
|
1231
|
-
const pos = this.stack.indexOf(name);
|
|
1232
|
-
if (pos !== -1) {
|
|
1233
|
-
for (let index = 0; index < pos; index++) this.popElement(true);
|
|
1234
|
-
this.popElement(false);
|
|
1235
|
-
} else if (this.htmlMode && name === "p") {
|
|
1236
|
-
this.emitOpenTag("p");
|
|
1237
|
-
this.closeCurrentTag(true);
|
|
1238
|
-
}
|
|
1239
|
-
} else if (this.htmlMode && name === "br") {
|
|
1240
|
-
this.cbs.onopentagname?.("br");
|
|
1241
|
-
this.cbs.onopentag?.("br", {}, true);
|
|
1242
|
-
this.cbs.onclosetag?.("br", false);
|
|
1243
|
-
}
|
|
1244
|
-
this.startIndex = endIndex + 1;
|
|
1245
|
-
}
|
|
1246
|
-
/**
|
|
1247
|
-
* @param endIndex End index for the current parser event.
|
|
1248
|
-
* @internal
|
|
1249
|
-
*/
|
|
1250
|
-
onselfclosingtag(endIndex) {
|
|
1251
|
-
this.endIndex = endIndex;
|
|
1252
|
-
if (this.recognizeSelfClosing || this.isInForeignContext()) {
|
|
1253
|
-
this.closeCurrentTag(false);
|
|
1254
|
-
this.startIndex = endIndex + 1;
|
|
1255
|
-
} else this.onopentagend(endIndex);
|
|
1256
|
-
}
|
|
1257
|
-
/**
|
|
1258
|
-
* Pop the top element off the stack, emit a close event, and maintain
|
|
1259
|
-
* the foreign context stack.
|
|
1260
|
-
* @param implied Whether this close is implied (not from an explicit end tag).
|
|
1261
|
-
*/
|
|
1262
|
-
popElement(implied) {
|
|
1263
|
-
const element = this.stack.shift();
|
|
1264
|
-
if (this.htmlMode && (foreignContextElements.has(element) || htmlIntegrationElements.has(element))) this.foreignContext.shift();
|
|
1265
|
-
this.cbs.onclosetag?.(element, implied);
|
|
1266
|
-
}
|
|
1267
|
-
closeCurrentTag(isOpenImplied) {
|
|
1268
|
-
const name = this.tagname;
|
|
1269
|
-
this.endOpenTag(isOpenImplied);
|
|
1270
|
-
if (this.stack[0] === name) this.popElement(!isOpenImplied);
|
|
1271
|
-
}
|
|
1272
|
-
/**
|
|
1273
|
-
* @param start Start index for the current parser event.
|
|
1274
|
-
* @param endIndex End index for the current parser event.
|
|
1275
|
-
* @internal
|
|
1276
|
-
*/
|
|
1277
|
-
onattribname(start, endIndex) {
|
|
1278
|
-
this.startIndex = start;
|
|
1279
|
-
const name = this.getSlice(start, endIndex);
|
|
1280
|
-
this.attribname = this.lowerCaseAttributeNames ? name.toLowerCase() : name;
|
|
1281
|
-
}
|
|
1282
|
-
/**
|
|
1283
|
-
* @param start Start index for the current parser event.
|
|
1284
|
-
* @param endIndex End index for the current parser event.
|
|
1285
|
-
* @internal
|
|
1286
|
-
*/
|
|
1287
|
-
onattribdata(start, endIndex) {
|
|
1288
|
-
this.attribvalue += this.getSlice(start, endIndex);
|
|
1289
|
-
}
|
|
1290
|
-
/**
|
|
1291
|
-
* @param cp Current Unicode code point.
|
|
1292
|
-
* @internal
|
|
1293
|
-
*/
|
|
1294
|
-
onattribentity(cp) {
|
|
1295
|
-
this.attribvalue += fromCodePoint(cp);
|
|
1296
|
-
}
|
|
1297
|
-
/**
|
|
1298
|
-
* @param quote Quote type used for the current attribute.
|
|
1299
|
-
* @param endIndex End index for the current parser event.
|
|
1300
|
-
* @internal
|
|
1301
|
-
*/
|
|
1302
|
-
onattribend(quote, endIndex) {
|
|
1303
|
-
this.endIndex = endIndex;
|
|
1304
|
-
this.cbs.onattribute?.(this.attribname, this.attribvalue, quote === QuoteType.Double ? "\"" : quote === QuoteType.Single ? "'" : quote === QuoteType.NoValue ? void 0 : null);
|
|
1305
|
-
if (this.attribs && !Object.hasOwn(this.attribs, this.attribname)) this.attribs[this.attribname] = this.attribvalue;
|
|
1306
|
-
this.attribvalue = "";
|
|
1307
|
-
}
|
|
1308
|
-
getInstructionName(value) {
|
|
1309
|
-
const index = value.search(reNameEnd);
|
|
1310
|
-
let name = index < 0 ? value : value.substr(0, index);
|
|
1311
|
-
if (this.lowerCaseTagNames) name = name.toLowerCase();
|
|
1312
|
-
return name;
|
|
1313
|
-
}
|
|
1314
|
-
/**
|
|
1315
|
-
* @param start Start index for the current parser event.
|
|
1316
|
-
* @param endIndex End index for the current parser event.
|
|
1317
|
-
* @internal
|
|
1318
|
-
*/
|
|
1319
|
-
ondeclaration(start, endIndex) {
|
|
1320
|
-
this.endIndex = endIndex;
|
|
1321
|
-
const value = this.getSlice(start, endIndex);
|
|
1322
|
-
if (this.cbs.onprocessinginstruction) {
|
|
1323
|
-
const name = this.htmlMode ? this.lowerCaseTagNames ? DOCUMENT_TYPE : value.slice(0, 7) : this.getInstructionName(value);
|
|
1324
|
-
this.cbs.onprocessinginstruction(`!${name}`, `!${value}`);
|
|
1325
|
-
}
|
|
1326
|
-
this.startIndex = endIndex + 1;
|
|
1327
|
-
}
|
|
1328
|
-
/**
|
|
1329
|
-
* @param start Start index for the current parser event.
|
|
1330
|
-
* @param endIndex End index for the current parser event.
|
|
1331
|
-
* @internal
|
|
1332
|
-
*/
|
|
1333
|
-
onprocessinginstruction(start, endIndex) {
|
|
1334
|
-
this.endIndex = endIndex;
|
|
1335
|
-
const value = this.getSlice(start, endIndex);
|
|
1336
|
-
if (this.cbs.onprocessinginstruction) {
|
|
1337
|
-
const name = this.getInstructionName(value);
|
|
1338
|
-
this.cbs.onprocessinginstruction(`?${name}`, `?${value}`);
|
|
1339
|
-
}
|
|
1340
|
-
this.startIndex = endIndex + 1;
|
|
1341
|
-
}
|
|
1342
|
-
/**
|
|
1343
|
-
* @param start Start index for the current parser event.
|
|
1344
|
-
* @param endIndex End index for the current parser event.
|
|
1345
|
-
* @param offset Offset applied when computing parser indices.
|
|
1346
|
-
* @internal
|
|
1347
|
-
*/
|
|
1348
|
-
oncomment(start, endIndex, offset) {
|
|
1349
|
-
this.endIndex = endIndex;
|
|
1350
|
-
this.cbs.oncomment?.(this.getSlice(start, endIndex - offset));
|
|
1351
|
-
this.cbs.oncommentend?.();
|
|
1352
|
-
this.startIndex = endIndex + 1;
|
|
1353
|
-
}
|
|
1354
|
-
/**
|
|
1355
|
-
* @param start Start index for the current parser event.
|
|
1356
|
-
* @param endIndex End index for the current parser event.
|
|
1357
|
-
* @param offset Offset applied when computing parser indices.
|
|
1358
|
-
* @internal
|
|
1359
|
-
*/
|
|
1360
|
-
oncdata(start, endIndex, offset) {
|
|
1361
|
-
this.endIndex = endIndex;
|
|
1362
|
-
const value = this.getSlice(start, endIndex - offset);
|
|
1363
|
-
if (!this.htmlMode || this.options.recognizeCDATA) {
|
|
1364
|
-
this.cbs.oncdatastart?.();
|
|
1365
|
-
this.cbs.ontext?.(value);
|
|
1366
|
-
this.cbs.oncdataend?.();
|
|
1367
|
-
} else if (this.isInForeignContext()) this.cbs.ontext?.(value);
|
|
1368
|
-
else {
|
|
1369
|
-
this.cbs.oncomment?.(`[CDATA[${value}]]`);
|
|
1370
|
-
this.cbs.oncommentend?.();
|
|
1371
|
-
}
|
|
1372
|
-
this.startIndex = endIndex + 1;
|
|
1373
|
-
}
|
|
1374
|
-
/** @internal */
|
|
1375
|
-
onend() {
|
|
1376
|
-
if (this.cbs.onclosetag) {
|
|
1377
|
-
this.endIndex = this.startIndex;
|
|
1378
|
-
for (let index = 0; index < this.stack.length; index++) this.cbs.onclosetag(this.stack[index], true);
|
|
1379
|
-
}
|
|
1380
|
-
this.cbs.onend?.();
|
|
1381
|
-
}
|
|
1382
|
-
/**
|
|
1383
|
-
* Resets the parser to a blank state, ready to parse a new HTML document
|
|
1384
|
-
*/
|
|
1385
|
-
reset() {
|
|
1386
|
-
this.cbs.onreset?.();
|
|
1387
|
-
this.tokenizer.reset();
|
|
1388
|
-
this.tagname = "";
|
|
1389
|
-
this.attribname = "";
|
|
1390
|
-
this.attribvalue = "";
|
|
1391
|
-
this.attribs = null;
|
|
1392
|
-
this.stack.length = 0;
|
|
1393
|
-
this.startIndex = 0;
|
|
1394
|
-
this.endIndex = 0;
|
|
1395
|
-
this.cbs.onparserinit?.(this);
|
|
1396
|
-
this.buffers.length = 0;
|
|
1397
|
-
this.foreignContext.length = 0;
|
|
1398
|
-
this.foreignContext.unshift(ForeignContext.None);
|
|
1399
|
-
this.bufferOffset = 0;
|
|
1400
|
-
this.writeIndex = 0;
|
|
1401
|
-
this.ended = false;
|
|
1402
|
-
}
|
|
1403
|
-
/**
|
|
1404
|
-
* Resets the parser, then parses a complete document and
|
|
1405
|
-
* pushes it to the handler.
|
|
1406
|
-
* @param data Document to parse.
|
|
1407
|
-
*/
|
|
1408
|
-
parseComplete(data) {
|
|
1409
|
-
this.reset();
|
|
1410
|
-
this.end(data);
|
|
1411
|
-
}
|
|
1412
|
-
getSlice(start, end) {
|
|
1413
|
-
if (start === end) return "";
|
|
1414
|
-
while (start - this.bufferOffset >= this.buffers[0].length) this.shiftBuffer();
|
|
1415
|
-
let slice = this.buffers[0].slice(start - this.bufferOffset, end - this.bufferOffset);
|
|
1416
|
-
while (end - this.bufferOffset > this.buffers[0].length) {
|
|
1417
|
-
this.shiftBuffer();
|
|
1418
|
-
slice += this.buffers[0].slice(0, end - this.bufferOffset);
|
|
1419
|
-
}
|
|
1420
|
-
return slice;
|
|
1421
|
-
}
|
|
1422
|
-
shiftBuffer() {
|
|
1423
|
-
this.bufferOffset += this.buffers[0].length;
|
|
1424
|
-
this.writeIndex--;
|
|
1425
|
-
this.buffers.shift();
|
|
1426
|
-
}
|
|
1427
|
-
/**
|
|
1428
|
-
* Parses a chunk of data and calls the corresponding callbacks.
|
|
1429
|
-
* @param chunk Chunk to parse.
|
|
1430
|
-
*/
|
|
1431
|
-
write(chunk) {
|
|
1432
|
-
if (this.ended) {
|
|
1433
|
-
this.cbs.onerror?.(/* @__PURE__ */ new Error(".write() after done!"));
|
|
1434
|
-
return;
|
|
1435
|
-
}
|
|
1436
|
-
this.buffers.push(chunk);
|
|
1437
|
-
if (this.tokenizer.running) {
|
|
1438
|
-
this.tokenizer.write(chunk);
|
|
1439
|
-
this.writeIndex++;
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
/**
|
|
1443
|
-
* Parses the end of the buffer and clears the stack, calls onend.
|
|
1444
|
-
* @param chunk Optional final chunk to parse.
|
|
1445
|
-
*/
|
|
1446
|
-
end(chunk) {
|
|
1447
|
-
if (this.ended) {
|
|
1448
|
-
this.cbs.onerror?.(/* @__PURE__ */ new Error(".end() after done!"));
|
|
1449
|
-
return;
|
|
1450
|
-
}
|
|
1451
|
-
if (chunk) this.write(chunk);
|
|
1452
|
-
this.ended = true;
|
|
1453
|
-
this.tokenizer.end();
|
|
1454
|
-
}
|
|
1455
|
-
/**
|
|
1456
|
-
* Pauses parsing. The parser won't emit events until `resume` is called.
|
|
1457
|
-
*/
|
|
1458
|
-
pause() {
|
|
1459
|
-
this.tokenizer.pause();
|
|
1460
|
-
}
|
|
1461
|
-
/**
|
|
1462
|
-
* Resumes parsing after `pause` was called.
|
|
1463
|
-
*/
|
|
1464
|
-
resume() {
|
|
1465
|
-
this.tokenizer.resume();
|
|
1466
|
-
while (this.tokenizer.running && this.writeIndex < this.buffers.length) this.tokenizer.write(this.buffers[this.writeIndex++]);
|
|
1467
|
-
if (this.ended) this.tokenizer.end();
|
|
1468
|
-
}
|
|
1469
|
-
};
|
|
1470
|
-
}));
|
|
1471
|
-
//#endregion
|
|
1472
|
-
//#region ../../node_modules/.pnpm/htmlparser2@12.0.0/node_modules/htmlparser2/dist/index.js
|
|
1473
|
-
var dist_exports = /* @__PURE__ */ __exportAll({
|
|
1474
|
-
DefaultHandler: () => DomHandler,
|
|
1475
|
-
DomHandler: () => DomHandler,
|
|
1476
|
-
DomUtils: () => dist_exports$3,
|
|
1477
|
-
ElementType: () => dist_exports$1,
|
|
1478
|
-
Parser: () => Parser,
|
|
1479
|
-
QuoteType: () => QuoteType,
|
|
1480
|
-
Tokenizer: () => Tokenizer,
|
|
1481
|
-
createDocumentStream: () => createDocumentStream,
|
|
1482
|
-
getFeed: () => getFeed,
|
|
1483
|
-
parseDocument: () => parseDocument,
|
|
1484
|
-
parseFeed: () => parseFeed
|
|
1485
|
-
});
|
|
1486
|
-
/**
|
|
1487
|
-
* Parses the data, returns the resulting document.
|
|
1488
|
-
* @param data The data that should be parsed.
|
|
1489
|
-
* @param options Optional options for the parser and DOM handler.
|
|
1490
|
-
*/
|
|
1491
|
-
function parseDocument(data, options) {
|
|
1492
|
-
const handler = new DomHandler(void 0, options);
|
|
1493
|
-
new Parser(handler, options).end(data);
|
|
1494
|
-
return handler.root;
|
|
1495
|
-
}
|
|
1496
|
-
/**
|
|
1497
|
-
* Creates a parser instance, with an attached DOM handler.
|
|
1498
|
-
* @param callback A callback that will be called once parsing has been completed, with the resulting document.
|
|
1499
|
-
* @param options Optional options for the parser and DOM handler.
|
|
1500
|
-
* @param elementCallback An optional callback that will be called every time a tag has been completed inside of the DOM.
|
|
1501
|
-
*/
|
|
1502
|
-
function createDocumentStream(callback, options, elementCallback) {
|
|
1503
|
-
const handler = new DomHandler((error) => callback(error, handler.root), options, elementCallback);
|
|
1504
|
-
return new Parser(handler, options);
|
|
1505
|
-
}
|
|
1506
|
-
/**
|
|
1507
|
-
* Parse a feed.
|
|
1508
|
-
* @param feed The feed that should be parsed, as a string.
|
|
1509
|
-
* @param options Optionally, options for parsing. When using this, you should set `xmlMode` to `true`.
|
|
1510
|
-
*/
|
|
1511
|
-
function parseFeed(feed, options = parseFeedDefaultOptions) {
|
|
1512
|
-
return getFeed(parseDocument(feed, options).children);
|
|
1513
|
-
}
|
|
1514
|
-
var parseFeedDefaultOptions;
|
|
1515
|
-
var init_dist = __esmMin((() => {
|
|
1516
|
-
init_Parser();
|
|
1517
|
-
init_dist$2();
|
|
1518
|
-
init_dist$1();
|
|
1519
|
-
init_Tokenizer();
|
|
1520
|
-
init_dist$3();
|
|
1521
|
-
parseFeedDefaultOptions = { xmlMode: true };
|
|
1522
|
-
}));
|
|
1523
|
-
//#endregion
|
|
1524
|
-
//#region ../../node_modules/.pnpm/html-dom-parser@8.0.0/node_modules/html-dom-parser/lib/server/html-to-dom.js
|
|
1525
|
-
var require_html_to_dom$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1526
|
-
var require_utilities = require_utilities$1();
|
|
1527
|
-
var domhandler = (init_dist$2(), __toCommonJS(dist_exports$2));
|
|
1528
|
-
var htmlparser2 = (init_dist(), __toCommonJS(dist_exports));
|
|
1529
|
-
/**
|
|
1530
|
-
* Parses HTML string to DOM nodes in Node.js.
|
|
1531
|
-
*
|
|
1532
|
-
* This is the same method as `require('htmlparser2').parseDOM`
|
|
1533
|
-
*
|
|
1534
|
-
* @see https://github.com/fb55/htmlparser2/blob/v9.0.0/src/index.ts#L44-L46
|
|
1535
|
-
* @see https://github.com/fb55/domhandler/tree/v5.0.3#readme
|
|
1536
|
-
*
|
|
1537
|
-
* @param html - HTML markup.
|
|
1538
|
-
* @param options - Parser options.
|
|
1539
|
-
* @returns - DOM nodes.
|
|
1540
|
-
*/
|
|
1541
|
-
function HTMLDOMParser(html, options) {
|
|
1542
|
-
if (typeof html !== "string") throw new TypeError("First argument must be a string.");
|
|
1543
|
-
if (!html) return [];
|
|
1544
|
-
const handler = new domhandler.DomHandler(void 0, options);
|
|
1545
|
-
new htmlparser2.Parser(handler, options).end(html);
|
|
1546
|
-
return require_utilities.unsetRootParent(handler.dom);
|
|
1547
|
-
}
|
|
1548
|
-
exports.default = HTMLDOMParser;
|
|
1549
|
-
}));
|
|
1550
|
-
//#endregion
|
|
1551
|
-
//#region ../../node_modules/.pnpm/html-dom-parser@8.0.0/node_modules/html-dom-parser/lib/index.js
|
|
1552
|
-
var require_lib = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1553
|
-
Object.defineProperties(exports, {
|
|
1554
|
-
__esModule: { value: true },
|
|
1555
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
1556
|
-
});
|
|
1557
|
-
exports.default = require_html_to_dom$1().default;
|
|
1558
|
-
}));
|
|
1559
|
-
//#endregion
|
|
1560
|
-
export { require_lib as t };
|