weasyprint-tsx 0.0.1

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 (41) hide show
  1. package/README.md +1 -0
  2. package/ReadMe.pdf +0 -0
  3. package/bun.lock +166 -0
  4. package/global.d.ts +16 -0
  5. package/package.json +11 -0
  6. package/packages/build/package.json +20 -0
  7. package/packages/build/src/build.ts +100 -0
  8. package/packages/build/src/cli.ts +13 -0
  9. package/packages/build/src/config.ts +90 -0
  10. package/packages/build/src/orchestrator.ts +61 -0
  11. package/packages/build/src/server.ts +36 -0
  12. package/packages/create/cli.js +28 -0
  13. package/packages/create/package.json +10 -0
  14. package/packages/create/template/global.d.ts +16 -0
  15. package/packages/create/template/package.json +18 -0
  16. package/packages/create/template/src/index.css +21 -0
  17. package/packages/create/template/src/index.tsx +25 -0
  18. package/packages/create/template/tsconfig.json +11 -0
  19. package/packages/create/template/weasyprint-tsx.config.ts +17 -0
  20. package/packages/ui/package.json +8 -0
  21. package/packages/ui/src/BlockBox.module.css +16 -0
  22. package/packages/ui/src/BlockBox.tsx +66 -0
  23. package/packages/ui/src/CodeBlock.tsx +17 -0
  24. package/packages/ui/src/DotLine.module.css +24 -0
  25. package/packages/ui/src/DotLine.tsx +45 -0
  26. package/packages/ui/src/Equation.module.css +4 -0
  27. package/packages/ui/src/Equation.tsx +38 -0
  28. package/packages/ui/src/List.module.css +53 -0
  29. package/packages/ui/src/List.tsx +120 -0
  30. package/packages/ui/src/Page.module.css +14 -0
  31. package/packages/ui/src/Page.tsx +33 -0
  32. package/packages/ui/src/Table.module.css +55 -0
  33. package/packages/ui/src/Table.tsx +164 -0
  34. package/packages/ui/src/Title.module.css +75 -0
  35. package/packages/ui/src/Titles.tsx +105 -0
  36. package/packages/ui/src/index.ts +9 -0
  37. package/packages/ui/src/utils.tsx +26 -0
  38. package/src/index.css +0 -0
  39. package/src/index.tsx +16 -0
  40. package/tsconfig.json +16 -0
  41. package/weasyprint-tsx.config.ts +7 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+
package/ReadMe.pdf ADDED
Binary file
package/bun.lock ADDED
@@ -0,0 +1,166 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "configVersion": 0,
4
+ "workspaces": {
5
+ "": {
6
+ "name": "@weasyprint-tsx/build",
7
+ },
8
+ "packages/build": {
9
+ "name": "@weasyprint-tsx/build",
10
+ "version": "0.0.1",
11
+ "bin": {
12
+ "weasyprint-tsx": "./src/cli.ts",
13
+ },
14
+ "dependencies": {
15
+ "@tailwindcss/postcss": "^4.3.0",
16
+ "postcss": "^8.5.15",
17
+ "postcss-custom-properties": "^15.0.1",
18
+ "preact": "^10.29.2",
19
+ "preact-render-to-string": "^6.7.0",
20
+ },
21
+ "devDependencies": {
22
+ "bun-types": "latest",
23
+ },
24
+ },
25
+ "packages/create": {
26
+ "name": "@weasyprint-tsx/create",
27
+ "version": "0.0.1",
28
+ "bin": {
29
+ "create-weasyprint-tsx": "src/cli.ts",
30
+ },
31
+ },
32
+ "packages/ui": {
33
+ "name": "@weasyprint-tsx/ui",
34
+ "version": "0.0.1",
35
+ },
36
+ },
37
+ "packages": {
38
+ "@alloc/quick-lru": ["@alloc/quick-lru@5.2.0", "", {}, "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw=="],
39
+
40
+ "@csstools/cascade-layer-name-parser": ["@csstools/cascade-layer-name-parser@3.0.0", "", { "peerDependencies": { "@csstools/css-parser-algorithms": "^4.0.0", "@csstools/css-tokenizer": "^4.0.0" } }, "sha512-/3iksyevwRfSJx5yH0RkcrcYXwuhMQx3Juqf40t97PeEy2/Mz2TItZ/z/216qpe4GgOyFBP8MKIwVvytzHmfIQ=="],
41
+
42
+ "@csstools/css-parser-algorithms": ["@csstools/css-parser-algorithms@4.0.0", "", { "peerDependencies": { "@csstools/css-tokenizer": "^4.0.0" } }, "sha512-+B87qS7fIG3L5h3qwJ/IFbjoVoOe/bpOdh9hAjXbvx0o8ImEmUsGXN0inFOnk2ChCFgqkkGFQ+TpM5rbhkKe4w=="],
43
+
44
+ "@csstools/css-tokenizer": ["@csstools/css-tokenizer@4.0.0", "", {}, "sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA=="],
45
+
46
+ "@csstools/utilities": ["@csstools/utilities@3.0.0", "", { "peerDependencies": { "postcss": "^8.4" } }, "sha512-etDqA/4jYvOGBM6yfKCOsEXfH96BKztZdgGmGqKi2xHnDe0ILIBraRspwgYatJH9JsCZ5HCGoCst8w18EKOAdg=="],
47
+
48
+ "@jridgewell/gen-mapping": ["@jridgewell/gen-mapping@0.3.13", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA=="],
49
+
50
+ "@jridgewell/remapping": ["@jridgewell/remapping@2.3.5", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ=="],
51
+
52
+ "@jridgewell/resolve-uri": ["@jridgewell/resolve-uri@3.1.2", "", {}, "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw=="],
53
+
54
+ "@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.5", "", {}, "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og=="],
55
+
56
+ "@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],
57
+
58
+ "@tailwindcss/node": ["@tailwindcss/node@4.3.0", "", { "dependencies": { "@jridgewell/remapping": "^2.3.5", "enhanced-resolve": "^5.21.0", "jiti": "^2.6.1", "lightningcss": "1.32.0", "magic-string": "^0.30.21", "source-map-js": "^1.2.1", "tailwindcss": "4.3.0" } }, "sha512-aFb4gUhFOgdh9AXo4IzBEOzBkkAxm9VigwDJnMIYv3lcfXCJVesNfbEaBl4BNgVRyid92AmdviqwBUBRKSeY3g=="],
59
+
60
+ "@tailwindcss/oxide": ["@tailwindcss/oxide@4.3.0", "", { "optionalDependencies": { "@tailwindcss/oxide-android-arm64": "4.3.0", "@tailwindcss/oxide-darwin-arm64": "4.3.0", "@tailwindcss/oxide-darwin-x64": "4.3.0", "@tailwindcss/oxide-freebsd-x64": "4.3.0", "@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.0", "@tailwindcss/oxide-linux-arm64-gnu": "4.3.0", "@tailwindcss/oxide-linux-arm64-musl": "4.3.0", "@tailwindcss/oxide-linux-x64-gnu": "4.3.0", "@tailwindcss/oxide-linux-x64-musl": "4.3.0", "@tailwindcss/oxide-wasm32-wasi": "4.3.0", "@tailwindcss/oxide-win32-arm64-msvc": "4.3.0", "@tailwindcss/oxide-win32-x64-msvc": "4.3.0" } }, "sha512-F7HZGBeN9I0/AuuJS5PwcD8xayx5ri5GhjYUDBEVYUkexyA/giwbDNjRVrxSezE3T250OU2K/wp/ltWx3UOefg=="],
61
+
62
+ "@tailwindcss/oxide-android-arm64": ["@tailwindcss/oxide-android-arm64@4.3.0", "", { "os": "android", "cpu": "arm64" }, "sha512-TJPiq67tKlLuObP6RkwvVGDoxCMBVtDgKkLfa/uyj7/FyxvQwHS+UOnVrXXgbEsfUaMgiVvC4KbJnRr26ho4Ng=="],
63
+
64
+ "@tailwindcss/oxide-darwin-arm64": ["@tailwindcss/oxide-darwin-arm64@4.3.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-oMN/WZRb+SO37BmUElEgeEWuU8E/HXRkiODxJxLe1UTHVXLrdVSgfaJV7pSlhRGMSOiXLuxTIjfsF3wYvz8cgQ=="],
65
+
66
+ "@tailwindcss/oxide-darwin-x64": ["@tailwindcss/oxide-darwin-x64@4.3.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-N6CUmu4a6bKVADfw77p+iw6Yd9Q3OBhe0veaDX+QazfuVYlQsHfDgxBrsjQ/IW+zywL8mTrNd0SdJT/zgtvMdA=="],
67
+
68
+ "@tailwindcss/oxide-freebsd-x64": ["@tailwindcss/oxide-freebsd-x64@4.3.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-zDL5hBkQdH5C6MpqbK3gQAgP80tsMwSI26vjOzjJtNCMUo0lFgOItzHKBIupOZNQxt3ouPH7RPhvNhiTfCe5CQ=="],
69
+
70
+ "@tailwindcss/oxide-linux-arm-gnueabihf": ["@tailwindcss/oxide-linux-arm-gnueabihf@4.3.0", "", { "os": "linux", "cpu": "arm" }, "sha512-R06HdNi7A7OEoMsf6d4tjZ71RCWnZQPHj2mnotSFURjNLdBC+cIgXQ7l81CqeoiQftjf6OOblxXMInMgN2VzMA=="],
71
+
72
+ "@tailwindcss/oxide-linux-arm64-gnu": ["@tailwindcss/oxide-linux-arm64-gnu@4.3.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-qTJHELX8jetjhRQHCLilkVLmybpzNQAtaI/gaoVoidn/ufbNDbAo8KlK2J+yPoc8wQxvDxCmh/5lr8nC1+lTbg=="],
73
+
74
+ "@tailwindcss/oxide-linux-arm64-musl": ["@tailwindcss/oxide-linux-arm64-musl@4.3.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-Z6sukiQsngnWO+l39X4pPbiWT81IC+PLKF+PHxIlyZbGNb9MODfYlXEVlFvej5BOZInWX01kVyzeLvHsXhfczQ=="],
75
+
76
+ "@tailwindcss/oxide-linux-x64-gnu": ["@tailwindcss/oxide-linux-x64-gnu@4.3.0", "", { "os": "linux", "cpu": "x64" }, "sha512-DRNdQRpSGzRGfARVuVkxvM8Q12nh19l4BF/G7zGA1oe+9wcC6saFBHTISrpIcKzhiXtSrlSrluCfvMuledoCTQ=="],
77
+
78
+ "@tailwindcss/oxide-linux-x64-musl": ["@tailwindcss/oxide-linux-x64-musl@4.3.0", "", { "os": "linux", "cpu": "x64" }, "sha512-Z0IADbDo8bh6I7h2IQMx601AdXBLfFpEdUotft86evd/8ZPflZe9COPO8Q1vw+pfLWIUo9zN/JGZvwuAJqduqg=="],
79
+
80
+ "@tailwindcss/oxide-wasm32-wasi": ["@tailwindcss/oxide-wasm32-wasi@4.3.0", "", { "dependencies": { "@emnapi/core": "^1.10.0", "@emnapi/runtime": "^1.10.0", "@emnapi/wasi-threads": "^1.2.1", "@napi-rs/wasm-runtime": "^1.1.4", "@tybys/wasm-util": "^0.10.1", "tslib": "^2.8.1" }, "cpu": "none" }, "sha512-HNZGOUxEmElksYR7S6sC5jTeNGpobAsy9u7Gu0AskJ8/20FR9GqebUyB+HBcU/ax6BHuiuJi+Oda4B+YX6H1yA=="],
81
+
82
+ "@tailwindcss/oxide-win32-arm64-msvc": ["@tailwindcss/oxide-win32-arm64-msvc@4.3.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-Pe+RPVTi1T+qymuuRpcdvwSVZjnll/f7n8gBxMMh3xLTctMDKqpdfGimbMyioqtLhUYZxdJ9wGNhV7MKHvgZsQ=="],
83
+
84
+ "@tailwindcss/oxide-win32-x64-msvc": ["@tailwindcss/oxide-win32-x64-msvc@4.3.0", "", { "os": "win32", "cpu": "x64" }, "sha512-Mvrf2kXW/yeW/OTezZlCGOirXRcUuLIBx/5Y12BaPM7wJoryG6dfS/NJL8aBPqtTEx/Vm4T4vKzFUcKDT+TKUA=="],
85
+
86
+ "@tailwindcss/postcss": ["@tailwindcss/postcss@4.3.0", "", { "dependencies": { "@alloc/quick-lru": "^5.2.0", "@tailwindcss/node": "4.3.0", "@tailwindcss/oxide": "4.3.0", "postcss": "^8.5.10", "tailwindcss": "4.3.0" } }, "sha512-Jm05Tjx+9yCLGv5qw1c+84Psds8MnyrEQYCB+FFk2lgGiUjlRqdxke4mVTuYrj2xnVZqKim2Apr5ySuQRYAw/w=="],
87
+
88
+ "@types/node": ["@types/node@25.9.3", "", { "dependencies": { "undici-types": ">=7.24.0 <7.24.7" } }, "sha512-603BddQMv3pUcr4U2dhujk83N2tTDVr/34wII2B6bJy6g+8WD6yUb11jszNs0gdi4PesVWl7ABt8nYMVpnLUcg=="],
89
+
90
+ "@weasyprint-tsx/build": ["@weasyprint-tsx/build@workspace:packages/build"],
91
+
92
+ "@weasyprint-tsx/create": ["@weasyprint-tsx/create@workspace:packages/create"],
93
+
94
+ "@weasyprint-tsx/ui": ["@weasyprint-tsx/ui@workspace:packages/ui"],
95
+
96
+ "bun-types": ["bun-types@1.3.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-4N0ig0fEomHt5R0KCFWjovxow98rIoRwKolrYdCcknNwMekCXRnWEUvgu5soYV8QXtVsrUD8B95MBOZGPvr6KQ=="],
97
+
98
+ "detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
99
+
100
+ "enhanced-resolve": ["enhanced-resolve@5.24.0", "", { "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.3.3" } }, "sha512-SkE2t82KlkkxQRVMVLAGKxLfORGQfrkx5dkj+vlgXRVNEdPc4eZcR+J/Fvj8C+yKSFH5L0q3NFlyufOVQnCcYQ=="],
101
+
102
+ "graceful-fs": ["graceful-fs@4.2.11", "", {}, "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="],
103
+
104
+ "jiti": ["jiti@2.7.0", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ=="],
105
+
106
+ "lightningcss": ["lightningcss@1.32.0", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-android-arm64": "1.32.0", "lightningcss-darwin-arm64": "1.32.0", "lightningcss-darwin-x64": "1.32.0", "lightningcss-freebsd-x64": "1.32.0", "lightningcss-linux-arm-gnueabihf": "1.32.0", "lightningcss-linux-arm64-gnu": "1.32.0", "lightningcss-linux-arm64-musl": "1.32.0", "lightningcss-linux-x64-gnu": "1.32.0", "lightningcss-linux-x64-musl": "1.32.0", "lightningcss-win32-arm64-msvc": "1.32.0", "lightningcss-win32-x64-msvc": "1.32.0" } }, "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ=="],
107
+
108
+ "lightningcss-android-arm64": ["lightningcss-android-arm64@1.32.0", "", { "os": "android", "cpu": "arm64" }, "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg=="],
109
+
110
+ "lightningcss-darwin-arm64": ["lightningcss-darwin-arm64@1.32.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ=="],
111
+
112
+ "lightningcss-darwin-x64": ["lightningcss-darwin-x64@1.32.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w=="],
113
+
114
+ "lightningcss-freebsd-x64": ["lightningcss-freebsd-x64@1.32.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig=="],
115
+
116
+ "lightningcss-linux-arm-gnueabihf": ["lightningcss-linux-arm-gnueabihf@1.32.0", "", { "os": "linux", "cpu": "arm" }, "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw=="],
117
+
118
+ "lightningcss-linux-arm64-gnu": ["lightningcss-linux-arm64-gnu@1.32.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ=="],
119
+
120
+ "lightningcss-linux-arm64-musl": ["lightningcss-linux-arm64-musl@1.32.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg=="],
121
+
122
+ "lightningcss-linux-x64-gnu": ["lightningcss-linux-x64-gnu@1.32.0", "", { "os": "linux", "cpu": "x64" }, "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA=="],
123
+
124
+ "lightningcss-linux-x64-musl": ["lightningcss-linux-x64-musl@1.32.0", "", { "os": "linux", "cpu": "x64" }, "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg=="],
125
+
126
+ "lightningcss-win32-arm64-msvc": ["lightningcss-win32-arm64-msvc@1.32.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw=="],
127
+
128
+ "lightningcss-win32-x64-msvc": ["lightningcss-win32-x64-msvc@1.32.0", "", { "os": "win32", "cpu": "x64" }, "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q=="],
129
+
130
+ "magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],
131
+
132
+ "nanoid": ["nanoid@3.3.12", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ=="],
133
+
134
+ "picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
135
+
136
+ "postcss": ["postcss@8.5.15", "", { "dependencies": { "nanoid": "^3.3.12", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A=="],
137
+
138
+ "postcss-custom-properties": ["postcss-custom-properties@15.0.1", "", { "dependencies": { "@csstools/cascade-layer-name-parser": "^3.0.0", "@csstools/css-parser-algorithms": "^4.0.0", "@csstools/css-tokenizer": "^4.0.0", "@csstools/utilities": "^3.0.0", "postcss-value-parser": "^4.2.0" }, "peerDependencies": { "postcss": "^8.4" } }, "sha512-cuyq8sd8dLY0GLbelz1KB8IMIoDECo6RVXMeHeXY2Uw3Q05k/d1GVITdaKLsheqrHbnxlwxzSRZQQ5u+rNtbMg=="],
139
+
140
+ "postcss-value-parser": ["postcss-value-parser@4.2.0", "", {}, "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ=="],
141
+
142
+ "preact": ["preact@10.29.2", "", {}, "sha512-7tNmwg/7mzzAoB/8kSg6Hl37JraAZw3Z3A0JSY7VXlZwo82Xn0G7wKbNNs2qoF4ZEEsQGTwDAroNdqKs1ofJxQ=="],
143
+
144
+ "preact-render-to-string": ["preact-render-to-string@6.7.0", "", { "peerDependencies": { "preact": ">=10 || >= 11.0.0-0" } }, "sha512-Z4WR8fmLMRpdYqJ9i7vrlXSsSrxVJydwrkEXHapexfARbWfGb7vGcnvNQnIzN0cXciMVOlz/XLoiMCi9gUsy9Q=="],
145
+
146
+ "source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],
147
+
148
+ "tailwindcss": ["tailwindcss@4.3.0", "", {}, "sha512-y6nxMGB1nMW9R6k96e5gdIFzcfL/gTJRNaqGes1YvkLnPVXzWgbqFF2yLC0T8G774n24cx3Pe8XrKoniCOAH+Q=="],
149
+
150
+ "tapable": ["tapable@2.3.3", "", {}, "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A=="],
151
+
152
+ "undici-types": ["undici-types@7.24.6", "", {}, "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg=="],
153
+
154
+ "@tailwindcss/oxide-wasm32-wasi/@emnapi/core": ["@emnapi/core@1.11.0", "", { "dependencies": { "@emnapi/wasi-threads": "1.2.2", "tslib": "^2.4.0" }, "bundled": true }, "sha512-l9Oo58x0HOP5znGzVhYW9U3e5wVuA4LAZU2AGezTmkhO1CgQRFDhDg4nneHsu/t3WniXg9QrG2nIXL/ZS8ln8Q=="],
155
+
156
+ "@tailwindcss/oxide-wasm32-wasi/@emnapi/runtime": ["@emnapi/runtime@1.11.0", "", { "dependencies": { "tslib": "^2.4.0" }, "bundled": true }, "sha512-55coeOFKHv1ywEcUXJtWU5f+Jr/W5tZDvZig8DLKSwUN1JpROQ4rk/SNOQiFWmaR/VKF4zuFyW1B8JduOSv6Pg=="],
157
+
158
+ "@tailwindcss/oxide-wasm32-wasi/@emnapi/wasi-threads": ["@emnapi/wasi-threads@1.2.2", "", { "dependencies": { "tslib": "^2.4.0" }, "bundled": true }, "sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA=="],
159
+
160
+ "@tailwindcss/oxide-wasm32-wasi/@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@1.1.5", "", { "dependencies": { "@tybys/wasm-util": "^0.10.2" }, "peerDependencies": { "@emnapi/core": "^1.7.1", "@emnapi/runtime": "^1.7.1" }, "bundled": true }, "sha512-AWPoBRJ9tsnVhor4sjO7rkni+7p+2IAEFj6cx06UgP10jkQHqay/36uRV/bFkgrh18D9vb4cr8Q0Pthskgzy+Q=="],
161
+
162
+ "@tailwindcss/oxide-wasm32-wasi/@tybys/wasm-util": ["@tybys/wasm-util@0.10.2", "", { "dependencies": { "tslib": "^2.4.0" }, "bundled": true }, "sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg=="],
163
+
164
+ "@tailwindcss/oxide-wasm32-wasi/tslib": ["tslib@2.8.1", "", { "bundled": true }, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
165
+ }
166
+ }
package/global.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ declare module "*.css" { const s: Record<string, string>; export default s; }
2
+
3
+
4
+ declare module "*.png" { const s: string; export default s; }
5
+ declare module "*.jpg" { const s: string; export default s; }
6
+ declare module "*.jpeg" { const s: string; export default s; }
7
+ declare module "*.webp" { const s: string; export default s; }
8
+ declare module "*.gif" { const s: string; export default s; }
9
+ declare module "*.svg" { const s: string; export default s; }
10
+ declare module "*.avif" { const s: string; export default s; }
11
+ declare module "*.ico" { const s: string; export default s; }
12
+ declare module "*.bmp" { const s: string; export default s; }
13
+
14
+ declare module ".json" {const o : Record<string, any>; export default o }
15
+ declare module ".toml" {const o : Record<string, any>; export default o }
16
+ declare module ".yaml" {const o : Record<string, any>; export default o }
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "weasyprint-tsx",
3
+ "version": "0.0.1",
4
+ "scripts": {
5
+ "dev": "bun packages/build/src/cli.ts --watch",
6
+ "init" : "bun packages/create/cli.ts"
7
+ },
8
+ "workspaces": [
9
+ "packages/*"
10
+ ]
11
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@weasyprint-tsx/build",
3
+ "version": "0.0.1",
4
+ "bin": {
5
+ "weasyprint-tsx": "./src/cli.ts"
6
+ },
7
+ "workspaces": [
8
+ "packages/*"
9
+ ],
10
+ "devDependencies": {
11
+ "bun-types": "latest"
12
+ },
13
+ "dependencies": {
14
+ "@tailwindcss/postcss": "^4.3.0",
15
+ "postcss": "^8.5.15",
16
+ "postcss-custom-properties": "^15.0.1",
17
+ "preact": "^10.29.2",
18
+ "preact-render-to-string": "^6.7.0"
19
+ }
20
+ }
@@ -0,0 +1,100 @@
1
+ import { join } from "path";
2
+ import { DConfig } from "./config";
3
+ import { BunPlugin } from "bun";
4
+ import postcss from "postcss";
5
+ import customProperties from "postcss-custom-properties";
6
+ import tailwindcss from "@tailwindcss/postcss";
7
+ import { injectDevScript } from "./server";
8
+ import { h } from "preact";
9
+ import { renderToStaticMarkup } from "preact-render-to-string";
10
+
11
+ const tailwindPlugin: BunPlugin = {
12
+ name: "tailwind-postcss",
13
+ setup(build) {
14
+ build.onLoad({ filter: /index\.css$/ }, async (args) => {
15
+ const css = await Bun.file(args.path).text();
16
+ const result = await postcss([
17
+ tailwindcss(),
18
+ customProperties({ preserve: false }),
19
+ ]).process(css, { from: args.path });
20
+ return { contents: result.css, loader: "css" };
21
+ });
22
+ },
23
+ };
24
+
25
+ export async function buildHTML(cfg: DConfig, dev: boolean = false) {
26
+ const ROOT = process.cwd();
27
+ const INPUT = join(ROOT, cfg.io.input);
28
+ const BUILD_DIR = join(ROOT, cfg.io.buildDir);
29
+ const BUILD_PATH = join(BUILD_DIR, "index.html");
30
+ const t0 = performance.now();
31
+
32
+ await import("fs/promises").then((fs) =>
33
+ fs.rm(BUILD_DIR, { recursive: true, force: true }),
34
+ );
35
+
36
+ const build = await Bun.build({
37
+ entrypoints: [INPUT],
38
+ outdir: BUILD_DIR,
39
+ target: "bun",
40
+ optimizeImports: ["preact", "@weasyprint-tsx/ui"],
41
+ plugins: [tailwindPlugin],
42
+ });
43
+ if (!build.success) {
44
+ process.stderr.write(build.logs.map(String).join("\n") + "\n");
45
+ return 0;
46
+ }
47
+
48
+ const { default: Document } = await import(
49
+ join(BUILD_DIR, `index.js?t=${performance.now()}`)
50
+ );
51
+
52
+ const html = "<!DOCTYPE html>" + renderToStaticMarkup(h(Document, {}));
53
+
54
+ await Bun.write(BUILD_PATH, html);
55
+
56
+ if (dev) {
57
+ injectDevScript(BUILD_PATH);
58
+ }
59
+ process.stdout.write(
60
+ `Bun HTML build -- ${(performance.now() - t0).toFixed(2)}ms\n`,
61
+ );
62
+ return Bun.hash(html);
63
+ }
64
+
65
+ function buildArgs(cfg: DConfig): string[] {
66
+ const wp = cfg.weasyprint ?? {};
67
+ const args = [cfg.weasyprint.path];
68
+
69
+ if (cfg.io.media_type && cfg.io.media_type !== "print")
70
+ args.push("--media-type", cfg.io.media_type);
71
+
72
+ for (const ss of cfg.pdf?.stylesheets ?? []) args.push("--stylesheet", ss);
73
+
74
+ if (wp.pdf_forms) args.push("--pdf-forms");
75
+ if (wp.optimize_images) args.push("--optimize-images");
76
+ if (wp.dpi) args.push("--dpi", String(wp.dpi));
77
+ if (wp.jpeg_quality) args.push("--jpeg-quality", String(wp.jpeg_quality));
78
+ if (wp.pdf_variant) args.push("--pdf-variant", wp.pdf_variant);
79
+ if (wp.cache) args.push("--cache-folder", wp.cache);
80
+ if (wp.full_fonts) args.push("--full-fonts");
81
+ if (wp.srgb) args.push("--srgb");
82
+
83
+ args.push(`${cfg.io.buildDir ?? ".build"}/index.html`, cfg.io.output);
84
+ return args;
85
+ }
86
+
87
+ export async function buildPDF(cfg: DConfig): Promise<void> {
88
+ const args = buildArgs(cfg);
89
+ const t0 = performance.now();
90
+ const proc = Bun.spawn(args, {
91
+ cwd: process.cwd(),
92
+ stderr: "inherit",
93
+ stdout: cfg.weasyprint.verbose ? "inherit" : "ignore",
94
+ });
95
+ const code = await proc.exited;
96
+ if (code !== 0) throw new Error(`WeasyPrint exited with code ${code}`);
97
+ process.stdout.write(
98
+ `Weasyprint PDF -- ${(performance.now() - t0).toFixed(2)}ms → ${cfg.io.output}\n`,
99
+ );
100
+ }
@@ -0,0 +1,13 @@
1
+ import { devMode, buildOnce } from "./orchestrator";
2
+
3
+
4
+
5
+ const args = process.argv.slice(2);
6
+ const watch = args.includes("--watch");
7
+ const output = args.find((a) => !a.startsWith("--"));
8
+
9
+ if (watch) {
10
+ devMode(output);
11
+ } else {
12
+ buildOnce(output);
13
+ }
@@ -0,0 +1,90 @@
1
+ import { resolve } from "path";
2
+
3
+ export interface Config {
4
+ io?: {
5
+ output?: string;
6
+ input?: string;
7
+ buildDir?: string;
8
+ media_type?: "print" | "screen";
9
+ };
10
+ pdf?: {
11
+ stylesheets?: string[];
12
+ };
13
+ weasyprint?: {
14
+ path: string;
15
+ verbose?: boolean;
16
+ pdf_forms?: boolean;
17
+ optimize_images?: boolean;
18
+ dpi?: number;
19
+ jpeg_quality?: number;
20
+ pdf_variant?: string;
21
+ cache?: string;
22
+ full_fonts?: boolean;
23
+ srgb?: boolean;
24
+ };
25
+ dev?: {
26
+ port?: number;
27
+ watch?: string;
28
+ };
29
+ }
30
+
31
+ const defaultConfig = {
32
+ io: {
33
+ output: "output.pdf",
34
+ input: "src/index.tsx",
35
+ buildDir: ".build",
36
+ media_type: "print",
37
+ },
38
+ pdf: {
39
+ stylesheets: [],
40
+ },
41
+ weasyprint: {
42
+ path: "weasyprint",
43
+ verbose: false,
44
+ },
45
+ dev: {
46
+ port: 3000,
47
+ watch: "src",
48
+ },
49
+ } satisfies Config;
50
+
51
+ export type DConfig = typeof defaultConfig & Config;
52
+
53
+ export function isObject(item: any) {
54
+ return item && typeof item === "object" && !Array.isArray(item);
55
+ }
56
+
57
+ export function mergeDeep(
58
+ target: Record<string, unknown>,
59
+ ...sources: Record<string, unknown>[]
60
+ ) {
61
+ if (!sources.length) return target;
62
+ const source = sources.shift();
63
+
64
+ if (isObject(target) && isObject(source)) {
65
+ for (const key in source) {
66
+ if (isObject(source[key])) {
67
+ if (!target[key]) Object.assign(target, { [key]: {} });
68
+ //@ts-ignore
69
+ mergeDeep(target[key], source[key]);
70
+ } else {
71
+ Object.assign(target, { [key]: source[key] });
72
+ }
73
+ }
74
+ }
75
+
76
+ return mergeDeep(target, ...sources);
77
+ }
78
+
79
+ export async function loadConfig(): Promise<DConfig> {
80
+ const configPath = resolve(process.cwd(), "weasyprint-tsx.config.ts");
81
+ let config = defaultConfig;
82
+ try {
83
+ const {default : userConfig} = await import(`${configPath}`);
84
+ config = mergeDeep(config, userConfig) as unknown as DConfig;
85
+ console.log(config , userConfig)
86
+ } catch (e) {
87
+ process.stdout.write(`No config file at ${configPath} found, using default.`);
88
+ }
89
+ return config;
90
+ }
@@ -0,0 +1,61 @@
1
+ import { watch } from "fs";
2
+ import { buildHTML, buildPDF } from "./build";
3
+ import { loadConfig } from "./config";
4
+ import { bumpPing, startServer } from "./server";
5
+ import { join } from "path";
6
+
7
+ export async function buildOnce(output?: string) {
8
+ const cfg = await loadConfig();
9
+ if (output) cfg.io.output = output;
10
+ let t0 = performance.now();
11
+
12
+ await buildHTML(cfg);
13
+ process.stdout.write(
14
+ `Bun HTML build -- ${(performance.now() - t0).toFixed(2)} ms`,
15
+ );
16
+ await buildPDF(cfg);
17
+ t0 = performance.now();
18
+ process.stdout.write(
19
+ `Weasyprint PDF build -- ${(performance.now() - t0).toFixed(2)} ms → ${cfg.io.output}`,
20
+ );
21
+ }
22
+
23
+ export async function devMode(output?: string) {
24
+ const cfg = await loadConfig();
25
+ const WATCH_DIR = join(process.cwd(), cfg.dev.watch);
26
+
27
+ if (output) cfg.io.output = cfg.io.output ?? output;
28
+ process.stdout.write(`Dev: http://localhost:${cfg.dev.port}`);
29
+
30
+ let pdfBusy = false;
31
+ let lastHash: number | BigInt = 0;
32
+ async function rebuild(): Promise<void> {
33
+ try {
34
+ const hash = await buildHTML(cfg, true);
35
+ bumpPing();
36
+ if (hash !== lastHash && !pdfBusy) {
37
+ lastHash = hash;
38
+ pdfBusy = true;
39
+ buildPDF(cfg)
40
+ .then(() => {})
41
+ .catch((e) => process.stderr.write(`Weasyprint error: ${e}\n`))
42
+ .finally(() => {
43
+ pdfBusy = false;
44
+ });
45
+ }
46
+ } catch (e) {
47
+ process.stderr.write(`Build error: ${e}\n`);
48
+ }
49
+ }
50
+
51
+ await rebuild();
52
+
53
+ startServer(cfg.dev.port, cfg.io.buildDir);
54
+
55
+ watch(WATCH_DIR, {}, async (ev, f) => {
56
+ process.stdout.write(`${ev} : file changed ${f}`);
57
+ await rebuild();
58
+ });
59
+
60
+ await Bun.sleep(Infinity);
61
+ }
@@ -0,0 +1,36 @@
1
+ import { join } from "path";
2
+
3
+ const DEV_SCRIPT = `<script>var _t=null;setInterval(function(){fetch('/__dev_ping').then(function(r){return r.text();}).then(function(s){if(_t!==null&&s!==_t)location.reload();_t=s;}).catch(function(){});},300);</script>`;
4
+
5
+ let pingCounter = 0;
6
+
7
+ export function bumpPing(): void {
8
+ pingCounter++;
9
+ }
10
+
11
+ export function startServer(port: number, buildDir: string): void {
12
+ Bun.serve({
13
+ port,
14
+ fetch(req) {
15
+ const url = new URL(req.url);
16
+
17
+ if (url.pathname === "/__dev_ping") {
18
+ return new Response(String(pingCounter), {
19
+ headers: { "Cache-Control": "no-store" },
20
+ });
21
+ }
22
+
23
+ const file = Bun.file(join(process.cwd(), buildDir , "index.html"));
24
+ return new Response(file);
25
+ },
26
+ });
27
+ }
28
+
29
+ export async function injectDevScript(htmlPath: string): Promise<void> {
30
+ let html = await Bun.file(htmlPath).text();
31
+ if (!html.includes("/__dev_ping")) {
32
+ html = html.replace("</html>", `${DEV_SCRIPT}</html>`);
33
+ await Bun.write(htmlPath, html);
34
+ }
35
+ }
36
+
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { cpSync, existsSync, readFileSync, writeFileSync } from "fs";
4
+ import { join } from "path";
5
+
6
+ const name = process.argv[2] ?? "my-doc";
7
+ const dest = join(process.cwd(), name);
8
+ const templateDir = join(import.meta.dir, "template");
9
+
10
+ if (existsSync(dest)) {
11
+ process.stderr.write(`Error: directory '${name}' already exists\n`);
12
+ process.exit(1);
13
+ }
14
+
15
+ cpSync(templateDir, dest, { recursive: true });
16
+
17
+ const pkgPath = join(dest, "package.json");
18
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
19
+ pkg.name = name;
20
+ writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
21
+
22
+ process.stdout.write(`
23
+ Created '${name}/'.
24
+
25
+ cd ${name}
26
+ bun run dev
27
+
28
+ `);
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@weasyprint-tsx/create",
3
+ "version": "0.0.1",
4
+ "bin": {
5
+ "create-weasyprint-tsx": "src/cli.ts"
6
+ },
7
+ "workspaces": [
8
+ "packages/*"
9
+ ]
10
+ }
@@ -0,0 +1,16 @@
1
+ declare module "*.css" { const s: Record<string, string>; export default s; }
2
+
3
+
4
+ declare module "*.png" { const s: string; export default s; }
5
+ declare module "*.jpg" { const s: string; export default s; }
6
+ declare module "*.jpeg" { const s: string; export default s; }
7
+ declare module "*.webp" { const s: string; export default s; }
8
+ declare module "*.gif" { const s: string; export default s; }
9
+ declare module "*.svg" { const s: string; export default s; }
10
+ declare module "*.avif" { const s: string; export default s; }
11
+ declare module "*.ico" { const s: string; export default s; }
12
+ declare module "*.bmp" { const s: string; export default s; }
13
+
14
+ declare module ".json" {const o : Record<string, any>; export default o }
15
+ declare module ".toml" {const o : Record<string, any>; export default o }
16
+ declare module ".yaml" {const o : Record<string, any>; export default o }
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "my-doc",
3
+ "private": true,
4
+ "scripts": {
5
+ "build": "weasyprint-tsx",
6
+ "dev": "weasyprint-tsx --watch",
7
+ "setup": ". scripts/install.sh"
8
+ },
9
+ "dependencies": {
10
+ "@weasyprint-tsx/build": "latest",
11
+ "@weasyprint-tsx/ui": "latest",
12
+ "preact": "^10.0.0",
13
+ "tailwindcss": "latest"
14
+ },
15
+ "devDependencies": {
16
+ "bun-types": "latest"
17
+ }
18
+ }
@@ -0,0 +1,21 @@
1
+ @import "tailwindcss";
2
+
3
+ @page {
4
+ size: A4;
5
+ margin: 2cm 1.5cm;
6
+
7
+ @bottom-center {
8
+ content: counter(page) " / " counter(pages);
9
+ font-size: 9pt;
10
+ color: #888;
11
+ }
12
+ }
13
+
14
+ html,
15
+ body {
16
+ color: #0f172a;
17
+ margin: 0;
18
+ padding: 0;
19
+ font-size: 10pt;
20
+ line-height: 1.7;
21
+ }