@aiquants/markdown 6.3.0 → 6.4.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 +40 -3
- package/dist/{abnfDiagram-VRR7QNED-BGUmgNQ4.cjs → abnfDiagram-VRR7QNED-B4qwBPG8.cjs} +1 -1
- package/dist/{abnfDiagram-VRR7QNED-D3L_2hCD.js → abnfDiagram-VRR7QNED-DJQK-fno.js} +3 -3
- package/dist/{arc-ChEpDr_9.js → arc-B5-ynLRd.js} +1 -1
- package/dist/{arc-B48_ucR0.cjs → arc-CXmyMsv9.cjs} +1 -1
- package/dist/{architectureDiagram-ZJ3FMSHR-D4ta1ajC.js → architectureDiagram-ZJ3FMSHR-C_JEocx6.js} +2 -2
- package/dist/{architectureDiagram-ZJ3FMSHR-Bg0dBVnf.cjs → architectureDiagram-ZJ3FMSHR-DyhTbYvV.cjs} +1 -1
- package/dist/{blockDiagram-677ZJIJ3-DkWMy8pP.cjs → blockDiagram-677ZJIJ3-BsWnBpmo.cjs} +1 -1
- package/dist/{blockDiagram-677ZJIJ3-CupyE7nK.js → blockDiagram-677ZJIJ3-COWsJwrz.js} +3 -3
- package/dist/{c4Diagram-LMCZKHZV-Cy1lIde9.js → c4Diagram-LMCZKHZV-BJGPyybb.js} +2 -2
- package/dist/{c4Diagram-LMCZKHZV-DxOKAkJI.cjs → c4Diagram-LMCZKHZV-C8SAoymj.cjs} +1 -1
- package/dist/{channel-TOZvPft0.cjs → channel-Catm-7_m.cjs} +1 -1
- package/dist/{channel-C9c0_XwC.js → channel-gEEzHgMK.js} +1 -1
- package/dist/{chunk-2Q5K7J3B-DahzXbiI.js → chunk-2Q5K7J3B-BrZPj48S.js} +1 -1
- package/dist/{chunk-2Q5K7J3B-DaGwwho3.cjs → chunk-2Q5K7J3B-D2pUNN7e.cjs} +1 -1
- package/dist/{chunk-32BRIVSS-BddWRgx3.cjs → chunk-32BRIVSS-BHwCDqTA.cjs} +1 -1
- package/dist/{chunk-32BRIVSS-DFLtYkrI.js → chunk-32BRIVSS-Qjp2CRZG.js} +1 -1
- package/dist/{chunk-5VM5RSS4-DSg2-2mp.cjs → chunk-5VM5RSS4-C-2Xl1mK.cjs} +1 -1
- package/dist/{chunk-5VM5RSS4-DiwEVqol.js → chunk-5VM5RSS4-Cz-1oXF8.js} +1 -1
- package/dist/{chunk-EX3LRPZG-OD-kvRfM.cjs → chunk-EX3LRPZG-CcWHrBHu.cjs} +1 -1
- package/dist/{chunk-EX3LRPZG-Ca4uquaA.js → chunk-EX3LRPZG-DOly63cQ.js} +4 -4
- package/dist/{chunk-JWPE2WC7-njgGfGvE.js → chunk-JWPE2WC7-D8oKuUKk.js} +1 -1
- package/dist/{chunk-JWPE2WC7-BGdnK7yg.cjs → chunk-JWPE2WC7-uLMzLWor.cjs} +1 -1
- package/dist/{chunk-MOJQB5TN-DPs_chEk.cjs → chunk-MOJQB5TN-CFHULd2m.cjs} +1 -1
- package/dist/{chunk-MOJQB5TN-B-H_fDpi.js → chunk-MOJQB5TN-DFfn4gwS.js} +1 -1
- package/dist/{chunk-PUDLZKDR-9xQzJ025.js → chunk-PUDLZKDR-BSXgzvcs.js} +6 -6
- package/dist/{chunk-PUDLZKDR-DZphdeDg.cjs → chunk-PUDLZKDR-CdXVWW4P.cjs} +1 -1
- package/dist/{chunk-RYQCIY6F-8Qpsw4iJ.cjs → chunk-RYQCIY6F-CVamSMzr.cjs} +1 -1
- package/dist/{chunk-RYQCIY6F-BNzT71C4.js → chunk-RYQCIY6F-D7rBCtF6.js} +1 -1
- package/dist/{chunk-V7JOEXUC-DG6RRlOY.js → chunk-V7JOEXUC-BEGUrMN0.js} +5 -5
- package/dist/{chunk-V7JOEXUC-BPE4_Rfd.cjs → chunk-V7JOEXUC-DJuvtTef.cjs} +1 -1
- package/dist/{chunk-VR4S4FIN-CLtgFgby.js → chunk-VR4S4FIN-DbzCqIxB.js} +1 -1
- package/dist/{chunk-VR4S4FIN-C-Pbv_Mm.cjs → chunk-VR4S4FIN-Okfemb3d.cjs} +1 -1
- package/dist/{chunk-XXDRQBXY-B0bOz96Q.cjs → chunk-XXDRQBXY-DQBgFSg2.cjs} +1 -1
- package/dist/{chunk-XXDRQBXY-DEXdwwNg.js → chunk-XXDRQBXY-DzmhMVRC.js} +1 -1
- package/dist/{classDiagram-v2-EOCWNBFH-B9uAd2dg.js → classDiagram-OUVF2IWQ-BGn-HjT8.js} +2 -2
- package/dist/{classDiagram-OUVF2IWQ-DMqQXVMf.cjs → classDiagram-OUVF2IWQ-DR8DD7tr.cjs} +1 -1
- package/dist/{classDiagram-OUVF2IWQ-B9uAd2dg.js → classDiagram-v2-EOCWNBFH-BGn-HjT8.js} +2 -2
- package/dist/{classDiagram-v2-EOCWNBFH-DMqQXVMf.cjs → classDiagram-v2-EOCWNBFH-DR8DD7tr.cjs} +1 -1
- package/dist/components/mathRendering.d.ts +1 -0
- package/dist/conversion.d.ts +26 -0
- package/dist/converter/NOTICES.md +178 -0
- package/dist/converter/createMarkdownConverter.d.ts +12 -0
- package/dist/converter/protocol.d.ts +58 -0
- package/dist/converter/serve.d.ts +12 -0
- package/dist/converter/worker.d.ts +1 -0
- package/dist/converter/worker.js +76 -0
- package/dist/converter.cjs +1 -0
- package/dist/converter.d.ts +4 -0
- package/dist/converter.js +109 -0
- package/dist/converter.wasm +0 -0
- package/dist/{cose-bilkent-JH36ORCC-DVB8IdFe.js → cose-bilkent-JH36ORCC-CXaSZTQh.js} +1 -1
- package/dist/{cose-bilkent-JH36ORCC-DxpO_Qhk.cjs → cose-bilkent-JH36ORCC-DKpnPAKO.cjs} +1 -1
- package/dist/{cynefinDiagram-TSTJHNR4-C-iEKX8r.js → cynefinDiagram-TSTJHNR4-BQSdT_2p.js} +2 -2
- package/dist/{cynefinDiagram-TSTJHNR4-Dvc8nHOe.cjs → cynefinDiagram-TSTJHNR4-WzHtBOXU.cjs} +1 -1
- package/dist/{dagre-VKFMJZFB-DqU8jG6A.cjs → dagre-VKFMJZFB-BOlxvZO9.cjs} +1 -1
- package/dist/{dagre-VKFMJZFB-CI1hyGqk.js → dagre-VKFMJZFB-DQ5e1PJD.js} +2 -2
- package/dist/{diagram-FQU43EPY-DQHw46B-.cjs → diagram-FQU43EPY-DdDxGx-M.cjs} +1 -1
- package/dist/{diagram-FQU43EPY-iMIQEr1Q.js → diagram-FQU43EPY-DlCF28sn.js} +2 -2
- package/dist/{diagram-G47NLZAW-Dxkn-83c.cjs → diagram-G47NLZAW-Cvts7_pn.cjs} +1 -1
- package/dist/{diagram-G47NLZAW-L7A0K5es.js → diagram-G47NLZAW-DVdw7HhH.js} +3 -3
- package/dist/{diagram-NH7WQ7WH-8BnG6h8J.js → diagram-NH7WQ7WH-BkU3b82h.js} +2 -2
- package/dist/{diagram-NH7WQ7WH-CBMFD5SB.cjs → diagram-NH7WQ7WH-Cs_Dyb0p.cjs} +1 -1
- package/dist/{diagram-OA4YK3LP-C24uGaef.js → diagram-OA4YK3LP-D39RUkK3.js} +3 -3
- package/dist/{diagram-OA4YK3LP-DrD1SsZM.cjs → diagram-OA4YK3LP-ONhluSWR.cjs} +1 -1
- package/dist/{diagram-WEI45ONY-kBWsy9sQ.js → diagram-WEI45ONY-CMD5pSfn.js} +2 -2
- package/dist/{diagram-WEI45ONY-BYN2qTiw.cjs → diagram-WEI45ONY-DyEvKt6H.cjs} +1 -1
- package/dist/{ebnfDiagram-CCIWWBDH-C7whdHrV.cjs → ebnfDiagram-CCIWWBDH-Bi-wg1C0.cjs} +1 -1
- package/dist/{ebnfDiagram-CCIWWBDH-DRfaz75o.js → ebnfDiagram-CCIWWBDH-Z3TtxdlL.js} +3 -3
- package/dist/{erDiagram-Q63AITRT-CvcOag5w.js → erDiagram-Q63AITRT-C-O8hBWj.js} +4 -4
- package/dist/{erDiagram-Q63AITRT-Cbh7ns6U.cjs → erDiagram-Q63AITRT-DQO3kH0H.cjs} +1 -1
- package/dist/errors-BW5JXRoX.cjs +1 -0
- package/dist/errors-Blk_XJ9C.js +55 -0
- package/dist/errors.d.ts +12 -0
- package/dist/{extractHeadings-By3kC3b_.cjs → extractHeadings-DSlyjlEb.cjs} +58 -58
- package/dist/{extractHeadings-Dz8gnhsx.js → extractHeadings-DkKFCMIW.js} +3766 -3732
- package/dist/flowDiagram-23GEKE2U-BHV7jjdl.js +7 -0
- package/dist/flowDiagram-23GEKE2U-Bn8nX3mJ.cjs +1 -0
- package/dist/{ganttDiagram-NO4QXBWP-Ccrw6Vga.js → ganttDiagram-NO4QXBWP-BgxDDjW1.js} +2 -2
- package/dist/{ganttDiagram-NO4QXBWP-YWoWQpTa.cjs → ganttDiagram-NO4QXBWP-C6v1dyOv.cjs} +1 -1
- package/dist/{gitGraphDiagram-IHSO6WYX-C-mHT-ew.js → gitGraphDiagram-IHSO6WYX-BSIaczat.js} +3 -3
- package/dist/{gitGraphDiagram-IHSO6WYX-nKm0aLrL.cjs → gitGraphDiagram-IHSO6WYX-Dly6wuUW.cjs} +1 -1
- 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.d.ts +3 -1
- package/dist/index.server.js +159 -173
- package/dist/{infoDiagram-FWYZ7A6U-HBcwdQ6Z.js → infoDiagram-FWYZ7A6U-BJpiPMD3.js} +1 -1
- package/dist/{infoDiagram-FWYZ7A6U-B6uUqDCC.cjs → infoDiagram-FWYZ7A6U-CRxeian2.cjs} +1 -1
- package/dist/{ishikawaDiagram-FXEZZL3T-CcSYEsTJ.js → ishikawaDiagram-FXEZZL3T-B3tCfTEo.js} +1 -1
- package/dist/{ishikawaDiagram-FXEZZL3T-D9WZm1OZ.cjs → ishikawaDiagram-FXEZZL3T-jEnTu6LN.cjs} +1 -1
- package/dist/{journeyDiagram-5HDEW3XC-BC3ajweK.cjs → journeyDiagram-5HDEW3XC-BXFW-Svx.cjs} +1 -1
- package/dist/{journeyDiagram-5HDEW3XC-PJm-8Gz8.js → journeyDiagram-5HDEW3XC-D7U-NNAM.js} +4 -4
- package/dist/{kanban-definition-HUTT4EX6-42_dEzBV.js → kanban-definition-HUTT4EX6-B14iIRCh.js} +2 -2
- package/dist/{kanban-definition-HUTT4EX6-BR-C1joQ.cjs → kanban-definition-HUTT4EX6-DSprt7D2.cjs} +1 -1
- package/dist/{linear-CoCezkp4.cjs → linear-B-_z7_Qw.cjs} +1 -1
- package/dist/{linear-B7J7VKh9.js → linear-DZOg62FH.js} +1 -1
- package/dist/{mindmap-definition-LN4V7U3C-BO555Yeu.cjs → mindmap-definition-LN4V7U3C-Bs_ccQ71.cjs} +1 -1
- package/dist/{mindmap-definition-LN4V7U3C-e4fXdr28.js → mindmap-definition-LN4V7U3C-Dh-Z6t4L.js} +3 -3
- package/dist/{pegDiagram-2B236MQR-nN-jUv5o.js → pegDiagram-2B236MQR-6OQwK0r-.js} +3 -3
- package/dist/{pegDiagram-2B236MQR-CqN17IwE.cjs → pegDiagram-2B236MQR-BunF191h.cjs} +1 -1
- package/dist/{pieDiagram-ENE6RG2P-D_EIGKcE.cjs → pieDiagram-ENE6RG2P-BUdykoZb.cjs} +1 -1
- package/dist/{pieDiagram-ENE6RG2P-EvhF_8o2.js → pieDiagram-ENE6RG2P-DjvAa5zD.js} +3 -3
- package/dist/{quadrantDiagram-ABIIQ3AL-2gTiccyy.js → quadrantDiagram-ABIIQ3AL-DfiOa0GN.js} +2 -2
- package/dist/{quadrantDiagram-ABIIQ3AL-HNTFSQzi.cjs → quadrantDiagram-ABIIQ3AL-ksoulitn.cjs} +1 -1
- package/dist/{railroadDiagram-RFXS5EU6-CRuA7qqW.cjs → railroadDiagram-RFXS5EU6-BWupYLwR.cjs} +1 -1
- package/dist/{railroadDiagram-RFXS5EU6-CYAI9-bK.js → railroadDiagram-RFXS5EU6-DxJ3t05t.js} +3 -3
- package/dist/remarkProcessor.server.d.ts +1 -28
- package/dist/{requirementDiagram-TGXJPOKE-BZc_cLKC.js → requirementDiagram-TGXJPOKE-CxplHHB8.js} +3 -3
- package/dist/{requirementDiagram-TGXJPOKE-DesNyieJ.cjs → requirementDiagram-TGXJPOKE-D17FjoFO.cjs} +1 -1
- package/dist/{sankeyDiagram-HTMAVEWB-wLwqusl2.cjs → sankeyDiagram-HTMAVEWB-CDXvEE-n.cjs} +1 -1
- package/dist/{sankeyDiagram-HTMAVEWB-B1QsmzsN.js → sankeyDiagram-HTMAVEWB-DFOQ2fD-.js} +1 -1
- package/dist/{sequenceDiagram-DBY2YBRQ-D3ciEWOE.cjs → sequenceDiagram-DBY2YBRQ-D-aVI5Yt.cjs} +1 -1
- package/dist/{sequenceDiagram-DBY2YBRQ-OTeHr40Q.js → sequenceDiagram-DBY2YBRQ-Gf5VRPPO.js} +3 -3
- package/dist/{sizeCapture-X5ZJPWSS-LlzRMz8i.cjs → sizeCapture-X5ZJPWSS-BAB3SekL.cjs} +1 -1
- package/dist/{sizeCapture-X5ZJPWSS-BhcQlLlw.js → sizeCapture-X5ZJPWSS-DyErW1EK.js} +1 -1
- package/dist/{stateDiagram-2N3HPSRC-D0q856z6.cjs → stateDiagram-2N3HPSRC-BrUDPgXu.cjs} +1 -1
- package/dist/{stateDiagram-2N3HPSRC-DjLE1--n.js → stateDiagram-2N3HPSRC-lxQmuBDw.js} +2 -2
- package/dist/{stateDiagram-v2-6OUMAXLB-DJHUGWBX.cjs → stateDiagram-v2-6OUMAXLB-B67PZ7bz.cjs} +1 -1
- package/dist/{stateDiagram-v2-6OUMAXLB-DKU0HsD1.js → stateDiagram-v2-6OUMAXLB-l5VmN12f.js} +2 -2
- package/dist/{swimlanes-5IMT3BWC-cxcj_GGS.js → swimlanes-5IMT3BWC-CMkiOd-R.js} +3 -3
- package/dist/{swimlanes-5IMT3BWC-DC6qS8iI.cjs → swimlanes-5IMT3BWC-DW61y4w7.cjs} +1 -1
- package/dist/{swimlanesDiagram-G3AALYLV-B95OToWo.js → swimlanesDiagram-G3AALYLV-CaDY11RK.js} +2 -2
- package/dist/{swimlanesDiagram-G3AALYLV-Dv76fKaH.cjs → swimlanesDiagram-G3AALYLV-DN1x1exB.cjs} +1 -1
- package/dist/{timeline-definition-FHXFAJF6-wD6O9DDR.cjs → timeline-definition-FHXFAJF6-DCW8SrSN.cjs} +1 -1
- package/dist/{timeline-definition-FHXFAJF6-P-5kO0xQ.js → timeline-definition-FHXFAJF6-GIvmYQNR.js} +2 -2
- package/dist/{vennDiagram-L72KCM5P-BwinGtNb.js → vennDiagram-L72KCM5P-DtN1NFNM.js} +1 -1
- package/dist/{vennDiagram-L72KCM5P-BXHvaRtm.cjs → vennDiagram-L72KCM5P-wENEw3FH.cjs} +1 -1
- package/dist/{wardleyDiagram-EHGQE667-BeYbREE2.js → wardleyDiagram-EHGQE667-CPYTbfuJ.js} +2 -2
- package/dist/{wardleyDiagram-EHGQE667-BDgwIQTf.cjs → wardleyDiagram-EHGQE667-Daugt2NV.cjs} +1 -1
- package/dist/{xychartDiagram-FW5EYKEG-DLCCDPGO.cjs → xychartDiagram-FW5EYKEG-B3D8pi1c.cjs} +1 -1
- package/dist/{xychartDiagram-FW5EYKEG-BXjx9Zgc.js → xychartDiagram-FW5EYKEG-C-NgU5xv.js} +2 -2
- package/package.json +17 -8
- package/dist/flowDiagram-23GEKE2U-C5ygxVuP.js +0 -7
- package/dist/flowDiagram-23GEKE2U-DSpM0zzA.cjs +0 -1
package/dist/index.server.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as ge, c as ke, a as be } from "./errors-Blk_XJ9C.js";
|
|
2
|
+
import { d as er } from "./errors-Blk_XJ9C.js";
|
|
3
|
+
import { l as L, L as O, a as ae, b as Ee } from "./linkCards-1JxY8wdm.js";
|
|
2
4
|
import { l as h } from "./simple-logger-DwH1YQvq.js";
|
|
3
|
-
import { Resolver as
|
|
4
|
-
import * as
|
|
5
|
-
import { BlockList as
|
|
6
|
-
import { Agent as
|
|
7
|
-
import { Parser as
|
|
8
|
-
import { spawn as
|
|
9
|
-
import { existsSync as
|
|
10
|
-
import { createRequire as
|
|
11
|
-
import * as
|
|
12
|
-
import { fileURLToPath as
|
|
13
|
-
import { createClient as
|
|
14
|
-
import { Http2SessionManager as
|
|
15
|
-
import { Message as x, proto3 as d, MethodKind as
|
|
16
|
-
const
|
|
5
|
+
import { Resolver as Te } from "node:dns/promises";
|
|
6
|
+
import * as se from "node:net";
|
|
7
|
+
import { BlockList as ve, isIP as ie, connect as Se } from "node:net";
|
|
8
|
+
import { Agent as ye, buildConnector as Y, fetch as Ae } from "undici";
|
|
9
|
+
import { Parser as _e } from "htmlparser2";
|
|
10
|
+
import { spawn as Re } from "node:child_process";
|
|
11
|
+
import { existsSync as C, unlinkSync as Le } from "node:fs";
|
|
12
|
+
import { createRequire as Oe } from "node:module";
|
|
13
|
+
import * as M from "node:path";
|
|
14
|
+
import { fileURLToPath as Pe } from "node:url";
|
|
15
|
+
import { createClient as Ce, ConnectError as Me, Code as Ie } from "@connectrpc/connect";
|
|
16
|
+
import { Http2SessionManager as xe, createConnectTransport as Ne } from "@connectrpc/connect-node";
|
|
17
|
+
import { Message as x, proto3 as d, MethodKind as De } from "@bufbuild/protobuf";
|
|
18
|
+
const Be = [
|
|
17
19
|
[[0], 8],
|
|
18
20
|
[[10], 8],
|
|
19
21
|
[[100, 64], 10],
|
|
@@ -28,7 +30,7 @@ const De = [
|
|
|
28
30
|
[[203, 0, 113], 24],
|
|
29
31
|
[[224], 4],
|
|
30
32
|
[[240], 4]
|
|
31
|
-
],
|
|
33
|
+
], Ue = [
|
|
32
34
|
[[100, 65435], 32],
|
|
33
35
|
[[0, 0, 0, 0, 65535, 0], 96],
|
|
34
36
|
[[256, 0, 0, 0], 64],
|
|
@@ -43,31 +45,31 @@ const De = [
|
|
|
43
45
|
[[65152], 10],
|
|
44
46
|
[[65216], 10],
|
|
45
47
|
[[65280], 8]
|
|
46
|
-
],
|
|
47
|
-
for (const [r, t] of
|
|
48
|
+
], T = new ve();
|
|
49
|
+
for (const [r, t] of Be) {
|
|
48
50
|
const e = [...r, 0, 0, 0].slice(0, 4).join(".");
|
|
49
|
-
|
|
51
|
+
T.addSubnet(e, t, "ipv4"), T.addSubnet(`::ffff:${e}`, 96 + t, "ipv6"), T.addSubnet(`::${e}`, 96 + t, "ipv6");
|
|
50
52
|
}
|
|
51
|
-
for (const [r, t] of
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
const t = r.replace(/^\[/u, "").replace(/\]$/u, "").replace(/%.*$/su, ""), e =
|
|
55
|
-
return e !== 0 &&
|
|
56
|
-
},
|
|
57
|
-
error: Object.assign(new Error(`Blocked hostname resolving to a private address: ${r} -> ${t}`), { code:
|
|
58
|
-
}),
|
|
59
|
-
const e =
|
|
53
|
+
for (const [r, t] of Ue)
|
|
54
|
+
T.addSubnet(`${r.map((e) => e.toString(16)).join(":")}::`, t, "ipv6");
|
|
55
|
+
const $ = (r) => {
|
|
56
|
+
const t = r.replace(/^\[/u, "").replace(/\]$/u, "").replace(/%.*$/su, ""), e = ie(t);
|
|
57
|
+
return e !== 0 && T.check(t, e === 4 ? "ipv4" : "ipv6");
|
|
58
|
+
}, le = "ERR_LINK_CARD_PRIVATE_ADDRESS", Z = Object.freeze({ timeoutMs: 1e3, tries: 2 }), q = new Te({ timeout: Z.timeoutMs, tries: Z.tries }), Q = (r, t) => ({
|
|
59
|
+
error: Object.assign(new Error(`Blocked hostname resolving to a private address: ${r} -> ${t}`), { code: le })
|
|
60
|
+
}), $e = async (r, t) => {
|
|
61
|
+
const e = ie(r);
|
|
60
62
|
if (e !== 0)
|
|
61
|
-
return
|
|
62
|
-
const [n, o] = await Promise.allSettled([t === 6 ? Promise.resolve([]) : q.resolve4(r), t === 4 ? Promise.resolve([]) : q.resolve6(r)]), s = n.status === "fulfilled" ? n.value : [], a = o.status === "fulfilled" ? o.value : [], i = [...s, ...a].find((R) =>
|
|
63
|
+
return $(r) ? Q(r, r) : { error: null, family: e === 4 ? 4 : 6, addresses: [r] };
|
|
64
|
+
const [n, o] = await Promise.allSettled([t === 6 ? Promise.resolve([]) : q.resolve4(r), t === 4 ? Promise.resolve([]) : q.resolve6(r)]), s = n.status === "fulfilled" ? n.value : [], a = o.status === "fulfilled" ? o.value : [], i = [...s, ...a].find((R) => $(R));
|
|
63
65
|
if (i !== void 0) return Q(r, i);
|
|
64
66
|
const [l, ...c] = s;
|
|
65
67
|
if (l !== void 0) return { error: null, family: 4, addresses: [l, ...c] };
|
|
66
|
-
const [f, ...
|
|
67
|
-
return f !== void 0 ? { error: null, family: 6, addresses: [f, ...
|
|
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 ${r}`), { code: "ENOTFOUND" }) };
|
|
70
|
+
}, He = (r, t, e) => {
|
|
69
71
|
const n = t.family === 4 || t.family === "IPv4" ? 4 : t.family === 6 || t.family === "IPv6" ? 6 : 0;
|
|
70
|
-
|
|
72
|
+
$e(r, n).then((o) => {
|
|
71
73
|
if (o.error !== null) {
|
|
72
74
|
e(o.error, "");
|
|
73
75
|
return;
|
|
@@ -78,7 +80,7 @@ const U = (r) => {
|
|
|
78
80
|
a.map((i) => ({ address: i, family: s }))
|
|
79
81
|
) : e(null, a[0], s);
|
|
80
82
|
});
|
|
81
|
-
},
|
|
83
|
+
}, je = /* @__PURE__ */ new Set(["127.0.0.1", "0.0.0.0", "[::1]"]), ze = [".local", ".internal", ".home.arpa"], j = (r, t) => {
|
|
82
84
|
let e;
|
|
83
85
|
try {
|
|
84
86
|
e = new URL(r);
|
|
@@ -91,8 +93,8 @@ const U = (r) => {
|
|
|
91
93
|
return { ok: !1, reason: "forbidden-url", detail: "URLs with a user name or password are not allowed" };
|
|
92
94
|
e.hash = "";
|
|
93
95
|
const n = e.hostname.replace(/\.+$/u, "");
|
|
94
|
-
return n === "localhost" || n.endsWith(".localhost") ||
|
|
95
|
-
},
|
|
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(".")) || ze.some((s) => n.endsWith(s)) ? { ok: !1, reason: "private-network", detail: "Internal domain access is not allowed" } : { ok: !0, href: e.href };
|
|
97
|
+
}, ce = (r) => {
|
|
96
98
|
let t;
|
|
97
99
|
try {
|
|
98
100
|
t = new URL(r);
|
|
@@ -100,20 +102,20 @@ const U = (r) => {
|
|
|
100
102
|
return "(unparsable URL)";
|
|
101
103
|
}
|
|
102
104
|
return t.protocol !== "http:" && t.protocol !== "https:" ? `(a ${t.protocol} URL)` : (t.username = "", t.password = "", t.href);
|
|
103
|
-
},
|
|
105
|
+
}, ue = 1024, Je = /^[\t\n\f\r ]$/u, w = (r) => Je.test(r), B = (r) => r.replace(/[A-Z]/gu, (t) => t.toLowerCase()), H = (r) => {
|
|
104
106
|
try {
|
|
105
107
|
return new TextDecoder(r).encoding;
|
|
106
108
|
} catch {
|
|
107
109
|
return null;
|
|
108
110
|
}
|
|
109
|
-
},
|
|
111
|
+
}, Ke = (r) => r[0] === 239 && r[1] === 187 && r[2] === 191 ? "utf-8" : r[0] === 254 && r[1] === 255 ? "utf-16be" : r[0] === 255 && r[1] === 254 ? "utf-16le" : null, Fe = (r) => {
|
|
110
112
|
for (const t of r.split(";").slice(1)) {
|
|
111
113
|
const e = t.indexOf("=");
|
|
112
114
|
if (e !== -1 && t.slice(0, e).trim().toLowerCase() === "charset")
|
|
113
115
|
return t.slice(e + 1).trim().replace(/^"(.*)"$/su, "$1");
|
|
114
116
|
}
|
|
115
117
|
return null;
|
|
116
|
-
},
|
|
118
|
+
}, Ge = (r) => {
|
|
117
119
|
let t = 0;
|
|
118
120
|
for (; ; ) {
|
|
119
121
|
const e = r.indexOf("charset", t);
|
|
@@ -133,7 +135,7 @@ const U = (r) => {
|
|
|
133
135
|
const s = r.slice(n).search(/[\t\n\f\r ;]/u);
|
|
134
136
|
return s === -1 ? r.slice(n) : r.slice(n, n + s);
|
|
135
137
|
}
|
|
136
|
-
},
|
|
138
|
+
}, de = (r, t) => {
|
|
137
139
|
let e = t;
|
|
138
140
|
for (; w(r.charAt(e)) || r.charAt(e) === "/"; ) e += 1;
|
|
139
141
|
if (r.charAt(e) === ">" || e >= r.length) return { attribute: null, end: e };
|
|
@@ -159,23 +161,23 @@ const U = (r) => {
|
|
|
159
161
|
if (o === ">") return { attribute: { name: n, value: "" }, end: e };
|
|
160
162
|
const s = r.slice(e).search(/[\t\n\f\r >]/u);
|
|
161
163
|
return s === -1 ? { attribute: null, end: r.length } : { attribute: { name: n, value: B(r.slice(e, e + s)) }, end: e + s };
|
|
162
|
-
},
|
|
164
|
+
}, Xe = (r, t) => {
|
|
163
165
|
const e = /* @__PURE__ */ new Set();
|
|
164
166
|
let n = !1, o = null, s = null, a = t;
|
|
165
167
|
for (; ; ) {
|
|
166
|
-
const { attribute: i, end: l } =
|
|
168
|
+
const { attribute: i, end: l } = de(r, a);
|
|
167
169
|
if (a = l, i === null) break;
|
|
168
170
|
if (!e.has(i.name))
|
|
169
171
|
if (e.add(i.name), i.name === "http-equiv")
|
|
170
172
|
n = i.value === "content-type";
|
|
171
173
|
else if (i.name === "content") {
|
|
172
|
-
const c =
|
|
174
|
+
const c = Ge(i.value), f = c === null ? null : H(c);
|
|
173
175
|
f !== null && s === null && (s = f, o = !0);
|
|
174
|
-
} else i.name === "charset" && (s =
|
|
176
|
+
} else i.name === "charset" && (s = H(i.value) ?? !1, o = !1);
|
|
175
177
|
}
|
|
176
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 };
|
|
177
|
-
},
|
|
178
|
-
const t = Array.from(r.subarray(0,
|
|
179
|
+
}, Ve = (r) => {
|
|
180
|
+
const t = Array.from(r.subarray(0, ue), (n) => String.fromCharCode(n)).join("");
|
|
179
181
|
let e = 0;
|
|
180
182
|
for (; e < t.length; )
|
|
181
183
|
if (t.startsWith("<!--", e)) {
|
|
@@ -183,14 +185,14 @@ const U = (r) => {
|
|
|
183
185
|
if (n === -1) return null;
|
|
184
186
|
e = n + 3;
|
|
185
187
|
} else if (/^<meta[\t\n\f\r /]$/iu.test(t.slice(e, e + 6))) {
|
|
186
|
-
const { encoding: n, end: o } =
|
|
188
|
+
const { encoding: n, end: o } = Xe(t, e + 5);
|
|
187
189
|
if (n !== null) return n;
|
|
188
190
|
e = o + 1;
|
|
189
191
|
} else if (/^<\/?[A-Za-z]/u.test(t.slice(e, e + 3))) {
|
|
190
192
|
let n = e + 1;
|
|
191
193
|
for (; n < t.length && !w(t.charAt(n)) && t.charAt(n) !== ">"; ) n += 1;
|
|
192
194
|
for (; ; ) {
|
|
193
|
-
const o =
|
|
195
|
+
const o = de(t, n);
|
|
194
196
|
if (n = o.end, o.attribute === null) break;
|
|
195
197
|
}
|
|
196
198
|
e = n + 1;
|
|
@@ -201,35 +203,35 @@ const U = (r) => {
|
|
|
201
203
|
} else
|
|
202
204
|
e += 1;
|
|
203
205
|
return null;
|
|
204
|
-
}, Ve = (r, t) => {
|
|
205
|
-
const e = Je(r);
|
|
206
|
-
if (e !== null) return e;
|
|
207
|
-
const n = Ke(t), o = n === null ? null : $(n);
|
|
208
|
-
return o !== null ? o : Xe(r) ?? "utf-8";
|
|
209
206
|
}, We = (r, t) => {
|
|
207
|
+
const e = Ke(r);
|
|
208
|
+
if (e !== null) return e;
|
|
209
|
+
const n = Fe(t), o = n === null ? null : H(n);
|
|
210
|
+
return o !== null ? o : Ve(r) ?? "utf-8";
|
|
211
|
+
}, Ye = (r, t) => {
|
|
210
212
|
const e = new Uint8Array(t);
|
|
211
213
|
let n = 0;
|
|
212
214
|
for (const o of r)
|
|
213
215
|
e.set(o, n), n += o.byteLength;
|
|
214
216
|
return e;
|
|
215
|
-
},
|
|
217
|
+
}, Ze = (r) => {
|
|
216
218
|
const t = [];
|
|
217
219
|
let e = 0, n = null;
|
|
218
220
|
const o = () => {
|
|
219
|
-
const s =
|
|
221
|
+
const s = Ye(t, e);
|
|
220
222
|
t.length = 0;
|
|
221
|
-
const a = new TextDecoder(
|
|
223
|
+
const a = new TextDecoder(We(s, r));
|
|
222
224
|
return n = a, { started: a, text: a.decode(s, { stream: !0 }) };
|
|
223
225
|
};
|
|
224
226
|
return {
|
|
225
|
-
write: (s) => n !== null ? n.decode(s, { stream: !0 }) : (t.push(s), e += s.byteLength, e <
|
|
227
|
+
write: (s) => n !== null ? n.decode(s, { stream: !0 }) : (t.push(s), e += s.byteLength, e < ue ? "" : o().text),
|
|
226
228
|
end: () => {
|
|
227
229
|
if (n !== null) return n.decode();
|
|
228
230
|
const { started: s, text: a } = o();
|
|
229
231
|
return a + s.decode();
|
|
230
232
|
}
|
|
231
233
|
};
|
|
232
|
-
},
|
|
234
|
+
}, qe = (r, t, e) => {
|
|
233
235
|
const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
234
236
|
return (s) => {
|
|
235
237
|
const a = n.get(s);
|
|
@@ -241,7 +243,7 @@ const U = (r) => {
|
|
|
241
243
|
});
|
|
242
244
|
return o.set(s, l), l;
|
|
243
245
|
};
|
|
244
|
-
},
|
|
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 = (r, t) => {
|
|
245
247
|
const e = Y({ lookup: r.lookup, blockList: r.blockList, timeout: t }), n = Y({ timeout: t });
|
|
246
248
|
return (o, s) => {
|
|
247
249
|
if (o.protocol !== "https:") {
|
|
@@ -255,27 +257,27 @@ const U = (r) => {
|
|
|
255
257
|
a.setTimeout(0), a.removeListener("error", i), n({ ...o, httpSocket: a }, s);
|
|
256
258
|
});
|
|
257
259
|
};
|
|
258
|
-
},
|
|
259
|
-
maxHeaderSize:
|
|
260
|
-
connect: nt
|
|
261
|
-
}),
|
|
260
|
+
}, at = (r) => new ye({
|
|
261
|
+
maxHeaderSize: Qe,
|
|
262
|
+
connect: ot(nt, fe.timeoutMs)
|
|
263
|
+
}), U = async (r) => {
|
|
262
264
|
r.body !== null && await Promise.allSettled([r.body.cancel()]);
|
|
263
|
-
},
|
|
265
|
+
}, st = (r) => r !== null && tt.has(r.split(";", 1)[0].trim().toLowerCase()), it = (r) => {
|
|
264
266
|
const t = [r];
|
|
265
267
|
for (let e = 0; e < 16 && t.length > 0; e += 1) {
|
|
266
268
|
const n = t.shift();
|
|
267
269
|
if (!(n instanceof Error)) continue;
|
|
268
270
|
const o = n.code;
|
|
269
|
-
if (typeof o == "string" &&
|
|
271
|
+
if (typeof o == "string" && rt.has(o)) return n.message;
|
|
270
272
|
t.push(n.cause, ...n instanceof AggregateError ? n.errors : []);
|
|
271
273
|
}
|
|
272
274
|
return null;
|
|
273
|
-
},
|
|
274
|
-
const e =
|
|
275
|
+
}, me = (r, t) => {
|
|
276
|
+
const e = it(r);
|
|
275
277
|
return e !== null ? (h.info("Refused link-card connection to a private address:", t, e), { ok: !1, reason: "private-network" }) : (h.error("Error fetching link-card metadata:", r), { ok: !1, reason: "unreachable" });
|
|
276
|
-
},
|
|
278
|
+
}, lt = () => new Promise((r) => {
|
|
277
279
|
setImmediate(r);
|
|
278
|
-
}),
|
|
280
|
+
}), ct = async (r, t, e, n) => {
|
|
279
281
|
if (r.body === null) return { ok: !0, value: t.end() };
|
|
280
282
|
const o = r.body.getReader();
|
|
281
283
|
let s = 0;
|
|
@@ -284,7 +286,7 @@ const U = (r) => {
|
|
|
284
286
|
try {
|
|
285
287
|
a = await o.read();
|
|
286
288
|
} catch (f) {
|
|
287
|
-
return
|
|
289
|
+
return me(f, n);
|
|
288
290
|
}
|
|
289
291
|
if (a.done) break;
|
|
290
292
|
const i = e - s, l = a.value.byteLength > i, c = l ? a.value.subarray(0, i) : a.value;
|
|
@@ -296,26 +298,26 @@ const U = (r) => {
|
|
|
296
298
|
await Promise.allSettled([o.cancel()]), h.warn("Link-card page body exceeds the size limit; parsing only its first bytes:", n, e);
|
|
297
299
|
break;
|
|
298
300
|
}
|
|
299
|
-
await
|
|
301
|
+
await lt();
|
|
300
302
|
}
|
|
301
303
|
return { ok: !0, value: t.end() };
|
|
302
|
-
},
|
|
304
|
+
}, ut = async (r, t, e, n) => {
|
|
303
305
|
let o = r;
|
|
304
306
|
for (let s = 0; s <= t.limits.maxRedirects; s += 1) {
|
|
305
307
|
let a;
|
|
306
308
|
try {
|
|
307
|
-
a = await
|
|
309
|
+
a = await Ae(o, { signal: n, redirect: "manual", dispatcher: t.agent });
|
|
308
310
|
} catch (f) {
|
|
309
|
-
return
|
|
311
|
+
return me(f, o);
|
|
310
312
|
}
|
|
311
|
-
const i =
|
|
313
|
+
const i = et.has(a.status) ? a.headers.get("location")?.trim() ?? "" : "";
|
|
312
314
|
if (i === "") {
|
|
313
315
|
if (!a.ok)
|
|
314
|
-
return await
|
|
316
|
+
return await U(a), { ok: !1, reason: "unreachable" };
|
|
315
317
|
const f = a.headers.get("content-type");
|
|
316
|
-
return
|
|
318
|
+
return st(f) ? ct(a, e({ url: o, contentType: f }), t.limits.maxBodyBytes, o) : (await U(a), { ok: !1, reason: "not-html" });
|
|
317
319
|
}
|
|
318
|
-
await
|
|
320
|
+
await U(a);
|
|
319
321
|
let l;
|
|
320
322
|
try {
|
|
321
323
|
l = new URL(i, o);
|
|
@@ -324,16 +326,16 @@ const U = (r) => {
|
|
|
324
326
|
}
|
|
325
327
|
const c = j(l.href);
|
|
326
328
|
if (!c.ok)
|
|
327
|
-
return h.info("Refused link-card redirect:",
|
|
329
|
+
return h.info("Refused link-card redirect:", ce(l), `(${c.reason}: ${c.detail})`), { ok: !1, reason: c.reason };
|
|
328
330
|
o = c.href;
|
|
329
331
|
}
|
|
330
332
|
return h.error("Too many redirects while fetching link-card metadata:", r), { ok: !1, reason: "unreachable" };
|
|
331
|
-
},
|
|
333
|
+
}, dt = (r, t, e) => {
|
|
332
334
|
const n = new AbortController(), o = setTimeout(() => n.abort(), t.limits.timeoutMs);
|
|
333
|
-
return
|
|
335
|
+
return ut(r, t, e, n.signal).finally(() => {
|
|
334
336
|
clearTimeout(o);
|
|
335
337
|
});
|
|
336
|
-
},
|
|
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 = (r) => r?.toLowerCase().split(/[\t\n\f\r ]+/u).includes("icon") === !0, bt = (r, t) => {
|
|
337
339
|
if (r === void 0) return t;
|
|
338
340
|
let e;
|
|
339
341
|
try {
|
|
@@ -341,7 +343,7 @@ const U = (r) => {
|
|
|
341
343
|
} catch {
|
|
342
344
|
return t;
|
|
343
345
|
}
|
|
344
|
-
return (e.protocol === "http:" || e.protocol === "https:") && e.href.length <=
|
|
346
|
+
return (e.protocol === "http:" || e.protocol === "https:") && e.href.length <= ae ? e.href : t;
|
|
345
347
|
}, ee = (r, t, e) => {
|
|
346
348
|
const n = r?.trim();
|
|
347
349
|
if (n === void 0 || n === "") return;
|
|
@@ -351,30 +353,30 @@ const U = (r) => {
|
|
|
351
353
|
} catch {
|
|
352
354
|
return;
|
|
353
355
|
}
|
|
354
|
-
return o.href.length <=
|
|
356
|
+
return o.href.length <= ae && j(o.href).ok ? o.href : void 0;
|
|
355
357
|
}, Et = (r, t) => {
|
|
356
|
-
let e = !1, n = 0, o = 0, s = 0, a = null, i = null, l = null, c, f,
|
|
358
|
+
let e = !1, n = 0, o = 0, s = 0, a = null, i = null, l = null, c, f, S, R, z, J, K = !1, F, G = !1;
|
|
357
359
|
const N = () => {
|
|
358
360
|
e = !0, D.pause();
|
|
359
|
-
}, D = new
|
|
361
|
+
}, D = new _e(
|
|
360
362
|
{
|
|
361
363
|
onopentagname(u) {
|
|
362
|
-
n += 1, o += 1, s = 0, (n >
|
|
364
|
+
n += 1, o += 1, s = 0, (n > ft || o > mt || a === null && !ht.has(u)) && N();
|
|
363
365
|
},
|
|
364
366
|
onattribute() {
|
|
365
|
-
s += 1, s >
|
|
367
|
+
s += 1, s > pt && N();
|
|
366
368
|
},
|
|
367
369
|
onopentag(u, m) {
|
|
368
370
|
if (!(e || a !== null)) {
|
|
369
|
-
if (
|
|
371
|
+
if (gt.has(u)) {
|
|
370
372
|
a = n;
|
|
371
373
|
return;
|
|
372
374
|
}
|
|
373
375
|
if (u === "meta") {
|
|
374
376
|
const p = m.content;
|
|
375
|
-
m.property === "og:site_name" && (R = p), m.property === "og:title" && (f = p), m.property === "og:description" && (
|
|
376
|
-
} else u === "link" && !K &&
|
|
377
|
-
|
|
377
|
+
m.property === "og:site_name" && (R = p), m.property === "og:title" && (f = p), m.property === "og:description" && (S = p), m.property === "og:image" && (z = p), m.name === "description" && (S = p);
|
|
378
|
+
} else u === "link" && !K && kt(m.rel) ? (K = !0, J = m.href) : u === "base" && !G && Object.hasOwn(m, "href") && (G = !0, F = m.href);
|
|
379
|
+
wt.has(u) && (i = u, u === "title" && c === void 0 && (l = ""));
|
|
378
380
|
}
|
|
379
381
|
},
|
|
380
382
|
ontext(u) {
|
|
@@ -396,7 +398,7 @@ const U = (r) => {
|
|
|
396
398
|
write: (u) => (e || D.write(u), !e),
|
|
397
399
|
end: () => {
|
|
398
400
|
e || D.end();
|
|
399
|
-
const u = L(f, O.title) ?? L(c, O.title), m = L(
|
|
401
|
+
const u = L(f, O.title) ?? L(c, O.title), m = L(S, O.description), p = L(R, O.siteName), X = bt(F, r), V = ee(z, X), W = ee(J, X);
|
|
400
402
|
return {
|
|
401
403
|
...u === null ? {} : { title: u },
|
|
402
404
|
...m === null ? {} : { description: m },
|
|
@@ -406,53 +408,53 @@ const U = (r) => {
|
|
|
406
408
|
};
|
|
407
409
|
}
|
|
408
410
|
};
|
|
409
|
-
},
|
|
411
|
+
}, Tt = /* @__PURE__ */ new Set(["authorize"]), vt = "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 = (r, t, e, n, o = {}) => new Response(r.method === "HEAD" ? null : JSON.stringify(e), {
|
|
410
412
|
status: t,
|
|
411
413
|
headers: { "Content-Type": "application/json; charset=utf-8", "Cache-Control": n, "X-Content-Type-Options": "nosniff", ...o }
|
|
412
414
|
}), te = (r) => new Response(null, {
|
|
413
415
|
status: 204,
|
|
414
|
-
headers: { "Cache-Control": `private, max-age=${
|
|
415
|
-
}),
|
|
416
|
+
headers: { "Cache-Control": `private, max-age=${pe[r]}`, "X-Content-Type-Options": "nosniff", [Ee]: r }
|
|
417
|
+
}), At = (r) => {
|
|
416
418
|
if (typeof r != "object" || r === null)
|
|
417
419
|
throw new TypeError("createLinkCardHandler: options must be an object with an authorize function");
|
|
418
420
|
if (typeof r.authorize != "function")
|
|
419
421
|
throw new TypeError("createLinkCardHandler: options.authorize must be a function (pass () => true to serve everyone)");
|
|
420
|
-
const t = Object.keys(r).filter((e) => !
|
|
422
|
+
const t = Object.keys(r).filter((e) => !Tt.has(e));
|
|
421
423
|
if (t.length > 0)
|
|
422
424
|
throw new TypeError(`createLinkCardHandler: unknown option(s): ${t.join(", ")}`);
|
|
423
|
-
},
|
|
424
|
-
const e =
|
|
425
|
+
}, _t = (r) => (t) => {
|
|
426
|
+
const e = Ze(t.contentType), n = Et(t.url);
|
|
425
427
|
return {
|
|
426
428
|
write: (o) => n.write(e.write(o)),
|
|
427
429
|
end: () => (n.write(e.end()), n.end())
|
|
428
430
|
};
|
|
429
|
-
},
|
|
430
|
-
|
|
431
|
-
const { authorize: e } = r, n =
|
|
432
|
-
(s) =>
|
|
433
|
-
{ maxEntries:
|
|
431
|
+
}, Rt = (r, t) => {
|
|
432
|
+
At(r);
|
|
433
|
+
const { authorize: e } = r, n = at(), o = qe(
|
|
434
|
+
(s) => dt(s, { agent: n, scope: t, limits: fe }, _t()),
|
|
435
|
+
{ maxEntries: yt, ttlMsOf: (s) => s.ok ? St : pe[s.reason] * 1e3 },
|
|
434
436
|
Date.now
|
|
435
437
|
);
|
|
436
438
|
return async (s) => {
|
|
437
439
|
if (s.method !== "GET" && s.method !== "HEAD")
|
|
438
|
-
return
|
|
440
|
+
return y(s, 405, { error: "Method Not Allowed" }, P, { Allow: "GET, HEAD" });
|
|
439
441
|
if (await e(s) !== !0)
|
|
440
|
-
return
|
|
442
|
+
return y(s, 401, { error: "Unauthorized" }, P);
|
|
441
443
|
const a = new URL(s.url).searchParams.get("url");
|
|
442
444
|
if (a === null || a === "")
|
|
443
|
-
return
|
|
445
|
+
return y(s, 400, { error: "Missing 'url' parameter" }, P);
|
|
444
446
|
const i = j(a);
|
|
445
447
|
if (!i.ok)
|
|
446
|
-
return h.info("Refused link-card URL:",
|
|
448
|
+
return h.info("Refused link-card URL:", ce(a), `(${i.reason}: ${i.detail})`), te(i.reason);
|
|
447
449
|
let l;
|
|
448
450
|
try {
|
|
449
451
|
l = await o(i.href);
|
|
450
452
|
} catch (c) {
|
|
451
|
-
return h.error("Unexpected error while reading link-card metadata:", i.href, c),
|
|
453
|
+
return h.error("Unexpected error while reading link-card metadata:", i.href, c), y(s, 500, { error: "Internal Server Error" }, P);
|
|
452
454
|
}
|
|
453
|
-
return l.ok ?
|
|
455
|
+
return l.ok ? y(s, 200, l.value, vt) : te(l.reason);
|
|
454
456
|
};
|
|
455
|
-
}, Yt = (r) =>
|
|
457
|
+
}, Yt = (r) => Rt(r, "public");
|
|
456
458
|
class k extends x {
|
|
457
459
|
/**
|
|
458
460
|
* @generated from field: string markdown_text = 1;
|
|
@@ -656,7 +658,7 @@ class g extends x {
|
|
|
656
658
|
return d.util.equals(g, t, e);
|
|
657
659
|
}
|
|
658
660
|
}
|
|
659
|
-
class
|
|
661
|
+
class b extends x {
|
|
660
662
|
/**
|
|
661
663
|
* @generated from field: string html_content = 1;
|
|
662
664
|
*/
|
|
@@ -678,22 +680,22 @@ class E extends x {
|
|
|
678
680
|
T: 9
|
|
679
681
|
/* ScalarType.STRING */
|
|
680
682
|
},
|
|
681
|
-
{ no: 2, name: "headings", kind: "message", T:
|
|
683
|
+
{ no: 2, name: "headings", kind: "message", T: E, repeated: !0 }
|
|
682
684
|
]);
|
|
683
685
|
static fromBinary(t, e) {
|
|
684
|
-
return new
|
|
686
|
+
return new b().fromBinary(t, e);
|
|
685
687
|
}
|
|
686
688
|
static fromJson(t, e) {
|
|
687
|
-
return new
|
|
689
|
+
return new b().fromJson(t, e);
|
|
688
690
|
}
|
|
689
691
|
static fromJsonString(t, e) {
|
|
690
|
-
return new
|
|
692
|
+
return new b().fromJsonString(t, e);
|
|
691
693
|
}
|
|
692
694
|
static equals(t, e) {
|
|
693
|
-
return d.util.equals(
|
|
695
|
+
return d.util.equals(b, t, e);
|
|
694
696
|
}
|
|
695
697
|
}
|
|
696
|
-
class
|
|
698
|
+
class E extends x {
|
|
697
699
|
/**
|
|
698
700
|
* @generated from field: string text = 1;
|
|
699
701
|
*/
|
|
@@ -735,19 +737,19 @@ class b extends x {
|
|
|
735
737
|
}
|
|
736
738
|
]);
|
|
737
739
|
static fromBinary(t, e) {
|
|
738
|
-
return new
|
|
740
|
+
return new E().fromBinary(t, e);
|
|
739
741
|
}
|
|
740
742
|
static fromJson(t, e) {
|
|
741
|
-
return new
|
|
743
|
+
return new E().fromJson(t, e);
|
|
742
744
|
}
|
|
743
745
|
static fromJsonString(t, e) {
|
|
744
|
-
return new
|
|
746
|
+
return new E().fromJsonString(t, e);
|
|
745
747
|
}
|
|
746
748
|
static equals(t, e) {
|
|
747
|
-
return d.util.equals(
|
|
749
|
+
return d.util.equals(E, t, e);
|
|
748
750
|
}
|
|
749
751
|
}
|
|
750
|
-
const
|
|
752
|
+
const Lt = {
|
|
751
753
|
typeName: "markdown.v1.MarkdownService",
|
|
752
754
|
methods: {
|
|
753
755
|
/**
|
|
@@ -756,81 +758,69 @@ const Rt = {
|
|
|
756
758
|
convert: {
|
|
757
759
|
name: "Convert",
|
|
758
760
|
I: k,
|
|
759
|
-
O:
|
|
760
|
-
kind:
|
|
761
|
+
O: b,
|
|
762
|
+
kind: De.Unary
|
|
761
763
|
}
|
|
762
764
|
}
|
|
763
|
-
},
|
|
764
|
-
createConnection: () =>
|
|
765
|
-
}),
|
|
766
|
-
class Pt extends Error {
|
|
767
|
-
/**
|
|
768
|
-
* Wraps the service's or the transport's resource-exhausted error.
|
|
769
|
-
* サービスか転送の resource exhausted のエラーを包む処理。
|
|
770
|
-
*
|
|
771
|
-
* @param cause - The connect error. connect のエラー。
|
|
772
|
-
*/
|
|
773
|
-
constructor(t) {
|
|
774
|
-
super(t.rawMessage, { cause: t }), this.name = "MarkdownResourceExhaustedError";
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
const ne = () => {
|
|
765
|
+
}, v = process.env.MARKDOWN_SOCKET_PATH || "/tmp/markdown.sock", Ot = new xe("http://localhost", void 0, {
|
|
766
|
+
createConnection: () => se.connect(v)
|
|
767
|
+
}), re = () => {
|
|
778
768
|
try {
|
|
779
|
-
return
|
|
769
|
+
return M.dirname(Pe(import.meta.url));
|
|
780
770
|
} catch {
|
|
781
771
|
return __dirname;
|
|
782
772
|
}
|
|
783
|
-
},
|
|
773
|
+
}, he = () => `@aiquants/markdown-${process.platform}-${process.arch}`, ne = () => process.platform === "win32" ? "bin/markdown-api.exe" : "bin/markdown-api", Pt = () => {
|
|
784
774
|
const r = process.env.MARKDOWN_API_BINARY;
|
|
785
|
-
if (r &&
|
|
775
|
+
if (r && C(r))
|
|
786
776
|
return r;
|
|
787
777
|
try {
|
|
788
|
-
const e =
|
|
789
|
-
if (
|
|
778
|
+
const e = Oe(M.join(re(), "index.js")).resolve(`${he()}/${ne()}`);
|
|
779
|
+
if (C(e))
|
|
790
780
|
return e;
|
|
791
781
|
} catch {
|
|
792
782
|
}
|
|
793
|
-
const t =
|
|
794
|
-
return
|
|
783
|
+
const t = M.join(re(), "..", "..", "go", "markdown-api", "dist", M.basename(ne()));
|
|
784
|
+
return C(t) ? t : void 0;
|
|
795
785
|
}, Ct = () => [
|
|
796
786
|
`markdown-api binary not found for ${process.platform}-${process.arch}.`,
|
|
797
|
-
`Expected the optional dependency ${
|
|
787
|
+
`Expected the optional dependency ${he()} to be installed.`,
|
|
798
788
|
"If your platform is unsupported, build the service yourself",
|
|
799
789
|
"(https://github.com/fehde-k/aiquants/tree/main/packages/go/markdown-api)",
|
|
800
790
|
"and point MARKDOWN_API_BINARY at it."
|
|
801
|
-
].join(" "),
|
|
802
|
-
const t =
|
|
791
|
+
].join(" "), we = () => new Promise((r) => {
|
|
792
|
+
const t = se.connect(v);
|
|
803
793
|
t.on("connect", () => {
|
|
804
794
|
t.destroy(), r(!0);
|
|
805
795
|
}), t.on("error", () => r(!1));
|
|
806
|
-
}),
|
|
796
|
+
}), oe = async (r) => {
|
|
807
797
|
const t = Date.now();
|
|
808
798
|
for (; Date.now() - t < r; ) {
|
|
809
|
-
if (await
|
|
799
|
+
if (await we()) return !0;
|
|
810
800
|
await new Promise((e) => setTimeout(e, 100));
|
|
811
801
|
}
|
|
812
802
|
return !1;
|
|
813
803
|
};
|
|
814
804
|
let A = null, _ = null;
|
|
815
|
-
const
|
|
805
|
+
const Mt = 2e3, It = () => {
|
|
816
806
|
const r = Number(process.env.MARKDOWN_API_STARTUP_TIMEOUT_MS);
|
|
817
807
|
return Number.isFinite(r) && r > 0 ? r : 1e4;
|
|
818
808
|
};
|
|
819
809
|
let I = null;
|
|
820
|
-
const
|
|
821
|
-
if (await
|
|
810
|
+
const xt = async () => {
|
|
811
|
+
if (await we()) return !0;
|
|
822
812
|
if (_) return _;
|
|
823
813
|
_ = (async () => {
|
|
824
|
-
const t =
|
|
814
|
+
const t = Pt();
|
|
825
815
|
if (!t)
|
|
826
|
-
return await
|
|
816
|
+
return await oe(Mt) ? !0 : (I = Ct(), !1);
|
|
827
817
|
I = null;
|
|
828
818
|
try {
|
|
829
|
-
|
|
819
|
+
C(v) && Le(v);
|
|
830
820
|
} catch {
|
|
831
821
|
}
|
|
832
822
|
try {
|
|
833
|
-
A =
|
|
823
|
+
A = Re(t, [], { stdio: "ignore" });
|
|
834
824
|
const e = () => {
|
|
835
825
|
if (A) {
|
|
836
826
|
try {
|
|
@@ -840,28 +830,24 @@ const Nt = async () => {
|
|
|
840
830
|
A = null;
|
|
841
831
|
}
|
|
842
832
|
};
|
|
843
|
-
return process.once("exit", e), await
|
|
833
|
+
return process.once("exit", e), await oe(It()) ? !0 : (console.error("markdown-api Go server did not become ready on socket:", v), e(), process.removeListener("exit", e), !1);
|
|
844
834
|
} catch (e) {
|
|
845
835
|
return console.error("Failed to spawn markdown-api Go server:", e), A = null, !1;
|
|
846
836
|
}
|
|
847
837
|
})();
|
|
848
838
|
const r = await _;
|
|
849
839
|
return r || (_ = null), r;
|
|
850
|
-
},
|
|
851
|
-
if (!
|
|
852
|
-
throw new TypeError("parseMarkdown: deniedPathSegments must be an array of path segment patterns (an empty array denies nothing)");
|
|
853
|
-
if (!Number.isSafeInteger(r.maxHtmlBytes) || r.maxHtmlBytes <= 0 || r.maxHtmlBytes > re)
|
|
854
|
-
throw new RangeError(`parseMarkdown: maxHtmlBytes must be an integer from 1 to ${re}, got ${r.maxHtmlBytes}`);
|
|
855
|
-
if (r.timeoutMs !== void 0 && (!Number.isSafeInteger(r.timeoutMs) || r.timeoutMs <= 0))
|
|
840
|
+
}, Nt = (r) => {
|
|
841
|
+
if (be(r, "parseMarkdown"), r.timeoutMs !== void 0 && (!Number.isSafeInteger(r.timeoutMs) || r.timeoutMs <= 0))
|
|
856
842
|
throw new RangeError(`parseMarkdown: timeoutMs must be a positive integer, got ${r.timeoutMs}`);
|
|
857
843
|
}, Zt = async (r, t, e, n, o) => {
|
|
858
|
-
if (
|
|
844
|
+
if (Nt(o), !await xt()) {
|
|
859
845
|
const i = I ? ` ${I}` : "";
|
|
860
|
-
throw new Error(`markdown service is not reachable on ${
|
|
846
|
+
throw new Error(`markdown service is not reachable on ${v}.${i}`);
|
|
861
847
|
}
|
|
862
848
|
const s = {};
|
|
863
849
|
n && (s.Authorization = `Bearer ${n}`);
|
|
864
|
-
const a =
|
|
850
|
+
const a = Ce(Lt, Ne({ baseUrl: "http://localhost", httpVersion: "2", sessionManager: Ot, readMaxBytes: 2 * o.maxHtmlBytes + ge }));
|
|
865
851
|
try {
|
|
866
852
|
const i = await a.convert(
|
|
867
853
|
{
|
|
@@ -891,12 +877,12 @@ const Nt = async () => {
|
|
|
891
877
|
}))
|
|
892
878
|
};
|
|
893
879
|
} catch (i) {
|
|
894
|
-
throw i instanceof Me && i.code ===
|
|
880
|
+
throw i instanceof Me && i.code === Ie.ResourceExhausted ? new ke(i.rawMessage, { cause: i }) : i;
|
|
895
881
|
}
|
|
896
882
|
};
|
|
897
883
|
export {
|
|
898
|
-
|
|
899
|
-
|
|
884
|
+
er as MAX_HTML_BYTES_LIMIT,
|
|
885
|
+
ke as MarkdownResourceExhaustedError,
|
|
900
886
|
Yt as createLinkCardHandler,
|
|
901
887
|
Zt as parseMarkdown
|
|
902
888
|
};
|