@lvce-editor/editor-worker 19.2.0 → 19.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,146 @@
1
1
  # Editor Worker
2
2
 
3
- Webworker for the core editing functionality in Lvce Editor.
3
+ Editor Worker contains the core editing logic for [Lvce Editor](https://github.com/lvce-editor/lvce-editor). It runs as a web worker and keeps the editor's document state, command handling, widget state, and virtual DOM rendering work off the renderer process.
4
+
5
+ ## Features
6
+
7
+ - Text document editing, selections, cursor movement, clipboard commands, indentation, line movement, sorting, commenting, undo, and redo.
8
+ - Virtual DOM generation for editor rows, cursors, selections, gutters, diagnostics, scroll bars, messages, and inline widgets.
9
+ - Editor widgets for completions, completion details, hover, find, rename, source actions, color picker, and code generation.
10
+ - Extension-host integration for diagnostics, hover, definitions, type definitions, tab completion, source actions, formatting, and tokenizers.
11
+ - Incremental rendering, diffing, text measurement, syntax highlighting, link detection, and editor preference handling.
12
+ - Unit and end-to-end coverage for editing behavior, widget rendering, extension fixtures, and browser-facing editor flows.
13
+
14
+ ## Repository Layout
15
+
16
+ ```text
17
+ .
18
+ ├── packages/editor-worker # Worker source, RPC API types, editor modules, and unit tests
19
+ ├── packages/build # Build, static export, dependency cache, and memory measurement scripts
20
+ ├── packages/e2e # Playwright-based end-to-end tests and fixture extensions
21
+ └── packages/server # Local test server wrapper for development and e2e runs
22
+ ```
23
+
24
+ ## Requirements
25
+
26
+ - Node.js `24.16.0` or newer compatible with the version in `.nvmrc`
27
+ - npm
28
+ - Chromium for Playwright e2e tests
29
+
30
+ If you use `nvm`, run:
31
+
32
+ ```sh
33
+ nvm use
34
+ ```
35
+
36
+ ## Getting Started
37
+
38
+ Install dependencies from the repository root:
39
+
40
+ ```sh
41
+ npm ci
42
+ ```
43
+
44
+ The root `postinstall` script bootstraps the packages with Lerna.
45
+
46
+ Start a development build and local test server:
47
+
48
+ ```sh
49
+ npm run dev
50
+ ```
51
+
52
+ This starts the editor worker watch build and the Lvce Editor test server with `packages/e2e` as the test path.
53
+
54
+ ## Common Commands
55
+
56
+ Run these commands from the repository root unless noted otherwise.
57
+
58
+ | Command | Description |
59
+ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------- |
60
+ | `npm run build` | Bundles the editor worker into `.tmp/dist/dist/editorWorkerMain.js` and prepares a publishable package in `.tmp/dist`. |
61
+ | `npm run build:watch` | Watches `packages/editor-worker/src/editorWorkerMain.ts` and rebuilds the worker with esbuild. |
62
+ | `npm run build:static` | Exports a static test build into `.tmp/static`. Run `npm run build` first. |
63
+ | `npm run dev` | Runs the watch build and local test server together. |
64
+ | `npm test` | Runs package test scripts through Lerna. |
65
+ | `npm run type-check` | Runs TypeScript project references for all packages. |
66
+ | `npm run lint` | Runs ESLint, Prettier checks, and Knip. |
67
+ | `npm run format` | Formats the repository with Prettier. |
68
+
69
+ Package-specific commands:
70
+
71
+ ```sh
72
+ cd packages/e2e
73
+ npm run e2e:headless
74
+ npm run e2e
75
+ ```
76
+
77
+ ```sh
78
+ cd packages/build
79
+ npm run measure
80
+ npm run measure:visible
81
+ ```
82
+
83
+ ## Build Output
84
+
85
+ `npm run build` creates `.tmp/dist`, including:
86
+
87
+ - `dist/editorWorkerMain.js`, the bundled worker entry point.
88
+ - `dist/api/api.d.ts`, copied from the worker RPC API type definition.
89
+ - `package.json`, `README.md`, and `LICENSE` for publishing `@lvce-editor/editor-worker`.
90
+
91
+ Version resolution for release builds comes from, in order:
92
+
93
+ 1. `RG_VERSION`
94
+ 2. `GIT_TAG`
95
+ 3. The current exact git tag
96
+ 4. `0.0.0-dev`
97
+
98
+ ## Worker Entry Points
99
+
100
+ - Runtime entry: `packages/editor-worker/src/editorWorkerMain.ts`
101
+ - Main worker bootstrap: `packages/editor-worker/src/parts/Main/Main.ts`
102
+ - Typed RPC surface: `packages/editor-worker/src/parts/Api/Api.ts`
103
+
104
+ The worker listens for RPC messages, registers widget modules, initializes unhandled error handling, and delegates editor commands through the module structure in `packages/editor-worker/src/parts`.
105
+
106
+ ## Testing
107
+
108
+ Unit tests live in `packages/editor-worker/test` and are run by the editor-worker package's Jest setup.
109
+
110
+ End-to-end tests live in `packages/e2e/src` and use fixture extensions from `packages/e2e/fixtures`. Before running e2e tests locally, install Chromium if needed:
111
+
112
+ ```sh
113
+ cd packages/e2e
114
+ npx playwright install chromium
115
+ npm run e2e:headless
116
+ ```
117
+
118
+ ## CI and Releases
119
+
120
+ Pull requests and pushes to `main` run on Ubuntu, macOS, and Windows. CI builds the worker, exports the static test build, runs unit tests, type checks, linting, e2e tests, and memory measurement.
121
+
122
+ Tagged releases matching `v*.*.*` create a draft GitHub release, build the publishable `.tmp/dist` package, publish it to npm, and then publish the GitHub release.
123
+
124
+ ## Contributing
125
+
126
+ Keep changes focused on the relevant worker module and add or update tests near the behavior being changed. For user-facing editor behavior, prefer an e2e scenario in `packages/e2e/src`; for focused document, rendering, or command behavior, prefer a unit test in `packages/editor-worker/test`.
127
+
128
+ Before opening a pull request, run:
129
+
130
+ ```sh
131
+ npm run build
132
+ npm test
133
+ npm run type-check
134
+ npm run lint
135
+ ```
136
+
137
+ For changes that affect browser behavior, also run:
138
+
139
+ ```sh
140
+ cd packages/e2e
141
+ npm run e2e:headless
142
+ ```
143
+
144
+ ## License
145
+
146
+ MIT