yuhwa 1.0.2 → 1.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.
Files changed (51) hide show
  1. package/README.md +13 -12
  2. package/client.d.ts +9 -1
  3. package/dist/astro.d.ts +2 -2
  4. package/dist/astro.js +8 -1
  5. package/dist/browser.d.ts +11 -5
  6. package/dist/browser.js +27 -7
  7. package/dist/cli.js +612 -49
  8. package/dist/editor/assets/index-BphHLTvA.js +689 -0
  9. package/dist/editor/assets/lsp.worker-sZtzIA6-.js +30 -0
  10. package/dist/editor/index.html +5 -4
  11. package/dist/figure-CA2hy0xh.d.ts +48 -0
  12. package/dist/{index-Dl845tUQ.d.ts → index-CnnoZYl0.d.ts} +76 -7
  13. package/dist/index.d.ts +2 -2
  14. package/dist/index.js +1 -1
  15. package/dist/ironmark.d.ts +4 -2
  16. package/dist/ironmark.js +18 -7
  17. package/dist/llms.txt +26 -17
  18. package/dist/lsp-browser.d.ts +2 -2
  19. package/dist/lsp-browser.js +1 -1
  20. package/dist/lsp-node.js +208 -212
  21. package/dist/lsp-server.d.ts +1 -1
  22. package/dist/lsp-server.js +1 -1
  23. package/dist/lsp.d.ts +44 -2
  24. package/dist/lsp.js +1 -1
  25. package/dist/markdown-it.d.ts +2 -1
  26. package/dist/markdown-it.js +7 -6
  27. package/dist/node-Bzn2uKXZ.js +224 -0
  28. package/dist/remark.d.ts +2 -1
  29. package/dist/remark.js +16 -5
  30. package/dist/{server-DJC_fQMe.d.ts → server--jHjJjOS.d.ts} +2 -2
  31. package/dist/{server-DmQuHQrG.js → server-Dxo7OG8K.js} +19 -2
  32. package/dist/{service-BYS9Qfkq.js → service-B1fpOg_L.js} +348 -44
  33. package/dist/{service-ClZ8clSQ.d.ts → service-Brvpt7Do.d.ts} +3 -1
  34. package/dist/{shared-qo_r6RUN.js → shared-Ddw88O9D.js} +3069 -742
  35. package/dist/{src-wk7tBpWs.js → src-DkQj7aIV.js} +2842 -744
  36. package/dist/style.css +14 -0
  37. package/dist/vite.d.ts +1 -1
  38. package/dist/vite.js +19 -12
  39. package/dist/vuepress.d.ts +3 -1
  40. package/dist/vuepress.js +7 -2
  41. package/dist/yuhwa.iife.js +91 -75
  42. package/dist/zoom-CCSUbX1X.d.ts +49 -0
  43. package/dist/zoom-QeqB6QlH.js +275 -0
  44. package/dist/zoom-script-CVdAzMhX.js +51 -0
  45. package/dist/zoom.d.ts +35 -0
  46. package/dist/zoom.js +19 -0
  47. package/package.json +10 -2
  48. package/dist/editor/assets/index-BQLsumas.js +0 -587
  49. package/dist/editor/assets/lsp.worker-RlPj9blG.js +0 -26
  50. package/dist/figure-BZHIKnxv.d.ts +0 -27
  51. package/dist/node-Bneu5eJV.js +0 -108
@@ -1,27 +0,0 @@
1
- import { n as Options } from "./index-Dl845tUQ.js";
2
- interface YuhwaDocsOptions extends Omit<Options, "theme" | "file"> {
3
- /** theme for light mode (default `paper`) */
4
- theme?: string;
5
- /**
6
- * theme for dark mode (default `midnight`); `false` renders one image only.
7
- * A block that sets `theme:` itself always renders one image.
8
- */
9
- darkTheme?: string | false;
10
- /**
11
- * How the dark image is picked:
12
- * - `class` (default): two images; `yuhwa/style.css` shows the one
13
- * matching the site's colour toggle (`.dark`, `[data-theme="dark"]` ...)
14
- * - `media`: a `<picture>` that follows the OS setting; needs no CSS
15
- */
16
- darkMode?: "class" | "media";
17
- /**
18
- * `svg` inlines the SVG instead of an `<img>` (markdown-it only; keeps
19
- * diagram text selectable and links clickable). Not for Vue-based sites.
20
- */
21
- output?: "img" | "svg";
22
- /** throw on errors and fail the build (default `true`); `false` shows them under the diagram */
23
- strict?: boolean;
24
- /** fence languages handled (default `['yuhwa']`) */
25
- languages?: string[];
26
- }
27
- export { YuhwaDocsOptions as t };
@@ -1,108 +0,0 @@
1
- import { W as isYuhwaPath, n as render } from "./src-wk7tBpWs.js";
2
- import { readFileSync } from "node:fs";
3
- // src/integrations/figure.ts
4
- /**
5
- * Shared core of the docs integrations (markdown-it, remark, Astro, VuePress):
6
- * renders one yuhwa source to a `<figure class="yuhwa">` as a hast tree, so
7
- * remark/MDX pipelines can use it directly and markdown-it gets it as HTML.
8
- *
9
- * Diagrams go in as `<img src="data:image/svg+xml,...">` by default: Vue-based
10
- * sites strip the SVG's `<style>`, MDX cannot take raw HTML, and diagram text
11
- * stays out of the site search index.
12
- */
13
- const el = (tagName, properties, children = []) => ({
14
- type: "element",
15
- tagName,
16
- properties,
17
- children
18
- });
19
- const dataUri = (svg) => `data:image/svg+xml,${encodeURIComponent(svg)}`;
20
- function errorMessage(errors, at) {
21
- return `yuhwa block at ${`${at.file ?? "markdown"}${at.line ? `:${at.line}` : ""}`}:\n${errors.map((d) => ` line ${d.line}: ${d.message}`).join("\n")}`;
22
- }
23
- function renderFigure(source, opts = {}, at = {}) {
24
- const { theme, darkTheme = "midnight", darkMode = "class", output = "img", strict = true, languages: _, ...rest } = opts;
25
- const base = {
26
- ...rest,
27
- file: at.file
28
- };
29
- const light = render(source, {
30
- ...base,
31
- theme
32
- });
33
- const errors = light.diagnostics.filter((d) => d.severity === "error");
34
- if (errors.length && strict) throw new Error(errorMessage(errors, at));
35
- const alt = light.diagram.settings.title ?? "diagram";
36
- const dark = darkTheme && !("theme" in light.diagram.settings) ? render(source, {
37
- ...base,
38
- theme: darkTheme
39
- }) : void 0;
40
- const children = [];
41
- const img = (svg, cls) => el("img", {
42
- src: dataUri(svg),
43
- alt,
44
- className: cls,
45
- loading: "lazy",
46
- decoding: "async"
47
- });
48
- const inline = (svg, cls) => el("div", { className: cls }, [{
49
- type: "text",
50
- value: svg
51
- }]);
52
- const one = output === "svg" ? inline : img;
53
- if (!dark) children.push(one(light.svg, ["yuhwa-svg"]));
54
- else if (darkMode === "media" && output === "img") children.push(el("picture", {}, [el("source", {
55
- media: "(prefers-color-scheme: dark)",
56
- srcSet: dataUri(dark.svg)
57
- }), img(light.svg, ["yuhwa-svg"])]));
58
- else children.push(one(light.svg, ["yuhwa-svg", "yuhwa-light"]), one(dark.svg, ["yuhwa-svg", "yuhwa-dark"]));
59
- if (errors.length) children.push(el("pre", { className: ["yuhwa-error"] }, [{
60
- type: "text",
61
- value: errorMessage(errors, at)
62
- }]));
63
- const hast = el("figure", {
64
- className: ["yuhwa"],
65
- dataYuhwa: ""
66
- }, children);
67
- return {
68
- hast,
69
- html: toHtml(hast, output === "svg"),
70
- result: light
71
- };
72
- }
73
- const ATTR = {
74
- className: "class",
75
- srcSet: "srcset",
76
- dataYuhwa: "data-yuhwa"
77
- };
78
- const escape = (s) => s.replace(/[&<>"]/g, (c) => ({
79
- "&": "&amp;",
80
- "<": "&lt;",
81
- ">": "&gt;",
82
- "\"": "&quot;"
83
- })[c]);
84
- const VOID = /* @__PURE__ */ new Set(["img", "source"]);
85
- /** minimal hast → HTML; with `raw`, text inside a `div` is the inline SVG and stays unescaped */
86
- function toHtml(node, raw, parent = "") {
87
- if (node.type === "text") return raw && parent === "div" ? node.value : escape(node.value);
88
- const attrs = Object.entries(node.properties).filter(([, v]) => v !== void 0 && v !== false).map(([k, v]) => ` ${ATTR[k] ?? k}${v === "" || v === true ? "" : `="${escape(Array.isArray(v) ? v.join(" ") : String(v))}"`}`).join("");
89
- if (VOID.has(node.tagName)) return `<${node.tagName}${attrs} />`;
90
- const inner = node.children.map((c) => toHtml(c, raw, node.tagName)).join("");
91
- return `<${node.tagName}${attrs}>${inner}</${node.tagName}>`;
92
- }
93
- /** `yuhwa no-render` (or any flag list) on a fence: leave it as a code block */
94
- function wantsRender(lang, meta, languages = ["yuhwa"]) {
95
- return !!lang && languages.includes(lang) && !/(^|\s)no-render(\s|$)/.test(meta ?? "");
96
- }
97
- // src/integrations/node.ts
98
- /** Node-only helper for the CLI and build-time integrations: `import` reads from disk. */
99
- /** Reads an `import "..."` target from disk; like `parse`, only `.yuhwa` files. */
100
- function diskResolve(path) {
101
- if (!isYuhwaPath(path)) return void 0;
102
- try {
103
- return readFileSync(path, "utf8");
104
- } catch {
105
- return;
106
- }
107
- }
108
- export { wantsRender as i, errorMessage as n, renderFigure as r, diskResolve as t };