agentic-mermaid 0.4.1 → 0.5.3
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/AGENT_NATIVE.md +94 -627
- package/CHANGELOG.md +651 -0
- package/Instructions_for_agents.md +44 -23
- package/LICENSES/Khroma-MIT.txt +21 -0
- package/LICENSES/Mermaid-MIT.txt +21 -0
- package/LICENSES/es-toolkit-MIT.txt +21 -0
- package/LICENSES/pele-MIT.txt +40 -0
- package/LICENSES/zenuml-core-MIT.txt +21 -0
- package/README.md +93 -50
- package/SECURITY.md +28 -12
- package/THIRD_PARTY_NOTICES.md +60 -0
- package/assets/hero.png +0 -0
- package/dist/agent-core.d.ts +478 -210
- package/dist/agent-core.js +1 -396
- package/dist/agent.d.ts +17 -8
- package/dist/agent.js +1 -408
- package/dist/agentic-mermaid-mcp.js +1 -11
- package/dist/am.js +1 -34562
- package/dist/browser-lazy/chunks/agentic-producer-core-CC6OOLDW.js +1 -0
- package/dist/browser-lazy/chunks/architecture-QUFVKYJR.js +13 -0
- package/dist/browser-lazy/chunks/block-6J3Q63BO.js +11 -0
- package/dist/browser-lazy/chunks/builtin-backends-7SOZZHPF.js +12 -0
- package/dist/browser-lazy/chunks/c4-SQVBZAKJ.js +10 -0
- package/dist/browser-lazy/chunks/chunk-2GPK4VFF.js +5 -0
- package/dist/browser-lazy/chunks/chunk-2I4UPL7Q.js +3 -0
- package/dist/browser-lazy/chunks/chunk-2SH76OTH.js +1 -0
- package/dist/browser-lazy/chunks/chunk-2UIA2IME.js +3 -0
- package/dist/browser-lazy/chunks/chunk-4LHYF3BS.js +1 -0
- package/dist/browser-lazy/chunks/chunk-5B2Z7575.js +1 -0
- package/dist/browser-lazy/chunks/chunk-5FQ534HP.js +1 -0
- package/dist/browser-lazy/chunks/chunk-5UVGUSD6.js +1 -0
- package/dist/browser-lazy/chunks/chunk-5X6MJX3H.js +1 -0
- package/dist/browser-lazy/chunks/chunk-AMJLVPUB.js +4 -0
- package/dist/browser-lazy/chunks/chunk-BU5LHXNJ.js +3 -0
- package/dist/browser-lazy/chunks/chunk-BY2CPG6B.js +1 -0
- package/dist/browser-lazy/chunks/chunk-CN7WTBWB.js +1 -0
- package/dist/browser-lazy/chunks/chunk-CQE4HQEW.js +1 -0
- package/dist/browser-lazy/chunks/chunk-CSFUKSU6.js +1 -0
- package/dist/browser-lazy/chunks/chunk-DF6765YX.js +17 -0
- package/dist/browser-lazy/chunks/chunk-E2WMJZNM.js +1 -0
- package/dist/browser-lazy/chunks/chunk-FAIMVOX5.js +6 -0
- package/dist/browser-lazy/chunks/chunk-GVOEAY52.js +1 -0
- package/dist/browser-lazy/chunks/chunk-HLWUNUCM.js +1 -0
- package/dist/browser-lazy/chunks/chunk-ICC7HBJX.js +1 -0
- package/dist/browser-lazy/chunks/chunk-J35HAQQF.js +20 -0
- package/dist/browser-lazy/chunks/chunk-J7FFAFQF.js +1 -0
- package/dist/browser-lazy/chunks/chunk-LH7HUDKW.js +1 -0
- package/dist/browser-lazy/chunks/chunk-N5ELX7LR.js +2 -0
- package/dist/browser-lazy/chunks/chunk-NMQQMRIR.js +1 -0
- package/dist/browser-lazy/chunks/chunk-NO7ZIVRU.js +1 -0
- package/dist/browser-lazy/chunks/chunk-OZ443IVJ.js +16 -0
- package/dist/browser-lazy/chunks/chunk-PQGPS2YV.js +7 -0
- package/dist/browser-lazy/chunks/chunk-QA6GJQ4X.js +1 -0
- package/dist/browser-lazy/chunks/chunk-RIVTHZAQ.js +1 -0
- package/dist/browser-lazy/chunks/chunk-SZELX2EJ.js +1 -0
- package/dist/browser-lazy/chunks/chunk-TYZOZXUJ.js +22 -0
- package/dist/browser-lazy/chunks/chunk-UL6NDWLL.js +1 -0
- package/dist/browser-lazy/chunks/chunk-VQYYGAXP.js +1 -0
- package/dist/browser-lazy/chunks/chunk-VWVZGQE2.js +1 -0
- package/dist/browser-lazy/chunks/chunk-X2UYKWKM.js +4 -0
- package/dist/browser-lazy/chunks/chunk-YCEICNM6.js +1 -0
- package/dist/browser-lazy/chunks/chunk-Z3FDIVLN.js +20 -0
- package/dist/browser-lazy/chunks/class-5QA4SCTS.js +13 -0
- package/dist/browser-lazy/chunks/decode-63UIZGD2.js +1 -0
- package/dist/browser-lazy/chunks/elk.bundled-L4CADV5W.js +24 -0
- package/dist/browser-lazy/chunks/er-7ZSKGN7Y.js +11 -0
- package/dist/browser-lazy/chunks/eventmodeling-2BPLHWRN.js +19 -0
- package/dist/browser-lazy/chunks/flowchart-NEIMZTB5.js +4 -0
- package/dist/browser-lazy/chunks/forest-implementation-AEP24AIP.js +1 -0
- package/dist/browser-lazy/chunks/gantt-RDPIFYAF.js +11 -0
- package/dist/browser-lazy/chunks/gitgraph-N4Y5RYB7.js +9 -0
- package/dist/browser-lazy/chunks/ishikawa-LD3YBDJN.js +6 -0
- package/dist/browser-lazy/chunks/journey-6YQR5DJX.js +16 -0
- package/dist/browser-lazy/chunks/kanban-PLMJ7NBW.js +20 -0
- package/dist/browser-lazy/chunks/mermaid-yaml-runtime-QVYX4EWK.js +136 -0
- package/dist/browser-lazy/chunks/mindmap-K2UBFO3Y.js +12 -0
- package/dist/browser-lazy/chunks/packet-CUW4QY6Y.js +7 -0
- package/dist/browser-lazy/chunks/pie-7F7UUCG3.js +15 -0
- package/dist/browser-lazy/chunks/quadrant-TOONO2WC.js +10 -0
- package/dist/browser-lazy/chunks/radar-J6JVWVAX.js +16 -0
- package/dist/browser-lazy/chunks/render-core-BZOM3K7D.js +3 -0
- package/dist/browser-lazy/chunks/requirement-CMAKDJPO.js +19 -0
- package/dist/browser-lazy/chunks/sankey-AWXQEP3F.js +13 -0
- package/dist/browser-lazy/chunks/sequence-Q2RJRB4L.js +5 -0
- package/dist/browser-lazy/chunks/state-WRBFQEDX.js +4 -0
- package/dist/browser-lazy/chunks/timeline-D2KILFXM.js +6 -0
- package/dist/browser-lazy/chunks/treemap-N3VYX5D4.js +6 -0
- package/dist/browser-lazy/chunks/xychart-G73OGK66.js +16 -0
- package/dist/browser-lazy/chunks/zenuml-H4BXNYXR.js +16 -0
- package/dist/browser-lazy/index.d.ts +544 -275
- package/dist/browser-lazy/index.js +1 -1
- package/dist/browser.global.js +802 -565
- package/dist/chunk-3LGLPG33.js +2 -0
- package/dist/chunk-7CRDX2QR.js +2 -0
- package/dist/chunk-7PPW2BMO.js +2 -0
- package/dist/chunk-DQDKA5ND.js +2 -0
- package/dist/chunk-EHCMJUMD.js +52 -0
- package/dist/chunk-GVCHLSHH.js +4 -0
- package/dist/chunk-H3NCS2XZ.js +19 -0
- package/dist/chunk-JZOJ4YGS.js +201 -0
- package/dist/chunk-MKE7GNYU.js +146 -0
- package/dist/chunk-NKNFOREZ.js +2 -0
- package/dist/chunk-O7H2UX5K.js +2 -0
- package/dist/chunk-OMY6NRQD.js +58 -0
- package/dist/chunk-UA234O4M.js +4 -0
- package/dist/chunk-VUFVLGTH.js +2 -0
- package/dist/chunk-XU5LPD2D.js +2 -0
- package/dist/cli-YGGTJZH7.js +226 -0
- package/dist/elk-constructor.js +2 -0
- package/dist/elk-constructor.node.js +11 -0
- package/dist/index-EeXqJXr5.d.ts +1223 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -334
- package/dist/jsonl-RPJY6YWO.js +2 -0
- package/dist/mcp-cli-63DYXTVD.js +2 -0
- package/dist/{index-BGA_-6LV.d.ts → paint-certification-6rwQjIv_.d.ts} +5283 -6173
- package/dist/server-5NEOHOFS.js +524 -0
- package/dist/svg-styles-BdnoM7AT.d.ts +724 -0
- package/dist/svg-styles.d.ts +1 -0
- package/dist/svg-styles.js +2 -0
- package/dist/svg.d.ts +13 -0
- package/dist/svg.js +2 -0
- package/dist/types-BcS52Mjt.d.ts +1360 -0
- package/dist/zenuml/chunks/appearance-UOQ5KA6O.js +1 -0
- package/dist/zenuml/chunks/builtin-backends-KDKE7YHO.js +12 -0
- package/dist/zenuml/chunks/chunk-42DXZ5C6.js +4 -0
- package/dist/zenuml/chunks/chunk-7TVYPTDW.js +1 -0
- package/dist/zenuml/chunks/chunk-EVPSMEKN.js +1 -0
- package/dist/zenuml/chunks/chunk-OXQWRSBM.js +20 -0
- package/dist/zenuml/chunks/chunk-QWX77U7G.js +2 -0
- package/dist/zenuml/chunks/chunk-RLJEI7YN.js +29 -0
- package/dist/zenuml/chunks/chunk-RZ6XK5CD.js +29 -0
- package/dist/zenuml/chunks/decode-BWERFDGK.js +1 -0
- package/dist/zenuml/chunks/mermaid-yaml-runtime-KZVU74WU.js +136 -0
- package/dist/zenuml/chunks/render-core-V5RQ737O.js +3 -0
- package/dist/zenuml/chunks/zenuml-EA2ZFRUX.js +20 -0
- package/dist/zenuml-frame.global.js +3626 -0
- package/dist/zenuml.d.ts +83 -0
- package/dist/zenuml.js +1 -0
- package/docs/MCP-DIRECTORY-LISTINGS.md +5 -1
- package/docs/README.md +59 -103
- package/docs/agent-api-cookbook.md +26 -16
- package/docs/agent-mutation-policy.md +86 -15
- package/docs/agent-workflow-examples.md +1 -1
- package/docs/api-advanced.md +385 -0
- package/docs/api.md +320 -366
- package/docs/ascii.md +40 -4
- package/docs/browser.md +46 -7
- package/docs/choosing-a-diagram.md +148 -0
- package/docs/code-mode-impact.md +1 -0
- package/docs/comparison.md +244 -28
- package/docs/computational-aesthetics-prototype-plan.md +10 -10
- package/docs/config.md +60 -2
- package/docs/custom-fonts.md +78 -21
- package/docs/diagram-families.md +160 -10
- package/docs/eventmodeling-and-zenuml.md +165 -0
- package/docs/features.md +21 -19
- package/docs/fork-differences.md +105 -32
- package/docs/getting-started.md +56 -51
- package/docs/layout-certification.md +126 -0
- package/docs/mcp-code-mode-rationale.md +20 -12
- package/docs/mcp-http-transport.md +14 -8
- package/docs/quality.md +145 -15
- package/docs/react.md +76 -31
- package/docs/style-authoring.md +23 -11
- package/docs/svg-semantic-contract.md +104 -4
- package/docs/testing-strategy.md +684 -126
- package/docs/theming.md +27 -8
- package/examples/styles/readme-hero.md +25 -0
- package/examples/styles/readme-hero.mmd +13 -0
- package/examples/styles/readme-hero.style.json +7 -0
- package/package.json +114 -57
- package/server.json +2 -2
- package/skills/agentic-mermaid-diagram-workflow/SKILL.md +26 -8
- package/skills/agentic-mermaid-diagram-workflow/references/cli.md +13 -3
- package/skills/agentic-mermaid-diagram-workflow/references/code-mode.md +2 -1
- package/skills/agentic-mermaid-diagram-workflow/references/flowchart.md +9 -6
- package/skills/agentic-mermaid-diagram-workflow/references/hosted-mcp.md +1 -0
- package/skills/agentic-mermaid-diagram-workflow/references/sequence.md +4 -3
- package/skills/agentic-mermaid-diagram-workflow/references/timeline.md +7 -6
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/agentflow.md +574 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/architecture.md +10 -2
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/c4.md +18 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/classDiagram.md +123 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/cynefin.md +6 -1
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/entityRelationshipDiagram.md +129 -9
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/eventmodeling.md +22 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/flowchart.md +188 -60
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/gitgraph.md +13 -7
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/mindmap.md +110 -1
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/packet.md +38 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/requirementDiagram.md +115 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/sequenceDiagram.md +101 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/stateDiagram.md +87 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/swimlanes.md +105 -2
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/timeline.md +12 -6
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/usecase.md +953 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/venn.md +77 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/xyChart.md +1 -1
- package/dist/browser-lazy/chunks/architecture-KTHE2HX3.js +0 -31
- package/dist/browser-lazy/chunks/chunk-2XCPFAD5.js +0 -46
- package/dist/browser-lazy/chunks/chunk-3H4F7RBT.js +0 -1
- package/dist/browser-lazy/chunks/chunk-4EVLW2NJ.js +0 -1
- package/dist/browser-lazy/chunks/chunk-5Q4S74UO.js +0 -1
- package/dist/browser-lazy/chunks/chunk-6OAPWSDO.js +0 -1
- package/dist/browser-lazy/chunks/chunk-A7L4WWVW.js +0 -143
- package/dist/browser-lazy/chunks/chunk-C7FJO2I3.js +0 -4
- package/dist/browser-lazy/chunks/chunk-D3XXDKIO.js +0 -1
- package/dist/browser-lazy/chunks/chunk-DXA5WL7H.js +0 -4
- package/dist/browser-lazy/chunks/chunk-EPFMQPXX.js +0 -1
- package/dist/browser-lazy/chunks/chunk-FFOHLPDA.js +0 -2
- package/dist/browser-lazy/chunks/chunk-FLD63DXE.js +0 -2
- package/dist/browser-lazy/chunks/chunk-G6OLSHRG.js +0 -7
- package/dist/browser-lazy/chunks/chunk-GRXCKTHX.js +0 -0
- package/dist/browser-lazy/chunks/chunk-I6VE56S7.js +0 -1
- package/dist/browser-lazy/chunks/chunk-KJVNXJ5Y.js +0 -1
- package/dist/browser-lazy/chunks/chunk-L227EPFP.js +0 -11
- package/dist/browser-lazy/chunks/chunk-LNIHDJSF.js +0 -1
- package/dist/browser-lazy/chunks/chunk-M6BT2HIP.js +0 -1
- package/dist/browser-lazy/chunks/chunk-NZRUMODH.js +0 -1
- package/dist/browser-lazy/chunks/chunk-OFRMKQA6.js +0 -1
- package/dist/browser-lazy/chunks/chunk-P7HMSKHJ.js +0 -1
- package/dist/browser-lazy/chunks/chunk-PXKL3O6H.js +0 -1
- package/dist/browser-lazy/chunks/chunk-PZEWZT35.js +0 -1
- package/dist/browser-lazy/chunks/chunk-STQRDZ67.js +0 -1
- package/dist/browser-lazy/chunks/chunk-SUFMSWTX.js +0 -1
- package/dist/browser-lazy/chunks/chunk-T7IJ6V4B.js +0 -3
- package/dist/browser-lazy/chunks/chunk-UAEZO5VL.js +0 -1
- package/dist/browser-lazy/chunks/chunk-WEUWIFG3.js +0 -1
- package/dist/browser-lazy/chunks/chunk-X64T74C5.js +0 -24
- package/dist/browser-lazy/chunks/class-F7R6TJ73.js +0 -9
- package/dist/browser-lazy/chunks/er-BDK7CM5L.js +0 -9
- package/dist/browser-lazy/chunks/flowchart-KFU6XV7S.js +0 -4
- package/dist/browser-lazy/chunks/gantt-I64VVDSP.js +0 -28
- package/dist/browser-lazy/chunks/gitgraph-EDUVJ5IJ.js +0 -8
- package/dist/browser-lazy/chunks/journey-TLO2RNM3.js +0 -40
- package/dist/browser-lazy/chunks/mindmap-OJCNDYPM.js +0 -9
- package/dist/browser-lazy/chunks/pie-HVG6XO7K.js +0 -19
- package/dist/browser-lazy/chunks/quadrant-U6S2L4MJ.js +0 -24
- package/dist/browser-lazy/chunks/radar-ZDLOBTVG.js +0 -32
- package/dist/browser-lazy/chunks/render-core-Y2DFNMQG.js +0 -12
- package/dist/browser-lazy/chunks/sequence-Z4WFS3VB.js +0 -12
- package/dist/browser-lazy/chunks/state-2HV2YGN3.js +0 -4
- package/dist/browser-lazy/chunks/timeline-XM4UFPOC.js +0 -20
- package/dist/browser-lazy/chunks/xychart-7JDHWTQY.js +0 -36
- package/dist/chunk-GGXCNCNA.js +0 -4118
- package/dist/chunk-IVD4NXNE.js +0 -615
- package/dist/chunk-JDMRPUAG.js +0 -37
- package/dist/chunk-JWAAW3FH.js +0 -149
- package/dist/chunk-LCGBT32P.js +0 -62036
- package/dist/chunk-RWMZRUIC.js +0 -4715
- package/dist/mcp-cli-4MLKC3ZH.js +0 -17
- package/docs/mutation-testing.md +0 -285
package/dist/chunk-IVD4NXNE.js
DELETED
|
@@ -1,615 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BUILTIN_RESOURCE_MEDIA_TYPES,
|
|
3
|
-
RESOURCE_MANIFEST,
|
|
4
|
-
applyPngColorProfile,
|
|
5
|
-
graphemes,
|
|
6
|
-
inlineFontVarForRaster,
|
|
7
|
-
inspectPngDimensions,
|
|
8
|
-
omitPngOutputOptions,
|
|
9
|
-
pngNapiRuntimeProvenance,
|
|
10
|
-
prepareRenderInput,
|
|
11
|
-
prepareSvgForPngRasterization,
|
|
12
|
-
projectNativePngOutputPolicyInput,
|
|
13
|
-
renderPngGraphicalProjection,
|
|
14
|
-
snapshotHostBackendPolicy,
|
|
15
|
-
snapshotResourceManifest
|
|
16
|
-
} from "./chunk-LCGBT32P.js";
|
|
17
|
-
|
|
18
|
-
// src/agent/png.ts
|
|
19
|
-
import { fileURLToPath } from "url";
|
|
20
|
-
import { tmpdir as tmpdir2 } from "os";
|
|
21
|
-
import { basename, dirname as dirname2, join as join4 } from "path";
|
|
22
|
-
import { existsSync, mkdtempSync as mkdtempSync2, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
23
|
-
import { Resvg } from "@resvg/resvg-js";
|
|
24
|
-
|
|
25
|
-
// src/agent/font-coverage.ts
|
|
26
|
-
import { readdirSync, readFileSync, statSync } from "fs";
|
|
27
|
-
import { join } from "path";
|
|
28
|
-
|
|
29
|
-
// src/agent/font-coverage-core.ts
|
|
30
|
-
import { decodeXML } from "entities";
|
|
31
|
-
var CMAP = 1668112752;
|
|
32
|
-
var TTCF = 1953784678;
|
|
33
|
-
var OTTO = 1330926671;
|
|
34
|
-
var TRUE = 1953658213;
|
|
35
|
-
function parseFont(bytes) {
|
|
36
|
-
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
37
|
-
try {
|
|
38
|
-
if (view.getUint32(0) === TTCF) {
|
|
39
|
-
const faces = [];
|
|
40
|
-
for (let i = 0; i < view.getUint32(8); i++) faces.push(parseSfnt(view, view.getUint32(12 + i * 4)));
|
|
41
|
-
return faces.filter((face2) => face2.length > 0);
|
|
42
|
-
}
|
|
43
|
-
const face = parseSfnt(view, 0);
|
|
44
|
-
return face.length > 0 ? [face] : [];
|
|
45
|
-
} catch {
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function parseSfnt(view, base) {
|
|
50
|
-
const version = view.getUint32(base);
|
|
51
|
-
if (version !== 65536 && version !== OTTO && version !== TRUE) return [];
|
|
52
|
-
const tables = view.getUint16(base + 4);
|
|
53
|
-
for (let i = 0; i < tables; i++) {
|
|
54
|
-
const record = base + 12 + i * 16;
|
|
55
|
-
if (view.getUint32(record) === CMAP) return parseCmap(view, view.getUint32(record + 8));
|
|
56
|
-
}
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
function parseCmap(view, offset) {
|
|
60
|
-
const lookups = [];
|
|
61
|
-
const count = view.getUint16(offset + 2);
|
|
62
|
-
for (let i = 0; i < count; i++) {
|
|
63
|
-
const record = offset + 4 + i * 8;
|
|
64
|
-
const platform = view.getUint16(record);
|
|
65
|
-
const encoding = view.getUint16(record + 2);
|
|
66
|
-
if (!(platform === 0 || platform === 3 && (encoding === 1 || encoding === 10))) continue;
|
|
67
|
-
const subtable = offset + view.getUint32(record + 4);
|
|
68
|
-
const format = view.getUint16(subtable);
|
|
69
|
-
if (format === 4) lookups.push(format4(view, subtable));
|
|
70
|
-
else if (format === 12) lookups.push(format12(view, subtable));
|
|
71
|
-
else if (format === 6) lookups.push(format6(view, subtable));
|
|
72
|
-
else if (format === 0) lookups.push(format0(view, subtable));
|
|
73
|
-
}
|
|
74
|
-
return lookups;
|
|
75
|
-
}
|
|
76
|
-
function format4(view, subtable) {
|
|
77
|
-
const count = view.getUint16(subtable + 6) / 2;
|
|
78
|
-
const ends = subtable + 14;
|
|
79
|
-
const starts = ends + count * 2 + 2;
|
|
80
|
-
const deltas = starts + count * 2;
|
|
81
|
-
const offsets = deltas + count * 2;
|
|
82
|
-
return { has(codepoint) {
|
|
83
|
-
if (codepoint > 65535) return false;
|
|
84
|
-
let low = 0, high = count - 1;
|
|
85
|
-
while (low < high) {
|
|
86
|
-
const mid = low + high >> 1;
|
|
87
|
-
if (view.getUint16(ends + mid * 2) < codepoint) low = mid + 1;
|
|
88
|
-
else high = mid;
|
|
89
|
-
}
|
|
90
|
-
if (view.getUint16(starts + low * 2) > codepoint || codepoint === 65535) return false;
|
|
91
|
-
const rangeOffset = view.getUint16(offsets + low * 2);
|
|
92
|
-
if (rangeOffset === 0) return (codepoint + view.getInt16(deltas + low * 2) & 65535) !== 0;
|
|
93
|
-
const glyphOffset = offsets + low * 2 + rangeOffset + (codepoint - view.getUint16(starts + low * 2)) * 2;
|
|
94
|
-
if (glyphOffset + 2 > view.byteLength) return false;
|
|
95
|
-
const glyph = view.getUint16(glyphOffset);
|
|
96
|
-
return glyph !== 0 && (glyph + view.getInt16(deltas + low * 2) & 65535) !== 0;
|
|
97
|
-
} };
|
|
98
|
-
}
|
|
99
|
-
function format12(view, subtable) {
|
|
100
|
-
const count = view.getUint32(subtable + 12);
|
|
101
|
-
const groups = subtable + 16;
|
|
102
|
-
return { has(codepoint) {
|
|
103
|
-
let low = 0, high = count - 1;
|
|
104
|
-
while (low <= high) {
|
|
105
|
-
const mid = low + high >> 1;
|
|
106
|
-
const at = groups + mid * 12;
|
|
107
|
-
if (codepoint < view.getUint32(at)) high = mid - 1;
|
|
108
|
-
else if (codepoint > view.getUint32(at + 4)) low = mid + 1;
|
|
109
|
-
else return view.getUint32(at + 8) + codepoint - view.getUint32(at) !== 0;
|
|
110
|
-
}
|
|
111
|
-
return false;
|
|
112
|
-
} };
|
|
113
|
-
}
|
|
114
|
-
function format6(view, subtable) {
|
|
115
|
-
const first = view.getUint16(subtable + 6);
|
|
116
|
-
const count = view.getUint16(subtable + 8);
|
|
117
|
-
return { has: (codepoint) => codepoint >= first && codepoint < first + count && view.getUint16(subtable + 10 + (codepoint - first) * 2) !== 0 };
|
|
118
|
-
}
|
|
119
|
-
function format0(view, subtable) {
|
|
120
|
-
return { has: (codepoint) => codepoint < 256 && view.getUint8(subtable + 6 + codepoint) !== 0 };
|
|
121
|
-
}
|
|
122
|
-
function extractSvgTextContent(svg) {
|
|
123
|
-
let text = "";
|
|
124
|
-
for (const match of svg.matchAll(/<text\b[^>]*>([\s\S]*?)<\/text>/g)) text += match[1].replace(/<[^>]*>/g, "");
|
|
125
|
-
return decodeXML(text);
|
|
126
|
-
}
|
|
127
|
-
function ignorable(codepoint) {
|
|
128
|
-
return codepoint <= 32 || codepoint === 127 || codepoint >= 8203 && codepoint <= 8207 || codepoint === 8232 || codepoint === 8233 || codepoint >= 65024 && codepoint <= 65039 || codepoint === 65279;
|
|
129
|
-
}
|
|
130
|
-
function script(codepoint) {
|
|
131
|
-
if (codepoint >= 11904 && codepoint <= 40959 || codepoint >= 44032 && codepoint <= 55295 || codepoint >= 63744 && codepoint <= 64255 || codepoint >= 131072 && codepoint <= 262143) return "CJK";
|
|
132
|
-
if (codepoint >= 9728 && codepoint <= 10175 || codepoint >= 126976 && codepoint <= 129791) return "emoji";
|
|
133
|
-
if (codepoint >= 1424 && codepoint <= 1535) return "Hebrew";
|
|
134
|
-
if (codepoint >= 1536 && codepoint <= 1919) return "Arabic";
|
|
135
|
-
if (codepoint >= 2304 && codepoint <= 2431) return "Devanagari";
|
|
136
|
-
return "other";
|
|
137
|
-
}
|
|
138
|
-
function findUncoveredScriptsFromBuffers(svg, fontBuffers) {
|
|
139
|
-
const faces = fontBuffers.flatMap(parseFont);
|
|
140
|
-
const byScript = /* @__PURE__ */ new Map();
|
|
141
|
-
for (const cluster of graphemes(extractSvgTextContent(svg))) {
|
|
142
|
-
const codepoints = [...cluster].map((char) => char.codePointAt(0)).filter((codepoint) => !ignorable(codepoint));
|
|
143
|
-
if (codepoints.length === 0) continue;
|
|
144
|
-
const oneFaceCovers = faces.some((face) => codepoints.every((codepoint) => face.some((lookup) => lookup.has(codepoint))));
|
|
145
|
-
const shapingUncertain = cluster.includes("\u200D") || /\p{Mark}/u.test(cluster);
|
|
146
|
-
if (oneFaceCovers && !shapingUncertain) continue;
|
|
147
|
-
for (const codepoint of codepoints) {
|
|
148
|
-
const bucket = byScript.get(script(codepoint)) ?? /* @__PURE__ */ new Set();
|
|
149
|
-
bucket.add(codepoint);
|
|
150
|
-
byScript.set(script(codepoint), bucket);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return [...byScript].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([name, values]) => ({
|
|
154
|
-
script: name,
|
|
155
|
-
chars: [...values].sort((a, b) => a - b).map((codepoint) => String.fromCodePoint(codepoint))
|
|
156
|
-
}));
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// src/agent/font-coverage.ts
|
|
160
|
-
var FONT_EXT = /\.(ttf|otf|ttc|otc)$/i;
|
|
161
|
-
function fontFilesUnder(directory, depth = 4) {
|
|
162
|
-
if (depth < 0) return [];
|
|
163
|
-
let entries;
|
|
164
|
-
try {
|
|
165
|
-
entries = readdirSync(directory).sort();
|
|
166
|
-
} catch {
|
|
167
|
-
return [];
|
|
168
|
-
}
|
|
169
|
-
const files = [];
|
|
170
|
-
for (const entry of entries) {
|
|
171
|
-
const path = join(directory, entry);
|
|
172
|
-
try {
|
|
173
|
-
const stat = statSync(path);
|
|
174
|
-
if (stat.isDirectory()) files.push(...fontFilesUnder(path, depth - 1));
|
|
175
|
-
else if (FONT_EXT.test(entry)) files.push(path);
|
|
176
|
-
} catch {
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return files;
|
|
180
|
-
}
|
|
181
|
-
function fontBuffersUnder(directories) {
|
|
182
|
-
const buffers = [];
|
|
183
|
-
for (const directory of directories) {
|
|
184
|
-
for (const file of fontFilesUnder(directory)) {
|
|
185
|
-
try {
|
|
186
|
-
buffers.push(new Uint8Array(readFileSync(file)));
|
|
187
|
-
} catch {
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return buffers;
|
|
192
|
-
}
|
|
193
|
-
function findUncoveredScripts(svg, callerFontDirectories, verifiedFontBuffers) {
|
|
194
|
-
return findUncoveredScriptsFromBuffers(svg, [
|
|
195
|
-
...verifiedFontBuffers,
|
|
196
|
-
...fontBuffersUnder(callerFontDirectories)
|
|
197
|
-
]);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// src/shared/png-font-warnings.ts
|
|
201
|
-
function buildPngFontWarnings(uncovered, options = {}) {
|
|
202
|
-
return uncovered.map(({ script: script2, chars }) => {
|
|
203
|
-
const examples = chars.slice(0, 5).join(" ");
|
|
204
|
-
const uncertainty = options.systemFontsMayCover ? " They are absent from bundled/caller-provided fonts; an installed system font may cover them, so final shaping is machine-dependent." : " They may draw as tofu or fail to shape as one grapheme.";
|
|
205
|
-
return {
|
|
206
|
-
code: "PNG_FONT_COVERAGE",
|
|
207
|
-
script: script2,
|
|
208
|
-
chars: [...chars],
|
|
209
|
-
message: `no known loaded face covers ${chars.length} ${script2} character${chars.length === 1 ? "" : "s"} (${examples}) in one grapheme cluster.${uncertainty} Supply fontDirs (CLI: --font-dirs <dir>) with a face that covers the cluster.`
|
|
210
|
-
};
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// src/node-resource-resolver.ts
|
|
215
|
-
import { createHash } from "crypto";
|
|
216
|
-
import {
|
|
217
|
-
closeSync,
|
|
218
|
-
constants as fsConstants,
|
|
219
|
-
fstatSync,
|
|
220
|
-
lstatSync,
|
|
221
|
-
openSync,
|
|
222
|
-
readSync,
|
|
223
|
-
realpathSync
|
|
224
|
-
} from "fs";
|
|
225
|
-
import { isAbsolute, join as join2, relative, sep } from "path";
|
|
226
|
-
var ResourceResolutionError = class extends Error {
|
|
227
|
-
code;
|
|
228
|
-
resourceId;
|
|
229
|
-
constructor(code, resourceId, message) {
|
|
230
|
-
super(`${code}: ${message}`);
|
|
231
|
-
this.name = "ResourceResolutionError";
|
|
232
|
-
this.code = code;
|
|
233
|
-
this.resourceId = resourceId;
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
function errnoCode(error) {
|
|
237
|
-
return typeof error === "object" && error !== null && "code" in error ? String(error.code) : void 0;
|
|
238
|
-
}
|
|
239
|
-
function sha256(bytes) {
|
|
240
|
-
return createHash("sha256").update(bytes).digest("hex");
|
|
241
|
-
}
|
|
242
|
-
function openedResourceDescriptorPath(platform, fd) {
|
|
243
|
-
if (platform === "linux") return `/proc/self/fd/${fd}`;
|
|
244
|
-
if (platform === "darwin") return `/dev/fd/${fd}`;
|
|
245
|
-
return void 0;
|
|
246
|
-
}
|
|
247
|
-
var NodeResourceResolver = class {
|
|
248
|
-
#root;
|
|
249
|
-
#manifest;
|
|
250
|
-
#maxResourceBytes;
|
|
251
|
-
#mediaTypes;
|
|
252
|
-
#byId;
|
|
253
|
-
constructor(packageRoot, manifest, options = {}) {
|
|
254
|
-
let manifestSnapshot;
|
|
255
|
-
try {
|
|
256
|
-
manifestSnapshot = snapshotResourceManifest(manifest);
|
|
257
|
-
} catch (error) {
|
|
258
|
-
const detail = error instanceof Error ? error.message.replace(/^INVALID_RESOURCE_MANIFEST:\s*/, "") : String(error);
|
|
259
|
-
throw new ResourceResolutionError("INVALID_RESOURCE_MANIFEST", "resource-manifest", detail);
|
|
260
|
-
}
|
|
261
|
-
const maxResourceBytes = options.maxResourceBytes ?? 16 * 1024 * 1024;
|
|
262
|
-
if (!Number.isSafeInteger(maxResourceBytes) || maxResourceBytes <= 0) {
|
|
263
|
-
throw new ResourceResolutionError("INVALID_RESOURCE_MANIFEST", "resource-manifest", "maxResourceBytes must be a positive safe integer");
|
|
264
|
-
}
|
|
265
|
-
try {
|
|
266
|
-
this.#root = realpathSync(packageRoot);
|
|
267
|
-
} catch {
|
|
268
|
-
throw new ResourceResolutionError("RESOURCE_MISSING", "resource-manifest", `package root does not exist: ${packageRoot}`);
|
|
269
|
-
}
|
|
270
|
-
this.#manifest = manifestSnapshot;
|
|
271
|
-
this.#maxResourceBytes = maxResourceBytes;
|
|
272
|
-
this.#mediaTypes = Object.freeze({ ...options.mediaTypes ?? BUILTIN_RESOURCE_MEDIA_TYPES });
|
|
273
|
-
this.#byId = new Map(this.#manifest.resources.map((entry) => [entry.identity.id, entry]));
|
|
274
|
-
}
|
|
275
|
-
list() {
|
|
276
|
-
return this.#manifest.resources;
|
|
277
|
-
}
|
|
278
|
-
#securePath(entry, declaredPath, missingCode) {
|
|
279
|
-
const segments = declaredPath.split("/");
|
|
280
|
-
let candidate = this.#root;
|
|
281
|
-
for (const segment of segments) {
|
|
282
|
-
candidate = join2(candidate, segment);
|
|
283
|
-
let stat;
|
|
284
|
-
try {
|
|
285
|
-
stat = lstatSync(candidate);
|
|
286
|
-
} catch (error) {
|
|
287
|
-
if (errnoCode(error) === "ENOENT") {
|
|
288
|
-
throw new ResourceResolutionError(missingCode, entry.identity.id, `declared path is missing: ${declaredPath}`);
|
|
289
|
-
}
|
|
290
|
-
throw error;
|
|
291
|
-
}
|
|
292
|
-
if (stat.isSymbolicLink()) {
|
|
293
|
-
throw new ResourceResolutionError("RESOURCE_SYMLINK_REJECTED", entry.identity.id, `symlink component is forbidden: ${declaredPath}`);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
const escaped = relative(this.#root, candidate);
|
|
297
|
-
if (escaped === ".." || escaped.startsWith(`..${sep}`) || isAbsolute(escaped)) {
|
|
298
|
-
throw new ResourceResolutionError("RESOURCE_PATH_ESCAPE", entry.identity.id, `path escapes package root: ${declaredPath}`);
|
|
299
|
-
}
|
|
300
|
-
return candidate;
|
|
301
|
-
}
|
|
302
|
-
#openSecureFile(entry, declaredPath, missingCode) {
|
|
303
|
-
const absolutePath = this.#securePath(entry, declaredPath, missingCode);
|
|
304
|
-
let fd;
|
|
305
|
-
try {
|
|
306
|
-
fd = openSync(absolutePath, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW);
|
|
307
|
-
} catch (error) {
|
|
308
|
-
const code = errnoCode(error);
|
|
309
|
-
if (code === "ENOENT") throw new ResourceResolutionError(missingCode, entry.identity.id, `declared path is missing: ${declaredPath}`);
|
|
310
|
-
if (code === "ELOOP") throw new ResourceResolutionError("RESOURCE_SYMLINK_REJECTED", entry.identity.id, `symlink component is forbidden: ${declaredPath}`);
|
|
311
|
-
throw error;
|
|
312
|
-
}
|
|
313
|
-
try {
|
|
314
|
-
const openedStat = fstatSync(fd);
|
|
315
|
-
if (!openedStat.isFile()) {
|
|
316
|
-
throw new ResourceResolutionError("RESOURCE_NOT_REGULAR", entry.identity.id, `resource is not a regular file: ${declaredPath}`);
|
|
317
|
-
}
|
|
318
|
-
const descriptorPath = openedResourceDescriptorPath(process.platform, fd);
|
|
319
|
-
if (descriptorPath) {
|
|
320
|
-
const openedPath = realpathSync(descriptorPath);
|
|
321
|
-
if (openedPath !== descriptorPath && !openedPath.startsWith(`${descriptorPath}${sep}`)) {
|
|
322
|
-
const escaped = relative(this.#root, openedPath);
|
|
323
|
-
if (escaped === ".." || escaped.startsWith(`..${sep}`) || isAbsolute(escaped)) {
|
|
324
|
-
throw new ResourceResolutionError("RESOURCE_PATH_ESCAPE", entry.identity.id, `opened file escapes package root: ${declaredPath}`);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
const rootedPath = this.#securePath(entry, declaredPath, missingCode);
|
|
329
|
-
const rootedStat = lstatSync(rootedPath);
|
|
330
|
-
if (!rootedStat.isFile()) {
|
|
331
|
-
throw new ResourceResolutionError("RESOURCE_NOT_REGULAR", entry.identity.id, `resource is not a regular file: ${declaredPath}`);
|
|
332
|
-
}
|
|
333
|
-
if (openedStat.dev !== rootedStat.dev || openedStat.ino !== rootedStat.ino) {
|
|
334
|
-
throw new ResourceResolutionError("RESOURCE_PATH_ESCAPE", entry.identity.id, `opened file identity no longer matches the rooted path: ${declaredPath}`);
|
|
335
|
-
}
|
|
336
|
-
return fd;
|
|
337
|
-
} catch (error) {
|
|
338
|
-
closeSync(fd);
|
|
339
|
-
throw error;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
resolve(resourceId) {
|
|
343
|
-
const entry = this.#byId.get(resourceId);
|
|
344
|
-
if (!entry) throw new ResourceResolutionError("UNKNOWN_RESOURCE", resourceId, `resource is not installed: ${resourceId}`);
|
|
345
|
-
if (entry.bytes > this.#maxResourceBytes) {
|
|
346
|
-
throw new ResourceResolutionError("RESOURCE_SIZE_LIMIT", resourceId, `${entry.bytes} exceeds the ${this.#maxResourceBytes}-byte host limit`);
|
|
347
|
-
}
|
|
348
|
-
const licenseFd = this.#openSecureFile(entry, entry.license.noticePath, "RESOURCE_LICENSE_NOTICE_MISSING");
|
|
349
|
-
closeSync(licenseFd);
|
|
350
|
-
const fd = this.#openSecureFile(entry, entry.path, "RESOURCE_MISSING");
|
|
351
|
-
let bytes;
|
|
352
|
-
try {
|
|
353
|
-
const before = fstatSync(fd);
|
|
354
|
-
if (before.size !== entry.bytes) {
|
|
355
|
-
throw new ResourceResolutionError("RESOURCE_SIZE_MISMATCH", resourceId, `declared ${entry.bytes} bytes but found ${before.size}`);
|
|
356
|
-
}
|
|
357
|
-
const bounded = new Uint8Array(entry.bytes + 1);
|
|
358
|
-
let read = 0;
|
|
359
|
-
while (read < bounded.byteLength) {
|
|
360
|
-
const count = readSync(fd, bounded, read, bounded.byteLength - read, null);
|
|
361
|
-
if (count === 0) break;
|
|
362
|
-
read += count;
|
|
363
|
-
}
|
|
364
|
-
const after = fstatSync(fd);
|
|
365
|
-
if (read !== entry.bytes || after.size !== entry.bytes) {
|
|
366
|
-
throw new ResourceResolutionError("RESOURCE_SIZE_MISMATCH", resourceId, `declared ${entry.bytes} bytes but securely read ${read}`);
|
|
367
|
-
}
|
|
368
|
-
bytes = bounded.slice(0, read);
|
|
369
|
-
} finally {
|
|
370
|
-
closeSync(fd);
|
|
371
|
-
}
|
|
372
|
-
const mediaType = this.#mediaTypes[entry.mediaType];
|
|
373
|
-
if (!mediaType || !mediaType(bytes)) {
|
|
374
|
-
throw new ResourceResolutionError("RESOURCE_MEDIA_TYPE_MISMATCH", resourceId, `resource bytes do not match ${entry.mediaType}`);
|
|
375
|
-
}
|
|
376
|
-
const actualDigest = sha256(bytes);
|
|
377
|
-
if (actualDigest !== entry.sha256) {
|
|
378
|
-
throw new ResourceResolutionError("RESOURCE_DIGEST_MISMATCH", resourceId, `expected ${entry.sha256}, received ${actualDigest}`);
|
|
379
|
-
}
|
|
380
|
-
const snapshot = bytes.slice();
|
|
381
|
-
return Object.freeze({
|
|
382
|
-
entry,
|
|
383
|
-
readBytes: () => snapshot.slice()
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
verifyInstalled() {
|
|
387
|
-
const resources = [];
|
|
388
|
-
const diagnostics = [];
|
|
389
|
-
for (const entry of this.#manifest.resources) {
|
|
390
|
-
try {
|
|
391
|
-
resources.push(this.resolve(entry.identity.id));
|
|
392
|
-
} catch (error) {
|
|
393
|
-
if (!entry.required && error instanceof ResourceResolutionError && error.code === "RESOURCE_MISSING") {
|
|
394
|
-
diagnostics.push(Object.freeze({
|
|
395
|
-
code: "OPTIONAL_RESOURCE_MISSING",
|
|
396
|
-
resourceId: entry.identity.id,
|
|
397
|
-
message: error.message
|
|
398
|
-
}));
|
|
399
|
-
continue;
|
|
400
|
-
}
|
|
401
|
-
throw error;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
return Object.freeze({
|
|
405
|
-
resources: Object.freeze(resources),
|
|
406
|
-
diagnostics: Object.freeze(diagnostics)
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
// src/agent/embedded-font-resources.ts
|
|
412
|
-
import { tmpdir } from "os";
|
|
413
|
-
import { dirname, join as join3 } from "path";
|
|
414
|
-
import { mkdirSync, mkdtempSync, readFileSync as readFileSync2, rmSync, writeFileSync } from "fs";
|
|
415
|
-
var registeredFiles;
|
|
416
|
-
function verifyEmbeddedFontResourceFiles(manifest, files) {
|
|
417
|
-
const snapshot = snapshotResourceManifest(manifest);
|
|
418
|
-
const pathOwners = /* @__PURE__ */ new Map();
|
|
419
|
-
for (const entry of snapshot.resources) {
|
|
420
|
-
pathOwners.set(entry.path, { resourceId: entry.identity.id, missingCode: "RESOURCE_MISSING" });
|
|
421
|
-
if (!pathOwners.has(entry.license.noticePath)) {
|
|
422
|
-
pathOwners.set(entry.license.noticePath, {
|
|
423
|
-
resourceId: entry.identity.id,
|
|
424
|
-
missingCode: "RESOURCE_LICENSE_NOTICE_MISSING"
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
const root = mkdtempSync(join3(tmpdir(), "agentic-mermaid-embedded-resources-"));
|
|
429
|
-
try {
|
|
430
|
-
const materialized = /* @__PURE__ */ new Set();
|
|
431
|
-
for (const file of files) {
|
|
432
|
-
const owner = pathOwners.get(file.manifestPath);
|
|
433
|
-
if (!owner) {
|
|
434
|
-
throw new ResourceResolutionError(
|
|
435
|
-
"UNKNOWN_RESOURCE",
|
|
436
|
-
file.manifestPath,
|
|
437
|
-
`embedded path is not declared by the font resource manifest: ${file.manifestPath}`
|
|
438
|
-
);
|
|
439
|
-
}
|
|
440
|
-
if (materialized.has(file.manifestPath)) {
|
|
441
|
-
throw new ResourceResolutionError(
|
|
442
|
-
"INVALID_RESOURCE_MANIFEST",
|
|
443
|
-
owner.resourceId,
|
|
444
|
-
`duplicate embedded path: ${file.manifestPath}`
|
|
445
|
-
);
|
|
446
|
-
}
|
|
447
|
-
let bytes;
|
|
448
|
-
try {
|
|
449
|
-
bytes = readFileSync2(file.embeddedPath);
|
|
450
|
-
} catch {
|
|
451
|
-
throw new ResourceResolutionError(
|
|
452
|
-
owner.missingCode,
|
|
453
|
-
owner.resourceId,
|
|
454
|
-
`embedded source is unavailable for declared path: ${file.manifestPath}`
|
|
455
|
-
);
|
|
456
|
-
}
|
|
457
|
-
const target = join3(root, file.manifestPath);
|
|
458
|
-
mkdirSync(dirname(target), { recursive: true, mode: 448 });
|
|
459
|
-
writeFileSync(target, bytes, { flag: "wx", mode: 256 });
|
|
460
|
-
materialized.add(file.manifestPath);
|
|
461
|
-
}
|
|
462
|
-
return new NodeResourceResolver(root, snapshot).verifyInstalled();
|
|
463
|
-
} finally {
|
|
464
|
-
try {
|
|
465
|
-
rmSync(root, { recursive: true, force: true });
|
|
466
|
-
} catch {
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
function verifyRegisteredEmbeddedFontResources(manifest) {
|
|
471
|
-
return registeredFiles ? verifyEmbeddedFontResourceFiles(manifest, registeredFiles) : void 0;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
// src/agent/png.ts
|
|
475
|
-
var cachedBundledFonts;
|
|
476
|
-
var cleanupRegistered = false;
|
|
477
|
-
function materializeVerifiedFontSnapshot(resources) {
|
|
478
|
-
const snapshotDirectory = mkdtempSync2(join4(tmpdir2(), "agentic-mermaid-fonts-"));
|
|
479
|
-
try {
|
|
480
|
-
const buffers = resources.map((resource) => resource.readBytes());
|
|
481
|
-
const files = buffers.map((bytes, index) => {
|
|
482
|
-
const file = join4(snapshotDirectory, `${index}-${basename(resources[index].entry.path)}`);
|
|
483
|
-
writeFileSync2(file, bytes, { flag: "wx", mode: 256 });
|
|
484
|
-
return file;
|
|
485
|
-
});
|
|
486
|
-
return Object.freeze({
|
|
487
|
-
snapshotDirectory,
|
|
488
|
-
buffers: Object.freeze(buffers),
|
|
489
|
-
files: Object.freeze(files)
|
|
490
|
-
});
|
|
491
|
-
} catch (error) {
|
|
492
|
-
try {
|
|
493
|
-
rmSync2(snapshotDirectory, { recursive: true, force: true });
|
|
494
|
-
} catch {
|
|
495
|
-
}
|
|
496
|
-
throw error;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
function resolveBundledFonts() {
|
|
500
|
-
if (cachedBundledFonts) return cachedBundledFonts;
|
|
501
|
-
const here = typeof import.meta.url === "string" ? fileURLToPath(import.meta.url) : __filename;
|
|
502
|
-
let dir = dirname2(here);
|
|
503
|
-
for (let i = 0; i < 6; i++) {
|
|
504
|
-
const candidate = join4(dir, "assets", "fonts");
|
|
505
|
-
if (existsSync(candidate)) {
|
|
506
|
-
const verified = new NodeResourceResolver(dir, RESOURCE_MANIFEST).verifyInstalled();
|
|
507
|
-
cachedBundledFonts = materializeVerifiedFontSnapshot(verified.resources);
|
|
508
|
-
break;
|
|
509
|
-
}
|
|
510
|
-
const parent = dirname2(dir);
|
|
511
|
-
if (parent === dir) break;
|
|
512
|
-
dir = parent;
|
|
513
|
-
}
|
|
514
|
-
if (!cachedBundledFonts) {
|
|
515
|
-
const embedded = verifyRegisteredEmbeddedFontResources(RESOURCE_MANIFEST);
|
|
516
|
-
if (embedded) cachedBundledFonts = materializeVerifiedFontSnapshot(embedded.resources);
|
|
517
|
-
}
|
|
518
|
-
if (!cachedBundledFonts) throw new Error("RESOURCE_MISSING: required bundled font manifest could not be located");
|
|
519
|
-
if (!cleanupRegistered) {
|
|
520
|
-
cleanupRegistered = true;
|
|
521
|
-
process.once("exit", () => {
|
|
522
|
-
try {
|
|
523
|
-
if (cachedBundledFonts) rmSync2(cachedBundledFonts.snapshotDirectory, { recursive: true, force: true });
|
|
524
|
-
} catch {
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
return cachedBundledFonts;
|
|
529
|
-
}
|
|
530
|
-
function renderMermaidPNG(input, opts = {}) {
|
|
531
|
-
return renderMermaidPNGWithReceipt(input, opts).png;
|
|
532
|
-
}
|
|
533
|
-
function renderMermaidPNGWithReceipt(input, opts = {}) {
|
|
534
|
-
return renderMermaidPNGWithReceiptForHost(input, opts, {});
|
|
535
|
-
}
|
|
536
|
-
function createMermaidPNGRenderer(hostOptions = {}) {
|
|
537
|
-
const backendPolicy = snapshotHostBackendPolicy(hostOptions.backendPolicy);
|
|
538
|
-
const host = Object.freeze({ ...backendPolicy ? { backendPolicy } : {} });
|
|
539
|
-
return Object.freeze({
|
|
540
|
-
renderMermaidPNG(input, opts = {}) {
|
|
541
|
-
return renderMermaidPNGWithReceiptForHost(input, opts, host).png;
|
|
542
|
-
},
|
|
543
|
-
renderMermaidPNGWithReceipt(input, opts = {}) {
|
|
544
|
-
return renderMermaidPNGWithReceiptForHost(input, opts, host);
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
function renderMermaidPNGWithReceiptForHost(input, opts, hostOptions) {
|
|
549
|
-
const preparedInput = prepareRenderInput(input);
|
|
550
|
-
const source = preparedInput.source;
|
|
551
|
-
const onWarning = opts.onWarning;
|
|
552
|
-
if (onWarning !== void 0 && typeof onWarning !== "function") {
|
|
553
|
-
throw new TypeError("PNG onWarning must be a function");
|
|
554
|
-
}
|
|
555
|
-
const outputOptions = projectNativePngOutputPolicyInput(opts);
|
|
556
|
-
const renderOptions = omitPngOutputOptions(opts);
|
|
557
|
-
const graphical = renderPngGraphicalProjection(
|
|
558
|
-
source,
|
|
559
|
-
renderOptions,
|
|
560
|
-
outputOptions,
|
|
561
|
-
{ backendPolicy: hostOptions.backendPolicy, expectedFamilyId: preparedInput.expectedFamilyId }
|
|
562
|
-
);
|
|
563
|
-
const outputPolicy = graphical.outputPolicy;
|
|
564
|
-
const svg = prepareSvgForPngRasterization(
|
|
565
|
-
inlineFontVarForRaster(graphical.svg),
|
|
566
|
-
graphical.rasterDimensions
|
|
567
|
-
);
|
|
568
|
-
const bundledFonts = resolveBundledFonts();
|
|
569
|
-
const emit = onWarning ?? ((w) => process.stderr.write(`agentic-mermaid renderMermaidPNG: warning ${w.code}: ${w.message}
|
|
570
|
-
`));
|
|
571
|
-
for (const warning of buildPngFontWarnings(findUncoveredScripts(
|
|
572
|
-
svg,
|
|
573
|
-
outputPolicy.fonts.callerDirectories,
|
|
574
|
-
bundledFonts.buffers
|
|
575
|
-
), { systemFontsMayCover: outputPolicy.fonts.loadSystemFonts })) emit(warning);
|
|
576
|
-
const resvgOpts = {
|
|
577
|
-
background: graphical.rasterBackground,
|
|
578
|
-
// The shared contract already projected and pinned exact integer root
|
|
579
|
-
// dimensions. Rendering at zoom 1 avoids resvg-specific ratio rounding.
|
|
580
|
-
fitTo: { mode: "zoom", value: 1 },
|
|
581
|
-
font: {
|
|
582
|
-
loadSystemFonts: outputPolicy.fonts.loadSystemFonts,
|
|
583
|
-
// These private files were materialized from the exact verified byte
|
|
584
|
-
// snapshots. Explicit caller directories remain a host-controlled input.
|
|
585
|
-
fontFiles: [...bundledFonts.files],
|
|
586
|
-
fontDirs: [...outputPolicy.fonts.callerDirectories],
|
|
587
|
-
// Inter is the metrics font: src/text-metrics.ts is calibrated for it
|
|
588
|
-
// and the SVG @import requests it, so rasterizing with anything else
|
|
589
|
-
// (DejaVu is ~14% wider) pushes long labels outside their measured
|
|
590
|
-
// boxes. resvg falls back per-glyph across every loaded font, so
|
|
591
|
-
// DejaVu still covers glyphs Inter lacks (arrows, math, Armenian, …).
|
|
592
|
-
defaultFontFamily: outputPolicy.fonts.defaultFamily
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
const resvg = new Resvg(svg, resvgOpts);
|
|
596
|
-
const png = applyPngColorProfile(resvg.render().asPng());
|
|
597
|
-
const actualDimensions = inspectPngDimensions(png);
|
|
598
|
-
if (actualDimensions.width !== graphical.rasterDimensions.width || actualDimensions.height !== graphical.rasterDimensions.height) {
|
|
599
|
-
throw new Error(
|
|
600
|
-
`native PNG rasterizer returned ${actualDimensions.width}\xD7${actualDimensions.height}; expected ${graphical.rasterDimensions.width}\xD7${graphical.rasterDimensions.height}`
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
return {
|
|
604
|
-
png: new Uint8Array(png.buffer, png.byteOffset, png.byteLength),
|
|
605
|
-
receipt: graphical.receipt,
|
|
606
|
-
runtime: pngNapiRuntimeProvenance(outputPolicy.fonts)
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
export {
|
|
611
|
-
renderMermaidPNG,
|
|
612
|
-
renderMermaidPNGWithReceipt,
|
|
613
|
-
createMermaidPNGRenderer
|
|
614
|
-
};
|
|
615
|
-
//# sourceMappingURL=chunk-IVD4NXNE.js.map
|
package/dist/chunk-JDMRPUAG.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AsciiWidthError,
|
|
3
|
-
MermaidFamilyDetectionError
|
|
4
|
-
} from "./chunk-LCGBT32P.js";
|
|
5
|
-
|
|
6
|
-
// src/render-error-diagnostic.ts
|
|
7
|
-
function projectKnownRenderErrorDiagnostic(error) {
|
|
8
|
-
if (error instanceof MermaidFamilyDetectionError) {
|
|
9
|
-
return {
|
|
10
|
-
code: error.code,
|
|
11
|
-
message: error.message,
|
|
12
|
-
line: error.line,
|
|
13
|
-
preservation: error.preservation,
|
|
14
|
-
help: error.help
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
if (error instanceof AsciiWidthError) {
|
|
18
|
-
return {
|
|
19
|
-
code: error.code,
|
|
20
|
-
message: error.message,
|
|
21
|
-
requestedWidth: error.requestedWidth,
|
|
22
|
-
requiredWidth: error.requiredWidth,
|
|
23
|
-
family: error.family,
|
|
24
|
-
reason: error.reason
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
return void 0;
|
|
28
|
-
}
|
|
29
|
-
function projectRenderErrorDiagnostic(error) {
|
|
30
|
-
return projectKnownRenderErrorDiagnostic(error) ?? { code: "RENDER_FAILED", message: "Rendering failed" };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
projectKnownRenderErrorDiagnostic,
|
|
35
|
-
projectRenderErrorDiagnostic
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=chunk-JDMRPUAG.js.map
|