@net-vim/core 0.4.0 → 0.5.1

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,8 +1,10 @@
1
+ import { FileSystem } from './types';
1
2
  /**
2
3
  * Simple utility to interact with the Origin Private File System (OPFS)
3
4
  * or fallback to a memory-based file system.
4
5
  */
5
6
  export declare const PRELUDE_BASE = ".config/net-vim/prelude";
7
+ export declare function setFSImplementation(fs: FileSystem): void;
6
8
  export declare const opfsFS: {
7
9
  readFile: typeof getConfigFile;
8
10
  writeFile: typeof writeConfigFile;
@@ -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 @@
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;
@@ -64,6 +64,17 @@ export interface LineRendererOptions {
64
64
  currentFilePath?: string | null | (() => string | null);
65
65
  }) => any;
66
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
+ }
67
78
  export interface VimState {
68
79
  buffer: string[];
69
80
  cursor: {
@@ -96,8 +107,18 @@ export interface VimState {
96
107
  x: number;
97
108
  y: number;
98
109
  };
110
+ hoverScrollOffset: number;
99
111
  statusMessage: string | null;
100
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;
101
122
  }
102
123
  export interface FileSystem {
103
124
  readFile: (path: string) => Promise<string | null>;
@@ -123,6 +144,7 @@ export interface VimAPI {
123
144
  on: (event: VimEvent, callback: (...args: any[]) => void) => void;
124
145
  executeCommand: (cmd: string) => void;
125
146
  loadPluginFromSource: (name: string, source: string) => Promise<boolean>;
147
+ loadPlugin: (plugin: any) => Promise<boolean>;
126
148
  registerGutter: (options: GutterOptions) => void;
127
149
  registerLineRenderer: (options: LineRendererOptions) => void;
128
150
  showCompletions: (items: CompletionItem[], onSelect: (item: CompletionItem) => void) => void;
@@ -132,6 +154,8 @@ export interface VimAPI {
132
154
  registerContextMenuItem: (item: ContextMenuItem) => void;
133
155
  insertText: (text: string) => void;
134
156
  rerender: () => void;
157
+ showPicker: (options: PickerOptions) => void;
158
+ hidePicker: () => void;
135
159
  setFS: (fs: FileSystem) => void;
136
160
  getFS: () => FileSystem;
137
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,6 +52,7 @@ export declare class VimEngine {
40
52
  private openDirectory;
41
53
  private openFile;
42
54
  getAPI(): VimAPI;
55
+ private updatePickerResults;
43
56
  private insertText;
44
57
  hideCompletions(): void;
45
58
  setViewportHeight(height: number): void;
@@ -47,10 +60,13 @@ export declare class VimEngine {
47
60
  private scrollCursorIntoView;
48
61
  private trigger;
49
62
  loadPluginFromSource(name: string, tsSource: string): Promise<boolean>;
63
+ loadPlugin(plugin: any): Promise<boolean>;
50
64
  setCursor(x: number, y: number): void;
51
65
  getState(): VimState;
52
66
  private showMessage;
53
67
  handleKey(key: string, _ctrl?: boolean): void;
68
+ private handlePickerKey;
69
+ private debouncedPickerUpdate;
54
70
  private handleExplorerSelect;
55
71
  private moveCursor;
56
72
  private putFromClipboard;
@@ -62,4 +78,6 @@ export declare class VimEngine {
62
78
  private deleteSelection;
63
79
  private handleCommandMode;
64
80
  private executeCommand;
81
+ private handleSearchMode;
82
+ private repeatSearch;
65
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@net-vim/core",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
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
+ }