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
package/dist/style.css CHANGED
@@ -46,3 +46,17 @@ figure.yuhwa .yuhwa-error {
46
46
  background: rgba(239, 68, 68, 0.08);
47
47
  border-radius: 6px;
48
48
  }
49
+
50
+ /* pan and zoom (`zoom` option and `yuhwa/zoom`): a framed viewer, full screen follows the site's colours */
51
+ figure.yuhwa .yuhwa-view {
52
+ border: 1px solid rgb(128 128 128 / 0.25);
53
+ border-radius: 8px;
54
+ }
55
+ :is(.dark, [data-theme='dark'], [data-mode='dark'], .theme-dark) figure.yuhwa .yuhwa-view {
56
+ color-scheme: dark;
57
+ }
58
+ @media (prefers-color-scheme: dark) {
59
+ :root:not(.light):not(.dark):not([data-theme]):not([data-mode]) figure.yuhwa .yuhwa-view {
60
+ color-scheme: dark;
61
+ }
62
+ }
package/dist/vite.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as YuhwaDocsOptions } from "./figure-BZHIKnxv.js";
1
+ import { t as YuhwaDocsOptions } from "./figure-CA2hy0xh.js";
2
2
  interface PluginContext {
3
3
  addWatchFile: (id: string) => void;
4
4
  error: (msg: string) => never;
package/dist/vite.js CHANGED
@@ -1,17 +1,18 @@
1
1
  import { readFileSync } from "node:fs";
2
- import { n as errorMessage, t as diskResolve } from "./node-Bneu5eJV.js";
3
- import { n as render } from "./src-wk7tBpWs.js";
2
+ import { r as errorMessage, t as diskResolve } from "./node-Bzn2uKXZ.js";
3
+ import { K as isYuhwaPath, n as render } from "./src-DkQj7aIV.js";
4
4
  // src/integrations/vite.ts
5
5
  /**
6
- * Vite plugin: `import diagram from './arch.yuhwa'` gives the rendered SVG
6
+ * Vite plugin: `import diagram from './arch.yu'` gives the rendered SVG
7
7
  * string, for apps (React, Vue, Svelte ...) and Vite-based docs sites.
8
8
  *
9
9
  * import yuhwa from 'yuhwa/vite';
10
10
  * export default defineConfig({ plugins: [yuhwa({ theme: 'midnight' })] });
11
11
  *
12
- * import svg, { source, darkSvg } from './arch.yuhwa';
12
+ * import svg, { source, darkSvg } from './arch.yu';
13
13
  *
14
- * Errors fail the build; imported .yuhwa files are watched.
14
+ * Errors fail the build; imported .yu files are watched. A diagram that sets
15
+ * `theme:` itself gets the same SVG as `darkSvg`.
15
16
  */
16
17
  function yuhwaVite(opts = {}) {
17
18
  return {
@@ -19,7 +20,7 @@ function yuhwaVite(opts = {}) {
19
20
  enforce: "pre",
20
21
  load(id) {
21
22
  const [path] = id.split("?");
22
- if (!path.endsWith(".yuhwa")) return null;
23
+ if (!isYuhwaPath(path)) return null;
23
24
  const source = readFileSync(path, "utf8");
24
25
  const cache = /* @__PURE__ */ new Map();
25
26
  const resolve = (p) => {
@@ -37,12 +38,18 @@ function yuhwaVite(opts = {}) {
37
38
  });
38
39
  const errors = r.diagnostics.filter((d) => d.severity === "error");
39
40
  if (errors.length) this.error(errorMessage(errors, { file: path }));
40
- const dark = opts.darkTheme === false ? r.svg : render(source, {
41
- theme: opts.darkTheme ?? "midnight",
42
- measure: opts.measure,
43
- file: path,
44
- resolve
45
- }).svg;
41
+ let dark = r.svg;
42
+ if (opts.darkTheme !== false && !("theme" in r.diagram.settings)) {
43
+ const d = render(source, {
44
+ theme: opts.darkTheme ?? "midnight",
45
+ measure: opts.measure,
46
+ file: path,
47
+ resolve
48
+ });
49
+ const darkErrors = d.diagnostics.filter((x) => x.severity === "error");
50
+ if (darkErrors.length) this.error(errorMessage(darkErrors, { file: `${path} (dark)` }));
51
+ dark = d.svg;
52
+ }
46
53
  return [
47
54
  `export default ${JSON.stringify(r.svg)};`,
48
55
  `export const darkSvg = ${JSON.stringify(dark)};`,
@@ -4,9 +4,11 @@
4
4
  * // .vuepress/config.ts
5
5
  * import { yuhwaPlugin } from 'yuhwa/vuepress';
6
6
  * export default defineUserConfig({ plugins: [yuhwaPlugin()] });
7
+ *
8
+ * `yuhwaPlugin({ zoom: true })` also loads the pan and zoom script.
7
9
  */
8
10
  import yuhwaMarkdownIt from "./markdown-it.js";
9
- import { t as YuhwaDocsOptions } from "./figure-BZHIKnxv.js";
11
+ import { t as YuhwaDocsOptions } from "./figure-CA2hy0xh.js";
10
12
  interface App {
11
13
  writeTemp: (file: string, content: string) => Promise<string>;
12
14
  }
package/dist/vuepress.js CHANGED
@@ -6,12 +6,17 @@ import yuhwaMarkdownIt from "./markdown-it.js";
6
6
  * // .vuepress/config.ts
7
7
  * import { yuhwaPlugin } from 'yuhwa/vuepress';
8
8
  * export default defineUserConfig({ plugins: [yuhwaPlugin()] });
9
+ *
10
+ * `yuhwaPlugin({ zoom: true })` also loads the pan and zoom script.
9
11
  */
10
12
  function yuhwaPlugin(opts = {}) {
11
13
  return {
12
14
  name: "yuhwa",
13
- extendsMarkdown: (md) => yuhwaMarkdownIt(md, opts),
14
- clientConfigFile: (app) => app.writeTemp("yuhwa/client.js", `import 'yuhwa/style.css';\nexport default {};\n`)
15
+ extendsMarkdown: (md) => yuhwaMarkdownIt(md, opts.zoom ? {
16
+ ...opts,
17
+ zoom: true
18
+ } : opts),
19
+ clientConfigFile: (app) => app.writeTemp("yuhwa/client.js", `import 'yuhwa/style.css';\n${opts.zoom ? `import 'yuhwa/zoom';\n` : ""}export default {};\n`)
15
20
  };
16
21
  }
17
22
  export { yuhwaPlugin as default, yuhwaPlugin };