Skip to content

Commit 8446288

Browse files
bajrangCoderajr-uribesummoner001KARANKOYU
authored
chore: sync Acode main changes (ef7f3265..521d67c0) (#29)
* fix: prevent crash when opening file:// links from LSP tooltips (#2977) Open file:// links in LSP hover/signature docs in the editor, and guard the native openInBrowser against file URIs and launch failures. (cherry picked from commit d755c315cb760a964a89b136f4ae244ef89db0f8) * update: es-sv (#2974) * update: es-sv * Fix errors detected by greptile * fix: fmt --------- Co-authored-by: Raunak Raj <71929976+bajrangCoder@users.noreply.github.com> (cherry picked from commit 579af33f9ee584c5f4ad9e60c0f4a90346aa3b5b) * feat(modes): let plugin modes reuse another mode's formatter (#2976) * feat(modes): let plugin modes reuse another mode's formatter Add a formatAs option to editorLanguages.register so a plugin mode (e.g. json-bedrock) formats with the formatter and Prettier parser of an existing mode (e.g. json) when the user hasn't picked one for it. editorLanguages.register now forwards its options to addMode, and Mode ignores malformed options instead of throwing. * fix(modes): resolve formatAs aliases and label the inherited choice Resolve formatAs through the mode list so an alias (e.g. json5) finds the base mode's saved formatter and Prettier parser. For modes with formatAs, the picker's unset option now names the inherited formatter (e.g. "Prettier (JSON)") instead of "None". * fix(settings): refresh inherited formatter label when the picker opens (cherry picked from commit 5323b5879f60605195b259fe38f35e2b7c273c6e) * chore(deps): bump @lezer/common to 1.5.4 @lezer/common 1.5.4 fixes the look-ahead of the anonymous nodes that balance long repeats (lezer/common!11). Before it, incremental parses never reused them and re-tokenized everything before an edit, so a keystroke's reparse grew with its position in the file: CodeMirror's language field hit its 20ms budget on every key deep in large files (369ms vs 0.5ms for an edit at line 100k of a 4MB file in plain Lezer). Bumped in dependencies and overrides, so every package uses this copy. (cherry picked from commit 88ddc2740ac307acb2410ef26094d7ff163b5caa) * feat(markdown): render mermaid diagrams with pele (#2987) * feat(markdown): render mermaid diagrams with pele Replace the mermaid package with pele, a small synchronous renderer that loads each diagram type on demand and themes via CSS variables. * fix(markdown): map pele colors to defined theme variables (cherry picked from commit b08fd0bfc27abd6c58c576d959c607a7b6b69c31) * feat(editor): add experimental canvas renderer (#2988) * build: link @acode/canvas-view from a local checkout Resolve canvas-view's imports (and their types) from Acode's own node_modules, so CodeMirror's state and view stay single instances. * feat(settings): add editor renderer setting Renderer: DOM (default) or Canvas (experimental), applied on reload. * feat(editor): add experimental canvas renderer With editorRenderer set to canvas, editors are @acode/canvas-view CanvasViews. Settings that the DOM editor applies through extensions (line numbers, folding, guides, rainbow brackets, whitespace, wrapping, scroll past end, RTL) become canvas options, kept in sync on changes. Themes map to a CanvasThemeSpec (config colors + the theme's HighlightStyle). The selection menu is driven by the view's touch selection hooks, reusing the existing menu UI. * perf(editor): leave out CodeMirror's fold gutter with the canvas renderer The canvas renderer draws its own fold markers, but foldGutter() was still in the state, and its markers plugin rebuilt (unused) markers for the viewport on every update and tab switch. Canvas views now get only the folding state (codeFolding) with indentation folding. * fix(editor): open the color picker on canvas views isViewEditable read contentDOM's contenteditable and aria-readonly attributes. A canvas view's contentDOM is its hidden input element, which has neither, so taps on color chips (regex and LSP document colors) were swallowed as if the editor were read-only. Read the state's editable and readOnly facets instead, which is what the DOM editor's attributes reflect. * feat(editor): leave read-only handling to canvas views Acode's read-only setup works around the DOM editor on mobile: it makes the content non-editable, blurs on every focus so no keyboard opens, and shows CodeMirror's cursor layer with CSS. A canvas view handles read-only documents itself: it ignores typing, cut, paste and drops, takes focus with inputmode="none" (so its cursor blinks and hardware shortcuts work, without a keyboard), and drops focus when it becomes read-only. For canvas views the extension is now only EditorState.readOnly plus the filter for Acode's own editing commands, and blurEditorIfReadOnly / focusEditorIfEditable leave them focused. * feat(editor): selection matches and active indent guide on canvas With the canvas renderer: - highlightSelectionMatches is on (it's off by default for the DOM editor), drawn with the theme's selectionMatch color, or its selection color, as the themes' CSS does; - indent guides highlight the block around the cursor (one rect per frame on the canvas); - the base extensions leave out drawSelection, dropCursor, highlightActiveLine (and its gutter) and highlightSpecialChars, which the canvas draws itself. The canvas view only skipped their plugins; the active line gutter still rebuilt its markers on every selection change. * feat(editor): show lint underlines on canvas views on touch devices On touch devices the LSP linter drops every in-text mark (markerFilter), so only the lint gutter showed an error. Canvas views draw the wavy underlines and lint points natively, without the DOM editor's layout cost, so they keep them; hover tooltips stay filtered on touch. * perf(editor): draw color chips on canvas views without DOM ColorChipWidget gets toCanvas(): the same box toDOM styles (0.9em, 2px margins, rounded, a faint border), in cells of the view's font. Canvas views then make no element per chip; they call toDOM only when a chip is tapped, so the color picker still opens. * fix(editor): apply the line height setting to the editor's lines The font theme set `lineHeight` on the editor element, but CodeMirror's base theme sets `line-height: 1.4` on `.cm-scroller`, so the setting never reached the lines or gutters: the DOM editor was always 1.4 while canvas views used the setting, and the two renderers didn't match. Set it on `.cm-scroller`, so both renderers use it (canvas-view measures it like CodeMirror, to the DOM's exact value). The default becomes 1.4, what the editor always showed, and stored values of the old default (2), which nobody ever saw, are migrated once so editors don't change size. * feat(editor): canvas backend and sticky scroll settings Two settings for the canvas renderer, next to "Renderer": - "Canvas backend": Auto (WebGL2), WebGL2 or WebGPU (falls back to WebGL2 where unavailable). Views are created with it, so a change asks to reload when the canvas renderer is on. - "Sticky scroll": keeps the header lines of the scopes around the top line pinned while scrolling. Applies live to canvas views. * build: use @acode.app/canvas-view from npm canvas-view is now published as @acode.app/canvas-view, so depend on it instead of a local `bun link` checkout and drop the rspack and tsconfig workarounds that kept the linked copy on Acode's CodeMirror packages. Raise @codemirror/view, state, language and @lezer/common to the versions canvas-view requires, in dependencies and overrides, so a single copy of each is installed. The newer view flushes on every selectionchange, and happy-dom fires that event synchronously from Selection methods, which re-entered EditorView.update in the read-only cursor test. Queue it there like a browser does. * fix(editor): keep edits and DOM extensions across renderer changes - Flush pending cache writes and save the session before the reload that applies a renderer or canvas backend change, as the pause handler does, so recent edits aren't lost. - Include the renderer in the editor state signature, and give the DOM fallback pane a fresh empty state, so states built for canvas views (without fold controls and the active line) aren't reused by DOM ones. - Declare the canvas backend and sticky scroll strings in LangStrings. * feat(settings): more canvas renderer settings, shown only with canvas - Cursor blink rate, sticky scroll max lines and gutter marker layout (shared column, column per gutter, over line numbers), mapped to the matching canvas-view options and applied live. - Bring back the scroll speed setting, which canvas views use. - Canvas-only settings (backend, sticky scroll, its max lines, gutter markers, cursor blink rate, scroll speed) are listed only while the canvas renderer is selected, and follow renderer changes. --------- (cherry picked from commit 98446ef10ea8f2866416d18e753ccc8bfccd8b44) * chore(deps): bump @acode.app/canvas-view to 0.0.2 The canvas renderer now draws font ligatures (Fira Code's =>, !==...) like the DOM editor, and its fold markers no longer flash when the mouse quickly enters and leaves the gutter. (cherry picked from commit a16e2d3b2c95f5f670121075584617c2c838df54) * Translation: Update hu-hu.json (#2989) * Translation: Update hu-hu.json Translate new strings * Translation: Update hu-hu.json Fix translation (cherry picked from commit 2f6e4c55e82333545ba987054aafc62929225e21) * chore(deps): bump @acode.app/canvas-view to 0.0.3 The canvas renderer's repeated flicks now add up like Android's list views, a magnifier shows the text under the finger while dragging a selection (like sora-editor), and touch selections no longer draw a blinking cursor at their end. (cherry picked from commit f4b75304f5af12c7891d137517350fce6967d536) * test: queue happy-dom selectionchange in quick tools navigation tests @codemirror/view 6.43.14+ re-enters EditorView.update when happy-dom fires selectionchange synchronously while the view syncs its selection. * feat(sidebar): add multi-select & drag-drop to file tree (#2999) * feat(sidebar): add multi-select to file tree Select files and folders in the sidebar and act on them together: copy, cut, delete, copy relative paths, open and rename. The clipboard is now shared across open folders and pastes multiple entries. * feat(sidebar): drag to move, folder header actions, review fixes - Long-press and drag entries (or the whole selection) onto a folder to move them; closed folders open on hover and the list scrolls at edges. - Open folder headers get New file, New folder, Refresh and Collapse all: shown on hover with a mouse, behind a single "+" on touch. - Paste keeps skipped or failed entries in the clipboard and continues past failures. - Pasting across servers or storage transfers through both providers. - Open and copy path keep entries selected inside a selected folder. - Folder-into-itself warnings no longer block the paste. - Closing an open folder drops its entries from the selection. - Mock the new sidebar modules in the file icon sidebar test. * feat(sidebar): slide folder header actions out inline on touch Tapping "+" now reveals the actions as an inline strip in the header instead of a popup menu; it closes after an action or a tap elsewhere. * fix(sidebar): header menu, tree scrolling, long-press and review fixes - Header button opens the folder's select menu, which now also has Refresh and Collapse all. - Size open folders on every expand and measure real header heights, so the tree can scroll to its last entry. - Holding still after a long press opens the menu without lifting; a drag needs a deliberate move. - Release touch listeners after a drag ends. - Replacing an existing entry works when pasting across connections. * fix(sidebar): keep drags working across open folders Opening another folder mid-drag collapsed the source folder, which then collapsed the new one back, and detached the touched row so the drag stopped receiving touch events. Size folders only when they expand, listen for touch events on the touched row too, and cancel a drag on any stray touch. * fix(sidebar): check exclusions before replacing, recheck folder before sizing - Cross-connection copies skip excluded entries before deleting an existing destination. - Size a folder only if it's still open once the files app has loaded. (cherry picked from commit dd6497033c62ee0c21b29945cf59c5976169a72e) * fix(sidebar): don't render a folder twice when toggled while loading (#3002) * fix(sidebar): don't render a folder twice when toggled while loading Collapsing and re-expanding a folder before its listing finished let the old load render alongside the new one. Stale loads now skip rendering, and a new expand or collapse cancels a tree that is still loading. * test(sidebar): cover root folders toggled while loading Drive a real root folder through expand, collapse and expand with the directory reads still pending, resolving them in both orders and failing the stale one, and check that only the latest tree renders, a stale error doesn't collapse the folder and the loading bar follows the latest read. openFolder's single JSX expression becomes a tag() call so the module can load in tests. * test(sidebar): stub global tag in root folder tests (cherry picked from commit 9960e6e227c79c6ed03b2de4231aca2506aeec30) * fix(scrollbar): place thumb correctly when it reappears (#3003) * fix(scrollbar): place thumb correctly when it reappears The value was set while the scrollbar was detached, so it was measured against an empty rect and painted at 0 for a frame. Only check the track along the scroll axis, and measure again after appending. * fix(scrollbar): measure the track on every update while attached The parent can change size without a window resize (e.g. the sidebar opening), so a cached track length can go stale. (cherry picked from commit 06db49298f8e4e1cf3c80f436f1b50c7dca17276) * feat(ui): polish dialogs, sidebar, search and file actions (#3004) * feat(ui): polish dialogs, sidebar, search and file actions - Rename selects the file name without its extension - Hide the search summary until there is a query - Show an unread dot on the notifications icon; clear-all icon - Pin the sponsor icon above the profile, out of the app list - Make the sidebar icon rail scrollable on touch - Show Delete in red in menus; distinct Save as icon - Map common native errors to readable messages - Theme-aware toast; sentence-case dialog buttons and titles - Title-case settings page names; fix inconsistent labels * style: format files command * fix(prompt): select whole file name when it has no extension (cherry picked from commit 6962af1e805b8996e743df97cad4df3ecef687e5) * feat(lang): update Turkish (tr-tr) translation (#2992) * feat(lang): update Turkish (tr-tr) translation * fix(lang): use "Yüklü" for "Installed" in tr-tr (cherry picked from commit 1d163d301eaa0ca96ce9e2218d1c11d22e1b627c) * fix(editor): keep cursor in document when pasting CRLF text (#3018) * fix(editor): keep cursor in document when pasting CRLF text Also update @lezer/common to 1.5.5. * chore(deps): sync package-lock with @lezer/common 1.5.5 * test(editor): cover pasting CRLF text (cherry picked from commit 672750c4e53a554b8f45cfe3092b29ce8406d3c9) * perf: keep the native Array.prototype.push on old WebViews (#3019) core-js forces its own Array.prototype.push below Chrome 122, because V8 there doesn't throw on push() with no arguments to an array whose length is read-only (V8 issue 12681). Nothing relies on that, but the replacement is plain JS and every push in the app goes through it. On an Infinix X688C (2GB, Helio G35-class CPU, WebView 80), 1M pushes took 1032ms with the polyfill and 122ms without, and a full parse of a 4MB JS file in Acode went from ~25s to ~18s. Text and first colors on opening that file came ~200ms and 200-400ms sooner, with both editors. WebView 122+ already used the native push and is unaffected. Ported from commit 521d67c0c0ee573445b5ed5868c1b62aedceeb62. Upstream bundles all of core-js/stable and swaps the module for an empty one with a NormalModuleReplacementPlugin. Here swc's env (mode "entry") already picks the core-js modules for the target engines, so the module is left out with env.exclude instead. --------- Co-authored-by: ajr_uribe <anthonyuribe3456@gmail.com> Co-authored-by: summoner <summoner001@users.noreply.github.com> Co-authored-by: KARANKOYU <262628218+KARANKOYU@users.noreply.github.com>
2 parents 9953794 + d0ee94b commit 8446288

103 files changed

Lines changed: 5849 additions & 2428 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎package-lock.json‎

Lines changed: 84 additions & 1283 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"ws": "^8.21.3"
7676
},
7777
"dependencies": {
78+
"@acode.app/canvas-view": "^0.0.3",
7879
"@codemirror/autocomplete": "^6.20.3",
7980
"@codemirror/commands": "^6.11.0",
8081
"@codemirror/lang-angular": "^0.1.4",
@@ -98,18 +99,18 @@
9899
"@codemirror/lang-wast": "^6.0.2",
99100
"@codemirror/lang-xml": "^6.1.0",
100101
"@codemirror/lang-yaml": "^6.1.3",
101-
"@codemirror/language": "^6.12.4",
102+
"@codemirror/language": "^6.13.1",
102103
"@codemirror/language-data": "^6.5.2",
103104
"@codemirror/legacy-modes": "^6.5.3",
104105
"@codemirror/lint": "^6.9.7",
105106
"@codemirror/lsp-client": "file:codemirror-lsp-client",
106107
"@codemirror/search": "^6.7.1",
107-
"@codemirror/state": "^6.7.1",
108+
"@codemirror/state": "^6.7.6",
108109
"@codemirror/theme-one-dark": "^6.1.3",
109-
"@codemirror/view": "^6.43.9",
110+
"@codemirror/view": "^6.43.14",
110111
"@deadlyjack/ajax": "^1.2.6",
111112
"@emmetio/codemirror6-plugin": "^0.4.1",
112-
"@lezer/common": "^1.5.2",
113+
"@lezer/common": "^1.5.5",
113114
"@lezer/highlight": "^1.2.5",
114115
"@lezer/lr": "^1.4.10",
115116
"@ungap/custom-elements": "^1.3.0",
@@ -140,10 +141,10 @@
140141
"markdown-it-github-alerts": "^1.0.1",
141142
"markdown-it-task-lists": "^2.1.1",
142143
"markdown-it-texmath": "^1.0.0",
143-
"mermaid": "^12.2.0",
144144
"mime-types": "^3.0.2",
145145
"motion": "^12.43.0",
146146
"mustache": "^4.2.0",
147+
"pele": "^1.10.0",
147148
"picomatch": "^4.0.7",
148149
"tough-cookie": "^6.0.2",
149150
"url-parse": "^1.5.10",
@@ -157,12 +158,12 @@
157158
"overrides": {
158159
"@codemirror/autocomplete": "^6.20.3",
159160
"@codemirror/commands": "^6.11.0",
160-
"@codemirror/language": "^6.12.4",
161+
"@codemirror/language": "^6.13.1",
161162
"@codemirror/lint": "^6.9.7",
162163
"@codemirror/search": "^6.7.1",
163-
"@codemirror/state": "^6.7.1",
164-
"@codemirror/view": "^6.43.9",
165-
"@lezer/common": "^1.5.2",
164+
"@codemirror/state": "^6.7.6",
165+
"@codemirror/view": "^6.43.14",
166+
"@lezer/common": "^1.5.5",
166167
"@lezer/lr": "^1.4.10",
167168
"tar": "^7.5.22"
168169
},

‎platforms/android/app/src/main/java/com/foxdebug/acode/system/System.java‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,8 +1678,26 @@ private void getAppInfo(Callback callback) {
16781678
}
16791679

16801680
private void openInBrowser(String src, Callback callback) {
1681-
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(src));
1682-
activity.startActivity(browserIntent);
1681+
if (src == null || src.isEmpty()) {
1682+
callback.error("No URL provided.");
1683+
return;
1684+
}
1685+
1686+
Uri uri = Uri.parse(src);
1687+
if ("file".equalsIgnoreCase(uri.getScheme())) {
1688+
// file:// URIs can't leave the app (FileUriExposedException).
1689+
callback.error("Cannot open file URI in browser: " + src);
1690+
return;
1691+
}
1692+
1693+
try {
1694+
Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri);
1695+
activity.startActivity(browserIntent);
1696+
callback.success();
1697+
} catch (Exception e) {
1698+
Log.e("System", "Failed to open URL: " + src, e);
1699+
callback.error(e.getMessage());
1700+
}
16831701
}
16841702

16851703
private void launchApp(

‎rspack.config.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ module.exports = (env, options) => {
2323
targets: platform === 'ios' ? 'ios_saf >= 18' : 'chrome >= 67',
2424
mode: 'entry',
2525
coreJs: require('core-js/package.json').version,
26+
// core-js replaces the native Array.prototype.push below Chrome 122, for
27+
// edge cases (lengths past 2^32 - 1, push() with no arguments on an array
28+
// with a read-only length) nothing relies on. Its JS version is ~8x
29+
// slower, and the parser, CodeMirror and the renderer push constantly.
30+
exclude: ['es.array.push'],
2631
};
2732
const typescriptLoader = {
2833
loader: 'builtin:swc-loader',

‎src/cm/baseExtensions.ts‎

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { history } from "@codemirror/commands";
88
import {
99
bracketMatching,
10+
codeFolding as codeFoldingState,
1011
defaultHighlightStyle,
1112
foldGutter,
1213
indentOnInput,
@@ -31,6 +32,17 @@ import indentationFolding from "./indentationFolding";
3132
export interface BaseExtensionOptions {
3233
autoIndent?: boolean;
3334
codeFolding?: boolean;
35+
/**
36+
* Show CodeMirror's fold gutter with code folding. The canvas renderer
37+
* draws its own fold markers, so it only needs the folding state.
38+
*/
39+
foldGutter?: boolean;
40+
/**
41+
* The canvas renderer draws the selection, cursors, drop cursor, active
42+
* line (and its gutter) and special characters itself, so those
43+
* extensions are left out.
44+
*/
45+
canvas?: boolean;
3446
autoCloseBrackets?: boolean;
3547
bracketMatching?: boolean;
3648
highlightActiveLine?: boolean;
@@ -46,17 +58,26 @@ export default function createBaseExtensions(
4658
const {
4759
autoIndent = true,
4860
codeFolding = true,
61+
foldGutter: showFoldGutter = true,
62+
canvas = false,
4963
autoCloseBrackets = true,
5064
bracketMatching: enableBracketMatching = true,
5165
highlightActiveLine: enableHighlightActiveLine = true,
5266
highlightSelectionMatches: enableHighlightSelectionMatches = true,
5367
} = options;
54-
const extensions: Extension[] = [highlightSpecialChars(), history()];
68+
const extensions: Extension[] = [history()];
69+
if (!canvas) extensions.push(highlightSpecialChars());
5570

56-
if (enableHighlightActiveLine) extensions.push(highlightActiveLineGutter());
57-
if (codeFolding) extensions.push(foldGutter(), indentationFolding);
58-
extensions.push(drawSelection());
59-
extensions.push(dropCursor());
71+
if (enableHighlightActiveLine && !canvas) {
72+
extensions.push(highlightActiveLineGutter());
73+
}
74+
if (codeFolding) {
75+
extensions.push(
76+
showFoldGutter ? foldGutter() : codeFoldingState(),
77+
indentationFolding,
78+
);
79+
}
80+
if (!canvas) extensions.push(drawSelection(), dropCursor());
6081
extensions.push(EditorState.allowMultipleSelections.of(true));
6182
if (autoIndent) extensions.push(indentOnInput());
6283
extensions.push(
@@ -66,7 +87,9 @@ export default function createBaseExtensions(
6687
if (autoCloseBrackets) extensions.push(closeBrackets());
6788
extensions.push(rectangularSelection());
6889
extensions.push(crosshairCursor());
69-
if (enableHighlightActiveLine) extensions.push(highlightActiveLine());
90+
if (enableHighlightActiveLine && !canvas) {
91+
extensions.push(highlightActiveLine());
92+
}
7093
if (enableHighlightSelectionMatches) {
7194
extensions.push(highlightSelectionMatches());
7295
}

0 commit comments

Comments
 (0)