yuhwa 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +5 -3
  2. package/dist/astro.d.ts +1 -1
  3. package/dist/astro.js +4 -3
  4. package/dist/browser.d.ts +10 -3
  5. package/dist/browser.js +85 -21
  6. package/dist/canvas.d.ts +2 -0
  7. package/dist/canvas.js +40 -0
  8. package/dist/cli.js +485 -236
  9. package/dist/editor/assets/index-DWm3xV_v.js +689 -0
  10. package/dist/editor/assets/{lsp.worker-sZtzIA6-.js → lsp.worker-N6A9m364.js} +23 -17
  11. package/dist/editor/index.html +4 -1
  12. package/dist/{figure-CA2hy0xh.d.ts → figure-BLHfxz_e.d.ts} +28 -5
  13. package/dist/index-xVW43gqW.d.ts +261 -0
  14. package/dist/index.d.ts +3 -2
  15. package/dist/index.js +5 -1
  16. package/dist/ironmark.d.ts +1 -1
  17. package/dist/ironmark.js +1 -1
  18. package/dist/lsp-browser.d.ts +2 -2
  19. package/dist/lsp-browser.js +2 -1
  20. package/dist/lsp-node.js +47 -27
  21. package/dist/lsp-server.d.ts +5 -1
  22. package/dist/lsp-server.js +1 -1
  23. package/dist/lsp.d.ts +1 -1
  24. package/dist/lsp.js +1 -1
  25. package/dist/markdown-it.d.ts +1 -1
  26. package/dist/markdown-it.js +5 -3
  27. package/dist/{node-Bzn2uKXZ.js → node-CkrQnPFb.js} +90 -12
  28. package/dist/parse--ljBMU60.js +3884 -0
  29. package/dist/plugin-CitzbblK.js +301 -0
  30. package/dist/{index-CnnoZYl0.d.ts → plugin-NMP_uf1a.d.ts} +93 -208
  31. package/dist/plugin.d.ts +12 -0
  32. package/dist/plugin.js +3 -0
  33. package/dist/raster-iqi6XRPU.js +299 -0
  34. package/dist/remark.d.ts +1 -1
  35. package/dist/remark.js +1 -1
  36. package/dist/rolldown-runtime-CEjnN5Q1.js +37 -0
  37. package/dist/{server-Dxo7OG8K.js → server-BTYtmr6B.js} +41 -63
  38. package/dist/{server--jHjJjOS.d.ts → server-DMAOtqqK.d.ts} +1 -1
  39. package/dist/{service-B1fpOg_L.js → service-C60VdeKS.js} +35 -3
  40. package/dist/{service-Brvpt7Do.d.ts → service-DimTFsE3.d.ts} +2 -0
  41. package/dist/{shared-Ddw88O9D.js → shared-h8tkFLY4.js} +719 -421
  42. package/dist/{src-DkQj7aIV.js → src-NCXCTK_4.js} +512 -4548
  43. package/dist/svg-uri-Dx8SGV-n.js +7 -0
  44. package/dist/vite.d.ts +1 -1
  45. package/dist/vite.js +3 -2
  46. package/dist/vuepress.d.ts +3 -2
  47. package/dist/vuepress.js +4 -2
  48. package/dist/watch-2VeW5DUN.js +35 -0
  49. package/dist/yuhwa.iife.js +55 -54
  50. package/dist/zoom-script-CaJ5MNUw.js +29 -0
  51. package/dist/{zoom-QeqB6QlH.js → zoom-yxhxX16c.js} +1 -1
  52. package/dist/zoom.d.ts +16 -7
  53. package/dist/zoom.js +2 -2
  54. package/package.json +24 -2
  55. package/skills/yuhwa/SKILL.md +12 -0
  56. package/dist/editor/assets/index-BphHLTvA.js +0 -689
  57. package/dist/zoom-script-CVdAzMhX.js +0 -51
@@ -0,0 +1,7 @@
1
+ // src/svg-uri.ts
2
+ const PREFIX = "data:image/svg+xml,";
3
+ /** the SVG as a `data:` URI, for an `<img src>` */
4
+ const svgDataUri = (svg) => PREFIX + encodeURIComponent(svg);
5
+ /** the SVG inside a URI made by `svgDataUri`, or `undefined` for any other URI */
6
+ const svgFromDataUri = (uri) => uri.startsWith(PREFIX) ? decodeURIComponent(uri.slice(19)) : void 0;
7
+ export { svgFromDataUri as n, svgDataUri as t };
package/dist/vite.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as YuhwaDocsOptions } from "./figure-CA2hy0xh.js";
1
+ import { t as YuhwaDocsOptions } from "./figure-BLHfxz_e.js";
2
2
  interface PluginContext {
3
3
  addWatchFile: (id: string) => void;
4
4
  error: (msg: string) => never;
package/dist/vite.js CHANGED
@@ -1,6 +1,7 @@
1
+ import { s as isYuhwaPath } from "./parse--ljBMU60.js";
1
2
  import { readFileSync } from "node:fs";
2
- import { r as errorMessage, t as diskResolve } from "./node-Bzn2uKXZ.js";
3
- import { K as isYuhwaPath, n as render } from "./src-DkQj7aIV.js";
3
+ import { i as errorMessage, t as diskResolve } from "./node-CkrQnPFb.js";
4
+ import { n as render } from "./src-NCXCTK_4.js";
4
5
  // src/integrations/vite.ts
5
6
  /**
6
7
  * Vite plugin: `import diagram from './arch.yu'` gives the rendered SVG
@@ -5,10 +5,11 @@
5
5
  * import { yuhwaPlugin } from 'yuhwa/vuepress';
6
6
  * export default defineUserConfig({ plugins: [yuhwaPlugin()] });
7
7
  *
8
- * `yuhwaPlugin({ zoom: true })` also loads the pan and zoom script.
8
+ * `yuhwaPlugin({ zoom: true })` also loads the pan and zoom script. The
9
+ * canvas script always loads, for `output=canvas` fences.
9
10
  */
10
11
  import yuhwaMarkdownIt from "./markdown-it.js";
11
- import { t as YuhwaDocsOptions } from "./figure-CA2hy0xh.js";
12
+ import { t as YuhwaDocsOptions } from "./figure-BLHfxz_e.js";
12
13
  interface App {
13
14
  writeTemp: (file: string, content: string) => Promise<string>;
14
15
  }
package/dist/vuepress.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import yuhwaMarkdownIt from "./markdown-it.js";
2
+ import { r as clientImports } from "./node-CkrQnPFb.js";
2
3
  // src/integrations/vuepress.ts
3
4
  /**
4
5
  * VuePress 2 plugin: renders ```yuhwa fences and adds the light/dark stylesheet.
@@ -7,7 +8,8 @@ import yuhwaMarkdownIt from "./markdown-it.js";
7
8
  * import { yuhwaPlugin } from 'yuhwa/vuepress';
8
9
  * export default defineUserConfig({ plugins: [yuhwaPlugin()] });
9
10
  *
10
- * `yuhwaPlugin({ zoom: true })` also loads the pan and zoom script.
11
+ * `yuhwaPlugin({ zoom: true })` also loads the pan and zoom script. The
12
+ * canvas script always loads, for `output=canvas` fences.
11
13
  */
12
14
  function yuhwaPlugin(opts = {}) {
13
15
  return {
@@ -16,7 +18,7 @@ function yuhwaPlugin(opts = {}) {
16
18
  ...opts,
17
19
  zoom: true
18
20
  } : opts),
19
- clientConfigFile: (app) => app.writeTemp("yuhwa/client.js", `import 'yuhwa/style.css';\n${opts.zoom ? `import 'yuhwa/zoom';\n` : ""}export default {};\n`)
21
+ clientConfigFile: (app) => app.writeTemp("yuhwa/client.js", clientImports(opts).map((m) => `import '${m}';\n`).join("") + "export default {};\n")
20
22
  };
21
23
  }
22
24
  export { yuhwaPlugin as default, yuhwaPlugin };
@@ -0,0 +1,35 @@
1
+ // src/integrations/watch.ts
2
+ /**
3
+ * Runs `attach` once the page is parsed, and again (batched to one frame)
4
+ * whenever elements are added, the page loads or comes back from the
5
+ * back/forward cache. Client-side navigation and hydration bring new figures
6
+ * this way. It watches `document`, not `<html>`, because hydration can replace
7
+ * the `<html>` element. `flag` on `window` makes a second install a no-op.
8
+ *
9
+ * Self-contained: `zoomScript` inlines its source, so it may not use imports.
10
+ */
11
+ function watchFigures(flag, attach) {
12
+ const w = window;
13
+ if (w[flag]) return;
14
+ w[flag] = true;
15
+ let queued = false;
16
+ const later = () => {
17
+ if (queued) return;
18
+ queued = true;
19
+ requestAnimationFrame(() => {
20
+ queued = false;
21
+ attach();
22
+ });
23
+ };
24
+ if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", attach, { once: true });
25
+ else attach();
26
+ addEventListener("load", later);
27
+ addEventListener("pageshow", later);
28
+ new MutationObserver((records) => {
29
+ if (records.some((r) => [...r.addedNodes].some((n) => n.nodeType === 1))) later();
30
+ }).observe(document, {
31
+ childList: true,
32
+ subtree: true
33
+ });
34
+ }
35
+ export { watchFigures as t };