@fresh-editor/fresh-editor 0.1.74 → 0.1.76

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +6 -0
  3. package/package.json +1 -1
  4. package/plugins/audit_mode.ts +9 -4
  5. package/plugins/buffer_modified.ts +1 -1
  6. package/plugins/calculator.ts +1 -1
  7. package/plugins/check-types.sh +41 -0
  8. package/plugins/clangd_support.ts +1 -1
  9. package/plugins/color_highlighter.ts +4 -1
  10. package/plugins/config-schema.json +44 -2
  11. package/plugins/diagnostics_panel.i18n.json +52 -52
  12. package/plugins/diagnostics_panel.ts +168 -540
  13. package/plugins/find_references.ts +82 -324
  14. package/plugins/git_blame.i18n.json +260 -247
  15. package/plugins/git_blame.ts +4 -9
  16. package/plugins/git_find_file.ts +42 -270
  17. package/plugins/git_grep.ts +50 -167
  18. package/plugins/git_gutter.ts +1 -1
  19. package/plugins/git_log.ts +4 -11
  20. package/plugins/lib/finder.ts +1499 -0
  21. package/plugins/lib/fresh.d.ts +104 -19
  22. package/plugins/lib/index.ts +14 -0
  23. package/plugins/lib/navigation-controller.ts +1 -1
  24. package/plugins/lib/panel-manager.ts +7 -13
  25. package/plugins/lib/results-panel.ts +914 -0
  26. package/plugins/lib/search-utils.ts +343 -0
  27. package/plugins/lib/virtual-buffer-factory.ts +3 -2
  28. package/plugins/live_grep.ts +56 -379
  29. package/plugins/markdown_compose.ts +1 -17
  30. package/plugins/merge_conflict.ts +16 -14
  31. package/plugins/path_complete.ts +1 -1
  32. package/plugins/search_replace.i18n.json +13 -13
  33. package/plugins/search_replace.ts +11 -9
  34. package/plugins/theme_editor.ts +57 -30
  35. package/plugins/todo_highlighter.ts +1 -0
  36. package/plugins/vi_mode.ts +9 -5
  37. package/plugins/welcome.ts +1 -1
  38. package/themes/dark.json +102 -0
  39. package/themes/high-contrast.json +102 -0
  40. package/themes/light.json +102 -0
  41. package/themes/nostalgia.json +102 -0
@@ -46,11 +46,90 @@
46
46
  * and define buffer-local keybindings. Virtual buffers typically use custom modes.
47
47
  */
48
48
 
49
- declare global {
49
+ /**
50
+ * Get the editor API instance.
51
+ * Plugins must call this at the top of their file to get a scoped editor object.
52
+ * @returns The editor API object for this plugin
53
+ * @example
54
+ * const editor = getEditor();
55
+ */
56
+ declare function getEditor(): EditorAPI;
57
+
58
+ /**
59
+ * Plugin-specific methods added by the JavaScript runtime wrapper.
60
+ * These extend the base EditorAPI with i18n and command registration helpers.
61
+ */
62
+ interface EditorAPI {
63
+ /**
64
+ * Translate a string using the plugin's i18n file
65
+ * @param key - Translation key (e.g., "status.ready")
66
+ * @param args - Optional interpolation arguments
67
+ * @returns Translated string
68
+ */
69
+ t(key: string, args?: Record<string, string>): string;
70
+
71
+ /**
72
+ * Get the i18n helper object (for compatibility)
73
+ * @returns Object with t() method bound to this plugin
74
+ */
75
+ getL10n(): { t: (key: string, args?: Record<string, string>) => string };
76
+
50
77
  /**
51
- * Global editor API object available to all TypeScript plugins
78
+ * Register a custom command (plugin wrapper - source is added automatically)
79
+ * @param name - Command name (use %key for i18n)
80
+ * @param description - Command description (use %key for i18n)
81
+ * @param action - Global function name to call
82
+ * @param contexts - Comma-separated contexts (default: "")
83
+ * @returns true if command was registered
52
84
  */
53
- const editor: EditorAPI;
85
+ registerCommand(name: string, description: string, action: string, contexts?: string): boolean;
86
+
87
+ /**
88
+ * Copy text to system clipboard (alias for setClipboard)
89
+ * @param text - Text to copy
90
+ */
91
+ copyToClipboard(text: string): void;
92
+
93
+ /**
94
+ * Join path segments into a single path (variadic version)
95
+ * @param parts - Path segments to join
96
+ * @returns Joined path string
97
+ */
98
+ pathJoin(...parts: string[]): string;
99
+
100
+ /**
101
+ * Add a visual overlay to buffer text (with optional parameters)
102
+ * Most parameters have defaults: bold=false, italic=false, bg=-1 (transparent), extend=false
103
+ */
104
+ addOverlay(
105
+ buffer_id: number,
106
+ namespace: string,
107
+ start: number,
108
+ end: number,
109
+ r: number,
110
+ g: number,
111
+ b: number,
112
+ underline: boolean,
113
+ bold?: boolean,
114
+ italic?: boolean,
115
+ bg_r?: number,
116
+ bg_g?: number,
117
+ bg_b?: number,
118
+ extend_to_line_end?: boolean
119
+ ): boolean;
120
+
121
+ /**
122
+ * Get the theme JSON Schema (with proper typing)
123
+ */
124
+ getThemeSchema(): {
125
+ $defs?: Record<string, Record<string, unknown>>;
126
+ properties?: Record<string, unknown>;
127
+ };
128
+
129
+ /**
130
+ * Get built-in themes as a map of name to JSON string
131
+ */
132
+ getBuiltinThemes(): Record<string, string>;
54
133
  }
55
134
 
56
135
  /**
@@ -309,7 +388,7 @@ interface TsCompositeLayoutConfig {
309
388
  /** Show separator between panes */
310
389
  show_separator?: boolean | null;
311
390
  /** Spacing between stacked panes */
312
- spacing?: u16 | null;
391
+ spacing?: number | null;
313
392
  }
314
393
 
315
394
  /** Pane style configuration */
@@ -414,6 +493,7 @@ interface EditorAPI {
414
493
  * @returns JSON Schema object
415
494
  */
416
495
  getThemeSchema(): unknown;
496
+ getBuiltinThemes(): unknown;
417
497
  /**
418
498
  * Get the current editor configuration
419
499
  *
@@ -514,7 +594,7 @@ interface EditorAPI {
514
594
  * @param process_id - ID returned from spawnBackgroundProcess
515
595
  * @returns true if process is running, false if not found or exited
516
596
  */
517
- isProcessRunning(#[bigint] process_id: number): boolean;
597
+ isProcessRunning(process_id: number): boolean;
518
598
  /** Compute syntax highlighting for a buffer range */
519
599
  getHighlights(buffer_id: number, start: number, end: number): Promise<TsHighlightSpan[]>;
520
600
  /** Get diff vs last saved snapshot for a buffer */
@@ -685,7 +765,7 @@ interface EditorAPI {
685
765
  * @param priority - Priority for ordering multiple lines at same position
686
766
  * @returns true if virtual line was added
687
767
  */
688
- addVirtualLine(buffer_id: number, position: number, text: string, fg_r: number, fg_g: number, fg_b: number, bg_r: i16, bg_g: i16, bg_b: i16, above: boolean, namespace: string, priority: number): boolean;
768
+ addVirtualLine(buffer_id: number, position: number, text: string, fg_r: number, fg_g: number, fg_b: number, bg_r: number, bg_g: number, bg_b: number, above: boolean, namespace: string, priority: number): boolean;
689
769
  /**
690
770
  * Set a line indicator in the gutter's indicator column
691
771
  * @param buffer_id - The buffer ID
@@ -792,14 +872,14 @@ interface EditorAPI {
792
872
  * @param process_id - ID returned from spawnBackgroundProcess or spawnProcessStart
793
873
  * @returns true if process was killed, false if not found
794
874
  */
795
- killProcess(#[bigint] process_id: number): Promise<boolean>;
875
+ killProcess(process_id: number): Promise<boolean>;
796
876
  /**
797
877
  * Wait for a cancellable process to complete and get its result
798
878
  *
799
879
  * @param process_id - ID returned from spawnProcessStart
800
880
  * @returns SpawnResult with stdout, stderr, and exit_code
801
881
  */
802
- spawnProcessWait(#[bigint] process_id: number): Promise<SpawnResult>;
882
+ spawnProcessWait(process_id: number): Promise<SpawnResult>;
803
883
  /**
804
884
  * Delay execution for a specified number of milliseconds
805
885
  *
@@ -808,7 +888,7 @@ interface EditorAPI {
808
888
  * @example
809
889
  * await editor.delay(100); // Wait 100ms
810
890
  */
811
- delay(#[bigint] ms: number): Promise<[]>;
891
+ delay(ms: number): Promise<void>;
812
892
  /** Find a buffer ID by its file path */
813
893
  findBufferByPath(path: string): number;
814
894
  /**
@@ -819,6 +899,14 @@ interface EditorAPI {
819
899
  * @returns true if prompt was started successfully
820
900
  */
821
901
  startPromptWithInitial(label: string, prompt_type: string, initial_value: string): boolean;
902
+ /**
903
+ * Delete a theme file by name
904
+ *
905
+ * Only deletes files from the user's themes directory.
906
+ * This is a safe operation that prevents plugins from deleting arbitrary files.
907
+ * @param name - Theme name (without .json extension)
908
+ */
909
+ deleteTheme(name: string): Promise<void>;
822
910
  /**
823
911
  * Create a composite buffer that displays multiple source buffers
824
912
  *
@@ -937,7 +1025,7 @@ interface EditorAPI {
937
1025
  * Anchors map corresponding line numbers between left and right buffers.
938
1026
  * Each anchor is a tuple of (left_line, right_line).
939
1027
  */
940
- setScrollSyncAnchors(group_id: number, anchors: Vec<(usize, usize): boolean;
1028
+ setScrollSyncAnchors(group_id: number, anchors: [number, number][]): boolean;
941
1029
  /** Remove a scroll sync group */
942
1030
  removeScrollSyncGroup(group_id: number): boolean;
943
1031
 
@@ -980,7 +1068,7 @@ interface EditorAPI {
980
1068
  * @param extend_to_line_end - Extend background to end of visual line
981
1069
  * @returns true if overlay was added
982
1070
  */
983
- addOverlay(buffer_id: number, namespace: string, start: number, end: number, r: number, g: number, b: number, bg_r: i16, bg_g: i16, bg_b: i16, underline: boolean, bold: boolean, italic: boolean, extend_to_line_end: boolean): boolean;
1071
+ addOverlay(buffer_id: number, namespace: string, start: number, end: number, r: number, g: number, b: number, bg_r: number, bg_g: number, bg_b: number, underline: boolean, bold: boolean, italic: boolean, extend_to_line_end: boolean): boolean;
984
1072
  /**
985
1073
  * Remove a specific overlay by its handle
986
1074
  * @param buffer_id - The buffer ID
@@ -1060,14 +1148,14 @@ interface EditorAPI {
1060
1148
  */
1061
1149
  readFile(path: string): Promise<string>;
1062
1150
  /**
1063
- * Write string content to a file, creating or overwriting
1151
+ * Write string content to a NEW file (fails if file exists)
1064
1152
  *
1065
- * Creates parent directories if they don't exist (behavior may vary).
1066
- * Replaces file contents entirely; use readFile + modify + writeFile for edits.
1153
+ * Creates a new file with the given content. Fails if the file already exists
1154
+ * to prevent plugins from accidentally overwriting user data.
1067
1155
  * @param path - Destination path (absolute or relative to cwd)
1068
1156
  * @param content - UTF-8 string to write
1069
1157
  */
1070
- writeFile(path: string, content: string): Promise<[]>;
1158
+ writeFile(path: string, content: string): Promise<void>;
1071
1159
  /**
1072
1160
  * Check if a path exists (file, directory, or symlink)
1073
1161
  *
@@ -1255,7 +1343,7 @@ interface EditorAPI {
1255
1343
  * ["q", "close_buffer"]
1256
1344
  * ], true);
1257
1345
  */
1258
- defineMode(name: string, parent: string, bindings: Vec<(String, String): boolean;
1346
+ defineMode(name: string, parent: string, bindings: [string, string][], read_only: boolean): boolean;
1259
1347
  /**
1260
1348
  * Switch the current split to display a buffer
1261
1349
  * @param buffer_id - ID of the buffer to show
@@ -1307,6 +1395,3 @@ interface EditorAPI {
1307
1395
  setVirtualBufferContent(buffer_id: number, entries: TextPropertyEntry[]): boolean;
1308
1396
 
1309
1397
  }
1310
-
1311
- // Export for module compatibility
1312
- export {};
@@ -22,3 +22,17 @@ export { NavigationController } from "./navigation-controller.ts";
22
22
  // Buffer Creation
23
23
  export { createVirtualBufferFactory } from "./virtual-buffer-factory.ts";
24
24
  export type { VirtualBufferOptions, SplitBufferOptions } from "./virtual-buffer-factory.ts";
25
+
26
+ // Finder Abstraction
27
+ export { Finder, defaultFuzzyFilter, parseGrepLine, parseGrepOutput, getRelativePath, createLiveProvider } from "./finder.ts";
28
+ export type {
29
+ DisplayEntry,
30
+ SearchSource,
31
+ FilterSource,
32
+ PreviewConfig,
33
+ FinderConfig,
34
+ PromptOptions,
35
+ PanelOptions as FinderPanelOptions,
36
+ FinderProvider,
37
+ LivePanelOptions,
38
+ } from "./finder.ts";
@@ -1,4 +1,4 @@
1
- /// <reference path="../../types/fresh.d.ts" />
1
+ /// <reference path="./fresh.d.ts" />
2
2
 
3
3
  import type { NavigationOptions } from "./types.ts";
4
4
 
@@ -1,4 +1,4 @@
1
- /// <reference path="../../types/fresh.d.ts" />
1
+ /// <reference path="./fresh.d.ts" />
2
2
 
3
3
  import type { PanelOptions, PanelState } from "./types.ts";
4
4
 
@@ -107,7 +107,7 @@ export class PanelManager {
107
107
  this.state.sourceBufferId = this.editor.getActiveBufferId();
108
108
 
109
109
  // Create virtual buffer in split
110
- const bufferId = await this.editor.createVirtualBufferInSplit({
110
+ const result = await this.editor.createVirtualBufferInSplit({
111
111
  name: this.panelName,
112
112
  mode: this.modeName,
113
113
  read_only: true,
@@ -119,11 +119,11 @@ export class PanelManager {
119
119
  });
120
120
 
121
121
  // Track state
122
- this.state.bufferId = bufferId;
123
- this.state.splitId = this.editor.getActiveSplitId();
122
+ this.state.bufferId = result.buffer_id;
123
+ this.state.splitId = result.split_id ?? this.editor.getActiveSplitId();
124
124
  this.state.isOpen = true;
125
125
 
126
- return bufferId;
126
+ return result.buffer_id;
127
127
  }
128
128
 
129
129
  /**
@@ -204,15 +204,9 @@ export class PanelManager {
204
204
  return;
205
205
  }
206
206
 
207
- // Focus source split and open file
207
+ // Focus source split and open file at location
208
208
  this.editor.focusSplit(this.state.sourceSplitId);
209
- await this.editor.openFile(filePath);
210
-
211
- // Jump to location
212
- this.editor.gotoLine(line);
213
- if (column > 1) {
214
- this.editor.gotoColumn(column);
215
- }
209
+ this.editor.openFile(filePath, line, column);
216
210
 
217
211
  // Focus back on panel
218
212
  this.focusPanel();