diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4d3ecf27b..cbd3bbbcd3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,6 +65,11 @@ jobs: distribution: temurin java-version: '26' + - name: Install native unit test dependencies + run: | + sudo apt-get update + sudo apt-get install --no-install-recommends -y clang libsqlite3-dev + - name: Run unit tests run: npm run test diff --git a/.github/workflows/native-tests.yml b/.github/workflows/native-tests.yml index ed27a99266..a6abf6e2b2 100644 --- a/.github/workflows/native-tests.yml +++ b/.github/workflows/native-tests.yml @@ -24,6 +24,15 @@ on: schedule: - cron: "0 5 * * *" workflow_dispatch: + inputs: + alpine_node_tests: + description: 'Run Alpine Node/Vite integration tests (npm access; may hit hosted-runner process exits)' + type: boolean + default: false + sponsor_privacy_tests: + description: 'Run StoreKit sponsorship and privacy bridge UI integration tests' + type: boolean + default: false permissions: contents: read @@ -152,13 +161,17 @@ jobs: } JS - name: Build and run simulator tests with SSH and FTP fixtures + env: + RUN_ALPINE_NODE_TESTS: ${{ inputs.alpine_node_tests || false }} + RUN_SPONSOR_PRIVACY_TESTS: ${{ inputs.sponsor_privacy_tests || false }} run: | python3 -m venv .ios-build/ssh-fixture-venv .ios-build/ssh-fixture-venv/bin/pip install -r tests/fixtures/ssh/requirements.txt # Temporarily exclude Alpine process exits on hosted runners (run 41789669396). # Local runs retain these tests; InAppRunnerTests also starts Alpine. skips=() - for test in AlpineInteractionTests AlpineLspTests AlpinePackageTests AlpineSignalTests AlpineSimdTests AlpineTerminalServerTests AlpineTerminalTests InAppRunnerTests; do + for test in AlpineInteractionTests AlpineLspTests AlpineNodeTests AlpinePackageTests AlpineSignalTests AlpineSimdTests AlpineTerminalServerTests AlpineTerminalTests InAppRunnerTests; do + if [[ "$test" == AlpineNodeTests && "$RUN_ALPINE_NODE_TESTS" == true ]]; then continue; fi skips+=("-skip-testing:runnerTests/$test") done # StoreKit test sessions and these web UI interactions fail on every hosted run @@ -174,6 +187,11 @@ jobs: runnerUITests/WebContextMenuUITests; do skips+=("-skip-testing:$test") done + if [[ "$RUN_SPONSOR_PRIVACY_TESTS" != true ]]; then + skips+=("-skip-testing:runnerTests/SponsorPurchaseTests") + skips+=("-skip-testing:runnerTests/AdsBridgeTests/testPrivacyBridgeReturnsOnlyCurrentIabSignals") + skips+=("-skip-testing:runnerTests/AdsBridgeTests/testPrivacySnapshotReflectsWithdrawalAndRemovedSignals") + fi .ios-build/ssh-fixture-venv/bin/python tests/fixtures/ssh/server.py -- npm run test:ios -- --target=${{ steps.simulator.outputs.id }} "${skips[@]}" - name: Run iPad startup and native UI checks run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a24337a29..527145df86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,634 +1,650 @@ # Change Log -## Unreleased +## v1.13.7 -* Ad-free pass redemption is discontinued; previously earned time remains valid until expiry. The `system.redeemReward` wrapper and native action have been removed. Plugins using that action must stop offering redemption. Internal pass-offer helpers and the `isWatchingRewardedAd` export were also removed. +- iOS sign-in now shares one account across Acode subdomain APIs. Existing production sessions stay signed in; users with only a legacy development session need to sign in again. +- Sponsorship supports iOS StoreKit purchases and recovers unfinished purchases on iOS and Android after restart, requesting missing sponsor details without another charge. +- iOS terminal: npm shows fetch and install-script activity by default while retaining security audits. Local server links open in an isolated in-app preview, with visible errors if the preview cannot open. +- System theme: dialog dimming now follows the current light or dark appearance. +- iOS: expose current UMP IAB consent signals through the privacy API so plugins can check advertising consent and respond to changed choices. +- iOS terminal: Node.js can run WebAssembly, so Vite, React and other WebAssembly-based tools work in Alpine. `os.networkInterfaces()` and `vite --host` now see the device's network interfaces. Older Node versions installed in the terminal keep starting, because only the engine settings they support are applied. + If a custom Node binary's V8 version cannot be detected, compatibility flags leave Sparkplug and Maglev at their defaults; that binary may miss the stability workarounds used for recognized versions. +- Ad-free pass redemption is discontinued; previously earned time remains valid until expiry. The `system.redeemReward` wrapper and native action have been removed. Plugins using that action must stop offering redemption. Internal pass-offer helpers and the `isWatchingRewardedAd` export were also removed. ## v1.13.5 -* fix(terminal): stop proot "can't sanitize binding" fd warnings by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2878 -* fix(editor): preserve indentation on soft-wrapped lines by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2880 -* feat(editor): add context menu for closing file tabs by @TonyGeez in https://github.com/Acode-Foundation/Acode/pull/2863 -* perf(editor): index language modes instead of sorting on every lookup by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2881 -* feat: improve console virtualisation by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2882 -* fix(search): prevent discovery restarts and stream results efficiently by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2883 -* feat(editor): add configurable word wrap indentation by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2886 -* fix: API calls throwing internal server errors by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2888 -* fix(editor): add monaco-style punctuation wrap opportunities by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2890 +- fix(terminal): stop proot "can't sanitize binding" fd warnings by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2878 +- fix(editor): preserve indentation on soft-wrapped lines by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2880 +- feat(editor): add context menu for closing file tabs by @TonyGeez in https://github.com/Acode-Foundation/Acode/pull/2863 +- perf(editor): index language modes instead of sorting on every lookup by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2881 +- feat: improve console virtualisation by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2882 +- fix(search): prevent discovery restarts and stream results efficiently by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2883 +- feat(editor): add configurable word wrap indentation by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2886 +- fix: API calls throwing internal server errors by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2888 +- fix(editor): add monaco-style punctuation wrap opportunities by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2890 ## v1.13.4 -* fix: prevent native execution startup race by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2851 -* fix(editor): improve selection contrast on active lines by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2852 -* fix(editor): treat missing write capability as editable by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2853 -* fix: race condition when moving to exact line/col by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2856 -* Add GitHub Actions workflow for congratulating Community PRs by @UnschooledGamer in https://github.com/Acode-Foundation/Acode/pull/2855 -* Shortcut For Opening Welcome Tab by @Game-Dev-Shubham in https://github.com/Acode-Foundation/Acode/pull/2773 -* chore: Add Lingala (ln) translation by @Degrace15 in https://github.com/Acode-Foundation/Acode/pull/2775 -* feat: added icons and api by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2732 -* feat: httpStream api by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2841 -* fix: app icon picker and banner hide on reload by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2867 -* fix: settings category for app icon and theme by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2872 -* fix(devcontainer): update docker base image from bullseye to bookworm by @maaz7409 in https://github.com/Acode-Foundation/Acode/pull/2870 +- fix: prevent native execution startup race by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2851 +- fix(editor): improve selection contrast on active lines by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2852 +- fix(editor): treat missing write capability as editable by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2853 +- fix: race condition when moving to exact line/col by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2856 +- Add GitHub Actions workflow for congratulating Community PRs by @UnschooledGamer in https://github.com/Acode-Foundation/Acode/pull/2855 +- Shortcut For Opening Welcome Tab by @Game-Dev-Shubham in https://github.com/Acode-Foundation/Acode/pull/2773 +- chore: Add Lingala (ln) translation by @Degrace15 in https://github.com/Acode-Foundation/Acode/pull/2775 +- feat: added icons and api by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2732 +- feat: httpStream api by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2841 +- fix: app icon picker and banner hide on reload by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2867 +- fix: settings category for app icon and theme by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2872 +- fix(devcontainer): update docker base image from bullseye to bookworm by @maaz7409 in https://github.com/Acode-Foundation/Acode/pull/2870 ## v1.13.3 -* refactor(file-browser): Replace plain object directory cache with `Map` by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2831 -* fix(editor): stabilize selection menu sizing and transitions by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2833 -* fix(editor): keep fullscreen controls above bottom pane tabs by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2834 -* chore(community-release-notifier): Change sed parsing - TG release notes by @UnschooledGamer in https://github.com/Acode-Foundation/Acode/pull/2832 -* fix(editor): restore cursor state and prevent tab-switch flash by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2835 -* feat(lsp): improve actions, navigation, and position handling by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2837 -* fix(editor): highlight all visible search matches by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2838 -* Translation: Update hu-hu.json by @summoner001 in https://github.com/Acode-Foundation/Acode/pull/2828 -* chore(deps): bump actions/setup-java from 5 to 6 by @dependabot[bot] in https://github.com/Acode-Foundation/Acode/pull/2821 -* feat: improved pluginContext by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2806 -* fix(webview): retain instance when destroy fails by @azamkassim in https://github.com/Acode-Foundation/Acode/pull/2836 -* fix(sftp): recover from failed profile migration by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2840 +- refactor(file-browser): Replace plain object directory cache with `Map` by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2831 +- fix(editor): stabilize selection menu sizing and transitions by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2833 +- fix(editor): keep fullscreen controls above bottom pane tabs by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2834 +- chore(community-release-notifier): Change sed parsing - TG release notes by @UnschooledGamer in https://github.com/Acode-Foundation/Acode/pull/2832 +- fix(editor): restore cursor state and prevent tab-switch flash by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2835 +- feat(lsp): improve actions, navigation, and position handling by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2837 +- fix(editor): highlight all visible search matches by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2838 +- Translation: Update hu-hu.json by @summoner001 in https://github.com/Acode-Foundation/Acode/pull/2828 +- chore(deps): bump actions/setup-java from 5 to 6 by @dependabot[bot] in https://github.com/Acode-Foundation/Acode/pull/2821 +- feat: improved pluginContext by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2806 +- fix(webview): retain instance when destroy fails by @azamkassim in https://github.com/Acode-Foundation/Acode/pull/2836 +- fix(sftp): recover from failed profile migration by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2840 ## v1.13.2 -* feat: stabilize SFTP and add secure SSH terminal integration by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2694 -* fix(lsp): correct workspace and document color capabilities and add tailwind lsp by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2736 -* refactor: Standardize DOM element dataset attributes across file browser component by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2543 -* fix(lsp): preserve websocket clients across tab switches by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2764 -* feat(plugins): expose static CodeMirror highlighter by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2769 -* refactor(loader): Extract `tailSpin` SVG component and dynamic gradient logic by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2776 -* fix(quick-tools): prevent scrollbars during editor gestures by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2777 -* fix: fall back to internal storage when external storage is unavailable by @ulite-Amr in https://github.com/Acode-Foundation/Acode/pull/2781 -* fix(theme): prevent freeze when switching to system theme by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2790 -* fix(sftp): cancel stalled connections and prevent delayed errors by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2791 -* fix: admob issues by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2800 -* fix(android): avoid splash surface crash on realme Android 13 by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2805 -* fix(session): restore picker documents and skip intent files tab by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2809 -* feat(console): isolate execution and improve mobile REPL UX by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2808 -* feat(console): follow active Acode theme by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2814 -* chore: improve Indonesian (id) language translations by @MatrixTM26 in https://github.com/Acode-Foundation/Acode/pull/2798 -* fix: preserve MIME type for plugin icons on plugin details page by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2818 -* fix(console): run JavaScript files in isolated worker by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2819 -* feat: plugin review by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2826 -* Improve selection menu UX and plugin action overflow by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2813 -* fix(search): include restored files in global search by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2830 +- feat: stabilize SFTP and add secure SSH terminal integration by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2694 +- fix(lsp): correct workspace and document color capabilities and add tailwind lsp by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2736 +- refactor: Standardize DOM element dataset attributes across file browser component by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2543 +- fix(lsp): preserve websocket clients across tab switches by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2764 +- feat(plugins): expose static CodeMirror highlighter by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2769 +- refactor(loader): Extract `tailSpin` SVG component and dynamic gradient logic by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2776 +- fix(quick-tools): prevent scrollbars during editor gestures by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2777 +- fix: fall back to internal storage when external storage is unavailable by @ulite-Amr in https://github.com/Acode-Foundation/Acode/pull/2781 +- fix(theme): prevent freeze when switching to system theme by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2790 +- fix(sftp): cancel stalled connections and prevent delayed errors by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2791 +- fix: admob issues by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2800 +- fix(android): avoid splash surface crash on realme Android 13 by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2805 +- fix(session): restore picker documents and skip intent files tab by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2809 +- feat(console): isolate execution and improve mobile REPL UX by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2808 +- feat(console): follow active Acode theme by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2814 +- chore: improve Indonesian (id) language translations by @MatrixTM26 in https://github.com/Acode-Foundation/Acode/pull/2798 +- fix: preserve MIME type for plugin icons on plugin details page by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2818 +- fix(console): run JavaScript files in isolated worker by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2819 +- feat: plugin review by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2826 +- Improve selection menu UX and plugin action overflow by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2813 +- fix(search): include restored files in global search by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2830 ## v1.12.9 -* fix(admob): remove the policy-prohibited interstitial shown while exiting the app +- fix(admob): remove the policy-prohibited interstitial shown while exiting the app ## v1.12.8 -* fix(terminal): close tab on process end and speed up long-press select by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2587 -* fix(editor): prevent false language mode recommendations by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2621 -* fix(lsp): send workspace folders during initialization by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2623 -* fix(admob): harden consent, banners, and variant builds by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2553 -* feat(lsp): add multi-server support to CodeMirror LSP client by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2627 +- fix(terminal): close tab on process end and speed up long-press select by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2587 +- fix(editor): prevent false language mode recommendations by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2621 +- fix(lsp): send workspace folders during initialization by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2623 +- fix(admob): harden consent, banners, and variant builds by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2553 +- feat(lsp): add multi-server support to CodeMirror LSP client by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2627 ## v1.12.7 -* fix: scroll shift when tab switching by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2329 -* Fixes several small querks and inconsistencies to improve UI/UX by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2331 -* feat: add setting to toggle emmet by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2332 -* feat: add a ui to manage running Terminal (Executor) processes by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2333 -* fix(settings): preserve scroll state and avoid full rerenders by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2348 -* fix: removed annoying terminal dialog by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2349 -* Better regex by @Palloxin in https://github.com/Acode-Foundation/Acode/pull/2325 -* fix(lsp): hover tooltip code highlighting by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2353 -* fix(lsp): scope cache fallback by runtime provider by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2354 -* feat: dont invoke acode service when uninstalling terminal by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2350 -* fix: run new files even if marked saved by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2360 -* perf(settings): lazy load sub-settings pages to optimize load time by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2358 -* fix: ignore files to be treated as plugin in src/plugins by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2362 -* feat: add setting to toggle `language package completion` by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2361 -* feat(performance): removed double memory usage when reading/writing text files by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2359 -* feat: add language-mode plugin recommendation system by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2368 -* feat(keybind): add code folds keybinds by @UnschooledGamer in https://github.com/Acode-Foundation/Acode/pull/2369 -* fix(editor): apply plugin language modes after restore (for plugin modes) by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2375 -* fix: Use inline themed SVG for loader spinner by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2379 -* fix: wait for plugin load before recommendation trigger by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2383 -* fix: don't check for app updates from github when app is from playstore by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2385 -* feat: improved ux by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2382 -* fix: Fixes bug in settings UI by @claycuy in https://github.com/Acode-Foundation/Acode/pull/2388 -* feat: lazy load things which are low-risk from main by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2386 -* fix(quicktools): preserve editor focus during rapid taps and stale issue by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2408 -* feat: new 'SEL' Command for Quick Tools by @Elitex07 in https://github.com/Acode-Foundation/Acode/pull/2414 -* feat(ui): use motion for page, tab, switch and press gestures animation by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2406 -* refactor(core): centralize plugin unmount error boundary and fix console telemetry by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2422 -* fix: language mode mapping to add maps for paths which doesnt exists by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2430 -* fix(editor): preserve restored tab editability while loading by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2431 -* fix(quicktools): prevent editor blur when tapping toolbar immediately after typing by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2432 -* feat: add native app auth code login flow by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2440 -* feat: improve CodeMirror quick tools modifier support by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2435 -* fix(security) critical security issue by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2442 -* fix: skip recommendation for binary file by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2446 -* feat(editor): implement multi-pane split layout by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2416 -* fix: plugin page ui for big screen by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2448 -* fix(editor): prevent styling loss flash on custom page tabs when splitting/closing panes by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2449 -* feat(lsp): group language servers into built-in, plugin, and custom categories by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2452 -* refactor(ui): improved toast and notification animations using motion by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2453 -* feat: added native crash handler by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2450 -* feat: make the clear command behave as reset by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2458 -* feat: Add hover and long press tooltips to quicktools items by @gahanad in https://github.com/Acode-Foundation/Acode/pull/2456 -* fix: add missing autoclosebracket keymap(paired bracket deletion) by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2472 -* fix: implement editor tab history navigation (#1819) by @Elitex07 in https://github.com/Acode-Foundation/Acode/pull/2459 -* fix(lsp): refresh installation status on the correct settings page by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2482 -* fix(editor): sync replacement untitled file state by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2483 -* feat: add cobalt editor theme by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2484 -* fix: zip project import by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2473 -* chore: update the xtermjs to v6 and fix session creation by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2487 -* fix(editor): improve wrapped line indentation and keep text wrap off by default by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2507 -* fix(editor): prevent syntax highlight color flicker on state recreation (#2304) by @Elitex07 in https://github.com/Acode-Foundation/Acode/pull/2457 -* Make line commands aware of folded blocks by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2508 -* fix: move bashrc sourcing to bottom of initrc so bashrc can override … by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2523 -* fix(settings): sync global search switch behavior and animation by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2527 -* refactor(editor): centralize CodeMirror commands and keybindings by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2516 -* feat(lsp): add document color chips with regex fallback by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2533 -* feat(lsp): add pull diagnostics and native TypeScript 7 by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2537 -* feat(lsp): add web worker language servers as defaults by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2531 -* fix: system theme by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2524 -* feat(editor): add indentation folding for legacy modes(as fallback) by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2538 -* feat: add WebView Plugin API by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2525 -* feat(files): move workspace indexing and search to native for saf/files by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2529 -* fix: upgrade tar to 7.5.19 (CVE-2026-59873) by @anupamme in https://github.com/Acode-Foundation/Acode/pull/2544 -* fix(fileBrowser): exclude non-selectable system utility tiles from batch selection operations by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2545 -* refactor(file-browser): extract reusable deletion logic and abstract Termux URI validation by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2548 -* feat(file-browser): integrate selection mode state with `actionStack` for back navigation by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2546 -* feat(files): skip excluded paths during copy operations by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2555 -* fix: the processutils in ProcessUtils.java by @anupamme in https://github.com/Acode-Foundation/Acode/pull/2557 -* fix: sanitize input hints to prevent XSS by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2559 -* feat: proot debug toggle by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2563 -* Improve recent dialog path readability by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2567 -* Fix CodeMirror theme colors and add Catppuccin variants by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2568 -* feat(editor): add configurable horizontal scroll margin to CodeMirror by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2569 -* fix(quick-tools): add visible close button to search when toggler is off by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2570 -* i18n: update Hungarian translations by @summoner001 in https://github.com/Acode-Foundation/Acode/pull/2207, https://github.com/Acode-Foundation/Acode/pull/2387, https://github.com/Acode-Foundation/Acode/pull/2429, https://github.com/Acode-Foundation/Acode/pull/2478, https://github.com/Acode-Foundation/Acode/pull/2485, https://github.com/Acode-Foundation/Acode/pull/2542, https://github.com/Acode-Foundation/Acode/pull/2558 -* i18n: update Indonesian translations and localization strings by @claycuy in https://github.com/Acode-Foundation/Acode/pull/2330, https://github.com/Acode-Foundation/Acode/pull/2372, https://github.com/Acode-Foundation/Acode/pull/2417, https://github.com/Acode-Foundation/Acode/pull/2479 -* i18n: update Simplified and Traditional Chinese translations by @LaunchLee in https://github.com/Acode-Foundation/Acode/pull/2468, https://github.com/Acode-Foundation/Acode/pull/2571 -* i18n: update Yemeni Arabic translations by @mohamedElneser in https://github.com/Acode-Foundation/Acode/pull/2480 -* i18n: update Indonesian translations by @Elderellerser in https://github.com/Acode-Foundation/Acode/pull/2491 +- fix: scroll shift when tab switching by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2329 +- Fixes several small querks and inconsistencies to improve UI/UX by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2331 +- feat: add setting to toggle emmet by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2332 +- feat: add a ui to manage running Terminal (Executor) processes by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2333 +- fix(settings): preserve scroll state and avoid full rerenders by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2348 +- fix: removed annoying terminal dialog by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2349 +- Better regex by @Palloxin in https://github.com/Acode-Foundation/Acode/pull/2325 +- fix(lsp): hover tooltip code highlighting by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2353 +- fix(lsp): scope cache fallback by runtime provider by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2354 +- feat: dont invoke acode service when uninstalling terminal by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2350 +- fix: run new files even if marked saved by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2360 +- perf(settings): lazy load sub-settings pages to optimize load time by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2358 +- fix: ignore files to be treated as plugin in src/plugins by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2362 +- feat: add setting to toggle `language package completion` by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2361 +- feat(performance): removed double memory usage when reading/writing text files by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2359 +- feat: add language-mode plugin recommendation system by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2368 +- feat(keybind): add code folds keybinds by @UnschooledGamer in https://github.com/Acode-Foundation/Acode/pull/2369 +- fix(editor): apply plugin language modes after restore (for plugin modes) by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2375 +- fix: Use inline themed SVG for loader spinner by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2379 +- fix: wait for plugin load before recommendation trigger by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2383 +- fix: don't check for app updates from github when app is from playstore by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2385 +- feat: improved ux by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2382 +- fix: Fixes bug in settings UI by @claycuy in https://github.com/Acode-Foundation/Acode/pull/2388 +- feat: lazy load things which are low-risk from main by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2386 +- fix(quicktools): preserve editor focus during rapid taps and stale issue by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2408 +- feat: new 'SEL' Command for Quick Tools by @Elitex07 in https://github.com/Acode-Foundation/Acode/pull/2414 +- feat(ui): use motion for page, tab, switch and press gestures animation by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2406 +- refactor(core): centralize plugin unmount error boundary and fix console telemetry by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2422 +- fix: language mode mapping to add maps for paths which doesnt exists by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2430 +- fix(editor): preserve restored tab editability while loading by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2431 +- fix(quicktools): prevent editor blur when tapping toolbar immediately after typing by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2432 +- feat: add native app auth code login flow by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2440 +- feat: improve CodeMirror quick tools modifier support by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2435 +- fix(security) critical security issue by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2442 +- fix: skip recommendation for binary file by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2446 +- feat(editor): implement multi-pane split layout by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2416 +- fix: plugin page ui for big screen by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2448 +- fix(editor): prevent styling loss flash on custom page tabs when splitting/closing panes by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2449 +- feat(lsp): group language servers into built-in, plugin, and custom categories by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2452 +- refactor(ui): improved toast and notification animations using motion by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2453 +- feat: added native crash handler by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2450 +- feat: make the clear command behave as reset by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2458 +- feat: Add hover and long press tooltips to quicktools items by @gahanad in https://github.com/Acode-Foundation/Acode/pull/2456 +- fix: add missing autoclosebracket keymap(paired bracket deletion) by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2472 +- fix: implement editor tab history navigation (#1819) by @Elitex07 in https://github.com/Acode-Foundation/Acode/pull/2459 +- fix(lsp): refresh installation status on the correct settings page by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2482 +- fix(editor): sync replacement untitled file state by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2483 +- feat: add cobalt editor theme by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2484 +- fix: zip project import by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2473 +- chore: update the xtermjs to v6 and fix session creation by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2487 +- fix(editor): improve wrapped line indentation and keep text wrap off by default by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2507 +- fix(editor): prevent syntax highlight color flicker on state recreation (#2304) by @Elitex07 in https://github.com/Acode-Foundation/Acode/pull/2457 +- Make line commands aware of folded blocks by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2508 +- fix: move bashrc sourcing to bottom of initrc so bashrc can override … by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2523 +- fix(settings): sync global search switch behavior and animation by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2527 +- refactor(editor): centralize CodeMirror commands and keybindings by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2516 +- feat(lsp): add document color chips with regex fallback by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2533 +- feat(lsp): add pull diagnostics and native TypeScript 7 by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2537 +- feat(lsp): add web worker language servers as defaults by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2531 +- fix: system theme by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2524 +- feat(editor): add indentation folding for legacy modes(as fallback) by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2538 +- feat: add WebView Plugin API by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2525 +- feat(files): move workspace indexing and search to native for saf/files by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2529 +- fix: upgrade tar to 7.5.19 (CVE-2026-59873) by @anupamme in https://github.com/Acode-Foundation/Acode/pull/2544 +- fix(fileBrowser): exclude non-selectable system utility tiles from batch selection operations by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2545 +- refactor(file-browser): extract reusable deletion logic and abstract Termux URI validation by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2548 +- feat(file-browser): integrate selection mode state with `actionStack` for back navigation by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2546 +- feat(files): skip excluded paths during copy operations by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2555 +- fix: the processutils in ProcessUtils.java by @anupamme in https://github.com/Acode-Foundation/Acode/pull/2557 +- fix: sanitize input hints to prevent XSS by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2559 +- feat: proot debug toggle by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2563 +- Improve recent dialog path readability by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2567 +- Fix CodeMirror theme colors and add Catppuccin variants by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2568 +- feat(editor): add configurable horizontal scroll margin to CodeMirror by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2569 +- fix(quick-tools): add visible close button to search when toggler is off by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2570 +- i18n: update Hungarian translations by @summoner001 in https://github.com/Acode-Foundation/Acode/pull/2207, https://github.com/Acode-Foundation/Acode/pull/2387, https://github.com/Acode-Foundation/Acode/pull/2429, https://github.com/Acode-Foundation/Acode/pull/2478, https://github.com/Acode-Foundation/Acode/pull/2485, https://github.com/Acode-Foundation/Acode/pull/2542, https://github.com/Acode-Foundation/Acode/pull/2558 +- i18n: update Indonesian translations and localization strings by @claycuy in https://github.com/Acode-Foundation/Acode/pull/2330, https://github.com/Acode-Foundation/Acode/pull/2372, https://github.com/Acode-Foundation/Acode/pull/2417, https://github.com/Acode-Foundation/Acode/pull/2479 +- i18n: update Simplified and Traditional Chinese translations by @LaunchLee in https://github.com/Acode-Foundation/Acode/pull/2468, https://github.com/Acode-Foundation/Acode/pull/2571 +- i18n: update Yemeni Arabic translations by @mohamedElneser in https://github.com/Acode-Foundation/Acode/pull/2480 +- i18n: update Indonesian translations by @Elderellerser in https://github.com/Acode-Foundation/Acode/pull/2491 ## v1.12.6 -* Refactor boot script and add editor interaction handler by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2216 -* fix(touchSelectionMenu): prevent menu overlap with cm-tooltips by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2220 -* fix: suppressed startup auth related toast instead just log it by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2222 -* feat: add option to control scrollbar height by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2223 -* feat: add astro mode (with lezer parser and grammar) by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2224 -* fix: improve cursor and quicktoolbar by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2225 -* feat(editor): make scroll-past-end bottom margin configurable by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2226 -* feat: Improve binary file skipping in sidebar search by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2229 -* fix(editor): preserve selected theme after sidebar file moves by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2230 -* ux improvements by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2231 -* feat(terminal): add custom touch scrolling with momentum physics by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2232 -* feat(terminal): add terminal theme picker to Theme Settings page by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2234 -* fix(lsp): show dynamic install status label with loader feedback by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2235 -* i18n(id-id): update strings by @hyperz111 in https://github.com/Acode-Foundation/Acode/pull/2228 -* feat: Improve LSP server reuse check with bridge status endpoint by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2238 -* i18n(lang.js): Update Indonesian language name to Bahasa Indonesia by @claycuy in https://github.com/Acode-Foundation/Acode/pull/2236 -* feat(color-picker): add format dropdown, cancel button, and cancellat… by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2240 -* fix: pro detection by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2248 -* i18n(id): refine translations for a more natural and accurate phrasing by @claycuy in https://github.com/Acode-Foundation/Acode/pull/2239 -* refactor(lsp): decouple runtime execution from built-in Alpine & support custom runtime providers by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2241 -* feat: improve the indexing and search UI/UX and few fallbacks stuff by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2256 -* fix: version parsing failure on nightly tags by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2249 -* feat: added config proxy by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2246 -* fix: disable CodeMirror EditContext by default by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2258 -* fix(lsp): check Terminal installation before installing server for builtin Alpine by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2259 -* fix(sidebar): preserve state across orientation changes by @Elitex07 in https://github.com/Acode-Foundation/Acode/pull/2219 -* fix: make indent guide stable and close to vscode one by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2266 -* fix(editor): prevent cursor snap after scrollbar drag by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2263 -* feat(quickTools): replace checkbox with height select & dynamic toggler by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2278 -* chore(deps): bump markdown-it from 14.1.1 to 14.2.0 by @dependabot[bot] in https://github.com/Acode-Foundation/Acode/pull/2286 -* chore(deps): bump dompurify from 3.4.3 to 3.4.10 by @dependabot[bot] in https://github.com/Acode-Foundation/Acode/pull/2271 -* chote(i18n): update german translation by @Mythryl-dev in https://github.com/Acode-Foundation/Acode/pull/2293 -* feat: do file-listing and index on java for file:/// and saf locations by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2283 -* improve vscode editor theme -* add few more popular editor themes like nord, AyuDark, GruvboxDark, MaterialPalenight. -* enable jsx in js mode +- Refactor boot script and add editor interaction handler by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2216 +- fix(touchSelectionMenu): prevent menu overlap with cm-tooltips by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2220 +- fix: suppressed startup auth related toast instead just log it by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2222 +- feat: add option to control scrollbar height by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2223 +- feat: add astro mode (with lezer parser and grammar) by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2224 +- fix: improve cursor and quicktoolbar by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2225 +- feat(editor): make scroll-past-end bottom margin configurable by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2226 +- feat: Improve binary file skipping in sidebar search by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2229 +- fix(editor): preserve selected theme after sidebar file moves by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2230 +- ux improvements by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2231 +- feat(terminal): add custom touch scrolling with momentum physics by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2232 +- feat(terminal): add terminal theme picker to Theme Settings page by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2234 +- fix(lsp): show dynamic install status label with loader feedback by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2235 +- i18n(id-id): update strings by @hyperz111 in https://github.com/Acode-Foundation/Acode/pull/2228 +- feat: Improve LSP server reuse check with bridge status endpoint by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2238 +- i18n(lang.js): Update Indonesian language name to Bahasa Indonesia by @claycuy in https://github.com/Acode-Foundation/Acode/pull/2236 +- feat(color-picker): add format dropdown, cancel button, and cancellat… by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2240 +- fix: pro detection by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2248 +- i18n(id): refine translations for a more natural and accurate phrasing by @claycuy in https://github.com/Acode-Foundation/Acode/pull/2239 +- refactor(lsp): decouple runtime execution from built-in Alpine & support custom runtime providers by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2241 +- feat: improve the indexing and search UI/UX and few fallbacks stuff by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2256 +- fix: version parsing failure on nightly tags by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/2249 +- feat: added config proxy by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2246 +- fix: disable CodeMirror EditContext by default by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2258 +- fix(lsp): check Terminal installation before installing server for builtin Alpine by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2259 +- fix(sidebar): preserve state across orientation changes by @Elitex07 in https://github.com/Acode-Foundation/Acode/pull/2219 +- fix: make indent guide stable and close to vscode one by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2266 +- fix(editor): prevent cursor snap after scrollbar drag by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2263 +- feat(quickTools): replace checkbox with height select & dynamic toggler by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2278 +- chore(deps): bump markdown-it from 14.1.1 to 14.2.0 by @dependabot[bot] in https://github.com/Acode-Foundation/Acode/pull/2286 +- chore(deps): bump dompurify from 3.4.3 to 3.4.10 by @dependabot[bot] in https://github.com/Acode-Foundation/Acode/pull/2271 +- chote(i18n): update german translation by @Mythryl-dev in https://github.com/Acode-Foundation/Acode/pull/2293 +- feat: do file-listing and index on java for file:/// and saf locations by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2283 +- improve vscode editor theme +- add few more popular editor themes like nord, AyuDark, GruvboxDark, MaterialPalenight. +- enable jsx in js mode ## v1.12.5 -* fix: custom fonts by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2192 -* fix(editor): stabilize restored tab highlighting by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2193 -* feat(terminal): bundle everything into the apk by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2197 -* improve the lsp message and ace to codemirror related clarrification by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2203 -* fix(terminal): handle axs symlink runtime checks by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2204 -* fix(i18n): Improve Indonesian translation naturalness and fix missing entries by @claycuy in https://github.com/Acode-Foundation/Acode/pull/2190 -* fix(lsp): add dont ask again for missing terminal prompt by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2208 +- fix: custom fonts by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2192 +- fix(editor): stabilize restored tab highlighting by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2193 +- feat(terminal): bundle everything into the apk by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2197 +- improve the lsp message and ace to codemirror related clarrification by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2203 +- fix(terminal): handle axs symlink runtime checks by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2204 +- fix(i18n): Improve Indonesian translation naturalness and fix missing entries by @claycuy in https://github.com/Acode-Foundation/Acode/pull/2190 +- fix(lsp): add dont ask again for missing terminal prompt by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2208 ## v1.12.4 -* chore(i18n): update strings in hu_hu.json by @summoner001 in https://github.com/Acode-Foundation/Acode/pull/2171 -* fix: Executor arguments getting ignored by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2176 -* fix: allow subdomain of acode.app by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2179 -* fix: highlighting issue happening due to state reuse by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2180 -* i18n(id-id): update strings by @hyperz111 in https://github.com/Acode-Foundation/Acode/pull/2178 -* feat: polish welcome tab with dynamic shortcuts, dismiss tracking, an… by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2182 -* fix: revert customtabs for plugins by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2183 -* fix: error when terminating terminal + fixed build by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2184 +- chore(i18n): update strings in hu_hu.json by @summoner001 in https://github.com/Acode-Foundation/Acode/pull/2171 +- fix: Executor arguments getting ignored by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2176 +- fix: allow subdomain of acode.app by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2179 +- fix: highlighting issue happening due to state reuse by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2180 +- i18n(id-id): update strings by @hyperz111 in https://github.com/Acode-Foundation/Acode/pull/2178 +- feat: polish welcome tab with dynamic shortcuts, dismiss tracking, an… by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2182 +- fix: revert customtabs for plugins by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/2183 +- fix: error when terminating terminal + fixed build by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2184 ## v1.12.0 (970) ### Important -* important(editor): Acode has migrated from Ace to CodeMirror. This is a major editor engine change and some plugins that depend on Ace internals may need updates for full compatibility. + +- important(editor): Acode has migrated from Ace to CodeMirror. This is a major editor engine change and some plugins that depend on Ace internals may need updates for full compatibility. ### Features -* feat(file-browser): add Copy Relative Path context menu option by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1854 -* feat(plugin-api): add PluginContext by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1867 -* feat(ui): improve splash screen by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1888 -* feat(shortcuts): pin file shortcuts to the home screen by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1889 -* feat(plugin-api): expose `isCodeMirror` flag on editor manager by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1892 -* feat(plugin-api): add Ace compatibility shims for plugins by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1893 -* feat(codemirror): support `shift` + click selection by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/1899 -* feat(terminal): add touch selection More menu API and select dialog wiring by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1905 -* feat(settings): add sponsor sidebar icon visibility toggle by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1906 -* feat(plugin-api): add secrets plugin API by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1902 -* feat(ads): add rewarded ads so free users can earn ad-free time by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1918 -* feat(plugin-api): expose CodeMirror packages for plugins by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1924 -* feat(editor): add Luau mode by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1927 -* feat(themes): add premium themes and overhaul legacy themes by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1930 -* feat(settings): add swatch previews to theme settings by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1931 -* feat(settings): redesign settings UI and localize help text by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1933 -* feat(native): move `checksumText` to native by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1942 -* feat(plugins): limit plugin installation load by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1951 -* feat(executor): add spawn stream support by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1972 -* feat(codemirror): improve teardrop handles, scrolling, and selection quality by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1971 -* feat(tabs): add pin and unpin support for editor and non-editor tabs by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1984 -* feat(native): improve `launchApp` by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1987 -* feat(fonts): add target-based font assignments and app font option by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1994 -* feat(tabs): add close left, close right, and close other tab commands by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2026 -* feat(storage): add public directory and merge `/home` with `/public` by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2049 -* feat(editor): add setting to disable HTML tag auto closing by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2051 -* feat(editor): select line on CodeMirror line number gutter click by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2052 -* feat(settings): add editor and UI zoom commands by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2058 -* feat(commands): restore `formatCode` command in CodeMirror 6 by @UnschooledGamer in https://github.com/Acode-Foundation/Acode/pull/2063 + +- feat(file-browser): add Copy Relative Path context menu option by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1854 +- feat(plugin-api): add PluginContext by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1867 +- feat(ui): improve splash screen by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1888 +- feat(shortcuts): pin file shortcuts to the home screen by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1889 +- feat(plugin-api): expose `isCodeMirror` flag on editor manager by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1892 +- feat(plugin-api): add Ace compatibility shims for plugins by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1893 +- feat(codemirror): support `shift` + click selection by @AuDevTist1C in https://github.com/Acode-Foundation/Acode/pull/1899 +- feat(terminal): add touch selection More menu API and select dialog wiring by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1905 +- feat(settings): add sponsor sidebar icon visibility toggle by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1906 +- feat(plugin-api): add secrets plugin API by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1902 +- feat(ads): add rewarded ads so free users can earn ad-free time by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1918 +- feat(plugin-api): expose CodeMirror packages for plugins by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1924 +- feat(editor): add Luau mode by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1927 +- feat(themes): add premium themes and overhaul legacy themes by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1930 +- feat(settings): add swatch previews to theme settings by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1931 +- feat(settings): redesign settings UI and localize help text by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1933 +- feat(native): move `checksumText` to native by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1942 +- feat(plugins): limit plugin installation load by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1951 +- feat(executor): add spawn stream support by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1972 +- feat(codemirror): improve teardrop handles, scrolling, and selection quality by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1971 +- feat(tabs): add pin and unpin support for editor and non-editor tabs by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1984 +- feat(native): improve `launchApp` by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1987 +- feat(fonts): add target-based font assignments and app font option by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1994 +- feat(tabs): add close left, close right, and close other tab commands by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2026 +- feat(storage): add public directory and merge `/home` with `/public` by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/2049 +- feat(editor): add setting to disable HTML tag auto closing by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2051 +- feat(editor): select line on CodeMirror line number gutter click by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2052 +- feat(settings): add editor and UI zoom commands by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/2058 +- feat(commands): restore `formatCode` command in CodeMirror 6 by @UnschooledGamer in https://github.com/Acode-Foundation/Acode/pull/2063 ### Fixes -* fix(terminal): normalize `acode open` paths so folder name is not `.` by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1864 -* fix(plugin): prevent plugin `'); + fs.writeFileSync(dir + '/main.jsx', "import React from 'react'; import {createRoot} from 'react-dom/client'; import {Clock} from 'lucide-react'; createRoot(document.getElementById('root')).render(
vite-probe
);"); + const options = {cwd: dir, encoding: 'utf8', timeout: 180000}; + child.execFileSync('npm', ['install', '--no-audit', '--no-fund'], options); + const port = await freePort(); + server = child.spawn('npm', ['run', 'dev', '--', '--port', String(port), '--strictPort'], {cwd: dir, detached: true, env: {...process.env, NO_COLOR: '1'}}); + const record = data => { log = (log + data).slice(-8000); }; + server.stdout.on('data', record); + server.stderr.on('data', record); + const url = 'http://127.0.0.1:' + port + '/'; + const page = await waitForServer(url, Date.now() + 120000); + assert.match(page, /@vite\/client/); + const module = await fetch(url + 'main.jsx'); + assert.equal(module.status, 200); + assert.match(await module.text(), /vite-probe/); + child.execFileSync('npm', ['run', 'build'], options); + assert.match(fs.readFileSync(dir + '/dist/index.html', 'utf8'), /assets\//); + console.log('VITE_REACT_PASS'); + })().catch(error => { console.error(error, log); process.exitCode = 1; }).finally(() => { + if (server?.pid) { try { process.kill(-server.pid, 'SIGTERM'); } catch {} } + fs.rmSync(dir, {recursive: true, force: true}); + }); + + function freePort() { + return new Promise((resolve, reject) => { + const probe = net.createServer().once('error', reject); + probe.listen(0, '127.0.0.1', () => { + const {port} = probe.address(); + probe.close(() => resolve(port)); + }); + }); + } + + async function waitForServer(url, deadline) { + for (;;) { + const remaining = deadline - Date.now(); + assert(remaining > 0, 'Vite did not start: ' + log); + assert.equal(server.exitCode, null, 'Vite exited: ' + log); + try { + const response = await fetch(url, {signal: AbortSignal.timeout(Math.min(10000, remaining))}); + if (response.status === 200) { + const page = await response.text(); + if (Date.now() < deadline) return page; + } + await response.body?.cancel(); + } catch {} + assert(Date.now() < deadline, 'Vite did not start: ' + log); + await new Promise(resolve => setTimeout(resolve, Math.min(500, deadline - Date.now()))); + } + } + """#) + XCTAssertEqual(result, "VITE_REACT_PASS") + } + + func testWebAssemblyWorkersAndLoopbackFetch() async throws { + let result = try await runNode("acode-node-runtime-probe.js", #""" + const assert = require('node:assert/strict'); + const http = require('node:http'); + const { MessageChannel, Worker } = require('node:worker_threads'); + (async () => { + const interfaces = Object.values(require('node:os').networkInterfaces()).flat(); + assert(interfaces.some(address => address.internal && address.address === '127.0.0.1' && address.netmask === '255.0.0.0')); + const bytes = Uint8Array.from([0,97,115,109,1,0,0,0,1,7,1,96,2,127,127,1,127,3,2,1,0,7,7,1,3,97,100,100,0,0,10,9,1,7,0,32,0,32,1,106,11]); + const { instance } = await WebAssembly.instantiate(bytes); + assert.equal(instance.exports.add(19, 23), 42); + console.log('WASM_PASS'); + const { port1, port2 } = new MessageChannel(); + await new Promise(resolve => { + port1.addEventListener('message', event => { + assert.equal(event.data, 42); + port1.close(); port2.close(); resolve(); + }, {once: true}); + port1.start(); port2.postMessage(42); + }); + const worker = new Worker("require('node:worker_threads').parentPort.postMessage(typeof WebAssembly + ':' + 6 * 7)", {eval: true}); + const [message] = await require('node:events').once(worker, 'message'); + assert.equal(message, 'object:42'); + await worker.terminate(); + console.log('WORKER_PASS'); + const server = http.createServer((req, res) => res.end('loopback π')); + await new Promise(resolve => server.listen(0, '127.0.0.1', resolve)); + try { + const response = await fetch('http://127.0.0.1:' + server.address().port); + assert.equal(await response.text(), 'loopback π'); + } finally { server.closeAllConnections(); server.close(); } + console.log('FETCH_PASS'); + })().catch(error => { console.error(error); process.exitCode = 1; }); + """#) + XCTAssertEqual(result, "WASM_PASS\nWORKER_PASS\nFETCH_PASS") + } + + func testNodeNamedDeviceFailsWithoutScanning() async throws { + let webView = try await editorWebView() + let result = try await webView.callAsyncJavaScript(#""" + if (!await Terminal.isInstalled() && !await Terminal.install()) throw new Error(Terminal.lastInstallError); + return await Executor.execute(`dir=$(mktemp -d /tmp/acode-node-device.XXXXXX) + ln -s /dev/zero "$dir/node" + "$dir/node" 2>/dev/null + status=$? + rm -rf "$dir" + printf "exit=%s" "$status"`, true); + """#, arguments: [:], in: nil, contentWorld: .page) as? String + XCTAssertEqual(result, "exit=126") + } + + private func runNode(_ name: String, _ code: String) async throws -> String? { + let webView = try await editorWebView() + return try await webView.callAsyncJavaScript(#""" + if (!await Terminal.isInstalled() && !await Terminal.install()) throw new Error(Terminal.lastInstallError); + if (!await Executor.execute('command -v npm || true', true)) await Executor.execute('apk add --no-cache nodejs npm', true); + const fs = acode.require('fs'); + const path = 'alpine://localhost/tmp/' + name; + if (await fs(path).exists()) await fs(path).delete(); + await fs('alpine://localhost/tmp').createFile(name, code); + try { + return await Executor.execute('node /tmp/' + name, true); + } finally { + await fs(path).delete(); + } + """#, arguments: ["name": name, "code": code], in: nil, contentWorld: .page) as? String + } +} diff --git a/platforms/ios/runnerTests/AlpinePackageTests.swift b/platforms/ios/runnerTests/AlpinePackageTests.swift index 518d6a7fce..d20ba36442 100644 --- a/platforms/ios/runnerTests/AlpinePackageTests.swift +++ b/platforms/ios/runnerTests/AlpinePackageTests.swift @@ -77,7 +77,7 @@ final class AlpinePackageTests: BridgeTestCase { const child = require('node:child_process'); const startup = child.spawnSync(process.execPath, ['-e', 'process.stdout.write(typeof WebAssembly)'], {encoding:'utf8'}); assert.equal(startup.status, 0); - assert.equal(startup.stdout, 'undefined'); + assert.equal(startup.stdout, 'object'); assert.equal(startup.stderr, ''); assert.equal(1 + 2, 3); fs.writeFileSync('/tmp/acode-node-utf8', 'hello π'); diff --git a/platforms/ios/runnerTests/AuthenticationTests.swift b/platforms/ios/runnerTests/AuthenticationTests.swift index 3ee015d858..fea057b070 100644 --- a/platforms/ios/runnerTests/AuthenticationTests.swift +++ b/platforms/ios/runnerTests/AuthenticationTests.swift @@ -29,7 +29,8 @@ final class AuthenticationTests: XCTestCase { let url = try auth.begin(baseURL: origin, version: 1011) let items = try XCTUnwrap(URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems) let values = Dictionary(uniqueKeysWithValues: items.map { ($0.name, $0.value!) }) - XCTAssertEqual(url.host, URL(string: origin)?.host) + XCTAssertEqual(url.host, "acode.app") + XCTAssertEqual(try AppAuthentication.accountURL(baseURL: origin).absoluteString, "https://acode.app/profile/edit?src=ios") XCTAssertEqual(url.path, "/login") XCTAssertEqual(values["authFlow"], "app-code") XCTAssertEqual(values["redirect"], "app") @@ -39,7 +40,7 @@ final class AuthenticationTests: XCTestCase { let callback = URL(string: "acode://auth/callback?state=\(values["state"]!)&code=test-code")! let request = try auth.consume(callback) let payload = try XCTUnwrap(JSONSerialization.jsonObject(with: request.httpBody!) as? [String: String]) - XCTAssertEqual(request.url?.absoluteString, origin + "/api/user/app-token/exchange") + XCTAssertEqual(request.url?.absoluteString, AppAuthentication.origin + "/api/user/app-token/exchange") XCTAssertEqual(request.httpMethod, "POST") XCTAssertEqual(payload["code"], "test-code") XCTAssertEqual(payload["state"], values["state"]) @@ -51,6 +52,16 @@ final class AuthenticationTests: XCTestCase { } } + func testLegacyDevelopmentExchangeCannotReplaceTheSharedAccount() throws { + try auth.save("production-token") + let pending = try JSONSerialization.data(withJSONObject: ["state": "fixture-state", "verifier": "fixture-verifier", "origin": "https://dev.acode.app"]) + try auth.secrets.set("pending_login", value: String(decoding: pending, as: UTF8.self)) + let callback = URL(string: "acode://auth/callback?state=fixture-state&code=development-code")! + XCTAssertThrowsError(try auth.consume(callback)) + XCTAssertEqual(try auth.token(for: URL(string: AppAuthentication.origin)!), "production-token") + XCTAssertNoThrow(try auth.begin(baseURL: "https://dev.acode.app", version: 1)) + } + func testRejectsForgedCallbacksUntrustedOriginsAndInvalidCookieTokens() throws { for value in ["http://acode.app", "https://acode.app.evil.test", "https://acode.app:8443", "https://user@acode.app", "https://acode.app/path", "http://dev.acode.app", "https://dev.acode.app.evil.test", "https://dev.acode.app:8443", "https://dev.acode.app?next=other"] { XCTAssertThrowsError(try auth.begin(baseURL: value, version: 1)) @@ -69,30 +80,31 @@ final class AuthenticationTests: XCTestCase { } @MainActor - func testAPIRoutingKeepsDevelopmentAndProductionCredentialsSeparate() async throws { + func testAPIRoutingSharesTheAccountAcrossAccountHosts() async throws { let production = URL(string: "https://acode.app")! let development = URL(string: "https://dev.acode.app")! - let previous = (HTTPCookieStorage.shared.cookies ?? []).filter { $0.name == "token" && AppAuthentication.hosts.contains($0.domain.trimmingCharacters(in: CharacterSet(charactersIn: "."))) } + let previous = (HTTPCookieStorage.shared.cookies ?? []).filter { $0.name == "token" && AppAuthentication.accountHosts.contains($0.domain.trimmingCharacters(in: CharacterSet(charactersIn: "."))) } let unrelated = HTTPCookie(properties: [.name: "review-fixture-" + UUID().uuidString, .value: "other", .domain: "acode.app", .path: "/"])! HTTPCookieStorage.shared.setCookie(unrelated) defer { HTTPCookieStorage.shared.deleteCookie(unrelated) - for cookie in HTTPCookieStorage.shared.cookies ?? [] where cookie.name == "token" && AppAuthentication.hosts.contains(cookie.domain.trimmingCharacters(in: CharacterSet(charactersIn: "."))) { + for cookie in HTTPCookieStorage.shared.cookies ?? [] where cookie.name == "token" && AppAuthentication.accountHosts.contains(cookie.domain.trimmingCharacters(in: CharacterSet(charactersIn: "."))) { HTTPCookieStorage.shared.deleteCookie(cookie) } previous.forEach(HTTPCookieStorage.shared.setCookie) } try auth.save("production-token") - try auth.save("development-token", for: development) + XCTAssertThrowsError(try auth.save("development-token", for: development)) + XCTAssertEqual(try auth.token(for: production), "production-token") let dataStore = WKWebsiteDataStore.nonPersistent() try await auth.synchronizeCookies(dataStore.httpCookieStore) let webCookies = await dataStore.httpCookieStore.allCookies().filter { $0.name == "token" } - XCTAssertEqual(Set(webCookies.map(\.domain)), Set(AppAuthentication.hosts)) + XCTAssertEqual(Set(webCookies.map(\.domain)), Set(AppAuthentication.accountHosts)) let api = AppAPIHandler(auth: auth) var source = URLRequest(url: URL(string: "acode://localhost/__api__/login?test=one%20two")!) source.setValue("include", forHTTPHeaderField: "X-Acode-Credentials") source.setValue("token=untrusted", forHTTPHeaderField: "Cookie") - for (origin, token) in [(production, "production-token"), (development, "development-token")] { + for (origin, token) in [(production, "production-token"), (development, "production-token")] { XCTAssertEqual((HTTPCookieStorage.shared.cookies(for: origin) ?? []).filter { $0.name == "token" }.map(\.value), [token]) source.setValue(origin.absoluteString, forHTTPHeaderField: "X-Acode-API-Origin") let request = try api.request(for: source) @@ -113,6 +125,50 @@ final class AuthenticationTests: XCTestCase { XCTAssertEqual(try auth.token(for: development), "") } + func testAPIOriginsMatchSharedJavaScriptCases() throws { + let fixture = try XCTUnwrap(Bundle(for: Self.self).url(forResource: "AcodeAPIOrigins", withExtension: "json")) + let cases = try JSONDecoder().decode([APIOriginCase].self, from: Data(contentsOf: fixture)) + for item in cases { + if item.accepted { XCTAssertNoThrow(try AppAuthentication.apiOrigin(item.origin), item.origin) } + else { XCTAssertThrowsError(try AppAuthentication.apiOrigin(item.origin), item.origin) } + } + } + + func testSubdomainsShareTheAccountWithoutBecomingSignInHosts() throws { + let api = AppAPIHandler(auth: auth) + var source = URLRequest(url: URL(string: "acode://localhost/__api__/v1/user/login")!) + source.setValue("include", forHTTPHeaderField: "X-Acode-Credentials") + try auth.save("account-token") + // Ignore tokens left by older builds that kept a separate dev account. + try auth.secrets.set("auth_token_dev", value: "legacy-development-token") + for host in ["acode.app", "dev.acode.app", "academy.acode.app", "service.acode.app", "nested.service.acode.app"] { + let origin = URL(string: "https://" + host)! + XCTAssertEqual(try auth.token(for: origin), "account-token") + source.setValue(origin.absoluteString, forHTTPHeaderField: "X-Acode-API-Origin") + let request = try api.request(for: source) + XCTAssertEqual(request.url?.absoluteString, origin.absoluteString + "/api/v1/user/login") + let tokens = (request.value(forHTTPHeaderField: "Cookie") ?? "").components(separatedBy: ";").map { $0.trimmingCharacters(in: .whitespaces) }.filter { $0.hasPrefix("token=") } + XCTAssertEqual(tokens, ["token=account-token"]) + if host != "acode.app" { + XCTAssertThrowsError(try auth.save("other-token", for: origin)) + } + if !AppAuthentication.accountHosts.contains(host) { + XCTAssertThrowsError(try auth.begin(baseURL: origin.absoluteString, version: 0)) + } + } + source.setValue("omit", forHTTPHeaderField: "X-Acode-Credentials") + XCTAssertNil(try api.request(for: source).value(forHTTPHeaderField: "Cookie")) + for value in ["https://.acode.app", "https://service..acode.app", "https://evilacode.app", "https://service.acode.app.evil.test", "http://service.acode.app", "https://service.acode.app:8443", "https://user:pass@service.acode.app", "https://service.acode.app/path", "https://service.acode.app?host=other"] { + source.setValue(value, forHTTPHeaderField: "X-Acode-API-Origin") + XCTAssertThrowsError(try api.request(for: source)) + } + try auth.secrets.remove("auth_token") + XCTAssertEqual(try auth.token(for: URL(string: "https://dev.acode.app")!), "", "A legacy dev token is not silently promoted to the shared account") + try auth.logout() + XCTAssertEqual(try auth.token(for: URL(string: "https://service.acode.app")!), "") + XCTAssertEqual(try auth.secrets.get("auth_token_dev"), "") + } + func testExchangeErrorsExplainRetryTimingAndExpiredSignIn() { let url = URL(string: "https://dev.acode.app/api/user/app-token/exchange")! let limited = HTTPURLResponse(url: url, statusCode: 429, httpVersion: nil, headerFields: ["Retry-After": "61"])! @@ -128,10 +184,10 @@ final class AuthenticationTests: XCTestCase { HTTPCookieStorage.shared.deleteCookie(cookie) } } - for host in AppAuthentication.hosts { + for host in AppAuthentication.accountHosts { let origin = URL(string: "https://" + host)! let url = origin.appendingPathComponent("api/cookie") - try auth.save("account-token", for: origin) + try auth.save("account-token") var source = URLRequest(url: URL(string: "acode://localhost/__api__/cookie")!) source.setValue(origin.absoluteString, forHTTPHeaderField: "X-Acode-API-Origin") source.setValue("include", forHTTPHeaderField: "X-Acode-Credentials") @@ -166,4 +222,33 @@ final class AuthenticationTests: XCTestCase { AppAPIHandler.storeCookies(from: response, credentials: true) XCTAssertFalse((HTTPCookieStorage.shared.cookies ?? []).contains { $0.name == name }) } + + func testAccountServicesOnlyStoreTheirOwnCookies() throws { + let name = "academy-fixture-" + UUID().uuidString + defer { + for cookie in HTTPCookieStorage.shared.cookies ?? [] where cookie.name == name { + HTTPCookieStorage.shared.deleteCookie(cookie) + } + } + let academy = URL(string: "https://NESTED.Service.ACODE.APP/api/cookie")! + let parent = HTTPURLResponse(url: academy, statusCode: 200, httpVersion: nil, headerFields: ["Set-Cookie": "\(name)=parent; Domain=.acode.app; Path=/; Secure"])! + AppAPIHandler.storeCookies(from: parent, credentials: true) + XCTAssertFalse((HTTPCookieStorage.shared.cookies ?? []).contains { $0.name == name }) + let own = HTTPURLResponse(url: academy, statusCode: 200, httpVersion: nil, headerFields: ["Set-Cookie": "\(name)=own; Path=/; Secure"])! + AppAPIHandler.storeCookies(from: own, credentials: true) + XCTAssertEqual((HTTPCookieStorage.shared.cookies(for: academy) ?? []).first { $0.name == name }?.value, "own") + XCTAssertFalse((HTTPCookieStorage.shared.cookies(for: URL(string: "https://acode.app/api/cookie")!) ?? []).contains { $0.name == name }) + XCTAssertTrue(AppAuthentication.acceptsCookie(for: "acode.app", from: "dev.acode.app")) + XCTAssertTrue(AppAuthentication.acceptsCookie(for: "AcOdE.App", from: "DEV.ACODE.APP")) + XCTAssertTrue(AppAuthentication.acceptsCookie(for: "nested.service.acode.app", from: "NESTED.Service.ACODE.APP")) + XCTAssertEqual(try AppAuthentication.apiOrigin("https://SERVICE.ACODE.APP"), URL(string: "https://service.acode.app")) + XCTAssertFalse(AppAuthentication.acceptsCookie(for: "acode.app", from: "nested.service.acode.app")) + XCTAssertFalse(AppAuthentication.acceptsCookie(for: "service.acode.app", from: "nested.service.acode.app")) + XCTAssertFalse(AppAuthentication.acceptsCookie(for: "other.acode.app", from: "nested.service.acode.app")) + } +} + +private struct APIOriginCase: Decodable { + let origin: String + let accepted: Bool } diff --git a/platforms/ios/runnerTests/HTTPFixture.swift b/platforms/ios/runnerTests/HTTPFixture.swift index 94c30d14d0..9d7133522e 100644 --- a/platforms/ios/runnerTests/HTTPFixture.swift +++ b/platforms/ios/runnerTests/HTTPFixture.swift @@ -118,9 +118,13 @@ final class HTTPFixture: @unchecked Sendable { }; """.utf8) case "/download": headers += "Content-Disposition: attachment; filename=\"\(downloadName)\"\r\n" - case "/cached-preview": - headers = "Content-Type: text/html; charset=utf-8\r\nCache-Control: max-age=3600\r\n" - data = Data("Cached fixture \(UUID().uuidString)".utf8) + case "/cached-script-page": + headers = "Content-Type: text/html; charset=utf-8\r\nCache-Control: no-store\r\n" + data = Data("Cached script fixture".utf8) + case "/cached-script": + headers = "Content-Type: text/javascript; charset=utf-8\r\nCache-Control: max-age=3600\r\nETag: \"fixture\"\r\n" + if head.components(separatedBy: "\r\n").contains(where: { $0.lowercased().hasPrefix("if-none-match:") }) { status = "304 Not Modified"; data = Data() } + else { data = Data("window.fixtureScriptVersion='\(UUID().uuidString)';".utf8) } case "/page": headers = "Content-Type: text/html; charset=utf-8\r\n"; data = Data("HTTP fixture

Page ✓

".utf8) case "/echo": data = body case "/redirect": status = "302 Found"; headers += "Location: /bytes\r\n"; data = Data() @@ -133,7 +137,8 @@ final class HTTPFixture: @unchecked Sendable { case "/stream": data = Data((0..<524288).map { UInt8($0 % 256) }) default: break } - let packet = Data("HTTP/1.1 \(status)\r\n\(headers)Content-Length: \(data.count)\r\nConnection: close\r\n\r\n".utf8) + data + let length = status.hasPrefix("304") ? "" : "Content-Length: \(data.count)\r\n" + let packet = Data("HTTP/1.1 \(status)\r\n\(headers)\(length)Connection: close\r\n\r\n".utf8) + data let send = { connection.send(content: packet, completion: .contentProcessed { _ in connection.cancel() }) } if path == "/slow" { queue.asyncAfter(deadline: .now() + 2, execute: send) } else { send() } diff --git a/platforms/ios/runnerTests/Iap.storekit b/platforms/ios/runnerTests/Iap.storekit index 1e52f516f9..258a710619 100644 --- a/platforms/ios/runnerTests/Iap.storekit +++ b/platforms/ios/runnerTests/Iap.storekit @@ -46,6 +46,96 @@ "productID": "ios_test_tip", "referenceName": "Tip test", "type": "Consumable" + }, + { + "displayPrice": "0.99", + "familyShareable": false, + "internalID": "200", + "localizations": [ + { + "description": "30 days of sponsorship (local test only)", + "displayName": "Crystal", + "locale": "en_US" + } + ], + "productID": "crystal", + "referenceName": "Crystal sponsor test", + "type": "Consumable" + }, + { + "displayPrice": "1.99", + "familyShareable": false, + "internalID": "201", + "localizations": [ + { + "description": "30 days of sponsorship (local test only)", + "displayName": "Bronze", + "locale": "en_US" + } + ], + "productID": "bronze", + "referenceName": "Bronze sponsor test", + "type": "Consumable" + }, + { + "displayPrice": "4.99", + "familyShareable": false, + "internalID": "202", + "localizations": [ + { + "description": "30 days of sponsorship (local test only)", + "displayName": "Silver", + "locale": "en_US" + } + ], + "productID": "silver", + "referenceName": "Silver sponsor test", + "type": "Consumable" + }, + { + "displayPrice": "9.99", + "familyShareable": false, + "internalID": "203", + "localizations": [ + { + "description": "30 days of sponsorship (local test only)", + "displayName": "Gold", + "locale": "en_US" + } + ], + "productID": "gold", + "referenceName": "Gold sponsor test", + "type": "Consumable" + }, + { + "displayPrice": "19.99", + "familyShareable": false, + "internalID": "204", + "localizations": [ + { + "description": "30 days of sponsorship (local test only)", + "displayName": "Platinum", + "locale": "en_US" + } + ], + "productID": "platinum", + "referenceName": "Platinum sponsor test", + "type": "Consumable" + }, + { + "displayPrice": "49.99", + "familyShareable": false, + "internalID": "205", + "localizations": [ + { + "description": "30 days of sponsorship (local test only)", + "displayName": "Titanium", + "locale": "en_US" + } + ], + "productID": "titanium", + "referenceName": "Titanium sponsor test", + "type": "Consumable" } ], "settings": { diff --git a/platforms/ios/runnerTests/PlatformUITests.swift b/platforms/ios/runnerTests/PlatformUITests.swift index 11e424522a..d396c62422 100644 --- a/platforms/ios/runnerTests/PlatformUITests.swift +++ b/platforms/ios/runnerTests/PlatformUITests.swift @@ -4,6 +4,40 @@ import WebKit @MainActor final class PlatformUITests: BridgeTestCase { + func testMultiPromptTextareaValidationValuesAndDismissal() async throws { + let webView = try await editorWebView() + let result = try await webView.callAsyncJavaScript(#""" + const stack=acode.require('actionStack'); + const initialDepth=stack.length; + const results=[]; + for(const method of ['click','submit','cancel','back','clear']) { + stack.setMark(); + let settled=false; + const pending=acode.multiPrompt('Textarea regression', [{id:'note',type:'textarea',required:true,sensitive:true,autofocus:true}]).then(value=>{settled=true;return value},()=>{settled=true;return null}); + const form=document.querySelector('.prompt.multi:not(.hide)'); + const field=form.querySelector('textarea'); + if(document.activeElement!==field)throw Error('Textarea did not receive focus'); + const submit=()=>method==='click'?form.querySelector('button[type=submit]').click():form.dispatchEvent(new Event('submit',{bubbles:true,cancelable:true})); + submit(); + await Promise.resolve(); + if(settled||!form.querySelector('.error-msg')?.textContent||form.classList.contains('hide'))throw Error('Required textarea accepted empty input'); + field.value='Private\ntext'; + if(method==='click'||method==='submit')submit(); + else if(method==='cancel')form.querySelector('button[type=button]').click(); + else if(method==='back')await stack.pop(); + else stack.clearFromMark(); + const value=await Promise.race([pending,new Promise((resolve,reject)=>setTimeout(()=>reject(Error('Unsettled '+method)),2000))]); + if((method==='click'||method==='submit')&&value?.note!=='Private\ntext')throw Error('Textarea value was lost'); + if(field.value!==''||stack.length!==initialDepth)throw Error('Dialog cleanup failed: '+method); + results.push(method); + stack.clearFromMark(); + await new Promise(resolve=>setTimeout(resolve,350)); + } + return results; + """#, arguments: [:], in: nil, contentWorld: .page) as? [String] + XCTAssertEqual(result, ["click", "submit", "cancel", "back", "clear"]) + } + func testCoveredEditorReturnsWithItsDocumentAndScrollPosition() async throws { let webView = try await editorWebView() let result = try await webView.callAsyncJavaScript(""" diff --git a/platforms/ios/runnerTests/PreviewBrowserTests.swift b/platforms/ios/runnerTests/PreviewBrowserTests.swift index 5c60eded92..b299438f0d 100644 --- a/platforms/ios/runnerTests/PreviewBrowserTests.swift +++ b/platforms/ios/runnerTests/PreviewBrowserTests.swift @@ -4,6 +4,16 @@ import WebKit @MainActor final class PreviewBrowserTests: BridgeTestCase { + func testTerminalPreviewsUseSeparateEphemeralStorage() throws { + let url = try XCTUnwrap(URL(string: "http://localhost:3000")) + let first = PreviewViewController(url: url, theme: [:], console: false, ephemeral: true) + let second = PreviewViewController(url: url, theme: [:], console: false, ephemeral: true) + let regular = PreviewViewController(url: url, theme: [:], console: false) + XCTAssertFalse(first.webView.configuration.websiteDataStore.isPersistent) + XCTAssertFalse(first.webView.configuration.websiteDataStore === second.webView.configuration.websiteDataStore) + XCTAssertTrue(regular.webView.configuration.websiteDataStore.isPersistent) + } + func testConsoleFocusKeepsScaleAndFitsAboveKeyboard() async throws { let app = try await editorWebView() var responder: UIResponder? = app diff --git a/platforms/ios/runnerTests/PreviewTransferTests.swift b/platforms/ios/runnerTests/PreviewTransferTests.swift index 0838159e52..6ccb80f319 100644 --- a/platforms/ios/runnerTests/PreviewTransferTests.swift +++ b/platforms/ios/runnerTests/PreviewTransferTests.swift @@ -46,33 +46,38 @@ final class PreviewTransferTests: BridgeTestCase { let server = try HTTPFixture() try await server.start() defer { server.stop() } - let browser = try await presentBrowser(server.origin + "/page") - let first = try await browser.webView.callAsyncJavaScript(""" - const read=()=>fetch('/cached-preview').then(response=>response.text()); - return [await read(), await read()]; - """, arguments: [:], in: nil, contentWorld: .page) as? [String] - let cached = try XCTUnwrap(first) - XCTAssertEqual(cached.count, 2) - XCTAssertEqual(cached.first, cached.last) - let refreshedPage = expectation(description: "Cache-disabled navigation finished") - browser.onPageFinished = { refreshedPage.fulfill() } + let store = WKWebsiteDataStore(forIdentifier: UUID()) + addTeardownBlock { @MainActor in + await store.removeData(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes(), modifiedSince: .distantPast) + } + let url = server.origin + "/cached-script-page" + let browser = try await presentBrowser(url, dataStore: store) + _ = try await browser.webView.evaluateJavaScript("document.cookie='previewSession=keep; path=/'; localStorage.setItem('previewDraft', 'keep')") + let cached = try await scriptVersion(browser) + try await finishNavigation(browser) { browser.load(try XCTUnwrap(URL(string: url))) } + let reused = try await scriptVersion(browser) + XCTAssertEqual(reused, cached, "Navigating again must reuse the cached script") + try await finishNavigation(browser) { browser.refresh() } + let revalidated = try await scriptVersion(browser) + XCTAssertEqual(revalidated, cached, "A normal refresh must revalidate the cached script") + // iOS 18 WebKit can keep serving a just-cached response after removeData, so assert the + // origin reload that bypasses every cache layer rather than eviction timing. browser.disableCache = true - browser.refresh() - await fulfillment(of: [refreshedPage], timeout: 5) - browser.onPageFinished = nil - let refreshed = try await browser.webView.callAsyncJavaScript("return await fetch('/cached-preview').then(response=>response.text())", arguments: [:], in: nil, contentWorld: .page) as? String - XCTAssertNotNil(refreshed) - XCTAssertNotEqual(refreshed, cached.first) + try await finishNavigation(browser) { browser.refresh() } + let refreshed = try await scriptVersion(browser) + XCTAssertNotEqual(refreshed, cached, "Cache-disabled refresh must fetch the script from the server") + let preserved = try await browser.webView.evaluateJavaScript("document.cookie.includes('previewSession=keep') && localStorage.getItem('previewDraft') === 'keep'") as? Bool + XCTAssertEqual(preserved, true, "Disabling cache must preserve the preview's session and stored data") await close(browser) } - private func presentBrowser(_ origin: String) async throws -> PreviewViewController { + private func presentBrowser(_ origin: String, dataStore: WKWebsiteDataStore? = nil) async throws -> PreviewViewController { let webView = try await editorWebView() var responder: UIResponder? = webView while responder != nil, !(responder is WebViewController) { responder = responder?.next } let host = try XCTUnwrap(responder as? WebViewController) XCTAssertNil(host.presentedViewController) - let browser = PreviewViewController(url: try XCTUnwrap(URL(string: origin)), theme: [:], console: false) + let browser = PreviewViewController(url: try XCTUnwrap(URL(string: origin)), theme: [:], console: false, dataStore: dataStore) browser.consoleEnabled = false let loaded = expectation(description: "Initial preview navigation finished") browser.onPageFinished = { loaded.fulfill() } @@ -85,6 +90,19 @@ final class PreviewTransferTests: BridgeTestCase { return browser } + private func finishNavigation(_ browser: PreviewViewController, _ navigate: () throws -> Void) async throws { + let finished = expectation(description: "Preview navigation finished") + browser.onPageFinished = { finished.fulfill() } + defer { browser.onPageFinished = nil } + try navigate() + await fulfillment(of: [finished], timeout: 5) + } + + private func scriptVersion(_ browser: PreviewViewController) async throws -> String { + let version = try await browser.webView.evaluateJavaScript("window.fixtureScriptVersion") as? String + return try XCTUnwrap(version) + } + private func close(_ browser: PreviewViewController) async { let presenter = browser.presentingViewController await withCheckedContinuation { continuation in diff --git a/platforms/ios/runnerTests/PrivacySignalsTests.swift b/platforms/ios/runnerTests/PrivacySignalsTests.swift new file mode 100644 index 0000000000..7574985b0e --- /dev/null +++ b/platforms/ios/runnerTests/PrivacySignalsTests.swift @@ -0,0 +1,75 @@ +import UserMessagingPlatform +import XCTest +@testable import runner + +extension AdsBridgeTests { + func testPrivacyBridgeReturnsOnlyCurrentIabSignals() async throws { + let (controller, plugin) = try await host() + let suite = "acode.privacy-test.\(UUID().uuidString)" + let defaults = try XCTUnwrap(UserDefaults(suiteName: suite)) + let original = plugin.privacy + defer { plugin.privacy = original; defaults.removePersistentDomain(forName: suite) } + let expected: [String: Any] = [ + "IABTCF_gdprApplies": 1, "IABTCF_TCString": "test-tc", + "IABTCF_AddtlConsent": "2~1.2", "IABGPP_HDR_GppString": "test-gpp", + "IABGPP_GppSID": "7_8", "IABTCF_PurposeConsents": "11000010000", + "IABTCF_PurposeLegitimateInterests": "01000010000" + ] + for (key, value) in expected { defaults.set(value, forKey: key) } + defaults.set("private", forKey: "unrelated-setting") + plugin.privacy = AMBPrivacy(plugin: plugin, information: PrivacySignalsFixture(), defaults: defaults) + let state = try await controller.webView.callAsyncJavaScript( + "return await admob.privacy.getState();", arguments: [:], in: nil, contentWorld: .page) as? [String: Any] + XCTAssertEqual(state?["consentStatus"] as? String, "obtained") + XCTAssertEqual(state?["canRequestAds"] as? Bool, true) + XCTAssertEqual(state?["iabSignals"] as? NSDictionary, expected as NSDictionary) + } + + func testPrivacySnapshotReflectsWithdrawalAndRemovedSignals() async throws { + let (controller, plugin) = try await host() + let suite = "acode.privacy-test.\(UUID().uuidString)" + let defaults = try XCTUnwrap(UserDefaults(suiteName: suite)) + let original = plugin.privacy + defer { plugin.privacy = original; defaults.removePersistentDomain(forName: suite) } + plugin.privacy = AMBPrivacy(plugin: plugin, information: PrivacySignalsFixture(), defaults: defaults) + defaults.set(1, forKey: "IABTCF_gdprApplies") + defaults.set("accepted-tc", forKey: "IABTCF_TCString") + defaults.set("11000010000", forKey: "IABTCF_PurposeConsents") + for purposes in ["11000010000", "00000000000", "11000010000"] { + defaults.set(purposes, forKey: "IABTCF_PurposeConsents") + let state = try await controller.webView.callAsyncJavaScript( + "return await admob.privacy.getState();", arguments: [:], in: nil, contentWorld: .page) as? [String: Any] + XCTAssertEqual(state?["canRequestAds"] as? Bool, true) + let signals = try XCTUnwrap(state?["iabSignals"] as? [String: Any]) + XCTAssertEqual(signals["IABTCF_PurposeConsents"] as? String, purposes) + } + defaults.removeObject(forKey: "IABTCF_TCString") + defaults.removeObject(forKey: "IABTCF_PurposeConsents") + let state = try await controller.webView.callAsyncJavaScript( + "return await admob.privacy.showOptions();", arguments: [:], in: nil, contentWorld: .page) as? [String: Any] + let signals = try XCTUnwrap(state?["iabSignals"] as? [String: Any]) + XCTAssertNil(signals["IABTCF_TCString"]) + XCTAssertEqual(signals["IABTCF_PurposeConsents"] as? String, "") + } + + func testPrivacySnapshotPreservesBitStringsAndMarksInvalidPurposeUnknown() throws { + let suite = "acode.privacy-test.\(UUID().uuidString)" + let defaults = try XCTUnwrap(UserDefaults(suiteName: suite)) + defer { defaults.removePersistentDomain(forName: suite) } + let plugin = AMBPlugin(bridge: Bridge()) + let privacy = AMBPrivacy(plugin: plugin, information: PrivacySignalsFixture(), defaults: defaults) + defaults.set("0", forKey: "IABTCF_gdprApplies") + defaults.set("01000010000", forKey: "IABTCF_PurposeLegitimateInterests") + defaults.set(1100001, forKey: "IABTCF_PurposeConsents") + let signals = try XCTUnwrap(privacy.state["iabSignals"] as? [String: Any]) + XCTAssertEqual(signals["IABTCF_gdprApplies"] as? String, "0") + XCTAssertEqual(signals["IABTCF_PurposeLegitimateInterests"] as? String, "01000010000") + XCTAssertEqual(signals["IABTCF_PurposeConsents"] as? String, "") + } +} + +private final class PrivacySignalsFixture: ConsentInformation { + override var consentStatus: ConsentStatus { .obtained } + override var canRequestAds: Bool { true } + override var privacyOptionsRequirementStatus: PrivacyOptionsRequirementStatus { .notRequired } +} diff --git a/platforms/ios/runnerTests/SponsorPurchaseTests.swift b/platforms/ios/runnerTests/SponsorPurchaseTests.swift new file mode 100644 index 0000000000..8b2cf81713 --- /dev/null +++ b/platforms/ios/runnerTests/SponsorPurchaseTests.swift @@ -0,0 +1,213 @@ +import StoreKitTest +import WebKit +import XCTest + +@MainActor +final class SponsorPurchaseTests: BridgeTestCase { + private var session: SKTestSession! + private var scripts: WKUserContentController? + private var originalScripts: [WKUserScript] = [] + + override func setUp() async throws { + let url = try XCTUnwrap(Bundle(for: Self.self).url(forResource: "Iap", withExtension: "storekit")) + session = try SKTestSession(contentsOf: url) + session.resetToDefaultState() + session.clearTransactions() + session.disableDialogs = true + let webView = try await appWebView() + let scripts = webView.configuration.userContentController + self.scripts = scripts + originalScripts = scripts.userScripts + // The app protects fetch after startup, and the iOS transport rewrites API URLs. + scripts.addUserScript(WKUserScript(source: """ + window.sponsorRequests=[];window.sponsorReject=true;window.sponsorFailureStatus=503; + const originalFetch=window.fetch.bind(window); + window.fetch=async(input,options)=>{ + const request=new Request(input,options); + const path=new URL(request.url).pathname; + if(['/api/sponsors','/__api__/sponsors'].includes(path))return new Response('[]'); + if(['/api/sponsor','/__api__/sponsor'].includes(path)) { + sponsorRequests.push(await request.json()); + return new Response(JSON.stringify(sponsorReject?{error:'Test registration failure'}:{}),{status:sponsorReject?sponsorFailureStatus:201}); + } + return originalFetch(input,options); + }; + """, injectionTime: .atDocumentStart, forMainFrameOnly: true)) + _ = try await webView.evaluateJavaScript("localStorage.removeItem('sponsor_pending_app.acode');localStorage.removeItem('sponsor_crystal')") + try await super.setUp() + try await reloadWebView(webView) + _ = try await editorWebView() + } + + override func tearDownWithError() throws { + scripts?.removeAllUserScripts() + for script in originalScripts { scripts?.addUserScript(script) } + scripts = nil + originalScripts = [] + session?.clearTransactions() + session?.resetToDefaultState() + session = nil + } + + func testSponsorPurchaseRetriesRegistrationBeforeFinishingAndCanBeBoughtAgain() async throws { + let webView = try await prepare() + try await openSponsor(webView) + let count = try await webView.evaluateJavaScript("document.querySelectorAll('#sponsor-page .tier').length") as? Int + XCTAssertEqual(count, 6) + try await selectCrystal(webView) + try await wait(webView, "sponsorRequests.length===1") + let unfinished = try await purchases(webView) + XCTAssertEqual(unfinished.count, 1) + let request = try await webView.evaluateJavaScript("sponsorRequests[0]") as? [String: Any] + XCTAssertEqual(request?["tier"] as? String, "crystal") + XCTAssertEqual(request?["packageName"] as? String, "app.acode") + XCTAssertEqual((request?["purchaseToken"] as? String)?.split(separator: ".").count, 3) + let retained = try await webView.evaluateJavaScript("!!localStorage.getItem('sponsor_crystal')") as? Bool + XCTAssertEqual(retained, true) + // Reopening the page recovers the unfinished transaction after a network failure. + _ = try await webView.evaluateJavaScript("sponsorReject=false;document.querySelectorAll('.prompt:not(.hide) button').forEach(button=>button.click());document.querySelector('#sponsor-page').closest('wc-page').hide()") + try await openSponsor(webView, waitForProducts: false) + try await wait(webView, "sponsorRequests.length===2&&!localStorage.getItem('sponsor_crystal')") + let remaining = try await purchases(webView) + XCTAssertTrue(remaining.isEmpty) + _ = try await webView.evaluateJavaScript("document.querySelectorAll('.prompt:not(.hide) button').forEach(button=>button.click())") + try await openSponsor(webView) + try await selectCrystal(webView) + try await wait(webView, "sponsorRequests.length===3&&!localStorage.getItem('sponsor_crystal')") + XCTAssertEqual(session.allTransactions().filter { $0.productIdentifier == "crystal" }.count, 2) + let finished = try await purchases(webView) + XCTAssertTrue(finished.isEmpty) + } + + func testCancelledAndPendingSponsorPurchasesDoNotRegisterUntilApproved() async throws { + let webView = try await prepare() + _ = try await webView.evaluateJavaScript("sponsorReject=false") + try await openSponsor(webView) + try await session.setSimulatedError(.generic(.userCancelled), forAPI: StoreKitPurchaseAPI()) + try await selectCrystal(webView) + try await wait(webView, "sponsorErrors.includes(1)&&app.classList.contains('title-loading-hide')") + let cancelledCount = try await webView.evaluateJavaScript("sponsorRequests.length") as? Int + XCTAssertEqual(cancelledCount, 0) + try await session.setSimulatedError(nil, forAPI: StoreKitPurchaseAPI()) + session.askToBuyEnabled = true + try await selectCrystal(webView) + for _ in 0..<100 { + if session.allTransactions().contains(where: { $0.state == .deferred }) { break } + try await Task.sleep(for: .milliseconds(100)) + } + let pending = try XCTUnwrap(session.allTransactions().first { $0.state == .deferred }) + let pendingCount = try await webView.evaluateJavaScript("sponsorRequests.length") as? Int + XCTAssertEqual(pendingCount, 0) + try session.approveAskToBuyTransaction(identifier: pending.identifier) + try await wait(webView, "sponsorRequests.length===1&&!localStorage.getItem('sponsor_crystal')") + } + + func testPaidSponsorRecoversAfterReloadWithoutOpeningSponsorPage() async throws { + let webView = try await prepare() + // Keep fulfillment pending, then lose the WebView and its local purchase context. + _ = try await session.buyProduct(identifier: "crystal") + _ = try await webView.evaluateJavaScript("localStorage.removeItem('sponsor_crystal');localStorage.removeItem('sponsor_pending_app.acode')") + let scripts = webView.configuration.userContentController + let originalScripts = scripts.userScripts.map { $0 } + defer { + scripts.removeAllUserScripts() + originalScripts.forEach(scripts.addUserScript) + } + scripts.addUserScript(WKUserScript(source: """ + window.sponsorReject=false; + """, injectionTime: .atDocumentStart, forMainFrameOnly: true)) + try await reloadWebView(webView) + _ = try await editorWebView() + try await wait(webView, "!!document.querySelector('.prompt.multi:not(.hide) input')") + let page = try await webView.evaluateJavaScript("!!document.querySelector('#sponsor-page')") as? Bool + XCTAssertEqual(page, false) + let message = try await webView.evaluateJavaScript("document.querySelector('.prompt.multi:not(.hide) .message > p').textContent") as? String + XCTAssertTrue(message?.contains("not be charged again") == true) + _ = try await webView.evaluateJavaScript(""" + const input=document.querySelector('.prompt.multi:not(.hide) input'); + input.value='Recovered Sponsor';input.dispatchEvent(new Event('input',{bubbles:true})); + document.querySelector('.prompt.multi:not(.hide) button[type="submit"]').click(); + """) + try await wait(webView, "sponsorRequests.length===1&&!localStorage.getItem('sponsor_pending_app.acode')") + let request = try await webView.evaluateJavaScript("sponsorRequests[0]") as? [String: Any] + XCTAssertEqual(request?["name"] as? String, "Recovered Sponsor") + XCTAssertEqual(request?["tier"] as? String, "crystal") + XCTAssertEqual(session.allTransactions().filter { $0.productIdentifier == "crystal" }.count, 1) + let remaining = try await purchases(webView) + XCTAssertTrue(remaining.isEmpty) + } + + func testRejectedDetailsCanBeCorrectedWithoutAnotherCharge() async throws { + let webView = try await prepare() + _ = try await webView.evaluateJavaScript("sponsorFailureStatus=400") + try await openSponsor(webView) + try await selectCrystal(webView) + try await wait(webView, "sponsorRequests.length===1&&!localStorage.getItem('sponsor_crystal')") + let unfinished = try await purchases(webView) + XCTAssertEqual(unfinished.count, 1) + let details = try await webView.evaluateJavaScript("JSON.parse(localStorage.getItem('sponsor_pending_app.acode'))[0].details===null") as? Bool + XCTAssertEqual(details, true) + _ = try await webView.evaluateJavaScript("sponsorReject=false;document.querySelectorAll('.prompt:not(.hide) button').forEach(button=>button.click());document.querySelector('#sponsor-page').closest('wc-page').hide()") + try await openSponsor(webView) + try await wait(webView, "!!document.querySelector('.prompt.multi:not(.hide) input')") + _ = try await webView.evaluateJavaScript(""" + const input=document.querySelector('.prompt.multi:not(.hide) input'); + input.value='Corrected Sponsor';input.dispatchEvent(new Event('input',{bubbles:true})); + document.querySelector('.prompt.multi:not(.hide) button[type="submit"]').click(); + """) + try await wait(webView, "sponsorRequests.length===2&&!localStorage.getItem('sponsor_pending_app.acode')") + let name = try await webView.evaluateJavaScript("sponsorRequests[1].name") as? String + XCTAssertEqual(name, "Corrected Sponsor") + XCTAssertEqual(session.allTransactions().filter { $0.productIdentifier == "crystal" }.count, 1) + let remaining = try await purchases(webView) + XCTAssertTrue(remaining.isEmpty) + } + + private func prepare() async throws -> WKWebView { + let webView = try await editorWebView() + _ = try await webView.evaluateJavaScript(""" + window.sponsorRequests=[];window.sponsorErrors=[];window.sponsorReject=true;window.sponsorFailureStatus=503; + const originalPurchase=iap.purchase; + iap.purchase=(product,success,failure,updateError)=>originalPurchase(product,success, + error=>{sponsorErrors.push(error);failure?.(error)}, + updateError?error=>{sponsorErrors.push(error);updateError(error)}:undefined); + localStorage.removeItem('sponsor_crystal'); + null; + """) + _ = try await webView.callAsyncJavaScript(""" + await acode.exec('open','settings'); + acode.require('settings').uiSettings['main-settings'].getListElement().querySelector('[data-key="sponsors"]').click(); + """, arguments: [:], in: nil, contentWorld: .page) + try await wait(webView, "!!document.querySelector('#sponsors-page .cta-button')") + return webView + } + + private func openSponsor(_ webView: WKWebView, waitForProducts: Bool = true) async throws { + // A closing page remains in the DOM until its fade-out finishes. + try await wait(webView, "!document.querySelector('#sponsor-page')&&!!document.querySelector('#sponsors-page .cta-button')") + _ = try await webView.evaluateJavaScript("document.querySelector('#sponsors-page .cta-button').click()") + if waitForProducts { try await wait(webView, "!!document.querySelector('#sponsor-page .crystal .purchase-btn')") } + } + + private func selectCrystal(_ webView: WKWebView) async throws { + _ = try await webView.evaluateJavaScript("document.querySelector('#sponsor-page .crystal .purchase-btn').click()") + try await wait(webView, "!!document.querySelector('.prompt.multi:not(.hide) input')") + _ = try await webView.callAsyncJavaScript(""" + const input=document.querySelector('.prompt.multi:not(.hide) input');input.value='Simulator Sponsor';input.dispatchEvent(new Event('input',{bubbles:true})); + document.querySelector('.prompt.multi:not(.hide) button[type="submit"]').click(); + """, arguments: [:], in: nil, contentWorld: .page) + } + + private func purchases(_ webView: WKWebView) async throws -> [[String: Any]] { + try await webView.callAsyncJavaScript("return await new Promise((resolve,reject)=>iap.getPurchases(resolve,reject))", arguments: [:], in: nil, contentWorld: .page) as? [[String: Any]] ?? [] + } + + private func wait(_ webView: WKWebView, _ expression: String) async throws { + for _ in 0..<150 { + if try await webView.evaluateJavaScript(expression) as? Bool == true { return } + try await Task.sleep(for: .milliseconds(100)) + } + let details = try await webView.evaluateJavaScript("JSON.stringify({errors:window.sponsorErrors,requests:window.sponsorRequests?.map(({purchaseToken,...details})=>details),details:localStorage.getItem('sponsor_crystal'),dialogs:[...document.querySelectorAll('.prompt:not(.hide)')].map(element=>element.textContent)})") + throw NSError(domain: "SponsorTests", code: 1, userInfo: [NSLocalizedDescriptionKey: "Timed out: \(expression); scene=\(String(describing: webView.window?.windowScene?.activationState)); \(details ?? "")"]) + } +} diff --git a/platforms/ios/runnerTests/TrackingAuthorizationTests.swift b/platforms/ios/runnerTests/TrackingAuthorizationTests.swift index 30b77978ec..0b2fb9ba24 100644 --- a/platforms/ios/runnerTests/TrackingAuthorizationTests.swift +++ b/platforms/ios/runnerTests/TrackingAuthorizationTests.swift @@ -13,8 +13,12 @@ final class TrackingAuthorizationTests: XCTestCase { var callback: ((ATTrackingManager.AuthorizationStatus) -> Void)? let notifications = NotificationCenter() let requested = expectation(description: "ATT requested in foreground") + var progressShown = 0 + var progressHidden = 0 let tracking = AMBTrackingAuthorization(status: { .notDetermined }, isActive: { self.appActive }, - notifications: notifications, request: { calls += 1; callback = $0; requested.fulfill() }) + notifications: notifications, + showProgress: { progressShown += 1; return { progressHidden += 1 } }, + request: { calls += 1; callback = $0; requested.fulfill() }) let finished = expectation(description: "Both callers receive the decision") finished.expectedFulfillmentCount = 2 for _ in 0..<2 { @@ -24,17 +28,23 @@ final class TrackingAuthorizationTests: XCTestCase { } } XCTAssertEqual(calls, 0) + XCTAssertEqual(progressShown, 1) + XCTAssertEqual(progressHidden, 0) appActive = true notifications.post(name: UIApplication.didBecomeActiveNotification, object: nil) await fulfillment(of: [requested], timeout: 2) XCTAssertEqual(calls, 1) callback?(.denied) await fulfillment(of: [finished], timeout: 2) + XCTAssertEqual(progressHidden, 1) } func testExistingTrackingDecisionsDoNotPromptAgain() { for status: ATTrackingManager.AuthorizationStatus in [.denied, .restricted, .authorized] { - let tracking = AMBTrackingAuthorization(status: { status }, isActive: { false }, request: { _ in + let tracking = AMBTrackingAuthorization(status: { status }, isActive: { false }, showProgress: { + XCTFail("A decided permission must not show loading feedback") + return {} + }, request: { _ in XCTFail("A decided permission must not prompt again") }) var result: ATTrackingManager.AuthorizationStatus? @@ -45,7 +55,11 @@ final class TrackingAuthorizationTests: XCTestCase { func testUndeterminedResultCannotStartAdsAndAllowsRetry() async { var calls = 0 - let tracking = AMBTrackingAuthorization(status: { .notDetermined }, isActive: { true }, request: { + var progressVisible = false + let tracking = AMBTrackingAuthorization(status: { .notDetermined }, isActive: { true }, showProgress: { + progressVisible = true + return { progressVisible = false } + }, request: { calls += 1 $0(calls == 1 ? .notDetermined : .authorized) }) @@ -55,6 +69,7 @@ final class TrackingAuthorizationTests: XCTestCase { failed.fulfill() } await fulfillment(of: [failed], timeout: 2) + XCTAssertFalse(progressVisible) let retried = expectation(description: "Retry succeeds") tracking.authorize { result in XCTAssertEqual(try? result.get(), .authorized) @@ -62,12 +77,17 @@ final class TrackingAuthorizationTests: XCTestCase { } await fulfillment(of: [retried], timeout: 2) XCTAssertEqual(calls, 2) + XCTAssertFalse(progressVisible) } func testResetCancelsCallerWithoutStartingAnOverlappingTrackingRequest() async { var requests = 0 + var progressVisible = false var reply: (@Sendable (ATTrackingManager.AuthorizationStatus) -> Void)? - let tracking = AMBTrackingAuthorization(status: { .notDetermined }, isActive: { true }, request: { + let tracking = AMBTrackingAuthorization(status: { .notDetermined }, isActive: { true }, showProgress: { + progressVisible = true + return { progressVisible = false } + }, request: { requests += 1 reply = $0 }) @@ -77,14 +97,17 @@ final class TrackingAuthorizationTests: XCTestCase { } tracking.cancel() XCTAssertTrue(cancelled) + XCTAssertFalse(progressVisible) let completed = expectation(description: "New caller receives the outstanding OS decision") tracking.authorize { result in XCTAssertEqual(try? result.get(), .denied) completed.fulfill() } XCTAssertEqual(requests, 1) + XCTAssertTrue(progressVisible) reply?(.denied) await fulfillment(of: [completed], timeout: 2) + XCTAssertFalse(progressVisible) } func testDeadlineFailsWaitersWithoutOverlappingOSRequestAndLateReplyCanRecover() async { @@ -144,8 +167,12 @@ final class TrackingAuthorizationTests: XCTestCase { func testInactiveWaitIsBoundedAndCanRetryWhenActive() async { appActive = false var calls = 0 + var progressVisible = false let tracking = AMBTrackingAuthorization(status: { .notDetermined }, isActive: { self.appActive }, - timeout: .milliseconds(25), request: { calls += 1; $0(.denied) }) + timeout: .milliseconds(25), showProgress: { + progressVisible = true + return { progressVisible = false } + }, request: { calls += 1; $0(.denied) }) let timedOut = expectation(description: "Inactive wait times out") tracking.authorize { result in if case .success = result { XCTFail("Inactive timeout must not start ads") } @@ -153,6 +180,7 @@ final class TrackingAuthorizationTests: XCTestCase { } await fulfillment(of: [timedOut], timeout: 2) XCTAssertEqual(calls, 0) + XCTAssertFalse(progressVisible) appActive = true let completed = expectation(description: "Active retry succeeds") tracking.authorize { result in @@ -190,4 +218,21 @@ final class TrackingAuthorizationTests: XCTestCase { replies[1](.restricted) await fulfillment(of: [completed], timeout: 2) } + + func testProgressFitsCompactScreenWithoutBlockingTouchesAndCleansUp() throws { + let container = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 568)) + let existingContent = UIView(frame: container.bounds) + container.addSubview(existingContent) + let hide = AMBPrivacyProgress.show(in: container) + container.layoutIfNeeded() + let panel = try XCTUnwrap(container.subviews.last as? UIVisualEffectView) + XCTAssertFalse(panel.isUserInteractionEnabled) + XCTAssertFalse(panel.hasAmbiguousLayout) + XCTAssertGreaterThan(panel.frame.height, 0) + XCTAssertGreaterThanOrEqual(panel.frame.minX, 20) + XCTAssertLessThanOrEqual(panel.frame.maxX, 300) + hide() + hide() + XCTAssertEqual(container.subviews, [existingContent]) + } } diff --git a/platforms/ios/runnerTests/WebShadowCaretTests.swift b/platforms/ios/runnerTests/WebShadowCaretTests.swift index 83b560a72f..c96d9cead5 100644 --- a/platforms/ios/runnerTests/WebShadowCaretTests.swift +++ b/platforms/ios/runnerTests/WebShadowCaretTests.swift @@ -24,11 +24,17 @@ final class WebShadowCaretTests: BridgeTestCase { configuration.websiteDataStore = .nonPersistent() WebShadowCaret.install(on: configuration.userContentController) let view = WKWebView(frame: CGRect(x: 0, y: 0, width: 400, height: 600), configuration: configuration) + let loaded = expectation(description: "Shadow editor fixture finished loading") + let navigation = ShadowCaretNavigation(loaded: loaded) + view.navigationDelegate = navigation + defer { view.navigationDelegate = nil; view.stopLoading() } view.loadHTMLString("", baseURL: nil) - for _ in 0..<100 { - if !view.isLoading, - (try? await view.evaluateJavaScript("document.querySelector('iframe')?.contentDocument?.readyState === 'complete'")) as? Bool == true { break } - try await Task.sleep(for: .milliseconds(50)) + await fulfillment(of: [loaded], timeout: 30) + guard let navigationResult = navigation.result else { return } + try navigationResult.get() + guard (try await view.evaluateJavaScript("document.querySelector('iframe')?.contentDocument?.readyState === 'complete'")) as? Bool == true else { + XCTFail("Shadow editor iframe did not finish loading") + return } let script = """ (() => { @@ -88,3 +94,21 @@ final class WebShadowCaretTests: BridgeTestCase { XCTAssertEqual(result, true) } } + +@MainActor +private final class ShadowCaretNavigation: NSObject, WKNavigationDelegate { + let loaded: XCTestExpectation + private(set) var result: Result? + + init(loaded: XCTestExpectation) { self.loaded = loaded } + + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { finish(.success(())) } + func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) { finish(.failure(error)) } + func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) { finish(.failure(error)) } + + private func finish(_ result: Result) { + guard self.result == nil else { return } + self.result = result + loaded.fulfill() + } +} diff --git a/src/components/terminal/openTerminalLink.js b/src/components/terminal/openTerminalLink.js new file mode 100644 index 0000000000..9758411fab --- /dev/null +++ b/src/components/terminal/openTerminalLink.js @@ -0,0 +1,43 @@ +import confirm from "dialogs/confirm"; +import browser from "native/browser"; +import helpers from "utils/helpers"; + +export default async function openTerminalLink(uri, isRemote = false) { + if (globalThis.Bridge?.platformId === "ios" && !isRemote) { + const local = localPreviewUrl(uri); + if (local) { + try { + browser.open(local, false, { + ephemeral: true, + onError: (error) => helpers.error(error), + }); + } catch (error) { + helpers.error(error); + } + return; + } + } + if (await confirm("Terminal", `Do you want to open ${uri} in browser?`)) { + system.openInBrowser(uri); + } +} + +function localPreviewUrl(uri) { + try { + const url = new URL(uri); + if (!["http:", "https:"].includes(url.protocol)) return null; + const host = url.hostname.toLowerCase().replace(/\.$/, ""); + if (host === "0.0.0.0") url.hostname = "127.0.0.1"; + else if (host === "[::]") url.hostname = "[::1]"; + else if ( + host !== "localhost" && + host !== "[::1]" && + !/^127\.\d+\.\d+\.\d+$/.test(host) + ) { + return null; + } + return url.href; + } catch { + return null; + } +} diff --git a/src/components/terminal/terminal.js b/src/components/terminal/terminal.js index eab8c117ad..b89ee191a1 100644 --- a/src/components/terminal/terminal.js +++ b/src/components/terminal/terminal.js @@ -16,11 +16,11 @@ import { getEffectiveKeyBindings, getResolvedKeyBindingsVersion, } from "cm/commandRegistry"; -import confirm from "dialogs/confirm"; import fonts from "lib/fonts"; import appSettings from "lib/settings"; import { quotePosixShellArg } from "utils/shell"; import LigaturesAddon from "./ligatures"; +import openTerminalLink from "./openTerminalLink"; import { DEFAULT_TERMINAL_SETTINGS, getTerminalSettings, @@ -100,15 +100,9 @@ export default class TerminalComponent { this.fitAddon = new FitAddon(); this.unicode11Addon = new Unicode11Addon(); this.searchAddon = new SearchAddon(); - this.webLinksAddon = new WebLinksAddon(async (event, uri) => { - const linkOpenConfirm = await confirm( - "Terminal", - `Do you want to open ${uri} in browser?`, - ); - if (linkOpenConfirm) { - system.openInBrowser(uri); - } - }); + this.webLinksAddon = new WebLinksAddon((event, uri) => + openTerminalLink(uri, Boolean(this.remoteSsh)), + ); this.webglAddon = null; // Load addons diff --git a/src/dialogs/multiPrompt.js b/src/dialogs/multiPrompt.js index 538702e6c2..5b84793610 100644 --- a/src/dialogs/multiPrompt.js +++ b/src/dialogs/multiPrompt.js @@ -3,8 +3,10 @@ import Checkbox from "components/checkbox"; import inputhints from "components/inputhints"; import actionStack from "lib/actionStack"; import restoreTheme from "lib/restoreTheme"; -import appSettings from "lib/settings"; import alert from "./alert"; +import restorePromptInput from "./restorePromptInput"; + +let nextPromptId = 0; /** * @typedef {object} Input @@ -30,96 +32,57 @@ import alert from "./alert"; * @param {string} message Message * @param {Array>} inputs Inputs * @param {String} help Help text + * @param {string} [description] Text shown above the inputs * @returns {Promise} */ -export default function multiPrompt(message, inputs, help) { +export default function multiPrompt(message, inputs, help, description) { + const actionId = `multi-prompt-${++nextPromptId}`; return new Promise((resolve, reject) => { - const $title = tag("div", { - className: "title", - child: tag("span", { - textContent: message, - }), - style: { - justifyContent: "space-between", - }, - }); - const $body = tag("div", { - className: "message scroll", - style: { - fontSize: "1rem", - }, - }); - const okBtn = tag("button", { - type: "submit", - textContent: strings.ok, - onclick: function (e) { - e.preventDefault(); - e.stopPropagation(); - const inputAr = [...$body.getAll("input")]; - - for (let $input of inputAr) { - if ($input.isRequired && !$input.value) { - $errorMessage.textContent = strings.required.capitalize(); - const $sibling = $input.nextElementSibling; - const $parent = $input.parentElement; - if ($sibling) $parent.insertBefore($errorMessage, $sibling); - else $parent.append($errorMessage); - return; - } - } - const values = getValue(); - hide(); - resolve(values); - }, - }); - const cancelBtn = tag("button", { - textContent: strings.cancel, - type: "button", - onclick: function () { - reject(); - hide(); - }, - }); + const $title = ( +
+ +
+ ); + const $body = ( +
+ ); + if (description) $body.append(

); + const okBtn = ( + + ); const $errorMessage = ( ); const $mask = ; - const $promptDiv = tag("form", { - action: "#", - className: "prompt multi", - onsubmit: (e) => { - e.preventDefault(); - if (!okBtn.disabled) { - const values = getValue(); - hide(); - resolve(values); - } - }, - children: [ - $title, - $body, - tag("div", { - className: "button-container", - children: [cancelBtn, okBtn], - }), - ], - }); + const $promptDiv = ( +

+ {$title} + {$body} +
+ + {okBtn} +
+
+ ); if (/^https?:/.test(help)) { - $title.append( - tag("a", { - href: help, - className: "icon help", - }), - ); + $title.append(); } else if (typeof help === "string") { $title.append( - tag("span", { - className: "icon help", - onclick: () => { - alert(strings.info, help); - }, - }), + alert(strings.info, help)} + />, ); } @@ -129,19 +92,48 @@ export default function multiPrompt(message, inputs, help) { }); actionStack.push({ - id: "prompt", - action: hidePrompt, + id: actionId, + action: cancel, + onClear: cancel, }); restoreTheme(true); system.setInputType("NORMAL"); document.body.append($promptDiv, $mask); - const $focusEl = [...$body.getAll("input[autofocus]")].pop(); + const $focusEl = [ + ...$body.getAll("input[autofocus], textarea[autofocus]"), + ].pop(); if ($focusEl) $focusEl.focus(); + function submit(event) { + event.preventDefault(); + event.stopPropagation(); + if (okBtn.disabled || $promptDiv.classList.contains("hide")) return; + for (const $input of $body.getAll("input, textarea")) { + if ($input.isRequired && !$input.value) { + $errorMessage.textContent = strings.required; + const $sibling = $input.nextElementSibling; + const $parent = $input.parentElement; + if ($sibling) $parent.insertBefore($errorMessage, $sibling); + else $parent.append($errorMessage); + return; + } + } + const values = getValue(); + hide(); + resolve(values); + } + + function cancel() { + reject(); + hidePrompt(); + } + function hidePrompt() { + if ($promptDiv.classList.contains("hide")) return; clearSensitiveInputs(); $promptDiv.classList.add("hide"); + restorePromptInput(); restoreTheme(); setTimeout(() => { if ($promptDiv.isConnected) $promptDiv.remove(); @@ -150,14 +142,13 @@ export default function multiPrompt(message, inputs, help) { } function hide() { - actionStack.remove("prompt"); - system.setInputType(appSettings.value.keyboardMode); + actionStack.remove(actionId); hidePrompt(); } function getValue() { const values = {}; - const inputAr = [...$body.getAll("input")]; + const inputAr = [...$body.getAll("input, textarea")]; inputAr.map(($input) => { if ($input.type === "checkbox" || $input.type === "radio") values[$input.id] = $input.checked; @@ -168,7 +159,9 @@ export default function multiPrompt(message, inputs, help) { return values; } - function clearSensitiveInputs(inputs = [...$body.getAll("input")]) { + function clearSensitiveInputs( + inputs = [...$body.getAll("input, textarea")], + ) { for (const $input of inputs) { if ($input.type === "password" || $input.isSensitive) { $input.value = ""; @@ -181,13 +174,8 @@ export default function multiPrompt(message, inputs, help) { * @param {Array} inputs Array of inputs */ function createGroup(inputs) { - const $text = tag("span", { - className: "hero", - }); - const $group = tag("div", { - className: "input-group", - child: $text, - }); + const $text = ; + const $group =
{$text}
; inputs.map((input) => { let $input; @@ -229,27 +217,41 @@ export default function multiPrompt(message, inputs, help) { } = input; const inputType = type === "textarea" ? "textarea" : "input"; - let _type = type === "filename" ? "text" : type || "text"; + const fieldType = type === "filename" ? "text" : type || "text"; let $input; - if (_type === "checkbox" || _type === "radio") { - $input = Checkbox(placeholder, value, name, id, type); + if (fieldType === "checkbox" || fieldType === "radio") { + $input = ( + + ); if (!group) { $input.style.marginTop = "1rem"; } } else { - $input = tag(inputType, { + const props = { id, placeholder, - value: value, + value, className: "input", isRequired: required, readOnly, autofocus, hidden, - }); + }; + $input = + inputType === "textarea" ? ( +