tikzify 0.0.0 → 0.0.6

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 (2) hide show
  1. package/README.md +114 -59
  2. package/package.json +6 -2
package/README.md CHANGED
@@ -1,73 +1,128 @@
1
- # React + TypeScript + Vite
1
+ # tikzsvg
2
2
 
3
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
3
+ Generate beautiful PDF books with emoji SVG overlays and custom backgrounds using XeLaTeX and TikZ.
4
4
 
5
- Currently, two official plugins are available:
5
+ ## Features
6
6
 
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
7
+ - 📚 Create multi-page PDF books from JSON input
8
+ - 🎨 Gradient backgrounds with customizable colors
9
+ - 🖼️ Embed images with custom shaped clipping paths
10
+ - ✨ SVG emoji overlays with precise positioning, scaling, and rotation
11
+ - 🌐 RTL (right-to-left) and LTR (left-to-right) text support
12
+ - 🔤 Hebrew text support with Fredoka-Bold font
13
+ - 📄 A5 paper format with page numbering
9
14
 
10
- ## React Compiler
15
+ ## Prerequisites
11
16
 
12
- The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
17
+ - [Bun](https://bun.sh) runtime
18
+ - XeLaTeX (from TeX Live or similar distribution)
19
+ - `Fredoka-Bold.ttf` font file in the project root
13
20
 
14
- ## Expanding the ESLint configuration
21
+ ## Installation
15
22
 
16
- If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
23
+ ```bash
24
+ bun install
25
+ ```
17
26
 
18
- ```js
19
- export default defineConfig([
20
- globalIgnores(['dist']),
21
- {
22
- files: ['**/*.{ts,tsx}'],
23
- extends: [
24
- // Other configs...
27
+ ## Usage
25
28
 
26
- // Remove tseslint.configs.recommended and replace with this
27
- tseslint.configs.recommendedTypeChecked,
28
- // Alternatively, use this for stricter rules
29
- tseslint.configs.strictTypeChecked,
30
- // Optionally, add this for stylistic rules
31
- tseslint.configs.stylisticTypeChecked,
29
+ ### Server Mode
32
30
 
33
- // Other configs...
34
- ],
35
- languageOptions: {
36
- parserOptions: {
37
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
- tsconfigRootDir: import.meta.dirname,
39
- },
40
- // other options...
41
- },
42
- },
43
- ])
31
+ Start the HTTP server:
32
+
33
+ ```bash
34
+ bun --hot src/server.ts
35
+ ```
36
+
37
+ Send a POST request with JSON book data:
38
+
39
+ ```bash
40
+ curl http://localhost:3000/ \
41
+ -H "Content-Type: application/json" \
42
+ -d @book.json \
43
+ -o output.pdf
44
44
  ```
45
45
 
46
- You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47
-
48
- ```js
49
- // eslint.config.js
50
- import reactX from 'eslint-plugin-react-x'
51
- import reactDom from 'eslint-plugin-react-dom'
52
-
53
- export default defineConfig([
54
- globalIgnores(['dist']),
55
- {
56
- files: ['**/*.{ts,tsx}'],
57
- extends: [
58
- // Other configs...
59
- // Enable lint rules for React
60
- reactX.configs['recommended-typescript'],
61
- // Enable lint rules for React DOM
62
- reactDom.configs.recommended,
63
- ],
64
- languageOptions: {
65
- parserOptions: {
66
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
- tsconfigRootDir: import.meta.dirname,
46
+ ### Book JSON Format
47
+
48
+ ```json
49
+ {
50
+ "dir": "rtl",
51
+ "pages": [
52
+ {
53
+ "gradient": ["#8B4513", "#FFD1E0"],
54
+ "textBg": "#FFF3E6",
55
+ "text": [
56
+ "Line 1 of text",
57
+ "Line 2 of text"
58
+ ],
59
+ "emojis": {
60
+ "text": [
61
+ {
62
+ "x": 10,
63
+ "y": 20,
64
+ "scale": 1.8,
65
+ "rotate": -15,
66
+ "emoji": "🍄"
67
+ }
68
+ ],
69
+ "image": [
70
+ {
71
+ "x": -170,
72
+ "y": -130,
73
+ "scale": 1.8,
74
+ "rotate": -15,
75
+ "emoji": "🌺"
76
+ }
77
+ ]
68
78
  },
69
- // other options...
70
- },
71
- },
72
- ])
79
+ "jpgBase64": "base64-encoded-image-data"
80
+ }
81
+ ]
82
+ }
73
83
  ```
84
+
85
+ ## API Reference
86
+
87
+ ### Book Schema
88
+
89
+ - `dir`: Text direction (`"rtl"` or `"ltr"`)
90
+ - `pages`: Array of page objects
91
+
92
+ ### Page Schema
93
+
94
+ - `gradient`: Array of two hex colors for background gradient
95
+ - `textBg`: Hex color for text background overlay
96
+ - `text`: Array of text lines to display
97
+ - `emojis.text`: Emoji overlays for text pages
98
+ - `emojis.image`: Emoji overlays for image pages
99
+ - `jpgBase64`: Base64-encoded JPEG image (max 256KB)
100
+
101
+ ### Emoji Schema
102
+
103
+ - `x`, `y`: Position coordinates in points
104
+ - `scale`: Scale factor
105
+ - `rotate`: Rotation angle in degrees
106
+ - `emoji`: Unicode emoji character
107
+
108
+ ## How It Works
109
+
110
+ 1. Receives book JSON via HTTP POST
111
+ 2. Parses and validates input using Zod schemas
112
+ 3. Converts emoji to SVG paths using pre-defined emoji map
113
+ 4. Generates XeLaTeX document with TikZ graphics
114
+ 5. Runs XeLaTeX twice to resolve coordinate references
115
+ 6. Returns compiled PDF
116
+
117
+ ## Development
118
+
119
+ The project uses:
120
+ - **Bun** for runtime and package management
121
+ - **TypeScript** for type safety
122
+ - **Zod** for schema validation
123
+ - **SAX** for SVG parsing
124
+ - **p-queue** for sequential PDF generation
125
+
126
+ ## License
127
+
128
+ MIT
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "tikzify",
3
- "version": "0.0.0",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "module": "dist/tikzsvg.es.js",
6
6
  "types": "dist/tikzsvg.d.ts",
7
7
  "files": [
8
8
  "src"
9
9
  ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/gkutiel/tikzsvg.git"
13
+ },
10
14
  "scripts": {},
11
15
  "devDependencies": {
12
16
  "@types/bun": "^1.3.6",
@@ -20,4 +24,4 @@
20
24
  "sax": "^1.4.4",
21
25
  "zod": "^4.3.5"
22
26
  }
23
- }
27
+ }