texlite 0.7.8 → 0.8.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 (34) hide show
  1. package/DESIGN.md +463 -0
  2. package/NPM_TESTING.md +136 -0
  3. package/OPERATIONS.md +261 -0
  4. package/README.md +82 -305
  5. package/README.zh-CN.md +64 -329
  6. package/dist/client/assets/{GitDialog-CqGyUxfP.js → GitDialog-CZRQPg3O.js} +1 -1
  7. package/dist/client/assets/{HistoryDialog-BMl2zxBa.js → HistoryDialog-BQtr58Co.js} +1 -1
  8. package/dist/client/assets/{LatexEditor-C4bFVwJZ.js → LatexEditor-XLwZxO6_.js} +1 -1
  9. package/dist/client/assets/{PdfPreview-BpP2LnX7.js → PdfPreview-D5CC-vqV.js} +1 -1
  10. package/dist/client/assets/{ProjectNavigationDialogs-B7mxG8Fz.js → ProjectNavigationDialogs-BdtTldSa.js} +1 -1
  11. package/dist/client/assets/{SystemMetricsDialog-BK_K3ah8.js → SystemMetricsDialog-CEbYJdj7.js} +1 -1
  12. package/dist/client/assets/index-BAFR6u6_.js +64 -0
  13. package/dist/client/assets/index-g5CaToD6.css +1 -0
  14. package/dist/client/assets/{minus-BwzSZenU.js → minus-KzdrD7TK.js} +1 -1
  15. package/dist/client/assets/spellCheck-CDZ9ZXo6.js +1 -0
  16. package/dist/client/index.html +2 -2
  17. package/dist/server/app.js +8 -3
  18. package/dist/server/cli.js +170 -32
  19. package/dist/server/environment.js +168 -38
  20. package/dist/server/harper.js +210 -119
  21. package/dist/server/i18n.js +8 -0
  22. package/dist/server/latexSpellMask.js +257 -0
  23. package/dist/server/projects.js +0 -12
  24. package/dist/server/routes/projectShared.js +1 -1
  25. package/dist/server/routes/projects.js +20 -19
  26. package/dist/server/routes/wordCount.js +83 -0
  27. package/dist/server/texcount.js +244 -0
  28. package/package.json +6 -3
  29. package/preview-1.png +0 -0
  30. package/preview-2.png +0 -0
  31. package/dist/client/assets/index-B9n8hfV0.js +0 -64
  32. package/dist/client/assets/index-BhyTKMoO.css +0 -1
  33. package/dist/client/assets/spellCheck-CvOAlLWp.js +0 -4
  34. package/preview.png +0 -0
package/OPERATIONS.md ADDED
@@ -0,0 +1,261 @@
1
+ # Operating TexLite
2
+
3
+ This guide covers installation, configuration, service operation, and backups.
4
+ For the product's intended use and editor comparison, start with the
5
+ [README](README.md). For implementation details and trade-offs, see
6
+ [DESIGN.md](DESIGN.md).
7
+
8
+ ## Requirements
9
+
10
+ - Node.js 24 or newer and npm
11
+ - `latexmk`
12
+ - At least one configured engine: `pdflatex`, `xelatex`, or `lualatex`
13
+ - `git` only when a project owner uses the optional Git/GitHub integration
14
+
15
+ Check a host before initialization:
16
+
17
+ ~~~bash
18
+ texlite requirements
19
+
20
+ # Equivalent individual checks:
21
+ node --version
22
+ npm --version
23
+ latexmk --version
24
+ xelatex --version
25
+ # Optional tools:
26
+ git --version
27
+ texcount -version
28
+ harper-cli --version
29
+ harper-ls --version
30
+ ~~~
31
+
32
+ `texlite init` and `texlite start` validate Node.js, `latexmk`, and every
33
+ engine named in `latex.allowedEngines`. `texlite requirements` can be run
34
+ before initialization: it checks only the default commands on `PATH`, without
35
+ reading a configuration file or any TexLite data. It requires Node.js and
36
+ `latexmk`, and requires at least one of the three supported LaTeX engines.
37
+ `texlite doctor` presents the configured deployment checks and optional host
38
+ tools in a table with their requirement level, installation state, and
39
+ detected version. Missing optional tools never stop the editor:
40
+ Git enables GitHub backup, TeXcount enables document statistics, and
41
+ `harper-cli` enables spelling and grammar diagnostics. `harper-ls` is shown
42
+ for host diagnosis and external editor integrations; TexLite itself invokes
43
+ `harper-cli`.
44
+
45
+ Formatting does not require a host binary. The browser uses bundled `tex-fmt`
46
+ WASM for `.tex`, `.cls`, and `.sty`, and browser-side `bibtex-tidy` for `.bib`.
47
+
48
+ ### Optional writing checks
49
+
50
+ TexLite does not bundle Harper. To enable its spelling and grammar diagnostics,
51
+ install a Harper distribution that provides `harper-cli` (the same host package
52
+ normally also provides `harper-ls`) and make it available on the TexLite service
53
+ `PATH`:
54
+
55
+ ~~~bash
56
+ harper-cli --version
57
+ ~~~
58
+
59
+ The command is optional: if it is absent or temporarily fails, TexLite remains
60
+ usable and the browser's native English spellchecker is enabled instead. Native
61
+ browser spellchecking does not provide Harper grammar diagnostics or suggested
62
+ replacements.
63
+
64
+ ## Install and initialize
65
+
66
+ ### Global npm installation
67
+
68
+ The published package provides the `texlite` executable. Configuration and
69
+ project data are outside the global npm installation:
70
+
71
+ ~~~bash
72
+ npm install --global texlite
73
+ texlite init
74
+ texlite start
75
+ texlite status
76
+ ~~~
77
+
78
+ Open <http://127.0.0.1:3000>. `init` creates the configuration if absent,
79
+ validates the environment, initializes storage, and creates the first
80
+ administrator. The server will not start without an active administrator.
81
+
82
+ The normal lifecycle commands can be run from any directory:
83
+
84
+ ~~~bash
85
+ texlite stop
86
+ texlite restart
87
+ texlite logs
88
+ ~~~
89
+
90
+ For a clean upgrade, restart after npm has installed the new version:
91
+
92
+ ~~~bash
93
+ npm update --global texlite
94
+ texlite restart
95
+ ~~~
96
+
97
+ Uninstalling the package does not remove configuration or data:
98
+
99
+ ~~~bash
100
+ npm uninstall --global texlite
101
+ ~~~
102
+
103
+ ### Source installation
104
+
105
+ ~~~bash
106
+ npm ci
107
+ cp texlite.config.example.json texlite.config.json
108
+ export TEXLITE_CONFIG="$PWD/texlite.config.json"
109
+ # Edit texlite.config.json if needed.
110
+ npm run init
111
+ npm run build
112
+ npm start
113
+ ~~~
114
+
115
+ For non-interactive initialization, supply these environment variables only to
116
+ the initialization command:
117
+
118
+ ~~~bash
119
+ TEXLITE_INIT_USERNAME=admin \
120
+ TEXLITE_INIT_DISPLAY_NAME=Administrator \
121
+ TEXLITE_INIT_PASSWORD='use-a-password-of-at-least-8-characters' \
122
+ npm run init
123
+ ~~~
124
+
125
+ Avoid putting a password into shell history on a shared host.
126
+
127
+ ## Command reference
128
+
129
+ | Command | Purpose |
130
+ | --- | --- |
131
+ | `texlite init` | Create configuration and the initial administrator. |
132
+ | `texlite serve` | Run in the foreground; suitable for debugging, Docker, or systemd. |
133
+ | `texlite start` / `stop` / `restart` | Manage the bundled-PM2 service. |
134
+ | `texlite status` | Show a colored, systemctl-style status view; add `--json` for scripts. |
135
+ | `texlite logs` | Stream PM2-managed logs. |
136
+ | `texlite requirements` | Check default host commands on `PATH` without loading TexLite configuration or data. |
137
+ | `texlite doctor` | Show configuration/application checks and a table of required and optional host software. Add `--json` for scripts. |
138
+ | `texlite config` | Print effective configuration and paths without changing them. |
139
+
140
+ `start`, `stop`, `restart`, `status`, and `logs` use the PM2 runtime bundled
141
+ with the global npm package—no separate global PM2 install is necessary.
142
+ Managed startup waits for the HTTP health endpoint, and `restart` recreates the
143
+ managed process so it uses paths from the newly installed npm version.
144
+
145
+ For a source checkout, `ecosystem.config.cjs` and the `npm run pm2:*` scripts
146
+ remain available. Run exactly one forked instance: cluster mode and multiple
147
+ TexLite processes sharing one data directory are unsupported because
148
+ collaboration state, the compile queue, SQLite, and project files are local to
149
+ one process.
150
+
151
+ ## Configuration
152
+
153
+ ### Where configuration and data live
154
+
155
+ Configuration path precedence:
156
+
157
+ 1. `--config PATH` passed to `texlite`;
158
+ 2. `TEXLITE_CONFIG`;
159
+ 3. `$XDG_CONFIG_HOME/texlite/texlite.config.json`;
160
+ 4. `~/.config/texlite/texlite.config.json`.
161
+
162
+ Relative paths are resolved from the configuration file. The default data
163
+ directory is `$XDG_DATA_HOME/texlite`, or `~/.local/share/texlite` when
164
+ `XDG_DATA_HOME` is unset. Set `storage.dataDir` or `TEXLITE_DATA_DIR` to move
165
+ it. The data directory contains the SQLite database, project sources, compiled
166
+ output, history objects, and Git-token encryption key.
167
+
168
+ Use [texlite.config.example.json](texlite.config.example.json) as a complete
169
+ starting point. It intentionally uses `.texlite` for repository development;
170
+ `texlite init` instead writes the XDG data-directory default.
171
+
172
+ ### Important settings and effective defaults
173
+
174
+ | Setting | Default | Notes |
175
+ | --- | --- | --- |
176
+ | `siteName` | `TexLite` | Site title. |
177
+ | `adminEmail` | empty | Optional administrator contact address. |
178
+ | `server.host` / `server.port` | `127.0.0.1` / `3000` | Keep localhost unless the deployment is separately secured. |
179
+ | `storage.dataDir` | XDG data directory | Stores all persistent project data. |
180
+ | `clientDir` | Installed package's `dist/client` | Normally changed only for development or a custom deployment. |
181
+ | `sessionDays` | `14` | Login-session lifetime. |
182
+ | `uploads.maxFileSizeMB` | `50` MB | Limit for uploads, ZIP entries, and attachments. |
183
+ | `pdf.loadingStrategy` / `pdf.rangeThresholdMB` | `auto` / `5` MB | Chooses full transfer for small PDFs and byte ranges for larger ones. |
184
+ | `history.maxVersions` / `history.maxStorageMB` | `200` / `128` MB | Per-project ordinary-version count and soft storage limit. |
185
+ | `latex.latexmk` | `latexmk` | Host command. |
186
+ | `latex.defaultEngine` | `xelatex` | Must appear in the allowed list. |
187
+ | `latex.allowedEngines` | `pdflatex`, `xelatex`, `lualatex` | Engines available in the UI. |
188
+ | `latex.extraArgs` | `[]` | Additional configured compiler arguments. |
189
+ | `latex.compileTimeoutSeconds` | `600` | Per-job time limit. |
190
+ | `latex.maxCompileJobs` | `10` | Global concurrent LaTeX-process limit. |
191
+ | `latex.allowProjectLatexmkrc` | `true` | Enables an owner-configured, multi-line `latexmkrc`. |
192
+ | `git.binary` / `git.operationTimeoutSeconds` | `git` / `120` seconds | Used only by optional Git integration. |
193
+ | `git.githubApiBaseUrl` | `https://api.github.com` | GitHub REST API endpoint. |
194
+
195
+ The current environment-variable overrides are:
196
+
197
+ ~~~text
198
+ TEXLITE_CONFIG
199
+ XDG_CONFIG_HOME XDG_DATA_HOME
200
+ TEXLITE_SITE_NAME TEXLITE_ADMIN_EMAIL
201
+ TEXLITE_HOST TEXLITE_PORT
202
+ TEXLITE_DATA_DIR TEXLITE_CLIENT_DIR
203
+ TEXLITE_SESSION_DAYS TEXLITE_MAX_UPLOAD_SIZE_MB
204
+ TEXLITE_PDF_LOADING_STRATEGY TEXLITE_PDF_RANGE_THRESHOLD_MB
205
+ TEXLITE_HISTORY_MAX_VERSIONS TEXLITE_HISTORY_MAX_STORAGE_MB
206
+ TEXLITE_LATEXMK TEXLITE_DEFAULT_ENGINE
207
+ TEXLITE_COMPILE_TIMEOUT TEXLITE_MAX_COMPILE_JOBS
208
+ TEXLITE_GIT TEXLITE_GIT_TIMEOUT
209
+ TEXLITE_GITHUB_API_URL
210
+ ~~~
211
+
212
+ Configuration is validated before TexLite opens the database or binds the HTTP
213
+ listener. Invalid JSON types, paths, limits, URLs, engine lists, timeout/queue
214
+ values, and cross-field combinations stop startup with a setting-specific,
215
+ actionable error. Explicit invalid values are never silently replaced with a
216
+ default. `texlite init` applies the same validation.
217
+
218
+ Accepted limits are: port `1–65535`, sessions `1–3650` days, upload size
219
+ `1–2048` MB, history count `10–5000`, history size `16–102400` MB, PDF range
220
+ threshold `1–2048` MB, compile timeout `1–3600` seconds, compile jobs `1–32`,
221
+ and Git timeout `1–3600` seconds.
222
+
223
+ Before every compile TexLite passes `-norc` to `latexmk`. A `.latexmkrc` found
224
+ in a ZIP upload, Git checkout, or project file tree is ignored. It is used only
225
+ when the owner explicitly saves it through Project Settings, which passes it
226
+ with `-r`. An `latexmkrc` is executable Perl configuration and should remain
227
+ disabled for users you do not trust.
228
+
229
+ TexLite never runs `tlmgr` or installs TeX packages. Updating the host TeX
230
+ distribution changes the environment used by subsequent compiles.
231
+
232
+ ## Development and verification
233
+
234
+ Run the API/server watcher and Vite in separate terminals:
235
+
236
+ ~~~bash
237
+ npm run dev # API/server: http://127.0.0.1:3000
238
+ npm run dev:web # Vite UI: http://127.0.0.1:5173
239
+ ~~~
240
+
241
+ Vite proxies `/api` requests to the server. Validate a production-style build
242
+ with:
243
+
244
+ ~~~bash
245
+ npm run typecheck
246
+ npm test
247
+ npm run build
248
+ npm start
249
+ ~~~
250
+
251
+ ## Backup and security
252
+
253
+ Back up the entire configured data directory, including `texlite.db`, its WAL
254
+ files, `git-token.key`, and `projects/`. Restoring saved GitHub tokens requires
255
+ the same encryption key. For an online copy of SQLite, include WAL files or use
256
+ a SQLite-aware backup method.
257
+
258
+ TexLite is designed for trusted users on localhost. Shell escape is disabled by
259
+ default and compile jobs have timeouts and concurrency limits, but LaTeX itself
260
+ is not a security boundary. Before exposing it to an untrusted network, add an
261
+ isolated compiler sandbox plus appropriate authentication and network controls.
package/README.md CHANGED
@@ -1,338 +1,115 @@
1
- # texLite
1
+ # TexLite
2
2
 
3
- texLite is a lightweight, local-first web workspace for writing, compiling, previewing, and discussing LaTeX documents. It is intended for a small group of trusted users on one server. It uses the LaTeX installation already available on the host instead of shipping a LaTeX container, and keeps the rest of the stack deliberately small.
4
-
5
- **Documentation:** English (this file) · [Design](DESIGN.md) · [简体中文](README.zh-CN.md)
6
-
7
- **Website:** [TexLite GitHub Pages](https://swufe-db-group.github.io/TexLite/)
3
+ A lightweight self-hosted alternative to Overleaf for *small, trusted* research
4
+ teams. Use your existing LaTeX distribution, with no heavyweight service stack.
8
5
 
9
6
  [![CI](https://github.com/SWUFE-DB-Group/TexLite/actions/workflows/ci.yml/badge.svg)](https://github.com/SWUFE-DB-Group/TexLite/actions/workflows/ci.yml)
10
7
  [![npm version](https://img.shields.io/npm/v/texlite?logo=npm&label=npm)](https://www.npmjs.com/package/texlite)
11
8
 
12
- ![texLite preview](preview.png)
13
-
14
- For design goals, architecture, collaboration and compilation behavior, history,
15
- navigation and diagnostics, GitHub backup, and data-management decisions, see
16
- [DESIGN.md](DESIGN.md).
17
-
18
- ## Requirements
19
-
20
- - Node.js 24 or newer
21
- - npm
22
- - git (optional; required only for the project-owner Git/GitHub integration)
23
- - latexmk
24
- - At least one configured engine: pdflatex, xelatex, or lualatex
9
+ **Documentation:** English (this file) · [Operations](OPERATIONS.md) · [Design](DESIGN.md) · [简体中文](README.zh-CN.md)
25
10
 
26
- Check the host before initialization:
27
-
28
- ~~~bash
29
- node --version
30
- npm --version
31
- latexmk --version
32
- xelatex --version
33
- # Optional, when Git/GitHub integration is needed:
34
- git --version
35
- ~~~
36
-
37
- npm run init and application startup check latexmk and every engine in latex.allowedEngines. Git is deliberately excluded from this core check, so a host without Git can initialize and run TexLite normally. When a project owner opens the Git panel or invokes a Git/GitHub operation, TexLite checks git.binary on demand and shows an actionable error if Git is unavailable.
11
+ **Website:** [TexLite GitHub Pages](https://swufe-db-group.github.io/TexLite/)
38
12
 
39
- Formatting is optional and runs in the browser. TexLite bundles the [`tex-fmt` npm package](https://www.npmjs.com/package/tex-fmt) (a WASM build) for `.tex`, `.cls`, and `.sty` files, and uses browser-side `bibtex-tidy` for `.bib` files. The editor settings panel accepts per-user/per-project TOML options for `tex-fmt`; no host formatter installation or PATH configuration is required.
13
+ ![TexLite workspace](preview-1.png)
14
+ ![TexLite project view](preview-2.png)
15
+
16
+ ## Why TexLite
17
+
18
+ - **Own the writing environment.** Use the host's TeX installation and keep
19
+ sources, history, and compiled output in one local data directory.
20
+ - **Collaborate without a large stack.** The default deployment is one Node.js
21
+ process, SQLite, and local files—plus real-time editing and source-level
22
+ comments for a small trusted team.
23
+
24
+ ## A practical distinction from Overleaf
25
+
26
+ [Overleaf](https://www.overleaf.com/about/features-overview) is a strong choice
27
+ when its hosted product or broader ecosystem is the right fit. TexLite addresses
28
+ a narrower self-hosted use case:
29
+
30
+ - A shared hosted service can queue, slow down, or time out at usage peaks.
31
+ - Overleaf's open-source [Community Edition](https://github.com/overleaf/overleaf)
32
+ follows a more involved [Docker deployment path](https://docs.overleaf.com/on-premises/getting-started/what-is-the-overleaf-toolkit), and
33
+ [source comments are a Server Pro feature](https://docs.overleaf.com/on-premises/user-and-project-management/roles-and-permissions).
34
+ - TexLite uses the server's existing TeX environment, runs as a small
35
+ single-host stack, and includes real-time source comments and replies.
36
+
37
+ Self-hosting does not make every document compile faster: that still depends on
38
+ the host and the document. It does give the team control over capacity, TeX
39
+ updates, data location, and the collaboration workflow.
40
+
41
+ For a desktop-first, individual workflow, start with
42
+ [VS Code + LaTeX Workshop](https://github.com/James-Yu/LaTeX-Workshop) or
43
+ [TeXstudio](https://texstudio.org/) instead. TexLite is purpose-built for
44
+ shared browser writing, not a replacement for a personal IDE.
45
+
46
+ ## What the writing workflow includes
47
+
48
+ - Projects with folders, ZIP import/export, tags, sharing, ownership transfer,
49
+ archiving, and a private per-user citation library.
50
+ - CodeMirror editing with LaTeX/BibTeX highlighting, folding, completion,
51
+ optional Vim mode, formatting, spelling/grammar assistance, search/replace,
52
+ and source/PDF SyncTeX navigation.
53
+ - Yjs-based collaborative source editing, active-session presence, comments
54
+ anchored to source text, replies, resolution, and permissions that let
55
+ reviewers comment without changing source.
56
+ - `latexmk` compilation with selectable engines, project settings, structured
57
+ diagnostics, cached successful PDFs, downloadable artifacts, and optional
58
+ project-level `latexmkrc`.
59
+ - Per-project history and owner-only Git/GitHub backup. Git is optional and is
60
+ checked only when its integration is used.
40
61
 
41
62
  ## Quick start
42
63
 
43
- ### Global npm installation
64
+ Install Node.js 24 or newer, `latexmk`, and at least one TeX engine such as
65
+ `pdflatex`, `xelatex`, or `lualatex`. Git is needed only for the optional
66
+ Git/GitHub integration.
44
67
 
45
- The published package provides a `texlite` executable. It keeps configuration
46
- and project data outside the global npm installation:
68
+ After installation, `texlite requirements` checks the relevant host software
69
+ and versions before initialization.
47
70
 
48
71
  ~~~bash
49
72
  npm install --global texlite
73
+ texlite requirements
50
74
  texlite init
51
75
  texlite start
52
76
  texlite status
53
77
  ~~~
54
78
 
55
- Open http://127.0.0.1:3000. The service can be stopped or restarted from any
56
- working directory:
79
+ Open <http://127.0.0.1:3000>. `texlite init` creates the configuration and the
80
+ first administrator; public registration is deliberately unavailable.
57
81
 
58
- ~~~bash
59
- texlite stop
60
- texlite restart
61
- texlite logs
62
- ~~~
63
-
64
- The default configuration is
65
- `$XDG_CONFIG_HOME/texlite/texlite.config.json`, or
66
- `~/.config/texlite/texlite.config.json` when `XDG_CONFIG_HOME` is not set. The
67
- default data directory is `$XDG_DATA_HOME/texlite`, or
68
- `~/.local/share/texlite`. Use `--config PATH` or `TEXLITE_CONFIG` to select a
69
- different configuration file.
70
-
71
- `texlite serve` runs the server in the foreground and is suitable for Docker,
72
- systemd, and debugging. `start`, `status`, `stop`, `restart`, and `logs` use the
73
- PM2 dependency bundled with the package. Managed startup waits until the HTTP
74
- health endpoint is ready; `status` reports `unhealthy` if PM2 is running but the
75
- managed process is not actually serving TexLite. `restart` recreates the PM2
76
- entry so npm upgrades always use the current package paths and environment.
77
- Failed startup attempts are bounded instead of entering an unlimited restart
78
- loop.
79
-
80
- For a clean upgrade:
82
+ For upgrades and routine management:
81
83
 
82
84
  ~~~bash
83
85
  npm update --global texlite
84
86
  texlite restart
85
- ~~~
86
-
87
- Uninstalling the npm package does not remove the configuration or project data:
88
-
89
- ~~~bash
90
- npm uninstall --global texlite
91
- ~~~
92
-
93
- ### Repository/source installation
94
-
95
- ~~~bash
96
- npm ci
97
- cp texlite.config.example.json texlite.config.json
98
- export TEXLITE_CONFIG="$PWD/texlite.config.json"
99
- # Edit texlite.config.json if needed.
100
- npm run init
101
- npm run build
102
- npm start
103
- ~~~
104
-
105
- The default server binds to localhost and does not expose public registration.
106
- The initialization command asks for the first administrator account; the server
107
- refuses to start until at least one active administrator exists.
108
-
109
- For a non-interactive initialization, set the following environment variables for that command only:
110
-
111
- ~~~bash
112
- TEXLITE_INIT_USERNAME=admin \
113
- TEXLITE_INIT_DISPLAY_NAME=Administrator \
114
- TEXLITE_INIT_PASSWORD='use-a-password-of-at-least-8-characters' \
115
- npm run init
116
- ~~~
117
-
118
- Avoid putting the password in shell history on a shared machine.
119
-
120
- ## Development and verification
121
-
122
- Run the API/server watcher and Vite in separate terminals:
123
-
124
- ~~~bash
125
- npm run dev # API and server at http://127.0.0.1:3000
126
- npm run dev:web # Vite UI at http://127.0.0.1:5173
127
- ~~~
128
-
129
- Vite proxies /api requests to the server. Before a production-style run, use:
130
-
131
- ~~~bash
132
- npm run typecheck
133
- npm test
134
- npm run build
135
- npm start
136
- ~~~
137
-
138
- ## Configuration
139
-
140
- Configuration path precedence is:
141
-
142
- 1. `--config PATH` passed to the `texlite` executable;
143
- 2. `TEXLITE_CONFIG`;
144
- 3. `$XDG_CONFIG_HOME/texlite/texlite.config.json`;
145
- 4. `~/.config/texlite/texlite.config.json`.
146
-
147
- Relative paths in the configuration are resolved relative to that configuration
148
- file. `storage.dataDir` defaults to `$XDG_DATA_HOME/texlite`, or
149
- `~/.local/share/texlite`. Set `storage.dataDir` in the configuration, or use
150
- `TEXLITE_DATA_DIR`, to choose another data directory. The production client
151
- bundle defaults to the `dist/client` directory inside the installed package;
152
- `TEXLITE_CLIENT_DIR` can override it for development or custom deployments.
153
-
154
- The example configuration is intentionally complete:
155
-
156
- ~~~json
157
- {
158
- "siteName": "TexLite",
159
- "adminEmail": "admin@example.com",
160
- "sessionDays": 14,
161
- "server": { "host": "127.0.0.1", "port": 3000 },
162
- "storage": { "dataDir": ".texlite" },
163
- "uploads": { "maxFileSizeMB": 50 },
164
- "pdf": { "loadingStrategy": "auto", "rangeThresholdMB": 5 },
165
- "history": { "maxVersions": 200, "maxStorageMB": 128 },
166
- "git": {
167
- "binary": "git",
168
- "operationTimeoutSeconds": 120,
169
- "githubApiBaseUrl": "https://api.github.com"
170
- },
171
- "latex": {
172
- "latexmk": "latexmk",
173
- "defaultEngine": "xelatex",
174
- "allowedEngines": ["pdflatex", "xelatex", "lualatex"],
175
- "extraArgs": [],
176
- "allowProjectLatexmkrc": true,
177
- "compileTimeoutSeconds": 600,
178
- "maxCompileJobs": 10
179
- }
180
- }
181
- ~~~
182
-
183
- The checked-in example uses `.texlite` as an explicit repository-development
184
- path. A configuration generated by `texlite init` uses the XDG data directory
185
- default described above instead.
186
-
187
- Important settings:
188
-
189
- - server.host and server.port: network bind address and port. Keep the host at 127.0.0.1 unless a separately secured deployment is intended.
190
- - storage.dataDir: SQLite database, project sources, compile output, and the Git token encryption key.
191
- - uploads.maxFileSizeMB: maximum size for a project upload, a ZIP entry, project files, and attachments. The default is 50 MB.
192
- - pdf.loadingStrategy: PDF.js transfer mode: `auto`, `full`, or `range`. In `auto` mode, PDFs at or below `pdf.rangeThresholdMB` use one cache-friendly response; larger PDFs use byte-range requests.
193
- - pdf.rangeThresholdMB: automatic Range threshold, defaulting to 5 MB. This is a deployment-level preview setting, not a project compiler option.
194
- - history.maxVersions: maximum number of ordinary, unlabeled versions retained per project. Initial and labeled versions are protected.
195
- - history.maxStorageMB: soft per-project limit for deduplicated history objects. The oldest ordinary versions are removed first; protected versions and the current internal baseline can exceed this limit.
196
- - latex.defaultEngine, latex.allowedEngines, latex.extraArgs: compile choices available in the UI.
197
- - latex.compileTimeoutSeconds: timeout for one compile job.
198
- - latex.maxCompileJobs: global number of concurrent LaTeX processes. Jobs for the same project and root document are serialized; newer source versions supersede older queued requests. Different root documents use independent workspaces and may compile concurrently within this global limit.
199
- - Compilation copies a short-lived immutable source snapshot, then runs `latexmk` outside the ordinary project-operation queue. Editing and retained-PDF reads can continue; Git checkout, history restore, deletion, and compile-cache cleanup wait for active compilation to finish.
200
- - latex.allowProjectLatexmkrc: allow a project to supply a multi-line latexmkrc. A project rc file is executable Perl configuration and should only be enabled for trusted users.
201
-
202
- Before every compile TexLite passes `-norc` to latexmk. Therefore a `.latexmkrc`
203
- included directly in an uploaded ZIP, Git checkout, or project source is ignored.
204
- The file is read only when the owner explicitly selects it in Project Settings,
205
- where TexLite passes it with `-r`.
206
-
207
- ### Effective defaults and startup validation
208
-
209
- When a setting is omitted, texLite uses the following built-in defaults (the
210
- generated example file may choose to show an explicit value such as an admin
211
- email):
212
-
213
- | Setting | Effective default |
214
- | --- | --- |
215
- | `siteName` | `TexLite` |
216
- | `adminEmail` | empty |
217
- | `server.host` / `server.port` | `127.0.0.1` / `3000` |
218
- | `storage.dataDir` | `$XDG_DATA_HOME/texlite` or `~/.local/share/texlite` |
219
- | `clientDir` | `dist/client` inside the installed package |
220
- | `sessionDays` | `14` |
221
- | `uploads.maxFileSizeMB` | `50` MB |
222
- | `pdf.loadingStrategy` | `auto` |
223
- | `pdf.rangeThresholdMB` | `5` MB |
224
- | `history.maxVersions` | `200` ordinary versions per project |
225
- | `history.maxStorageMB` | `128` MB per project (soft limit) |
226
- | `latex.latexmk` | `latexmk` |
227
- | `latex.defaultEngine` | `xelatex` |
228
- | `latex.allowedEngines` | `pdflatex`, `xelatex`, `lualatex` |
229
- | `latex.extraArgs` | `[]` |
230
- | `latex.allowProjectLatexmkrc` | `true` |
231
- | `latex.compileTimeoutSeconds` | `600` seconds |
232
- | `latex.maxCompileJobs` | `10` |
233
- | `git.binary` / `git.operationTimeoutSeconds` | `git` / `120` seconds |
234
- | `git.githubApiBaseUrl` | `https://api.github.com` |
235
-
236
- Configuration is validated before environment checks, database opening, or
237
- the HTTP listener starts. Explicit values are never silently replaced by a
238
- default. The accepted ranges are: port `1–65535`, sessions `1–3650` days,
239
- upload size `1–2048` MB, history versions `10–5000`, history storage
240
- `16–102400` MB, PDF Range threshold `1–2048` MB, compile timeout `1–3600` seconds, compile jobs `1–32`,
241
- and Git timeout `1–3600` seconds. Engine names must be supported, unique, and
242
- the allowed-engine list must include the selected default engine. Data and
243
- project paths must not point at files (the data directory cannot be the
244
- filesystem root); a missing data directory must have an existing writable
245
- parent. The GitHub API endpoint must be an `http://` or `https://` URL.
246
-
247
- Invalid JSON types, empty required strings, malformed integers (including
248
- decimal or non-numeric environment overrides), unsupported engines, invalid
249
- URLs, and unusable paths stop startup with the setting name, expected value,
250
- and a remediation hint. The same validation runs during `npm run init`, so a
251
- configuration can be checked before creating the first administrator.
252
-
253
- Environment variables override the corresponding file values:
254
-
255
- ~~~text
256
- TEXLITE_CONFIG
257
- XDG_CONFIG_HOME XDG_DATA_HOME
258
- TEXLITE_SITE_NAME TEXLITE_ADMIN_EMAIL
259
- TEXLITE_HOST TEXLITE_PORT
260
- TEXLITE_DATA_DIR TEXLITE_CLIENT_DIR
261
- TEXLITE_SESSION_DAYS TEXLITE_MAX_UPLOAD_SIZE_MB
262
- TEXLITE_PDF_LOADING_STRATEGY TEXLITE_PDF_RANGE_THRESHOLD_MB
263
- TEXLITE_HISTORY_MAX_VERSIONS TEXLITE_HISTORY_MAX_STORAGE_MB
264
- TEXLITE_LATEXMK TEXLITE_DEFAULT_ENGINE
265
- TEXLITE_COMPILE_TIMEOUT TEXLITE_MAX_COMPILE_JOBS
266
- TEXLITE_GIT TEXLITE_GIT_TIMEOUT
267
- TEXLITE_GITHUB_API_URL
268
- ~~~
269
-
270
- texLite does not run tlmgr or install missing packages. Updating TeX Live on the host changes the environment used by the next compile.
271
-
272
- ## Service management
273
-
274
- For a global npm installation, the lifecycle commands use the bundled PM2
275
- runtime. No separate global PM2 installation is needed:
276
-
277
- ~~~bash
278
- texlite start
279
- texlite status
280
87
  texlite logs
281
- texlite restart
282
- texlite stop
283
- ~~~
284
-
285
- `texlite status` uses a colored, systemctl-style terminal view. Use
286
- `texlite status --json` for scripts and monitoring integrations.
287
-
288
- `texlite doctor` validates configuration, paths, LaTeX, and the administrator;
289
- add `--git` to check the optional Git integration. `texlite config` prints the
290
- effective paths and values. `texlite serve` keeps the process in the foreground
291
- and does not start PM2.
292
-
293
- <details>
294
- <summary>Repository deployment with a separately installed PM2</summary>
295
-
296
- For repository deployments, `ecosystem.config.cjs` and the npm PM2 wrappers are
297
- also available. It deliberately runs one forked instance (`instances: 1`);
298
- cluster mode is not supported because collaboration state, the compile queue,
299
- SQLite, and the project filesystem are local to one process.
300
-
301
- ~~~bash
302
- npm install --global pm2
303
- npm run build
304
- pm2 start ecosystem.config.cjs
305
- pm2 status
306
- pm2 logs texlite
307
88
  ~~~
308
89
 
309
- The repository wrappers are `npm run pm2:start`, `npm run pm2:restart`,
310
- `npm run pm2:stop`, `npm run pm2:delete`, `npm run pm2:logs`, and
311
- `npm run pm2:save`.
90
+ `texlite serve` runs in the foreground for debugging, Docker, or systemd.
91
+ `start`, `stop`, `restart`, `status`, and `logs` use the PM2 runtime bundled
92
+ with the npm package. Run `texlite help` for the complete command list.
312
93
 
313
- After deploying new code:
94
+ ## Documentation map
314
95
 
315
- ~~~bash
316
- npm run build
317
- pm2 restart texlite --update-env
318
- ~~~
319
-
320
- To keep the process across reboots, run the command printed by pm2 startup, then save the process list:
321
-
322
- ~~~bash
323
- pm2 save
324
- ~~~
325
-
326
- Useful lifecycle commands are pm2 stop texlite, pm2 restart texlite, pm2 delete texlite, and pm2 monit.
327
-
328
- </details>
329
-
330
- ## Security boundaries
96
+ | Need | Read |
97
+ | --- | --- |
98
+ | Installation, configuration paths, effective defaults, environment overrides, service management, backups, and security boundaries | [Operations guide](OPERATIONS.md) |
99
+ | Collaboration, source persistence, compilation isolation, history, and design trade-offs | [Design](DESIGN.md) |
100
+ | Testing an npm package before publication | [NPM testing guide](NPM_TESTING.md) |
101
+ | Complete configuration starting point | [texlite.config.example.json](texlite.config.example.json) |
331
102
 
332
- texLite is designed for trusted users on localhost. The default compiler disables shell escape, does not concatenate shell commands, and enforces compile timeouts and concurrency limits. Nevertheless, LaTeX itself and a project latexmkrc are not a security sandbox. Before exposing texLite to an untrusted network or public registration, add an isolated compiler sandbox and an appropriate authentication/reverse-proxy layer.
103
+ ## Scope and security
333
104
 
334
- ## License and status
105
+ TexLite is a single-host application for trusted users. It is not a compiler
106
+ sandbox: LaTeX and an enabled project `latexmkrc` can execute powerful local
107
+ behaviour. Keep the default `127.0.0.1` bind unless you add the authentication,
108
+ network controls, and isolated compiler environment appropriate for an
109
+ untrusted deployment.
335
110
 
336
- texLite is licensed under the GNU Affero General Public License v3.0. See [LICENSE](LICENSE). If you need proprietary modifications or commercial terms different from AGPL-3.0, contact the copyright holder for a separate commercial license.
111
+ ## License
337
112
 
338
- This repository is an early, single-host application rather than a drop-in replacement for Overleaf. Review and adapt the deployment, backup, and security settings for the environment in which it will run.
113
+ TexLite is licensed under the GNU Affero General Public License v3.0; see
114
+ [LICENSE](LICENSE). For proprietary modifications or commercial terms that
115
+ differ from AGPL-3.0, contact the copyright holder.