@aiquants/markdown 6.4.0 → 7.0.0
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/README.md +2 -1
- package/dist/{abnfDiagram-VRR7QNED-DJQK-fno.js → abnfDiagram-VRR7QNED-2HHLEFYn.js} +3 -3
- package/dist/{abnfDiagram-VRR7QNED-B4qwBPG8.cjs → abnfDiagram-VRR7QNED-B9qvbKps.cjs} +1 -1
- package/dist/{arc-B5-ynLRd.js → arc-DD1A3GS6.js} +1 -1
- package/dist/{arc-CXmyMsv9.cjs → arc-DGI79XZe.cjs} +1 -1
- package/dist/{architectureDiagram-ZJ3FMSHR-DyhTbYvV.cjs → architectureDiagram-ZJ3FMSHR-B7adKw79.cjs} +1 -1
- package/dist/{architectureDiagram-ZJ3FMSHR-C_JEocx6.js → architectureDiagram-ZJ3FMSHR-C2Isv_kl.js} +2 -2
- package/dist/{blockDiagram-677ZJIJ3-COWsJwrz.js → blockDiagram-677ZJIJ3-BzDG3iuJ.js} +3 -3
- package/dist/{blockDiagram-677ZJIJ3-BsWnBpmo.cjs → blockDiagram-677ZJIJ3-tX1_79x-.cjs} +1 -1
- package/dist/{c4Diagram-LMCZKHZV-BJGPyybb.js → c4Diagram-LMCZKHZV-C1E7x4pL.js} +2 -2
- package/dist/{c4Diagram-LMCZKHZV-C8SAoymj.cjs → c4Diagram-LMCZKHZV-Cw3Nz-fO.cjs} +1 -1
- package/dist/{channel-Catm-7_m.cjs → channel-BDmOr8WI.cjs} +1 -1
- package/dist/{channel-gEEzHgMK.js → channel-rE7Nidar.js} +1 -1
- package/dist/{chunk-2Q5K7J3B-D2pUNN7e.cjs → chunk-2Q5K7J3B-B_uu3ryF.cjs} +1 -1
- package/dist/{chunk-2Q5K7J3B-BrZPj48S.js → chunk-2Q5K7J3B-CTJGCzMl.js} +1 -1
- package/dist/{chunk-32BRIVSS-Qjp2CRZG.js → chunk-32BRIVSS-80KutoA3.js} +1 -1
- package/dist/{chunk-32BRIVSS-BHwCDqTA.cjs → chunk-32BRIVSS-BU3k8fI2.cjs} +1 -1
- package/dist/{chunk-5VM5RSS4-Cz-1oXF8.js → chunk-5VM5RSS4-B832yI0V.js} +1 -1
- package/dist/{chunk-5VM5RSS4-C-2Xl1mK.cjs → chunk-5VM5RSS4-uqdZf5S-.cjs} +1 -1
- package/dist/{chunk-EX3LRPZG-CcWHrBHu.cjs → chunk-EX3LRPZG-5HbToUCP.cjs} +1 -1
- package/dist/{chunk-EX3LRPZG-DOly63cQ.js → chunk-EX3LRPZG-DApvzt_L.js} +4 -4
- package/dist/{chunk-JWPE2WC7-uLMzLWor.cjs → chunk-JWPE2WC7-CBmUqzlg.cjs} +1 -1
- package/dist/{chunk-JWPE2WC7-D8oKuUKk.js → chunk-JWPE2WC7-Dum8Mfkz.js} +1 -1
- package/dist/{chunk-MOJQB5TN-DFfn4gwS.js → chunk-MOJQB5TN-EODWFr7m.js} +1 -1
- package/dist/{chunk-MOJQB5TN-CFHULd2m.cjs → chunk-MOJQB5TN-hBYZmLmM.cjs} +1 -1
- package/dist/{chunk-PUDLZKDR-BSXgzvcs.js → chunk-PUDLZKDR-C2TE3L5R.js} +6 -6
- package/dist/{chunk-PUDLZKDR-CdXVWW4P.cjs → chunk-PUDLZKDR-Cy-CXwf7.cjs} +1 -1
- package/dist/{chunk-RYQCIY6F-D7rBCtF6.js → chunk-RYQCIY6F-BEpprYHU.js} +1 -1
- package/dist/{chunk-RYQCIY6F-CVamSMzr.cjs → chunk-RYQCIY6F-DYWz_eP5.cjs} +1 -1
- package/dist/{chunk-V7JOEXUC-BEGUrMN0.js → chunk-V7JOEXUC-BM-hXi97.js} +5 -5
- package/dist/{chunk-V7JOEXUC-DJuvtTef.cjs → chunk-V7JOEXUC-GAaV0B4H.cjs} +1 -1
- package/dist/{chunk-VR4S4FIN-DbzCqIxB.js → chunk-VR4S4FIN-BC678u_2.js} +1 -1
- package/dist/{chunk-VR4S4FIN-Okfemb3d.cjs → chunk-VR4S4FIN-BXcUlQwZ.cjs} +1 -1
- package/dist/{chunk-XXDRQBXY-DzmhMVRC.js → chunk-XXDRQBXY-CQpPgj7q.js} +1 -1
- package/dist/{chunk-XXDRQBXY-DQBgFSg2.cjs → chunk-XXDRQBXY-DUBr_c4F.cjs} +1 -1
- package/dist/{classDiagram-OUVF2IWQ-DR8DD7tr.cjs → classDiagram-OUVF2IWQ-COvGPN2S.cjs} +1 -1
- package/dist/{classDiagram-v2-EOCWNBFH-BGn-HjT8.js → classDiagram-OUVF2IWQ-yWKe5-Fq.js} +2 -2
- package/dist/{classDiagram-v2-EOCWNBFH-DR8DD7tr.cjs → classDiagram-v2-EOCWNBFH-COvGPN2S.cjs} +1 -1
- package/dist/{classDiagram-OUVF2IWQ-BGn-HjT8.js → classDiagram-v2-EOCWNBFH-yWKe5-Fq.js} +2 -2
- package/dist/converter.wasm +0 -0
- package/dist/{cose-bilkent-JH36ORCC-CXaSZTQh.js → cose-bilkent-JH36ORCC-BZn7k9jD.js} +1 -1
- package/dist/{cose-bilkent-JH36ORCC-DKpnPAKO.cjs → cose-bilkent-JH36ORCC-CcFTw3np.cjs} +1 -1
- package/dist/{cynefinDiagram-TSTJHNR4-WzHtBOXU.cjs → cynefinDiagram-TSTJHNR4-XM1i8MSX.cjs} +1 -1
- package/dist/{cynefinDiagram-TSTJHNR4-BQSdT_2p.js → cynefinDiagram-TSTJHNR4-hurHHCIy.js} +2 -2
- package/dist/{dagre-VKFMJZFB-BOlxvZO9.cjs → dagre-VKFMJZFB-3LTByKBx.cjs} +1 -1
- package/dist/{dagre-VKFMJZFB-DQ5e1PJD.js → dagre-VKFMJZFB-CAdYW8rl.js} +2 -2
- package/dist/{diagram-FQU43EPY-DdDxGx-M.cjs → diagram-FQU43EPY-Cbzx46mZ.cjs} +1 -1
- package/dist/{diagram-FQU43EPY-DlCF28sn.js → diagram-FQU43EPY-CksXO5SO.js} +2 -2
- package/dist/{diagram-G47NLZAW-Cvts7_pn.cjs → diagram-G47NLZAW-C86xos3U.cjs} +1 -1
- package/dist/{diagram-G47NLZAW-DVdw7HhH.js → diagram-G47NLZAW-CyQT8r6l.js} +3 -3
- package/dist/{diagram-NH7WQ7WH-BkU3b82h.js → diagram-NH7WQ7WH-ClLVgFsl.js} +2 -2
- package/dist/{diagram-NH7WQ7WH-Cs_Dyb0p.cjs → diagram-NH7WQ7WH-DqE3-hMS.cjs} +1 -1
- package/dist/{diagram-OA4YK3LP-D39RUkK3.js → diagram-OA4YK3LP-CkDm25Bj.js} +3 -3
- package/dist/{diagram-OA4YK3LP-ONhluSWR.cjs → diagram-OA4YK3LP-TeFqqPyo.cjs} +1 -1
- package/dist/{diagram-WEI45ONY-CMD5pSfn.js → diagram-WEI45ONY-DCJ7RPdW.js} +2 -2
- package/dist/{diagram-WEI45ONY-DyEvKt6H.cjs → diagram-WEI45ONY-sNQ6RgM4.cjs} +1 -1
- package/dist/{ebnfDiagram-CCIWWBDH-Bi-wg1C0.cjs → ebnfDiagram-CCIWWBDH-CwojFWHZ.cjs} +1 -1
- package/dist/{ebnfDiagram-CCIWWBDH-Z3TtxdlL.js → ebnfDiagram-CCIWWBDH-ORZrs8P1.js} +3 -3
- package/dist/embeds/testing.cjs +1 -1
- package/dist/embeds/testing.js +1 -1
- package/dist/embeds.cjs +1 -1
- package/dist/embeds.js +1 -1
- package/dist/{erDiagram-Q63AITRT-DQO3kH0H.cjs → erDiagram-Q63AITRT-B5r4qjGb.cjs} +1 -1
- package/dist/{erDiagram-Q63AITRT-C-O8hBWj.js → erDiagram-Q63AITRT-DLihpfSY.js} +4 -4
- package/dist/{extractHeadings-DSlyjlEb.cjs → extractHeadings-AC80DPCv.cjs} +3 -3
- package/dist/{extractHeadings-DkKFCMIW.js → extractHeadings-jpTidOYO.js} +42 -42
- package/dist/flowDiagram-23GEKE2U-gaIzKUxz.js +7 -0
- package/dist/flowDiagram-23GEKE2U-pAPxQFWB.cjs +1 -0
- package/dist/{ganttDiagram-NO4QXBWP-BgxDDjW1.js → ganttDiagram-NO4QXBWP-Cc8dpB_u.js} +2 -2
- package/dist/{ganttDiagram-NO4QXBWP-C6v1dyOv.cjs → ganttDiagram-NO4QXBWP-qrmnl_LY.cjs} +1 -1
- package/dist/{gitGraphDiagram-IHSO6WYX-Dly6wuUW.cjs → gitGraphDiagram-IHSO6WYX-Bi0LKdq4.cjs} +1 -1
- package/dist/{gitGraphDiagram-IHSO6WYX-BSIaczat.js → gitGraphDiagram-IHSO6WYX-DEf3gB0s.js} +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.client.cjs +1 -1
- package/dist/index.client.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.server.cjs +1 -1
- package/dist/index.server.js +246 -241
- package/dist/{infoDiagram-FWYZ7A6U-CRxeian2.cjs → infoDiagram-FWYZ7A6U-ByUzaoGp.cjs} +1 -1
- package/dist/{infoDiagram-FWYZ7A6U-BJpiPMD3.js → infoDiagram-FWYZ7A6U-CC1jQUez.js} +1 -1
- package/dist/{ishikawaDiagram-FXEZZL3T-B3tCfTEo.js → ishikawaDiagram-FXEZZL3T-BD2ZWvM9.js} +1 -1
- package/dist/{ishikawaDiagram-FXEZZL3T-jEnTu6LN.cjs → ishikawaDiagram-FXEZZL3T-q0Tua53X.cjs} +1 -1
- package/dist/{journeyDiagram-5HDEW3XC-D7U-NNAM.js → journeyDiagram-5HDEW3XC-B2d4YZ1X.js} +4 -4
- package/dist/{journeyDiagram-5HDEW3XC-BXFW-Svx.cjs → journeyDiagram-5HDEW3XC-Cc_OHYxa.cjs} +1 -1
- package/dist/{kanban-definition-HUTT4EX6-DSprt7D2.cjs → kanban-definition-HUTT4EX6-CGhp8hq-.cjs} +1 -1
- package/dist/{kanban-definition-HUTT4EX6-B14iIRCh.js → kanban-definition-HUTT4EX6-CVTjOFjf.js} +2 -2
- package/dist/{linear-DZOg62FH.js → linear-Gki9XU32.js} +1 -1
- package/dist/{linear-B-_z7_Qw.cjs → linear-NPD77kko.cjs} +1 -1
- package/dist/{mindmap-definition-LN4V7U3C-Bs_ccQ71.cjs → mindmap-definition-LN4V7U3C-BVMzWil4.cjs} +1 -1
- package/dist/{mindmap-definition-LN4V7U3C-Dh-Z6t4L.js → mindmap-definition-LN4V7U3C-CcFlbH0m.js} +3 -3
- package/dist/{pegDiagram-2B236MQR-6OQwK0r-.js → pegDiagram-2B236MQR-BIEbmEyL.js} +3 -3
- package/dist/{pegDiagram-2B236MQR-BunF191h.cjs → pegDiagram-2B236MQR-BjkrlFo4.cjs} +1 -1
- package/dist/{pieDiagram-ENE6RG2P-DjvAa5zD.js → pieDiagram-ENE6RG2P-B8b2HOMr.js} +3 -3
- package/dist/{pieDiagram-ENE6RG2P-BUdykoZb.cjs → pieDiagram-ENE6RG2P-C_zKMY-f.cjs} +1 -1
- package/dist/{providers-L5RM3KgR.js → providers-BwQK7hZa.js} +4 -4
- package/dist/{providers-BO7J62-7.cjs → providers-DO2t7ks4.cjs} +1 -1
- package/dist/{quadrantDiagram-ABIIQ3AL-DfiOa0GN.js → quadrantDiagram-ABIIQ3AL-CAzEuvrn.js} +2 -2
- package/dist/{quadrantDiagram-ABIIQ3AL-ksoulitn.cjs → quadrantDiagram-ABIIQ3AL-DM2brpjs.cjs} +1 -1
- package/dist/{railroadDiagram-RFXS5EU6-BWupYLwR.cjs → railroadDiagram-RFXS5EU6-D4qyeIm0.cjs} +1 -1
- package/dist/{railroadDiagram-RFXS5EU6-DxJ3t05t.js → railroadDiagram-RFXS5EU6-Dj5Hhb2C.js} +3 -3
- package/dist/{requirementDiagram-TGXJPOKE-CxplHHB8.js → requirementDiagram-TGXJPOKE-DCsyd9cl.js} +3 -3
- package/dist/{requirementDiagram-TGXJPOKE-D17FjoFO.cjs → requirementDiagram-TGXJPOKE-DxMueY11.cjs} +1 -1
- package/dist/{sankeyDiagram-HTMAVEWB-DFOQ2fD-.js → sankeyDiagram-HTMAVEWB-Djmdo0Ih.js} +1 -1
- package/dist/{sankeyDiagram-HTMAVEWB-CDXvEE-n.cjs → sankeyDiagram-HTMAVEWB-HPKhkyBx.cjs} +1 -1
- package/dist/{sequenceDiagram-DBY2YBRQ-D-aVI5Yt.cjs → sequenceDiagram-DBY2YBRQ-3XPFEpyb.cjs} +1 -1
- package/dist/{sequenceDiagram-DBY2YBRQ-Gf5VRPPO.js → sequenceDiagram-DBY2YBRQ-BsELINW9.js} +3 -3
- package/dist/{sizeCapture-X5ZJPWSS-BAB3SekL.cjs → sizeCapture-X5ZJPWSS-31abQGwa.cjs} +1 -1
- package/dist/{sizeCapture-X5ZJPWSS-DyErW1EK.js → sizeCapture-X5ZJPWSS-CYMPBUJR.js} +1 -1
- package/dist/{stateDiagram-2N3HPSRC-BrUDPgXu.cjs → stateDiagram-2N3HPSRC-B0XEIOiL.cjs} +1 -1
- package/dist/{stateDiagram-2N3HPSRC-lxQmuBDw.js → stateDiagram-2N3HPSRC-a3NuIfYf.js} +2 -2
- package/dist/{stateDiagram-v2-6OUMAXLB-B67PZ7bz.cjs → stateDiagram-v2-6OUMAXLB-BwCXOhvG.cjs} +1 -1
- package/dist/{stateDiagram-v2-6OUMAXLB-l5VmN12f.js → stateDiagram-v2-6OUMAXLB-DGoXPnAk.js} +2 -2
- package/dist/{swimlanes-5IMT3BWC-CMkiOd-R.js → swimlanes-5IMT3BWC-261b0Snh.js} +3 -3
- package/dist/{swimlanes-5IMT3BWC-DW61y4w7.cjs → swimlanes-5IMT3BWC-BogVCjJZ.cjs} +1 -1
- package/dist/{swimlanesDiagram-G3AALYLV-CaDY11RK.js → swimlanesDiagram-G3AALYLV-0hHND0xf.js} +2 -2
- package/dist/{swimlanesDiagram-G3AALYLV-DN1x1exB.cjs → swimlanesDiagram-G3AALYLV-B-HBl7xR.cjs} +1 -1
- package/dist/{timeline-definition-FHXFAJF6-GIvmYQNR.js → timeline-definition-FHXFAJF6-B_euDX4t.js} +2 -2
- package/dist/{timeline-definition-FHXFAJF6-DCW8SrSN.cjs → timeline-definition-FHXFAJF6-Cm4g61OO.cjs} +1 -1
- package/dist/{vennDiagram-L72KCM5P-DtN1NFNM.js → vennDiagram-L72KCM5P-BL65fZ2Z.js} +1 -1
- package/dist/{vennDiagram-L72KCM5P-wENEw3FH.cjs → vennDiagram-L72KCM5P-DCLNzpM1.cjs} +1 -1
- package/dist/{wardleyDiagram-EHGQE667-CPYTbfuJ.js → wardleyDiagram-EHGQE667-BbdgmKNq.js} +2 -2
- package/dist/{wardleyDiagram-EHGQE667-Daugt2NV.cjs → wardleyDiagram-EHGQE667-yrrICYTB.cjs} +1 -1
- package/dist/{xychartDiagram-FW5EYKEG-B3D8pi1c.cjs → xychartDiagram-FW5EYKEG-1YlGN0q3.cjs} +1 -1
- package/dist/{xychartDiagram-FW5EYKEG-C-NgU5xv.js → xychartDiagram-FW5EYKEG-D0ITIjet.js} +2 -2
- package/package.json +10 -11
- package/dist/flowDiagram-23GEKE2U-BHV7jjdl.js +0 -7
- package/dist/flowDiagram-23GEKE2U-Bn8nX3mJ.cjs +0 -1
package/dist/index.server.js
CHANGED
|
@@ -2,9 +2,9 @@ import { R as ge, c as ke, a as be } from "./errors-Blk_XJ9C.js";
|
|
|
2
2
|
import { d as er } from "./errors-Blk_XJ9C.js";
|
|
3
3
|
import { l as L, L as O, a as ae, b as Ee } from "./linkCards-1JxY8wdm.js";
|
|
4
4
|
import { l as h } from "./simple-logger-DwH1YQvq.js";
|
|
5
|
-
import { Resolver as
|
|
5
|
+
import { Resolver as ve } from "node:dns/promises";
|
|
6
6
|
import * as se from "node:net";
|
|
7
|
-
import { BlockList as
|
|
7
|
+
import { BlockList as Te, isIP as ie, connect as Se } from "node:net";
|
|
8
8
|
import { Agent as ye, buildConnector as Y, fetch as Ae } from "undici";
|
|
9
9
|
import { Parser as _e } from "htmlparser2";
|
|
10
10
|
import { spawn as Re } from "node:child_process";
|
|
@@ -13,8 +13,8 @@ import { createRequire as Oe } from "node:module";
|
|
|
13
13
|
import * as M from "node:path";
|
|
14
14
|
import { fileURLToPath as Pe } from "node:url";
|
|
15
15
|
import { createClient as Ce, ConnectError as Me, Code as Ie } from "@connectrpc/connect";
|
|
16
|
-
import { Http2SessionManager as
|
|
17
|
-
import { Message as
|
|
16
|
+
import { Http2SessionManager as Ne, createConnectTransport as xe } from "@connectrpc/connect-node";
|
|
17
|
+
import { Message as N, proto3 as d, MethodKind as De } from "@bufbuild/protobuf";
|
|
18
18
|
const Be = [
|
|
19
19
|
[[0], 8],
|
|
20
20
|
[[10], 8],
|
|
@@ -45,45 +45,45 @@ const Be = [
|
|
|
45
45
|
[[65152], 10],
|
|
46
46
|
[[65216], 10],
|
|
47
47
|
[[65280], 8]
|
|
48
|
-
], T = new
|
|
49
|
-
for (const [
|
|
50
|
-
const e = [...
|
|
51
|
-
T.addSubnet(e,
|
|
48
|
+
], T = new Te();
|
|
49
|
+
for (const [t, r] of Be) {
|
|
50
|
+
const e = [...t, 0, 0, 0].slice(0, 4).join(".");
|
|
51
|
+
T.addSubnet(e, r, "ipv4"), T.addSubnet(`::ffff:${e}`, 96 + r, "ipv6"), T.addSubnet(`::${e}`, 96 + r, "ipv6");
|
|
52
52
|
}
|
|
53
|
-
for (const [
|
|
54
|
-
T.addSubnet(`${
|
|
55
|
-
const $ = (
|
|
56
|
-
const
|
|
57
|
-
return e !== 0 && T.check(
|
|
58
|
-
}, le = "ERR_LINK_CARD_PRIVATE_ADDRESS", Z = Object.freeze({ timeoutMs: 1e3, tries: 2 }), q = new
|
|
59
|
-
error: Object.assign(new Error(`Blocked hostname resolving to a private address: ${
|
|
60
|
-
}), $e = async (
|
|
61
|
-
const e = ie(
|
|
53
|
+
for (const [t, r] of Ue)
|
|
54
|
+
T.addSubnet(`${t.map((e) => e.toString(16)).join(":")}::`, r, "ipv6");
|
|
55
|
+
const $ = (t) => {
|
|
56
|
+
const r = t.replace(/^\[/u, "").replace(/\]$/u, "").replace(/%.*$/su, ""), e = ie(r);
|
|
57
|
+
return e !== 0 && T.check(r, e === 4 ? "ipv4" : "ipv6");
|
|
58
|
+
}, le = "ERR_LINK_CARD_PRIVATE_ADDRESS", Z = Object.freeze({ timeoutMs: 1e3, tries: 2 }), q = new ve({ timeout: Z.timeoutMs, tries: Z.tries }), Q = (t, r) => ({
|
|
59
|
+
error: Object.assign(new Error(`Blocked hostname resolving to a private address: ${t} -> ${r}`), { code: le })
|
|
60
|
+
}), $e = async (t, r) => {
|
|
61
|
+
const e = ie(t);
|
|
62
62
|
if (e !== 0)
|
|
63
|
-
return $(
|
|
64
|
-
const [n, o] = await Promise.allSettled([
|
|
65
|
-
if (i !== void 0) return Q(
|
|
63
|
+
return $(t) ? Q(t, t) : { error: null, family: e === 4 ? 4 : 6, addresses: [t] };
|
|
64
|
+
const [n, o] = await Promise.allSettled([r === 6 ? Promise.resolve([]) : q.resolve4(t), r === 4 ? Promise.resolve([]) : q.resolve6(t)]), s = n.status === "fulfilled" ? n.value : [], a = o.status === "fulfilled" ? o.value : [], i = [...s, ...a].find((R) => $(R));
|
|
65
|
+
if (i !== void 0) return Q(t, i);
|
|
66
66
|
const [l, ...c] = s;
|
|
67
67
|
if (l !== void 0) return { error: null, family: 4, addresses: [l, ...c] };
|
|
68
68
|
const [f, ...S] = a;
|
|
69
|
-
return f !== void 0 ? { error: null, family: 6, addresses: [f, ...S] } : n.status === "rejected" ? { error: n.reason } : o.status === "rejected" ? { error: o.reason } : { error: Object.assign(new Error(`No address for ${
|
|
70
|
-
}, He = (
|
|
71
|
-
const n =
|
|
72
|
-
$e(
|
|
69
|
+
return f !== void 0 ? { error: null, family: 6, addresses: [f, ...S] } : n.status === "rejected" ? { error: n.reason } : o.status === "rejected" ? { error: o.reason } : { error: Object.assign(new Error(`No address for ${t}`), { code: "ENOTFOUND" }) };
|
|
70
|
+
}, He = (t, r, e) => {
|
|
71
|
+
const n = r.family === 4 || r.family === "IPv4" ? 4 : r.family === 6 || r.family === "IPv6" ? 6 : 0;
|
|
72
|
+
$e(t, n).then((o) => {
|
|
73
73
|
if (o.error !== null) {
|
|
74
74
|
e(o.error, "");
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
const { family: s, addresses: a } = o;
|
|
78
|
-
|
|
78
|
+
r.all === !0 ? e(
|
|
79
79
|
null,
|
|
80
80
|
a.map((i) => ({ address: i, family: s }))
|
|
81
81
|
) : e(null, a[0], s);
|
|
82
82
|
});
|
|
83
|
-
}, je = /* @__PURE__ */ new Set(["127.0.0.1", "0.0.0.0", "[::1]"]),
|
|
83
|
+
}, je = /* @__PURE__ */ new Set(["127.0.0.1", "0.0.0.0", "[::1]"]), Ke = [".local", ".internal", ".home.arpa"], j = (t, r) => {
|
|
84
84
|
let e;
|
|
85
85
|
try {
|
|
86
|
-
e = new URL(
|
|
86
|
+
e = new URL(t);
|
|
87
87
|
} catch {
|
|
88
88
|
return { ok: !1, reason: "forbidden-url", detail: "Invalid URL" };
|
|
89
89
|
}
|
|
@@ -93,79 +93,79 @@ const $ = (r) => {
|
|
|
93
93
|
return { ok: !1, reason: "forbidden-url", detail: "URLs with a user name or password are not allowed" };
|
|
94
94
|
e.hash = "";
|
|
95
95
|
const n = e.hostname.replace(/\.+$/u, "");
|
|
96
|
-
return n === "localhost" || n.endsWith(".localhost") || je.has(n) ? { ok: !1, reason: "private-network", detail: "Localhost access is not allowed" } : $(n) ? { ok: !1, reason: "private-network", detail: "Private network access is not allowed" } : !(n.startsWith("[") || n.includes(".")) ||
|
|
97
|
-
}, ce = (
|
|
98
|
-
let
|
|
96
|
+
return n === "localhost" || n.endsWith(".localhost") || je.has(n) ? { ok: !1, reason: "private-network", detail: "Localhost access is not allowed" } : $(n) ? { ok: !1, reason: "private-network", detail: "Private network access is not allowed" } : !(n.startsWith("[") || n.includes(".")) || Ke.some((s) => n.endsWith(s)) ? { ok: !1, reason: "private-network", detail: "Internal domain access is not allowed" } : { ok: !0, href: e.href };
|
|
97
|
+
}, ce = (t) => {
|
|
98
|
+
let r;
|
|
99
99
|
try {
|
|
100
|
-
|
|
100
|
+
r = new URL(t);
|
|
101
101
|
} catch {
|
|
102
102
|
return "(unparsable URL)";
|
|
103
103
|
}
|
|
104
|
-
return
|
|
105
|
-
}, ue = 1024,
|
|
104
|
+
return r.protocol !== "http:" && r.protocol !== "https:" ? `(a ${r.protocol} URL)` : (r.username = "", r.password = "", r.href);
|
|
105
|
+
}, ue = 1024, ze = /^[\t\n\f\r ]$/u, w = (t) => ze.test(t), B = (t) => t.replace(/[A-Z]/gu, (r) => r.toLowerCase()), H = (t) => {
|
|
106
106
|
try {
|
|
107
|
-
return new TextDecoder(
|
|
107
|
+
return new TextDecoder(t).encoding;
|
|
108
108
|
} catch {
|
|
109
109
|
return null;
|
|
110
110
|
}
|
|
111
|
-
},
|
|
112
|
-
for (const
|
|
113
|
-
const e =
|
|
114
|
-
if (e !== -1 &&
|
|
115
|
-
return
|
|
111
|
+
}, Je = (t) => t[0] === 239 && t[1] === 187 && t[2] === 191 ? "utf-8" : t[0] === 254 && t[1] === 255 ? "utf-16be" : t[0] === 255 && t[1] === 254 ? "utf-16le" : null, Fe = (t) => {
|
|
112
|
+
for (const r of t.split(";").slice(1)) {
|
|
113
|
+
const e = r.indexOf("=");
|
|
114
|
+
if (e !== -1 && r.slice(0, e).trim().toLowerCase() === "charset")
|
|
115
|
+
return r.slice(e + 1).trim().replace(/^"(.*)"$/su, "$1");
|
|
116
116
|
}
|
|
117
117
|
return null;
|
|
118
|
-
}, Ge = (
|
|
119
|
-
let
|
|
118
|
+
}, Ge = (t) => {
|
|
119
|
+
let r = 0;
|
|
120
120
|
for (; ; ) {
|
|
121
|
-
const e =
|
|
121
|
+
const e = t.indexOf("charset", r);
|
|
122
122
|
if (e === -1) return null;
|
|
123
123
|
let n = e + 7;
|
|
124
|
-
for (; w(
|
|
125
|
-
if (
|
|
126
|
-
|
|
124
|
+
for (; w(t.charAt(n)); ) n += 1;
|
|
125
|
+
if (t.charAt(n) !== "=") {
|
|
126
|
+
r = n;
|
|
127
127
|
continue;
|
|
128
128
|
}
|
|
129
|
-
for (n += 1; w(
|
|
130
|
-
const o =
|
|
129
|
+
for (n += 1; w(t.charAt(n)); ) n += 1;
|
|
130
|
+
const o = t.charAt(n);
|
|
131
131
|
if (o === '"' || o === "'") {
|
|
132
|
-
const a =
|
|
133
|
-
return a === -1 ? null :
|
|
132
|
+
const a = t.indexOf(o, n + 1);
|
|
133
|
+
return a === -1 ? null : t.slice(n + 1, a);
|
|
134
134
|
}
|
|
135
|
-
const s =
|
|
136
|
-
return s === -1 ?
|
|
135
|
+
const s = t.slice(n).search(/[\t\n\f\r ;]/u);
|
|
136
|
+
return s === -1 ? t.slice(n) : t.slice(n, n + s);
|
|
137
137
|
}
|
|
138
|
-
}, de = (
|
|
139
|
-
let e =
|
|
140
|
-
for (; w(
|
|
141
|
-
if (
|
|
138
|
+
}, de = (t, r) => {
|
|
139
|
+
let e = r;
|
|
140
|
+
for (; w(t.charAt(e)) || t.charAt(e) === "/"; ) e += 1;
|
|
141
|
+
if (t.charAt(e) === ">" || e >= t.length) return { attribute: null, end: e };
|
|
142
142
|
let n = "";
|
|
143
143
|
for (; ; ) {
|
|
144
|
-
const a =
|
|
144
|
+
const a = t.charAt(e);
|
|
145
145
|
if (a === "") return { attribute: null, end: e };
|
|
146
146
|
if (a === "=" && n !== "") break;
|
|
147
147
|
if (w(a)) {
|
|
148
|
-
for (; w(
|
|
149
|
-
if (
|
|
148
|
+
for (; w(t.charAt(e)); ) e += 1;
|
|
149
|
+
if (t.charAt(e) !== "=") return { attribute: { name: n, value: "" }, end: e };
|
|
150
150
|
break;
|
|
151
151
|
}
|
|
152
152
|
if (a === "/" || a === ">") return { attribute: { name: n, value: "" }, end: e };
|
|
153
153
|
n += B(a), e += 1;
|
|
154
154
|
}
|
|
155
|
-
for (e += 1; w(
|
|
156
|
-
const o =
|
|
155
|
+
for (e += 1; w(t.charAt(e)); ) e += 1;
|
|
156
|
+
const o = t.charAt(e);
|
|
157
157
|
if (o === '"' || o === "'") {
|
|
158
|
-
const a =
|
|
159
|
-
return a === -1 ? { attribute: null, end:
|
|
158
|
+
const a = t.indexOf(o, e + 1);
|
|
159
|
+
return a === -1 ? { attribute: null, end: t.length } : { attribute: { name: n, value: B(t.slice(e + 1, a)) }, end: a + 1 };
|
|
160
160
|
}
|
|
161
161
|
if (o === ">") return { attribute: { name: n, value: "" }, end: e };
|
|
162
|
-
const s =
|
|
163
|
-
return s === -1 ? { attribute: null, end:
|
|
164
|
-
}, Xe = (
|
|
162
|
+
const s = t.slice(e).search(/[\t\n\f\r >]/u);
|
|
163
|
+
return s === -1 ? { attribute: null, end: t.length } : { attribute: { name: n, value: B(t.slice(e, e + s)) }, end: e + s };
|
|
164
|
+
}, Xe = (t, r) => {
|
|
165
165
|
const e = /* @__PURE__ */ new Set();
|
|
166
|
-
let n = !1, o = null, s = null, a =
|
|
166
|
+
let n = !1, o = null, s = null, a = r;
|
|
167
167
|
for (; ; ) {
|
|
168
|
-
const { attribute: i, end: l } = de(
|
|
168
|
+
const { attribute: i, end: l } = de(t, a);
|
|
169
169
|
if (a = l, i === null) break;
|
|
170
170
|
if (!e.has(i.name))
|
|
171
171
|
if (e.add(i.name), i.name === "http-equiv")
|
|
@@ -176,110 +176,110 @@ const $ = (r) => {
|
|
|
176
176
|
} else i.name === "charset" && (s = H(i.value) ?? !1, o = !1);
|
|
177
177
|
}
|
|
178
178
|
return o === null || typeof s != "string" || o && !n ? { encoding: null, end: a } : s === "utf-16be" || s === "utf-16le" ? { encoding: "utf-8", end: a } : { encoding: s === "x-user-defined" ? "windows-1252" : s, end: a };
|
|
179
|
-
}, Ve = (
|
|
180
|
-
const
|
|
179
|
+
}, Ve = (t) => {
|
|
180
|
+
const r = Array.from(t.subarray(0, ue), (n) => String.fromCharCode(n)).join("");
|
|
181
181
|
let e = 0;
|
|
182
|
-
for (; e <
|
|
183
|
-
if (
|
|
184
|
-
const n =
|
|
182
|
+
for (; e < r.length; )
|
|
183
|
+
if (r.startsWith("<!--", e)) {
|
|
184
|
+
const n = r.indexOf("-->", e + 2);
|
|
185
185
|
if (n === -1) return null;
|
|
186
186
|
e = n + 3;
|
|
187
|
-
} else if (/^<meta[\t\n\f\r /]$/iu.test(
|
|
188
|
-
const { encoding: n, end: o } = Xe(
|
|
187
|
+
} else if (/^<meta[\t\n\f\r /]$/iu.test(r.slice(e, e + 6))) {
|
|
188
|
+
const { encoding: n, end: o } = Xe(r, e + 5);
|
|
189
189
|
if (n !== null) return n;
|
|
190
190
|
e = o + 1;
|
|
191
|
-
} else if (/^<\/?[A-Za-z]/u.test(
|
|
191
|
+
} else if (/^<\/?[A-Za-z]/u.test(r.slice(e, e + 3))) {
|
|
192
192
|
let n = e + 1;
|
|
193
|
-
for (; n <
|
|
193
|
+
for (; n < r.length && !w(r.charAt(n)) && r.charAt(n) !== ">"; ) n += 1;
|
|
194
194
|
for (; ; ) {
|
|
195
|
-
const o = de(
|
|
195
|
+
const o = de(r, n);
|
|
196
196
|
if (n = o.end, o.attribute === null) break;
|
|
197
197
|
}
|
|
198
198
|
e = n + 1;
|
|
199
|
-
} else if (/^<[!/?]$/u.test(
|
|
200
|
-
const n =
|
|
199
|
+
} else if (/^<[!/?]$/u.test(r.slice(e, e + 2))) {
|
|
200
|
+
const n = r.indexOf(">", e + 1);
|
|
201
201
|
if (n === -1) return null;
|
|
202
202
|
e = n + 1;
|
|
203
203
|
} else
|
|
204
204
|
e += 1;
|
|
205
205
|
return null;
|
|
206
|
-
}, We = (
|
|
207
|
-
const e =
|
|
206
|
+
}, We = (t, r) => {
|
|
207
|
+
const e = Je(t);
|
|
208
208
|
if (e !== null) return e;
|
|
209
|
-
const n = Fe(
|
|
210
|
-
return o !== null ? o : Ve(
|
|
211
|
-
}, Ye = (
|
|
212
|
-
const e = new Uint8Array(
|
|
209
|
+
const n = Fe(r), o = n === null ? null : H(n);
|
|
210
|
+
return o !== null ? o : Ve(t) ?? "utf-8";
|
|
211
|
+
}, Ye = (t, r) => {
|
|
212
|
+
const e = new Uint8Array(r);
|
|
213
213
|
let n = 0;
|
|
214
|
-
for (const o of
|
|
214
|
+
for (const o of t)
|
|
215
215
|
e.set(o, n), n += o.byteLength;
|
|
216
216
|
return e;
|
|
217
|
-
}, Ze = (
|
|
218
|
-
const
|
|
217
|
+
}, Ze = (t) => {
|
|
218
|
+
const r = [];
|
|
219
219
|
let e = 0, n = null;
|
|
220
220
|
const o = () => {
|
|
221
|
-
const s = Ye(
|
|
222
|
-
|
|
223
|
-
const a = new TextDecoder(We(s,
|
|
221
|
+
const s = Ye(r, e);
|
|
222
|
+
r.length = 0;
|
|
223
|
+
const a = new TextDecoder(We(s, t));
|
|
224
224
|
return n = a, { started: a, text: a.decode(s, { stream: !0 }) };
|
|
225
225
|
};
|
|
226
226
|
return {
|
|
227
|
-
write: (s) => n !== null ? n.decode(s, { stream: !0 }) : (
|
|
227
|
+
write: (s) => n !== null ? n.decode(s, { stream: !0 }) : (r.push(s), e += s.byteLength, e < ue ? "" : o().text),
|
|
228
228
|
end: () => {
|
|
229
229
|
if (n !== null) return n.decode();
|
|
230
230
|
const { started: s, text: a } = o();
|
|
231
231
|
return a + s.decode();
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
|
-
}, qe = (
|
|
234
|
+
}, qe = (t, r, e) => {
|
|
235
235
|
const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
236
236
|
return (s) => {
|
|
237
237
|
const a = n.get(s);
|
|
238
238
|
if (a !== void 0 && a.expireAt > e()) return Promise.resolve(a.value);
|
|
239
239
|
const i = o.get(s);
|
|
240
240
|
if (i !== void 0) return i;
|
|
241
|
-
const l =
|
|
241
|
+
const l = t(s).then((c) => (!n.has(s) && n.size >= r.maxEntries && n.delete(n.keys().next().value), n.set(s, { value: c, expireAt: e() + r.ttlMsOf(c) }), c)).finally(() => {
|
|
242
242
|
o.delete(s);
|
|
243
243
|
});
|
|
244
244
|
return o.set(s, l), l;
|
|
245
245
|
};
|
|
246
|
-
}, Qe = 65536, et = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]), tt = /* @__PURE__ */ new Set(["text/html", "application/xhtml+xml"]), rt = /* @__PURE__ */ new Set(["ERR_IP_BLOCKED", le]), fe = Object.freeze({ timeoutMs: 5e3, maxRedirects: 5, maxBodyBytes: 8 * 1024 * 1024 }), nt = Object.freeze({ lookup: He, blockList: T }), ot = (
|
|
247
|
-
const e = Y({ lookup:
|
|
246
|
+
}, Qe = 65536, et = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]), tt = /* @__PURE__ */ new Set(["text/html", "application/xhtml+xml"]), rt = /* @__PURE__ */ new Set(["ERR_IP_BLOCKED", le]), fe = Object.freeze({ timeoutMs: 5e3, maxRedirects: 5, maxBodyBytes: 8 * 1024 * 1024 }), nt = Object.freeze({ lookup: He, blockList: T }), ot = (t, r) => {
|
|
247
|
+
const e = Y({ lookup: t.lookup, blockList: t.blockList, timeout: r }), n = Y({ timeout: r });
|
|
248
248
|
return (o, s) => {
|
|
249
249
|
if (o.protocol !== "https:") {
|
|
250
250
|
e(o, s);
|
|
251
251
|
return;
|
|
252
252
|
}
|
|
253
|
-
const a = Se({ host: o.hostname, port: Number(o.port === "" ? 443 : o.port), lookup:
|
|
253
|
+
const a = Se({ host: o.hostname, port: Number(o.port === "" ? 443 : o.port), lookup: t.lookup, blockList: t.blockList }), i = (l) => {
|
|
254
254
|
a.destroy(), s(l, null);
|
|
255
255
|
};
|
|
256
|
-
a.setTimeout(
|
|
256
|
+
a.setTimeout(r, () => i(Object.assign(new Error(`Connect timeout: ${o.hostname}`), { code: "UND_ERR_CONNECT_TIMEOUT" }))), a.once("error", i), a.once("connect", () => {
|
|
257
257
|
a.setTimeout(0), a.removeListener("error", i), n({ ...o, httpSocket: a }, s);
|
|
258
258
|
});
|
|
259
259
|
};
|
|
260
|
-
}, at = (
|
|
260
|
+
}, at = (t) => new ye({
|
|
261
261
|
maxHeaderSize: Qe,
|
|
262
262
|
connect: ot(nt, fe.timeoutMs)
|
|
263
|
-
}), U = async (
|
|
264
|
-
|
|
265
|
-
}, st = (
|
|
266
|
-
const
|
|
267
|
-
for (let e = 0; e < 16 &&
|
|
268
|
-
const n =
|
|
263
|
+
}), U = async (t) => {
|
|
264
|
+
t.body !== null && await Promise.allSettled([t.body.cancel()]);
|
|
265
|
+
}, st = (t) => t !== null && tt.has(t.split(";", 1)[0].trim().toLowerCase()), it = (t) => {
|
|
266
|
+
const r = [t];
|
|
267
|
+
for (let e = 0; e < 16 && r.length > 0; e += 1) {
|
|
268
|
+
const n = r.shift();
|
|
269
269
|
if (!(n instanceof Error)) continue;
|
|
270
270
|
const o = n.code;
|
|
271
271
|
if (typeof o == "string" && rt.has(o)) return n.message;
|
|
272
|
-
|
|
272
|
+
r.push(n.cause, ...n instanceof AggregateError ? n.errors : []);
|
|
273
273
|
}
|
|
274
274
|
return null;
|
|
275
|
-
}, me = (
|
|
276
|
-
const e = it(
|
|
277
|
-
return e !== null ? (h.info("Refused link-card connection to a private address:",
|
|
278
|
-
}, lt = () => new Promise((
|
|
279
|
-
setImmediate(
|
|
280
|
-
}), ct = async (
|
|
281
|
-
if (
|
|
282
|
-
const o =
|
|
275
|
+
}, me = (t, r) => {
|
|
276
|
+
const e = it(t);
|
|
277
|
+
return e !== null ? (h.info("Refused link-card connection to a private address:", r, e), { ok: !1, reason: "private-network" }) : (h.error("Error fetching link-card metadata:", t), { ok: !1, reason: "unreachable" });
|
|
278
|
+
}, lt = () => new Promise((t) => {
|
|
279
|
+
setImmediate(t);
|
|
280
|
+
}), ct = async (t, r, e, n) => {
|
|
281
|
+
if (t.body === null) return { ok: !0, value: r.end() };
|
|
282
|
+
const o = t.body.getReader();
|
|
283
283
|
let s = 0;
|
|
284
284
|
for (; ; ) {
|
|
285
285
|
let a;
|
|
@@ -290,7 +290,7 @@ const $ = (r) => {
|
|
|
290
290
|
}
|
|
291
291
|
if (a.done) break;
|
|
292
292
|
const i = e - s, l = a.value.byteLength > i, c = l ? a.value.subarray(0, i) : a.value;
|
|
293
|
-
if (s += c.byteLength, !
|
|
293
|
+
if (s += c.byteLength, !r.write(c)) {
|
|
294
294
|
await Promise.allSettled([o.cancel()]);
|
|
295
295
|
break;
|
|
296
296
|
}
|
|
@@ -300,13 +300,13 @@ const $ = (r) => {
|
|
|
300
300
|
}
|
|
301
301
|
await lt();
|
|
302
302
|
}
|
|
303
|
-
return { ok: !0, value:
|
|
304
|
-
}, ut = async (
|
|
305
|
-
let o =
|
|
306
|
-
for (let s = 0; s <=
|
|
303
|
+
return { ok: !0, value: r.end() };
|
|
304
|
+
}, ut = async (t, r, e, n) => {
|
|
305
|
+
let o = t;
|
|
306
|
+
for (let s = 0; s <= r.limits.maxRedirects; s += 1) {
|
|
307
307
|
let a;
|
|
308
308
|
try {
|
|
309
|
-
a = await Ae(o, { signal: n, redirect: "manual", dispatcher:
|
|
309
|
+
a = await Ae(o, { signal: n, redirect: "manual", dispatcher: r.agent });
|
|
310
310
|
} catch (f) {
|
|
311
311
|
return me(f, o);
|
|
312
312
|
}
|
|
@@ -315,7 +315,7 @@ const $ = (r) => {
|
|
|
315
315
|
if (!a.ok)
|
|
316
316
|
return await U(a), { ok: !1, reason: "unreachable" };
|
|
317
317
|
const f = a.headers.get("content-type");
|
|
318
|
-
return st(f) ? ct(a, e({ url: o, contentType: f }),
|
|
318
|
+
return st(f) ? ct(a, e({ url: o, contentType: f }), r.limits.maxBodyBytes, o) : (await U(a), { ok: !1, reason: "not-html" });
|
|
319
319
|
}
|
|
320
320
|
await U(a);
|
|
321
321
|
let l;
|
|
@@ -329,42 +329,42 @@ const $ = (r) => {
|
|
|
329
329
|
return h.info("Refused link-card redirect:", ce(l), `(${c.reason}: ${c.detail})`), { ok: !1, reason: c.reason };
|
|
330
330
|
o = c.href;
|
|
331
331
|
}
|
|
332
|
-
return h.error("Too many redirects while fetching link-card metadata:",
|
|
333
|
-
}, dt = (
|
|
334
|
-
const n = new AbortController(), o = setTimeout(() => n.abort(),
|
|
335
|
-
return ut(
|
|
332
|
+
return h.error("Too many redirects while fetching link-card metadata:", t), { ok: !1, reason: "unreachable" };
|
|
333
|
+
}, dt = (t, r, e) => {
|
|
334
|
+
const n = new AbortController(), o = setTimeout(() => n.abort(), r.limits.timeoutMs);
|
|
335
|
+
return ut(t, r, e, n.signal).finally(() => {
|
|
336
336
|
clearTimeout(o);
|
|
337
337
|
});
|
|
338
|
-
}, ft = 256, mt = 4096, pt = 64, ht = /* @__PURE__ */ new Set(["html", "head", "title", "meta", "link", "base", "basefont", "bgsound", "noframes", "script", "style", "template", "noscript"]), wt = /* @__PURE__ */ new Set(["title", "script", "style"]), gt = /* @__PURE__ */ new Set(["noscript", "template", "noframes"]), kt = (
|
|
339
|
-
if (
|
|
338
|
+
}, ft = 256, mt = 4096, pt = 64, ht = /* @__PURE__ */ new Set(["html", "head", "title", "meta", "link", "base", "basefont", "bgsound", "noframes", "script", "style", "template", "noscript"]), wt = /* @__PURE__ */ new Set(["title", "script", "style"]), gt = /* @__PURE__ */ new Set(["noscript", "template", "noframes"]), kt = (t) => t?.toLowerCase().split(/[\t\n\f\r ]+/u).includes("icon") === !0, bt = (t, r) => {
|
|
339
|
+
if (t === void 0) return r;
|
|
340
340
|
let e;
|
|
341
341
|
try {
|
|
342
|
-
e = new URL(
|
|
342
|
+
e = new URL(t, r);
|
|
343
343
|
} catch {
|
|
344
|
-
return
|
|
344
|
+
return r;
|
|
345
345
|
}
|
|
346
|
-
return (e.protocol === "http:" || e.protocol === "https:") && e.href.length <= ae ? e.href :
|
|
347
|
-
}, ee = (
|
|
348
|
-
const n =
|
|
346
|
+
return (e.protocol === "http:" || e.protocol === "https:") && e.href.length <= ae ? e.href : r;
|
|
347
|
+
}, ee = (t, r, e) => {
|
|
348
|
+
const n = t?.trim();
|
|
349
349
|
if (n === void 0 || n === "") return;
|
|
350
350
|
let o;
|
|
351
351
|
try {
|
|
352
|
-
o = new URL(n,
|
|
352
|
+
o = new URL(n, r);
|
|
353
353
|
} catch {
|
|
354
354
|
return;
|
|
355
355
|
}
|
|
356
356
|
return o.href.length <= ae && j(o.href).ok ? o.href : void 0;
|
|
357
|
-
}, Et = (
|
|
358
|
-
let e = !1, n = 0, o = 0, s = 0, a = null, i = null, l = null, c, f, S, R, z, J
|
|
359
|
-
const
|
|
357
|
+
}, Et = (t, r) => {
|
|
358
|
+
let e = !1, n = 0, o = 0, s = 0, a = null, i = null, l = null, c, f, S, R, K, z, J = !1, F, G = !1;
|
|
359
|
+
const x = () => {
|
|
360
360
|
e = !0, D.pause();
|
|
361
361
|
}, D = new _e(
|
|
362
362
|
{
|
|
363
363
|
onopentagname(u) {
|
|
364
|
-
n += 1, o += 1, s = 0, (n > ft || o > mt || a === null && !ht.has(u)) &&
|
|
364
|
+
n += 1, o += 1, s = 0, (n > ft || o > mt || a === null && !ht.has(u)) && x();
|
|
365
365
|
},
|
|
366
366
|
onattribute() {
|
|
367
|
-
s += 1, s > pt &&
|
|
367
|
+
s += 1, s > pt && x();
|
|
368
368
|
},
|
|
369
369
|
onopentag(u, m) {
|
|
370
370
|
if (!(e || a !== null)) {
|
|
@@ -374,13 +374,13 @@ const $ = (r) => {
|
|
|
374
374
|
}
|
|
375
375
|
if (u === "meta") {
|
|
376
376
|
const p = m.content;
|
|
377
|
-
m.property === "og:site_name" && (R = p), m.property === "og:title" && (f = p), m.property === "og:description" && (S = p), m.property === "og:image" && (
|
|
378
|
-
} else u === "link" && !
|
|
377
|
+
m.property === "og:site_name" && (R = p), m.property === "og:title" && (f = p), m.property === "og:description" && (S = p), m.property === "og:image" && (K = p), m.name === "description" && (S = p);
|
|
378
|
+
} else u === "link" && !J && kt(m.rel) ? (J = !0, z = m.href) : u === "base" && !G && Object.hasOwn(m, "href") && (G = !0, F = m.href);
|
|
379
379
|
wt.has(u) && (i = u, u === "title" && c === void 0 && (l = ""));
|
|
380
380
|
}
|
|
381
381
|
},
|
|
382
382
|
ontext(u) {
|
|
383
|
-
a === null && (l !== null ? l += u : i === null && /[^\t\n\f\r ]/u.test(u) &&
|
|
383
|
+
a === null && (l !== null ? l += u : i === null && /[^\t\n\f\r ]/u.test(u) && x());
|
|
384
384
|
},
|
|
385
385
|
onclosetag(u) {
|
|
386
386
|
if (!e) {
|
|
@@ -398,7 +398,7 @@ const $ = (r) => {
|
|
|
398
398
|
write: (u) => (e || D.write(u), !e),
|
|
399
399
|
end: () => {
|
|
400
400
|
e || D.end();
|
|
401
|
-
const u = L(f, O.title) ?? L(c, O.title), m = L(S, O.description), p = L(R, O.siteName), X = bt(F,
|
|
401
|
+
const u = L(f, O.title) ?? L(c, O.title), m = L(S, O.description), p = L(R, O.siteName), X = bt(F, t), V = ee(K, X), W = ee(z, X);
|
|
402
402
|
return {
|
|
403
403
|
...u === null ? {} : { title: u },
|
|
404
404
|
...m === null ? {} : { description: m },
|
|
@@ -408,30 +408,30 @@ const $ = (r) => {
|
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
410
|
};
|
|
411
|
-
},
|
|
412
|
-
status:
|
|
411
|
+
}, vt = /* @__PURE__ */ new Set(["authorize"]), Tt = "private, max-age=1800", St = 3600 * 1e3, pe = Object.freeze({ "private-network": 1800, "forbidden-url": 1800, unreachable: 300, "not-html": 300 }), yt = 1e3, P = "no-store", y = (t, r, e, n, o = {}) => new Response(t.method === "HEAD" ? null : JSON.stringify(e), {
|
|
412
|
+
status: r,
|
|
413
413
|
headers: { "Content-Type": "application/json; charset=utf-8", "Cache-Control": n, "X-Content-Type-Options": "nosniff", ...o }
|
|
414
|
-
}), te = (
|
|
414
|
+
}), te = (t) => new Response(null, {
|
|
415
415
|
status: 204,
|
|
416
|
-
headers: { "Cache-Control": `private, max-age=${pe[
|
|
417
|
-
}), At = (
|
|
418
|
-
if (typeof
|
|
416
|
+
headers: { "Cache-Control": `private, max-age=${pe[t]}`, "X-Content-Type-Options": "nosniff", [Ee]: t }
|
|
417
|
+
}), At = (t) => {
|
|
418
|
+
if (typeof t != "object" || t === null)
|
|
419
419
|
throw new TypeError("createLinkCardHandler: options must be an object with an authorize function");
|
|
420
|
-
if (typeof
|
|
420
|
+
if (typeof t.authorize != "function")
|
|
421
421
|
throw new TypeError("createLinkCardHandler: options.authorize must be a function (pass () => true to serve everyone)");
|
|
422
|
-
const
|
|
423
|
-
if (
|
|
424
|
-
throw new TypeError(`createLinkCardHandler: unknown option(s): ${
|
|
425
|
-
}, _t = (
|
|
426
|
-
const e = Ze(
|
|
422
|
+
const r = Object.keys(t).filter((e) => !vt.has(e));
|
|
423
|
+
if (r.length > 0)
|
|
424
|
+
throw new TypeError(`createLinkCardHandler: unknown option(s): ${r.join(", ")}`);
|
|
425
|
+
}, _t = (t) => (r) => {
|
|
426
|
+
const e = Ze(r.contentType), n = Et(r.url);
|
|
427
427
|
return {
|
|
428
428
|
write: (o) => n.write(e.write(o)),
|
|
429
429
|
end: () => (n.write(e.end()), n.end())
|
|
430
430
|
};
|
|
431
|
-
}, Rt = (
|
|
432
|
-
At(
|
|
433
|
-
const { authorize: e } =
|
|
434
|
-
(s) => dt(s, { agent: n, scope:
|
|
431
|
+
}, Rt = (t, r) => {
|
|
432
|
+
At(t);
|
|
433
|
+
const { authorize: e } = t, n = at(), o = qe(
|
|
434
|
+
(s) => dt(s, { agent: n, scope: r, limits: fe }, _t()),
|
|
435
435
|
{ maxEntries: yt, ttlMsOf: (s) => s.ok ? St : pe[s.reason] * 1e3 },
|
|
436
436
|
Date.now
|
|
437
437
|
);
|
|
@@ -452,10 +452,10 @@ const $ = (r) => {
|
|
|
452
452
|
} catch (c) {
|
|
453
453
|
return h.error("Unexpected error while reading link-card metadata:", i.href, c), y(s, 500, { error: "Internal Server Error" }, P);
|
|
454
454
|
}
|
|
455
|
-
return l.ok ? y(s, 200, l.value,
|
|
455
|
+
return l.ok ? y(s, 200, l.value, Tt) : te(l.reason);
|
|
456
456
|
};
|
|
457
|
-
}, Yt = (
|
|
458
|
-
class
|
|
457
|
+
}, Yt = (t) => Rt(t, "public");
|
|
458
|
+
class b extends N {
|
|
459
459
|
/**
|
|
460
460
|
* @generated from field: string markdown_text = 1;
|
|
461
461
|
*/
|
|
@@ -564,8 +564,8 @@ class k extends x {
|
|
|
564
564
|
* @generated from field: bool include_source_lines = 14;
|
|
565
565
|
*/
|
|
566
566
|
includeSourceLines = !1;
|
|
567
|
-
constructor(
|
|
568
|
-
super(), d.util.initPartial(
|
|
567
|
+
constructor(r) {
|
|
568
|
+
super(), d.util.initPartial(r, this);
|
|
569
569
|
}
|
|
570
570
|
static runtime = d;
|
|
571
571
|
static typeName = "markdown.v1.ConvertRequest";
|
|
@@ -621,44 +621,44 @@ class k extends x {
|
|
|
621
621
|
/* ScalarType.BOOL */
|
|
622
622
|
}
|
|
623
623
|
]);
|
|
624
|
-
static fromBinary(
|
|
625
|
-
return new
|
|
624
|
+
static fromBinary(r, e) {
|
|
625
|
+
return new b().fromBinary(r, e);
|
|
626
626
|
}
|
|
627
|
-
static fromJson(
|
|
628
|
-
return new
|
|
627
|
+
static fromJson(r, e) {
|
|
628
|
+
return new b().fromJson(r, e);
|
|
629
629
|
}
|
|
630
|
-
static fromJsonString(
|
|
631
|
-
return new
|
|
630
|
+
static fromJsonString(r, e) {
|
|
631
|
+
return new b().fromJsonString(r, e);
|
|
632
632
|
}
|
|
633
|
-
static equals(
|
|
634
|
-
return d.util.equals(
|
|
633
|
+
static equals(r, e) {
|
|
634
|
+
return d.util.equals(b, r, e);
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
|
-
class g extends
|
|
637
|
+
class g extends N {
|
|
638
638
|
/**
|
|
639
639
|
* @generated from field: repeated string segment_patterns = 1;
|
|
640
640
|
*/
|
|
641
641
|
segmentPatterns = [];
|
|
642
|
-
constructor(
|
|
643
|
-
super(), d.util.initPartial(
|
|
642
|
+
constructor(r) {
|
|
643
|
+
super(), d.util.initPartial(r, this);
|
|
644
644
|
}
|
|
645
645
|
static runtime = d;
|
|
646
646
|
static typeName = "markdown.v1.DenyRules";
|
|
647
647
|
static fields = d.util.newFieldList(() => [{ no: 1, name: "segment_patterns", kind: "scalar", T: 9, repeated: !0 }]);
|
|
648
|
-
static fromBinary(
|
|
649
|
-
return new g().fromBinary(
|
|
648
|
+
static fromBinary(r, e) {
|
|
649
|
+
return new g().fromBinary(r, e);
|
|
650
650
|
}
|
|
651
|
-
static fromJson(
|
|
652
|
-
return new g().fromJson(
|
|
651
|
+
static fromJson(r, e) {
|
|
652
|
+
return new g().fromJson(r, e);
|
|
653
653
|
}
|
|
654
|
-
static fromJsonString(
|
|
655
|
-
return new g().fromJsonString(
|
|
654
|
+
static fromJsonString(r, e) {
|
|
655
|
+
return new g().fromJsonString(r, e);
|
|
656
656
|
}
|
|
657
|
-
static equals(
|
|
658
|
-
return d.util.equals(g,
|
|
657
|
+
static equals(r, e) {
|
|
658
|
+
return d.util.equals(g, r, e);
|
|
659
659
|
}
|
|
660
660
|
}
|
|
661
|
-
class
|
|
661
|
+
class E extends N {
|
|
662
662
|
/**
|
|
663
663
|
* @generated from field: string html_content = 1;
|
|
664
664
|
*/
|
|
@@ -667,8 +667,8 @@ class b extends x {
|
|
|
667
667
|
* @generated from field: repeated markdown.v1.Heading headings = 2;
|
|
668
668
|
*/
|
|
669
669
|
headings = [];
|
|
670
|
-
constructor(
|
|
671
|
-
super(), d.util.initPartial(
|
|
670
|
+
constructor(r) {
|
|
671
|
+
super(), d.util.initPartial(r, this);
|
|
672
672
|
}
|
|
673
673
|
static runtime = d;
|
|
674
674
|
static typeName = "markdown.v1.ConvertResponse";
|
|
@@ -680,22 +680,22 @@ class b extends x {
|
|
|
680
680
|
T: 9
|
|
681
681
|
/* ScalarType.STRING */
|
|
682
682
|
},
|
|
683
|
-
{ no: 2, name: "headings", kind: "message", T:
|
|
683
|
+
{ no: 2, name: "headings", kind: "message", T: v, repeated: !0 }
|
|
684
684
|
]);
|
|
685
|
-
static fromBinary(
|
|
686
|
-
return new
|
|
685
|
+
static fromBinary(r, e) {
|
|
686
|
+
return new E().fromBinary(r, e);
|
|
687
687
|
}
|
|
688
|
-
static fromJson(
|
|
689
|
-
return new
|
|
688
|
+
static fromJson(r, e) {
|
|
689
|
+
return new E().fromJson(r, e);
|
|
690
690
|
}
|
|
691
|
-
static fromJsonString(
|
|
692
|
-
return new
|
|
691
|
+
static fromJsonString(r, e) {
|
|
692
|
+
return new E().fromJsonString(r, e);
|
|
693
693
|
}
|
|
694
|
-
static equals(
|
|
695
|
-
return d.util.equals(
|
|
694
|
+
static equals(r, e) {
|
|
695
|
+
return d.util.equals(E, r, e);
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
|
-
class
|
|
698
|
+
class v extends N {
|
|
699
699
|
/**
|
|
700
700
|
* @generated from field: string text = 1;
|
|
701
701
|
*/
|
|
@@ -708,8 +708,8 @@ class E extends x {
|
|
|
708
708
|
* @generated from field: string id = 3;
|
|
709
709
|
*/
|
|
710
710
|
id = "";
|
|
711
|
-
constructor(
|
|
712
|
-
super(), d.util.initPartial(
|
|
711
|
+
constructor(r) {
|
|
712
|
+
super(), d.util.initPartial(r, this);
|
|
713
713
|
}
|
|
714
714
|
static runtime = d;
|
|
715
715
|
static typeName = "markdown.v1.Heading";
|
|
@@ -736,17 +736,17 @@ class E extends x {
|
|
|
736
736
|
/* ScalarType.STRING */
|
|
737
737
|
}
|
|
738
738
|
]);
|
|
739
|
-
static fromBinary(
|
|
740
|
-
return new
|
|
739
|
+
static fromBinary(r, e) {
|
|
740
|
+
return new v().fromBinary(r, e);
|
|
741
741
|
}
|
|
742
|
-
static fromJson(
|
|
743
|
-
return new
|
|
742
|
+
static fromJson(r, e) {
|
|
743
|
+
return new v().fromJson(r, e);
|
|
744
744
|
}
|
|
745
|
-
static fromJsonString(
|
|
746
|
-
return new
|
|
745
|
+
static fromJsonString(r, e) {
|
|
746
|
+
return new v().fromJsonString(r, e);
|
|
747
747
|
}
|
|
748
|
-
static equals(
|
|
749
|
-
return d.util.equals(
|
|
748
|
+
static equals(r, e) {
|
|
749
|
+
return d.util.equals(v, r, e);
|
|
750
750
|
}
|
|
751
751
|
}
|
|
752
752
|
const Lt = {
|
|
@@ -757,13 +757,18 @@ const Lt = {
|
|
|
757
757
|
*/
|
|
758
758
|
convert: {
|
|
759
759
|
name: "Convert",
|
|
760
|
-
I:
|
|
761
|
-
O:
|
|
760
|
+
I: b,
|
|
761
|
+
O: E,
|
|
762
762
|
kind: De.Unary
|
|
763
763
|
}
|
|
764
764
|
}
|
|
765
|
-
},
|
|
766
|
-
|
|
765
|
+
}, k = () => {
|
|
766
|
+
const t = process.env.MARKDOWN_SOCKET_PATH;
|
|
767
|
+
if (t === void 0 || t === "")
|
|
768
|
+
throw new Error("MARKDOWN_SOCKET_PATH is required: set it to the path of the markdown-api service's UNIX domain socket, the same value the service reads");
|
|
769
|
+
return t;
|
|
770
|
+
}, Ot = new Ne("http://localhost", void 0, {
|
|
771
|
+
createConnection: () => se.connect(k())
|
|
767
772
|
}), re = () => {
|
|
768
773
|
try {
|
|
769
774
|
return M.dirname(Pe(import.meta.url));
|
|
@@ -771,31 +776,31 @@ const Lt = {
|
|
|
771
776
|
return __dirname;
|
|
772
777
|
}
|
|
773
778
|
}, he = () => `@aiquants/markdown-${process.platform}-${process.arch}`, ne = () => process.platform === "win32" ? "bin/markdown-api.exe" : "bin/markdown-api", Pt = () => {
|
|
774
|
-
const
|
|
775
|
-
if (
|
|
776
|
-
return
|
|
779
|
+
const t = process.env.MARKDOWN_API_BINARY;
|
|
780
|
+
if (t && C(t))
|
|
781
|
+
return t;
|
|
777
782
|
try {
|
|
778
783
|
const e = Oe(M.join(re(), "index.js")).resolve(`${he()}/${ne()}`);
|
|
779
784
|
if (C(e))
|
|
780
785
|
return e;
|
|
781
786
|
} catch {
|
|
782
787
|
}
|
|
783
|
-
const
|
|
784
|
-
return C(
|
|
788
|
+
const r = M.join(re(), "..", "..", "go", "markdown-api", "dist", M.basename(ne()));
|
|
789
|
+
return C(r) ? r : void 0;
|
|
785
790
|
}, Ct = () => [
|
|
786
791
|
`markdown-api binary not found for ${process.platform}-${process.arch}.`,
|
|
787
792
|
`Expected the optional dependency ${he()} to be installed.`,
|
|
788
793
|
"If your platform is unsupported, build the service yourself",
|
|
789
794
|
"(https://github.com/fehde-k/aiquants/tree/main/packages/go/markdown-api)",
|
|
790
795
|
"and point MARKDOWN_API_BINARY at it."
|
|
791
|
-
].join(" "), we = () => new Promise((
|
|
792
|
-
const
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
}),
|
|
796
|
-
}), oe = async (
|
|
797
|
-
const
|
|
798
|
-
for (; Date.now() -
|
|
796
|
+
].join(" "), we = () => new Promise((t) => {
|
|
797
|
+
const r = se.connect(k());
|
|
798
|
+
r.on("connect", () => {
|
|
799
|
+
r.destroy(), t(!0);
|
|
800
|
+
}), r.on("error", () => t(!1));
|
|
801
|
+
}), oe = async (t) => {
|
|
802
|
+
const r = Date.now();
|
|
803
|
+
for (; Date.now() - r < t; ) {
|
|
799
804
|
if (await we()) return !0;
|
|
800
805
|
await new Promise((e) => setTimeout(e, 100));
|
|
801
806
|
}
|
|
@@ -803,24 +808,24 @@ const Lt = {
|
|
|
803
808
|
};
|
|
804
809
|
let A = null, _ = null;
|
|
805
810
|
const Mt = 2e3, It = () => {
|
|
806
|
-
const
|
|
807
|
-
return Number.isFinite(
|
|
811
|
+
const t = Number(process.env.MARKDOWN_API_STARTUP_TIMEOUT_MS);
|
|
812
|
+
return Number.isFinite(t) && t > 0 ? t : 1e4;
|
|
808
813
|
};
|
|
809
814
|
let I = null;
|
|
810
|
-
const
|
|
815
|
+
const Nt = async () => {
|
|
811
816
|
if (await we()) return !0;
|
|
812
817
|
if (_) return _;
|
|
813
818
|
_ = (async () => {
|
|
814
|
-
const
|
|
815
|
-
if (!
|
|
819
|
+
const r = Pt();
|
|
820
|
+
if (!r)
|
|
816
821
|
return await oe(Mt) ? !0 : (I = Ct(), !1);
|
|
817
822
|
I = null;
|
|
818
823
|
try {
|
|
819
|
-
C(
|
|
824
|
+
C(k()) && Le(k());
|
|
820
825
|
} catch {
|
|
821
826
|
}
|
|
822
827
|
try {
|
|
823
|
-
A = Re(
|
|
828
|
+
A = Re(r, [], { stdio: "ignore" });
|
|
824
829
|
const e = () => {
|
|
825
830
|
if (A) {
|
|
826
831
|
try {
|
|
@@ -830,29 +835,29 @@ const xt = async () => {
|
|
|
830
835
|
A = null;
|
|
831
836
|
}
|
|
832
837
|
};
|
|
833
|
-
return process.once("exit", e), await oe(It()) ? !0 : (console.error("markdown-api Go server did not become ready on socket:",
|
|
838
|
+
return process.once("exit", e), await oe(It()) ? !0 : (console.error("markdown-api Go server did not become ready on socket:", k()), e(), process.removeListener("exit", e), !1);
|
|
834
839
|
} catch (e) {
|
|
835
840
|
return console.error("Failed to spawn markdown-api Go server:", e), A = null, !1;
|
|
836
841
|
}
|
|
837
842
|
})();
|
|
838
|
-
const
|
|
839
|
-
return
|
|
840
|
-
},
|
|
841
|
-
if (be(
|
|
842
|
-
throw new RangeError(`parseMarkdown: timeoutMs must be a positive integer, got ${
|
|
843
|
-
}, Zt = async (
|
|
844
|
-
if (
|
|
843
|
+
const t = await _;
|
|
844
|
+
return t || (_ = null), t;
|
|
845
|
+
}, xt = (t) => {
|
|
846
|
+
if (be(t, "parseMarkdown"), t.timeoutMs !== void 0 && (!Number.isSafeInteger(t.timeoutMs) || t.timeoutMs <= 0))
|
|
847
|
+
throw new RangeError(`parseMarkdown: timeoutMs must be a positive integer, got ${t.timeoutMs}`);
|
|
848
|
+
}, Zt = async (t, r, e, n, o) => {
|
|
849
|
+
if (k(), xt(o), !await Nt()) {
|
|
845
850
|
const i = I ? ` ${I}` : "";
|
|
846
|
-
throw new Error(`markdown service is not reachable on ${
|
|
851
|
+
throw new Error(`markdown service is not reachable on ${k()}.${i}`);
|
|
847
852
|
}
|
|
848
853
|
const s = {};
|
|
849
854
|
n && (s.Authorization = `Bearer ${n}`);
|
|
850
|
-
const a = Ce(Lt,
|
|
855
|
+
const a = Ce(Lt, xe({ baseUrl: "http://localhost", httpVersion: "2", sessionManager: Ot, readMaxBytes: 2 * o.maxHtmlBytes + ge }));
|
|
851
856
|
try {
|
|
852
857
|
const i = await a.convert(
|
|
853
858
|
{
|
|
854
|
-
markdownText:
|
|
855
|
-
filePath:
|
|
859
|
+
markdownText: t,
|
|
860
|
+
filePath: r,
|
|
856
861
|
workspaceRoot: e,
|
|
857
862
|
validateExistence: o.validateExistence ?? !0,
|
|
858
863
|
enableSubscript: o.enableSubscript,
|