@joinezco/codeblock 0.0.9 → 0.0.11

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 (59) hide show
  1. package/dist/editor.d.ts +23 -2
  2. package/dist/editor.js +346 -41
  3. package/dist/index.d.ts +3 -2
  4. package/dist/index.js +3 -2
  5. package/dist/lsps/index.d.ts +5 -0
  6. package/dist/lsps/index.js +9 -2
  7. package/dist/panels/{footer.d.ts → settings.d.ts} +7 -1
  8. package/dist/panels/{footer.js → settings.js} +12 -3
  9. package/dist/panels/terminal.d.ts +3 -0
  10. package/dist/panels/terminal.js +76 -0
  11. package/dist/panels/toolbar.d.ts +40 -3
  12. package/dist/panels/toolbar.js +919 -160
  13. package/dist/themes/index.js +63 -17
  14. package/dist/types.d.ts +5 -0
  15. package/dist/utils/fs.d.ts +7 -0
  16. package/dist/utils/fs.js +41 -15
  17. package/dist/workers/fs.worker.d.ts +4 -8
  18. package/dist/workers/fs.worker.js +27 -53
  19. package/package.json +14 -12
  20. package/dist/assets/clike-C8IJ2oj_.js +0 -1
  21. package/dist/assets/cmake-BQqOBYOt.js +0 -1
  22. package/dist/assets/dockerfile-C_y-rIpk.js +0 -1
  23. package/dist/assets/fs.worker-DfanUHpQ.js +0 -21
  24. package/dist/assets/go-CTD25R5P.js +0 -1
  25. package/dist/assets/haskell-BWDZoCOh.js +0 -1
  26. package/dist/assets/index-BAnLzvMk.js +0 -1
  27. package/dist/assets/index-BBC9WDX6.js +0 -1
  28. package/dist/assets/index-BEXYxRro.js +0 -1
  29. package/dist/assets/index-BfYmUKH9.js +0 -13
  30. package/dist/assets/index-BhaTNAWE.js +0 -1
  31. package/dist/assets/index-CCbYDSng.js +0 -1
  32. package/dist/assets/index-CIi8tLT6.js +0 -1
  33. package/dist/assets/index-CaANcgI2.js +0 -3
  34. package/dist/assets/index-CkWzFNzm.js +0 -208
  35. package/dist/assets/index-D_XGv9QZ.js +0 -1
  36. package/dist/assets/index-DkmiPfkD.js +0 -1
  37. package/dist/assets/index-DmNlLMQ4.js +0 -6
  38. package/dist/assets/index-DmX_vI7D.js +0 -1
  39. package/dist/assets/index-DogEEevD.js +0 -1
  40. package/dist/assets/index-DsDl5qZV.js +0 -2
  41. package/dist/assets/index-gAy5mDg-.js +0 -1
  42. package/dist/assets/index-i5qJLB2h.js +0 -1
  43. package/dist/assets/javascript.worker-ClsyHOLi.js +0 -552
  44. package/dist/assets/lua-BgMRiT3U.js +0 -1
  45. package/dist/assets/perl-CdXCOZ3F.js +0 -1
  46. package/dist/assets/process-Dw9K5EnD.js +0 -1357
  47. package/dist/assets/properties-C78fOPTZ.js +0 -1
  48. package/dist/assets/ruby-B2Rjki9n.js +0 -1
  49. package/dist/assets/shell-CjFT_Tl9.js +0 -1
  50. package/dist/assets/swift-BzpIVaGY.js +0 -1
  51. package/dist/assets/toml-BXUEaScT.js +0 -1
  52. package/dist/assets/vb-CmGdzxic.js +0 -1
  53. package/dist/e2e/editor.spec.d.ts +0 -1
  54. package/dist/e2e/editor.spec.js +0 -309
  55. package/dist/e2e/example.spec.d.ts +0 -5
  56. package/dist/e2e/example.spec.js +0 -44
  57. package/dist/index.html +0 -15
  58. package/dist/resources/config.json +0 -13
  59. package/dist/styles.css +0 -7
@@ -1,5 +1,5 @@
1
1
  import { EditorView } from "@codemirror/view";
2
- import { StateEffect, StateField } from "@codemirror/state";
2
+ import { Facet, StateEffect, StateField } from "@codemirror/state";
3
3
  import { setThemeEffect, lineWrappingCompartment } from "../editor";
4
4
  const defaultSettings = {
5
5
  theme: 'system',
@@ -10,11 +10,20 @@ const defaultSettings = {
10
10
  lspLogEnabled: false,
11
11
  agentUrl: '',
12
12
  terminalEnabled: false,
13
+ maxVisibleLines: 0,
14
+ showLineNumbers: true,
15
+ showFoldGutter: true,
16
+ autoHideToolbar: false,
13
17
  };
18
+ /** Facet carrying initial settings so settingsField.create() can read them without circular imports. */
19
+ export const InitialSettingsFacet = Facet.define({
20
+ combine: (values) => Object.assign({}, ...values),
21
+ });
14
22
  export const updateSettingsEffect = StateEffect.define();
15
23
  export const settingsField = StateField.define({
16
- create() {
17
- return { ...defaultSettings };
24
+ create(state) {
25
+ const initial = state.facet(InitialSettingsFacet);
26
+ return { ...defaultSettings, ...initial };
18
27
  },
19
28
  update(value, tr) {
20
29
  for (const e of tr.effects) {
@@ -0,0 +1,3 @@
1
+ import { EditorView } from "@codemirror/view";
2
+ /** Open (or toggle) the terminal panel on the given editor view. */
3
+ export declare function openTerminal(view: EditorView): Promise<void>;
@@ -0,0 +1,76 @@
1
+ import { showPanel } from "@codemirror/view";
2
+ import { terminalCompartment } from "../editor";
3
+ import { settingsField, resolveThemeDark } from "./settings";
4
+ let ghosttyModule = null;
5
+ async function ensureGhostty() {
6
+ if (ghosttyModule)
7
+ return ghosttyModule;
8
+ // Dynamic import — ghostty-web is loaded only when the terminal is opened.
9
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
+ const mod = await import('ghostty-web');
11
+ await mod.init();
12
+ ghosttyModule = mod;
13
+ return mod;
14
+ }
15
+ const CLOSE_ICON = '\uf00d'; // nf-fa-close
16
+ function createTerminalPanel(view) {
17
+ const dom = document.createElement("div");
18
+ dom.className = "cm-terminal-panel";
19
+ // Header bar with close button
20
+ const header = document.createElement("div");
21
+ header.className = "cm-terminal-header";
22
+ const title = document.createElement("span");
23
+ title.className = "cm-terminal-title";
24
+ title.textContent = "Terminal";
25
+ header.appendChild(title);
26
+ const closeBtn = document.createElement("button");
27
+ closeBtn.className = "cm-terminal-close";
28
+ closeBtn.style.fontFamily = 'var(--cm-icon-font-family)';
29
+ closeBtn.textContent = CLOSE_ICON;
30
+ closeBtn.title = "Close terminal";
31
+ closeBtn.addEventListener("click", () => {
32
+ view.dispatch({
33
+ effects: terminalCompartment.reconfigure([]),
34
+ });
35
+ });
36
+ header.appendChild(closeBtn);
37
+ dom.appendChild(header);
38
+ // Terminal container
39
+ const container = document.createElement("div");
40
+ container.className = "cm-terminal-container";
41
+ dom.appendChild(container);
42
+ let terminal = null;
43
+ // Lazy-load ghostty-web and mount
44
+ ensureGhostty().then(({ Terminal }) => {
45
+ if (!dom.isConnected)
46
+ return;
47
+ const settings = view.state.field(settingsField);
48
+ const dark = resolveThemeDark(settings.theme);
49
+ terminal = new Terminal({
50
+ fontSize: settings.fontSize,
51
+ theme: dark
52
+ ? { background: '#1e1e1e', foreground: '#d4d4d4' }
53
+ : { background: '#ffffff', foreground: '#1e1e1e' },
54
+ });
55
+ terminal.open(container);
56
+ terminal.write('\x1b[1;32m$\x1b[0m Terminal ready (no backend connected)\r\n');
57
+ }).catch((err) => {
58
+ container.textContent = `Failed to load terminal: ${err.message}`;
59
+ container.style.padding = '8px';
60
+ container.style.color = '#f44';
61
+ });
62
+ return {
63
+ dom,
64
+ top: false,
65
+ destroy() {
66
+ terminal?.dispose?.();
67
+ terminal = null;
68
+ },
69
+ };
70
+ }
71
+ /** Open (or toggle) the terminal panel on the given editor view. */
72
+ export async function openTerminal(view) {
73
+ view.dispatch({
74
+ effects: terminalCompartment.reconfigure(showPanel.of(createTerminalPanel)),
75
+ });
76
+ }
@@ -3,11 +3,32 @@ import { StateField } from "@codemirror/state";
3
3
  import { HighlightedSearch } from "../utils/search";
4
4
  export interface CommandResult {
5
5
  id: string;
6
- type: 'create-file' | 'rename-file' | 'import-local-files' | 'import-local-folder' | 'open-file';
6
+ type: 'create-file' | 'save-as' | 'rename-file' | 'import-local-files' | 'import-local-folder' | 'open-file' | 'settings' | 'open-terminal' | 'file-action';
7
7
  icon: string;
8
8
  iconColor?: string;
9
9
  query: string;
10
10
  requiresInput?: boolean;
11
+ /** For type 'file-action': callback executed when the command is selected. */
12
+ action?: (view: EditorView) => void;
13
+ }
14
+ export interface FileActionEntry {
15
+ /** File extensions this command applies to (e.g. ['svg']) */
16
+ extensions: string[];
17
+ /** Display label */
18
+ label: string;
19
+ /** Nerd Font icon glyph */
20
+ icon: string;
21
+ /** Callback when selected */
22
+ action: (view: EditorView) => void;
23
+ }
24
+ /** Register a command that appears when files with matching extensions are open. */
25
+ export declare function registerFileAction(entry: FileActionEntry): void;
26
+ export interface SettingsEntry {
27
+ id: string;
28
+ settingKey: string;
29
+ type: 'settings-toggle' | 'settings-cycle' | 'settings-input';
30
+ icon: string;
31
+ currentValue: string;
11
32
  }
12
33
  export interface BrowseEntry {
13
34
  id: string;
@@ -16,10 +37,10 @@ export interface BrowseEntry {
16
37
  iconColor?: string;
17
38
  fullPath: string;
18
39
  }
19
- export type SearchResult = HighlightedSearch | CommandResult | BrowseEntry;
40
+ export type SearchResult = HighlightedSearch | CommandResult | BrowseEntry | SettingsEntry;
20
41
  export interface NamingMode {
21
42
  active: boolean;
22
- type: 'create-file' | 'rename-file';
43
+ type: 'create-file' | 'save-as' | 'rename-file';
23
44
  originalQuery: string;
24
45
  languageExtension?: string;
25
46
  }
@@ -28,6 +49,22 @@ export interface BrowseMode {
28
49
  currentPath: string;
29
50
  filter: string;
30
51
  }
52
+ export interface SettingsMode {
53
+ active: boolean;
54
+ filter: string;
55
+ editing: string | null;
56
+ }
57
+ export interface DeleteMode {
58
+ active: boolean;
59
+ filePath: string;
60
+ }
61
+ export interface OverwriteMode {
62
+ active: boolean;
63
+ filePath: string;
64
+ action: 'save-as' | 'create-file' | 'rename';
65
+ /** For rename: the old path to delete after overwrite */
66
+ oldPath?: string;
67
+ }
31
68
  export declare const setSearchResults: import("@codemirror/state").StateEffectType<SearchResult[]>;
32
69
  export declare const searchResultsField: StateField<SearchResult[]>;
33
70
  export declare const toolbarPanel: (view: EditorView) => Panel;