Skip to content

Commit 4a4db9a

Browse files
committed
add diagrams to docs
1 parent 0c2b80a commit 4a4db9a

14 files changed

Lines changed: 324 additions & 148 deletions

docs/docs/contribution/adding-languages.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,36 @@ If you still have doubts if the language qualifies, [let's discuss it](https://g
1414

1515
## Checklist when adding
1616

17+
```mermaid
18+
flowchart TD
19+
A[Add Language] --> B["Create language specs<br/>src/livecodes/languages/"]
20+
B --> C["Add to languages.ts<br/>or processors.ts"]
21+
22+
C --> D{"Compiler needs<br/>separate build?"}
23+
D -->|Yes| E["Add to build script<br/>scripts/build.js"]
24+
D -->|No| F{"New packages/<br/>static files?"}
25+
26+
F -->|Yes| G["Add to browser-compilers repo<br/>and CDN"]
27+
F -->|No| H["Reference vendors.ts<br/>for CDN links"]
28+
29+
E --> H
30+
G --> H
31+
32+
H --> I["Add name/aliases<br/>to sdk/models.ts"]
33+
I --> J["Add editor support<br/>Monaco/CodeMirror/Prismjs"]
34+
J --> K["Add language info<br/>html/language-info.html"]
35+
K --> L{"Starter template?"}
36+
37+
L -->|Yes| M["Create template<br/>Add to TemplateList, command-menu,<br/>language-info"]
38+
L -->|No| N["Add e2e tests"]
39+
40+
M --> N
41+
N --> O["Add language docs<br/>docs/docs/languages/"]
42+
O --> P["Add to docs slider<br/>LanguageSliders.tsx"]
43+
P --> Q["Add licenses<br/>vendor-licenses.mdx"]
44+
Q --> R["Update badge<br/>README.mdx"]
45+
```
46+
1747
- [ ] Add [language specs](https://github.com/live-codes/livecodes/tree/develop/src/livecodes/languages) and include that in the list of [languages](https://github.com/live-codes/livecodes/blob/develop/src/livecodes/languages/languages.ts) or [processors](https://github.com/live-codes/livecodes/blob/develop/src/livecodes/languages/processors.ts).
1848
- [ ] The compiler +/- formatter should be lazy-loaded.
1949
- [ ] If the compiler needs a separate build, add it to the [build script](https://github.com/live-codes/livecodes/blob/3a2617850f09487b9af92de862093f082942b8a9/scripts/build.js#L207).

docs/docs/contribution/build-system.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ The main build script is located at [`scripts/build.js`](../../../scripts/build.
3939

4040
### Build Phases
4141

42+
```mermaid
43+
flowchart LR
44+
A[1. Preparation] --> B[2. ESM Build]
45+
B --> C[3. IIFE Build]
46+
C --> D[4. Workers Build]
47+
D --> E[5. Styles Build]
48+
E --> F[6. SDK Build]
49+
F --> G[7. I18n Build]
50+
G --> H[Post-Build<br/>Hash & CSS Injection]
51+
```
52+
4253
#### 1. Preparation (`prepareDir`)
4354

4455
- Creates output directories (`build/livecodes/`, `build/sdk/`, `build/tmp/`)

docs/docs/contribution/code-formatting-system.mdx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@ LiveCodes uses [Prettier](https://prettier.io/) as the primary code formatter, w
88

99
## Architecture
1010

11-
```
12-
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
13-
│ core.ts │────▶│ get-formatter.ts │────▶│ formatter.ts │
14-
│ (format call) │ │ (factory) │ │ (Web Worker) │
15-
└──────────────────┘ └──────────────────┘ └──────────────────┘
16-
17-
18-
┌──────────────────┐
19-
│ format.worker.ts │
20-
│ - Prettier │
21-
│ - Custom parsers │
22-
│ - Custom formatters │
23-
└──────────────────┘
11+
```mermaid
12+
flowchart LR
13+
A[core.ts<br/>format call] --> B[get-formatter.ts<br/>factory]
14+
B --> C[formatter.ts<br/>Web Worker]
15+
C --> D[format.worker.ts]
16+
17+
subgraph "Worker Content"
18+
D --> E[Prettier]
19+
D --> F[Custom parsers]
20+
D --> G[Custom formatters]
21+
end
2422
```
2523

2624
## Formatter Interface

docs/docs/contribution/compiler-system.mdx

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,35 @@ The compiler system uses a **worker-based architecture** to perform compilation
1818

1919
### Key Components
2020

21-
```
22-
src/livecodes/compiler/
23-
├── index.ts # Public API exports
24-
├── models.ts # Type definitions
25-
├── create-compiler.ts # Main compiler factory
26-
├── get-compiler.ts # Compiler instance getter
27-
├── get-all-compilers.ts # Compiler registry builder
28-
├── compile.worker.ts # Web Worker for compilation
29-
├── compile.page.ts # Page-level compilers
30-
├── compile-in-compiler.ts# Worker communication helper
31-
├── compile-blocks.ts # SFC block compilation
32-
├── compiler-sandbox.ts # iframe sandbox creation
33-
├── import-map.ts # Import resolution utilities
34-
├── compiler-utils.ts # iframe initialization
35-
└── utils.ts # Utility functions
21+
```mermaid
22+
graph TD
23+
subgraph "src/livecodes/compiler/"
24+
A[index.ts] --> B[models.ts]
25+
A --> C[create-compiler.ts]
26+
A --> D[get-compiler.ts]
27+
A --> E[get-all-compilers.ts]
28+
A --> F[compile.worker.ts]
29+
A --> G[compile.page.ts]
30+
A --> H[compile-in-compiler.ts]
31+
A --> I[compile-blocks.ts]
32+
A --> J[compiler-sandbox.ts]
33+
A --> K[import-map.ts]
34+
A --> L[compiler-utils.ts]
35+
A --> M[utils.ts]
36+
end
37+
38+
B["Type definitions"]
39+
C["Main compiler factory"]
40+
D["Compiler instance getter"]
41+
E["Compiler registry builder"]
42+
F["Web Worker for compilation"]
43+
G["Page-level compilers"]
44+
H["Worker communication helper"]
45+
I["SFC block compilation"]
46+
J["iframe sandbox creation"]
47+
K["Import resolution utilities"]
48+
L["iframe initialization"]
49+
M["Utility functions"]
3650
```
3751

3852
## Core Concepts
@@ -296,17 +310,19 @@ Workers and main thread communicate via typed messages:
296310

297311
### Example Message Flow
298312

299-
```
300-
Main Thread Worker
301-
| |
302-
|-- init (config) ------------>|
303-
|<-- init-success -------------|
304-
| |
305-
|-- load (typescript) -------->|
306-
|<-- loaded (typescript) ------|
307-
| |
308-
|-- compile (code, language) ->|
309-
|<-- compiled (result) --------|
313+
```mermaid
314+
sequenceDiagram
315+
participant Main as Main Thread
316+
participant Worker as Worker
317+
318+
Main->>Worker: init (config)
319+
Worker->>Main: init-success
320+
321+
Main->>Worker: load (typescript)
322+
Worker->>Main: loaded (typescript)
323+
324+
Main->>Worker: compile (code, language)
325+
Worker->>Main: compiled (result)
310326
```
311327

312328
## Import Resolution (`import-map.ts`)

docs/docs/contribution/config-system.mdx

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,21 @@ For individual configuration properties and their meanings, see the [Configurati
1616

1717
## Architecture
1818

19-
```
20-
src/livecodes/config/
21-
├── index.ts # Public API exports
22-
├── default-config.ts # Default configuration values
23-
├── build-config.ts # Configuration builder (merges defaults + user + params)
24-
├── config.ts # Config getters/setters and helpers
25-
├── validate-config.ts # Configuration validation
26-
└── upgrade-config.ts # Version upgrade migrations
19+
```mermaid
20+
graph TD
21+
subgraph "src/livecodes/config/"
22+
A[index.ts] --> B[default-config.ts]
23+
A --> C[build-config.ts]
24+
A --> D[config.ts]
25+
A --> E[validate-config.ts]
26+
A --> F[upgrade-config.ts]
27+
end
28+
29+
B["Default configuration values"]
30+
C["Configuration builder"]
31+
D["Config getters/setters"]
32+
E["Configuration validation"]
33+
F["Version upgrade migrations"]
2734
```
2835

2936
## Configuration Types
@@ -50,6 +57,19 @@ interface Config extends ContentConfig, AppConfig, UserConfig {}
5057

5158
## Configuration Flow
5259

60+
```mermaid
61+
flowchart TD
62+
A[Default Configuration<br/>default-config.ts] --> B[merge]
63+
C[Saved Project Configuration<br/>from storage] --> B
64+
B --> D[merge]
65+
E[User Configuration<br/>programmatic/SDK] --> D
66+
D --> F[merge]
67+
G[URL Query Parameters] --> F
68+
F --> H[merge]
69+
I[URL Hash Parameters] --> H
70+
H --> J["Final Configuration<br/>fixLanguageNames()"]
71+
```
72+
5373
### 1. Default Configuration
5474

5575
`default-config.ts` provides the base configuration:

docs/docs/contribution/editor-system.mdx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,29 @@ All editors implement the `CodeEditor` interface defined in `models.ts`.
1414

1515
### Editor Selection
1616

17-
- **Headless mode**`fake` editor
18-
- **Result mode** (non-console/compiled) → `fake` editor
19-
- **Simple mode** (inactive editor) → `fake` editor
20-
- **Simple mode** (active editor) → `codemirror`
21-
- **Codeblock or Lite mode**`codejar`
22-
- **Mobile**`codemirror` (for auto)
23-
- **Desktop**`monaco` (for auto)
24-
- **Explicit selection**`monaco`, `codemirror`, or `codejar`
17+
```mermaid
18+
flowchart TD
19+
A[Mode?] --> B{Headless?}
20+
B -->|Yes| C[fake editor]
21+
B -->|No| D{Result mode<br/>non-console/compiled?}
22+
23+
D -->|Yes| C
24+
D -->|No| E{Simple mode?}
25+
26+
E -->|Yes| F{Active editor?}
27+
F -->|Yes| G[codemirror]
28+
F -->|No| C
29+
30+
E -->|No| H{Codeblock or Lite mode?}
31+
H -->|Yes| I[codejar]
32+
33+
H -->|No| J{Explicit selection?}
34+
J -->|Yes| K[Selected editor<br/>monaco/codemirror/codejar]
35+
36+
J -->|No| L{Mobile?}
37+
L -->|Yes| G
38+
L -->|No| M[monaco]
39+
```
2540

2641
---
2742

docs/docs/contribution/i18n.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,31 @@ Maintainers are responsible for managing the i18n workflow and ensuring the qual
185185

186186
We consider the i18n process to consist of two parts:
187187

188+
```mermaid
189+
flowchart TD
190+
subgraph "No-Source Update"
191+
A[Lokalise master branch] --> B[i18n/develop branch]
192+
B --> C[Auto PR if changes]
193+
end
194+
195+
subgraph "Source Update"
196+
D[Developers add strings<br/>data-i18n / translateString] --> E[npm run i18n-export]
197+
E --> F[Generate .lokalise.json<br/>and .ts files]
198+
F --> G[Commit & push]
199+
G --> H[PR created & reviewed]
200+
H --> I[PR merged]
201+
I --> J[Auto comment: .i18n-update-push]
202+
J --> K[Comment triggers workflow<br/>Creates i18n/branch]
203+
K --> L[Push source to Lokalise]
204+
L --> M[Translators work on Lokalise]
205+
M --> N[Comment .i18n-update-pull]
206+
N --> O[Pull translations<br/>Update .ts files]
207+
O --> P[Create PR to develop]
208+
P --> Q[Merge to develop]
209+
Q --> R[Say merge to master<br/>to sync Lokalise]
210+
end
211+
```
212+
188213
#### No-Source Update
189214

190215
This means there are no changes to the source code/texts, only translations are updated. Adding new languages or updating existing translations are examples of this part.

docs/docs/contribution/language-support-system.mdx

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,21 @@ These compilers and runtimes can be provided either as **JavaScript** or **WebAs
2828

2929
## Architecture
3030

31-
```
32-
┌─────────────────────────────────────────────────────────────────────┐
33-
│ languages/index.ts │
34-
│ exports: languages, processors, utils, prettier, css-presets │
35-
└─────────────────────────────────────────────────────────────────────┘
36-
37-
┌───────────────────────┼───────────────────────┐
38-
│ │ │
39-
▼ ▼ ▼
40-
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
41-
│ languages.ts │ │ processors.ts │ │ prettier.ts │
42-
│ - Language[] │ │ - Processor[] │ │ - parserPlugins │
43-
└──────────────────┘ └──────────────────┘ └──────────────────┘
44-
│ │
45-
▼ ▼
46-
┌───────────────────┐ ┌──────────────────┐
47-
│ lang-<name>/ │ │ <processor>/ │
48-
│-lang-*.ts │ │ - processor-*.ts │
49-
│-lang-*-script.ts │ └──────────────────┘
50-
│-lang-*-compiler.ts│
51-
└───────────────────┘
31+
```mermaid
32+
graph TD
33+
A["languages/index.ts<br/>exports: languages, processors, utils, prettier, css-presets"]
34+
35+
A --> B[languages.ts]
36+
A --> C[processors.ts]
37+
A --> D[prettier.ts]
38+
39+
B --> E["lang-{name}/<br/>lang-*.ts<br/>lang-*-script.ts<br/>lang-*-compiler.ts"]
40+
C --> F["{processor}/<br/>processor-*.ts"]
41+
42+
D --> G["parserPlugins"]
43+
44+
B["Language[]"]
45+
C["Processor[]"]
5246
```
5347

5448
---

docs/docs/contribution/release.mdx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,35 @@
22

33
To start a new release:
44

5+
```mermaid
6+
flowchart TD
7+
A["Checkout develop branch"] --> B["Ensure no uncommitted changes"]
8+
B --> C["npm run start-release"]
9+
C --> D{App or SDK?}
10+
11+
D -->|App| E["Increment appVersion<br/>in package.json"]
12+
D -->|SDK| F["Increment version<br/>in src/sdk/package.sdk.json"]
13+
14+
E --> G["Generate changelog"]
15+
F --> G
16+
17+
G --> H["Create release branch<br/>releases/v{version}"]
18+
H --> I["Push to GitHub<br/>triggers preview deploy"]
19+
I --> J["Create PR to develop"]
20+
21+
J --> K["PR merged"]
22+
K --> L["GitHub Action workflow"]
23+
24+
L --> M["Build app/SDK"]
25+
M --> N["Create & push release tag"]
26+
N --> O["Compress build to zip/tar"]
27+
O --> P["Create GitHub release<br/>with changelog"]
28+
29+
P --> Q{App or SDK?}
30+
Q -->|App| R["Create permanent URL<br/>v{version}.livecodes.io"]
31+
Q -->|SDK| S["Publish to npm"]
32+
```
33+
534
- Checkout the branch `develop`.
635
- Make sure there are no uncommitted changes.
736
- Run `npm run start-release` and answer the prompts. This will:
@@ -25,9 +54,7 @@ To start a new release:
2554
- If App release -> create a permanent URL (v\{version\}.livecodes.io) which is a proxy to preview deploy.
2655
- If SDK release -> publish to npm.
2756

28-
:::info
57+
## Note
2958

3059
App versions are numeric e.g. `v20`
3160
SDK versions are semver e.g. `v1.2.3`
32-
33-
:::

0 commit comments

Comments
 (0)