@vemjs/renderer-vecto 0.1.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/CHANGELOG.md +53 -0
- package/README.md +115 -0
- package/dist/CommandBar.d.ts +13 -0
- package/dist/CommandBar.d.ts.map +1 -0
- package/dist/CommandBar.js +60 -0
- package/dist/CommandBar.js.map +1 -0
- package/dist/FileSystemHandler.d.ts +9 -0
- package/dist/FileSystemHandler.d.ts.map +1 -0
- package/dist/FileSystemHandler.js +51 -0
- package/dist/FileSystemHandler.js.map +1 -0
- package/dist/VemEditorEntity.d.ts +16 -0
- package/dist/VemEditorEntity.d.ts.map +1 -0
- package/dist/VemEditorEntity.js +209 -0
- package/dist/VemEditorEntity.js.map +1 -0
- package/dist/Workspace.d.ts +13 -0
- package/dist/Workspace.d.ts.map +1 -0
- package/dist/Workspace.js +55 -0
- package/dist/Workspace.js.map +1 -0
- package/dist/WorkspaceExplorer.d.ts +18 -0
- package/dist/WorkspaceExplorer.d.ts.map +1 -0
- package/dist/WorkspaceExplorer.js +102 -0
- package/dist/WorkspaceExplorer.js.map +1 -0
- package/dist/WorkspaceLayout.d.ts +38 -0
- package/dist/WorkspaceLayout.d.ts.map +1 -0
- package/dist/WorkspaceLayout.js +165 -0
- package/dist/WorkspaceLayout.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/package.json +19 -0
- package/src/CommandBar.ts +69 -0
- package/src/FileSystemHandler.test.ts +51 -0
- package/src/FileSystemHandler.ts +60 -0
- package/src/VemEditorEntity.ts +235 -0
- package/src/Workspace.ts +65 -0
- package/src/WorkspaceExplorer.ts +124 -0
- package/src/WorkspaceLayout.ts +191 -0
- package/src/index.ts +48 -0
- package/tsconfig.json +13 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @vemjs/renderer-vecto
|
|
2
|
+
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0498765: chore: release infrastructure, package metadata, and documentation scaffolding
|
|
8
|
+
|
|
9
|
+
This changeset covers all release preparation work for the initial 0.1.0 publish:
|
|
10
|
+
|
|
11
|
+
**Package metadata** — Added `license`, `repository`, `keywords`, and `publishConfig` fields to
|
|
12
|
+
all four packages so they display correctly on npmjs.com with proper source links, license badges,
|
|
13
|
+
and searchable tags.
|
|
14
|
+
|
|
15
|
+
**CI/CD pipeline** — Rewrote `.github/workflows/ci.yml` and `release.yml`:
|
|
16
|
+
|
|
17
|
+
- `quality` job: build → test → lint (oxlint) → dead-code scan (knip) on every PR and push
|
|
18
|
+
- `publish` job: automatic `changeset publish` to npm on every merge to `main` via
|
|
19
|
+
`changesets/action@v1` using the `NPM_TOKEN` org secret
|
|
20
|
+
|
|
21
|
+
**Changesets** — Initialized `.changeset/` with a `config.json` configured for public access and
|
|
22
|
+
patch-level internal dependency updates, enabling a fully automated release flow.
|
|
23
|
+
|
|
24
|
+
**Tooling** — Added `knip.config.ts` (dead-code detection), `oxlintrc.json` (TypeScript-aware
|
|
25
|
+
lint rules), `.lintstagedrc.json` (auto-fix staged files on commit), and updated root
|
|
26
|
+
`package.json` scripts: `build`, `test`, `lint`, `knip`, `changeset`, `version-packages`,
|
|
27
|
+
`release`.
|
|
28
|
+
|
|
29
|
+
**Dependabot** — Configured weekly npm dependency scanning with dev/prod groups and
|
|
30
|
+
`@vectojs/*` major-version pin to avoid upstream breaking changes.
|
|
31
|
+
|
|
32
|
+
**Repository** — Updated root `README.md` with CI/npm/license badges and package table.
|
|
33
|
+
Updated `SECURITY.md` with all four `@vemjs/*` packages and coordinated-disclosure guidance.
|
|
34
|
+
Added GitHub topics (vim, editor, typescript, vectojs, canvas, modal-editing, lsp) and branch
|
|
35
|
+
protection requiring the `quality` status check before merging to `main`.
|
|
36
|
+
|
|
37
|
+
**Build hygiene** — Cleaned all `dist/` directories and rebuilt from source to ensure no
|
|
38
|
+
test artefacts are included in published tarballs. Verified `knip` reports zero issues.
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [0498765]
|
|
41
|
+
- Updated dependencies [3fa4848]
|
|
42
|
+
- @vemjs/core@0.2.0
|
|
43
|
+
|
|
44
|
+
## 0.1.0
|
|
45
|
+
|
|
46
|
+
### Features
|
|
47
|
+
|
|
48
|
+
- `VemEditorEntity` — zero-DOM canvas text editor with line numbers, cursor blink, VISUAL selection highlights, scroll, gutter
|
|
49
|
+
- `CommandBar` — VectoUI `Input`-based command palette (`:w`, `:q`, `:vsp`, `:sp`)
|
|
50
|
+
- `WorkspaceLayout` — resizable `PanelGroup` / `Panel` split panes (vertical + horizontal)
|
|
51
|
+
- `VemWorkspace` — tabbed multi-file workspace using VectoUI `Tabs`
|
|
52
|
+
- `WorkspaceExplorer` — sidebar `TreeView` file picker + editor area, File System Access API integration
|
|
53
|
+
- `FileSystemHandler` — recursive directory handle mapper with lazy expansion and folder-first sort
|
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# @vemjs/renderer-vecto
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@vemjs/renderer-vecto)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
The high-performance, **zero-DOM Canvas 2D** rendering layer for the **Vem Editor**, powered by the [VectoJS](https://github.com/vectojs/vectojs) Entity-Component-System (ECS) engine. It provides the full visual editor layout, including multi-pane split windows, file explorers, tab bars, gutters, line numbers, visual highlights, and the interactive Command Bar.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Zero-DOM Rendering Core**: Every pixel — from individual code glyphs and blinking cursors to selection highlights and sidebar files — is drawn directly to a single HTML5 `<canvas>` via VectoJS ECS entities.
|
|
11
|
+
- **Split Windows Layout**: Integrated `WorkspaceLayout` that provides dynamic, resizable vertical and horizontal panels without layout thrashing.
|
|
12
|
+
- **Lazy File Explorer Tree**: High-performance sidebar tree component with lazy node expansion leveraging the Web File System Access API.
|
|
13
|
+
- **Command Bar Component**: Smooth command-line overlay supporting Vim command history and interactive autocomplete suggestions.
|
|
14
|
+
- **Keyboard Event Router**: Advanced physical key event capturing and routing that bypasses browser-native DOM inputs to support Vim normal, insert, visual, and command modes natively.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
This package requires `@vemjs/core` and `@vectojs/core` as peer dependencies.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
bun add @vemjs/renderer-vecto @vemjs/core @vectojs/core
|
|
22
|
+
# or via npm
|
|
23
|
+
npm install @vemjs/renderer-vecto @vemjs/core @vectojs/core
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
Initialize the renderer within a VectoJS Scene, mount the editor shell, and attach a canvas element:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { VemEditorState } from '@vemjs/core';
|
|
32
|
+
import { WorkspaceExplorer, VectoRenderer } from '@vemjs/renderer-vecto';
|
|
33
|
+
import { Scene } from '@vectojs/core';
|
|
34
|
+
|
|
35
|
+
// 1. Create Core Editor State
|
|
36
|
+
const editorState = new VemEditorState('// Press :w to write, :q to quit\nconsole.log("Vem");');
|
|
37
|
+
|
|
38
|
+
// 2. Initialize VectoJS Scene on an HTML5 canvas
|
|
39
|
+
const canvas = document.querySelector('canvas') as HTMLCanvasElement;
|
|
40
|
+
const scene = new Scene(canvas);
|
|
41
|
+
|
|
42
|
+
// 3. Instantiate the high-level Workspace Explorer layout
|
|
43
|
+
const explorer = new WorkspaceExplorer(editorState);
|
|
44
|
+
|
|
45
|
+
// 4. Add the explorer entity to the VectoJS Scene hierarchy
|
|
46
|
+
scene.add(explorer);
|
|
47
|
+
|
|
48
|
+
// 5. Start the render loop
|
|
49
|
+
scene.start();
|
|
50
|
+
|
|
51
|
+
// 6. Connect high-level keystroke router
|
|
52
|
+
canvas.focus();
|
|
53
|
+
canvas.addEventListener('keydown', (e) => {
|
|
54
|
+
// Let Vem handle Vim key mappings natively
|
|
55
|
+
explorer.handleKeyEvent(e);
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## API Reference
|
|
60
|
+
|
|
61
|
+
### `VectoRenderer`
|
|
62
|
+
|
|
63
|
+
Lower-level binding utility to attach editor states to canvas render cycles.
|
|
64
|
+
|
|
65
|
+
- `constructor(editorState: VemEditorState)`: Binds editor state context.
|
|
66
|
+
- `attach(canvas: HTMLCanvasElement): void`: Instantiates a VectoJS scene, adds a `VemEditorEntity`, and begins the execution loop.
|
|
67
|
+
- `render(): void`: Triggers manual state evaluation and update.
|
|
68
|
+
|
|
69
|
+
### `WorkspaceExplorer`
|
|
70
|
+
|
|
71
|
+
High-level workspace GUI structure containing the sidebar explorer, file tree picker, and the active editor workspaces.
|
|
72
|
+
|
|
73
|
+
- `constructor(editorState: VemEditorState)`: Creates the layout hierarchy.
|
|
74
|
+
- `getWorkspace(): VemWorkspace`: Returns the active editor workspace tab group.
|
|
75
|
+
- `handleKeyEvent(e: KeyboardEvent): void`: Translates and routes physical keyboard events into the modal state machine.
|
|
76
|
+
|
|
77
|
+
### `VemEditorEntity`
|
|
78
|
+
|
|
79
|
+
The individual text editing Canvas entity. Handles rendering lines of code, cursors, line selections, and relative gutters. Inherits from `Vecto.Entity`.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## VectoJS Zero-DOM Philosophy
|
|
84
|
+
|
|
85
|
+
Traditional web text editors (e.g. Monaco, VS Code, CodeMirror) rely heavily on absolute-positioned HTML elements or inline `<span>` tags. When rendering large files with complex syntax tokenization, this causes heavy layout thrashing, DOM node pollution, and GC overhead.
|
|
86
|
+
|
|
87
|
+
Vem rejects this overhead. Under our **Zero-DOM Canvas 2D Philosophy**:
|
|
88
|
+
|
|
89
|
+
1. **ECS-Driven Rendering**: Every visual piece is a VectoJS `Entity`. Layout is computed on raw float coordinates in memory.
|
|
90
|
+
2. **Text Caching**: Font glyphs are cached or drawn using fast sub-pixel Canvas text routines, allowing rendering speeds exceeding 60 FPS even with 10,000 lines of code.
|
|
91
|
+
3. **Zero HTML/CSS pollution**: Outside of the single `<canvas>` container, no extra DOM elements are spawned. Gutters, selections, and menus are purely drawn visually.
|
|
92
|
+
4. **Portability**: Because the renderer is decoupled from browser-native DOM nodes, Vem can run seamlessly inside Node.js, Web Workers, or Native Tauri containers without changing any styling systems.
|
|
93
|
+
|
|
94
|
+
## Architecture
|
|
95
|
+
|
|
96
|
+
```mermaid
|
|
97
|
+
graph TD
|
|
98
|
+
Canvas[HTML5 Canvas Element] --> Scene[VectoJS Scene]
|
|
99
|
+
Scene --> Explorer[WorkspaceExplorer Entity]
|
|
100
|
+
Explorer --> Sidebar[Sidebar TreeView Entity]
|
|
101
|
+
Explorer --> Layout[WorkspaceLayout PanelGroup]
|
|
102
|
+
Layout --> EditorPane[EditorPane Entity]
|
|
103
|
+
EditorPane --> EditorEntity[VemEditorEntity]
|
|
104
|
+
EditorEntity --> Gutter[Gutter rendering]
|
|
105
|
+
EditorEntity --> Selection[Visual Selection highlights]
|
|
106
|
+
Explorer --> CmdBar[CommandBar Input Entity]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Contributing
|
|
110
|
+
|
|
111
|
+
Please review [CONTRIBUTING.md](../../CONTRIBUTING.md) for details on our workflow and engineering guidelines.
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
This package is licensed under the MIT License - see the LICENSE file for details.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UIComponent } from '@vectojs/ui';
|
|
2
|
+
import type { IRenderer } from '@vectojs/core';
|
|
3
|
+
import type { VemEditorState } from '@vemjs/core';
|
|
4
|
+
export declare class CommandBar extends UIComponent {
|
|
5
|
+
private editorState;
|
|
6
|
+
private prefixText;
|
|
7
|
+
private input;
|
|
8
|
+
constructor(editorState: VemEditorState, width: number);
|
|
9
|
+
updateWidth(width: number): void;
|
|
10
|
+
clear(): void;
|
|
11
|
+
render(r: IRenderer): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=CommandBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandBar.d.ts","sourceRoot":"","sources":["../src/CommandBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,qBAAa,UAAW,SAAQ,WAAW;IACzC,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,UAAU,CAAO;IACzB,OAAO,CAAC,KAAK,CAAQ;gBAET,WAAW,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM;IAyC/C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKhC,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI;CASlC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { UIComponent, Text, Input } from '@vectojs/ui';
|
|
2
|
+
export class CommandBar extends UIComponent {
|
|
3
|
+
editorState;
|
|
4
|
+
prefixText;
|
|
5
|
+
input;
|
|
6
|
+
constructor(editorState, width) {
|
|
7
|
+
super();
|
|
8
|
+
this.editorState = editorState;
|
|
9
|
+
this.width = width;
|
|
10
|
+
this.height = 30;
|
|
11
|
+
this.prefixText = new Text(':', {
|
|
12
|
+
font: 'bold 14px monospace',
|
|
13
|
+
color: '#38bdf8', // sky-400
|
|
14
|
+
});
|
|
15
|
+
this.prefixText.setPosition(5, 5);
|
|
16
|
+
this.input = new Input({
|
|
17
|
+
width: width - 20,
|
|
18
|
+
height: 25,
|
|
19
|
+
font: '14px monospace',
|
|
20
|
+
color: '#e2e8f0',
|
|
21
|
+
bg: '#1e293b', // slate-800
|
|
22
|
+
border: 'transparent',
|
|
23
|
+
onChange: (value) => {
|
|
24
|
+
// Mirror changes to editorState command buffer
|
|
25
|
+
this.editorState.commandText = value;
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
this.input.id = 'vem-command-input';
|
|
29
|
+
this.input.setPosition(15, 2);
|
|
30
|
+
// Watch for Escape and Enter on the input component to bridge to editorState
|
|
31
|
+
this.input.on('keydown', (e) => {
|
|
32
|
+
const key = e.nativeEvent?.key || e.key;
|
|
33
|
+
if (key === 'Escape') {
|
|
34
|
+
this.editorState.handleKey('Escape');
|
|
35
|
+
}
|
|
36
|
+
else if (key === 'Enter') {
|
|
37
|
+
this.editorState.handleKey('Enter');
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
this.add(this.prefixText);
|
|
41
|
+
this.add(this.input);
|
|
42
|
+
}
|
|
43
|
+
updateWidth(width) {
|
|
44
|
+
this.width = width;
|
|
45
|
+
this.input.width = width - 20;
|
|
46
|
+
}
|
|
47
|
+
clear() {
|
|
48
|
+
this.input.value = '';
|
|
49
|
+
}
|
|
50
|
+
render(r) {
|
|
51
|
+
r.beginPath();
|
|
52
|
+
r.moveTo(0, 0);
|
|
53
|
+
r.lineTo(this.width, 0);
|
|
54
|
+
r.lineTo(this.width, this.height);
|
|
55
|
+
r.lineTo(0, this.height);
|
|
56
|
+
r.closePath();
|
|
57
|
+
r.fill('#1e293b'); // slate-800
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=CommandBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandBar.js","sourceRoot":"","sources":["../src/CommandBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAIvD,MAAM,OAAO,UAAW,SAAQ,WAAW;IACjC,WAAW,CAAiB;IAC5B,UAAU,CAAO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,OAAO,EAAE,CAAC;gBAC3B,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACtC,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAEM,WAAW,CAAC,KAAa;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,GAAG,EAAE,CAAC;IAChC,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;IACxB,CAAC;IAEM,MAAM,CAAC,CAAY;QACxB,CAAC,CAAC,SAAS,EAAE,CAAC;QACd,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACf,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACxB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC,CAAC,SAAS,EAAE,CAAC;QACd,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TreeNode } from '@vectojs/ui';
|
|
2
|
+
export declare class FileSystemHandler {
|
|
3
|
+
private fileHandles;
|
|
4
|
+
readDirectory(dirHandle: FileSystemDirectoryHandle, pathPrefix?: string): Promise<TreeNode[]>;
|
|
5
|
+
getFileHandle(path: string): FileSystemFileHandle | undefined;
|
|
6
|
+
readFile(fileHandle: FileSystemFileHandle): Promise<string>;
|
|
7
|
+
saveFile(fileHandle: FileSystemFileHandle, content: string): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=FileSystemHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileSystemHandler.d.ts","sourceRoot":"","sources":["../src/FileSystemHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,WAAW,CAA2C;IAEjD,aAAa,CACxB,SAAS,EAAE,yBAAyB,EACpC,UAAU,SAAK,GACd,OAAO,CAAC,QAAQ,EAAE,CAAC;IAqCf,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS;IAIvD,QAAQ,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;IAK3D,QAAQ,CAAC,UAAU,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAKxF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export class FileSystemHandler {
|
|
2
|
+
fileHandles = new Map();
|
|
3
|
+
async readDirectory(dirHandle, pathPrefix = '') {
|
|
4
|
+
const nodes = [];
|
|
5
|
+
for await (const entry of dirHandle.values()) {
|
|
6
|
+
const fullPath = pathPrefix ? `${pathPrefix}/${entry.name}` : entry.name;
|
|
7
|
+
if (entry.kind === 'directory') {
|
|
8
|
+
nodes.push({
|
|
9
|
+
id: fullPath,
|
|
10
|
+
label: entry.name,
|
|
11
|
+
icon: '📁',
|
|
12
|
+
children: async () => {
|
|
13
|
+
return this.readDirectory(entry, fullPath);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
else if (entry.kind === 'file') {
|
|
18
|
+
this.fileHandles.set(fullPath, entry);
|
|
19
|
+
nodes.push({
|
|
20
|
+
id: fullPath,
|
|
21
|
+
label: entry.name,
|
|
22
|
+
icon: '📄',
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Sort: directories first, then files alphabetically
|
|
27
|
+
nodes.sort((a, b) => {
|
|
28
|
+
const aIsDir = a.icon === '📁';
|
|
29
|
+
const bIsDir = b.icon === '📁';
|
|
30
|
+
if (aIsDir && !bIsDir)
|
|
31
|
+
return -1;
|
|
32
|
+
if (!aIsDir && bIsDir)
|
|
33
|
+
return 1;
|
|
34
|
+
return a.label.localeCompare(b.label);
|
|
35
|
+
});
|
|
36
|
+
return nodes;
|
|
37
|
+
}
|
|
38
|
+
getFileHandle(path) {
|
|
39
|
+
return this.fileHandles.get(path);
|
|
40
|
+
}
|
|
41
|
+
async readFile(fileHandle) {
|
|
42
|
+
const file = await fileHandle.getFile();
|
|
43
|
+
return await file.text();
|
|
44
|
+
}
|
|
45
|
+
async saveFile(fileHandle, content) {
|
|
46
|
+
const writable = await fileHandle.createWritable();
|
|
47
|
+
await writable.write(content);
|
|
48
|
+
await writable.close();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=FileSystemHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileSystemHandler.js","sourceRoot":"","sources":["../src/FileSystemHandler.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,iBAAiB;IACpB,WAAW,GAAG,IAAI,GAAG,EAAgC,CAAC;IAEvD,KAAK,CAAC,aAAa,CACxB,SAAoC,EACpC,UAAU,GAAG,EAAE;QAEf,MAAM,KAAK,GAAe,EAAE,CAAC;QAE7B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAK,SAAiB,CAAC,MAAM,EAAE,EAAE,CAAC;YACtD,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;YAEzE,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW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AAE,CAAC;QACxC,OAAO,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,UAAgC,EAAE,OAAe;QACrE,MAAM,QAAQ,GAAG,MAAO,UAAkB,CAAC,cAAc,EAAE,CAAC;QAC5D,MAAM,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UIComponent } from '@vectojs/ui';
|
|
2
|
+
import type { IRenderer } from '@vectojs/core';
|
|
3
|
+
import type { VemEditorState } from '@vemjs/core';
|
|
4
|
+
export declare class VemEditorEntity extends UIComponent {
|
|
5
|
+
private editorState;
|
|
6
|
+
private gutterText;
|
|
7
|
+
private bodyText;
|
|
8
|
+
private commandBar;
|
|
9
|
+
private charWidth;
|
|
10
|
+
private lineHeight;
|
|
11
|
+
private scrollY;
|
|
12
|
+
constructor(editorState: VemEditorState);
|
|
13
|
+
updateFromState(): void;
|
|
14
|
+
render(r: IRenderer): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=VemEditorEntity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VemEditorEntity.d.ts","sourceRoot":"","sources":["../src/VemEditorEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,UAAU,CAAO;IACzB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,UAAU,CAAa;IAE/B,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,OAAO,CAAK;gBAER,WAAW,EAAE,cAAc;IAsChC,eAAe,IAAI,IAAI;IAmDvB,MAAM,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI;CAkIlC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { UIComponent, Text, RichText } from '@vectojs/ui';
|
|
2
|
+
import { CommandBar } from './CommandBar';
|
|
3
|
+
export class VemEditorEntity extends UIComponent {
|
|
4
|
+
editorState;
|
|
5
|
+
gutterText;
|
|
6
|
+
bodyText;
|
|
7
|
+
commandBar;
|
|
8
|
+
charWidth = 8.4;
|
|
9
|
+
lineHeight = 20;
|
|
10
|
+
scrollY = 0; // scroll offset in lines
|
|
11
|
+
constructor(editorState) {
|
|
12
|
+
super();
|
|
13
|
+
this.editorState = editorState;
|
|
14
|
+
this.width = 800;
|
|
15
|
+
this.height = 600;
|
|
16
|
+
this.clipChildren = true;
|
|
17
|
+
this.gutterText = new Text('', {
|
|
18
|
+
font: '14px monospace',
|
|
19
|
+
color: '#64748b', // slate-500
|
|
20
|
+
lineHeight: this.lineHeight,
|
|
21
|
+
});
|
|
22
|
+
// Editor body text
|
|
23
|
+
this.bodyText = new RichText([], {
|
|
24
|
+
font: '14px monospace',
|
|
25
|
+
color: '#e2e8f0', // slate-200
|
|
26
|
+
});
|
|
27
|
+
this.commandBar = new CommandBar(editorState, this.width);
|
|
28
|
+
this.commandBar.setPosition(0, this.height - 30);
|
|
29
|
+
this.add(this.gutterText);
|
|
30
|
+
this.add(this.bodyText);
|
|
31
|
+
// Try to measure the exact monospace char width if running in browser
|
|
32
|
+
if (typeof document !== 'undefined') {
|
|
33
|
+
const canvas = document.createElement('canvas');
|
|
34
|
+
const ctx = canvas.getContext('2d');
|
|
35
|
+
if (ctx) {
|
|
36
|
+
ctx.font = '14px monospace';
|
|
37
|
+
this.charWidth = ctx.measureText('A').width;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
this.updateFromState();
|
|
41
|
+
}
|
|
42
|
+
updateFromState() {
|
|
43
|
+
const buffer = this.editorState.getBuffer();
|
|
44
|
+
const cursor = this.editorState.getCursor();
|
|
45
|
+
const lineCount = buffer.getLineCount();
|
|
46
|
+
// 1. Calculate gutter width dynamically
|
|
47
|
+
const maxLineDigits = Math.max(2, lineCount.toString().length);
|
|
48
|
+
const gutterWidth = maxLineDigits * this.charWidth + 15;
|
|
49
|
+
// 2. Set line numbers text
|
|
50
|
+
const lineNums = [];
|
|
51
|
+
for (let i = 1; i <= lineCount; i++) {
|
|
52
|
+
lineNums.push(i.toString().padStart(maxLineDigits, ' '));
|
|
53
|
+
}
|
|
54
|
+
this.gutterText.setText(lineNums.join('\n'));
|
|
55
|
+
this.gutterText.setPosition(5, 5);
|
|
56
|
+
// 3. Set editor body text
|
|
57
|
+
const spans = buffer.getLines().map((line, idx) => {
|
|
58
|
+
const suffix = idx === lineCount - 1 ? '' : '\n';
|
|
59
|
+
return { text: line + suffix };
|
|
60
|
+
});
|
|
61
|
+
this.bodyText.setSpans(spans);
|
|
62
|
+
this.bodyText.setPosition(gutterWidth + 5, 5);
|
|
63
|
+
// 4. Handle viewport scrolling to keep cursor visible
|
|
64
|
+
const visibleLines = Math.floor((this.height - 35) / this.lineHeight); // reserve 35px for status bar
|
|
65
|
+
if (cursor.line >= this.scrollY + visibleLines) {
|
|
66
|
+
this.scrollY = cursor.line - visibleLines + 1;
|
|
67
|
+
}
|
|
68
|
+
else if (cursor.line < this.scrollY) {
|
|
69
|
+
this.scrollY = cursor.line;
|
|
70
|
+
}
|
|
71
|
+
// Update children scroll positions
|
|
72
|
+
const scrollOffsetY = -this.scrollY * this.lineHeight;
|
|
73
|
+
this.gutterText.setPosition(5, 5 + scrollOffsetY);
|
|
74
|
+
this.bodyText.setPosition(gutterWidth + 5, 5 + scrollOffsetY);
|
|
75
|
+
// 5. Handle CommandBar visibility
|
|
76
|
+
if (this.editorState.getMode() === 'COMMAND') {
|
|
77
|
+
if (!this.children.includes(this.commandBar)) {
|
|
78
|
+
this.add(this.commandBar);
|
|
79
|
+
}
|
|
80
|
+
this.commandBar.clear();
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
if (this.children.includes(this.commandBar)) {
|
|
84
|
+
this.remove(this.commandBar);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
render(r) {
|
|
89
|
+
// 1. Draw editor background
|
|
90
|
+
r.beginPath();
|
|
91
|
+
r.moveTo(0, 0);
|
|
92
|
+
r.lineTo(this.width, 0);
|
|
93
|
+
r.lineTo(this.width, this.height);
|
|
94
|
+
r.lineTo(0, this.height);
|
|
95
|
+
r.closePath();
|
|
96
|
+
r.fill('#0f172a'); // slate-900
|
|
97
|
+
const lineCount = this.editorState.getBuffer().getLineCount();
|
|
98
|
+
const maxLineDigits = Math.max(2, lineCount.toString().length);
|
|
99
|
+
const gutterWidth = maxLineDigits * this.charWidth + 15;
|
|
100
|
+
// 2. Draw gutter background
|
|
101
|
+
r.beginPath();
|
|
102
|
+
r.moveTo(0, 0);
|
|
103
|
+
r.lineTo(gutterWidth, 0);
|
|
104
|
+
r.lineTo(gutterWidth, this.height);
|
|
105
|
+
r.lineTo(0, this.height);
|
|
106
|
+
r.closePath();
|
|
107
|
+
r.fill('#1e293b'); // slate-800
|
|
108
|
+
// Apply scrolling transformation for cursor and selections
|
|
109
|
+
r.save();
|
|
110
|
+
r.translate(0, -this.scrollY * this.lineHeight);
|
|
111
|
+
// 3. Draw Visual Mode selections
|
|
112
|
+
const selection = this.editorState.getVisualSelection();
|
|
113
|
+
if (selection) {
|
|
114
|
+
const type = selection.type;
|
|
115
|
+
let s = { ...selection.anchor };
|
|
116
|
+
let e = { ...selection.active };
|
|
117
|
+
if (s.line > e.line || (s.line === e.line && s.character > e.character)) {
|
|
118
|
+
const temp = s;
|
|
119
|
+
s = e;
|
|
120
|
+
e = temp;
|
|
121
|
+
}
|
|
122
|
+
const drawSelRect = (lineIdx, startChar, endChar) => {
|
|
123
|
+
const x = gutterWidth + 5 + startChar * this.charWidth;
|
|
124
|
+
const y = 5 + lineIdx * this.lineHeight;
|
|
125
|
+
const w = (endChar - startChar) * this.charWidth;
|
|
126
|
+
const h = this.lineHeight;
|
|
127
|
+
r.beginPath();
|
|
128
|
+
r.moveTo(x, y);
|
|
129
|
+
r.lineTo(x + w, y);
|
|
130
|
+
r.lineTo(x + w, y + h);
|
|
131
|
+
r.lineTo(x, y + h);
|
|
132
|
+
r.closePath();
|
|
133
|
+
r.fill('rgba(56, 189, 248, 0.3)'); // sky-400 opacity
|
|
134
|
+
};
|
|
135
|
+
if (type === 'line') {
|
|
136
|
+
for (let l = s.line; l <= e.line; l++) {
|
|
137
|
+
const lineText = this.editorState.getBuffer().getLine(l);
|
|
138
|
+
drawSelRect(l, 0, Math.max(1, lineText.length));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else if (type === 'char') {
|
|
142
|
+
if (s.line === e.line) {
|
|
143
|
+
drawSelRect(s.line, s.character, e.character + 1);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const sLineText = this.editorState.getBuffer().getLine(s.line);
|
|
147
|
+
drawSelRect(s.line, s.character, Math.max(s.character + 1, sLineText.length + 1));
|
|
148
|
+
for (let l = s.line + 1; l < e.line; l++) {
|
|
149
|
+
const lText = this.editorState.getBuffer().getLine(l);
|
|
150
|
+
drawSelRect(l, 0, lText.length + 1);
|
|
151
|
+
}
|
|
152
|
+
drawSelRect(e.line, 0, e.character + 1);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else if (type === 'block') {
|
|
156
|
+
const minCol = Math.min(selection.anchor.character, selection.active.character);
|
|
157
|
+
const maxCol = Math.max(selection.anchor.character, selection.active.character);
|
|
158
|
+
for (let l = s.line; l <= e.line; l++) {
|
|
159
|
+
drawSelRect(l, minCol, maxCol + 1);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// 4. Draw Vim cursor
|
|
164
|
+
const cursor = this.editorState.getCursor();
|
|
165
|
+
const cursorX = gutterWidth + 5 + cursor.character * this.charWidth;
|
|
166
|
+
const cursorY = 5 + cursor.line * this.lineHeight;
|
|
167
|
+
const mode = this.editorState.getMode();
|
|
168
|
+
r.beginPath();
|
|
169
|
+
if (mode === 'INSERT') {
|
|
170
|
+
r.moveTo(cursorX, cursorY);
|
|
171
|
+
r.lineTo(cursorX + 2, cursorY);
|
|
172
|
+
r.lineTo(cursorX + 2, cursorY + this.lineHeight);
|
|
173
|
+
r.lineTo(cursorX, cursorY + this.lineHeight);
|
|
174
|
+
r.closePath();
|
|
175
|
+
r.fill('#f43f5e'); // rose-500
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
r.moveTo(cursorX, cursorY);
|
|
179
|
+
r.lineTo(cursorX + this.charWidth, cursorY);
|
|
180
|
+
r.lineTo(cursorX + this.charWidth, cursorY + this.lineHeight);
|
|
181
|
+
r.lineTo(cursorX, cursorY + this.lineHeight);
|
|
182
|
+
r.closePath();
|
|
183
|
+
r.fill('rgba(56, 189, 248, 0.7)'); // sky-400 opacity
|
|
184
|
+
}
|
|
185
|
+
r.restore(); // Restore scroll transform
|
|
186
|
+
// 5. Draw status bar at the bottom
|
|
187
|
+
const statusBarHeight = 30;
|
|
188
|
+
const statusY = this.height - statusBarHeight;
|
|
189
|
+
r.beginPath();
|
|
190
|
+
r.moveTo(0, statusY);
|
|
191
|
+
r.lineTo(this.width, statusY);
|
|
192
|
+
r.lineTo(this.width, this.height);
|
|
193
|
+
r.lineTo(0, this.height);
|
|
194
|
+
r.closePath();
|
|
195
|
+
r.fill('#1e293b'); // slate-800
|
|
196
|
+
if (mode !== 'COMMAND') {
|
|
197
|
+
const modeText = `-- ${mode} --`;
|
|
198
|
+
const posText = `${cursor.line + 1}:${cursor.character + 1}`;
|
|
199
|
+
const pendingKeys = this.editorState.getPendingKeys();
|
|
200
|
+
const pendingText = pendingKeys.length > 0 ? pendingKeys.join('') : '';
|
|
201
|
+
r.fillText(modeText, 10, statusY + 18, 'bold 12px monospace', '#38bdf8');
|
|
202
|
+
if (pendingText) {
|
|
203
|
+
r.fillText(pendingText, 120, statusY + 18, '12px monospace', '#e2e8f0');
|
|
204
|
+
}
|
|
205
|
+
r.fillText(posText, this.width - 60, statusY + 18, '12px monospace', '#94a3b8');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=VemEditorEntity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VemEditorEntity.js","sourceRoot":"","sources":["../src/VemEditorEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,OAAO,eAAgB,SAAQ,WAAW;IACtC,WAAW,CAAiB;IAC5B,UAAU,CAAO;IACjB,QAAQ,CAAW;IACnB,UAAU,CAAa;IAEvB,SAAS,GAAG,GAAG,CAAC;IAChB,UAAU,GAAG,EAAE,CAAC;IAChB,OAAO,GAAG,CAAC,CAAC,CAAC,yBAAyB;IAE9C,YAAY,WAA2B;QACrC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;QAClB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAEzB,IAAI,CAAC,UAAU,GAAG,IAAI,IAAI,CAAC,EAAE,EAAE;YAC7B,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,SAAS,EAAE,YAAY;YAC9B,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC,CAAC;QAEH,mBAAmB;QACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,E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,SAAS,EAAE,CAAC;YACvB,MAAM,QAAQ,GAAG,MAAM,IAAI,KAAK,CAAC;YACjC,MAAM,OAAO,GAAG,GAAG,MAAM,CAAC,IAAI,GAAG,CAAC,IAAI,MAAM,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;YAC7D,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC;YACtD,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAEvE,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,qBAAqB,EAAE,SAAS,CAAC,CAAC;YACzE,IAAI,WAAW,EAAE,CAAC;gBAChB,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;YAC1E,CAAC;YACD,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UIComponent } from '@vectojs/ui';
|
|
2
|
+
import type { IRenderer } from '@vectojs/core';
|
|
3
|
+
import { WorkspaceLayout } from './WorkspaceLayout';
|
|
4
|
+
export declare class VemWorkspace extends UIComponent {
|
|
5
|
+
private tabsComponent;
|
|
6
|
+
private layouts;
|
|
7
|
+
constructor(width: number, height: number, initialText?: string);
|
|
8
|
+
addTab(initialText?: string): void;
|
|
9
|
+
update(dt: number, time: number): void;
|
|
10
|
+
getActiveLayout(): WorkspaceLayout | null;
|
|
11
|
+
render(_r: IRenderer): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=Workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Workspace.d.ts","sourceRoot":"","sources":["../src/Workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAQ,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAAa,YAAa,SAAQ,WAAW;IAC3C,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,OAAO,CAAyB;gBAE5B,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;IAmBxD,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAelC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAQtC,eAAe,IAAI,eAAe,GAAG,IAAI;IAWzC,MAAM,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI;CAGnC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { UIComponent, Tabs } from '@vectojs/ui';
|
|
2
|
+
import { WorkspaceLayout } from './WorkspaceLayout';
|
|
3
|
+
export class VemWorkspace extends UIComponent {
|
|
4
|
+
tabsComponent = null;
|
|
5
|
+
layouts = [];
|
|
6
|
+
constructor(width, height, initialText) {
|
|
7
|
+
super();
|
|
8
|
+
this.width = width;
|
|
9
|
+
this.height = height;
|
|
10
|
+
const initialLayout = new WorkspaceLayout(width, height - 30, initialText || '');
|
|
11
|
+
this.layouts.push(initialLayout);
|
|
12
|
+
this.tabsComponent = new Tabs({
|
|
13
|
+
width: this.width,
|
|
14
|
+
height: this.height,
|
|
15
|
+
tabHeight: 30,
|
|
16
|
+
tabs: [{ id: 'tab-1', label: 'Tab 1', content: initialLayout }],
|
|
17
|
+
value: 'tab-1',
|
|
18
|
+
});
|
|
19
|
+
this.add(this.tabsComponent);
|
|
20
|
+
}
|
|
21
|
+
addTab(initialText) {
|
|
22
|
+
const nextIndex = this.layouts.length + 1;
|
|
23
|
+
const newLayout = new WorkspaceLayout(this.width, this.height - 30, initialText || '');
|
|
24
|
+
this.layouts.push(newLayout);
|
|
25
|
+
const updatedTabs = this.layouts.map((layout, idx) => ({
|
|
26
|
+
id: `tab-${idx + 1}`,
|
|
27
|
+
label: `Tab ${idx + 1}`,
|
|
28
|
+
content: layout,
|
|
29
|
+
}));
|
|
30
|
+
this.tabsComponent.tabs = updatedTabs;
|
|
31
|
+
this.tabsComponent.value = `tab-${nextIndex}`;
|
|
32
|
+
}
|
|
33
|
+
update(dt, time) {
|
|
34
|
+
super.update(dt, time);
|
|
35
|
+
if (this.tabsComponent) {
|
|
36
|
+
this.tabsComponent.width = this.width;
|
|
37
|
+
this.tabsComponent.height = this.height;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
getActiveLayout() {
|
|
41
|
+
if (!this.tabsComponent)
|
|
42
|
+
return null;
|
|
43
|
+
const activeId = this.tabsComponent.value;
|
|
44
|
+
const match = activeId.match(/tab-(\d+)/);
|
|
45
|
+
if (match) {
|
|
46
|
+
const idx = parseInt(match[1], 10) - 1;
|
|
47
|
+
return this.layouts[idx] || null;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
render(_r) {
|
|
52
|
+
// Handled by tabsComponent
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=Workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Workspace.js","sourceRoot":"","sources":["../src/Workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,OAAO,YAAa,SAAQ,WAAW;IACnC,aAAa,GAAg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