paseo-ratex-markdown 0.1.2 → 0.1.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.
Files changed (105) hide show
  1. package/OVERVIEW.md +1 -1
  2. package/README.md +34 -20
  3. package/npm-shrinkwrap.json +8 -10
  4. package/package.json +5 -7
  5. package/scripts/embed-assets.mjs +39 -4
  6. package/scripts/prepare-plugin.mjs +5 -6
  7. package/server/ratex.ts +2 -2
  8. package/server/scene.ts +1 -1
  9. package/{node_modules/ratex-wasm/dist/types.d.ts → server/vendor/ratex-types.d.ts} +2 -0
  10. package/{node_modules/ratex-wasm/pkg → server/vendor}/ratex_wasm.d.ts +2 -0
  11. package/{node_modules/ratex-wasm/pkg → server/vendor}/ratex_wasm.js +2 -0
  12. package/node_modules/opentype.js/LICENSE +0 -20
  13. package/node_modules/opentype.js/README.md +0 -577
  14. package/node_modules/opentype.js/bin/ot +0 -84
  15. package/node_modules/opentype.js/dist/opentype.js +0 -16333
  16. package/node_modules/opentype.js/dist/opentype.min.js +0 -4
  17. package/node_modules/opentype.js/dist/opentype.min.js.map +0 -7
  18. package/node_modules/opentype.js/dist/opentype.min.mjs +0 -3
  19. package/node_modules/opentype.js/dist/opentype.min.mjs.map +0 -7
  20. package/node_modules/opentype.js/dist/opentype.mjs +0 -16308
  21. package/node_modules/opentype.js/package.json +0 -51
  22. package/node_modules/ratex-wasm/LICENSE +0 -85
  23. package/node_modules/ratex-wasm/README.md +0 -92
  24. package/node_modules/ratex-wasm/README.zh-CN.md +0 -99
  25. package/node_modules/ratex-wasm/dist/index.d.ts +0 -68
  26. package/node_modules/ratex-wasm/dist/index.d.ts.map +0 -1
  27. package/node_modules/ratex-wasm/dist/index.js +0 -145
  28. package/node_modules/ratex-wasm/dist/ratex-formula.d.ts +0 -31
  29. package/node_modules/ratex-wasm/dist/ratex-formula.d.ts.map +0 -1
  30. package/node_modules/ratex-wasm/dist/ratex-formula.js +0 -135
  31. package/node_modules/ratex-wasm/dist/renderer.d.ts +0 -21
  32. package/node_modules/ratex-wasm/dist/renderer.d.ts.map +0 -1
  33. package/node_modules/ratex-wasm/dist/renderer.js +0 -169
  34. package/node_modules/ratex-wasm/dist/types.d.ts.map +0 -1
  35. package/node_modules/ratex-wasm/dist/types.js +0 -5
  36. package/node_modules/ratex-wasm/fonts/KaTeX_AMS-Regular.ttf +0 -0
  37. package/node_modules/ratex-wasm/fonts/KaTeX_AMS-Regular.woff +0 -0
  38. package/node_modules/ratex-wasm/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  39. package/node_modules/ratex-wasm/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  40. package/node_modules/ratex-wasm/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  41. package/node_modules/ratex-wasm/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  42. package/node_modules/ratex-wasm/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  43. package/node_modules/ratex-wasm/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  44. package/node_modules/ratex-wasm/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  45. package/node_modules/ratex-wasm/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  46. package/node_modules/ratex-wasm/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  47. package/node_modules/ratex-wasm/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  48. package/node_modules/ratex-wasm/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  49. package/node_modules/ratex-wasm/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  50. package/node_modules/ratex-wasm/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  51. package/node_modules/ratex-wasm/fonts/KaTeX_Main-Bold.ttf +0 -0
  52. package/node_modules/ratex-wasm/fonts/KaTeX_Main-Bold.woff +0 -0
  53. package/node_modules/ratex-wasm/fonts/KaTeX_Main-Bold.woff2 +0 -0
  54. package/node_modules/ratex-wasm/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  55. package/node_modules/ratex-wasm/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  56. package/node_modules/ratex-wasm/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  57. package/node_modules/ratex-wasm/fonts/KaTeX_Main-Italic.ttf +0 -0
  58. package/node_modules/ratex-wasm/fonts/KaTeX_Main-Italic.woff +0 -0
  59. package/node_modules/ratex-wasm/fonts/KaTeX_Main-Italic.woff2 +0 -0
  60. package/node_modules/ratex-wasm/fonts/KaTeX_Main-Regular.ttf +0 -0
  61. package/node_modules/ratex-wasm/fonts/KaTeX_Main-Regular.woff +0 -0
  62. package/node_modules/ratex-wasm/fonts/KaTeX_Main-Regular.woff2 +0 -0
  63. package/node_modules/ratex-wasm/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  64. package/node_modules/ratex-wasm/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  65. package/node_modules/ratex-wasm/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  66. package/node_modules/ratex-wasm/fonts/KaTeX_Math-Italic.ttf +0 -0
  67. package/node_modules/ratex-wasm/fonts/KaTeX_Math-Italic.woff +0 -0
  68. package/node_modules/ratex-wasm/fonts/KaTeX_Math-Italic.woff2 +0 -0
  69. package/node_modules/ratex-wasm/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  70. package/node_modules/ratex-wasm/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  71. package/node_modules/ratex-wasm/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  72. package/node_modules/ratex-wasm/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  73. package/node_modules/ratex-wasm/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  74. package/node_modules/ratex-wasm/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  75. package/node_modules/ratex-wasm/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  76. package/node_modules/ratex-wasm/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  77. package/node_modules/ratex-wasm/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  78. package/node_modules/ratex-wasm/fonts/KaTeX_Script-Regular.ttf +0 -0
  79. package/node_modules/ratex-wasm/fonts/KaTeX_Script-Regular.woff +0 -0
  80. package/node_modules/ratex-wasm/fonts/KaTeX_Script-Regular.woff2 +0 -0
  81. package/node_modules/ratex-wasm/fonts/KaTeX_Size1-Regular.ttf +0 -0
  82. package/node_modules/ratex-wasm/fonts/KaTeX_Size1-Regular.woff +0 -0
  83. package/node_modules/ratex-wasm/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  84. package/node_modules/ratex-wasm/fonts/KaTeX_Size2-Regular.ttf +0 -0
  85. package/node_modules/ratex-wasm/fonts/KaTeX_Size2-Regular.woff +0 -0
  86. package/node_modules/ratex-wasm/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  87. package/node_modules/ratex-wasm/fonts/KaTeX_Size3-Regular.ttf +0 -0
  88. package/node_modules/ratex-wasm/fonts/KaTeX_Size3-Regular.woff +0 -0
  89. package/node_modules/ratex-wasm/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  90. package/node_modules/ratex-wasm/fonts/KaTeX_Size4-Regular.ttf +0 -0
  91. package/node_modules/ratex-wasm/fonts/KaTeX_Size4-Regular.woff +0 -0
  92. package/node_modules/ratex-wasm/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  93. package/node_modules/ratex-wasm/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  94. package/node_modules/ratex-wasm/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  95. package/node_modules/ratex-wasm/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  96. package/node_modules/ratex-wasm/fonts.css +0 -126
  97. package/node_modules/ratex-wasm/package.json +0 -50
  98. package/node_modules/ratex-wasm/pkg/LICENSE +0 -22
  99. package/node_modules/ratex-wasm/pkg/package.json +0 -22
  100. package/node_modules/ratex-wasm/pkg/ratex_wasm_bg.wasm +0 -0
  101. package/node_modules/ratex-wasm/pkg/ratex_wasm_bg.wasm.d.ts +0 -10
  102. package/node_modules/ratex-wasm/src/index.ts +0 -223
  103. package/node_modules/ratex-wasm/src/ratex-formula.ts +0 -154
  104. package/node_modules/ratex-wasm/src/renderer.ts +0 -204
  105. package/node_modules/ratex-wasm/src/types.ts +0 -79
package/OVERVIEW.md CHANGED
@@ -10,7 +10,7 @@ The daemon lays out each formula with the bundled `ratex-wasm` module and uses e
10
10
 
11
11
  ## Setup and requirements
12
12
 
13
- Paseo 0.11.0 or later. Installing from npm or Git needs Node.js and npm on the daemon host. The npm package includes its embedded math engine and glyph outlines; a Git installation prepares them from locked dependencies.
13
+ Paseo 0.11.0 or later. Installing from npm or Git needs Node.js and npm on the daemon host. The npm package and the repository both include the embedded math engine and glyph outlines; a Git installation only installs the locked Markdown parser.
14
14
 
15
15
  Desktop and web clients render formulas. iOS and Android clients render them where Paseo draws inline SVG icons (0.13 and later) and show the TeX source otherwise.
16
16
 
package/README.md CHANGED
@@ -23,22 +23,6 @@ Open Markdown files in [Paseo](https://paseo.sh) with their LaTeX math typeset b
23
23
  | --- | --- |
24
24
  | ![The same document in the light theme](assets/screenshot-light.png) | ![The document on a narrow screen](assets/screenshot-compact.png) |
25
25
 
26
- ## How it opens Markdown
27
-
28
- Paseo's plugin API decides where the plugin can draw:
29
-
30
- - **Paseo 0.13 and later** ([file panels](https://github.com/getpaseo/paseo/pull/7411), merged
31
- after 0.12.0): opening a
32
- `.md` or `.markdown` file offers **Markdown (RaTeX)** next to Paseo's own Markdown and Source
33
- panels. Pick it and check **Don't ask me again** to make it the default for Markdown files.
34
- - **Paseo 0.11 and 0.12**: open a Markdown file, press <kbd>⌘K</kbd> / <kbd>Ctrl+K</kbd> and
35
- run **Open Markdown preview (RaTeX)**: the panel shows that file, and running the command again
36
- from another Markdown file switches it. Run from any other tab, the panel lists the workspace's
37
- Markdown files; pick one to read it. Relative links to other Markdown files open in the same
38
- panel.
39
-
40
- The plugin detects file panel support at runtime, so the same release works on both.
41
-
42
26
  ## Requirements
43
27
 
44
28
  | Component | Requirement |
@@ -59,7 +43,7 @@ paseo plugin install npm:paseo-ratex-markdown
59
43
  paseo plugin ls
60
44
  ```
61
45
 
62
- From GitHub (the daemon runs `npm ci` and generates the embedded assets during installation):
46
+ From GitHub (the daemon installs the locked Markdown parser with `npm ci` during installation):
63
47
 
64
48
  ```bash
65
49
  paseo plugin add git:ZedRover/paseo-ratex-markdown
@@ -69,6 +53,33 @@ You can also paste either source into **Settings → Plugins → Plugin source**
69
53
  the npm package and the repository share one name: update with
70
54
  `paseo plugin update paseo-ratex-markdown`.
71
55
 
56
+ ## Usage
57
+
58
+ Paseo's plugin API decides where the plugin can draw. The plugin detects file panel support at
59
+ runtime, so the same release works on every version below.
60
+
61
+ ### Paseo 0.11 and 0.12
62
+
63
+ 1. Open a `.md` or `.markdown` file in the workspace.
64
+ 2. Press <kbd>⌘K</kbd> / <kbd>Ctrl+K</kbd> and run **Open Markdown preview (RaTeX)**.
65
+ 3. A **Markdown (RaTeX)** tab opens in the same pane and shows that file with its math typeset.
66
+
67
+ Run the command again from another Markdown tab to switch the preview to that file. Run from any
68
+ other tab, the preview lists the workspace's Markdown files instead; pick one to read it. iOS and
69
+ Android always start from this list.
70
+
71
+ In the preview, the file name at the top opens the list again with a filter, and the reload button
72
+ reads the file again. Relative links to other Markdown files open in the same preview.
73
+
74
+ ### Paseo 0.13 and later
75
+
76
+ These releases add [file panels](https://github.com/getpaseo/paseo/pull/7411), merged after 0.12.0.
77
+
78
+ 1. Open a `.md` or `.markdown` file. Paseo offers **Markdown (RaTeX)** next to its own Markdown
79
+ and Source panels.
80
+ 2. Pick **Markdown (RaTeX)**. Check **Don't ask me again** to make it the default for Markdown
81
+ files.
82
+
72
83
  ## Math syntax
73
84
 
74
85
  | Written as | Renders as |
@@ -102,8 +113,11 @@ Markdown text ──► markdown-it + math rules (client) ──► document tre
102
113
  ```
103
114
 
104
115
  The daemon half embeds the `ratex-wasm` binary and KaTeX glyph outlines, so nothing is fetched at
105
- runtime. During preparation, opentype.js extracts the outlines from the pinned fonts; the
106
- runtime reads those paths directly without a font parser. Its SVG output matches RaTeX's own
116
+ runtime. `npm run prepare` generates them in `server/vendor` from the pinned `ratex-wasm`
117
+ package, with opentype.js extracting the outlines from its fonts; the runtime reads those paths
118
+ directly without a font parser. The generated files are committed, and CI fails when they no
119
+ longer match the pinned package, so neither the npm package nor a Git installation carries
120
+ `ratex-wasm` itself. Its SVG output matches RaTeX's own
107
121
  `ratex-svg` renderer pixel for pixel on the test formulas. Layouts are cached on both sides,
108
122
  so a theme change repaints without new requests,
109
123
  and an edit only lays out the formulas that changed.
@@ -137,7 +151,7 @@ and an edit only lays out the formulas that changed.
137
151
  ## Development
138
152
 
139
153
  ```bash
140
- npm ci # installs dependencies and embeds the RaTeX assets (npm run prepare)
154
+ npm ci # installs dependencies; npm run prepare refreshes server/vendor
141
155
  npm run typecheck
142
156
  npm test
143
157
  paseo plugin install "$PWD" # try it on your local daemon
@@ -1,30 +1,28 @@
1
1
  {
2
2
  "name": "paseo-ratex-markdown",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "paseo-ratex-markdown",
9
- "version": "0.1.2",
9
+ "version": "0.1.3",
10
10
  "bundleDependencies": [
11
11
  "markdown-it",
12
- "markdown-it-footnote",
13
- "opentype.js",
14
- "ratex-wasm"
12
+ "markdown-it-footnote"
15
13
  ],
16
14
  "license": "MIT",
17
15
  "dependencies": {
18
16
  "markdown-it": "15.0.3",
19
- "markdown-it-footnote": "4.0.0",
20
- "opentype.js": "2.0.0",
21
- "ratex-wasm": "0.1.15"
17
+ "markdown-it-footnote": "4.0.0"
22
18
  },
23
19
  "devDependencies": {
24
20
  "@getpaseo/plugin": "0.11.2",
25
21
  "@tanstack/react-query": "^5.90.11",
26
22
  "@types/node": "^22.19.0",
27
23
  "@types/react": "~19.2.0",
24
+ "opentype.js": "2.0.0",
25
+ "ratex-wasm": "0.1.15",
28
26
  "react": "19.1.0",
29
27
  "react-native": "0.81.5",
30
28
  "typescript": "^5.9.3",
@@ -3169,7 +3167,7 @@
3169
3167
  "version": "2.0.0",
3170
3168
  "resolved": "https://registry.npmjs.org/opentype.js/-/opentype.js-2.0.0.tgz",
3171
3169
  "integrity": "sha512-kCyjv6xdDY1W/jLWZ/L3QhhTlKUqDZMQ5+Jdlw12b3dXkKNpYBqqlMMj0YDQPShWFTMwgZI1hG14kN3XUDSg/A==",
3172
- "inBundle": true,
3170
+ "dev": true,
3173
3171
  "license": "MIT",
3174
3172
  "bin": {
3175
3173
  "ot": "bin/ot"
@@ -3336,7 +3334,7 @@
3336
3334
  "version": "0.1.15",
3337
3335
  "resolved": "https://registry.npmjs.org/ratex-wasm/-/ratex-wasm-0.1.15.tgz",
3338
3336
  "integrity": "sha512-8+WuJFrx2l6dMVib07neaKnWlujQfXdLPatYX58/IiSy6BBZAIWP73DDfjzHZvi9PgU02YumsP6I78j7aMVw7w==",
3339
- "inBundle": true,
3337
+ "dev": true,
3340
3338
  "license": "MIT"
3341
3339
  },
3342
3340
  "node_modules/react": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-ratex-markdown",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Opens Markdown files in Paseo with LaTeX math typeset by RaTeX.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -48,21 +48,19 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "markdown-it": "15.0.3",
51
- "markdown-it-footnote": "4.0.0",
52
- "opentype.js": "2.0.0",
53
- "ratex-wasm": "0.1.15"
51
+ "markdown-it-footnote": "4.0.0"
54
52
  },
55
53
  "bundleDependencies": [
56
54
  "markdown-it",
57
- "markdown-it-footnote",
58
- "opentype.js",
59
- "ratex-wasm"
55
+ "markdown-it-footnote"
60
56
  ],
61
57
  "devDependencies": {
62
58
  "@getpaseo/plugin": "0.11.2",
63
59
  "@tanstack/react-query": "^5.90.11",
64
60
  "@types/node": "^22.19.0",
65
61
  "@types/react": "~19.2.0",
62
+ "opentype.js": "2.0.0",
63
+ "ratex-wasm": "0.1.15",
66
64
  "react": "19.1.0",
67
65
  "react-native": "0.81.5",
68
66
  "typescript": "^5.9.3",
@@ -2,12 +2,14 @@ import { createHash } from "node:crypto";
2
2
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- import { brotliCompressSync, constants } from "node:zlib";
5
+ import { brotliCompressSync, brotliDecompressSync, constants } from "node:zlib";
6
6
  import opentype from "opentype.js";
7
7
 
8
8
  // The Paseo server bundle is evaluated from a string: it has no plugin directory to read
9
9
  // files from at runtime. The RaTeX WASM binary and precomputed KaTeX outlines therefore
10
10
  // travel inside the bundle as Brotli-compressed base64. Font parsing happens only here.
11
+ // The output is committed with the bindings it needs, so installations never run this and
12
+ // ratex-wasm stays a development dependency. CI checks that the output is current.
11
13
 
12
14
  const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
13
15
  const packageDir = path.join(root, "node_modules", "ratex-wasm");
@@ -23,7 +25,7 @@ const FONT_IDS = [
23
25
 
24
26
  const manifest = JSON.parse(await readFile(path.join(root, "package.json"), "utf8"));
25
27
  const installed = JSON.parse(await readFile(path.join(packageDir, "package.json"), "utf8"));
26
- const pinned = manifest.dependencies["ratex-wasm"];
28
+ const pinned = manifest.devDependencies["ratex-wasm"];
27
29
  if (installed.version !== pinned) {
28
30
  throw new Error(`ratex-wasm ${installed.version} is installed, but package.json pins ${pinned}. Run npm ci.`);
29
31
  }
@@ -45,14 +47,46 @@ function encode(bytes) {
45
47
  const header = (source) =>
46
48
  `// Generated by scripts/embed-assets.mjs from ratex-wasm@${installed.version}/${source}. Do not edit.\n`;
47
49
 
50
+ /**
51
+ * Brotli output may differ between Node releases. Keep a committed file whose comments and
52
+ * payloads already describe the same bytes, so only a ratex-wasm update rewrites it.
53
+ */
54
+ async function writeEncoded(file, text, payloads) {
55
+ const existing = await readFile(file, "utf8").catch(() => null);
56
+ if (existing !== null) {
57
+ const comments = (source) => source.split("\n").filter((line) => line.startsWith("//")).join("\n");
58
+ const found = [...existing.matchAll(/"([A-Za-z0-9+/]{64,}={0,2})"/g)].map((match) => match[1]);
59
+ const unchanged =
60
+ comments(existing) === comments(text) &&
61
+ found.length === payloads.length &&
62
+ found.every((base64, index) => {
63
+ const bytes = brotliDecompressSync(Buffer.from(base64, "base64"));
64
+ return createHash("sha256").update(bytes).digest("hex") === payloads[index].sha256;
65
+ });
66
+ if (unchanged) return;
67
+ }
68
+ await writeFile(file, text);
69
+ }
70
+
48
71
  await mkdir(outDir, { recursive: true });
49
72
 
73
+ // The wasm-bindgen bindings and the display list types, so the runtime needs no ratex-wasm.
74
+ for (const [source, target] of [
75
+ ["pkg/ratex_wasm.js", "ratex_wasm.js"],
76
+ ["pkg/ratex_wasm.d.ts", "ratex_wasm.d.ts"],
77
+ ["dist/types.d.ts", "ratex-types.d.ts"],
78
+ ]) {
79
+ const content = await readFile(path.join(packageDir, source), "utf8");
80
+ await writeFile(path.join(outDir, target), header(source) + "// ratex-wasm: MIT License, Copyright (c) erweixin.\n" + content);
81
+ }
82
+
50
83
  const wasm = encode(await readFile(path.join(packageDir, "pkg", "ratex_wasm_bg.wasm")));
51
- await writeFile(
84
+ await writeEncoded(
52
85
  path.join(outDir, "ratex-wasm-bytes.ts"),
53
86
  header("pkg/ratex_wasm_bg.wasm") +
54
87
  `// ${wasm.size} bytes, sha256 ${wasm.sha256}; Brotli-compressed, then base64.\n` +
55
88
  `export const RATEX_WASM_BROTLI_BASE64 = "${wasm.base64}";\n`,
89
+ [wasm],
56
90
  );
57
91
 
58
92
  const fonts = [];
@@ -67,7 +101,7 @@ for (const id of FONT_IDS) {
67
101
  }
68
102
  fonts.push({ id, ...encode(Buffer.from(JSON.stringify({ characters, outlines }))) });
69
103
  }
70
- await writeFile(
104
+ await writeEncoded(
71
105
  path.join(outDir, "katex-glyphs.ts"),
72
106
  header("fonts/KaTeX_*.ttf") +
73
107
  "// KaTeX fonts: SIL Open Font License 1.1, see the LICENSE file in ratex-wasm.\n" +
@@ -76,6 +110,7 @@ await writeFile(
76
110
  "export const KATEX_GLYPHS_BROTLI_BASE64: Readonly<Record<string, string>> = {\n" +
77
111
  fonts.map(({ id, base64 }) => ` "${id}": "${base64}",\n`).join("") +
78
112
  "};\n",
113
+ fonts,
79
114
  );
80
115
  // Remove the pre-0.1.1 generated asset when rebuilding an existing checkout.
81
116
  await rm(path.join(outDir, "katex-fonts.ts"), { force: true });
@@ -24,21 +24,20 @@ function run(command, args) {
24
24
  if (result.status !== 0) process.exit(result.status ?? 1);
25
25
  }
26
26
 
27
- // A fresh Git checkout has no generated assets: install the locked production tree
28
- // without lifecycle scripts, then embed them. npm carries the shrinkwrap, generated
29
- // assets and bundled dependencies, so that channel needs no installation step here.
30
- if (!(await exists("server/vendor/ratex-wasm-bytes.ts")) || !(await exists("server/vendor/katex-glyphs.ts"))) {
27
+ // Both channels carry the embedded RaTeX assets in server/vendor. npm also carries the
28
+ // bundled dependencies; a fresh Git checkout installs the locked production tree without
29
+ // lifecycle scripts.
30
+ if (!(await exists("node_modules/markdown-it/package.json"))) {
31
31
  if (!(await exists("npm-shrinkwrap.json"))) throw new Error("Missing dependency lock. Reinstall the plugin.");
32
32
  run(process.platform === "win32" ? "npm.cmd" : "npm", [
33
33
  "ci", "--omit=dev", "--ignore-scripts", "--no-audit", "--no-fund",
34
34
  ]);
35
- run(process.execPath, ["scripts/embed-assets.mjs"]);
36
35
  }
37
36
 
38
37
  for (const file of [
39
38
  "server/vendor/ratex-wasm-bytes.ts",
40
39
  "server/vendor/katex-glyphs.ts",
41
- "node_modules/ratex-wasm/pkg/ratex_wasm.js",
40
+ "server/vendor/ratex_wasm.js",
42
41
  "node_modules/markdown-it/package.json",
43
42
  "node_modules/markdown-it-footnote/package.json",
44
43
  ]) {
package/server/ratex.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Buffer } from "node:buffer";
2
2
  import { brotliDecompressSync } from "node:zlib";
3
- import type { DisplayList } from "ratex-wasm";
4
- import { initSync, renderLatexWithOptions } from "../node_modules/ratex-wasm/pkg/ratex_wasm.js";
3
+ import type { DisplayList } from "./vendor/ratex-types.js";
4
+ import { initSync, renderLatexWithOptions } from "./vendor/ratex_wasm.js";
5
5
  import { RATEX_WASM_BROTLI_BASE64 } from "./vendor/ratex-wasm-bytes.ts";
6
6
 
7
7
  /**
package/server/scene.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Color, DisplayItem, DisplayList } from "ratex-wasm";
1
+ import type { Color, DisplayItem, DisplayList } from "./vendor/ratex-types.js";
2
2
  import {
3
3
  UNITS_PER_EM,
4
4
  type Bounds,
@@ -1,3 +1,5 @@
1
+ // Generated by scripts/embed-assets.mjs from ratex-wasm@0.1.15/dist/types.d.ts. Do not edit.
2
+ // ratex-wasm: MIT License, Copyright (c) erweixin.
1
3
  /**
2
4
  * TypeScript types mirroring RaTeX Rust DisplayList (ratex-types).
3
5
  * Used by web-render to draw on Canvas 2D.
@@ -1,3 +1,5 @@
1
+ // Generated by scripts/embed-assets.mjs from ratex-wasm@0.1.15/pkg/ratex_wasm.d.ts. Do not edit.
2
+ // ratex-wasm: MIT License, Copyright (c) erweixin.
1
3
  /* tslint:disable */
2
4
  /* eslint-disable */
3
5
 
@@ -1,3 +1,5 @@
1
+ // Generated by scripts/embed-assets.mjs from ratex-wasm@0.1.15/pkg/ratex_wasm.js. Do not edit.
2
+ // ratex-wasm: MIT License, Copyright (c) erweixin.
1
3
  /* @ts-self-types="./ratex_wasm.d.ts" */
2
4
 
3
5
  /**
@@ -1,20 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2020 Frederik De Bleser
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.