@aiquants/markdown 6.0.0 → 6.2.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 +142 -7
- package/dist/{abnfDiagram-VRR7QNED-D7Rp9EaV.js → abnfDiagram-VRR7QNED-Csrzuwyl.js} +3 -3
- package/dist/{abnfDiagram-VRR7QNED-KTGT9TWM.cjs → abnfDiagram-VRR7QNED-DX6eyf4O.cjs} +1 -1
- package/dist/arc-Gw7Urszo.js +83 -0
- package/dist/{arc-D5T_urCC.cjs → arc-ZAQ3z7kr.cjs} +1 -1
- package/dist/{architectureDiagram-ZJ3FMSHR-DLrGYTYy.js → architectureDiagram-ZJ3FMSHR-Coy6_Fcg.js} +2 -2
- package/dist/{architectureDiagram-ZJ3FMSHR-BOo3y9aD.cjs → architectureDiagram-ZJ3FMSHR-DxzMbkp1.cjs} +1 -1
- package/dist/{blockDiagram-677ZJIJ3-B60l5Fpl.js → blockDiagram-677ZJIJ3-CbR-wn2x.js} +3 -3
- package/dist/{blockDiagram-677ZJIJ3-DnjCjo0a.cjs → blockDiagram-677ZJIJ3-THmR4OyE.cjs} +1 -1
- package/dist/{c4Diagram-LMCZKHZV-bd8fWQ1F.cjs → c4Diagram-LMCZKHZV-BcJpuXK1.cjs} +1 -1
- package/dist/{c4Diagram-LMCZKHZV-BmbplKCu.js → c4Diagram-LMCZKHZV-DHMqNO9p.js} +2 -2
- package/dist/{channel-B3oXm84X.js → channel-CfC4eqki.js} +1 -1
- package/dist/{channel-DJ_PyD9w.cjs → channel-Cryph4zI.cjs} +1 -1
- package/dist/{chunk-2Q5K7J3B-C0hbxO3D.js → chunk-2Q5K7J3B-C3BIc3MH.js} +1 -1
- package/dist/{chunk-2Q5K7J3B-CWLCO342.cjs → chunk-2Q5K7J3B-CxWyY331.cjs} +1 -1
- package/dist/{chunk-32BRIVSS-DUWtkDEY.js → chunk-32BRIVSS-C37ccuiX.js} +1 -1
- package/dist/{chunk-32BRIVSS-Cb9nTxqN.cjs → chunk-32BRIVSS-C3w_aYfI.cjs} +1 -1
- package/dist/{chunk-5VM5RSS4-DHA5n_Ls.cjs → chunk-5VM5RSS4-Cbt79-V5.cjs} +1 -1
- package/dist/{chunk-5VM5RSS4-C3mSh-gE.js → chunk-5VM5RSS4-DVLmkcyq.js} +1 -1
- package/dist/{chunk-EX3LRPZG-ByY6_kep.cjs → chunk-EX3LRPZG-BZOxrSRn.cjs} +1 -1
- package/dist/{chunk-EX3LRPZG-DCF1zjtT.js → chunk-EX3LRPZG-Co0Bql0-.js} +37 -37
- package/dist/{chunk-JWPE2WC7-CUBzYD4G.cjs → chunk-JWPE2WC7-Cvt_ToFU.cjs} +1 -1
- package/dist/{chunk-JWPE2WC7-CPLOunIL.js → chunk-JWPE2WC7-DUndc3Wb.js} +1 -1
- package/dist/{chunk-MOJQB5TN-P8-yb3-j.cjs → chunk-MOJQB5TN-AAMW2q8N.cjs} +1 -1
- package/dist/{chunk-MOJQB5TN-CmOhW6SK.js → chunk-MOJQB5TN-aTSDPliR.js} +11 -11
- package/dist/{chunk-PUDLZKDR-pKdIELvz.cjs → chunk-PUDLZKDR-CzCdcyAN.cjs} +1 -1
- package/dist/{chunk-PUDLZKDR-DH7B7ZTK.js → chunk-PUDLZKDR-Q5QzbDtY.js} +11 -11
- package/dist/{chunk-RYQCIY6F-DcvQCEoc.cjs → chunk-RYQCIY6F-DbjhsOnH.cjs} +1 -1
- package/dist/{chunk-RYQCIY6F-C7ytn_QX.js → chunk-RYQCIY6F-O6wbIIFF.js} +10 -10
- package/dist/{chunk-V7JOEXUC-CtXgqODy.cjs → chunk-V7JOEXUC-B6Qc5ABc.cjs} +1 -1
- package/dist/{chunk-V7JOEXUC-BgLcssUF.js → chunk-V7JOEXUC-OTS1fN7j.js} +10 -10
- package/dist/{chunk-VR4S4FIN-BK6xeIQk.js → chunk-VR4S4FIN-D4tY80kq.js} +1 -1
- package/dist/{chunk-VR4S4FIN-Cc4GDi2Z.cjs → chunk-VR4S4FIN-DlneMFEg.cjs} +1 -1
- package/dist/{chunk-XXDRQBXY-COtZ25Ez.js → chunk-XXDRQBXY-58rTAwvh.js} +1 -1
- package/dist/{chunk-XXDRQBXY-D1OixGzR.cjs → chunk-XXDRQBXY-CvhBfnFQ.cjs} +1 -1
- package/dist/{classDiagram-OUVF2IWQ-DDLmqaG6.cjs → classDiagram-OUVF2IWQ-C0S2HAJU.cjs} +1 -1
- package/dist/{classDiagram-v2-EOCWNBFH-Jc-IwOm0.js → classDiagram-OUVF2IWQ-hcuKRiyp.js} +2 -2
- package/dist/{classDiagram-v2-EOCWNBFH-DDLmqaG6.cjs → classDiagram-v2-EOCWNBFH-C0S2HAJU.cjs} +1 -1
- package/dist/{classDiagram-OUVF2IWQ-Jc-IwOm0.js → classDiagram-v2-EOCWNBFH-hcuKRiyp.js} +2 -2
- package/dist/components/HostedScrollArea.d.ts +15 -0
- package/dist/components/MarkdownViewer.d.ts +3 -1
- package/dist/components/embeds/LinkCard.d.ts +14 -3
- package/dist/components/mermaidInteraction.d.ts +1 -0
- package/dist/{cose-bilkent-JH36ORCC-DaucPocG.js → cose-bilkent-JH36ORCC-BwltbHKG.js} +5 -5
- package/dist/{cose-bilkent-JH36ORCC-OwiXHdQY.cjs → cose-bilkent-JH36ORCC-DVZVn03H.cjs} +1 -1
- package/dist/{cynefinDiagram-TSTJHNR4-Ag-HcuUm.cjs → cynefinDiagram-TSTJHNR4-DYCBxaEi.cjs} +1 -1
- package/dist/{cynefinDiagram-TSTJHNR4-Dkmz7gDw.js → cynefinDiagram-TSTJHNR4-ogTeIoNY.js} +28 -28
- package/dist/{dagre-VKFMJZFB-BHGdcjt3.js → dagre-VKFMJZFB-BfNdgMHQ.js} +9 -9
- package/dist/{dagre-VKFMJZFB-Q4CcAQ09.cjs → dagre-VKFMJZFB-DJW9o9XX.cjs} +1 -1
- package/dist/{diagram-FQU43EPY-jWCrN_AW.cjs → diagram-FQU43EPY-BRpNVpgn.cjs} +1 -1
- package/dist/{diagram-FQU43EPY-DBASKnKu.js → diagram-FQU43EPY-CJf3yD8h.js} +25 -25
- package/dist/{diagram-G47NLZAW-B4XMStX7.cjs → diagram-G47NLZAW-5rZfUeWV.cjs} +1 -1
- package/dist/{diagram-G47NLZAW-BY1mmnYA.js → diagram-G47NLZAW-D0-6oupP.js} +25 -25
- package/dist/{diagram-NH7WQ7WH-BXFvYRtm.js → diagram-NH7WQ7WH-BwrWWWZJ.js} +19 -19
- package/dist/{diagram-NH7WQ7WH-BS1eEa9R.cjs → diagram-NH7WQ7WH-g7m8p5fK.cjs} +1 -1
- package/dist/{diagram-OA4YK3LP-DgGrzezu.js → diagram-OA4YK3LP-BBqA1m8s.js} +13 -13
- package/dist/{diagram-OA4YK3LP-CTaL_2Nc.cjs → diagram-OA4YK3LP-BxP8KUna.cjs} +1 -1
- package/dist/{diagram-WEI45ONY-BHxWKH3v.js → diagram-WEI45ONY-CMexm2GN.js} +35 -35
- package/dist/{diagram-WEI45ONY-DX7BGSMI.cjs → diagram-WEI45ONY-DgJyq1w0.cjs} +1 -1
- package/dist/{ebnfDiagram-CCIWWBDH-BUK_anpV.js → ebnfDiagram-CCIWWBDH-DvLr_8nV.js} +3 -3
- package/dist/{ebnfDiagram-CCIWWBDH-BpDmVVJY.cjs → ebnfDiagram-CCIWWBDH-sfiWOXCW.cjs} +1 -1
- package/dist/embeds/linkCards.d.ts +32 -0
- package/dist/embeds/testing.cjs +1 -1
- package/dist/embeds/testing.js +1 -1
- package/dist/embeds.cjs +1 -1
- package/dist/embeds.d.ts +1 -1
- package/dist/embeds.js +53 -74
- package/dist/{erDiagram-Q63AITRT-Cd9H9BtP.cjs → erDiagram-Q63AITRT-B11THykZ.cjs} +1 -1
- package/dist/{erDiagram-Q63AITRT-Qb2bmkNp.js → erDiagram-Q63AITRT-D6U6Ng3Y.js} +4 -4
- package/dist/{extractHeadings-B2pUyEPa.js → extractHeadings-CdLPwHlC.js} +4882 -4827
- package/dist/extractHeadings-DRUBnhbi.cjs +311 -0
- package/dist/flowDiagram-23GEKE2U-CDscoQ9F.cjs +1 -0
- package/dist/flowDiagram-23GEKE2U-CLibi_u4.js +7 -0
- package/dist/{ganttDiagram-NO4QXBWP-C6-ExcDz.cjs → ganttDiagram-NO4QXBWP-BLlXK3zo.cjs} +1 -1
- package/dist/{ganttDiagram-NO4QXBWP-BVISsrzr.js → ganttDiagram-NO4QXBWP-CGCdgj0K.js} +2 -2
- package/dist/{gitGraphDiagram-IHSO6WYX-DLzPc702.cjs → gitGraphDiagram-IHSO6WYX-BHOyibqH.cjs} +1 -1
- package/dist/{gitGraphDiagram-IHSO6WYX-BDVA2TFP.js → gitGraphDiagram-IHSO6WYX-Bib3c0C6.js} +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.client.cjs +1 -1
- package/dist/index.client.d.ts +1 -0
- package/dist/index.client.js +33 -32
- package/dist/index.js +33 -32
- package/dist/index.server.cjs +1 -1
- package/dist/index.server.d.ts +1 -0
- package/dist/index.server.js +598 -151
- package/dist/{infoDiagram-FWYZ7A6U-D31UwqjR.js → infoDiagram-FWYZ7A6U-BUqDBIaP.js} +3 -3
- package/dist/{infoDiagram-FWYZ7A6U-DMF_wb2h.cjs → infoDiagram-FWYZ7A6U-BcDp6g1Y.cjs} +1 -1
- package/dist/{ishikawaDiagram-FXEZZL3T-DUlnwraq.cjs → ishikawaDiagram-FXEZZL3T-C3QHQ1ia.cjs} +1 -1
- package/dist/{ishikawaDiagram-FXEZZL3T-XA6-gyHY.js → ishikawaDiagram-FXEZZL3T-CcPh4nuP.js} +18 -18
- package/dist/{journeyDiagram-5HDEW3XC-CwQyFcYa.cjs → journeyDiagram-5HDEW3XC-B17v98Wb.cjs} +1 -1
- package/dist/{journeyDiagram-5HDEW3XC-B8sfsWpu.js → journeyDiagram-5HDEW3XC-MdxndgF1.js} +30 -30
- package/dist/{kanban-definition-HUTT4EX6-BjPlt2-E.cjs → kanban-definition-HUTT4EX6-BApVXeVQ.cjs} +1 -1
- package/dist/{kanban-definition-HUTT4EX6-FTrTBare.js → kanban-definition-HUTT4EX6-JhfZ6Qik.js} +120 -120
- package/dist/{linear-D3AJM3sY.cjs → linear-CIVwb13z.cjs} +1 -1
- package/dist/{linear-DI9P_z72.js → linear-dbOUbGpD.js} +8 -8
- package/dist/linkCardServer/addressGuard.server.d.ts +25 -0
- package/dist/linkCardServer/htmlEncoding.server.d.ts +6 -0
- package/dist/linkCardServer/linkCardHandler.server.d.ts +7 -0
- package/dist/linkCardServer/metadataCache.server.d.ts +5 -0
- package/dist/linkCardServer/pageFetch.server.d.ts +37 -0
- package/dist/linkCardServer/pageMetadata.server.d.ts +11 -0
- package/dist/linkCards-1JxY8wdm.js +48 -0
- package/dist/linkCards-Bjd_vW39.cjs +1 -0
- package/dist/markdown.css +1 -1
- package/dist/{mindmap-definition-LN4V7U3C-CxgWZidl.cjs → mindmap-definition-LN4V7U3C-BUbo0u-Y.cjs} +1 -1
- package/dist/{mindmap-definition-LN4V7U3C-YW4YcL9x.js → mindmap-definition-LN4V7U3C-gNTBga2z.js} +16 -16
- package/dist/{pegDiagram-2B236MQR-sJjLKeF3.js → pegDiagram-2B236MQR-BqjpbNkG.js} +3 -3
- package/dist/{pegDiagram-2B236MQR-CUo7q5bl.cjs → pegDiagram-2B236MQR-DZiQVxu1.cjs} +1 -1
- package/dist/{pieDiagram-ENE6RG2P-D4VanIOv.js → pieDiagram-ENE6RG2P-C1Gr48CK.js} +60 -60
- package/dist/{pieDiagram-ENE6RG2P-Cy_sUuLQ.cjs → pieDiagram-ENE6RG2P-D2nxDVFV.cjs} +1 -1
- package/dist/providers-BO7J62-7.cjs +1 -0
- package/dist/{providers-Drq7MT_K.js → providers-L5RM3KgR.js} +23 -23
- package/dist/{quadrantDiagram-ABIIQ3AL-D3c8xLpt.cjs → quadrantDiagram-ABIIQ3AL-C855tL3K.cjs} +1 -1
- package/dist/{quadrantDiagram-ABIIQ3AL-ubxphjb_.js → quadrantDiagram-ABIIQ3AL-DuD9ZdUQ.js} +18 -18
- package/dist/{railroadDiagram-RFXS5EU6-_Q4W5hB-.cjs → railroadDiagram-RFXS5EU6-BZsnhaQd.cjs} +1 -1
- package/dist/{railroadDiagram-RFXS5EU6-DvpD4C_A.js → railroadDiagram-RFXS5EU6-xx1d3Md8.js} +3 -3
- package/dist/{requirementDiagram-TGXJPOKE-Dk_6BuX9.js → requirementDiagram-TGXJPOKE-CCu1UYFH.js} +3 -3
- package/dist/{requirementDiagram-TGXJPOKE-DdYIO-wU.cjs → requirementDiagram-TGXJPOKE-D_NbFRkb.cjs} +1 -1
- package/dist/{sankeyDiagram-HTMAVEWB-zuYg6LTg.cjs → sankeyDiagram-HTMAVEWB-Dn2Ta-XX.cjs} +1 -1
- package/dist/{sankeyDiagram-HTMAVEWB-s3Kd7T8n.js → sankeyDiagram-HTMAVEWB-QGzXzczJ.js} +1 -1
- package/dist/{sequenceDiagram-DBY2YBRQ-BvNPCevg.cjs → sequenceDiagram-DBY2YBRQ-BA3Oc4pz.cjs} +1 -1
- package/dist/{sequenceDiagram-DBY2YBRQ-YQic4wxL.js → sequenceDiagram-DBY2YBRQ-CjnUnaw9.js} +3 -3
- package/dist/simple-logger-9yf7ypyB.cjs +1 -0
- package/dist/simple-logger-DwH1YQvq.js +103 -0
- package/dist/{sizeCapture-X5ZJPWSS-BqrdzzsI.cjs → sizeCapture-X5ZJPWSS-BPQhVBe0.cjs} +1 -1
- package/dist/{sizeCapture-X5ZJPWSS-qMsWGfjy.js → sizeCapture-X5ZJPWSS-nb9uU-BE.js} +1 -1
- package/dist/{stateDiagram-2N3HPSRC-D1Ub8LYq.js → stateDiagram-2N3HPSRC-Byg3E1AA.js} +11 -11
- package/dist/{stateDiagram-2N3HPSRC-Ds8f-scd.cjs → stateDiagram-2N3HPSRC-DSqLqSY5.cjs} +1 -1
- package/dist/{stateDiagram-v2-6OUMAXLB-PmrsPXuZ.cjs → stateDiagram-v2-6OUMAXLB-VRhXyf-C.cjs} +1 -1
- package/dist/{stateDiagram-v2-6OUMAXLB-DW8wjtk3.js → stateDiagram-v2-6OUMAXLB-hKcuYy9t.js} +2 -2
- package/dist/styles/markdown.css +1 -1
- package/dist/{swimlanes-5IMT3BWC-jZhcesRT.cjs → swimlanes-5IMT3BWC-CVnOKNcb.cjs} +1 -1
- package/dist/{swimlanes-5IMT3BWC-C8P8vU0w.js → swimlanes-5IMT3BWC-DyIDdThc.js} +3 -3
- package/dist/{swimlanesDiagram-G3AALYLV-B9FKeJRf.js → swimlanesDiagram-G3AALYLV-BF1ofRjP.js} +2 -2
- package/dist/{swimlanesDiagram-G3AALYLV-M5Cg2MHU.cjs → swimlanesDiagram-G3AALYLV-C3U5wLlX.cjs} +1 -1
- package/dist/{timeline-definition-FHXFAJF6-Ch-He--D.js → timeline-definition-FHXFAJF6-DBmE_qU3.js} +38 -38
- package/dist/{timeline-definition-FHXFAJF6-DZm1-KlQ.cjs → timeline-definition-FHXFAJF6-KUETCXLT.cjs} +1 -1
- package/dist/utils/simple-logger.d.ts +1 -0
- package/dist/{vennDiagram-L72KCM5P-CaoPscCM.js → vennDiagram-L72KCM5P-C6j4k5X-.js} +102 -102
- package/dist/{vennDiagram-L72KCM5P-mUSI238J.cjs → vennDiagram-L72KCM5P-DkSV3dIE.cjs} +1 -1
- package/dist/{wardleyDiagram-EHGQE667-CSAqF366.js → wardleyDiagram-EHGQE667-BaG6Cf_u.js} +18 -18
- package/dist/{wardleyDiagram-EHGQE667-CkKP97H-.cjs → wardleyDiagram-EHGQE667-uWMTMxL-.cjs} +1 -1
- package/dist/{xychartDiagram-FW5EYKEG-OEsTD_k4.js → xychartDiagram-FW5EYKEG-BPl5BnMB.js} +27 -27
- package/dist/{xychartDiagram-FW5EYKEG-BivGpkVk.cjs → xychartDiagram-FW5EYKEG-QAFE-xqg.cjs} +1 -1
- package/package.json +12 -8
- package/dist/arc-DzZml7Bc.js +0 -83
- package/dist/extractHeadings-DgefF9l1.cjs +0 -311
- package/dist/flowDiagram-23GEKE2U-BOmNlv7X.cjs +0 -1
- package/dist/flowDiagram-23GEKE2U-DMZnRz-6.js +0 -7
- package/dist/providers-Bxr2Wb-j.cjs +0 -1
package/dist/index.server.js
CHANGED
|
@@ -1,13 +1,459 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
1
|
+
import { l as L, L as O, a as se, b as ke } from "./linkCards-1JxY8wdm.js";
|
|
2
|
+
import { l as h } from "./simple-logger-DwH1YQvq.js";
|
|
3
|
+
import { Resolver as be } from "node:dns/promises";
|
|
4
|
+
import * as ie from "node:net";
|
|
5
|
+
import { BlockList as ye, isIP as le, connect as Te } from "node:net";
|
|
6
|
+
import { Agent as Se, buildConnector as Y, fetch as ve } from "undici";
|
|
7
|
+
import { Parser as Ae } from "htmlparser2";
|
|
8
|
+
import { spawn as _e } from "node:child_process";
|
|
9
|
+
import { existsSync as M, unlinkSync as Re } from "node:fs";
|
|
10
|
+
import { createRequire as Le } from "node:module";
|
|
11
|
+
import * as C from "node:path";
|
|
12
|
+
import { fileURLToPath as Oe } from "node:url";
|
|
13
|
+
import { createClient as Pe, ConnectError as Me, Code as Ce } from "@connectrpc/connect";
|
|
14
|
+
import { Http2SessionManager as Ie, createConnectTransport as xe } from "@connectrpc/connect-node";
|
|
15
|
+
import { Message as x, proto3 as d, MethodKind as Ne } from "@bufbuild/protobuf";
|
|
16
|
+
const De = [
|
|
17
|
+
[[0], 8],
|
|
18
|
+
[[10], 8],
|
|
19
|
+
[[100, 64], 10],
|
|
20
|
+
[[127], 8],
|
|
21
|
+
[[169, 254], 16],
|
|
22
|
+
[[172, 16], 12],
|
|
23
|
+
[[192, 0, 0], 24],
|
|
24
|
+
[[192, 0, 2], 24],
|
|
25
|
+
[[192, 168], 16],
|
|
26
|
+
[[198, 18], 15],
|
|
27
|
+
[[198, 51, 100], 24],
|
|
28
|
+
[[203, 0, 113], 24],
|
|
29
|
+
[[224], 4],
|
|
30
|
+
[[240], 4]
|
|
31
|
+
], Be = [
|
|
32
|
+
[[100, 65435], 32],
|
|
33
|
+
[[0, 0, 0, 0, 65535, 0], 96],
|
|
34
|
+
[[256, 0, 0, 0], 64],
|
|
35
|
+
[[256, 0, 0, 1], 64],
|
|
36
|
+
[[8193, 0], 32],
|
|
37
|
+
[[8193, 2, 0], 48],
|
|
38
|
+
[[8193, 3512], 32],
|
|
39
|
+
[[8194], 16],
|
|
40
|
+
[[16383], 20],
|
|
41
|
+
[[24320], 16],
|
|
42
|
+
[[64512], 7],
|
|
43
|
+
[[65152], 10],
|
|
44
|
+
[[65216], 10],
|
|
45
|
+
[[65280], 8]
|
|
46
|
+
], y = new ye();
|
|
47
|
+
for (const [r, t] of De) {
|
|
48
|
+
const e = [...r, 0, 0, 0].slice(0, 4).join(".");
|
|
49
|
+
y.addSubnet(e, t, "ipv4"), y.addSubnet(`::ffff:${e}`, 96 + t, "ipv6"), y.addSubnet(`::${e}`, 96 + t, "ipv6");
|
|
50
|
+
}
|
|
51
|
+
for (const [r, t] of Be)
|
|
52
|
+
y.addSubnet(`${r.map((e) => e.toString(16)).join(":")}::`, t, "ipv6");
|
|
53
|
+
const U = (r) => {
|
|
54
|
+
const t = r.replace(/^\[/u, "").replace(/\]$/u, "").replace(/%.*$/su, ""), e = le(t);
|
|
55
|
+
return e !== 0 && y.check(t, e === 4 ? "ipv4" : "ipv6");
|
|
56
|
+
}, ce = "ERR_LINK_CARD_PRIVATE_ADDRESS", Z = Object.freeze({ timeoutMs: 1e3, tries: 2 }), q = new be({ timeout: Z.timeoutMs, tries: Z.tries }), Q = (r, t) => ({
|
|
57
|
+
error: Object.assign(new Error(`Blocked hostname resolving to a private address: ${r} -> ${t}`), { code: ce })
|
|
58
|
+
}), He = async (r, t) => {
|
|
59
|
+
const e = le(r);
|
|
60
|
+
if (e !== 0)
|
|
61
|
+
return U(r) ? Q(r, r) : { error: null, family: e === 4 ? 4 : 6, addresses: [r] };
|
|
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) => U(R));
|
|
63
|
+
if (i !== void 0) return Q(r, i);
|
|
64
|
+
const [l, ...c] = s;
|
|
65
|
+
if (l !== void 0) return { error: null, family: 4, addresses: [l, ...c] };
|
|
66
|
+
const [f, ...S] = a;
|
|
67
|
+
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" }) };
|
|
68
|
+
}, Ue = (r, t, e) => {
|
|
69
|
+
const n = t.family === 4 || t.family === "IPv4" ? 4 : t.family === 6 || t.family === "IPv6" ? 6 : 0;
|
|
70
|
+
He(r, n).then((o) => {
|
|
71
|
+
if (o.error !== null) {
|
|
72
|
+
e(o.error, "");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const { family: s, addresses: a } = o;
|
|
76
|
+
t.all === !0 ? e(
|
|
77
|
+
null,
|
|
78
|
+
a.map((i) => ({ address: i, family: s }))
|
|
79
|
+
) : e(null, a[0], s);
|
|
80
|
+
});
|
|
81
|
+
}, $e = /* @__PURE__ */ new Set(["127.0.0.1", "0.0.0.0", "[::1]"]), je = [".local", ".internal", ".home.arpa"], j = (r, t) => {
|
|
82
|
+
let e;
|
|
83
|
+
try {
|
|
84
|
+
e = new URL(r);
|
|
85
|
+
} catch {
|
|
86
|
+
return { ok: !1, reason: "forbidden-url", detail: "Invalid URL" };
|
|
87
|
+
}
|
|
88
|
+
if (e.protocol !== "http:" && e.protocol !== "https:")
|
|
89
|
+
return { ok: !1, reason: "forbidden-url", detail: "Only http(s) URLs are allowed" };
|
|
90
|
+
if (e.username !== "" || e.password !== "")
|
|
91
|
+
return { ok: !1, reason: "forbidden-url", detail: "URLs with a user name or password are not allowed" };
|
|
92
|
+
e.hash = "";
|
|
93
|
+
const n = e.hostname.replace(/\.+$/u, "");
|
|
94
|
+
return n === "localhost" || n.endsWith(".localhost") || $e.has(n) ? { ok: !1, reason: "private-network", detail: "Localhost access is not allowed" } : U(n) ? { ok: !1, reason: "private-network", detail: "Private network access is not allowed" } : !(n.startsWith("[") || n.includes(".")) || je.some((s) => n.endsWith(s)) ? { ok: !1, reason: "private-network", detail: "Internal domain access is not allowed" } : { ok: !0, href: e.href };
|
|
95
|
+
}, ue = (r) => {
|
|
96
|
+
let t;
|
|
97
|
+
try {
|
|
98
|
+
t = new URL(r);
|
|
99
|
+
} catch {
|
|
100
|
+
return "(unparsable URL)";
|
|
101
|
+
}
|
|
102
|
+
return t.protocol !== "http:" && t.protocol !== "https:" ? `(a ${t.protocol} URL)` : (t.username = "", t.password = "", t.href);
|
|
103
|
+
}, de = 1024, ze = /^[\t\n\f\r ]$/u, w = (r) => ze.test(r), B = (r) => r.replace(/[A-Z]/gu, (t) => t.toLowerCase()), $ = (r) => {
|
|
104
|
+
try {
|
|
105
|
+
return new TextDecoder(r).encoding;
|
|
106
|
+
} catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}, Je = (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, Ke = (r) => {
|
|
110
|
+
for (const t of r.split(";").slice(1)) {
|
|
111
|
+
const e = t.indexOf("=");
|
|
112
|
+
if (e !== -1 && t.slice(0, e).trim().toLowerCase() === "charset")
|
|
113
|
+
return t.slice(e + 1).trim().replace(/^"(.*)"$/su, "$1");
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}, Fe = (r) => {
|
|
117
|
+
let t = 0;
|
|
118
|
+
for (; ; ) {
|
|
119
|
+
const e = r.indexOf("charset", t);
|
|
120
|
+
if (e === -1) return null;
|
|
121
|
+
let n = e + 7;
|
|
122
|
+
for (; w(r.charAt(n)); ) n += 1;
|
|
123
|
+
if (r.charAt(n) !== "=") {
|
|
124
|
+
t = n;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
for (n += 1; w(r.charAt(n)); ) n += 1;
|
|
128
|
+
const o = r.charAt(n);
|
|
129
|
+
if (o === '"' || o === "'") {
|
|
130
|
+
const a = r.indexOf(o, n + 1);
|
|
131
|
+
return a === -1 ? null : r.slice(n + 1, a);
|
|
132
|
+
}
|
|
133
|
+
const s = r.slice(n).search(/[\t\n\f\r ;]/u);
|
|
134
|
+
return s === -1 ? r.slice(n) : r.slice(n, n + s);
|
|
135
|
+
}
|
|
136
|
+
}, fe = (r, t) => {
|
|
137
|
+
let e = t;
|
|
138
|
+
for (; w(r.charAt(e)) || r.charAt(e) === "/"; ) e += 1;
|
|
139
|
+
if (r.charAt(e) === ">" || e >= r.length) return { attribute: null, end: e };
|
|
140
|
+
let n = "";
|
|
141
|
+
for (; ; ) {
|
|
142
|
+
const a = r.charAt(e);
|
|
143
|
+
if (a === "") return { attribute: null, end: e };
|
|
144
|
+
if (a === "=" && n !== "") break;
|
|
145
|
+
if (w(a)) {
|
|
146
|
+
for (; w(r.charAt(e)); ) e += 1;
|
|
147
|
+
if (r.charAt(e) !== "=") return { attribute: { name: n, value: "" }, end: e };
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
if (a === "/" || a === ">") return { attribute: { name: n, value: "" }, end: e };
|
|
151
|
+
n += B(a), e += 1;
|
|
152
|
+
}
|
|
153
|
+
for (e += 1; w(r.charAt(e)); ) e += 1;
|
|
154
|
+
const o = r.charAt(e);
|
|
155
|
+
if (o === '"' || o === "'") {
|
|
156
|
+
const a = r.indexOf(o, e + 1);
|
|
157
|
+
return a === -1 ? { attribute: null, end: r.length } : { attribute: { name: n, value: B(r.slice(e + 1, a)) }, end: a + 1 };
|
|
158
|
+
}
|
|
159
|
+
if (o === ">") return { attribute: { name: n, value: "" }, end: e };
|
|
160
|
+
const s = r.slice(e).search(/[\t\n\f\r >]/u);
|
|
161
|
+
return s === -1 ? { attribute: null, end: r.length } : { attribute: { name: n, value: B(r.slice(e, e + s)) }, end: e + s };
|
|
162
|
+
}, Ge = (r, t) => {
|
|
163
|
+
const e = /* @__PURE__ */ new Set();
|
|
164
|
+
let n = !1, o = null, s = null, a = t;
|
|
165
|
+
for (; ; ) {
|
|
166
|
+
const { attribute: i, end: l } = fe(r, a);
|
|
167
|
+
if (a = l, i === null) break;
|
|
168
|
+
if (!e.has(i.name))
|
|
169
|
+
if (e.add(i.name), i.name === "http-equiv")
|
|
170
|
+
n = i.value === "content-type";
|
|
171
|
+
else if (i.name === "content") {
|
|
172
|
+
const c = Fe(i.value), f = c === null ? null : $(c);
|
|
173
|
+
f !== null && s === null && (s = f, o = !0);
|
|
174
|
+
} else i.name === "charset" && (s = $(i.value) ?? !1, o = !1);
|
|
175
|
+
}
|
|
176
|
+
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
|
+
}, Xe = (r) => {
|
|
178
|
+
const t = Array.from(r.subarray(0, de), (n) => String.fromCharCode(n)).join("");
|
|
179
|
+
let e = 0;
|
|
180
|
+
for (; e < t.length; )
|
|
181
|
+
if (t.startsWith("<!--", e)) {
|
|
182
|
+
const n = t.indexOf("-->", e + 2);
|
|
183
|
+
if (n === -1) return null;
|
|
184
|
+
e = n + 3;
|
|
185
|
+
} else if (/^<meta[\t\n\f\r /]$/iu.test(t.slice(e, e + 6))) {
|
|
186
|
+
const { encoding: n, end: o } = Ge(t, e + 5);
|
|
187
|
+
if (n !== null) return n;
|
|
188
|
+
e = o + 1;
|
|
189
|
+
} else if (/^<\/?[A-Za-z]/u.test(t.slice(e, e + 3))) {
|
|
190
|
+
let n = e + 1;
|
|
191
|
+
for (; n < t.length && !w(t.charAt(n)) && t.charAt(n) !== ">"; ) n += 1;
|
|
192
|
+
for (; ; ) {
|
|
193
|
+
const o = fe(t, n);
|
|
194
|
+
if (n = o.end, o.attribute === null) break;
|
|
195
|
+
}
|
|
196
|
+
e = n + 1;
|
|
197
|
+
} else if (/^<[!/?]$/u.test(t.slice(e, e + 2))) {
|
|
198
|
+
const n = t.indexOf(">", e + 1);
|
|
199
|
+
if (n === -1) return null;
|
|
200
|
+
e = n + 1;
|
|
201
|
+
} else
|
|
202
|
+
e += 1;
|
|
203
|
+
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
|
+
}, We = (r, t) => {
|
|
210
|
+
const e = new Uint8Array(t);
|
|
211
|
+
let n = 0;
|
|
212
|
+
for (const o of r)
|
|
213
|
+
e.set(o, n), n += o.byteLength;
|
|
214
|
+
return e;
|
|
215
|
+
}, Ye = (r) => {
|
|
216
|
+
const t = [];
|
|
217
|
+
let e = 0, n = null;
|
|
218
|
+
const o = () => {
|
|
219
|
+
const s = We(t, e);
|
|
220
|
+
t.length = 0;
|
|
221
|
+
const a = new TextDecoder(Ve(s, r));
|
|
222
|
+
return n = a, { started: a, text: a.decode(s, { stream: !0 }) };
|
|
223
|
+
};
|
|
224
|
+
return {
|
|
225
|
+
write: (s) => n !== null ? n.decode(s, { stream: !0 }) : (t.push(s), e += s.byteLength, e < de ? "" : o().text),
|
|
226
|
+
end: () => {
|
|
227
|
+
if (n !== null) return n.decode();
|
|
228
|
+
const { started: s, text: a } = o();
|
|
229
|
+
return a + s.decode();
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
}, Ze = (r, t, e) => {
|
|
233
|
+
const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
234
|
+
return (s) => {
|
|
235
|
+
const a = n.get(s);
|
|
236
|
+
if (a !== void 0 && a.expireAt > e()) return Promise.resolve(a.value);
|
|
237
|
+
const i = o.get(s);
|
|
238
|
+
if (i !== void 0) return i;
|
|
239
|
+
const l = r(s).then((c) => (!n.has(s) && n.size >= t.maxEntries && n.delete(n.keys().next().value), n.set(s, { value: c, expireAt: e() + t.ttlMsOf(c) }), c)).finally(() => {
|
|
240
|
+
o.delete(s);
|
|
241
|
+
});
|
|
242
|
+
return o.set(s, l), l;
|
|
243
|
+
};
|
|
244
|
+
}, qe = 65536, Qe = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]), et = /* @__PURE__ */ new Set(["text/html", "application/xhtml+xml"]), tt = /* @__PURE__ */ new Set(["ERR_IP_BLOCKED", ce]), me = Object.freeze({ timeoutMs: 5e3, maxRedirects: 5, maxBodyBytes: 8 * 1024 * 1024 }), rt = Object.freeze({ lookup: Ue, blockList: y }), nt = (r, t) => {
|
|
245
|
+
const e = Y({ lookup: r.lookup, blockList: r.blockList, timeout: t }), n = Y({ timeout: t });
|
|
246
|
+
return (o, s) => {
|
|
247
|
+
if (o.protocol !== "https:") {
|
|
248
|
+
e(o, s);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const a = Te({ host: o.hostname, port: Number(o.port === "" ? 443 : o.port), lookup: r.lookup, blockList: r.blockList }), i = (l) => {
|
|
252
|
+
a.destroy(), s(l, null);
|
|
253
|
+
};
|
|
254
|
+
a.setTimeout(t, () => i(Object.assign(new Error(`Connect timeout: ${o.hostname}`), { code: "UND_ERR_CONNECT_TIMEOUT" }))), a.once("error", i), a.once("connect", () => {
|
|
255
|
+
a.setTimeout(0), a.removeListener("error", i), n({ ...o, httpSocket: a }, s);
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
}, ot = (r) => new Se({
|
|
259
|
+
maxHeaderSize: qe,
|
|
260
|
+
connect: nt(rt, me.timeoutMs)
|
|
261
|
+
}), H = async (r) => {
|
|
262
|
+
r.body !== null && await Promise.allSettled([r.body.cancel()]);
|
|
263
|
+
}, at = (r) => r !== null && et.has(r.split(";", 1)[0].trim().toLowerCase()), st = (r) => {
|
|
264
|
+
const t = [r];
|
|
265
|
+
for (let e = 0; e < 16 && t.length > 0; e += 1) {
|
|
266
|
+
const n = t.shift();
|
|
267
|
+
if (!(n instanceof Error)) continue;
|
|
268
|
+
const o = n.code;
|
|
269
|
+
if (typeof o == "string" && tt.has(o)) return n.message;
|
|
270
|
+
t.push(n.cause, ...n instanceof AggregateError ? n.errors : []);
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
}, pe = (r, t) => {
|
|
274
|
+
const e = st(r);
|
|
275
|
+
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
|
+
}, it = () => new Promise((r) => {
|
|
277
|
+
setImmediate(r);
|
|
278
|
+
}), lt = async (r, t, e, n) => {
|
|
279
|
+
if (r.body === null) return { ok: !0, value: t.end() };
|
|
280
|
+
const o = r.body.getReader();
|
|
281
|
+
let s = 0;
|
|
282
|
+
for (; ; ) {
|
|
283
|
+
let a;
|
|
284
|
+
try {
|
|
285
|
+
a = await o.read();
|
|
286
|
+
} catch (f) {
|
|
287
|
+
return pe(f, n);
|
|
288
|
+
}
|
|
289
|
+
if (a.done) break;
|
|
290
|
+
const i = e - s, l = a.value.byteLength > i, c = l ? a.value.subarray(0, i) : a.value;
|
|
291
|
+
if (s += c.byteLength, !t.write(c)) {
|
|
292
|
+
await Promise.allSettled([o.cancel()]);
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
if (l) {
|
|
296
|
+
await Promise.allSettled([o.cancel()]), h.warn("Link-card page body exceeds the size limit; parsing only its first bytes:", n, e);
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
await it();
|
|
300
|
+
}
|
|
301
|
+
return { ok: !0, value: t.end() };
|
|
302
|
+
}, ct = async (r, t, e, n) => {
|
|
303
|
+
let o = r;
|
|
304
|
+
for (let s = 0; s <= t.limits.maxRedirects; s += 1) {
|
|
305
|
+
let a;
|
|
306
|
+
try {
|
|
307
|
+
a = await ve(o, { signal: n, redirect: "manual", dispatcher: t.agent });
|
|
308
|
+
} catch (f) {
|
|
309
|
+
return pe(f, o);
|
|
310
|
+
}
|
|
311
|
+
const i = Qe.has(a.status) ? a.headers.get("location")?.trim() ?? "" : "";
|
|
312
|
+
if (i === "") {
|
|
313
|
+
if (!a.ok)
|
|
314
|
+
return await H(a), { ok: !1, reason: "unreachable" };
|
|
315
|
+
const f = a.headers.get("content-type");
|
|
316
|
+
return at(f) ? lt(a, e({ url: o, contentType: f }), t.limits.maxBodyBytes, o) : (await H(a), { ok: !1, reason: "not-html" });
|
|
317
|
+
}
|
|
318
|
+
await H(a);
|
|
319
|
+
let l;
|
|
320
|
+
try {
|
|
321
|
+
l = new URL(i, o);
|
|
322
|
+
} catch {
|
|
323
|
+
return h.error("Blocked redirect to an unparsable Location from:", o), { ok: !1, reason: "unreachable" };
|
|
324
|
+
}
|
|
325
|
+
const c = j(l.href);
|
|
326
|
+
if (!c.ok)
|
|
327
|
+
return h.info("Refused link-card redirect:", ue(l), `(${c.reason}: ${c.detail})`), { ok: !1, reason: c.reason };
|
|
328
|
+
o = c.href;
|
|
329
|
+
}
|
|
330
|
+
return h.error("Too many redirects while fetching link-card metadata:", r), { ok: !1, reason: "unreachable" };
|
|
331
|
+
}, ut = (r, t, e) => {
|
|
332
|
+
const n = new AbortController(), o = setTimeout(() => n.abort(), t.limits.timeoutMs);
|
|
333
|
+
return ct(r, t, e, n.signal).finally(() => {
|
|
334
|
+
clearTimeout(o);
|
|
335
|
+
});
|
|
336
|
+
}, dt = 256, ft = 4096, mt = 64, pt = /* @__PURE__ */ new Set(["html", "head", "title", "meta", "link", "base", "basefont", "bgsound", "noframes", "script", "style", "template", "noscript"]), ht = /* @__PURE__ */ new Set(["title", "script", "style"]), wt = /* @__PURE__ */ new Set(["noscript", "template", "noframes"]), gt = (r) => r?.toLowerCase().split(/[\t\n\f\r ]+/u).includes("icon") === !0, Et = (r, t) => {
|
|
337
|
+
if (r === void 0) return t;
|
|
338
|
+
let e;
|
|
339
|
+
try {
|
|
340
|
+
e = new URL(r, t);
|
|
341
|
+
} catch {
|
|
342
|
+
return t;
|
|
343
|
+
}
|
|
344
|
+
return (e.protocol === "http:" || e.protocol === "https:") && e.href.length <= se ? e.href : t;
|
|
345
|
+
}, ee = (r, t, e) => {
|
|
346
|
+
const n = r?.trim();
|
|
347
|
+
if (n === void 0 || n === "") return;
|
|
348
|
+
let o;
|
|
349
|
+
try {
|
|
350
|
+
o = new URL(n, t);
|
|
351
|
+
} catch {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
return o.href.length <= se && j(o.href).ok ? o.href : void 0;
|
|
355
|
+
}, kt = (r, t) => {
|
|
356
|
+
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
|
+
const N = () => {
|
|
358
|
+
e = !0, D.pause();
|
|
359
|
+
}, D = new Ae(
|
|
360
|
+
{
|
|
361
|
+
onopentagname(u) {
|
|
362
|
+
n += 1, o += 1, s = 0, (n > dt || o > ft || a === null && !pt.has(u)) && N();
|
|
363
|
+
},
|
|
364
|
+
onattribute() {
|
|
365
|
+
s += 1, s > mt && N();
|
|
366
|
+
},
|
|
367
|
+
onopentag(u, m) {
|
|
368
|
+
if (!(e || a !== null)) {
|
|
369
|
+
if (wt.has(u)) {
|
|
370
|
+
a = n;
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
if (u === "meta") {
|
|
374
|
+
const p = m.content;
|
|
375
|
+
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);
|
|
376
|
+
} else u === "link" && !K && gt(m.rel) ? (K = !0, J = m.href) : u === "base" && !G && Object.hasOwn(m, "href") && (G = !0, F = m.href);
|
|
377
|
+
ht.has(u) && (i = u, u === "title" && c === void 0 && (l = ""));
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
ontext(u) {
|
|
381
|
+
a === null && (l !== null ? l += u : i === null && /[^\t\n\f\r ]/u.test(u) && N());
|
|
382
|
+
},
|
|
383
|
+
onclosetag(u) {
|
|
384
|
+
if (!e) {
|
|
385
|
+
if (n -= 1, a !== null) {
|
|
386
|
+
n < a && (a = null);
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
u === i && (i = null, l !== null && (c = l, l = null));
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
{ decodeEntities: !0 }
|
|
394
|
+
);
|
|
395
|
+
return {
|
|
396
|
+
write: (u) => (e || D.write(u), !e),
|
|
397
|
+
end: () => {
|
|
398
|
+
e || D.end();
|
|
399
|
+
const u = L(f, O.title) ?? L(c, O.title), m = L(S, O.description), p = L(R, O.siteName), X = Et(F, r), V = ee(z, X), W = ee(J, X);
|
|
400
|
+
return {
|
|
401
|
+
...u === null ? {} : { title: u },
|
|
402
|
+
...m === null ? {} : { description: m },
|
|
403
|
+
...p === null ? {} : { site_name: p },
|
|
404
|
+
...V === void 0 ? {} : { image: V },
|
|
405
|
+
...W === void 0 ? {} : { icon: W }
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
}, bt = /* @__PURE__ */ new Set(["authorize"]), yt = "private, max-age=1800", Tt = 3600 * 1e3, he = Object.freeze({ "private-network": 1800, "forbidden-url": 1800, unreachable: 300, "not-html": 300 }), St = 1e3, P = "no-store", v = (r, t, e, n, o = {}) => new Response(r.method === "HEAD" ? null : JSON.stringify(e), {
|
|
410
|
+
status: t,
|
|
411
|
+
headers: { "Content-Type": "application/json; charset=utf-8", "Cache-Control": n, "X-Content-Type-Options": "nosniff", ...o }
|
|
412
|
+
}), te = (r) => new Response(null, {
|
|
413
|
+
status: 204,
|
|
414
|
+
headers: { "Cache-Control": `private, max-age=${he[r]}`, "X-Content-Type-Options": "nosniff", [ke]: r }
|
|
415
|
+
}), vt = (r) => {
|
|
416
|
+
if (typeof r != "object" || r === null)
|
|
417
|
+
throw new TypeError("createLinkCardHandler: options must be an object with an authorize function");
|
|
418
|
+
if (typeof r.authorize != "function")
|
|
419
|
+
throw new TypeError("createLinkCardHandler: options.authorize must be a function (pass () => true to serve everyone)");
|
|
420
|
+
const t = Object.keys(r).filter((e) => !bt.has(e));
|
|
421
|
+
if (t.length > 0)
|
|
422
|
+
throw new TypeError(`createLinkCardHandler: unknown option(s): ${t.join(", ")}`);
|
|
423
|
+
}, At = (r) => (t) => {
|
|
424
|
+
const e = Ye(t.contentType), n = kt(t.url);
|
|
425
|
+
return {
|
|
426
|
+
write: (o) => n.write(e.write(o)),
|
|
427
|
+
end: () => (n.write(e.end()), n.end())
|
|
428
|
+
};
|
|
429
|
+
}, _t = (r, t) => {
|
|
430
|
+
vt(r);
|
|
431
|
+
const { authorize: e } = r, n = ot(), o = Ze(
|
|
432
|
+
(s) => ut(s, { agent: n, scope: t, limits: me }, At()),
|
|
433
|
+
{ maxEntries: St, ttlMsOf: (s) => s.ok ? Tt : he[s.reason] * 1e3 },
|
|
434
|
+
Date.now
|
|
435
|
+
);
|
|
436
|
+
return async (s) => {
|
|
437
|
+
if (s.method !== "GET" && s.method !== "HEAD")
|
|
438
|
+
return v(s, 405, { error: "Method Not Allowed" }, P, { Allow: "GET, HEAD" });
|
|
439
|
+
if (await e(s) !== !0)
|
|
440
|
+
return v(s, 401, { error: "Unauthorized" }, P);
|
|
441
|
+
const a = new URL(s.url).searchParams.get("url");
|
|
442
|
+
if (a === null || a === "")
|
|
443
|
+
return v(s, 400, { error: "Missing 'url' parameter" }, P);
|
|
444
|
+
const i = j(a);
|
|
445
|
+
if (!i.ok)
|
|
446
|
+
return h.info("Refused link-card URL:", ue(a), `(${i.reason}: ${i.detail})`), te(i.reason);
|
|
447
|
+
let l;
|
|
448
|
+
try {
|
|
449
|
+
l = await o(i.href);
|
|
450
|
+
} catch (c) {
|
|
451
|
+
return h.error("Unexpected error while reading link-card metadata:", i.href, c), v(s, 500, { error: "Internal Server Error" }, P);
|
|
452
|
+
}
|
|
453
|
+
return l.ok ? v(s, 200, l.value, yt) : te(l.reason);
|
|
454
|
+
};
|
|
455
|
+
}, Yt = (r) => _t(r, "public");
|
|
456
|
+
class E extends x {
|
|
11
457
|
/**
|
|
12
458
|
* @generated from field: string markdown_text = 1;
|
|
13
459
|
*/
|
|
@@ -103,12 +549,12 @@ class i extends h {
|
|
|
103
549
|
* @generated from field: markdown.v1.DenyRules deny = 13;
|
|
104
550
|
*/
|
|
105
551
|
deny;
|
|
106
|
-
constructor(
|
|
107
|
-
super(),
|
|
552
|
+
constructor(t) {
|
|
553
|
+
super(), d.util.initPartial(t, this);
|
|
108
554
|
}
|
|
109
|
-
static runtime =
|
|
555
|
+
static runtime = d;
|
|
110
556
|
static typeName = "markdown.v1.ConvertRequest";
|
|
111
|
-
static fields =
|
|
557
|
+
static fields = d.util.newFieldList(() => [
|
|
112
558
|
{
|
|
113
559
|
no: 1,
|
|
114
560
|
name: "markdown_text",
|
|
@@ -151,46 +597,46 @@ class i extends h {
|
|
|
151
597
|
/* ScalarType.BOOL */
|
|
152
598
|
},
|
|
153
599
|
{ no: 12, name: "max_html_bytes", kind: "scalar", T: 13, opt: !0 },
|
|
154
|
-
{ no: 13, name: "deny", kind: "message", T:
|
|
600
|
+
{ no: 13, name: "deny", kind: "message", T: g }
|
|
155
601
|
]);
|
|
156
|
-
static fromBinary(
|
|
157
|
-
return new
|
|
602
|
+
static fromBinary(t, e) {
|
|
603
|
+
return new E().fromBinary(t, e);
|
|
158
604
|
}
|
|
159
|
-
static fromJson(
|
|
160
|
-
return new
|
|
605
|
+
static fromJson(t, e) {
|
|
606
|
+
return new E().fromJson(t, e);
|
|
161
607
|
}
|
|
162
|
-
static fromJsonString(
|
|
163
|
-
return new
|
|
608
|
+
static fromJsonString(t, e) {
|
|
609
|
+
return new E().fromJsonString(t, e);
|
|
164
610
|
}
|
|
165
|
-
static equals(
|
|
166
|
-
return
|
|
611
|
+
static equals(t, e) {
|
|
612
|
+
return d.util.equals(E, t, e);
|
|
167
613
|
}
|
|
168
614
|
}
|
|
169
|
-
class
|
|
615
|
+
class g extends x {
|
|
170
616
|
/**
|
|
171
617
|
* @generated from field: repeated string segment_patterns = 1;
|
|
172
618
|
*/
|
|
173
619
|
segmentPatterns = [];
|
|
174
|
-
constructor(
|
|
175
|
-
super(),
|
|
620
|
+
constructor(t) {
|
|
621
|
+
super(), d.util.initPartial(t, this);
|
|
176
622
|
}
|
|
177
|
-
static runtime =
|
|
623
|
+
static runtime = d;
|
|
178
624
|
static typeName = "markdown.v1.DenyRules";
|
|
179
|
-
static fields =
|
|
180
|
-
static fromBinary(
|
|
181
|
-
return new
|
|
625
|
+
static fields = d.util.newFieldList(() => [{ no: 1, name: "segment_patterns", kind: "scalar", T: 9, repeated: !0 }]);
|
|
626
|
+
static fromBinary(t, e) {
|
|
627
|
+
return new g().fromBinary(t, e);
|
|
182
628
|
}
|
|
183
|
-
static fromJson(
|
|
184
|
-
return new
|
|
629
|
+
static fromJson(t, e) {
|
|
630
|
+
return new g().fromJson(t, e);
|
|
185
631
|
}
|
|
186
|
-
static fromJsonString(
|
|
187
|
-
return new
|
|
632
|
+
static fromJsonString(t, e) {
|
|
633
|
+
return new g().fromJsonString(t, e);
|
|
188
634
|
}
|
|
189
|
-
static equals(
|
|
190
|
-
return
|
|
635
|
+
static equals(t, e) {
|
|
636
|
+
return d.util.equals(g, t, e);
|
|
191
637
|
}
|
|
192
638
|
}
|
|
193
|
-
class
|
|
639
|
+
class k extends x {
|
|
194
640
|
/**
|
|
195
641
|
* @generated from field: string html_content = 1;
|
|
196
642
|
*/
|
|
@@ -199,12 +645,12 @@ class c extends h {
|
|
|
199
645
|
* @generated from field: repeated markdown.v1.Heading headings = 2;
|
|
200
646
|
*/
|
|
201
647
|
headings = [];
|
|
202
|
-
constructor(
|
|
203
|
-
super(),
|
|
648
|
+
constructor(t) {
|
|
649
|
+
super(), d.util.initPartial(t, this);
|
|
204
650
|
}
|
|
205
|
-
static runtime =
|
|
651
|
+
static runtime = d;
|
|
206
652
|
static typeName = "markdown.v1.ConvertResponse";
|
|
207
|
-
static fields =
|
|
653
|
+
static fields = d.util.newFieldList(() => [
|
|
208
654
|
{
|
|
209
655
|
no: 1,
|
|
210
656
|
name: "html_content",
|
|
@@ -212,22 +658,22 @@ class c extends h {
|
|
|
212
658
|
T: 9
|
|
213
659
|
/* ScalarType.STRING */
|
|
214
660
|
},
|
|
215
|
-
{ no: 2, name: "headings", kind: "message", T:
|
|
661
|
+
{ no: 2, name: "headings", kind: "message", T: b, repeated: !0 }
|
|
216
662
|
]);
|
|
217
|
-
static fromBinary(
|
|
218
|
-
return new
|
|
663
|
+
static fromBinary(t, e) {
|
|
664
|
+
return new k().fromBinary(t, e);
|
|
219
665
|
}
|
|
220
|
-
static fromJson(
|
|
221
|
-
return new
|
|
666
|
+
static fromJson(t, e) {
|
|
667
|
+
return new k().fromJson(t, e);
|
|
222
668
|
}
|
|
223
|
-
static fromJsonString(
|
|
224
|
-
return new
|
|
669
|
+
static fromJsonString(t, e) {
|
|
670
|
+
return new k().fromJsonString(t, e);
|
|
225
671
|
}
|
|
226
|
-
static equals(
|
|
227
|
-
return
|
|
672
|
+
static equals(t, e) {
|
|
673
|
+
return d.util.equals(k, t, e);
|
|
228
674
|
}
|
|
229
675
|
}
|
|
230
|
-
class
|
|
676
|
+
class b extends x {
|
|
231
677
|
/**
|
|
232
678
|
* @generated from field: string text = 1;
|
|
233
679
|
*/
|
|
@@ -240,12 +686,12 @@ class m extends h {
|
|
|
240
686
|
* @generated from field: string id = 3;
|
|
241
687
|
*/
|
|
242
688
|
id = "";
|
|
243
|
-
constructor(
|
|
244
|
-
super(),
|
|
689
|
+
constructor(t) {
|
|
690
|
+
super(), d.util.initPartial(t, this);
|
|
245
691
|
}
|
|
246
|
-
static runtime =
|
|
692
|
+
static runtime = d;
|
|
247
693
|
static typeName = "markdown.v1.Heading";
|
|
248
|
-
static fields =
|
|
694
|
+
static fields = d.util.newFieldList(() => [
|
|
249
695
|
{
|
|
250
696
|
no: 1,
|
|
251
697
|
name: "text",
|
|
@@ -268,20 +714,20 @@ class m extends h {
|
|
|
268
714
|
/* ScalarType.STRING */
|
|
269
715
|
}
|
|
270
716
|
]);
|
|
271
|
-
static fromBinary(
|
|
272
|
-
return new
|
|
717
|
+
static fromBinary(t, e) {
|
|
718
|
+
return new b().fromBinary(t, e);
|
|
273
719
|
}
|
|
274
|
-
static fromJson(
|
|
275
|
-
return new
|
|
720
|
+
static fromJson(t, e) {
|
|
721
|
+
return new b().fromJson(t, e);
|
|
276
722
|
}
|
|
277
|
-
static fromJsonString(
|
|
278
|
-
return new
|
|
723
|
+
static fromJsonString(t, e) {
|
|
724
|
+
return new b().fromJsonString(t, e);
|
|
279
725
|
}
|
|
280
|
-
static equals(
|
|
281
|
-
return
|
|
726
|
+
static equals(t, e) {
|
|
727
|
+
return d.util.equals(b, t, e);
|
|
282
728
|
}
|
|
283
729
|
}
|
|
284
|
-
const
|
|
730
|
+
const Rt = {
|
|
285
731
|
typeName: "markdown.v1.MarkdownService",
|
|
286
732
|
methods: {
|
|
287
733
|
/**
|
|
@@ -289,146 +735,147 @@ const C = {
|
|
|
289
735
|
*/
|
|
290
736
|
convert: {
|
|
291
737
|
name: "Convert",
|
|
292
|
-
I:
|
|
293
|
-
O:
|
|
294
|
-
kind:
|
|
738
|
+
I: E,
|
|
739
|
+
O: k,
|
|
740
|
+
kind: Ne.Unary
|
|
295
741
|
}
|
|
296
742
|
}
|
|
297
|
-
},
|
|
298
|
-
createConnection: () =>
|
|
299
|
-
}),
|
|
300
|
-
class
|
|
743
|
+
}, T = process.env.MARKDOWN_SOCKET_PATH || "/tmp/markdown.sock", Lt = new Ie("http://localhost", void 0, {
|
|
744
|
+
createConnection: () => ie.connect(T)
|
|
745
|
+
}), we = 64 * 1024, Ot = 4294967295, re = Math.floor((Ot - we) / 2);
|
|
746
|
+
class Pt extends Error {
|
|
301
747
|
/**
|
|
302
748
|
* Wraps the service's or the transport's resource-exhausted error.
|
|
303
749
|
* サービスか転送の resource exhausted のエラーを包む処理。
|
|
304
750
|
*
|
|
305
751
|
* @param cause - The connect error. connect のエラー。
|
|
306
752
|
*/
|
|
307
|
-
constructor(
|
|
308
|
-
super(
|
|
753
|
+
constructor(t) {
|
|
754
|
+
super(t.rawMessage, { cause: t }), this.name = "MarkdownResourceExhaustedError";
|
|
309
755
|
}
|
|
310
756
|
}
|
|
311
|
-
const
|
|
757
|
+
const ne = () => {
|
|
312
758
|
try {
|
|
313
|
-
return
|
|
759
|
+
return C.dirname(Oe(import.meta.url));
|
|
314
760
|
} catch {
|
|
315
761
|
return __dirname;
|
|
316
762
|
}
|
|
317
|
-
},
|
|
763
|
+
}, ge = () => `@aiquants/markdown-${process.platform}-${process.arch}`, oe = () => process.platform === "win32" ? "bin/markdown-api.exe" : "bin/markdown-api", Mt = () => {
|
|
318
764
|
const r = process.env.MARKDOWN_API_BINARY;
|
|
319
|
-
if (r &&
|
|
765
|
+
if (r && M(r))
|
|
320
766
|
return r;
|
|
321
767
|
try {
|
|
322
|
-
const
|
|
323
|
-
if (
|
|
324
|
-
return
|
|
768
|
+
const e = Le(C.join(ne(), "index.js")).resolve(`${ge()}/${oe()}`);
|
|
769
|
+
if (M(e))
|
|
770
|
+
return e;
|
|
325
771
|
} catch {
|
|
326
772
|
}
|
|
327
|
-
const
|
|
328
|
-
return
|
|
329
|
-
},
|
|
773
|
+
const t = C.join(ne(), "..", "..", "go", "markdown-api", "dist", C.basename(oe()));
|
|
774
|
+
return M(t) ? t : void 0;
|
|
775
|
+
}, Ct = () => [
|
|
330
776
|
`markdown-api binary not found for ${process.platform}-${process.arch}.`,
|
|
331
|
-
`Expected the optional dependency ${
|
|
777
|
+
`Expected the optional dependency ${ge()} to be installed.`,
|
|
332
778
|
"If your platform is unsupported, build the service yourself",
|
|
333
779
|
"(https://github.com/fehde-k/aiquants/tree/main/packages/go/markdown-api)",
|
|
334
780
|
"and point MARKDOWN_API_BINARY at it."
|
|
335
|
-
].join(" "),
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}),
|
|
340
|
-
}),
|
|
341
|
-
const
|
|
342
|
-
for (; Date.now() -
|
|
343
|
-
if (await
|
|
344
|
-
await new Promise((
|
|
781
|
+
].join(" "), Ee = () => new Promise((r) => {
|
|
782
|
+
const t = ie.connect(T);
|
|
783
|
+
t.on("connect", () => {
|
|
784
|
+
t.destroy(), r(!0);
|
|
785
|
+
}), t.on("error", () => r(!1));
|
|
786
|
+
}), ae = async (r) => {
|
|
787
|
+
const t = Date.now();
|
|
788
|
+
for (; Date.now() - t < r; ) {
|
|
789
|
+
if (await Ee()) return !0;
|
|
790
|
+
await new Promise((e) => setTimeout(e, 100));
|
|
345
791
|
}
|
|
346
792
|
return !1;
|
|
347
793
|
};
|
|
348
|
-
let
|
|
349
|
-
const
|
|
794
|
+
let A = null, _ = null;
|
|
795
|
+
const It = 2e3, xt = () => {
|
|
350
796
|
const r = Number(process.env.MARKDOWN_API_STARTUP_TIMEOUT_MS);
|
|
351
797
|
return Number.isFinite(r) && r > 0 ? r : 1e4;
|
|
352
798
|
};
|
|
353
|
-
let
|
|
354
|
-
const
|
|
355
|
-
if (await
|
|
356
|
-
if (
|
|
357
|
-
|
|
358
|
-
const
|
|
359
|
-
if (!
|
|
360
|
-
return await
|
|
361
|
-
|
|
799
|
+
let I = null;
|
|
800
|
+
const Nt = async () => {
|
|
801
|
+
if (await Ee()) return !0;
|
|
802
|
+
if (_) return _;
|
|
803
|
+
_ = (async () => {
|
|
804
|
+
const t = Mt();
|
|
805
|
+
if (!t)
|
|
806
|
+
return await ae(It) ? !0 : (I = Ct(), !1);
|
|
807
|
+
I = null;
|
|
362
808
|
try {
|
|
363
|
-
|
|
809
|
+
M(T) && Re(T);
|
|
364
810
|
} catch {
|
|
365
811
|
}
|
|
366
812
|
try {
|
|
367
|
-
|
|
368
|
-
const
|
|
369
|
-
if (
|
|
813
|
+
A = _e(t, [], { stdio: "ignore" });
|
|
814
|
+
const e = () => {
|
|
815
|
+
if (A) {
|
|
370
816
|
try {
|
|
371
|
-
|
|
817
|
+
A.kill("SIGTERM");
|
|
372
818
|
} catch {
|
|
373
819
|
}
|
|
374
|
-
|
|
820
|
+
A = null;
|
|
375
821
|
}
|
|
376
822
|
};
|
|
377
|
-
return process.once("exit",
|
|
378
|
-
} catch (
|
|
379
|
-
return console.error("Failed to spawn markdown-api Go server:",
|
|
823
|
+
return process.once("exit", e), await ae(xt()) ? !0 : (console.error("markdown-api Go server did not become ready on socket:", T), e(), process.removeListener("exit", e), !1);
|
|
824
|
+
} catch (e) {
|
|
825
|
+
return console.error("Failed to spawn markdown-api Go server:", e), A = null, !1;
|
|
380
826
|
}
|
|
381
827
|
})();
|
|
382
|
-
const r = await
|
|
383
|
-
return r || (
|
|
384
|
-
},
|
|
828
|
+
const r = await _;
|
|
829
|
+
return r || (_ = null), r;
|
|
830
|
+
}, Dt = (r) => {
|
|
385
831
|
if (!Array.isArray(r.deniedPathSegments))
|
|
386
832
|
throw new TypeError("parseMarkdown: deniedPathSegments must be an array of path segment patterns (an empty array denies nothing)");
|
|
387
|
-
if (!Number.isSafeInteger(r.maxHtmlBytes) || r.maxHtmlBytes <= 0 || r.maxHtmlBytes >
|
|
388
|
-
throw new RangeError(`parseMarkdown: maxHtmlBytes must be an integer from 1 to ${
|
|
833
|
+
if (!Number.isSafeInteger(r.maxHtmlBytes) || r.maxHtmlBytes <= 0 || r.maxHtmlBytes > re)
|
|
834
|
+
throw new RangeError(`parseMarkdown: maxHtmlBytes must be an integer from 1 to ${re}, got ${r.maxHtmlBytes}`);
|
|
389
835
|
if (r.timeoutMs !== void 0 && (!Number.isSafeInteger(r.timeoutMs) || r.timeoutMs <= 0))
|
|
390
836
|
throw new RangeError(`parseMarkdown: timeoutMs must be a positive integer, got ${r.timeoutMs}`);
|
|
391
|
-
},
|
|
392
|
-
if (
|
|
393
|
-
const
|
|
394
|
-
throw new Error(`markdown service is not reachable on ${
|
|
395
|
-
}
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
const
|
|
837
|
+
}, Zt = async (r, t, e, n, o) => {
|
|
838
|
+
if (Dt(o), !await Nt()) {
|
|
839
|
+
const i = I ? ` ${I}` : "";
|
|
840
|
+
throw new Error(`markdown service is not reachable on ${T}.${i}`);
|
|
841
|
+
}
|
|
842
|
+
const s = {};
|
|
843
|
+
n && (s.Authorization = `Bearer ${n}`);
|
|
844
|
+
const a = Pe(Rt, xe({ baseUrl: "http://localhost", httpVersion: "2", sessionManager: Lt, readMaxBytes: 2 * o.maxHtmlBytes + we }));
|
|
399
845
|
try {
|
|
400
|
-
const
|
|
846
|
+
const i = await a.convert(
|
|
401
847
|
{
|
|
402
848
|
markdownText: r,
|
|
403
|
-
filePath:
|
|
404
|
-
workspaceRoot:
|
|
405
|
-
validateExistence:
|
|
406
|
-
enableSubscript:
|
|
407
|
-
enableSuperscript:
|
|
408
|
-
enableMark:
|
|
409
|
-
enableTableMerge:
|
|
410
|
-
enableEmbeds:
|
|
411
|
-
enableZennDirectives:
|
|
412
|
-
resolveImports:
|
|
413
|
-
maxHtmlBytes:
|
|
414
|
-
deny: new
|
|
849
|
+
filePath: t,
|
|
850
|
+
workspaceRoot: e,
|
|
851
|
+
validateExistence: o.validateExistence ?? !0,
|
|
852
|
+
enableSubscript: o.enableSubscript,
|
|
853
|
+
enableSuperscript: o.enableSuperscript,
|
|
854
|
+
enableMark: o.enableMark,
|
|
855
|
+
enableTableMerge: o.enableTableMerge,
|
|
856
|
+
enableEmbeds: o.enableEmbeds,
|
|
857
|
+
enableZennDirectives: o.enableZennDirectives,
|
|
858
|
+
resolveImports: o.resolveImports ?? !1,
|
|
859
|
+
maxHtmlBytes: o.maxHtmlBytes,
|
|
860
|
+
deny: new g({ segmentPatterns: [...o.deniedPathSegments] })
|
|
415
861
|
},
|
|
416
|
-
{ headers:
|
|
862
|
+
{ headers: s, signal: o.signal, timeoutMs: o.timeoutMs }
|
|
417
863
|
);
|
|
418
864
|
return {
|
|
419
|
-
htmlContent:
|
|
420
|
-
headings:
|
|
421
|
-
text:
|
|
422
|
-
depth:
|
|
423
|
-
id:
|
|
865
|
+
htmlContent: i.htmlContent,
|
|
866
|
+
headings: i.headings.map((l) => ({
|
|
867
|
+
text: l.text,
|
|
868
|
+
depth: l.depth,
|
|
869
|
+
id: l.id
|
|
424
870
|
}))
|
|
425
871
|
};
|
|
426
|
-
} catch (
|
|
427
|
-
throw
|
|
872
|
+
} catch (i) {
|
|
873
|
+
throw i instanceof Me && i.code === Ce.ResourceExhausted ? new Pt(i) : i;
|
|
428
874
|
}
|
|
429
875
|
};
|
|
430
876
|
export {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
877
|
+
re as MAX_HTML_BYTES_LIMIT,
|
|
878
|
+
Pt as MarkdownResourceExhaustedError,
|
|
879
|
+
Yt as createLinkCardHandler,
|
|
880
|
+
Zt as parseMarkdown
|
|
434
881
|
};
|