@net-vim/core 0.3.1 → 0.5.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.
@@ -44,8 +44,11 @@ interface VimUIProps {
44
44
  x: number;
45
45
  y: number;
46
46
  });
47
+ hoverScrollOffset?: number | (() => number);
47
48
  statusMessage?: string | null | (() => string | null);
48
49
  wrap: boolean | (() => boolean);
50
+ lineEnding: 'LF' | 'CRLF' | (() => 'LF' | 'CRLF');
51
+ picker?: (() => any) | any;
49
52
  onCursorChange?: (cursor: {
50
53
  x: number;
51
54
  y: number;
@@ -1,10 +1,14 @@
1
1
  import { VimEngine } from './vim-engine';
2
+ import { FileSystem } from './types';
2
3
  export { default as VimEditor } from './VimEditor';
3
4
  export * from './types';
4
5
  export * from './vim-engine';
5
6
  export * from './plugin-manager';
7
+ export * as prelude from './prelude';
8
+ export { PRELUDE_PLUGINS } from './prelude';
6
9
  export interface InitOptions {
7
10
  wasmUrl?: string;
11
+ fileSystem?: FileSystem;
8
12
  }
9
13
  export declare function initNetVim(container: HTMLElement, options?: InitOptions): Promise<{
10
14
  vim: VimEngine;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,13 +1,22 @@
1
+ import { FileSystem } from './types';
1
2
  /**
2
3
  * Simple utility to interact with the Origin Private File System (OPFS)
4
+ * or fallback to a memory-based file system.
3
5
  */
4
6
  export declare const PRELUDE_BASE = ".config/net-vim/prelude";
7
+ export declare function setFSImplementation(fs: FileSystem): void;
5
8
  export declare const opfsFS: {
6
9
  readFile: typeof getConfigFile;
7
10
  writeFile: typeof writeConfigFile;
8
11
  listDirectory: typeof listDirectory;
9
12
  isDirectory: typeof isDirectory;
10
13
  };
14
+ export declare const autoFS: {
15
+ readFile: (path: string) => Promise<string | null>;
16
+ writeFile: (path: string, content: string) => Promise<void>;
17
+ listDirectory: (path: string) => Promise<string[]>;
18
+ isDirectory: (path: string) => Promise<boolean>;
19
+ };
11
20
  export declare function getConfigFile(path: string): Promise<string | null>;
12
21
  export declare function ensureConfigDir(path: string): Promise<FileSystemDirectoryHandle>;
13
22
  export declare function writeConfigFile(path: string, content: string): Promise<void>;
@@ -9,6 +9,8 @@ export interface ScopedVimAPI extends VimAPI {
9
9
  fs: {
10
10
  readFile: (path: string) => Promise<string | null>;
11
11
  writeFile: (path: string, content: string) => Promise<void>;
12
+ listDirectory: (path: string) => Promise<string[]>;
13
+ isDirectory: (path: string) => Promise<boolean>;
12
14
  };
13
15
  configFs: {
14
16
  readFile: (path: string) => Promise<string | null>;
@@ -36,6 +38,10 @@ export declare class PluginManager {
36
38
  * Loads a TypeScript plugin from a raw string
37
39
  */
38
40
  loadPluginFromSource(name: string, tsSource: string): Promise<boolean>;
41
+ /**
42
+ * Loads a plugin from a WebVimPlugin object
43
+ */
44
+ loadPlugin(plugin: WebVimPlugin): Promise<boolean>;
39
45
  private registerPlugin;
40
46
  private createScopedAPI;
41
47
  getLoadedPlugins(): PluginMetadata[];
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ metadata: {
3
+ name: string;
4
+ description: string;
5
+ author: string;
6
+ };
7
+ setup: (api: any) => void;
8
+ };
9
+ export default _default;
@@ -0,0 +1,8 @@
1
+ export { default as contextMenu } from './context-menu';
2
+ export { default as eruda } from './eruda';
3
+ export { default as externalFs } from './external-fs';
4
+ export { default as fuzzyFinder } from './fuzzy-finder';
5
+ export { default as hello } from './hello';
6
+ export { default as lineNumbers } from './line-numbers';
7
+ export { default as markdownSyntax } from './markdown-syntax';
8
+ export { default as tsLsp } from './ts-lsp';
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ metadata: {
3
+ name: string;
4
+ description: string;
5
+ };
6
+ setup: (api: any) => void;
7
+ };
8
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -9,7 +9,7 @@ declare module "solid-js" {
9
9
  }
10
10
  }
11
11
  export declare const TYPES_VERSION = "1.0.0";
12
- export type VimMode = 'Normal' | 'Insert' | 'Command' | 'Visual';
12
+ export type VimMode = 'Normal' | 'Insert' | 'Command' | 'Visual' | 'Search';
13
13
  export type VimEvent = 'ModeChanged' | 'CursorMoved' | 'TextChanged' | 'BufferLoaded' | 'FileChanged' | 'FileDeleted' | 'KeyDown' | 'FSChanged';
14
14
  export interface CompletionItem {
15
15
  label: string;
@@ -61,8 +61,20 @@ export interface LineRendererOptions {
61
61
  x: number;
62
62
  y: number;
63
63
  });
64
+ currentFilePath?: string | null | (() => string | null);
64
65
  }) => any;
65
66
  }
67
+ export interface PickerItem {
68
+ label: string;
69
+ detail?: string;
70
+ id?: string;
71
+ }
72
+ export interface PickerOptions {
73
+ items: PickerItem[] | ((query: string) => Promise<PickerItem[]>);
74
+ onSelect: (item: PickerItem) => void;
75
+ onCancel?: () => void;
76
+ placeholder?: string;
77
+ }
66
78
  export interface VimState {
67
79
  buffer: string[];
68
80
  cursor: {
@@ -95,8 +107,18 @@ export interface VimState {
95
107
  x: number;
96
108
  y: number;
97
109
  };
110
+ hoverScrollOffset: number;
98
111
  statusMessage: string | null;
99
112
  wrap: boolean;
113
+ lineEnding: 'LF' | 'CRLF';
114
+ picker: {
115
+ active: boolean;
116
+ query: string;
117
+ items: PickerItem[];
118
+ selectedIndex: number;
119
+ placeholder: string;
120
+ loading: boolean;
121
+ } | null;
100
122
  }
101
123
  export interface FileSystem {
102
124
  readFile: (path: string) => Promise<string | null>;
@@ -118,9 +140,11 @@ export interface VimAPI {
118
140
  y: number;
119
141
  } | null;
120
142
  getMode: () => VimMode;
143
+ getCurrentFilePath: () => string | null;
121
144
  on: (event: VimEvent, callback: (...args: any[]) => void) => void;
122
145
  executeCommand: (cmd: string) => void;
123
146
  loadPluginFromSource: (name: string, source: string) => Promise<boolean>;
147
+ loadPlugin: (plugin: any) => Promise<boolean>;
124
148
  registerGutter: (options: GutterOptions) => void;
125
149
  registerLineRenderer: (options: LineRendererOptions) => void;
126
150
  showCompletions: (items: CompletionItem[], onSelect: (item: CompletionItem) => void) => void;
@@ -130,6 +154,8 @@ export interface VimAPI {
130
154
  registerContextMenuItem: (item: ContextMenuItem) => void;
131
155
  insertText: (text: string) => void;
132
156
  rerender: () => void;
157
+ showPicker: (options: PickerOptions) => void;
158
+ hidePicker: () => void;
133
159
  setFS: (fs: FileSystem) => void;
134
160
  getFS: () => FileSystem;
135
161
  resetFS: () => void;
@@ -30,9 +30,21 @@ export declare class VimEngine {
30
30
  private onCompletionSelect;
31
31
  private hoverText;
32
32
  private hoverPos;
33
+ private hoverScrollOffset;
33
34
  private statusMessage;
34
35
  private messageTimeout;
35
36
  private wrap;
37
+ private lineEnding;
38
+ private pickerActive;
39
+ private pickerQuery;
40
+ private pickerItems;
41
+ private pickerSelectedIndex;
42
+ private pickerPlaceholder;
43
+ private pickerLoading;
44
+ private pickerOptions;
45
+ private pickerDebounceTimeout;
46
+ private lastSearchPattern;
47
+ private lastSearchForward;
36
48
  constructor(onUpdate: () => void);
37
49
  init(): Promise<void>;
38
50
  setUpdateCallback(onUpdate: () => void): void;
@@ -40,18 +52,24 @@ export declare class VimEngine {
40
52
  private openDirectory;
41
53
  private openFile;
42
54
  getAPI(): VimAPI;
55
+ private updatePickerResults;
56
+ private insertText;
43
57
  hideCompletions(): void;
44
58
  setViewportHeight(height: number): void;
45
59
  setViewportWidth(width: number): void;
46
60
  private scrollCursorIntoView;
47
61
  private trigger;
48
62
  loadPluginFromSource(name: string, tsSource: string): Promise<boolean>;
63
+ loadPlugin(plugin: any): Promise<boolean>;
49
64
  setCursor(x: number, y: number): void;
50
65
  getState(): VimState;
51
66
  private showMessage;
52
67
  handleKey(key: string, _ctrl?: boolean): void;
68
+ private handlePickerKey;
69
+ private debouncedPickerUpdate;
53
70
  private handleExplorerSelect;
54
71
  private moveCursor;
72
+ private putFromClipboard;
55
73
  private handleNormalMode;
56
74
  private handleInsertMode;
57
75
  private handleVisualMode;
@@ -60,4 +78,6 @@ export declare class VimEngine {
60
78
  private deleteSelection;
61
79
  private handleCommandMode;
62
80
  private executeCommand;
81
+ private handleSearchMode;
82
+ private repeatSearch;
63
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@net-vim/core",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "Vim-compatible editor engine and component library for the web.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -44,15 +44,9 @@
44
44
  "types": "./dist/index.d.ts"
45
45
  }
46
46
  },
47
- "scripts": {
48
- "sync-wasm": "cp -r ../../crates/tui-engine/pkg/* ./src/wasm/",
49
- "build": "npm run sync-wasm && vite build",
50
- "prepublishOnly": "npm run build",
51
- "test": "vitest run"
52
- },
53
47
  "dependencies": {
54
- "@net-vim/virtual-keyboard": "workspace:*",
55
- "solid-js": "^1.9.11"
48
+ "solid-js": "^1.9.11",
49
+ "@net-vim/virtual-keyboard": "0.1.0"
56
50
  },
57
51
  "devDependencies": {
58
52
  "typescript": "~5.9.3",
@@ -61,5 +55,10 @@
61
55
  "vite-plugin-solid": "^2.11.10",
62
56
  "vite-plugin-top-level-await": "^1.6.0",
63
57
  "vite-plugin-wasm": "^3.5.0"
58
+ },
59
+ "scripts": {
60
+ "sync-wasm": "cp -r ../../crates/tui-engine/pkg/* ./src/wasm/",
61
+ "build": "npm run sync-wasm && vite build",
62
+ "test": "vitest run"
64
63
  }
65
- }
64
+ }