@vemjs/renderer-vecto 0.1.1 → 0.1.3

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.
@@ -63,6 +63,22 @@ export class WorkspaceExplorer extends UIComponent {
63
63
  this.openDirectoryCallbacks.push(cb);
64
64
  }
65
65
 
66
+ private flattenFiles(nodes: any[]): string[] {
67
+ const list: string[] = [];
68
+ const recurse = (nodeList: any[], prefix: string) => {
69
+ for (const node of nodeList) {
70
+ const path = prefix ? `${prefix}/${node.label}` : node.label;
71
+ if (node.children && node.children.length > 0) {
72
+ recurse(node.children, path);
73
+ } else if (!node.children || node.children.length === 0) {
74
+ list.push(path);
75
+ }
76
+ }
77
+ };
78
+ recurse(nodes, '');
79
+ return list;
80
+ }
81
+
66
82
  private async handleOpenFolder(): Promise<void> {
67
83
  if (typeof window === 'undefined' || !(window as any).showDirectoryPicker) {
68
84
  console.warn('File System Access API is not supported in this environment.');
@@ -73,6 +89,13 @@ export class WorkspaceExplorer extends UIComponent {
73
89
  const rootHandle = await (window as any).showDirectoryPicker();
74
90
  const nodes = await this.fsHandler.readDirectory(rootHandle);
75
91
 
92
+ // Cache all file paths for search plugins (like Telescope)
93
+ const fileList = this.flattenFiles(nodes);
94
+ const activeState = this.getActiveEditorState();
95
+ if (activeState) {
96
+ activeState.projectFiles = fileList;
97
+ }
98
+
76
99
  this.treeView = new TreeView({
77
100
  nodes,
78
101
  width: this.leftPanel.width,
@@ -106,9 +129,68 @@ export class WorkspaceExplorer extends UIComponent {
106
129
  }
107
130
  }
108
131
 
132
+ public getActiveEditorState(): any | null {
133
+ return this.workspace.getActiveLayout()?.getActiveState() || null;
134
+ }
135
+
136
+ private lastSidebarPosition: 'left' | 'right' | 'hidden' = 'left';
137
+ private lastSidebarWidth = 240;
138
+
139
+ public syncLayout(activeState: any): void {
140
+ const layout = activeState.layoutConfig;
141
+
142
+ this.remove(this.panelGroup);
143
+
144
+ this.panelGroup = new PanelGroup({
145
+ direction: 'horizontal',
146
+ width: this.width,
147
+ height: this.height,
148
+ });
149
+
150
+ this.leftPanel = new Panel({
151
+ minSize: 150,
152
+ defaultSize: layout.sidebarWidth / Math.max(1, this.width),
153
+ });
154
+ this.rightPanel = new Panel({ minSize: 300 });
155
+
156
+ if (layout.sidebarPosition === 'left') {
157
+ this.leftPanel.add(this.openBtn);
158
+ if (this.treeView) this.leftPanel.add(this.treeView);
159
+ this.rightPanel.add(this.workspace);
160
+
161
+ this.panelGroup.addPanel(this.leftPanel);
162
+ this.panelGroup.addPanel(this.rightPanel);
163
+ } else if (layout.sidebarPosition === 'right') {
164
+ this.leftPanel.add(this.openBtn);
165
+ if (this.treeView) this.leftPanel.add(this.treeView);
166
+ this.rightPanel.add(this.workspace);
167
+
168
+ this.panelGroup.addPanel(this.rightPanel);
169
+ this.panelGroup.addPanel(this.leftPanel);
170
+ } else {
171
+ this.rightPanel.add(this.workspace);
172
+ this.panelGroup.addPanel(this.rightPanel);
173
+ }
174
+
175
+ this.add(this.panelGroup);
176
+ }
177
+
109
178
  public update(dt: number, time: number): void {
110
179
  super.update(dt, time);
111
180
 
181
+ const activeState = this.getActiveEditorState();
182
+ if (activeState) {
183
+ const layout = activeState.layoutConfig;
184
+ if (
185
+ layout.sidebarPosition !== this.lastSidebarPosition ||
186
+ layout.sidebarWidth !== this.lastSidebarWidth
187
+ ) {
188
+ this.lastSidebarPosition = layout.sidebarPosition;
189
+ this.lastSidebarWidth = layout.sidebarWidth;
190
+ this.syncLayout(activeState);
191
+ }
192
+ }
193
+
112
194
  if (this.panelGroup.width !== this.width || this.panelGroup.height !== this.height) {
113
195
  this.panelGroup.width = this.width;
114
196
  this.panelGroup.height = this.height;
@@ -131,13 +213,34 @@ export class WorkspaceExplorer extends UIComponent {
131
213
  }
132
214
  }
133
215
 
134
- public render(_r: IRenderer): void {
135
- _r.beginPath();
136
- _r.moveTo(0, 0);
137
- _r.lineTo(this.leftPanel.width, 0);
138
- _r.lineTo(this.leftPanel.width, this.height);
139
- _r.lineTo(0, this.height);
140
- _r.closePath();
141
- _r.fill('#090d16'); // deep slate sidebar background
216
+ public render(r: IRenderer): void {
217
+ const activeState = this.getActiveEditorState();
218
+ if (!activeState) return;
219
+
220
+ const theme = activeState.theme;
221
+ const layout = activeState.layoutConfig;
222
+
223
+ // Apply button styling
224
+ this.openBtn.bg = theme.statusBarBg;
225
+ this.openBtn.hoverBg = theme.statusBarBg;
226
+ this.openBtn.color = theme.fg;
227
+
228
+ if (this.treeView) {
229
+ /* eslint-disable-next-line no-underscore-dangle */
230
+ (this.treeView as any)._color = theme.fg;
231
+ /* eslint-disable-next-line no-underscore-dangle */
232
+ (this.treeView as any)._selColor = theme.accent + '33';
233
+ }
234
+
235
+ if (layout.sidebarPosition !== 'hidden') {
236
+ const startX = layout.sidebarPosition === 'left' ? 0 : this.width - this.leftPanel.width;
237
+ r.beginPath();
238
+ r.moveTo(startX, 0);
239
+ r.lineTo(startX + this.leftPanel.width, 0);
240
+ r.lineTo(startX + this.leftPanel.width, this.height);
241
+ r.lineTo(startX, this.height);
242
+ r.closePath();
243
+ r.fill(theme.sidebarBg);
244
+ }
142
245
  }
143
246
  }