Compare commits

...

1077 commits
24.04 ... main

Author SHA1 Message Date
Damien Elmes
3890e12c9e Bump version
.1 release skipped due to missing bugfix
2025-09-17 16:50:13 +10:00
llama
80cff16250
fix: persist colour picker's custom palette in profile (#4326)
* add SaveCustomColours rpc method

* restore custom colour palette on editor init

* save custom colour palette on colour picker open and input

there doesn't seem to be an event fired when the picker is
cancelled/closed, so it's still possible for work to be lost

* save colours on `change` instead of `input`

`input` is supposed to be fired on every adjustment to the picker
whereas `change` is only fired when the picker is accepted, but qt
seems to treat both as the latter, so this is currently a no-op

* Store colors in the collection

One minor tweak to the logic while I was there: an invalid color no
longer invalidates all the rest.

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-09-17 16:46:53 +10:00
Abdo
75d9026be5
Decode images asynchronously (#4320) 2025-09-17 09:06:42 +03:00
Damien Elmes
6854d13b88 Bump version 2025-09-17 15:50:16 +10:00
Damien Elmes
29072654db Update translations 2025-09-17 15:50:02 +10:00
jcznk
ec6f09958a
(UI polish) Improved margins in Card Browser's "Previewer" (#4337)
* Improved margins in Card Browser's "Preview" pane

* Alternate approach that looks good on Mac too

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2025-09-17 15:30:22 +10:00
snowtimeglass
c2957746f4
Make timebox message translatable with flexible variable order (#4338)
* Make timebox message translatable with flexible variable order

Currently, the timebox dialog message is built from two separate strings,
each containing one variable:
"{ $count } cards studied in" + "{ $count } minutes."

As a result, translators cannot freely reorder the variables in their translations.

This change introduces a single string with both variables, allowing translators
to adjust the order for more natural expressions in their languages.

* Preserve old string for now

* Ensure message doesn't display over two lines

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-09-17 15:13:59 +10:00
Luc Mcgrady
9e415869b8
Fix/Add lower review limit to health check. (#4334) 2025-09-17 14:04:27 +10:00
Emil Hamrin
7e8a1076c1
Updated Dockerfile to use Ninja build system (#4321)
* Updated Dockerfile to support ninja build

* Install python using uv

* Bumped python version

* Add disclaimer (dae)
2025-09-17 14:02:09 +10:00
dependabot[bot]
b97fb45e06
Bump vite from 6.3.5 to 6.3.6 (#4328)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.3.5 to 6.3.6.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.3.6/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.3.6/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 6.3.6
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-17 12:08:11 +10:00
Damien Elmes
61094d387a Update translations 2025-09-17 09:31:47 +10:00
Damien Elmes
90ed4cc115 Disable NPM package scripts, and assert lockfile unchanged
With all the recent supply chain attacks, this seems prudent. There are
three in our current package list. esbuild's is just a performance
optimization (https://github.com/evanw/esbuild/issues/4085), and
dprint's gets done when we invoke .bin/dprint anyway. svelte-preprocess
simply prints something to the screen.
2025-09-17 09:31:23 +10:00
jcznk
4506ad0c97
Prevent clipping for QPushButton:default (#4323) 2025-09-14 20:44:16 +03:00
Damien Elmes
539054c34d Bump version 2025-09-06 21:17:08 +10:00
Damien Elmes
cf12c201d8 Update translations 2025-09-06 21:16:13 +10:00
Lukas Sommer
3b0297d14d
Update deck-config.ftl (#4319) 2025-09-06 21:15:42 +10:00
Damien Elmes
58deb14028 Ensure the newly-spawned terminal doesn't inherit the env var
It seems like the open call was leaking it into the newly spawned
process.

Follow-up fix to 2491eb0316
2025-09-04 16:18:11 +10:00
Damien Elmes
5c4d2e87a1 Bump version 2025-09-04 14:39:29 +10:00
Damien Elmes
6d31776c25 Update translations 2025-09-04 14:38:45 +10:00
Luc Mcgrady
dda730dfa2
Fix/Invalid memory states in simulator after parameters changed (#4317)
* Fix/Invalid memory states after optimization for simulator

* Update ts/routes/deck-options/FsrsOptions.svelte

* typo

* ./check
2025-09-04 14:35:00 +10:00
Damien Elmes
08431106da Exclude SSLKEYLOGFILE from Python
Closes #4308
2025-09-04 13:20:12 +10:00
Damien Elmes
b4b1c2013f Use the audio input device's preferred format
19f9afba64 broke recording for devices that
only support a single channel. Instead of hard-coding the values, we should
be using what the device prefers.

Apparently some devices may only support float formats, so conversion code
has been added to handle that case as well.

https://forums.ankiweb.net/t/cant-record-my-voice-after-upgrading-to-25-7-3/64453
2025-09-04 12:55:36 +10:00
maxr777
5280cb2f1c
Enable nc: to only search in a specific field (#4276) (#4312)
* Enable nc: to only search in a specific field

* Add FieldSearchMode enum to replace boolean fields

* Avoid magic numbers in enum

* Use standard naming so Prost can remove redundant text

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-09-04 11:52:08 +10:00
Damien Elmes
b2ab0c0830 Add an experimental new system Qt mode to the launcher
Goal is to allow users to use their system Qt libraries that have
things like fcitx support available.

For #4313
2025-09-03 23:54:27 +10:00
Damien Elmes
6a985c9fb0 Add support for custom launcher venv locations
Closes #4305 when https://github.com/ankitects/anki-manual/pull/444 is
merged, and makes it easier to maintain multiple Anki versions at once.
2025-09-03 20:54:16 +10:00
Damien Elmes
db1d04f622 Centralize uv command setup
Closes #4306
2025-09-03 19:58:45 +10:00
Damien Elmes
2491eb0316 Don't reuse existing terminal process
May possibly help with #4304
2025-09-03 17:32:30 +10:00
Damien Elmes
06f9d41a96 Bypass install_name_tool invocation on macOS
Not sure when https://github.com/astral-sh/uv/issues/14893 will be
ready, and this seems to solve the problem for now.

Closes #4227
2025-09-03 17:32:30 +10:00
llama
8d5c385c76
use existing translation instead of adding new one (#4310) (#4316)
Co-authored-by: Abdo <abdo@abdnh.net>
2025-09-02 23:54:17 +03:00
llama
153b972dfd
Show the number of cards added when adding (#4310)
* modify `generate_cards_for_note` to return count

* modify `add_note` to return count

* show the number of cards added when adding
2025-09-02 18:06:49 +10:00
Jarrett Ye
4ac80061ca
Add desired_retention field to NormalDeckSchema11 (#4292)
* Add desired_retention field to NormalDeckSchema11

* pass ci
2025-09-02 17:55:23 +10:00
Damien Elmes
01b825f7c6 Fix theme/checkboxes when path contains an apostrophe
I couldn't find a list of other characters we might need to handle too.
I tested with ", but Qt failed to start then.

https://forums.ankiweb.net/t/qt-rendering-bug-in-check-boxes/66196
2025-09-02 15:55:37 +10:00
洩氏诹诹子
157da4c7a7
Fix mirror configuration not working during launcher download (#4280)
Use environment variable instead of configuration file
2025-09-02 14:58:34 +10:00
Damien Elmes
8ef208e418 Fix importing of Mnemosyne collections with missing cards
There's no associated scheduling data, but we can at least preserve
the note.

https://forums.ankiweb.net/t/error-importing-mnemosyne-2-9-deck/65592
2025-09-01 18:25:34 +10:00
Lee Doughty
65ea013270
Update microphone icon to respect dark mode (#4297) 2025-09-01 17:56:48 +10:00
Damien Elmes
ef1a1deb9c Update translations 2025-09-01 15:13:40 +10:00
GithubAnon0000
c93e11f343
FIX gap above bury (#4298) 2025-09-01 15:09:42 +10:00
€šm̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰̰�Ř§Ů Â£╟©舐æØ¢£ðsÞ¥¿—
e3d0a30443
Fix ninja BuildAction name sanitization (#4291)
rust commit 8296ad0 changes the output of std::any::type_name to include
regions such as lifetime and generic arguments, which results in invalid
Ninja rule names being generated, such as `CargoBuild<_>`.
2025-09-01 15:08:29 +10:00
Jarrett Ye
4fdb4983dd
Fix/recompute memory state when deck-specific DR is changed (#4293) 2025-09-01 15:07:35 +10:00
Luc Mcgrady
3521da3ad6
Chore/Remove CMRR from fsrs help modal (#4290)
* Remove cmrr from fsrs help sections

* move other strings
2025-09-01 14:58:20 +10:00
Damien Elmes
ca60911e19 Update to Rust 1.89 + latest deps 2025-09-01 14:55:49 +10:00
Damien Elmes
71ec878780 Fixes for Rust 1.89
Closes #4287
2025-09-01 14:55:49 +10:00
user1823
6dd9daf074
Increase randomness in random sorting of new cards (#4286)
* Increase randomness in random sorting of new cards

Currently, the new cards appear roughly in the same order on consecutive days (if they are skipped by burying). This change aims to increase randomness by spreading out the salt across the hash space.

* Fix errors
2025-09-01 14:22:27 +10:00
user1823
3b33d20849
Fix LRT database check for cards with no usable reviews (#4284)
Fixes https://forums.ankiweb.net/t/anki-25-08-beta-3/64738/62
2025-09-01 14:19:36 +10:00
Luc Mcgrady
542c557404
Fix/Workload deck_size unset (#4283) 2025-09-01 14:18:30 +10:00
Luc Mcgrady
211cbfe660
Fix/Simulator intervals decending overflows (#4275)
* Fix/Simulator intervals decending overflows

* saturating_sub

* oops
2025-09-01 14:16:40 +10:00
Damien Elmes
359231a4d8 Update licenses after tracing-subscriber bump 2025-09-01 13:42:10 +10:00
Damien Elmes
d23764b59e Bump devalue for latest CVE 2025-09-01 13:41:00 +10:00
Damien Elmes
1dc31bb360 One step closer to tools/run-qt* on Windows
Doing the rest manually for now
2025-09-01 13:39:46 +10:00
dependabot[bot]
6fa33777db
Bump tracing-subscriber from 0.3.19 to 0.3.20 (#4296)
Bumps [tracing-subscriber](https://github.com/tokio-rs/tracing) from 0.3.19 to 0.3.20.
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-subscriber-0.3.19...tracing-subscriber-0.3.20)

---
updated-dependencies:
- dependency-name: tracing-subscriber
  dependency-version: 0.3.20
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-01 13:35:46 +10:00
Lee Doughty
2fee6f959b
Replace deprecated $app/stores with $app/state in SvelteKit frontend (#4282)
* Migrate frontend from /stores to /state

* Update CONTRIBUTORS
2025-08-26 21:28:49 +03:00
Expertium
3d0a408a2b
A small clarification in deck-config.ftl (#4264)
* A small clarification in deck-config.ftl

* Tweak wording (dae)

https://github.com/ankitects/anki/pull/4264#issuecomment-3188208351
2025-08-22 20:23:29 +10:00
user1823
3e846c8756
Make simulator fill missing values of DR and decay too (#4269)
* Make simulator fill missing values of DR and decay too

If a card has missing memory states, it will likely have missing DR and decay too. So, it makes sense to simultaneously update them as well.

* Fix error

* Avoid causing sync conflicts when filling in missing memory in sim

https://github.com/ankitects/anki/pull/4269#issuecomment-3201450124

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-08-20 03:03:53 +10:00
Abdo
79932aad41
Fix sync errors not being reported in some cases (#4281)
* Set parent of sync error dialog

* Explicitly mention parent arg in show_info() functions
2025-08-20 03:02:51 +10:00
Luc Mcgrady
2879dc63c3
Fix/Learn count not included in workload graph (#4274)
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2025-08-20 02:58:25 +10:00
Abdo
b92eabf4ae
Replace activeWindow() with activeModalWidget() (#4267) 2025-08-20 02:32:54 +10:00
Abdo
1660a22548
Fix Mnemosyne fact ID in error messages (#4266) 2025-08-20 02:32:03 +10:00
Siyuan Yan
a3b3b0850d
Hi res microhpone icon for the recording dialog (#4262)
* Replace media-record.png with SVG icon

- Added SVG version of the microphone icon (from Font Awesome Free v7.0.0)
- Updated sound.py to use QIcon for proper SVG support
- Icon now displays at 60x60 pixels

* Remove obsolete media-record.png icon

The PNG icon has been replaced with an SVG version

* Update CONTRIBUTORS

* Replace icon with AnkiMobile's record icon

CC-BY requires attribution, and we don't currently have a way to describe
those attributions in a way the mobile clients can also include automatically.
For now, I've switched it to an icon I authored myself to avoid the issue.

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2025-08-20 02:31:31 +10:00
Luc Mcgrady
562cef1f22
Fix #4253 (#4259)
* Reapply "Fix/Retention help button bounds (#4253)" (#4258)

This reverts commit fb2e2bd37a.

* move div up slots instead of using condition

* Avoid tabbing

---------

Co-authored-by: Abdo <abdo@abdnh.net>
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2025-08-20 01:19:25 +10:00
Damien Elmes
e676e1a484 Exclude version numbers from cargo/licenses.json
Version numbers are not required by the license, and keeping them in means
the build breaks after merging in a dependabot update.
2025-08-19 23:48:04 +10:00
Damien Elmes
37f7872565 Fix crash when disabling FSRS
https://forums.ankiweb.net/t/anki-25-08-beta-3/64738/51?u=dae
2025-08-19 23:34:09 +10:00
dependabot[bot]
5c07c899ec
Bump slab from 0.4.10 to 0.4.11 (#4265)
Bumps [slab](https://github.com/tokio-rs/slab) from 0.4.10 to 0.4.11.
- [Release notes](https://github.com/tokio-rs/slab/releases)
- [Changelog](https://github.com/tokio-rs/slab/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/slab/compare/v0.4.10...v0.4.11)

---
updated-dependencies:
- dependency-name: slab
  dependency-version: 0.4.11
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2025-08-19 19:59:48 +10:00
Damien Elmes
054740dd14 Skip licenses.json check for dependabot updates 2025-08-19 19:49:48 +10:00
Damien Elmes
78a3b3ef7b Expose control over AppNap for AnkiConnect
https://forums.ankiweb.net/t/recent-anki-updates-bundle-id-change-disabling-app-nap-macos-anki-connect/65550
2025-08-19 19:46:11 +10:00
Luc Mcgrady
f3b4284afb
Fix/System locale for simulator percentages (#4260)
Co-authored-by: Ross Brown <rbrownwsws@googlemail.com>
2025-08-11 06:44:11 +03:00
Damien Elmes
fb2e2bd37a
Revert "Fix/Retention help button bounds (#4253)" (#4258)
This reverts commit 5462d99255.
2025-08-09 16:46:25 +10:00
user1823
a0c1a398f4
Improve elapsed seconds calculation for learning cards in browser table (#4255)
* Improve calculation of elapsed seconds for learning cards in browser_table.rs

https://github.com/ankitects/anki/pull/4231/files#r2257105522

* Format
2025-08-09 16:16:36 +10:00
Damien Elmes
d4862e99da Bump version 2025-08-08 20:37:53 +10:00
Damien Elmes
34ed674869 Update translations 2025-08-08 20:31:05 +10:00
Damien Elmes
8c7cd80245 Support socks proxies when fetching versions 2025-08-08 20:30:51 +10:00
Damien Elmes
68bc4c02cf Add mirror option to launcher; stop downloading automatically
To give users a chance to choose a mirror first, we have to give up
the automatic downloading on first run.

Closes #4226
2025-08-08 20:30:51 +10:00
Luc Mcgrady
f4266f0142
Feat/Neaten dr graph x-axis (#4251)
* Remove "Plotted on x axis"

* Add: X tick format

* fix formatx

* Fix: Regular simualtor x axis
2025-08-08 20:30:10 +10:00
user1823
d3e8dc6dbf
Fix/Exclude new cards from is_due_in_days (#4249)
https://github.com/ankitects/anki/pull/4231/files#r2238901958
2025-08-08 20:28:13 +10:00
Luc Mcgrady
5462d99255
Fix/Retention help button bounds (#4253)
* Move onTitleClick

* rename variable

* Fix: Tabbing issues
2025-08-08 10:56:50 +03:00
Luc Mcgrady
2d60471f36
Use space-around for tabbed values (#4252)
* space-around

* have your cake and eat it
2025-08-07 06:36:53 +03:00
Jarrett Ye
62e01fe03a
Fix Cards with Missing Last Review Time During Database Check (#4237)
* Fix Cards with Missing Last Review Time During Database Check

* clippy

* Apply suggestions from code review

Co-authored-by: Luc Mcgrady <lucmcgrady@gmail.com>

* Apply suggestions from code review

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* Add is_reset method to RevlogEntry and update scheduling logic

This commit introduces the `is_reset` method to the `RevlogEntry` struct, which identifies entries representing reset operations. Additionally, the scheduling logic in `memory_state.rs` and `params.rs` has been updated to utilize this new method, ensuring that reset entries are handled correctly during review scheduling.

* Implement is_cramming method in RevlogEntry and update scheduling logic

This commit adds the `is_cramming` method to the `RevlogEntry` struct, which identifies entries representing cramming operations. The scheduling logic in `params.rs` has been updated to utilize this new method, improving the clarity and maintainability of the code.

* Refactor rating logic in RevlogEntry and update related scheduling functions

This commit introduces a new `has_rating` method in the `RevlogEntry` struct to encapsulate the logic for checking if an entry has a rating. The scheduling logic in `params.rs` and the calculation of normal answer counts in `card.rs` have been updated to use this new method, enhancing code clarity and maintainability.

* update revlog test helper function to assign button_chosen correctly

* Refactor card property fixing logic to use CardFixStats struct

* Add one-way sync trigger for last review time updates in dbcheck

* Update documentation for is_reset method in RevlogEntry to clarify ease_factor condition

* Apply suggestions from code review

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* Minor wording tweak

---------

Co-authored-by: Luc Mcgrady <lucmcgrady@gmail.com>
Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>
2025-08-06 19:49:30 +10:00
user1823
5c6e2188e2
Limit time studied today to minutes (#4242)
* Limit time studied today to minutes

* Update timespan.rs

* Update today.rs

* Update timespan.rs

* Update today.rs

* Update today.rs

* Update time.ts

* Update time.ts

* Update timespan.rs

* Update timespan.rs

* Update timespan.rs

* Update today.rs
2025-08-06 19:30:44 +10:00
llama
ab55440a05
Fix show_exception's messagebox always formatting as plaintext (#4246)
* fix show_exception's messagebox always formatting as plaintext

* Revert "fix show_exception's messagebox always formatting as plaintext"

This reverts commit aec6dd9be8.

* convert SearchError msg to markdown when in browser
2025-08-06 19:07:32 +10:00
llama
aae9f53e79
set min height for simulator graph (#4248) 2025-08-06 18:22:43 +10:00
Thomas Rixen
a77ffbf4a5
Statistics "Reviews" graph, make the color of "New" and "Learning" cards consistent with the color of card count (#4245)
* Statistics Reviews graph, make the color of New and Learning cards consistent with the color of card count

* removing bleu warning

* contributors
2025-08-06 18:07:10 +10:00
Luc Mcgrady
402008950c
Feat/expected_workload_with_existing_cards implementation (#4243)
* https://github.com/open-spaced-repetition/fsrs-rs/pull/355

* add is_included card

* bump version

* ./check

* update package.lock

* parallellify

* bump fsrs
2025-08-06 18:01:06 +10:00
Luc Mcgrady
f7e6e9cb0d
Feat/Card stats update review time (#4236)
* Feat/Card stats update review time

* Update rslib/src/stats/card.rs

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* fix

* self.storage.update_card

---------

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>
2025-08-06 17:55:50 +10:00
Jarrett Ye
2b55882cce
Fix/use real step count to simulate (#4240)
* Fix/use real step count to simulate

* Update licenses.json
2025-08-04 16:01:26 +10:00
Luc Mcgrady
0d0c42c6d9
"Workload" variable typo (#4239) 2025-08-04 16:00:27 +10:00
Luc Mcgrady
b76918a217
Feat/Show health check and already optimal at the same time (#4238) 2025-08-04 16:00:02 +10:00
user1823
f7974568c9
Update stale comment (#4235) 2025-08-04 15:31:22 +10:00
Damien Elmes
d13c117e80 Bump version 2025-07-28 21:54:44 +10:00
Damien Elmes
8932199513 Possible fix for launcher failing to appear on some Linux systems
While testing the previous PR, I noticed that if stdout is set to None,
the same behaviour is shown as in the following report:
https://forums.ankiweb.net/t/cannot-switch-versions/64565

This leads me to wonder whether IsTerminal is behaving differently
on that user's system, and the use of an env var may be more reliable.
2025-07-28 21:53:44 +10:00
Damien Elmes
69d54864a8 Fix launcher display on Tools>Upgrade/Downgrade on Windows 10
Thanks to abdo:
https://forums.ankiweb.net/t/anki-25-08-beta-3/64738/6
2025-07-28 21:43:11 +10:00
Damien Elmes
baeccfa3e4 Bump version 2025-07-28 19:19:04 +10:00
Damien Elmes
e99682a277 Update translations 2025-07-28 19:18:38 +10:00
Jarrett Ye
4dc00556c1
Fix/use current_retrievability_seconds in SQL to keep consistent with card info (#4231)
* Feat/use current_retrievability_seconds in SQL

* replace `days_since_last_review` with `seconds_since_last_review`

* Update is_due_in_days logic to include original or current due date check
2025-07-28 19:06:20 +10:00
llama
3dc6b6b3ca
Refactor IO fill tool target check logic (#4222)
* populate canvas.targets with subtargets during mouse events

* use canvas.targets instead of findTargetInGroup

* remove unused findTargetInGroup
2025-07-28 19:01:50 +10:00
Luc Mcgrady
c947690aeb
Feat/Use cached workload values (#4208)
* Feat/Use cached workload values

* Fix: Calculation when unchanged

* Modify constants

* Cache clearing logic

* Use function params

* use https://github.com/open-spaced-repetition/fsrs-rs/pull/352

* Revert "use https://github.com/open-spaced-repetition/fsrs-rs/pull/352"

This reverts commit 72efcf230c.

* Reapply "use https://github.com/open-spaced-repetition/fsrs-rs/pull/352"

This reverts commit 49eab2969f.

* ./check

* bump fsrs
2025-07-28 19:00:16 +10:00
Luc Mcgrady
1af3c58d40
Feat/Desired retention info graphs (#4199)
* backend part

* split memorised and cost

* slapdash frontend

* extract some simulator logic

* Add zoomed version of graph

* ./check

* Fix: Tooltip

* Fix: Simulator/workload transition

* remove "time"

* Update ts/routes/graphs/simulator.ts

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* Added: Mode toggle

* Disable Dr in workload mode

* keep button order consistant between modes

* dont clear points on mode swap

* add review count graph

* Revert "dont clear points on mode swap"

This reverts commit fc89efb1d9.

* "Help me pick" button

* unrelated title case change

* Add translation strings

* fix: missing translation string

* Fix: Layout shift

* Add: Experimental

* Fix Time / Memorized

* per day values

* set review limit to 9999 on open

* keep default at currently set value

* Do DR calculation in parallel (dae)

Approx 5x faster on my machine

---------

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>
Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-07-28 18:55:08 +10:00
Jarrett Ye
46bcf4efa6
Feat/per-deck desired retention (#4194)
* Feat/per-deck desired retention

* Refactor desired retention logic in Collection implementation

Updated the logic for retrieving deck-specific desired retention in both `memory_state.rs` and `mod.rs` to handle cases where the deck's normal state may not be available. This change ensures that the default configuration is used when necessary, improving the robustness of the retention handling.

* Refactor desired retention handling in FsrsOptions.svelte

Updated the logic for effective desired retention to use the configuration default instead of the deck-specific value. This change improves consistency in the retention value used throughout the component, ensuring that the correct value is bound to the UI elements.

* refactor the logic for obtaining deck-specific desired retention by using method chaining

* support deck-specific desired retention when rescheduling

* Refactor desired retention logic to use a dedicated method for improved clarity and maintainability.
2025-07-28 18:22:35 +10:00
Damien Elmes
60750f8e4c Update Uzbek language name
https://forums.ankiweb.net/t/uzbek-language-name/64725
2025-07-28 17:59:41 +10:00
Damien Elmes
661f78557f Fix sync server message failing to persist
It was disappearing immediately on macOS
2025-07-28 17:51:27 +10:00
Damien Elmes
7172b2d266 More launcher fixes
- The pyproject copy change broke the initial run case
- Avoid calling 'uv pip show' before venv created, as it causes
a pop-up prompting the user to install developer tools on macOS (#4227)
- Add a tip to the user about the unwanted install_name_tool pop-up
(Also tracked in #4227)
- Print 'Checking for updates...' prior to the potentially slow network
request
2025-07-25 23:34:50 +07:00
Damien Elmes
78c6db2023 Bump version 2025-07-25 19:12:06 +07:00
Damien Elmes
e2692b5ac9 Fix inability to upgrade/downgrade from a Python 3.9 version
Resolves AttributeError: module 'pip_system_certs.wrapt_requests' has no attribute 'inject_truststore'
2025-07-25 16:49:31 +07:00
Damien Elmes
177c483398 Stop copying updated pyproject/python pin on startup
The 'latest' and 'choose version' paths always read from the the
dist file these days, so the file doesn't need to be copied in advance.
The other reason for the current behaviour was so that when the user
manually installs a new launcher, it opens into the launcher on next
run, as that's probably what the user wanted. But this causes problems
when the launcher is updated automatically by things like homebrew.

https://forums.ankiweb.net/t/anki-homebrew-issues-terminal-and-crash-on-exit/64413/4
2025-07-25 15:40:00 +07:00
Damien Elmes
20b7bb66db Fix 'limits start from top' link 2025-07-25 14:45:04 +07:00
Damien Elmes
ca0459d8ee Use pip-system-certs when checking Anki versions 2025-07-24 21:56:15 +07:00
Damien Elmes
e511d63b7e Bump version to 25.07.4 2025-07-24 21:35:20 +07:00
Damien Elmes
d6e49f8ea5 Update translations 2025-07-24 21:35:05 +07:00
Damien Elmes
416e7af02b Pass --managed-python when fetching versions
Tentatively closes https://github.com/ankitects/anki/issues/4227
2025-07-24 21:32:23 +07:00
Damien Elmes
c74a97a5fa Increase default network timeout in launcher
https://forums.ankiweb.net/t/the-desktop-anki-app-cant-launch/64425/4
2025-07-24 20:34:43 +07:00
Damien Elmes
00bc0354c9 Provide better output when downloading versions fails
- include stdout/stderr when utf8_output() fails
- don't swallow the error returned by handle_Version_install_or_update
- skip codesigning when NODMG set

Closes #4224
2025-07-24 20:23:43 +07:00
llama
aee71afebe
set min size for card info dialog (#4221) 2025-07-24 18:55:47 +07:00
dependabot[bot]
ef69f424c1
Bump form-data from 4.0.1 to 4.0.4 (#4219)
Bumps [form-data](https://github.com/form-data/form-data) from 4.0.1 to 4.0.4.
- [Release notes](https://github.com/form-data/form-data/releases)
- [Changelog](https://github.com/form-data/form-data/blob/master/CHANGELOG.md)
- [Commits](https://github.com/form-data/form-data/compare/v4.0.1...v4.0.4)

---
updated-dependencies:
- dependency-name: form-data
  dependency-version: 4.0.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-24 18:51:12 +07:00
Damien Elmes
19f9afba64 Start requiring two channels for recording
Closes #4225
2025-07-24 18:49:29 +07:00
Damien Elmes
229337dbe0 Work around Conda breaking launcher
Closes #4216
2025-07-24 18:40:41 +07:00
llama
1f3d03f7f8
add io mask rotation snapping (#4214) 2025-07-22 14:32:42 +03:00
user1823
47c1094195
Add last_review_time to _to_backend_card (#4218)
Presumably, without this change, add-ons would delete the value of last_review_time from the card when they modify the card.
2025-07-22 14:26:44 +03:00
llama
35a889e1ed
Prioritise prefix matches in tag autocomplete results (#4212)
* prioritise prefix matches in tag autocomplete results

* update/add tests

* fix lint

was fine locally though?
2025-07-22 14:11:33 +03:00
Damien Elmes
65b5aefd07 Bump version to 25.07.3 2025-07-21 15:00:46 +07:00
Damien Elmes
8c72b03f4c Bump version
Preparing for another 25.07.x release
2025-07-19 00:56:16 +07:00
Damien Elmes
fc845a11a9 Update translations 2025-07-19 00:56:16 +07:00
Damien Elmes
aeaf001df7 Hack back in a fix for lack of ANSI codes on Windows 10
There must be a better way to do this, but someone more familiar
with Win32 internals than I will need to discover it.

https://forums.ankiweb.net/t/anki-25-08-beta/63645/61
2025-07-19 00:40:16 +07:00
Damien Elmes
a3da224511 Possible fix for error getting current version in launcher
https://forums.ankiweb.net/t/anki-25-08-beta/63645/68
2025-07-19 00:40:16 +07:00
Abdo
63ddd0e183
Fix wrong tab order in preferences (#4210) 2025-07-18 22:20:10 +07:00
Damien Elmes
278a84f8d2 Fix 'same cloze' shortcut on macOS
https://forums.ankiweb.net/t/mac-shortcut-for-cloze-deletion-same-card/63785
2025-07-18 18:12:30 +07:00
Danika-Dakika
0b30155c90
Adding to about.py (#4211)
Adding a Hebrew translator.
2025-07-18 04:05:01 +03:00
Damien Elmes
37fe704326 Tweak protobuf requirements
Motivated by https://forums.ankiweb.net/t/python-anki-sync-server-broken/64069

From https://protobuf.dev/support/cross-version-runtime-guarantee/:
"Python-specific Guarantees
Since the 3.20.0 release, the Protobuf Python generated code became a thin wrapper around an embedded FileDescriptorProto. Because these protos are supported on extremely long timeframes, our usual major version compatibility windows aren’t typically necessary.

Python may break generated code compatibility in specific future major version releases, but it will be coupled with poison pill warnings and errors in advance. As of 6.32.0, all generated code since 3.20.0 will be supported until at least 8.x.y."
2025-07-16 14:15:25 +07:00
Damien Elmes
e77cd791de Bump version 2025-07-15 22:26:46 +07:00
Damien Elmes
4e29440d6a Version the launcher 2025-07-15 22:26:46 +07:00
Damien Elmes
cc4b0a825e Update translations 2025-07-15 20:45:38 +07:00
Damien Elmes
15bbcdd568 Downgrade Chromium as potential rendering fix
https://forums.ankiweb.net/t/anki-25-08-beta/63645/57
2025-07-15 18:26:02 +07:00
Damien Elmes
12635f4cd2 Show Chromium version in About instead of PyQt version 2025-07-15 18:25:11 +07:00
Damien Elmes
834fb41015 Exclude VIRTUAL_ENV from environ as well
https://forums.ankiweb.net/t/anki-25-08-beta/63645/51
2025-07-15 17:03:51 +07:00
user1823
5a19027185
Minor tweak in simulator string (#4204) 2025-07-15 16:59:06 +07:00
llama
0375b4aac0
fix default-coloured io masks not following css var (#4202) 2025-07-14 01:22:14 +03:00
sorata
a1934ae9e4
update preferences.ftl (#4196) 2025-07-13 22:35:21 +03:00
Bradley Szoke
58a8aa7353
fix: set cursor to pointer when on range (#4197)
* set cursor to pointer when on range

* chore: white space removal

* chore: update contributors file
2025-07-13 22:29:23 +03:00
jcznk
4604bc7567
Add margin to QPushButton to prevent clipping (#4201)
* Update CONTRIBUTORS

* Add margin to QPushButton to prevent clipping
2025-07-13 22:21:31 +03:00
Damien Elmes
3b18097550 Support user pyproject modifications again
This changes 'keep existing version' to 'sync project changes'
when changes to the pyproject.toml file have been detected that
are newer than the installer's version.

Also adds a way to temporarily enable the launcher, as we needed some
other trigger than the pyproject.toml file anyway, and this approach
also solves #4165.

And removes the 'quit' option, since it's an uncommon operation, and
the user can just close the window instead.

Short-term caveat: users with older launchers/addon will trigger the old
pyproject.toml mtime bump, leading to a 'sync project changes' message
that will not make much sense to a typical user.
2025-07-13 00:58:13 +07:00
GithubAnon0000
c56fd3ee28
FIX Graph Tooltip uses wrong font (#4193) 2025-07-12 13:41:22 +07:00
Damien Elmes
f4e587256c Retention rate -> retention
https://forums.ankiweb.net/t/rename-true-retention-retention-rate/63446/5

Closes #4190
2025-07-12 13:38:16 +07:00
Damien Elmes
51cf09daf3 Strip only UV_* env vars
If we don't preserve env vars like TEMP, it results in run failures
on Windows:
https://forums.ankiweb.net/t/anki-25-08-beta/63645/28
2025-07-09 21:38:45 +07:00
Kevin Nakamura
dfbb7302e8
set UV_PYTHON_DOWNLOADS=auto when doing uv sync (#4191)
* set UV_PYTHON_DOWNLOADS=auto when doing `uv sync`

* Clear env vars prior to invoking uv, and add --no-config

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-07-09 17:57:37 +07:00
Jarrett Ye
1f7f7bc8a3
Fix/FSRS simulator fallback to memory_state_from_sm2 when converting cards (#4189)
* Fix/FSRS simulator fallback to memory_state_from_sm2 for after setting “Ignore cards reviewed before”

* add comment to fsrs_item_for_memory_state

* Add historical retention field to FSRS review request and update related logic

- Added `historical_retention` field to `SimulateFsrsReviewRequest` in `scheduler.proto`.
- Updated `simulator.rs` to use `req.historical_retention` instead of the removed `desired_retention`.
- Modified `FsrsOptions.svelte` to include `historicalRetention` in the options passed to the component.

* Update rslib/src/scheduler/fsrs/memory_state.rs

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* Update rslib/src/scheduler/fsrs/simulator.rs

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* pass ci

* Update rslib/src/scheduler/fsrs/simulator.rs

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* format

* Update rslib/src/scheduler/fsrs/simulator.rs

Co-authored-by: Luc Mcgrady <lucmcgrady@gmail.com>

* format

* Fix condition in is_included_card function to check CardType instead of CardQueue

---------

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>
Co-authored-by: Luc Mcgrady <lucmcgrady@gmail.com>
2025-07-09 16:22:59 +07:00
Jarrett Ye
208729fa3e
Skip unnecessary computations when the load balancer is disabled (#4184)
* Only get_deck_config when load balancer is enabled

* Refactor load balancer card addition logic to use pre-fetched deckconfig_id

* Refactor get_scheduling_states to use context for deck configuration
2025-07-08 16:29:36 +07:00
Kevin Nakamura
6744a0a31a
Re-order terminals, again, for better UX. (#4186)
* Re-order terminals, again, for better UX.

* Move x-terminal-emulator up (dae)
2025-07-08 16:29:07 +07:00
Damien Elmes
1ad82ea8b5 Avoid UV_PRERELEASE=allow
It had some downsides:
- the lockfile was discarded when switching between beta/non-beta
- it could result in beta versions of transitory dependencies

By adding 'anki' and 'aqt' as first-party packages with explicit
version numbers (validated by the version list we get from PyPi),
we can allow them to be installed without breaking other deps.

https://forums.ankiweb.net/t/bundling-numpy-in-an-add-on/62669/15
2025-07-08 15:32:54 +07:00
Damien Elmes
1098d9ac2a enter -> Enter 2025-07-08 12:51:08 +07:00
Damien Elmes
778ab76586 Work around gnome-terminal failing to appear 2025-07-08 12:51:07 +07:00
Damien Elmes
c57b7c496d Bump version 2025-07-08 01:15:30 +07:00
Damien Elmes
fabed12f4b Update to Qt 6.9.1 2025-07-08 01:14:40 +07:00
Damien Elmes
84658e9cec Rename tarball folder to match tarball name 2025-07-08 01:11:55 +07:00
llama
11c3e60615
Debounce mathjax rendering via cooldown instead (#4173)
* add cooldown timer

* debounce mathjax rendering via cooldown instead
2025-07-08 00:56:13 +07:00
GithubAnon0000
3d9fbfd97f
Use system font for webviews instead of bootstrap font stack and add exception for note editor (#4163)
* Revert "Revert "Use system font for webviews instead of bootstrap font stack …"

This reverts commit d1793550b0.

* Update editor-base.scss
2025-07-08 00:51:44 +07:00
llama
80ff9a120c
Allow creating deck via #deck:... if non-existent when importing (#4154)
* add deck name field to metadata protobuf msg

* fallback to creating new deck specified in `#deck:...`

* update tests

* create deck if it doesn't exist

* plumbing

* allow creating deck via `#deck:...`

* apply suggestion for protobuf
2025-07-08 00:46:04 +07:00
Jarrett Ye
037dfa1bc1
Add last_review_time to card data for performance and accuracy (#4124)
* Add `last_review_time` to card data

* cargo clippy

* Calculate days elapsed since last review time in add_extract_fsrs_relative_retrievability

* expose last_review_time to Card in Python

* Fix last_review_time assignment in Card class to use last_review_time_secs

* format

* Update last_review_time assignment to exclude filtered preview state in Card class
2025-07-08 00:41:01 +07:00
Damien Elmes
3adcf05ca6 Bump version to 25.07.2 2025-07-07 23:49:54 +07:00
Damien Elmes
3bd725b6be Add Uzbek to the list of available languages 2025-07-07 23:49:37 +07:00
Damien Elmes
0009e798e1 Update translations 2025-07-07 23:47:02 +07:00
Damien Elmes
436a1d78bc On first run, automatically download the latest version 2025-07-07 23:46:33 +07:00
Damien Elmes
2e74101ca4 Show recent versions in launcher
Did it with Python to avoid bloating the launcher binary with
network code
2025-07-07 23:46:33 +07:00
Lucio Sauer
7fe201d6bd
aqt wheel: fix unintended inclusion of qt/aqt/data (#4180)
The inclusion of files under qt/aqt is handled by qt/pyproject.toml,
not qt/hatch_build.py, which works with the files under out/qt/_aqt.

Excluding qt/aqt/data and all files ending in .ui in qt/pyproject.toml
fixes the issue, since the other unwanted files (**/*.scss, **/*.ts, and
**/tsconfig*) all reside under qt/aqt/data.

Fixes: 04996c77f3
2025-07-07 23:44:08 +07:00
Luc Mcgrady
8a3b72e6e5
Fix/Help modal appears behind simulator modal (#4171)
* Fix/Help modal appears behind simulator modal

* Correct help modal keys (Doesn't work)
2025-07-07 16:21:46 +07:00
Luc Mcgrady
d3e1fd1f80
Feat/Replace easy day table with display:grid (#4179)
* Feat/Replace easy day table with grid

* Add max width
2025-07-07 15:46:52 +07:00
Kevin Nakamura
3d6b4761e4
Try unix terminals in roughly most specific to least specific. (#4177) 2025-07-07 15:44:39 +07:00
GithubAnon0000
1ca31413f7
FIX revert button is visible for screenreaders (#4174) 2025-07-07 15:23:39 +07:00
Alexander Bocken
b205008a5e
respect env var UV_BINARY with OFFLINE_BUILD being set (#4170)
* respect env var UV_BINARY with OFFLINE_BUILD being set

* cleanup formatting, fix import

* Fix build error (dae)
2025-07-07 15:16:00 +07:00
Luc Mcgrady
b16439fc9c
Feat/Confirmation box for save options to preset (#4172) 2025-07-07 15:10:24 +07:00
Kevin Nakamura
f927aa5788
Statically link MSVC runtime, removing the need to install the redistributable (#4166)
* Statically link MSVC runtime, removing the need to install the redistributable.

* CONTRIBUTORS I've already contributed and added my email, but the last commit got mangled.
2025-07-05 15:03:14 +03:00
Damien Elmes
a83a6b5928 Update translations 2025-07-05 01:39:33 +07:00
sorata
052b9231ec
rename: true retention > retention rate (#4164) 2025-07-05 01:39:12 +07:00
Damien Elmes
1b51c16e26 Bump version to 25.07.1 2025-07-05 01:37:43 +07:00
Damien Elmes
de2d1477de Hack in a message about the launcher add-on
We can't show an AnkiWeb page for a locally-installed add-on, and
having a custom config action is the only way we can easily expose
this for older clients as well.

Re: #4158
2025-07-05 01:37:42 +07:00
Damien Elmes
ccc0c7cdbb Add --managed-python to uv python install invocation
https://github.com/ankitects/anki/pull/4162#issuecomment-3036984410
2025-07-05 01:36:39 +07:00
Damien Elmes
deaf25f757 Add an ankiw script to make running on Windows easier 2025-07-05 01:36:35 +07:00
Damien Elmes
93dbd6e4cf Update translations
(cherry picked from commit 09495d3a8b,
as #4162 accidentally reverted them)
2025-07-04 23:57:32 +07:00
Damien Elmes
7b0289b5d3 Use a (soon-to-be) real version number in example
Closes #4160
2025-07-04 23:53:44 +07:00
GithubAnon0000
08a8b6691c
ADD a Contributor to about.py (#4161)
* ADD a Contributor to CONTRIBUTORS

As requested in https://forums.ankiweb.net/t/anki-contributors-list/63493

* RM contrib from CONTRIBUTORS

* Add contrib to about.py
2025-07-04 23:47:56 +07:00
Kevin Nakamura
fc6447a938
Launcher: Run uv python install before running uv sync (#4162)
* Launcher: Run `uv python install` before running `uv sync`

* Less copy/paste.

* Minor readability improvements

* Make sure we check file presence before attempting to read

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-07-04 23:35:50 +07:00
Damien Elmes
d1793550b0
Revert "Use system font for webviews instead of bootstrap font stack (#4147)" (#4159)
This reverts commit 0b5218706a.
2025-07-04 21:22:30 +07:00
Damien Elmes
cedece5cae Fix glibc version check in Linux installer
I'd changed it for testing, and accidentally committed it.
2025-07-04 17:20:05 +07:00
Damien Elmes
2594dcb2bb Bump version to 25.07
I'd normally do an RC before a stable release, but this is going to
be a "soft release", and with beta updates off by default in the launcher,
jumping straight to a stable release avoids the initial install problems.
2025-07-04 15:49:17 +07:00
Damien Elmes
09495d3a8b Update translations 2025-07-04 15:47:06 +07:00
Luc Mcgrady
f5285f359a
Feat/Add legacy evaluate config bool (#4149)
* Feat/Add legacy evaluate config bool

* Minor tweaks based on PR suggestions (dae)

New enabling command:

from anki.config import Config
mw.col.set_config_bool(Config.Bool.FSRS_LEGACY_EVALUATE, True)
2025-07-04 15:32:09 +07:00
llama
fba1d7b4b0
reuse blank deck created while importing if deck column is empty (#4150) 2025-07-04 14:48:35 +07:00
Luc Mcgrady
4232185735
Feat/Add globe to help tooltip (#4148)
* Add global option to HelpItem

* Fix: Spacing

* add to more sections

* Fix: Spacing again
2025-07-04 14:42:40 +07:00
GithubAnon0000
0b5218706a
Use system font for webviews instead of bootstrap font stack (#4147) 2025-07-04 14:41:58 +07:00
Damien Elmes
bb1b289690 Add some helpers to allow add-ons to install packages into the venv
While something we probably don't want to encourage much of, this
may enable some previously-unshared add-ons.

https://forums.ankiweb.net/t/bundling-numpy-in-an-add-on/62669/5

The 'uv add' command is transaction, so if an add-on tries to inject
incompatible dependencies into the environment, the venv will be
left as-is. And each Anki upgrade/downgrade resets the requirements,
so the requested packages shouldn't cause errors down the line.

Sample add-on:

import subprocess
from aqt import mw
from aqt.operations import QueryOp
from aqt.qt import QAction
from aqt.utils import showInfo

def ensure_spacy(col):
    print("trying to import spacy")
    try:
        import spacy
        print("successful import")
        return
    except Exception as e:
        print("error importing:", e)

    print("attempting add")
    try:
        from aqt.package import add_python_requirements as add
    except Exception as e:
        raise Exception(f"package unavailable, can't install: {e}")
    # be explicit about version, or Anki beta users will get
    # a beta wheel that may break
    (success, output) = add(["spacy==3.8.7", "https://github.com/explosion/spacy-models/releases/download/ko_core_news_sm-3.8.0/ko_core_news_sm-3.8.0-py3-none-any.whl"])
    if not success:
        raise Exception(f"adding failed: {output}")

    print("success")

    # alterantively:
    # from aqt.package import venv_binary
    # subprocess.run([venv_binary("spacy"), "download", "ko_core_news_sm"], check=True)
    # print("model added")

    # large packages will freeze for a while on first import on macOS
    import spacy
    print("spacy import successful")

def activate_spacy():
    def on_success(res):
        mw.progress.single_shot(1000, lambda: showInfo("Spacy installed"))

    QueryOp(parent=mw, op=ensure_spacy, success=on_success).with_progress("Installing spacy...").run_in_background()

action = QAction("Activate Spacy", mw)
action.triggered.connect(activate_spacy)
mw.form.menuTools.addAction(action)
2025-07-04 14:23:04 +07:00
Damien Elmes
e81a7e8b1a Stop enabling betas by default 2025-07-02 12:57:02 +07:00
Damien Elmes
da90705346 Re-expose legacy RMSE calculations
Closes #4143
2025-07-01 18:22:55 +07:00
Damien Elmes
9e1690774c Update svelte/vite/esbuild for CWEs 2025-07-01 18:01:48 +07:00
Damien Elmes
ee5e8c9230 Update to latest node LTS; add update helper 2025-07-01 17:06:27 +07:00
llama
b6c70f7b75
Add search keyword to strip clozes beforehand (#4145)
* add strip_clozes fn

* add test

* replace without_combining with process_text

* update write_unqualified

* update write_regex

* add `sc:...` search option

* add test

* strip clozes before stripping combining characters

find_notes_sc           time:   [1.0398 s 1.0405 s 1.0412 s]
                        change: [-6.1276% -6.0323% -5.9401%] (p = 0.00 < 0.05)
                        Performance has improved.

* add bitflags crate

* add and use ProcessTextFlags

* update sqlwriter.rs to use bitflags
2025-07-01 16:35:21 +07:00
Lukas Sommer
944e453419
Comments for translators (#4137)
* Update deck-config.ftl

* Update ftl/core/deck-config.ftl

Co-authored-by: Luc Mcgrady <lucmcgrady@gmail.com>

---------

Co-authored-by: Luc Mcgrady <lucmcgrady@gmail.com>
2025-07-01 16:10:34 +07:00
llama
14eb297bbf
add "copy debug info" button to show_exception's dialog (#4146) 2025-07-01 15:35:50 +07:00
Damien Elmes
a07370f565 Add a trademark symbol to the readme and about screens 2025-07-01 11:40:03 +07:00
Damien Elmes
bf36e10519 Hide CMRR
https://forums.ankiweb.net/t/anki-25-06-beta/62271/156
2025-07-01 11:20:28 +07:00
Damien Elmes
b22b3310d6 Revert "Feat/Cmrr target selector (#4116)"
This reverts commit ad0dbb563a.

https://forums.ankiweb.net/t/anki-25-06-beta/62271/156
2025-07-01 11:20:20 +07:00
Matt Brubeck
7720c7de1a
Only run empty_filtered_deck on filtered decks. (#4139)
Fixes #4138.
2025-06-30 16:47:14 +07:00
Damien Elmes
0be87b887e Add category type
Unsure if this helps; the app is not even showing in the screen time
list for me at the moment.

https://forums.ankiweb.net/t/correct-apple-screen-time-category-macos-ios/62962
2025-06-30 14:28:37 +07:00
Damien Elmes
bce3cabf9b Friendlier error when glibc too old, and properly declare min macOS 2025-06-30 14:20:42 +07:00
Damien Elmes
ad34b76fa9 Do anki_release upload last 2025-06-29 22:30:20 +07:00
Damien Elmes
e0727b1bc8 Bump version 2025-06-29 22:17:01 +07:00
Damien Elmes
18cac8bbe5 Update translations 2025-06-29 22:17:01 +07:00
Damien Elmes
045e571edf Support hidden local Claude config 2025-06-29 22:16:59 +07:00
Damien Elmes
469fd763c7 Fix taskbar pinning on Windows
Closes #4107
2025-06-29 20:53:43 +07:00
Damien Elmes
6eb1db0f5d Switch to the windows crate 2025-06-29 16:49:20 +07:00
Damien Elmes
349a696f93 Fix transient console pop-ups on Windows 2025-06-29 16:46:45 +07:00
Damien Elmes
66f34da7ef Fix lint, and ensure Rust checks get re-run on launcher change 2025-06-29 15:54:31 +07:00
Damien Elmes
3d7dc32777 Add a 'revert to previous version' action + more
- Show current version
- Ensure uv builds switch to python 3.13
2025-06-29 15:51:15 +07:00
llama
58dfb9cdd3
fix deck options page being scrollable while simulator modal is open (#4133) 2025-06-29 14:42:52 +07:00
GithubAnon0000
185fdebb63
Followup to #4122 (make text selectable) (#4132) 2025-06-29 14:42:19 +07:00
Luc Mcgrady
0739ea58f8
Add disclaimer to workload tooltip (#4131) 2025-06-29 14:41:35 +07:00
Damien Elmes
5c23ac5a86
Revert "Fix/unapplied scss (#4103)" (#4136)
This reverts commit ae6cf98f40.
2025-06-29 14:40:56 +07:00
Abdo
f94d05bcbe
Switch to Ruff (#4119)
* Add check:ruff build action

* Add fix:ruff action

* Add Ruff config

Mostly generated by Cursor

* Handle rest of lints

* Fix formatting

* Replace black and isort with ruff-format

* Run ruff-format

* Fix lint errors

* Remove pylint disables

* Remove .pylintrc

* Update docs

* Fix check:format not just checking

* Fix isort rule being ignored

* Sort imports

* Ensure ./ninja format also handles import sorting

* Remove unused isort cfg

* Enable unsafe fixes in fix:ruff, and enable unused var warning

* Re-run on config change; enable unnecessary ARG ignores

* Use all pycodestyle errors, and add some more commented-out ones

Latter logged on https://github.com/ankitects/anki/issues/4135
2025-06-29 14:38:35 +07:00
Damien Elmes
b8963b463e Fix Windows CI and minor display tweak 2025-06-29 13:54:17 +07:00
Damien Elmes
bdb3c714dc Put Python install inside uv root as well 2025-06-29 13:42:15 +07:00
Damien Elmes
731e7d5b5c Add uninstall support to launcher 2025-06-29 13:32:06 +07:00
Damien Elmes
f89ab00236 Update to Rust 1.88
We'll need to handle https://github.com/ankitects/anki/issues/4134 before
we get access to let chains.
2025-06-29 11:50:49 +07:00
Damien Elmes
b872852afe Store uv cache inside AnkiProgramFiles, and allow disabling 2025-06-29 11:50:49 +07:00
Damien Elmes
aa8dfe1cf4 Fix icon/menu entries on macOS after update
We need to exec() Python from a GUI context so that the app name and
icon are inherited from our launcher bundle. And we need to munge
sys.argv[0] prior to main window instantiation so that we don't get
app menu entries like "Hide -c". We do that in the launcher instead
of __init__.py so that older versions display correctly too.
2025-06-29 11:50:49 +07:00
Damien Elmes
f5073b402a Inject Upgrade/Downgrade menu item and audio support into older versions 2025-06-29 11:50:49 +07:00
GithubAnon0000
a587343f29
FIX: Margin between icon was selectable but shouldn't be (#4122) 2025-06-28 21:47:29 +03:00
GithubAnon0000
cfeb71724d
CHANGE right-click in the editor to show option to open folder in linux (#4125)
* CHANGE right-click in the editor to show option to open folder in linux

* FIX checks

* Use heuristics

* ./ninja format

* Use fallback from main instead of xdg-open
2025-06-28 21:33:17 +03:00
Damien Elmes
aae970bed9 Bump version 2025-06-27 21:08:56 +07:00
Damien Elmes
63dcfde005 Update translations 2025-06-27 21:08:56 +07:00
Jarrett Ye
fe5dfe9ec2
Fix/update card.decay in card_state_updater (#4127) 2025-06-27 16:50:29 +07:00
David Allison
5f73725a64
Remove newline: 'Restore to default confirmation' (#4128) 2025-06-27 16:50:06 +07:00
Luc Mcgrady
ad0dbb563a
Feat/Cmrr target selector (#4116)
* backend

* Add: Frontend

* us

* Added: Loss aversion

* change proto format

* Added: Loss aversion

* Added: Future retention targets

* update default fail cost multiplier

* Future Retention -> Post Abandon Memorized

* superfluous as const

* Fix: Wrong default

* Fix: Wrong import order
2025-06-27 16:44:19 +07:00
Luc Mcgrady
e505ca032b
Fix/Add check_output_timestamps to PythonEnvironment (#4113)
* Fix/explicitly set restat

* Revert "Fix/explicitly set restat"

This reverts commit ace2e5ef6a.

* add check_output_timestamps to python.rs
2025-06-27 16:41:50 +07:00
Abdo
fdce765861
Make PYTHONPYCACHEPREFIX point to an absolute path (#4111) 2025-06-27 16:36:27 +07:00
Luc Mcgrady
ae6cf98f40
Fix/unapplied scss (#4103)
* deck options + change notetype

* graphs

* image occlusion

* congrats

* imports

* ./check

* style

* $lib

* delete unused index.ts files
2025-06-27 16:28:35 +07:00
Damien Elmes
bedab0a54b Drop psutil from wheel requirements
We're not using it ourselves, and usage appears isolated to a couple of
add-ons (notably ankirestart)
2025-06-27 16:10:12 +07:00
Damien Elmes
de7de82f76 Refactor launcher + various tweaks
- Launcher can now be accessed via Tools>Upgrade/Downgrade
- Anki closes automatically on update
- When launcher not available, show update link like in the past
- It appears that access to the modern console host requires an app
to be built with the windows console subsystem, so we introduce an
extra anki-console.exe binary to relaunch ourselves with. Solves
https://forums.ankiweb.net/t/new-online-installer-launcher/62745/50
- Windows now requires you to close the terminal like on a Mac,
as I couldn't figure out how to have it automatically close. Suggestions
welcome!
- Reduce the amount of duplicate/near-duplicate code in the various
platform files, and improve readability
- Add a helper to install the current code into the launcher env
- Fix cargo test failing to build on ARM64 Windows
2025-06-27 16:10:12 +07:00
Damien Elmes
73edf23954 Drop Pauker and SuperMemo importers from legacy importer
The legacy importer has only been kept around to support some add-ons,
and these are so infrequently used that they're better off shifted
to add-ons (even they even still work)
2025-06-27 16:10:12 +07:00
Damien Elmes
9b287dc51a Python dependency/wheel tweaks
- Use --locked to assert that the lockfile won't change, so we need
to explicitly 'uv lock' when making changes. Still trying to get to
the bottom of why the lockfile sometimes has editable entries, which
break things when switching between platforms.
- Exclude __pycache__ from wheels
- Move the typing stubs to our dev deps
(https://github.com/ankitects/anki/pull/4074#pullrequestreview-2948088436)
2025-06-27 16:10:12 +07:00
Damien Elmes
7edd9221ac Avoid Qt's automatic About labeling
It gets confused by our launcher process, and provides no way to
alter the default assigned text while keeping the About role on a Mac.
2025-06-27 16:10:12 +07:00
Luc Mcgrady
630bdd3189
Fix/Optimize button alignment (#4117)
* Fix/Button alignment

* add hr
2025-06-25 16:44:47 +03:00
Jarrett Ye
992fb054bd
Refactor FSRS data clearing into Card::clear_fsrs_data (#4123)
Extracted repeated logic for clearing FSRS-related fields into a new Card::clear_fsrs_data() method. Updated set_deck and FSRS disabling code paths to use this method for improved code reuse and maintainability.
2025-06-25 16:40:51 +03:00
llama
d6f93fab76
adjust top toolbar height on body class update (#4120) 2025-06-25 14:20:31 +03:00
llama
06195d1268
add bottom and right margins to account for focus outline (#4115) 2025-06-25 14:15:45 +03:00
llama
a73f1507ba
use KeyboardEvent.key instead of code (#4114) 2025-06-25 14:08:25 +03:00
Damien Elmes
b250a2f724 Add terminal support for *nix 2025-06-22 21:52:44 +07:00
Damien Elmes
d2f818fad2 macOS launcher improvements
- do mpv initial run in parallel
- improve messages, show dots regularly
2025-06-22 21:03:02 +07:00
Damien Elmes
eb6c977e08 Add menu to launcher, and improve terminal display on Windows 2025-06-22 20:25:15 +07:00
Damien Elmes
782645d92e Bump beta version 2025-06-21 19:17:48 +07:00
Damien Elmes
246fa75a35 Create release wheel as part of normal build
Avoids the need for a separate publish
2025-06-21 19:17:48 +07:00
Damien Elmes
cfd448565a Fix sync-server separate compile
https://forums.ankiweb.net/t/anki-25-06-beta/62271/96
2025-06-21 19:17:48 +07:00
user1823
5cc3a2276b
Fix repeated ticks in reviews graph (#4108)
Regressed in #4086
2025-06-21 19:17:18 +07:00
user1823
c28306eb94
Save dr and decay in card even if item is None (#4106)
* Document the purpose of storing dr and decay in card

* Format

* Fix type mismatch errors

* Update memory_state.rs

* Save dr and decay in card even if item is None

* Format

* Fix mismatched types

* Update memory_state.rs
2025-06-21 19:16:54 +07:00
Jarrett Ye
88538d8bad
Fix/set due date on intraday learning card (#4101)
- Introduced `next_day_start` parameter to `set_due_date` for improved due date handling.
- Updated logic to account for Unix epoch timestamps when calculating due dates.
2025-06-21 19:15:30 +07:00
llama
cc395f7c44
Upgrade to nom 8.0.0 (#4105)
* bump nom to 8.0.0

* update cloze.rs

* update template.rs

* update imageocclusion.rs

* update search/parser.rs

* update card_rendering/parser.rs

* replace use of fold_many0 with many0

in nom 8, `many0` doesn't accumulate when used within `recognize`
2025-06-21 19:15:19 +07:00
Jarrett Ye
a4c95f5fbd
include decay in ComputeMemoryStateResponse (#4102)
* include decay in ComputeMemoryStateResponse

* Add decay attribute to ComputedMemoryState and update Collection methods

* Refactor decay calculation into a helper function for improved readability and maintainability in memory state management

* format & clippy
2025-06-20 20:59:35 +03:00
Damien Elmes
b781dfabf5 Add helpers to run Qt 6.7 and 6.9
Removed the 6.8 one, as that's our default
2025-06-20 21:55:38 +07:00
Damien Elmes
718f39fdf3 Temporarily force-enable prereleases
Some users are struggling to read or understand the steps to enable
it.
2025-06-20 19:05:30 +07:00
Damien Elmes
b2dc5a0263 Bump version 2025-06-20 16:52:25 +07:00
Damien Elmes
d542ae9065 Fix check action on Windows ARM
- Update nextest (not required)
- Build nextest without self-update, which pulls in ring
- Disable running of tests in rsbridge, as it has no tests, and
requires host arch's python.lib to execute
- A double \ in CARGO_TARGET_DIR was breaking update_* tests
2025-06-20 16:52:25 +07:00
Damien Elmes
cd71931506 Launcher tweaks
- Handle beta/rc tags in .version when launching Anki
- Update pyproject.toml/.python_version if distributed version newer
- Support prerelease marker to opt in to betas
- Check for updates when using uv sync
- Avoid system Python by default, as it can cause breakages
(e.g. ARM Python installed on Windows)
2025-06-20 16:13:50 +07:00
Damien Elmes
4abc0eb8b8 Use same version for anki-release; publish to main index 2025-06-20 16:13:50 +07:00
Damien Elmes
a60a955c61 Handle beta/rc tags, bump beta, add exact version pin to aqt 2025-06-20 16:13:50 +07:00
Damien Elmes
a41c60c016 Trigger uv sync if user approves update 2025-06-20 16:13:50 +07:00
Damien Elmes
8e20973c52 Drop remaining qt5 code 2025-06-20 16:13:50 +07:00
Damien Elmes
cd411927cc Split libankihelper into a separate module
It's rarely updated, and the old approach resulted in a 'proper' aqt
build only being done on a Mac.
2025-06-20 16:13:49 +07:00
Damien Elmes
344cac1ef4 Update translations 2025-06-19 14:42:08 +07:00
Damien Elmes
f98f620116 Avoid committing release deps
These will only get bumped on a new publish, and keeping the file
around leads to spurious security alerts.
2025-06-19 14:14:57 +07:00
Damien Elmes
04996c77f3
Migrate build system to uv (#4074)
* Migrate build system to uv

Closes #3787, and is a step towards #3081 and #4022

This change breaks our PyOxidizer bundling process. While we probably
could update it to work with the new venvs & lockfile, my intention
is to use this as a base to try out a uv-based packager/installer.

Some notes about the changes:

- Use uv for python download + venv installation
- Drop python/requirements* in favour of pyproject files / uv.lock
- Bumped to latest Python 3.9 version. The move to 3.13 should be
a fairly trivial change when we're ready.
- Dropped the old write_wheel.py in favour of uv/hatchling. This has
the unfortunate side-effect of dropping leading zeros in our wheels,
which we could try hack around in the future.
- Switch to Qt 6.7 for the dev repo, as it's the first PyQt version
with a Linux/ARM WebEngine wheel.
- Unified our macOS deployment target with minimum required for ARM.
- Dropped unused fluent python files
- Dropped unused python license generation
- Dropped helpers to run under Qt 5, as our wheels were already
requiring Qt 6 to install.

* Build action to create universal uv binary

* Drop some PyOxidizer-related files

* Use Windows ARM64 cargo/node binaries during build

We can't provide ARM64 wheels to users yet due to #4079, but we can
at least speed up the build.

The rustls -> native-tls change on Windows is because ring requires
clang to compile for ARM64, and I figured it's best to keep our Windows
deps consistent. We already built the wheels with native-tls.

* Make libankihelper a universal library

We were shipping a single arch library in a purelib, leading to
breakages when running on a different platform.

* Use Python wheel for mpv/lame on Windows/Mac

This is convenient, but suboptimal on a Mac at the moment. The first
run of mpv will take a number of seconds for security checks to run,
and our mpv code ends up timing out, repeating the process each time.
Our installer stub will need to invoke mpv once first to get it validated.

We could address this by distributing the audio with the installer/stub,
or perhaps by putting the binaries in a .pkg file that's notarized+stapled
and then included in the wheel.

* Add some helper scripts to build a fully-locked wheel

* Initial macOS launcher prototype

* Add a hidden env var to preload our libs and audio helpers on macOS

* qt/bundle -> qt/launcher

- remove more of the old bundling code
- handle app icon

* Fat binary, notarization & dmg

* Publish wheels on testpypi for testing

* Use our Python pin for the launcher too

* Python cleanups

* Extend launcher to other platforms + more

- Switch to Qt 6.8 for repo default, as 6.7 depends on an older
libwebp/tiff which is unavailable on newer installs
- Drop tools/mac-x86, as we no longer need to test against Qt 5
- Add flags to cross compile wheels on Mac and Linux
- Bump glibc target to 2_36, building on Debian Stable
- Increase mpv timeout on macOS to allow for initial gatekeeper checks
- Ship both arm64 and amd64 uv on Linux, with a bash stub to pick
the appropriate arch.

* Fix pylint on Linux

* Fix failure to run from /usr/local/bin

* Remove remaining pyoxidizer refs, and clean up duplicate release folder

* Rust dep updates

- Rust 1.87 for now (1.88 due out in around a week)
- Nom looks involved, so I left it for now
- prost-reflect depends on a new prost version that got yanked

* Python 3.13 + dep updates

Updated protoc binaries + add helper in order to try fix build breakage.
Ended up being due to an AI-generated update to pip-system-certs that
was not reviewed carefully enough:
https://gitlab.com/alelec/pip-system-certs/-/issues/36

The updated mypy/black needed some tweaks to our files.

* Windows compilation fixes

* Automatically run Anki after installing on Windows

* Touch pyproject.toml upon install, so we check for updates

* Update Python deps

- urllib3 for CVE
- pip-system-certs got fixed
- markdown/pytest also updated
2025-06-19 14:03:16 +07:00
user1823
bbf533b172
Update the default value of FSRS-6 decay in forgetting curve (#4096)
Changed in 037345fd57
2025-06-19 13:25:30 +07:00
user1823
ba0d590c16
Clear desired retention and decay when changing decks (#4095)
These values are preset-specific and entries from previous deck may cause issues.
2025-06-19 13:23:49 +07:00
Damien Elmes
a63e4ef1c8 Revert "Ignore TaskManager's on_done callback if collection unloaded (#4076)"
This reverts commit ccc42227d8.

Closes #4094
2025-06-19 13:17:30 +07:00
Damien Elmes
c5eb00cb42 Experiment with Claude
*grumbles about lack of support for a dot prefix*
2025-06-19 13:17:30 +07:00
user1823
44f3bbbbc9
Limit study time to hours in reviews graph (#4086)
* Add maxUnit argument to naturalUnit

* Limit study time to hours in reviews graph

Relevant discussions:
- https://forums.ankiweb.net/t/reviews-graph-units-of-total-time-studied-suggestion/61237
- https://forums.ankiweb.net/t/why-does-anki-display-study-time-in-months/37722
- https://forums.ankiweb.net/t/poll-use-hours-in-total-time-stats/62076
- https://github.com/ankitects/anki/pull/3901#issuecomment-2973161601

* Use the new approach for native stability in Card Info

* Use a simpler approach
2025-06-18 14:34:58 +07:00
Damien Elmes
4040a3c1f9 Fix stale 'now' in timing info
Closes #4089
2025-06-18 12:18:38 +07:00
llama
669312d5eb
Fix unescaped deck names potentially missing from overview (#4084)
* html-escape deck name in overview

* move escaping past hook
2025-06-18 11:35:02 +07:00
Lukas Sommer
b4cee124c0
Comments for translators (#4075)
* Update deck-config.ftl

* Update deck-config.ftl

* Update comment

* Udpate comments
2025-06-18 11:34:29 +07:00
llama
5cb191d624
Fix IO text labels' fill attr being saved even if default colour (#4083)
* move exporting of fill attr to subclasses

* set text colour for new labels
2025-06-16 13:07:05 +03:00
Jarrett Ye
615bbf95a1
update to fsrs-rs 4.0.0 (#4080)
* update to fsrs-rs 4.0.0

* fix ci

* update test
2025-06-14 12:48:33 +07:00
Luc Mcgrady
11cc9287ff
Fix/Missing cardID special field (#4078) 2025-06-13 10:47:16 +07:00
sorata
b1f3783a6a
use abbr. for days of week (#4077) 2025-06-13 10:46:17 +07:00
Abdo
ccc42227d8
Ignore TaskManager's on_done callback if collection unloaded (#4076)
* Ignore TaskManager's on_done callback if collection unloaded

* Check col.db
2025-06-13 10:45:41 +07:00
Luc Mcgrady
6004616672
Feat/Health check tooltip (#4068)
* Feat/Health check tooltip

* Update ftl/core/deck-config.ftl

* split deckConfigHealthCheckTooltip

* wording change

* separate "(slow)"

* Add title to health check messages
2025-06-13 10:42:47 +07:00
Damien Elmes
e728e8bcb1 Recreate pyenv if it was created with uv
Temporary fix for #4074 breaking normal builds
2025-06-12 12:20:02 +07:00
Damien Elmes
22f4a83222 Bump requests for CVE 2025-06-11 13:35:03 +07:00
Luc Mcgrady
83131cb48e
Feat/Message at 100% progress for optimize (#4069) 2025-06-11 13:31:17 +07:00
sorata
fe750dba9f
style hr element (#4067) 2025-06-11 13:02:08 +07:00
Sunong2008
ccc9d9027a
Delay retention workload info display after FSRS optimization alerts (#4066)
* Update FsrsOptions.svelte

* Update CONTRIBUTORS

* Make it full width too, so it doesn't resize when transitioning past 90

* Make sure the Warning appears after the alert

* Update FsrsOptions.svelte

* Update FsrsOptions.svelte

* Update FsrsOptions.svelte
2025-06-11 13:01:47 +07:00
Jarrett Ye
ce6497cd2b
Fix/remove the lower limit of interval when set due date (#4063)
* Fix/remove the lower limit of interval when set due date

* don't affect SM-2

* Apply patch from user1823

* Fix build

* More suggestions from user1823
2025-06-08 15:36:32 +07:00
sorata
e5d34fbb18
Update default styles (#4060)
* add margin for hr

* add line height to default styles

* update my email

* change margin to 1em
2025-06-08 11:24:46 +07:00
Damien Elmes
c1fc45928d Bump version 2025-06-06 14:05:33 +07:00
Damien Elmes
e66bbc62ec Update translations 2025-06-06 13:20:08 +07:00
Damien Elmes
2427743751 Formatting fix
I have checks running on push, but must have confused the build system
by modifying the file at the wrong time.
2025-06-06 13:19:47 +07:00
Damien Elmes
933d63545a Stop collapsing reschedule entries
Closes #3316
2025-06-06 13:13:48 +07:00
Damien Elmes
50b7588231
Treat play_file() and co as internal routines without protection (#4059)
* Treat play_file() and co as internal routines without protection

Our code and add-ons need a way to play audio from arbitrary locations. I propose we treat the _tag API as suitable for user input, and the _file API for internal use.

* Mention basename in the *_file() paths
2025-06-06 12:55:04 +07:00
Luc Mcgrady
55ecbc1125
Feat/Health check (#4047)
* Message on low log loss

* make console.log permanent

* Added: Health check option

* disable button

* change health check conditions

* i18n

* ./check

* Apply suggestions from code review

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* delete shadowed fsrs

* Update ts/routes/deck-options/FsrsOptions.svelte

Co-authored-by: llama <gh@siid.sh>

* Update ftl/core/deck-config.ftl

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* anon's suggestions

* snake_case

* capital slow

* make global

* on by default

* Adjusted loss values

* Show message on pass

* ./check

* ComputeParamsRequest

* update coefficients

* update thresholds

* fix thresholds

* Apply suggestions from code review

---------

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>
Co-authored-by: llama <gh@siid.sh>
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2025-06-06 12:43:33 +07:00
Jarrett Ye
8add993fca
improve the accuracy of the expected workload calculation (#4056)
* improve the accuracy of the expected workload calculation

* ./ninja fix:minilints

* implement smoothing & a separate struct for return value

* set TERMINATION_PROB to 0.001
2025-06-04 18:20:12 +07:00
Ren Tatsumoto
3ab8c2294d
Restore ability for add-ons to provide full paths to media (#4054)
* fix #4053

* check if file exist

AJT Japanese needs to play files stored in all possible locations on disk

* check absolute path

* add comment

* check if passed name is basename

* Add a security note to reduce the chance of a regression

* Tweak comment in the non-add-on case
2025-06-04 18:11:37 +07:00
Ren Tatsumoto
29e3146e1f
trim file to basename before creating SoundOrVideoTag (#4057)
* trim file to basename before creating SoundOrVideoTag

* add import
2025-06-04 18:03:14 +07:00
llama
996fa8bcb0
add answer key shortcuts to grade now dialog (#4055) 2025-06-04 12:15:33 +07:00
llama
174b199164
Add IO mask colour fill tool (#4048)
* add fill tool

* add fill tool logic

* open colour picker on fill tool activation

* refactor/add fill attr to io clozes

* fill masks in editor

* fill text and inactive masks in reviewer

* fix lint

* remove debug option
2025-06-04 11:45:34 +07:00
GithubAnon0000
27c1ed1899
FIX diacrititcs being cutoff in input card templates (#4049) 2025-06-03 16:27:32 +07:00
Luc Mcgrady
bbac90d97d
Fix/Invalid parameter counts saveable (#4052)
* Add frontend check for parameters

* Fix backend

* ./check

* Fix: Wrong type
2025-06-03 16:27:04 +07:00
Expertium
4e928fd7ca
Optimize All -> Optimize All Presets (#4050) 2025-06-03 16:23:35 +07:00
Jarrett Ye
2de0c79ba5
Feat/evaluate FSRS with time series split (#3962) 2025-06-03 15:26:33 +07:00
Damien Elmes
37984233cc Restore cert error check
https://forums.ankiweb.net/t/bug-unknown-error-on-startup-anki-25-02/61232/3
2025-06-02 16:52:09 +07:00
Luc Mcgrady
a99beb71fe
Feat/Card ID special field (#4046)
* Feat/Card ID special field

* remove clone
2025-06-02 16:35:13 +07:00
Luc Mcgrady
06c0e4c14a
Fix/CMRR style (#4043) 2025-06-01 13:18:35 +07:00
Damien Elmes
f81a9bfdfb
Fix mpv being left around on abrupt termination (#4042)
Closes #4015
2025-06-01 13:16:28 +07:00
Damien Elmes
96ff27d1fb
Ensure media files are passed relative to the media folder (#4041)
We were (partially) doing this for MpvManager, but not for
Windows' SimpleMpvPlayer. By passing a media file starting
with a special scheme, a malicious actor could have caused a file to
be written to the filesystem on Windows.

Thanks once again to Michael Lappas for the report.
2025-06-01 13:16:04 +07:00
Damien Elmes
757247d424 Use more secure API key
https://github.com/ankitects/anki/pull/3925#discussion_r2051494659
2025-05-31 16:01:03 +07:00
Damien Elmes
6cdebd7638 Fix inverted margin logic
https://github.com/ankitects/anki/pull/4040#issuecomment-2921626962
2025-05-30 22:48:31 +07:00
llama
f9f0894162
Add left margin to browser when sidebar is closed (#4040)
* add left margin to browser when sidebar is closed

* listen for event instead of explicit user action

* refresh sidebar on visibility change

* Add a margin on macOS even when not collapsed

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-05-30 13:35:06 +07:00
Abdo
14b8a8ad0d
Fix new card sort order not reacting to changes in gather order (#4039) 2025-05-30 13:05:36 +07:00
Marvin Kopf
7a8b4a193f
offload mpv callback registration to background thread to avoid UI blocking (#4038)
Instantiating `MPV(MPVBase)` triggers multiple synchronous `command()` calls to the mpv process during callback registration. These calls block the main thread and degrade startup performance. This change defers registration via `taskman.run_in_background`.
2025-05-30 13:05:06 +07:00
Luc Mcgrady
f29bcb743b
Feat/Desired retention warning improvements (#3995)
* Feat/90% desired retention warning

* Update ftl/core/deck-config.ftl

* show on newly enabled

* Show warning on focus

* Never hide warning

* Display relative change

* Add: Separate warning for too long and short

* Revert unchanged text changes

* interval -> workload

* Remove dead code

* fsrs-rs/@L-M-Sherlock's workload calculation

* Added: delay

* CONSTANT_CASE

* Fix: optimized state

* Removed "Processing"

* Remove dead code

* 1 digit precision

* bump fsrs-rs

* typo

* Apply suggestions from code review

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>

* Improve rounding

* improve comment

* rounding <1%

* decrease rounding precision

* bump ts-fsrs

* use actual cost values

* ./check

* typo

* include relearning

* change factor wording

* simplify sql

* ./check

* Apply suggestions from code review

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* Fix: missing search_cids

* @dae's style patch

* Fix: Doesn't update on arrow keys change

* force two lines

* center two lines

---------

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>
2025-05-27 13:07:21 +10:00
Jarrett Ye
1e6d12b830
Set Due Date: Set interval to actual elapsed days when FSRS is enabled (#4035) 2025-05-26 23:33:39 +10:00
Jarrett Ye
dfee38898d
calculate accurate retrievability in card info (#4034) 2025-05-26 23:25:27 +10:00
llama
16c5eaf00a
don't show "double click to expand" when it's not possible (#4030) 2025-05-22 23:21:08 +10:00
llama
420cd237df
fix io undo logic error (#4027) 2025-05-22 23:11:04 +10:00
GithubAnon0000
6a1d55ae75
ADD myself to about.py (#4026) 2025-05-22 22:55:37 +10:00
Luc Mcgrady
8694b3b410
Use non breaking spaces for names on about page (#4025)
* use non breaking spaces for names on about page

* Update qt/aqt/about.py

Co-authored-by: llama <gh@siid.sh>

---------

Co-authored-by: llama <gh@siid.sh>
2025-05-22 22:55:15 +10:00
GithubAnon0000
ec513dfde7
Fix DR not being in percent in the forgetting curve (#4024)
* FIX DR not displayed as % in forgetting curve

* Run ./check and fix errors found by it

* Round DR to full number
2025-05-22 22:54:35 +10:00
llama
d39284e101
Fix IO masks not saving when scaled (#4021)
* trigger save after modifying object

* remove redundant save

already called by undoStack.onObjectModified or setShapePosition
2025-05-22 21:43:38 +10:00
GithubAnon0000
e989564be2
FIX borken support link (#4019)
https://github.com/ankitects/anki/issues/4017
2025-05-22 21:40:13 +10:00
Damien Elmes
3b7f21e50e Update translations 2025-05-22 21:25:33 +10:00
Lukas Sommer
28e9c5a630
Fix URL schemes translation (#4004) 2025-05-22 21:24:48 +10:00
llama
31d877f20d
place caret after mathjax element on overlay close event (#4016) 2025-05-19 13:43:01 +10:00
dependabot[bot]
150683ebe2
Bump vite from 5.4.18 to 5.4.19 (#4018)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.4.18 to 5.4.19.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.4.19/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.4.19/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 5.4.19
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-19 13:38:53 +10:00
Damien Elmes
7b4a7dcf18 Bump flask-cors for latest CVEs 2025-05-19 13:34:59 +10:00
Emmanuel Ferdman
8a61a5470c
Resolve Python regex library warnings (#4012)
* Resolve Python regex library warnings

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>

* Add CONTRIBUTORS

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2025-05-19 13:29:54 +10:00
spiritualfather
63fd1ffbff
upgrade esbuild versions (#4011)
* upgrade esbuild versions

* Update license file
2025-05-19 13:25:05 +10:00
llama
d667abffd1
Fix searching for non-blank adjacent wildcard fields (#4009)
* modify collect_ranges to take param on whether to join ranges

* update tests

* update existing call

* fix searching for non-empty wildcard fields
2025-05-19 13:15:23 +10:00
Luc Mcgrady
ed13a351b9
Fix/Prevent manual resize of params input (#4008) 2025-05-19 13:10:47 +10:00
sorata
277061498d
update backup restore message (#4005)
* update backup restore message

* Update ftl/qt/qt-misc.ftl

Co-authored-by: GithubAnon0000 <160563432+GithubAnon0000@users.noreply.github.com>

---------

Co-authored-by: GithubAnon0000 <160563432+GithubAnon0000@users.noreply.github.com>
2025-05-19 13:09:43 +10:00
Lukas Sommer
a402670c4e
Update sync.ftl (#4003)
* Update sync.ftl

* Update ftl/core/sync.ftl

Improved string by @GithubAnon0000

Co-authored-by: GithubAnon0000 <160563432+GithubAnon0000@users.noreply.github.com>

---------

Co-authored-by: GithubAnon0000 <160563432+GithubAnon0000@users.noreply.github.com>
2025-05-19 10:44:54 +10:00
Damien Elmes
48a0640a07 Revert "feat(scheduler): add from_queue flag to CardAnswer (#3976)"
This reverts commit 1f95d030bb.

Buggy: https://github.com/ankitects/anki/pull/3983
2025-05-19 10:26:10 +10:00
Damien Elmes
d3d6bd8ce0 Skip ytdl flag on macOS ARM
Fixes sounds failing to play in the packaged build on macOS.
2025-05-15 19:04:26 +10:00
Damien Elmes
1157465844 Update translations 2025-05-15 16:50:08 +10:00
llama
413b73d9f4
fix onNote potentially discarding editor field changes (#4001) 2025-05-15 16:48:56 +10:00
llama
97b12b420a
Resize fsrs params input to fit content (#3999)
* resize param input on value change

* resize on window resize
2025-05-15 16:41:30 +10:00
user1823
8f2c708751
Include reset entries in dataset exported for research (#3998)
https://github.com/open-spaced-repetition/fsrs4anki-helper/pull/566#issuecomment-2875432135
2025-05-15 16:31:18 +10:00
llama
a2a1f597be
Style the fsrs params input (#3997)
* style textarea and date inputs

* remove redundant date input styling
2025-05-15 16:30:17 +10:00
llama
4e1a901738
Clarify field separator being a guess when importing csv (#3996)
* clarify that the initially selected field separator is a guess

* explain why the field seperator setting might be locked
2025-05-15 16:26:51 +10:00
Adnane Taghi
f96c8c2ac8 Make URL schemes dialog more ergonomic (#4002)
(originally merged into a PR branch)

* Make URL schemes dialog more ergonomic

* add name to contributors list

* Title Case

* Tweak build instructions so Cursor picks them up

* Use a warning icon for the URL scheme pop-up

* Default to cancelling
2025-05-15 16:17:33 +10:00
Kolby Moroz Liebl
6427ff3db5
Fix dockerimage, by bumping rust version (#3993) 2025-05-15 16:09:27 +10:00
Damien Elmes
86c89907e7
Add URL scheme whitelist (#3994)
* Add experimental Cursor rules

* Add the ability to customize URL schemes

Closes #3965
2025-05-15 15:37:49 +10:00
Luc Mcgrady
f7cdf4eb9e
Fix/Leech suspended tooltip (#3992)
* Fix/Leech suspended popup

* extra check

* Fix: None check

* move comment
2025-05-15 15:14:10 +10:00
GithubAnon0000
f727934a42
CHANGE collection size too large error to add MB values and info about compressed vs. uncompressed. (#3981)
* CHANGE collection size too large error to add MB values and info about compressed vs. uncompressed

* Round f64 to 2 decimals

* Remove line breaks from ftl/core

* Remove string 'uncompressed' from code

* Add string 'uncompressed' to ftl/core

* Remove if statement change introduced to test changes locally

* Run ./check
2025-05-15 15:08:41 +10:00
GithubAnon0000
37dfbca094
UPDATE answer button graph tooltip to include I) answer button name and II) description of what "correct" means (#3979)
* ADD name of the button after button number (1 → again...)

* ADD info string to explain what 'correct' means

* Run ./check and make it happy

* Apply suggestion from @dae to make text shorter
2025-05-15 14:54:51 +10:00
llama
1c69333210
don't scale border width along with existing masks (#3991) 2025-05-12 01:49:29 +03:00
Damien Elmes
5080451829 Disable YouTube DL in mpv
mpv looks for ytdl on the path, which includes the CWD on Windows.
A malicious shared deck could place an executable called yt-dlp.exe in the
media folder, which mpv would then helpfully invoke the first time
a YouTube link was encountered.

A big thank you to Michael Lappas for the report.
2025-05-10 19:31:06 +10:00
llama
c33974f6ab
Fix polygons closing when clicking existing masks while editing IO (#3990)
* fix polygons closing when clicking existing masks while editing io

* disallow selecting new polygons

* update CONTRIBUTORS

* preserve ids when pushing canvas state to undo stack

* rehandle tool changes after undoing/redoing

the polygon tool makes all objects unselectable, which isn't
preserved when restoring the canvas state after an undo/redo
2025-05-10 16:32:44 +10:00
llama
573f59fab1
Allow rotating IO masks (#3987)
* Revert "Disable rotation globally"

This reverts commit 22736238c1.

* alt. impl for hiding rotation marker when selecting/ungrouping

* (de)serialise angles

* rotate masks in reviewer

* update bounds checking

* floats.ts -> lib.ts

* add convenience fns

* store mask angles (deg) in steps of 10000

* update CONTRIBUTORS
2025-05-10 16:21:33 +10:00
llama
5cc44b3f68
Make IO polygon markers centred and transparent (#3989)
* make polygon markers centred and transparent

* centre active line

* set perPixelTargetFind per object, and not on the canvas

otherwise it can't be overridden for a specific object
see 4c305baae6/src/canvas.class.js (L786)
2025-05-09 00:20:00 +10:00
llama
9025202204
properly construct file url when opening image/folder on linux (#3986) 2025-05-08 23:29:46 +10:00
Abdo
80618cad85
Clear notetypes cache on import (#3969)
* Clear notetypes cache on import

* Clear cache in AnkiQt.on_operation_did_execute() instead
2025-05-08 23:11:47 +10:00
Jarrett Ye
1124a63798
expose decay of Card object in Python (#3985) 2025-05-06 23:32:58 +03:00
Damien Elmes
cbb202a46f Re-run minilints on .md change
While trivial updates to our docs don't really need a license
declaration, they were causing CI to fail after merge.
2025-05-05 19:10:13 +10:00
Divyansh Kushwaha
6a07c6e561
docs: correct reference for linux dockerfile (#3982) 2025-05-05 18:57:08 +10:00
Luc Mcgrady
e06852a0ed
Fix/SQL retrievability underflow (#3980)
* Fix/Saturating sub called before u32 conversion

* more
2025-05-05 18:49:12 +10:00
GithubAnon0000
dcc6000f70
Properly align label and radio input in the stats window (#3977)
* Properly align label and radio input in the stats window

* use margin-inline-end instead of margin-right to support RTL
2025-05-05 18:10:58 +10:00
Damien Elmes
d1bb69aaec Remove unused import 2025-05-05 18:08:31 +10:00
Abdo
b84f2d7873
Use correct debug scripts folder (#3973) 2025-05-05 17:26:04 +10:00
Abdo
0277721280
Fix invalid rust-analyzer option (#3972) 2025-05-05 17:25:11 +10:00
Luc Mcgrady
a66f8b2b5f
Fix/Layout shift on CardCounts button hover (#3971) 2025-05-05 17:24:34 +10:00
Damien Elmes
c70e9d26c5 Add the ability to hide the forgetting curve from card info 2025-05-05 17:04:15 +10:00
Matt Brubeck
bcb28f0a85
Use first >= 1d interval for starting memory state (#3959)
When a filtered revlog history begins with one or more < 1d intervals
(for example, because it starts in the middle of a sequence of
relearning steps), use the first >= 1d interval to calculate the initial
memory state.

Bug report thread:

https://forums.ankiweb.net/t/fsrs-stability-when-first-non-ignored-revlog-has-a-relearning-interval/59894
2025-05-05 15:49:06 +10:00
GithubAnon0000
57ecfbe562
REMOVE percentages of x-axis in the answer buttons graph (#3952)
* Allow linebreak between kind and percentage in answer buttons graph. This is BROKEN!

* FIX: percentage is not below kind

* FIX: y-axis wrongly had percentages

* REMOVE debugging console

* run ./check and fix errors

* REMOVE unused comment (commented out code)

* FIX: Percentage Text is cutoff (this removes transition as well)

* FIX: incorrect alignment

* UPDATE variable names to make them more meaningful

* UNDO removing transition

* REMOVE percentage from x-axis

* Revert "UNDO removing transition"

This reverts commit 2652b16bd7.

* RESTORE transition in x-axis
2025-05-05 15:37:24 +10:00
Yaoliang Chen
1f95d030bb
feat(scheduler): add from_queue flag to CardAnswer (#3976)
Co-authored-by: Yaoliang <yaoliang.ch@gmail.com>
2025-05-03 12:21:48 +03:00
Jarrett Ye
bd67e9fe1b
Fix/stability doesn't increase after pressing good (#3975) 2025-05-03 12:04:35 +03:00
Jonathan Schoreels
963fcf7c60
Check if self.card.reps>0 before substracing 1 (#3966)
* Check if self.card.reps>0 before substracing 1

* Fix formatting

* Use a more rust-y way to avoid the Panic for underflow, especially wé're talking seed value

Co-Authored-By: jake <jake@sharnoth.com>

---------

Co-authored-by: jake <jake@sharnoth.com>
2025-04-30 21:53:36 +10:00
sorata
ad12046e87
Improve an Error Message (#3964)
* improve a string

* Update ftl/core/deck-config.ftl
2025-04-30 21:44:11 +10:00
Matt Brubeck
ef37952ba0
Remove dead code in reviews_for_fsrs (#3958)
* Clarify logic in reviews_for_fsrs

Prior to this change, the second check of `first_of_last_learn_entries`
was dead code because the first check would always break out of the loop
before it could succeed.  Re-order the code for clarity and add a
comment to explain the logic.

* Update CONTRIBUTORS
2025-04-30 21:28:30 +10:00
Jarrett Ye
92cfb7340e
add ellipsis to Grade Now (#3970)
* add ellipsis to Grade Now

* Revert "add ellipsis to Grade Now"

This reverts commit 8a3cf51c9e.

* add ellipsis to Grade Now
2025-04-29 16:43:14 +10:00
llama
51b5086b01
Fix unescaped deck names missing from tooltips when deleted (#3960) 2025-04-29 02:18:56 +03:00
Jarrett Ye
07033435a6
Fix/remove incorrect invalid input check (#3963) 2025-04-29 02:10:19 +03:00
llama
6ff023f6a1
apply min-height to anki-editable directly (#3957) 2025-04-28 06:41:00 +10:00
Luc Mcgrady
ad073ab10c
Feat/CMRR uses simulate config (#3947)
* Added: simulate_request_to_config

* Use SimulateConfig for CMRR

* ./check

* Fix: ComputingRetention

* Use actual cards for optimal_retention
2025-04-27 21:02:37 +10:00
Damien Elmes
e748cec5d1 Update translations 2025-04-27 19:49:52 +10:00
Damien Elmes
1e2f11a271 Latest FSRS 2025-04-27 19:48:43 +10:00
Evgeny Kulikov
2acdc8c30a
Close only "child" window (e.g. Preview) inside Browser on Cmd+W (#3913)
Currently, if a user tries to close Preview which was opened inside Browse, the "parent" Browse window itself gets closed

Co-authored-by: beyondcompute <beyondcompute@users.noreply.github.com>
2025-04-27 18:25:20 +10:00
JL710
62bad44eed
add toggle for browser sidebar (#3953)
* add toggle for browser sidebar

* Update CONTRIBUTORS
2025-04-27 18:22:56 +10:00
Jarrett Ye
90f2e06b17
Fix/missing-simulator-decay-for-FSRS-5 (#3956) 2025-04-27 17:20:13 +10:00
Jarrett Ye
6d0e52e8a0
Fix/incorrect fallback of decay (#3954) 2025-04-27 17:19:59 +10:00
Luc Mcgrady
2406830ff9
Fix/no memory state revlogs in reverse order on card stats screen. (#3951) 2025-04-26 12:09:40 +10:00
user1823
9872645d5a
Update sorting by R for FSRS 6 (#3949)
* Update sorting by R for FSRS 6

* Update sqlite.rs
2025-04-26 12:05:38 +10:00
Jarrett Ye
a5778f3377
Fix/FSRS-6 doesn't give <1d intervals & use log loss instead of RMSE(bins) (#3948)
* Fix/FSRS-6 doesn't give <1d intervals

https://forums.ankiweb.net/t/anki-25-05-beta-1/59710/8?u=l.m.sherlock

* use log loss instead of rmse to determine use which parameters
2025-04-26 12:05:13 +10:00
RREEMMII
0321c26e73
Fix docs of note_fields_check to match changes made in PR #3912 (#3944)
Co-authored-by: Rémi Deloye <remi.deloye@telecom-paris.fr>
2025-04-26 11:55:40 +10:00
Jarrett Ye
7556f71b96
Update to FSRS-rs v3.0.0 (fix historic memory state) (#3946)
* Update to FSRS-rs v3.0.0 (fix historic memory state)

* format
2025-04-25 20:09:19 +10:00
Damien Elmes
365d50012c Add another contributor to the about screen as requested 2025-04-25 18:42:54 +10:00
Jonathan Schoreels
863fe3cd50
Add a way to pass information from browser_will_search to browser_did_search without having it going to the backend (#3945)
* Add a way to pass information from browser_will_search to browser_did_search without having it going to the backend

* Allow None for SearchContext.properties

* Adding myself in CONTRIBUTORS

* Rename SearchContext.properties to SearchContext.addon_metadata

* Revert "Adding myself in CONTRIBUTORS"

This reverts commit a993577279.

* Reapply "Adding myself in CONTRIBUTORS"

This reverts commit f3ce51c83d.
2025-04-25 18:40:24 +10:00
Damien Elmes
0aaa6383f8 Bump version 2025-04-25 16:52:46 +10:00
Damien Elmes
ab17fc147c Update translations 2025-04-25 16:51:28 +10:00
Jarrett Ye
e096c462fa
Feat/FSRS-6 (#3929)
* Feat/FSRS-6

* update comment

* add decay to Card

* ./ninja fix:minilints

* pass check

* fix NaN in evaluation

* remove console

* decay should fallback to 0.5 when it's None.

* Update SimulatorModal.svelte

* Update a few comments

* Update FSRS decay defaults to use constants for better maintainability and clarity

* Update rslib/src/storage/card/data.rs
2025-04-25 16:44:34 +10:00
llama
1e6c8b2006
Fix fields with \n being ignored when searching all fields w/o regex (#3943)
* add singleline flag to regex when searching all fields

* update test
2025-04-24 20:01:10 +10:00
Luc Mcgrady
e861364092
Fix/Calculate missing memory states on simulate (#3940)
* Fix: Recalculate memory states on simulate

* Fix: Wrong cards included

* Save states to cards

* ./check

* Update rslib/src/scheduler/fsrs/simulator.rs
2025-04-24 19:32:31 +10:00
llama
b5f15491a0
carry over tags when refetching csv metadata (#3938) 2025-04-24 19:18:57 +10:00
Luc Mcgrady
a2e0060470
Chore/Simulator modal i18n (#3927)
* Chore: Simulator i18n

* Buttons should be Title Case (dae)
2025-04-24 19:17:04 +10:00
Arthur Milchior
7bebcad864
Some documentation and reduce copy/paste (#3917)
* NF: document that cloze number are kept as they are in the field

I needed to know because {{c1 generate card 0 for example. And storing
the card ordinal would have been another consistent choice.

* NF: introduce method that return the cloze number in fields

This slightly reduce code duplication.

* Apply suggestions from code review
2025-04-24 19:02:11 +10:00
Evgeny Kulikov
fe2c1510ca
Add Cmd+W close shortcut (on Mac) to more dialogs (#3905)
* Enable Cmd+W shortcut in "Edit Current" on Mac

* Enable Cmd+W shortcut in "Fields" editor on Mac

* Enable Cmd+W shortcut in "Cards" editing on Mac

* Enable Cmd+W shortcut in "Sync" tab modal on Mac

* Enable Cmd+W shortcut in "Custom Study" tab modal on Mac

* Enable Cmd+W shortcut in Settings view on Mac

* Enable Cmd+W shortcut in Export dialogs on Mac

* Enable Cmd+W shortcut for getText dialog on Mac

* Enable Cmd+W shortcut in "Change Deck" on Mac

* Enable Cmd+W shortcut in Reposition dialog on Mac

* Enable Cmd+W shortcut in "Grade Now" dialog on Mac

* Enable Cmd+W shortcut in "Reset…" dialog on Mac

* Remove duplicate camelCase variant of add_close_shortcut (dae)

- The camelCase variant will remain accessible with a warning.
- The removed setattr line is legacy cruft, and wasn't doing anything.
2025-04-24 18:53:01 +10:00
Arthur Milchior
efaaae8ce4
Cloze button get disabled outside of cloze field (#3879)
* NF: replace `disabled` by `enabled`

This allows to remove the negations and, in my opinion, make the code
easier to understand and edit.

* Cloze button get disabled outside of cloze field

More specifically, if the user focus in a field that is not a cloze
field, the button are still there but appear as disabled. The shortcut
instead of adding the cloze context shows an alert explaining why this
can't be done.

While this message is already displayed when the user tries to add a
note with cloze in non-cloze field, I suspect it will save time to
stop the user as soon as possible from making mistake. This should
make very clear what is authorized and what is not.

It'll also be a reminder of whether the current field is a cloze or
not.

In order to do this, I added a back-end method (that I expect we may
reuse in ankidroid) to get the index of the fields used in cloze. This
set is sent to the note editor, which propagates it where needed.

In mathjax, the cloze symbol is removed when the selected field is not
a cloze field.
2025-04-24 18:37:41 +10:00
Damien Elmes
b23a6af63e Restore ability to check pages externally on other devices
Broken by the recent security changes
2025-04-24 18:33:09 +10:00
GithubAnon0000
aacf8ec774
Add help modal to TR table (#3874)
* Update TrueRetention.svelte adding description

* Update statistics.ftl to add additional info

* Swap TR with DR

* Change string to 'Is expected to'

* Add help modal to TR table

* Add tooltip slot to Graph.svelte (thanks @Luc-Mcgrady)

* Fix lint warning and failing test

* Remove unused code

* removedd on:mount to make eslint happy

* ADD back on:mount

* ADD back code needed for on:mount

* REMOVE openHelpModal() as I couldn't figure out how to make the title clickable

* attempt to ADD clickable title (BROKEN\!)

* Update ts/lib/components/TitledContainer.svelte

Co-authored-by: Luc Mcgrady <lucmcgrady@gmail.com>

* Update ts/routes/graphs/Graph.svelte

Co-authored-by: Luc Mcgrady <lucmcgrady@gmail.com>

* Update ts/routes/graphs/TrueRetention.svelte

Co-authored-by: Luc Mcgrady <lucmcgrady@gmail.com>

* ADD exported onTitleClick as @Luc-Mcgrady suggested

* REMOVE vite.config.ts file

---------

Co-authored-by: Luc Mcgrady <lucmcgrady@gmail.com>
2025-04-24 18:31:45 +10:00
Aristotelis
79b19a17a3
Add add-on scripts to editor CSP (#3942) 2025-04-24 15:28:25 +10:00
Damien Elmes
1e74e8e86e
Fix add-on buttons not working in the editor (#3941)
* Fix add-on buttons not working in the editor

* Ensure old listeners are cleaned up

Thanks to iamllama: https://github.com/ankitects/anki/pull/3941#discussion_r2057066283
2025-04-24 15:26:46 +10:00
Damien Elmes
72abb7ec5b Declare dependency on typing_extensions
venv as things like black depended on it. When running in a packaged
build, it wasn't being included, and Anki was failing to start.

I've added it to the anki module instead of aqt, even though only
the latter is currently using it, so that we don't accidentally introduce
the same bug in the future when using typing_extensions from within
libanki.
2025-04-23 17:56:06 +10:00
Damien Elmes
dd0abfc200 Don't check collection size on sync to third-party server
Closes #3936
2025-04-23 17:03:04 +10:00
Damien Elmes
ddb8573e8d
Use CSP to block inline JS content in editor (#3939)
* Revert "Sanitize field content in editor"

This reverts commit 1c156905f8.

* Use CSP to block inline JS content in editor

This blocks inline scripts, scripts in the media folder, and
handlers like onclick in the editor. This is nicer than the previous
solution - it doesn't make any permanent changes, and leaves other
content like SVGs alone. Thanks to Nil Admirari for the suggestion.
2025-04-23 16:21:48 +10:00
Aristotelis
5b0f371791
Fix AnkiWebPage not being initialized for default web view kinds (e.g. in add-ons) (#3933)
* add AnkiWebView subclasses for stats, empty cards and find dupes ui

* update ui files to use subclassed webviews instead

* remove superfluous calls to AnkiWebView.set_kind

* Avoid set_kind() race condition in legacy stats webview

Replacing the web view is a hacky workaround, but likely a reasonable compromise for a legacy view that we do not want to maintain a separate Qt form for.

* Slightly refactor AnkiWebView subclass creation and tweak inline comment

+ Extend create_ankiwebview_subclass() with the ability to set any
  init time AnkiWebView argument
+ Introduce some nice-to-haves in terms of static type checking support
  and IDE autocompletion
+ Mark helper function as private to discourage add-on use

* Drop `AnkiWebView.set_kind` completely

There no longer is an Anki-internal use case for changing the web view kind after initializing a web view, and add-ons almost certainly do not have any use for it either.

Given that setting the kind after web view construction can lead  to known race conditions with `domDone` signals, we should remove this method to discourage uses like this in both Anki code and add-on consumers.

There currenty only seems to be one add-on calling `set_kind()`, so this seem like a justifiable API change.

---------

Co-authored-by: llama <100429699+iamllama@users.noreply.github.com>
2025-04-22 21:22:40 +10:00
llama
a74fd74631
Fix flashing when opening the stats, empty cards or find dupes dialogs (#3928)
* add AnkiWebView subclasses for stats, empty cards and find dupes ui

* update ui files to use subclassed webviews instead

* remove superfluous calls to AnkiWebView.set_kind

* revert impl

* set page background colour after setPage in AnkiWebView.set_kind
2025-04-17 15:18:55 +03:00
Damien Elmes
1a68c9f5d5
Harden access to internal API (#3925)
* Sanitize field content in editor

The editor already strips script tags from fields, but was allowing
through Javascript in things like onclick handlers. We block this now,
as the editor context has access to internal APIs that we don't want to
expose to untrusted third-party code.

* Require an auth token for API access

We were previously inspecting the referrer, but that is spoofable,
and doesn't guard against other processes on the machine.

To accomplish this, we use a request interceptor to automatically
add an auth token to webviews with the right context. Some related
changes were required:

- We avoid storing _page, which was leading to leaks & warning on exit
- At webview creation (or set_kind() invocation), we assign either
an authenticated or unauthenticated web profile.
- Some of our screens initialize the AnkiWebView when calling, e.g.,
aqt.forms.stats.Ui_Dialog(). They then immediately call .set_kind().
This reveals a race condition in our DOM handling code: the webview
initialization creates an empty page with the injected script, which
causes a domDone signal to be sent back. This signal arrives after
we've created another page with .set_kind(), causing our code to think
the DOM is ready when it's not. Then when we try to inject the dynamic
styling, we get an error, as the DOM is not ready yet. In the absence
of better solutions, I've added a hack to set_kind() to deal with this
for now.

* Provide AnkiWebPage init defaults for existing add-on callers

* Inject bridge script when profile set-up skipped

Some add-ons fully override AnkiWebPage.__init__ and thus depend on _setupBridge injecting the JS bridge script.

With this change we account for these cases, while giving add-ons the opportunity to look for solutions that do not require overriding AnkiWebPage.__init__ completely.

* Add some missed pages/endpoints (thanks to iamllama)

* Avoid sending API key for remote resources

Thanks to Abdo for the report

---------

Co-authored-by: Aristotelis P <201596065+aps-amboss@users.noreply.github.com>
2025-04-17 11:15:10 +10:00
Damien Elmes
7969b4061f Bump vite/svelte for latest security fixes 2025-04-15 20:53:26 +10:00
llama
1d2d6e51b9
Fix error when middle clicking in editor on systems w/o global mouse selection (#3923)
* fix potential error when middle clicking in editor

* update about.py
2025-04-15 20:26:18 +10:00
GithubAnon0000
e7fbf159a6
add min-height to fields (#3922)
* add min-height to fields

* 30px → 1.5em

This works with different font sizes too. Now there are no size jumps between empty field / field with string / field with empty html.
2025-04-15 20:24:43 +10:00
Luc Mcgrady
781a23c6c4
Feat/Ignored before card count (#3910)
* GetIgnoredBeforeCount

* get_card_count_with_ignore_before

* Included / total

* Respect search

* Get frontend hooked up

* Fix: Malformed sql and search

* Variable names

* Added: Alert colours

* i18n

* ./check

* Remove console.log

* Fix: Tooltip showing for default value

* Update ftl/core/deck-config.ftl

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* Fix: Multiple backend calls

* Message: (Approximately)

* Fix: Bouncing info message

* Added: Change delay

* Added: ignore_before_updated

* ./check

* Fix typing, camelCase and improve wording

* Temporarily enable the check on startup

---------

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>
2025-04-15 20:21:54 +10:00
(x⋅ln(7))⁻¹
369dec9319
Add an option to disable middle click to paste on Linux (#3904)
* Add checkbox

* Working in editor

* Toolbar webview

* Other webviews

* Even more webviews

* Move to profile settings

* Add to contributors [skip ci]

* Fix checks

* Fix checks

* Better?

* Remove unneded

* Remove checkbox and a few other things

* How the hell did that happen

* Undo FTL changes (dae)

* Remove superfluous config entry (dae)

* Add comment about profile keys (dae)
2025-04-15 19:51:00 +10:00
babofitos
066f5fd281
Fix: correct typo and adjust indentation in docstring (#3920)
* fix: correct typo and adjust indentation in docstring

Fixed a small typo in the webview_did_inject_style_into_page docstring and adjusted indentation for consistency.

* Update CONTRIBUTORS
2025-04-13 17:00:19 +10:00
llama
9d167feb8f
Remove use of createClassComponent in mathjax-element.ts (#3919)
* replace use of deprecated createClassComponent with mount

* bump esbuild-svelte from 0.8.1 to 0.9.2

* mathjax-element.ts -> mathjax-element.svelte.ts

* move caret after tick
2025-04-13 16:21:22 +10:00
llama
8b2a64852b
fix drag/drop breaking when editor is zoomed (#3916) 2025-04-13 14:44:28 +10:00
llama
4f6dcb0b5b
Fix autoplay not being stopped on editor close if it interrupted another (#3915)
* fix autoplay not stopped on editor close if it interrupted another

* Update qt/aqt/sound.py
2025-04-13 14:43:25 +10:00
RREEMMII
1fa99c97e4
Add a warning when there is a cloze in "back extra" and "text" is empty (#3912)
* Add a warning when there is a cloze in "back extra" and "text" is empty

Fix #3909

* Disallow non-blank first field card

* Fix Rust ninja check
2025-04-13 14:40:35 +10:00
user1823
e546c6d11f
Improve natural unit conversion for a time b/w 360 to 365 days (#3901)
* Improve natural unit conversion for a time b/w 360 to 365 days

Previously, 363 days would be converted to 12.1 months, which is quite confusing because
- a user would think that if the value is more than 12 months, why it isn't displayed in years
- the value is actually less than a year, which is counterintuitive as 12.1 m suggests a value more than a year.

* precise

* Update time.ts to match timespan.rs

* Add another test

* Use average duration of a month instead

* Update time.ts

* Update test_schedv3.py

* Update time.test.ts
2025-04-13 14:26:34 +10:00
GithubAnon0000
332830e5d7
Cleanup old TODO (#3903)
This Todo is no longer needed, since #1503 has been closed.
2025-04-11 20:38:20 +10:00
llama
d9c71a54cf
Allow drag-dropping into plaintext editor (#3902)
* expose field index as data attr on container

* allow drag/dropping into fields' plaintext editors
2025-04-11 19:34:47 +10:00
user1823
0f9216c127
Replace some means in Stats with medians (#3900)
* Display median interval in Stats instead of mean

Median is better suited than mean for reporting skewed data.

* Display median ease in Stats instead of mean

* Update difficulty.ts

* Update ease.ts

* Update statistics.ftl

* Format eases.rs

* Remove unused import

* Change Median back to Average in UI

* Revert "Change Median back to Average in UI"

This reverts commit e0c1e3f8e4.

* Preserve the old translations for now (dae)
2025-04-11 19:29:23 +10:00
ikkz
480e8f5409
style: use consistent input styles (#3894) 2025-04-10 15:51:52 +10:00
Lukas Sommer
56613be933
Comment for translators for statistics-total (#3880)
* Update statistics.ftl

* Update statistics.ftl

* Improve wording
2025-04-10 15:41:29 +10:00
Arthur Milchior
ab75e3d49b
Introduce language_bridge.md (#3572)
This commit explains how to calls a method implemented in a language
from a different language.

This explains how to declare the RPCs, how to call them and how to
implement them. This is based on examples of code at main at the time
of writting. I used permalink to ensure that the links remains
relevant even if the specific examples change later.

The last section is about the special case of calling TypeScript from
Python, which does not use RPC but is still relevant in a bridge
document.

This commit also add a paragraph explaining what protobuf is in the
protobuf documentation, so that new contributors who don't know what
protobuf is can understand why we use it.
2025-04-10 15:30:18 +10:00
Damien Elmes
ffbc9a77b7 Update tokio, crossbeam-channel and cargo-deny 2025-04-10 15:18:55 +10:00
dependabot[bot]
fab6ee96fe
Bump vite from 5.4.14 to 5.4.17 (#3914)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.4.14 to 5.4.17.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.4.17/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.4.17/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 5.4.17
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-10 15:11:32 +10:00
Damien Elmes
9e3239baf4 Update translations 2025-04-10 15:03:14 +10:00
Damien Elmes
475fdf04a4 Latest Rust CVEs 2025-04-10 15:03:02 +10:00
llama
ccab18b7ba
Modify card rendering output to specify if rendered card is empty (#3890)
* modify render_card to return whether card was empty

* plumbing

* add flag to proto message

* plumbing: pass flag along to PartiallyRenderedCard

* add tests

* Use a custom return type for clarity (dae)
2025-03-31 17:51:28 +07:00
Lukas Sommer
1798620d64
Update statistics.ftl (#3887) 2025-03-31 17:39:51 +07:00
llama
aa5684638b
Improve performance of card rendering parser (#3886)
* refactor parser

* update test

* add tests

* refactor CardNodes

* Increase nested cloze limit to underlying protobuf limit (dae)
2025-03-31 17:38:46 +07:00
Kris Cherven
52781aaab8
Fix superfluous message when a deck is dragged to its parent (#3859)
* Move the solution to the Rust layer

* CONTRIBUTORS fix (1)

* CONTRIBUTORS fix (2)

* Fix CI issues

* Simplify reparenting solution

* Fix reparenting message with tags

* Revert "Fix reparenting message with tags"

This reverts commit 199958c1c5.

* tags: Return None in reparented_name when the name is unchanged
2025-03-31 16:47:56 +07:00
user1823
86ed715458
Hide AverageForDaysStudied when studiedPercent = 100 (#3888)
Showing both is redundant when studiedPercent is 100
2025-03-29 05:15:41 +03:00
ikkz
567cd9b9e3
style: add shadow to graph tooltip (#3891) 2025-03-29 05:08:59 +03:00
Yuki
acdf486b29
Refactor: Make Load Balancer Optional Throughout Codebase (#3860)
* Refactoring: load balancer

* Update about.py

* Refactoring: load balancer

* Update about.py

* Clean the code

* Remove config check from get_scheduling_states

* Backend method for the load balancer

* Refactor backend method for the load balancer
2025-03-26 23:19:28 +10:00
GithubAnon0000
e7e6a3834b
Center align rows in FSRS simulator (#3882) 2025-03-26 17:21:21 +10:00
Abdo
f4a0598f2f
Return a copy of note type in ModelManager.get() (#3865)
* Return a copy of note type in ModelManager.get()

* Update tests

* Revert "Return a copy of note type in ModelManager.get()"

This reverts commit 04ef186336.

* Add note to .get()
2025-03-26 15:11:34 +10:00
llama
45bb56808a
Fix deck day limits incorrectly being carried over when importing (#3878)
* re-export DayLimit

* add and use DeckContext::maybe_correct_day_limits

* update existing test

* add test

* small tweaks

* refactor

* refactor test
2025-03-25 00:45:09 +07:00
llama
886c5795d4
Fix panic when clearing today limits on the day collection was made (#3877)
* fix panic on clearing today limits on the day collection was made

* avoid possible overflow

* clear future today limits
2025-03-25 00:24:11 +07:00
GithubAnon0000
a766f511dd
Move TR table upwards (#3873)
* Move TR table upwards

This moves the TR table upwards, before the buttons graph.

Also see: https://forums.ankiweb.net/t/let-s-remove-the-answer-buttons-chart-from-stats/56170/26?u=anon_0000

* Moved hour graph below TR graph
2025-03-25 00:13:51 +07:00
Jarrett Ye
a4e0a0824b
Fix/out of index (#3872) 2025-03-25 00:04:25 +07:00
Jarrett Ye
d52889f45c
Feat/simplified relearning steps logic with updated FSRS training API (#3867)
* Feat/simplified relearning steps logic with updated FSRS training API

* Update params.rs

* use ComputeParametersInput

* update fsrs-rs dependency

* update cargo/format/rust-toolchain
2025-03-20 14:04:38 +07:00
Jarrett Ye
5d7f6b25c0
Improve performance of stats revlog entries with memory state (#3866)
* improve performace of stats_revlog_entries_with_memory_state

* format

* move Vec<RevlogEntry> into FsrsItemForMemoryState
2025-03-20 14:02:40 +07:00
llama
d8c83ac075
Loosen csv metadata parsing (#3862)
* add qsv-sniffer crate

* use qsv-sniffer before falling back to old delimiter heuristic

* update test metadata macro

* revert impl

* trim potential suffixed delimiters from non-freeform meta lines

* add test
2025-03-19 18:56:17 +07:00
Kris Cherven
ab8692a91e
Show "and others" at the end of the contributor list in the About dialog (#3863)
* Show "and others" at the end of the contributor list in the about dialog

* Make about addendum translatable

* Fix CONTRIBUTORS

* Fix CONTRIBUTORS

* Update ftl/qt/about.ftl (dae)
2025-03-19 18:16:51 +07:00
Kris Cherven
938c55ca01
Fix broken window decorations on unpackaged GNOME instances (#3858)
* Fix broken window decorations on unpackaged GNOME instances

* Fix CONTRIBUTORS detection

* Fix CONTRIBUTORS
2025-03-19 17:58:42 +07:00
Evgeny Kulikov
ffcc7612ab
Add-ons Dialog: disable View Config/Page/Files buttons when clicking them would not lead to useful result (#3869)
* Remove unused import

* Nit-pick on code comment

* Enable View Page/Config buttons only when 1 add-on selected

* Enable Cmd+W shortcut (on Mac only) to close Add-ons dialog
2025-03-19 04:27:34 +03:00
Arthur Milchior
6ef24739fc
NF: sligthly optimize cards.py (#3870)
As AnkiDroid wants to be similar to Anki, instead of making AnkiDroid
slightly less efficient, I prefer to slightly improve Anki.

AnkiDroid related PR:
https://github.com/ankidroid/Anki-Android/pull/18112.
2025-03-19 04:14:13 +03:00
Damien Elmes
83d0f5dae9 Add ES translator as requested 2025-03-17 22:11:29 +07:00
Damien Elmes
14dc979e44 Fix panic when a preset is missing 2025-03-15 19:40:48 +07:00
Expertium
d53f01064c
Fine-tune load balancer (#3864) 2025-03-15 18:40:17 +07:00
Jarrett Ye
0e31efac08
Feat/grade now (#3840)
* Feat/grade now

* pass ci

* fix from_queue

* Refactor card answering to support from_queue flag

- Add `from_queue` field to `CardAnswer` struct and proto message
- Modify `answer_card_inner` to handle queue updates based on `from_queue`
- Remove `grade_card` method and consolidate card answering logic
- Update related test cases to set `from_queue` flag

* fix current_changes() called when no op set

* Optimize queue updates for batch card processing

- Refactor `grade_now` to collect processed card IDs first
- Add new `update_queues_for_processed_cards` method for efficient batch queue updates
- Improve queue management by removing entries and updating counts in a single pass
- Remove individual queue update method in favor of batch processing

* pass ci

* keep the same style

* remove ineffective code

* remove unused imports
2025-03-15 17:30:40 +07:00
Luc Mcgrady
79b6f658c3
Feat: Simulator suspend after lapse count (#3837)
* Added: Leech suspend to simulator

* Added: leech threshold spin box

* Update git rev

* Added: Save to preset options

* ./check

* Added: "Advanced settings" dropdown

* Removed: Indent

* Added: Easy days

* Added: Sticky header

* Removed: Easy Day updating without saving

* un-nest disclosure

* bump fsrs

* Update a VSCode setting to match recent releases

* Move Easy Days above the Advanced settings

I think it's a bit more logical to have Advanced come last.

* Ensure graph fits inside screen height

* Bump fsrs version
2025-03-15 17:28:15 +07:00
chel-ou
122980e06b
Add hooks for comparing answers (#3855)
* Add hooks associated to compare answer feature

* Update CONTRIBUTORS

* Add type pattern to compare answer related hooks
2025-03-15 12:12:01 +07:00
Jarrett Ye
33b8235186
Fix/incorrect initialization of SchedTimingToday in graphs/retrievability.rs (#3857) 2025-03-14 17:06:25 +07:00
llama
d809ee92db
Fix cargo ignoring lockfile when building syncserver image (#3856)
* pass --locked to cargo invocation

* update Dockerfile.distroless as well

Co-authored-by: Simon <8466614+SimonBaars@users.noreply.github.com>

---------

Co-authored-by: Simon <8466614+SimonBaars@users.noreply.github.com>
2025-03-14 17:04:56 +07:00
Val Enfys
d0ed54a768
Update my name in Anki's credits (#3852)
* Update my name in about.py

* Add name to CONTRIBUTORS
2025-03-14 17:00:48 +07:00
Evgeny Kulikov
339bf436d1
Prevent accidental dragging of audio playback buttons and hint links (#3844)
* Add myself to CONTRIBUTORS

* Set draggable="false" attribute on .replay-button

Because currently if a user drags slightly (even unintentionally) upon clicking a play button, play does not happen

* Prevent dragging hint links

Because if a user moves cursor a little after `mousedown`, action (expanding the hint) does not occur. Which might cause issues from accessibility standpoint
2025-03-14 16:47:03 +07:00
Thomas Graves
f5f22edb6a
Don't recalculate remaining steps, conditionally (#3849)
* Don't recalculate remaining steps, conditionally

Bug report reproduction steps:
Create a new profile so that everything is set to default.
Create a new card.
Click Good.
Open deck options and empty learning steps. Save.
No go back and put 1m 10m as LS.
Go back to the card and it should show 10m on the Good button.

Check if old_steps is empty and if it is just use remaining
steps for the new_remaining steps. Add test.

* Update contributers

* Format code

* Fix clippy error

* Use more idiomatic imports
2025-03-14 16:32:28 +07:00
Damien Elmes
9b5da546be Check collection size when syncing
Currently we only check the size on a one-way sync, allowing users
to bypass the limits by incrementally syncing a lot of material.
To prevent this:

- The server now checks if the collection is already oversize,
and forces a one-way sync if it is
- The client checks if the local collection is oversize and refuses
to proceed, so they don't waste time uploading material that will
likely trigger the limit the next time they sync.
2025-03-10 20:28:57 +07:00
Luc Mcgrady
cad6e0b0bf
Added: Max interval too low warning. (#3847)
* Added: Max interval too low warning.

* Lower threshold to 180

* Add self to about.py
2025-03-10 16:14:35 +07:00
Brayan Oliveira
94e90dbf85
Add title for some dialogs and avoid hardcoding the text of the discard changes dialog (#3846)
* feat: add title to rename dialog

* fix: localize hardcoded message

* feat: add title to create deck dialog

* refactor: formatting fixes

* add name to about screen

adding my name to contributors for the third time
2025-03-10 15:53:43 +07:00
Jakub Fidler
d8460d354a
fix: Task manager exception handling (#3839)
* Raise exception from closures in run_in_background using run_on_main

* Add author to CONTRIBUTORS file

* Undo taskman changes

* Raise exceptions from _on_closures_pending using singleShot
2025-03-10 14:17:50 +07:00
Damien Elmes
b75f2798e6 Silence a warning about ring
https://github.com/ankitects/anki/issues/3081
2025-03-10 14:00:23 +07:00
Brayan Oliveira
63c2a09ef6
feat: add title to some of the sync dialogs (#3838)
* refactor: accept window title in some dialog methods

* feat: match sync initial title with state

Sync iniates in the `Checked` state, so the initial title is changed to match it instead of using the generic `Anki` title

* feat: use `Sync` as the tile of login screen

Maybe a new string should be created for that.

* feat: Use `Sync` as title of the sync conflict dialog

Maybe a new string should be used for that

* refactor: fix formatting

* fix: alias in CONTRIBUTORS

Even in 2025, the script isn't smart enough to handle different casing or use just the GitHub ID
2025-03-03 15:03:28 +03:00
Jarrett Ye
a6426bebe2
Feat/support load balance and easy days in FSRS simulator (#3829)
* Feat/support load balance and easy days in FSRS simulator

* format

* consider LoadBalancerEnabled

* use fsrs::PostSchedulingFn

* add load balance and easy days to compute_optimal_retention

* move simulator to a pop-over

* fix incorrect simulationNumber when error 500

* Feat: Save to Preset Options

* update tabs when update newPerDay & reviewsPerDay

* don't reset deckSize & daysToSimulate when save options

* fix missing easy days

* plan to support review priority

* Fix graph line rendering with non-scaling stroke

* simplify review priority function with helper wrapper

* fallback to default ReviewPriority for Added & ReverseAdded

* Update ts/routes/deck-options/SimulatorModal.svelte

Co-authored-by: Luc Mcgrady <lucmcgrady@gmail.com>

* Wrap review priority function in Arc for thread-safe sharing

* more granularity for R sorting

* Add graph smoothing option to FSRS simulator

* Improve graph resize handling in FSRS simulator

* simplify review priority calculation

* Add review order selection to FSRS simulator modal

* Refactor review priority function using macro for conciseness

* Add copyright and license header to SimulatorModal.svelte

* cargo clippy

* ./ninja fix:eslint

* update fsrs-rs

* Update FSRS dependencies and refactor load balancing functions

- Update fsrs-rs dependency to latest commit
- Modify retention and simulator modules to use Arc instead of Box
- Update function signatures and imports in simulator module
- Simplify review card order handling with direct enum usage

* resolve reviewed changes

* replace .unwrap() with ?

* move simulating into SimulatorModal

* add (crate) to interval_to_weekday

* Update FsrsOptions.svelte

* format

---------

Co-authored-by: Luc Mcgrady <lucmcgrady@gmail.com>
2025-02-27 10:53:01 +07:00
Lukas Sommer
96df6becfc
Comments for translators about sort order (#3831)
* Comments for translators about sort order

* Group combobox entries together. More comments.

* Touch CONTRIBUTORS
2025-02-26 10:32:06 +03:00
GithubAnon0000
42620c4e60
Update uninstall.sh to give feedback to the user (#3834)
The uninstall script runs `xdg-mime uninstall` which takes >5 seconds to process.

There is no indication to the user though that the script is actually running. Adding an `echo` info message solves that.

Additionally we could `rm -rfv` to make it more verbose (the install script is verbose too). But the main thing that needs time to process is the `xdg-mime uninstall` part of the script.

The reason why I didn't make `rm -rf` verbose, too, is that the output text is greater than the buffer that the terminal provides – meaning you cannot view it from the beginning. And since `rm` is very fast even on old systems with slow hardware I didn't really see a reason to make it verbose here.
2025-02-26 10:24:52 +03:00
Damien Elmes
76c4ec7403 Add actions-processing based on qt-misc-processing 2025-02-21 18:29:41 +07:00
Damien Elmes
a7c5376063 Update translations 2025-02-21 18:21:28 +07:00
GithubAnon0000
00cc1b408a
Increase font size for accessibility (#3832)
Apparently no font size should be lower than 12px, see https://www.boia.org/blog/accessibility-tips-let-users-control-font-size.

With the current 55%, I get a computed font size of 8.25px though. Considering the text shows the helpful message "Press ⁨Enter⁩ to accept, ⁨Shift+Enter⁩ for new line.", I think we should add a minimum font size.
2025-02-21 17:14:15 +07:00
llama
8ec139f62a
Debounce mathjax rendering to avoid stalling (#3827)
* move change-timer to editable

* debounce mathjax rendering
2025-02-21 16:39:11 +07:00
mumtazrifai
e373b0ed9b
Use default flag name when flag is renamed to empty string (#3826)
* Add function to restore the default name of a flag

* Call function to restore default flag name if flag renamed to empty string

* Update _load_flags to use the default_flag_names dict

* Add name to contributors file

* Add trailing comma to pass tests

* Update to follow python style guide

* Update about.py

* Revert "Update _load_flags to use the default_flag_names dict"

This reverts commit caa8fea94b.

* Use require_refresh() instead of storing default flag names
2025-02-21 16:38:04 +07:00
Damien Elmes
2727cf39b2 Update to Rust 1.85
Edition update to follow later
2025-02-21 10:42:42 +07:00
Damien Elmes
8e13e6bfc1 Update n2 [action required]
Make sure to run tools/install-n2 after updating to this commit.
n2 have merged in some changes we were previously hosting in a fork,
but the parsing of the flags was altered.
2025-02-19 10:34:45 +07:00
llama
1c8c5a41f5
Cache rendered mathjax to avoid stalling when editing plaintext (#3828)
* add lru-cache

* cache mathjax rendering
2025-02-18 14:41:37 +07:00
Jake Probst
5552fc6e97
add hook for day rollover (#3817)
* add hook for day rollover

* rollover -> day_did_change
2025-02-18 13:46:15 +07:00
Jarrett Ye
59e143ec25
Feat/support load balance and easy days in rescheduling (#3815)
* Feat/support load balance and easy days in rescheduling

* ./ninja fix:minilints

* apply clippy

* reuse calculate_easy_days_modifiers()

* consider LoadBalancerEnabled

* move calculate_easy_days_modifiers out of struct

* improve naming & add comments

* apply clippy

* reschedule if easy days settings are changed

* Minor simplification

* refactor to share code between load balancer and rescheduler

* intervals_and_params -> intervals_and_weights

* find_best_interval -> select_weighted_interval

* cargo clippy

* add warning about easyDaysChanged

* compare arrays directly

* Don't show warning if fsrs+rescehdule is already enabled

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
Co-authored-by: Jake Probst <jake.probst@gmail.com>
2025-02-18 13:44:00 +07:00
GithubAnon0000
8fc822a6e7
Use tilted (filled and unfilled) sticky icons in the cards editor (#3825)
* Update icons.ts to include hollow and solid icons

* Update icons.ts

* Create sticky-pin-hollow.svg

* Create sticky-pin-solid.svg

* Update StickyBadge.svelte to reflect changed icons
2025-02-16 22:24:11 +07:00
Damien Elmes
7f8420255d Update n2
The flickering on Windows has been improved
2025-02-16 18:41:25 +07:00
dependabot[bot]
ee3da3d1aa
Bump esbuild from 0.21.5 to 0.25.0 (#3823)
* Bump esbuild from 0.21.5 to 0.25.0

Bumps [esbuild](https://github.com/evanw/esbuild) from 0.21.5 to 0.25.0.
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG-2024.md)
- [Commits](https://github.com/evanw/esbuild/compare/v0.21.5...v0.25.0)

---
updated-dependencies:
- dependency-name: esbuild
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix lock

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-02-16 16:31:39 +07:00
GithubAnon0000
689eead99a
Update FsrsOptions.svelte to add margin / gap between simulator buttons (#3822)
* Update FsrsOptions.svelte to add margin / gap between simulator buttons

* Hopefully fix gh test error
2025-02-16 16:30:48 +07:00
GithubAnon0000
1beb0cfa8c
Update NoteEditor.svelte to swap pin and html view. (#3821) 2025-02-16 16:23:22 +07:00
llama
70b6cc9682
set editor's card when reopening (#3814) 2025-02-16 16:11:28 +07:00
Luc Mcgrady
5d07eca327
Fix: Close cards missing "copy card info" button (#3811) 2025-02-16 16:10:04 +07:00
Luc Mcgrady
4459e06f74
Copy card debug info (#3801)
* Added: Copy card debug info button

* Fix: Button margins

* Added: More info

* Deleted useless info

* Added: Revlog rows

* Added: cardRow

* Replaced button with shortcut

* Fix: Copying new cards info error

* ./check

* Added: Rollover

* Format outputted json

* neatened imports

* make linter happy

* revert button changes

* Value Error -> Assert

* preserve normal copy functionality
2025-02-16 16:06:12 +07:00
dependabot[bot]
055a8818bc
Bump esbuild from 0.19.12 to 0.25.0 (#3806)
Bumps [esbuild](https://github.com/evanw/esbuild) from 0.19.12 to 0.25.0.
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG-2024.md)
- [Commits](https://github.com/evanw/esbuild/compare/v0.19.12...v0.25.0)

---
updated-dependencies:
- dependency-name: esbuild
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-16 16:00:00 +07:00
Danika-Dakika
70771ca9da
Merge pull request #3820 from Danika-Dakika/user-about
Added translation contributor
2025-02-15 12:01:39 -08:00
Danika-Dakika
c8e4c366c1
Update about.py
Added translation contributor
2025-02-15 11:27:34 -08:00
Damien Elmes
038d85b1d9 Further tweaks to easy days
The previous commit added word-wrap, but it was not working after I'd
removed some other tweaks I'd made in testing, that I thought were not
required. I ended up switching to standard table columns and a fixed
layout, so that both the column and row headers will wrap properly.
2025-02-11 17:04:58 +07:00
Damien Elmes
348822a14b Quick hack to improve minimum deck options width
Partial fix for #3796
2025-02-11 16:11:43 +07:00
Jarrett Ye
0d9a11c19b
Add margin to the bottom of forgetting curve (#3805) 2025-02-11 15:46:36 +07:00
GithubAnon0000
44e01ea063
Update reviewer.py to prevent custom scheduler js from commenting out py code (#3795)
* Update reviewer.py to prevent custom scheduler js from commenting out py code

* Do not use custom code, but move {js} instead
2025-02-09 16:06:49 +03:00
llama
01c4b48c7d
only change notetype/deck when reopening if no changes to discard (#3798) 2025-02-09 15:58:21 +03:00
Luc Mcgrady
dda5973fdc
Remove forgetting curve radio buttons when only one radio button (#3804) 2025-02-09 15:53:05 +03:00
Damien Elmes
acaeee91fa Bump version 2025-02-06 22:59:27 +07:00
Damien Elmes
20561414b2 Update translations 2025-02-06 22:59:19 +07:00
llama
da8c0f0e9b
clear io image field when resetting in add mode (#3794) 2025-02-06 22:58:49 +07:00
Damien Elmes
f893ec63af Prompt user to apply Windows updates when SSL connection fails
See #3793
2025-02-06 22:57:15 +07:00
Damien Elmes
50c1155eb7 Give editcurrent its own menubar too
Closes #3785
2025-02-06 18:57:59 +07:00
Danika-Dakika
6e7dcad542
Update Deck Options strings to clarify Timers (#3792)
* Update CONTRIBUTORS

added myself

* Update about.py

added myself

* Update scheduling.ftl

timers-related string changes

* Update deck-config.ftl

timers-related string changes

* Update help-page.ts

timers-related string changes
2025-02-06 15:17:30 +07:00
llama
8dea502689
add cut handler in TagInput (#3791) 2025-02-06 14:26:44 +07:00
dependabot[bot]
0b7afea63e
Bump vitest from 2.1.3 to 2.1.9 (#3790)
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 2.1.3 to 2.1.9.
- [Release notes](https://github.com/vitest-dev/vitest/releases)
- [Commits](https://github.com/vitest-dev/vitest/commits/v2.1.9/packages/vitest)

---
updated-dependencies:
- dependency-name: vitest
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-06 14:24:51 +07:00
Jarrett Ye
54679c5779
Fix/disable FSRS short-term scheduler if w[17] or w[18] is zero (#3788)
* Fix/disable FSRS short-term scheduler if w[17] or w[18] is zero

* fix bracket

* rename variable
2025-02-06 14:24:40 +07:00
llama
2cbcd79a84
Cap preview cols to prevent stall when csv is parsed with the wrong delimiter (#3786)
* cap csv import preview table at 1000 columns

* add fluent message

* show warning when preview table columns have been truncated

* simplify fluent message ($count will almost always be a big num)

* _tr -> tr
2025-02-06 14:23:43 +07:00
Luc Mcgrady
dd93691b9c
Added: SpinnerBox percentage symbol. (#3777)
* Added: Padded percentage symbol

* Added: Floating percentage

* ./check

* half finished comment

* Removed: redundant toStringValue function

* Removed: Accidental import

* Improved pointer-events:none

* Improve percentage alignment

* Improve leftmost percentage alignment

* Fix: Percentage sticks to left

* ./check

* Fix: IOS css

* ./check
2025-02-06 14:21:26 +07:00
Luc Mcgrady
93032cdceb
Delete y-axis titles for graphs (#3789)
* Remove simulator y axis labels

* Remove forgetting curve y-axis title

* ./check

* Mark the card-stats string as deprecated as well (dae)
2025-02-06 14:17:39 +07:00
Damien Elmes
de7a693465 Latest openssl CVE 2025-02-03 15:17:07 +07:00
Jarrett Ye
7781d1b471
Update to FSRS-rs v2.0.3 (fix simulator) (#3784) 2025-02-02 23:35:34 +07:00
llama
009a683e62
Fix discard changes randomly being a noop on certain linux systems (#3781)
* fix discard changes randomly being a noop on certain linux systems

* use QApplication.setActiveWindow instead

* revert current impl

* wait for the next event loop iter before calling activeWindow
2025-02-02 23:31:36 +07:00
llama
fab939e0e1
add image context menu actions for io mask editor (#3779) 2025-01-31 00:06:29 +11:00
llama
3641030b35
fix error when right-clicking empty space in update addons dialog (#3780) 2025-01-30 23:42:27 +11:00
Expertium
ca9fb505aa
Added "preset" to "Optimize all" and "Optimize current" (#3778)
I think this one really calls for a poll. Dae, I highly suggest you to ask multiple users whether "Optimize current" and "Optimize all" are clear enough or need "preset". I'm pretty sure most people will find it confusing without "preset".
2025-01-30 23:41:01 +11:00
llama
56dd93b5be
Add drag/drop support when adding IO images (#3776)
* allow adding images via drag/drop when adding io

* support editing io notes as well

Co-authored-by: Abdo <abdo@abdnh.net>

---------

Co-authored-by: Abdo <abdo@abdnh.net>
2025-01-27 18:58:58 +03:00
llama
00501c267c
fix copying images with filenames containing reserved chars (#3775) 2025-01-27 16:57:31 +03:00
Damien Elmes
b65fa693da Hack in a fix for wheel generation 2025-01-27 01:20:58 +11:00
Damien Elmes
7a61e52576 Auto-expand bundle progress in Buildkite on Linux 2025-01-26 19:37:34 +11:00
Damien Elmes
c398baca7a Bundling got broken in the revert to Qt 6.6 2025-01-26 19:32:01 +11:00
Damien Elmes
92b1144d97 Bump Rust to 1.84
+ fix new warnings/lints
+ update pyo3 to fix some other warnings
2025-01-26 18:51:21 +11:00
Damien Elmes
a05e41e035 Update translations 2025-01-26 18:20:40 +11:00
Damien Elmes
169d85883d Reviews graph: orange -> blue
Closes #3764
2025-01-26 17:45:14 +11:00
Damien Elmes
5ccc6304e3 Fix drag&drop on some Linux systems
Thanks to Ab_Bc:
https://forums.ankiweb.net/t/image-occlusion-not-working-jan-2025/54523/17

Closes #3767
2025-01-26 17:31:54 +11:00
Damien Elmes
5c84a0cb5e
Fall back to SM2 relative order when memory state missing (#3771)
Closes #3770
2025-01-26 17:26:46 +11:00
Damien Elmes
71ae5a6b67 Use a simple menubar for addcards on macOS
This makes initial-open and reopen behaviour consistent.

Closes #3659
2025-01-26 17:05:09 +11:00
Damien Elmes
7884edfd3a
Yarn 4 (#3772)
* Update to yarn 4, and pin the version

* Use yarn to invoke prettier, as yarn 4 is not setting +x

* Fix a few peer dependency warnings
2025-01-26 14:40:17 +11:00
Mike Hardy
2ef46afb48
build: specify the canvas transitive node dependency build failure workaround in future-compatible way (#3752)
* fix: specify canvas npm optional dep ignore workaround more cleanly

this should allow it to work with yarn classic and yarn modern

* chore: add self to CONTRIBUTORS
2025-01-26 11:57:30 +11:00
Jarrett Ye
43e860783b
Fix/re-optimize FSRS if short-term param is weird (#3742)
* Fix/re-optimize FSRS if short-term param is weird

* Reset progress when another run is required (dae)

* only count the same-day steps

* Fix flicker when optimizing again (dae)
2025-01-26 10:42:17 +11:00
Damien Elmes
5883e4eae8 Move Optimize All action into main deck options page
Closes #3696

I have no strong feelings about the message/button wordings or
layout, so if people have better suggestions, they are welcome.
2025-01-25 22:57:05 +11:00
Damien Elmes
c253d40d1d Use prettier's cache
Approximately halves runtime on my system
2025-01-25 22:52:25 +11:00
Damien Elmes
3d13d259bb Use Qt 6.8 on ARM Linux; add tools/run-qt6.8
Prior to this change, ./run fails out of the box on ARM systems, as Qt
wasn't available on PyPI until the 6.8 release.

Also added a script in tools/ for testing Qt6.8 issues on other platforms.
2025-01-25 21:59:31 +11:00
Damien Elmes
cd1824165f Revert "Qt 6.8.1"
This reverts commit 04228de666.

Anki 25.01 Beta 1 revealed a bunch of regressions with the latest
Qt, and zero reports of improvements from it, so we'll be better off
holding off on it for now, and perhaps reporting the deadkeys issue
to Qt once we've got a proper reproduction process.
2025-01-25 21:41:33 +11:00
Luc Mcgrady
f038d6726a
Fix: Simulator Ignores New Cards Already Introduced (#3760)
* Subtract introduced:1 count from learn count of first day of simulator.

* Fix: Cards filtered

* Tidy up

* Fix: Cards filtered (2)

* ./check

* Removed unnecessary filter

* Fix: Doesn't work for real new cards

* ./check

* Fix: .is_none()

* Limit to 1 day

* Removed "days_to_simulate" argument from convert
2025-01-25 21:16:25 +11:00
user1823
b80384c715
More accurate sorting by R (#3747)
* Match calc of relative overdueness in SM2 and FSRS

* Fix calculation of FSRS relative overdueness

* Improve readability by avoiding double negative

* Move comment line
2025-01-25 21:15:49 +11:00
llama
9b2987b4a8
Fix numeric deck and notetype names being treated as ids when importing csv (#3748)
* fallback to treating deck and notetype ids as names

* add test for metadata
2025-01-25 20:13:30 +11:00
Omar Kohl
eaec53bfc4
Ignore SYNC_PORT and SYNC_BASE in syncserver Dockerfile (#3716)
Hardcode them to:

    SYNC_PORT=8080
    SYNC_BASE=/anki_data

If these env variables are passed into the container with different values,
they are ignored.

The reasons is if the user modifies SYNC_BASE they risk data loss since
anki-sync-server will no longer write data into the volume. If they change
SYNC_PORT they need to also change it when mapping this internal port to the
external port of the container, which could be confusing plus it has no benefit
to allow this since it's always possible to change the external port even if
the internal port is fixed to 8080 (e.g. `-p 1234:8080`).

In both cases there is no benefit to making these values configurable and there
are risks associated.

Unfortunately there is no easy way of implementing this for the
Dockerfile.distroless so it's up to the user not to modify these values.
2025-01-25 19:28:55 +11:00
Damien Elmes
5ef8e33d42 Update translations 2025-01-25 19:25:24 +11:00
Ross Brown
dc37a28de0
Add translation strings for True Retention table (#3745)
* Add translation strings for True Retention table

* Hard-code strings to make pylint happy
2025-01-25 19:18:43 +11:00
GithubAnon0000
e32292585b
FIX lang selection resetting to en_US for some langs (#3744)
* FIX lang selection resetting to en_US for some langs

Fixes https://forums.ankiweb.net/t/anki-25-01-beta/54490/17?u=anon_0000.

# Issue
Set a hand full of certain languages in the preferences screen and see that the translations have been applied after reboot. The language selection in preferences wrongly shows en_US though, not the current active language. If you wanted to switch to `en_US` in this case, then you'd have to first switch to a working language (like de_DE) and then switch to en_US.

# Solution
`anki/qt/aqt/preferences.py` has the functions `setup_language()` and `current_lang_index()`. I noticed that it defaults to en_US, if the language is not in `compatMap` and it couldn’t return the index of the current language. No idea if this code is faulty but I headed over to `anki/pylib/anki/lang.py` afterwards.

Here, in `compatMap`, I added e.g. `"la": "la_LA"`. I knew the code since I could get it with `print("––– lang is ", lang)` in `preferences.py` (`current_lang_index()` retrieves `la` for latin).

After adding those code changes from my PR, the problem for those selected languages had gone away.

No idea if that's best practices though or if something else should be fixed instead.

* UPDATE CONTRIBUTORS adding myself to the list
2025-01-25 19:14:50 +11:00
llama
df808727c8
fix changes to tags not being reflected when editing in io mode (#3768) 2025-01-25 10:36:21 +03:00
Omar Kohl
71e2a6f782
Introduce PUID and PGID env variables to syncserver Dockerfile (#3714)
PUID and PGID are optional env variables to specify the user and group id of
the user that the anki-sync-server process should run with.

This gives more flexibility for solving permission problems with volumes and is
a common pattern for Docker images (e.g. see here:
https://docs.linuxserver.io/general/understanding-puid-and-pgid/)

The anki-sync-server process will write any files with the permissions of the
user it's running with, which can be a problem when you need to access those
files from outside the container or when they are being written into a bind
mount that is owned by a particular user on the host system.

To be able to implement this the entrypoint.sh needs to run as root (since it
needs to create a user and change file permissions). anki-sync-server then
needs to be started with the user 'anki', which is why the new dependency
'su-exec' is required. The user 'anki' and group 'anki-group' can no longer be
created at image build time because then their ids would be fixed.

Also update the build instructions to require building the Docker image inside
the directory where the Dockerfile resides since the build now needs to copy
the entrypoint.sh and it seems wrong the specify the path
docs/syncserver/entrypoint.sh inside the Dockerfile.
2025-01-25 18:19:38 +11:00
Arthur Milchior
6c37d5fc70
Add percentage to FSRS spinner (#3679)
* Add percentage to FSRS spinner

This commit add a percentage option in SpinBox and SpinBoxFloatRow, set to False
by default.

If it's true, a percent symbol is added at the end of the line before
the increase/decrease button.

While the value is represented as a percentage without decimal places,
the internal representation is not changed. Which mean that a
multiplier must used to compute the string value, indicate to the
input field the min, max and step, and when updating the result.

* Remove unsightly percentage sign, and update historical retention too

https://github.com/ankitects/anki/pull/3679#issuecomment-2579636981

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-01-25 18:17:02 +11:00
llama
873c4e617d
Recognise and check for media referenced in <source> tags (#3763)
* recognise and check <source> tags for media

* add test
2025-01-25 10:16:24 +03:00
llama
8ec94e281c
Remove unfinished polygon when undoing and redoing in IO mode (#3759)
* make removeUnfinishedPolygon return whether a polygon was removed

* treat removing an unfinished polygon as a discrete undo step

* has to be handled when redoing as well, but not as a discrete step
2025-01-25 10:08:47 +03:00
llama
d463f11d07
Allow reopening the add cards window (#3756)
* allow reopening the add cards window

* deck needs to be changed after notetype
since changing notetype potentially changes deck
2025-01-25 09:54:10 +03:00
kelciour
760ce162fb
Cleanup avplayer on profile close (#3754) 2025-01-25 09:44:15 +03:00
Damien Elmes
3364daa0cc Update translations 2025-01-24 22:42:07 +11:00
Damien Elmes
f3626c72b7 Ankiweb ID -> Email
https://forums.ankiweb.net/t/harmonization-email-and-ankiweb-id-strings/54817
2025-01-24 22:41:23 +11:00
Damien Elmes
28ba578fc7 Fix invalid reschedule revlog entries
https://forums.ankiweb.net/t/statistics-messed-up-after-fsrs-reschedule/54622

Caused by syncing the revlogs in a normal sync to a client that doesn't
understand them yet - they end up using the default for RevlogReviewKind
instead, which is 0.
2025-01-24 19:06:50 +11:00
Damien Elmes
5f68c5208e Use only newer vite version
https://github.com/ankitects/anki/pull/3765
2025-01-24 18:36:38 +11:00
Damien Elmes
455677a5c0 Ensure sveltekit gets built before congrats page
Fixes race condition in build
2025-01-24 18:32:19 +11:00
Damien Elmes
2d1c6c64e8 Add a separate route for card info in the sidebar
The move to Sveltekit broke the 'card info during review' add-on and
its descendants. This didn't get noticed in 24.11 due to the old
card-info.js file still being shipped.

I considered adding back the card-info.js generation, but it ended up
being simpler to move parts of the add-on into a separate page instead.
This is a stop-gap solution - in the future I'd like to get us to a
point where such component compositions can be done by add-ons,
and don't need to be done as part of Anki's build process.

Related: #3187
2025-01-24 18:08:11 +11:00
Damien Elmes
774d57cdc8 Restore the missing external congrats page 2025-01-24 16:21:36 +11:00
Damien Elmes
bc48eb4595 Log Anki version at startup
Useful for confirming running version when debugging startup problems
2025-01-24 14:33:34 +11:00
Damien Elmes
c9e0469f60 Bump vite for latest CVE 2025-01-24 14:07:01 +11:00
Damien Elmes
5974f5df7e Mention how about is not intended to mirror CONTRIBUTORS
https://github.com/ankitects/anki/pull/3750
https://github.com/ankitects/anki/pull/3575
2025-01-24 14:07:01 +11:00
Damien Elmes
06ef25755b Ensure pyoxidizer rebuilt on arch change
Fixes broken builds when switching between ARM and AMD on a Mac.
2025-01-24 12:50:00 +11:00
Damien Elmes
46310612ae Add camera to entitlements
https://forums.ankiweb.net/t/are-there-any-plans-to-allow-the-use-of-the-webcam-in-anki-for-mac/53851
2025-01-24 12:47:20 +11:00
user1823
64ca90934b
Increase font size in debug console (#3743) 2025-01-20 06:47:33 +03:00
Gregory
1be94a8b04
Update about.py (#3738)
add contributor
2025-01-18 17:19:09 +11:00
llama
430d5f5639
Revert Editor.set_note's signature change with an alternative approach for #3730 (#3736)
* remove orig_note_id param

* add and use Note.orig_note_id instead

* add and use Editor.orig_note_id instead
2025-01-18 17:14:09 +11:00
Jarrett Ye
d2ced60f7c
Update to FSRS-rs v2.0.2 (L2 regularization) (#3737) 2025-01-18 16:43:53 +11:00
Ross Brown
5b8d8247f8
Fix True Retention table clipping on overflow (#3735) 2025-01-18 16:00:13 +11:00
llama
86c2887e56
Add support for copied image files when adding IO notes (#3733)
* unhardcode allowed_suffixes

* support pasting urls from clipboard when adding io notes
2025-01-18 15:59:36 +11:00
Jarrett Ye
ac2b44859e
Feat/add future projection to forgetting curve with today marker (#3732)
* Feat/Add future projection to forgetting curve with today marker

* format

* remove the vertical line
2025-01-18 15:54:53 +11:00
Luca Auer
899cb89990
Prevent stale frames from being drawn / always ensure up-to-date contents in webview (#3668)
* Prevent stale frames being drawn.

At key points where external changes enter the webview, stale images might get rendered. This ensures that a frame showing current state is always shown.

* Only stage single redraw

* Remove potentially superfluous calls to `self.update()`

* Remove potentially superfluous calls to `self.update()`.

I lost this one during some git troubles.

* Revert unrelated change

The function is supposed to take a boolean telling it whether or not the loading succeeded, which it doesn't as is. However, this is unrelated and works either way so I also reverted it again.

* chore: code cleanup

* cleanup: Remove redundant check for presence of callback

A callback will be used either way for this call, so it can be simplified. The check happens inside the handler.

* Add comment explaining why this change is necessary, referencing the relevant PR.

* Clarify comment to answer the why, not the what.

One can see what is being done, why is probably more important.
2025-01-18 15:54:20 +11:00
Damien Elmes
7ba143bad8 Update translations 2025-01-17 16:03:17 +11:00
Damien Elmes
73d6641b7f Bump version 2025-01-17 16:03:17 +11:00
Damien Elmes
0653dae86c Unify AMD and ARM Docker images
+ Initial groundwork for AMD64 builds on ARM/Rosetta. Not currently
viable due to bugs in either Linux or Rosetta which results in a
Sveltekit build hanging indefinitely.
2025-01-17 16:03:17 +11:00
llama
9c0911891d
Fix "Create copy" for IO notes (#3730)
* expose get_image_occlusion_fields

* fix create copy for io

* revert current impl

* passthru original note id when creating copy

* add IOCloningMode

* fix create copy for io
2025-01-17 16:03:00 +11:00
Abdo
3acca96ed8
Fix issue in regex for underscored CSS imports (#3728)
* Use lazy quantifier in UNDERSCORED_CSS_IMPORTS regex

* Add test
2025-01-17 15:48:58 +11:00
user1823
c35237c94d
Don't treat manually scheduled cards with no reps as new cards (#3727)
Complements the change in https://github.com/ankitects/anki/pull/3639, ensuring that scheduler and rescheduling produce the same results.
2025-01-17 15:48:41 +11:00
Lukas Sommer
d153ce9241
Comments for translators (#3729) 2025-01-17 06:11:07 +03:00
user1823
5ef2328ea4
Clear memory states during bulk action if item is None (#3717)
* Clear memory states during bulk action if item is None

Prevents issues like https://forums.ankiweb.net/t/suggestion-copy-card-debug-info-button/54206/10 and https://github.com/ankitects/anki/issues/3634

* Fix entries not being removed if ignore_before_date after the last grade

* Fix test failure

* Also clear memory states when rescheduling using FSRS helper add-on if item is None
2025-01-15 20:49:15 +11:00
Luc Mcgrady
146a0b2dcf
"Copy template as markdown" button. (#3719)
* Added: Copy template info button

* Consistent with Ankidroid

* Fix: Missing newline

* Renamed variables

* ./check

* Fix: Remove ``` from templates

* Stylistic changes

* ./check
2025-01-15 20:29:35 +11:00
Damien Elmes
39e293b27d Increase allowed nesting level
Making it configurable would be complicated, so this just restores
the limit to close to the protobuf limit we were butting up against
for now.

Related: #3637
2025-01-13 16:03:27 +11:00
Damien Elmes
9a5c21739c Remove stale comment 2025-01-13 15:56:33 +11:00
Abdo
2c1a4895ba Switch back to Prettier for Svelte formatting
Closes #3649
Closes #3713
2025-01-13 15:53:55 +11:00
Damien Elmes
178a3faaf7 Remove run-lin/win
Since these are local to my setup, I'm better off using a shell
alias and not cluttering the repo.
2025-01-13 15:51:44 +11:00
Damien Elmes
3b4ada175d Minor tweaks to tools/ 2025-01-13 15:51:44 +11:00
llama
38821372dd
Use platform-native button layout in dialogs and messageboxes (#3725)
* set button-layout prop in stylesheet

* fix lint

* check for and use non-default layout on linux before falling back
2025-01-13 14:24:21 +11:00
Abdo
e98a597b4d
Fix flaky tests (#3724) 2025-01-13 13:56:52 +11:00
llama
2a1448bc45
Fix newer notes incorrectly being skipped when importing successive exports (#3693)
* add Note::set_modified_with_mtime

* add struct for Collection::update_note_inner_without_cards's args

* refactor Collection::update_note_inner_without_cards to use the arg struct

* add Collection::update_note_inner_without_cards_using_mtime

* use incoming note's mtime when updating notes during import
2025-01-13 13:42:44 +11:00
llama
afd7fca4cb
fix csv columns breaking when not contiguous (#3690) 2025-01-13 13:42:31 +11:00
wackbyte
b6afddd181
Reduce use of type casting (#3723) 2025-01-12 20:05:05 +11:00
wackbyte
493320fb33
Unpin svelte and update sveltekit-svg (#3722)
Warnings from enums were fixed in https://github.com/sveltejs/svelte/pull/14192
2025-01-12 18:06:54 +11:00
Yuki
db30685b9a
Refactoring and comments (#3721) 2025-01-12 15:46:20 +11:00
Ross Brown
d0a4fbb7aa
Fix "Note Types" dialog moving down each time it is opened (#3718) 2025-01-12 15:33:37 +11:00
Damien Elmes
2a85c6a2c0 glibc notes apply to AMD64 too 2025-01-12 15:07:12 +11:00
Damien Elmes
a83df635f7 Add camera usage description
https://forums.ankiweb.net/t/are-there-any-plans-to-allow-the-use-of-the-webcam-in-anki-for-mac/53851/10
2025-01-12 13:00:04 +11:00
Damien Elmes
1b5b6850bf Remove unused proto import 2025-01-12 12:58:17 +11:00
Damien Elmes
6966da14c2 Start installing PyQt6 into the Linux ARM64 venv by default
Now that an ARM wheel is on PyPI, we no longer need to rely on a
system PyQt to build on ARM. The install is skipped when PYTHONPATH
is set, so older distros with glibc <2.39 can continue to use the
system packages instead.
2025-01-10 22:26:30 +11:00
Damien Elmes
256822bbb1 Improve error when n2/ninja missing 2025-01-10 22:26:30 +11:00
Damien Elmes
3bdf61e2fd Improve error when git not installed 2025-01-10 22:26:30 +11:00
Omar Kohl
b189820218
Ensure data is stored in a volume in anki-sync-server Docker image (#3674)
Otherwise data would be lost by default when removing (or re-creating) a
container.

It would be possible to expose the default directory (e.g.
/home/anki/.syncserver) but it would be different for the two Dockerfiles and
less convenient for users of the Docker container to specify such a long path
when naming their volumes.

Setting the permissions is necessary since anki will be running with 'anki'
user permissions inside the container.
2025-01-10 21:42:55 +11:00
Yuki
9460911d90
Fix menubar in fullscreen (#3710)
* Fix/menubar in fullscreen

* CONTRIBUTORS file

* Fix/menubar in fullscreen

* CONTRIBUTORS file

* Fix and add Type hints
2025-01-10 20:18:32 +11:00
kelciour
53be365678
Fix mpv loadfile syntax change 2 (#3711)
* Revert "Fix mpv loadfile syntax change (#3105)"

This reverts commit 111f3bd138.

* Fix mpv loadfile syntax change 2
2025-01-10 19:16:08 +11:00
Damien Elmes
4c34a2d133 Fix Windows bundling
Missed in the Qt6.8 changes
2025-01-10 18:10:36 +11:00
Damien Elmes
1fb1cbbf85 Update translations 2025-01-09 23:40:00 +11:00
Damien Elmes
708a8a5830 More CVE dep updates 2025-01-09 23:38:51 +11:00
llama
ef94bf1cb0
Add support for html comments to template syntax (#3662)
* add support for comments to templates

* add tests

* add support for comments to CardLayout

* fix lints

* revert current impl

* extract parsing logic from legacy_text_token

* add support for comments to templates

* add tests

* refactor take_until_handlebar_start_or

* remove redundant rest

* Require full subclause match when locating next token (dae)

* Rework legacy template handling (dae)

The handlebar parser is now an instance method of a TemplateMode
enum, allowing us to avoid duplicate code for the legacy code path,
and the necessity to box up the iterator.

This does result in a change in behaviour: when the user has specified
the alternate syntax, the standard syntax will no longer be accepted.

* Remove stale comment (dae)
2025-01-09 23:35:48 +11:00
llama
b6d7bb190d
Fix IO editor always starting in "hide all, guess one" mode (#3709)
* update backend

* set hideAllGuessOne in mask editor instead
2025-01-09 23:14:02 +11:00
Jarrett Ye
c4ad27a2db
Feat/support new cards ignore review limit in simulator (#3707)
* Feat/support new cards ignore review limit in simulator

* ./ninja fix:minilints & ./ninja format

* use published crate

* make newCardsIgnoreReviewLimit reactive

* format

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-01-09 22:49:13 +11:00
llama
f0e67c4cd3
Fix image field not being saved if a mask is created too quickly (#3706)
* commit image field immediately in setupMaskEditor

* use saveFieldNow instead
2025-01-09 22:29:34 +11:00
David Elizalde
1bdd7f706f
Issue 2563 - remove mhchem (#3705)
* Issue 2563 - remove mhchem

* Update CONTRIBUTORS
2025-01-09 22:24:39 +11:00
Luc Mcgrady
59391e96fb
Added colour to simulator tooltip (#3692)
* Added colour to simulator tooltip

* ./check
2025-01-09 21:44:54 +11:00
llama
9499473caa
Fix EasyDays not applying defaults correctly in deck options (#3691)
* fix EasyDays not applying defaults correctly

* remove the svelte-ignore that's no longer needed
2025-01-09 21:32:16 +11:00
Luc Mcgrady
16514727ff
Simulator legend tooltip (#3676)
* Added: Tooltip to simulator legend

* Added: Memorised tooltip

* Add: Per day text

* Added: Group name to tooltip
2025-01-09 20:33:10 +11:00
Damien Elmes
5d150c74a4
Qt 6.8.1 (#3633)
* Qt 6.8.1

Bumps minimum glibc to 2.35, and minimum macOS to 12

* Drop generation of Qt5 packaged build

Closes #3615

* Include qt6 requirements in aqt wheel; drop extra deps

* Fix aqt wheels growing over time
2025-01-09 20:07:12 +11:00
Jarrett Ye
39bf29e1a6
Fix/last date of existing card should not be positive in simulation (#3667)
* Fix/last date of existing card should not be positive in simulation

* update fsrs-rs to v1.4.9

* ./ninja fix:minilints
2025-01-08 23:05:37 +11:00
Jake Probst
aaf8b4dddb
Easy days: revisited (#3661)
* new easy days algorithm

* take easy day percent totals in account when determining reduced scheduling

* Use variant method to avoid repeated mapping to a constant (dae)

It was probably not worth the time I took to change this ^_^;
2025-01-08 21:56:27 +11:00
Jarrett Ye
58bcab2484
Sort FSRSItems by RevlogId for training (#3660)
* Sort FSRSItems by RevlogId for training

* update fsrs-rs v1.5.0
2025-01-08 21:32:00 +11:00
Arthur Milchior
d7fc98d4d8
Deck options without bridge (#3571)
* NF: Modify CONTRIBUTORS

Just so that I stop getting the warning

* NF: Create `deckOptionsReady`

* NF: rename _close to require_close

The method will have to be used outside of this class, so can't be private

* NF: simplify slightly some code

* NF: remove bridge command from deck options

* Remove unused import

* Remove superfluous comment with a typo
2025-01-08 21:30:30 +11:00
llama
769f302ea8
Fix "discard changes" appearing on deck options (#3689)
* patch original config after a preset is selected for the first time

* update comment
2025-01-07 17:41:52 +03:00
llama
d01d83e2c6
convert floats to single-precision before comparing in isModified (#3686) 2025-01-07 17:13:43 +03:00
Luc Mcgrady
f057ee465d
Prevent simulate button spam (#3670) 2025-01-07 16:58:22 +03:00
Ben Nguyen
d89e6f3bdd
IO: Prevent text masks from flipping (#3672)
* Lock scaling flip when creating new text mask

* Lock scaling flip on existing text masks
2025-01-07 15:43:28 +03:00
llama
4ee6dacaa3
fix card info failing to load with qt5 (#3681) 2025-01-07 15:39:51 +03:00
llama
ca6002fd58
remove image menu feature when on qt5 (#3685) 2025-01-07 15:30:51 +03:00
sorata
f1a5808d83
Don't Exclude Suspended Cards from Retreivability Graph (#3665)
* Revert "Fix/skip suspended cards in graphs context retrievability (#3518)"

This reverts commit 939cc5a268.

* apply suggestions
2025-01-05 01:30:43 +03:00
Omar Kohl
6f2c959dc3
replace localhost with 127.0.0.1 in syncserver Dockerfile (#3673)
* Add myself to CONTRIBUTORS file

* replace localhost with 127.0.0.1 in syncserver Dockerfile

The healthcheck was failing, presumably because localhost was resolving to ::1
(IPv6), as detailed in this issue: https://github.com/maildev/maildev/pull/500
2025-01-05 01:24:29 +03:00
Ross Brown
9877e22fd2
Tweak how the True Retention stats table displays numbers (#3677)
* Tweak how the True Retention stats table displays numbers

- Always show fractional parts of numbers even if they are 0 (91.0% not 91%).
- Show "N/A" for percentages instead of 0% when there are 0 total reviews.

* Localise percentages correctly
2025-01-04 23:13:32 +03:00
llama
91b3740554
Stop audio playback on editor close (#3666)
* stop audio playback on browser close

* revert fix

* add caller-aware versions of play_file and stop_and_clear_queue

* stop editor's audio autoplay on close

* remove superfluous stop_and_clear_queue from addcards
2025-01-04 18:55:40 +03:00
Niclas Heinz
936e10bd76
update docker deps and docker docs (#3671)
* docs(docker): Change suggested version numbre

* deps(docker): Bump rust to 1.83.0 and alpine to 3.21.0

* deps(docker): Bump rust to 1.83.0

* CONTRIBUTORS: Add my name
2025-01-04 17:58:54 +03:00
Omar Kohl
7f12814bbe
avoid warning by setting SYNC_PORT as ARG in Dockerfile (#3675)
* Add myself to CONTRIBUTORS file

* avoid warning by setting SYNC_PORT as ARG in Dockerfile

    1 warning found (use docker --debug to expand):
    - UndefinedVar: Usage of undefined variable '$SYNC_PORT'
2025-01-04 17:51:43 +03:00
llama
5a7a9090b6
Allow choosing filtered decks in stats (#3687)
* add optional passthru param dyn to DeckChooser

* include filtered decks when choosing decks in stats
2025-01-04 17:39:16 +03:00
user1823
7fa544df9b
Add some unit tests (#3678)
* Add some unit tests

Covers most of the cases encountered in https://github.com/ankitects/anki/pull/3639

* Format

* Update params.rs

Makes the test more robust.

* Update params.rs

When training, the first FSRS item is removed. That's why none of the other tests includes it.

Co-authored-by: Jarrett Ye <jarrett.ye@outlook.com>

* Improve naming

* Fix typo

---------

Co-authored-by: Jarrett Ye <jarrett.ye@outlook.com>
2025-01-04 17:26:23 +03:00
Lukas Sommer
9d1be9a413
Translation comments for actiony-all-selected and actiony-any-selected (#3658)
* Translation comments for actiony-all-selected and actiony-any-selected

* Update

* Update
2024-12-23 21:47:40 +10:00
Luc Mcgrady
c985acb9fe
Add memorized option to FSRS simulation graph (#3655)
* Added: Memorized option to graph

* Count -> Reviews

* Added: Margin to radio button input

* Fix: Labels

* ./check

* Check errors?

* bump fsrs to 1.4.6

* ./ninja fix:minilints

* Added: Don't show hidden simulator values.

* Bump to fsrs 1.4.7
2024-12-22 11:40:51 +10:00
llama
53a2e34a3f
Fix missing buttons on bottom bar when window is narrow (#3653)
* Delay offsetHeight query to account for reflow

* Handle invalid value if webview page was deleted
2024-12-22 11:29:54 +10:00
Ben Nguyen
3a7a1c7346
Don't parse TTS text as XML (#3651) 2024-12-22 11:09:00 +10:00
Ross Brown
5637390b50
Make the "True Retention" table pretty (#3640)
* Make the True Retention table pretty

* Hide absolute pass/fail table for 'all'

* Run './ninja format'

* Manually run prettier on Svelte 5 components

* Refactor to not use {#snippet}

* Fix lint to pass check:eslint

* Fix lint to pass check:svelte

* Rename t9n -> tr to follow code style

* Replace hard-coded string with a translation string

* Use assertUnreachable(...) for exhaustively matching enum
2024-12-19 00:41:57 +11:00
Jarrett Ye
e7fff9eba0
Fix/forget to update memory state during relearning (#3648) 2024-12-19 00:33:04 +11:00
Jarrett Ye
abef3f39ca
Fix/dataPoint index is off by one day in simulator & remove moving average (#3645)
* Fix/dataPoint index is off by one day in simulator

* remove movingAverage
2024-12-19 00:09:04 +11:00
Jake Probst
69e699dc13
Fix easy days causing load balancer to disproportionately schedule graduates to the furthest day (#3643)
* don't do easy days calculation if all days are the same ease
2024-12-18 23:49:59 +11:00
Luc Mcgrady
482874d4f0
Fix Fsrs simulator input problems (#3642)
* Fix: min value for Additional new cards not 0

* Fix: New cards/day default value not starting value

* Preset defaults for review intervals and per day.

* Fix: "Additional new cards to simulate" localisation

* Revert "Fix: "Additional new cards to simulate" localisation"

This reverts commit 9be61d9f93.
2024-12-18 23:43:51 +11:00
llama
b061da73d3
Replace use of window.postMessage in card info (#3646)
* Use anki.updateCard instead of window.onmessage in card-info

* Make card-info placeholder text grey

---------

Co-authored-by: Abdo <abdo@abdnh.net>
2024-12-18 11:32:07 +03:00
Jarrett Ye
474dbc2812
Fix/fallback to non-manual entry when first_of_last_learn_entries non found (#3639)
* Fix/fallback to non-manual entry when first_of_last_learn_entries non found

* refactor single_card_revlog_to_item(s)

* update unit test of bypassed_learning_is_handled

* move comment line

* remove first_relearn_entries

* skip cram entry

* only pick non_manual_entries after ignore date

* fallback to non_manual_entries if the first learning step is before the ignore date

* pass ci

* update ignore_before_date_between_learning_steps_when_reviewing

* shorten the comment

* Minor refactoring

- fsrs_items_for_memory_state - fsrs_items_for_memory_states
- single_card_revlog_to_item -> fsrs_item_for_memory_state
(to match fsrs_items_for_training)
- single_card_revlog_to_items -> reviews_for_fsrs
- Use struct instead of tuple for reviews_for_fsrs output
- Don't return count, since we're already returning the filtered list

* More renaming/comment tweaks

- non_manual_entries -> first_user_grade_idx
- change comments to reflect the fact that we're working backwards
- Use "user-graded" rather than "non-manual"

* Add extra unit test

* Some wording tweaks
2024-12-17 23:34:19 +11:00
Jarrett Ye
4d20945319
Fix/FSRS Simulator Failure: min > max (#3644) 2024-12-17 11:45:43 +03:00
llama
a0712b04e1
Split off path into its own arg (#3641) 2024-12-16 14:15:05 +03:00
Mani
65fd461ddc
Allow object to move to right edge and bottom edge and allow scroll of note fields when not using IO (#3630)
* allow drag and draw at right and bottom edge of canvas area

* allow scroll in fields, when mask editor hidden

* format code
2024-12-15 19:30:47 +03:00
Damien Elmes
d900506003 Fix 'type error: failed to fetch' in congrats screen
The previously-added catch was not working due to the implicit error
handling of the proto methods.

Closes #2895
2024-12-14 22:51:13 +11:00
llama
b726e28229
Remove use of window.location.href in CardInfoDialog (#3621)
* Replace window.location in CardInfoDialog with load_sveltekit_page

* Fix format

* Fix ForgettingCurve's reactivity

* Props' default args aren't reactive

* Add global _updateCardId fn to card-info

* Use _updateCardId to reactively update card-info

* Fix format

* Fix type

* Use dummy form instead of window global for client-side nav

* Fallback to window.location in case form hasn't been rendered

* Use window.postMessage instead of dummy <form>
2024-12-14 22:45:54 +11:00
Jarrett Ye
adcac61b44
Update to FSRS-rs v1.4.4 (clipping post-lapse stability) (#3628)
* Update to FSRS-rs v1.4.4 (clipping post-lapse stability)

* ./ninja fix:minilints
2024-12-14 22:01:34 +11:00
OuOu2021
008edbba28
I18n: Improve i18n and multi-platform display of FSRS Simulator (#3611)
* Improve i18n and multi-platform display of FSRS Simulator

* Tweak the graph bounds to avoid overlapping of the y-axis tick values ​​and the y-axis title

* Update CONTRIBUTORS

* I18n for 4 more strings

* Reduce TitledContainer wrapper of fsrs simulator graph to maximize content display area

* Clean unused variables

* Update ftl/core/deck-config.ftl

* Update ftl/core/deck-config.ftl
2024-12-14 21:59:00 +11:00
a.r
1fb5e99efc
typeanswer: [type:nc] - use nfkd again (#3627) 2024-12-14 21:53:48 +11:00
llama
a2ad0bce55
Fix CardInfoPlaceholder not showing when card id is invalid (#3631)
* Catch bigint parsing error

* Modify CONTRIBUTORS
2024-12-14 21:32:51 +11:00
llama
2d207ff5ba
Remove hardcoded note/card colours from switch.py (#3629)
* Remove hardcoded note/card colours in switch.py

* Modify CONTRIBUTORS

* Switch to None as a safe default value
2024-12-14 21:30:28 +11:00
Bart Louwers
36d0fddd38
[Qt 6.7] Set ForceDarkMode attribute in AnkiWebView (#3622)
* Set ForceDarkMode attribute in AnkiWebView

* Use hasattr for backward compatibility

* Make mypy happy
2024-12-14 21:29:30 +11:00
Damien Elmes
d014f72377 Update url crate to fix idna vuln 2024-12-14 21:03:02 +11:00
Damien Elmes
9c3f89466d Fix glibc tag for AMD build 2024-12-09 19:40:16 +11:00
OuOu2021
cee04bf20c
Apply gradient effect to forgetting curve (#3604)
* Add gradient color for forgetting curve

* Add desiredRetention prop for CardInfo

* update CONTRIBUTORS

* Formatting

* Tweak range of gradient

* Tweak: salmon -> tomato

* Get desired retention of the card from backend

* Add a reference line for desired retention

* Fix: Corrected the steel blue's height & Hide desired retention line when yMin is higher than desiredRetentionY

* Add y axis title

* Show desired retention in the tooltip

* I18n: improve translation and vertical text display

* Revert rotatation&writing-mode of vertical title

* Tweak font-size of y axis title

* Fix: delete old desired retention line when changing duration

* Update ftl/core/card-stats.ftl

---------

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2024-12-09 17:44:05 +11:00
BlueGreenMagick
3b99ae4b91
Fix deck options button twitching on hover (#3623)
* Fix options page tab button text twitching on hover

* Fix options help modal button layout shifting on hover
2024-12-09 16:12:36 +11:00
Ross Brown
d1032d86a7
Make sure Anki resets the QtMessageHandler as it is exiting (#3620) 2024-12-09 15:39:45 +11:00
Ben Nguyen
128f54ed90
Fix reuse internal clipboard for primary selection pasting (#3613)
* Pass down clipboard mode

* Add type annotation
2024-12-09 15:38:52 +11:00
Luc Mcgrady
d6ffaa921f
Add "No reviews to optimize" message (#3610)
* Separate failed message from optimal

* No reviews only

* Fix: Can't block optimize if not optimal

* Wording change

* Update ftl/core/deck-config.ftl

* Simplify code (dae)
2024-12-09 15:21:58 +11:00
hideo aoyama
039c7fc0a9
Snap: keep LD_LIBRARY_PATH when in snap environment (#3618) 2024-12-07 00:42:03 +11:00
Ben Nguyen
a4626bf48e
Remove infinite spinning icon for reset parameters dropdown and add a question mark (#3603)
* Add question mark to popup words

* Remove spinning icon

* Formatting
2024-12-07 00:41:34 +11:00
user1823
f345517dcc
Change font of debug console to Consolas (#3606) 2024-12-07 00:37:43 +11:00
Luc Mcgrady
6524a24a89
Slider easy day gui (#3605)
* Slider easy day gui

* Removed: Borders

* Added: Bottom borders
2024-12-07 00:34:56 +11:00
sorata
d897b4588e
update error message (#3612)
Co-authored-by: Abdo <abdo@abdnh.net>
2024-12-06 03:05:49 +03:00
Ben Nguyen
496d76e478
Hide progress text when done (#3609) 2024-12-06 02:53:24 +03:00
Sawan Sunar
f6a3e98ac3
fix deck button not clickable in stats screen (#3602)
Changed z-index of the underlying spinner
2024-12-02 19:34:39 +03:00
Damien Elmes
87ccd24efd Update translations 2024-11-26 22:00:20 +10:00
Jarrett Ye
6874440cda Fix/incorrect memory state inference for incomplete review history (#3599)
make ci happy
2024-11-26 21:57:09 +10:00
dependabot[bot]
67e7bf1660
Bump @sveltejs/kit from 2.7.3 to 2.8.3 (#3598)
Bumps [@sveltejs/kit](https://github.com/sveltejs/kit/tree/HEAD/packages/kit) from 2.7.3 to 2.8.3.
- [Release notes](https://github.com/sveltejs/kit/releases)
- [Changelog](https://github.com/sveltejs/kit/blob/main/packages/kit/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/kit/commits/@sveltejs/kit@2.8.3/packages/kit)

---
updated-dependencies:
- dependency-name: "@sveltejs/kit"
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-26 20:54:19 +10:00
Damien Elmes
13865dc0bb Rust updates for CVE and yanked package 2024-11-26 20:53:05 +10:00
Abdo
2cd6b1c3b7
Fix congrats screen not refreshing (#3594) 2024-11-24 20:52:56 +10:00
Jarrett Ye
9a013d8601
Fix/FSRS progress sometime shows 0 reviews (#3591)
* Fix/FSRS progress sometime shows 0 reviews

* wait for progress_thread

* set 200ms timeout
2024-11-24 20:52:12 +10:00
Damien Elmes
69ac450098 "Fields for ..."
https://forums.ankiweb.net/t/add-note-type-name-to-the-fields-editor/52263
2024-11-23 22:45:19 +11:00
dependabot[bot]
3c20b49cca
Bump cross-spawn from 7.0.3 to 7.0.6 (#3590)
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-19 15:31:41 +10:00
Damien Elmes
4486227178 Bump mimalloc for CVE 2024-11-19 15:27:39 +10:00
Damien Elmes
01c368654b Remove remaining remnants of unused error; fix CI 2024-11-19 15:26:02 +10:00
Jean Khawand
15fde04264
Bump rust base image 1.80.1 to 1.82.0 (#3587) 2024-11-18 23:42:24 +10:00
Jarrett Ye
e992d6d462
Fix/inconsistent retrievability calculations between normal/filtered decks and display/sorting (#3582) 2024-11-18 01:24:04 +10:00
user1823
1c3754f6c7
Improve wording of optimal retention tooltip (#3579)
The previous wording was tautological.

Originally reported in https://forums.ankiweb.net/t/retrievability-vs-retention/51764/11
2024-11-18 01:20:58 +10:00
user1823
db1280e6ae
Exclude new cards from Future Due stats (#3576)
* Exclude new cards from Future Due stats

https://github.com/ankitects/anki/pull/3530#issuecomment-2439924619

Before 7ea573b004, they were excluded anyway.

* Update future_due.rs

* Update comment

* Minor simplification
2024-11-18 01:19:27 +10:00
Abdo
2cbb648456
Fix editor width changing as tag completions shown (#3574)
* Fix editor width changing as tag completions shown

* Avoid @render for now

* Ignore eslint warning
2024-11-18 01:11:21 +10:00
RumovZ
b933796a51
Fix setting tags column to first unmapped column (#3568)
Closes #3561.
2024-11-18 00:39:13 +10:00
Abdo
03c50c8332
Do not show warning if Browser Appearance has no field references (#3566) 2024-11-18 00:38:21 +10:00
sorata
d3f2f45805
update links (#3562) 2024-11-18 00:37:21 +10:00
user1823
15b48cf894
Correct a comment (#3570)
Because of the `entry.button_chosen == 0` part, it also filters out reschedule entries. Frankly, we don't need the `(entry.review_kind == RevlogReviewKind::Rescheduled)` part, but I didn't remove it yet.

Co-authored-by: Abdo <abdo@abdnh.net>
2024-11-17 13:08:01 +03:00
Ben Nguyen
9d09c32ece
Enable strict_optional for aqt/tagedit, utils, sync (#3578)
* Enable strict_optional for tagedit

* Fix mypy errors

* Enable strict_optional for utils

* Fix mypy errors

* Enable strict_optional for sync

* Fix mypy errors

---------

Co-authored-by: Abdo <abdo@abdnh.net>
2024-11-15 16:29:19 +03:00
Ben Nguyen
29f714d973
Enable strict_optional for aqt/mediasync, package, progress (#3577)
* Enable strict_optional for mediasync

* Fix mypy errors

* Enable strict_optional for package

* Fix mypy errors

* Enable strict_optional for progress

* Fix mypy errors
2024-11-15 16:24:50 +03:00
Ben Nguyen
edf59c2bb2
Enable strict_optional for aqt/deckchooser, about, webview (#3573)
* Enable strict_optional for deckchooser

* Fix mypy errors

* Enable strict_optional for about

* Fix mypy errors

* Enable strict_optional for webview

* Fix mypy errors

* Fix merge error

* Revert utils

* Add early returns

---------

Co-authored-by: Abdo <abdo@abdnh.net>
2024-11-13 12:06:55 +03:00
Ben Nguyen
db7f128b83
Enable strict_optional for aqt/mediacheck, theme, toolbar (#3569)
* Enable strict_optional for mediacheck

* Fix mypy errors

* Enable strict_optional for theme

* Fix mypy errors

* Enable strict_optional for toolbar

* Fix mypy errors
2024-11-12 19:47:04 +03:00
Abdo
763712c696
Remove outdated TODO (#3567) 2024-11-09 18:42:49 +03:00
Ben Nguyen
fdaad7150e
Enable strict_optional for aqt/debug_console, emptycards, flags (#3565)
* Enable strict_optional for debug_console

* Fix mypy errors

* Enable strict_optional for emptycards

* Fix mypy errors

* Enable strict_optional for flags

* Fix mypy errors
2024-11-09 13:43:51 +03:00
Abdo
748aa0f07a
Bump AnkiHub API version (#3564) 2024-11-09 04:05:26 +03:00
Damien Elmes
97e6b3d35b Update translations 2024-11-08 22:54:26 +10:00
Damien Elmes
ba1f5f46c6 Flag server messages so AnkiDroid can handle them separately 2024-11-08 22:54:15 +10:00
sorata
1b192dca6b
Move to all "Note type" (#3560)
* update change-notetype.ftl

* update notetypes.ftl

* update errors.ftl

* update adding.ftl

* update actions.ftl

* update browsing.ftl

* update exporting.ftl

* update importing.ftl

* update card-templates.ftl

* update database-check.ftl

* fix casing

* Update ftl/core/adding.ftl

Co-authored-by: Abdo <abdo@abdnh.net>

---------

Co-authored-by: Abdo <abdo@abdnh.net>
2024-11-08 22:53:57 +10:00
Damien Elmes
b646f09c68
Add descending retrievability (#3559)
* "relative overdueness" -> "retrievability ascending"

* Add 'retrievability descending'
2024-11-08 22:53:13 +10:00
Ben Nguyen
a150eda287
Enable strict_optional for aqt/notetypechooser, stats, switch (#3558)
* Enable strict_optional for notetypechooser

* Fix mypy errors

* Enable strict_optional for stats

* Fix mypy errors

* Enable strict_optional for switch

* Fix mypy errors

---------

Co-authored-by: Abdo <abdo@abdnh.net>
2024-11-08 13:42:42 +03:00
Damien Elmes
7f5e081014 Bump version to 24.11 2024-11-07 17:05:27 +10:00
Damien Elmes
1f96489755 Fix invalid preset search matching cards in filtered decks
https://forums.ankiweb.net/t/anki-24-10-release-candidate/51191/64
2024-11-07 16:52:50 +10:00
Jake Probst
487b38b06c
include backlog cards in today in future due graph (#3379)
* include backlog cards in today in future due graph

when backlog option is not checked

* Don't add the backlog to today when backlog disabled

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2024-11-07 09:06:07 +10:00
Damien Elmes
b4ae7ce907 Remove unused link 2024-11-07 08:37:32 +10:00
Abdo
eb393aeaee
Warn if no day is set to Normal (#3557) 2024-11-07 08:35:39 +10:00
Ben Nguyen
ac731624e1
Enable strict_optional for aqt/deckoptions, editcurrent, filtered_deck (#3556)
* Enable strict_optional for filtered_deck

* Fix mypy errors

* Enable strict_optional for editcurrent

* Fix mypy errors

* Enable strict_optional for deckoptions

* Fix mypy errors
2024-11-07 08:33:41 +10:00
Abdo
11d2b91268
Fix target deck reset to notetype-specific setting (#3555) 2024-11-07 08:32:42 +10:00
Abdo
4dcbcdb0ce
Escape special search characters in preset name (#3554) 2024-11-07 08:32:00 +10:00
Abdo
442ddb085a
Fix UI hanging with empty context menu (#3553) 2024-11-05 17:49:48 +03:00
Damien Elmes
898c91284b Update translations 2024-11-05 18:30:29 +10:00
Damien Elmes
9986ee54fd Latest waitress CVE 2024-11-05 18:30:08 +10:00
Abdo
43d9b00b85
Remove legacy import option (#3536)
* Remove legacy import option

* Always return False in legacy_import_export()
2024-11-05 18:25:06 +10:00
Abdo
7629a1b76f
Fix flaky tests (#3541)
* Fix flaky state_application() test

* Try to fix flaky unicode_normalization() test
2024-11-05 18:23:50 +10:00
Jarrett Ye
0fa9e0ef51
Feat/align FSRS-rs with PyTorch Implementation (#3540)
* Feat/align FSRS-rs with PyTorch Implementation

* Update to FSRS-rs v1.4.2

fix https://forums.ankiweb.net/t/anki-24-10-release-candidate/51191/37?u=l.m.sherlock

* Update to FSRS-rs v1.4.3

improve performance: https://github.com/open-spaced-repetition/fsrs-rs/pull/252
2024-11-05 18:20:28 +10:00
Ben Nguyen
8b84583433
Enable strict_optional for aqt/clayout, changenotetype, fields (#3544)
* Enable strict_optional for clayout

* Fix mypy errors

* Enable strict_optional for changenotetype

* Fix mypy errors

* Enable strict_optional for fields

* Fix mypy errors
2024-10-30 13:40:40 +03:00
Ben Nguyen
a25edecc88
Enable strict_optional for aqt/studydeck, tts, mediasrv (#3542)
* Enable strict_optional for studydeck

* Fix mypy errors

* Enable strict_optional for tts

* Fix mypy errors in tts

* Enable strict_optional for mediasrv

* Fix mypy errors in mediasrv
2024-10-29 12:05:54 +03:00
Ben Nguyen
7f58ca213c
Enable strict_optional for aqt/modelchooser.py (#3539)
* Enable strict_optional

* Fix mypy errors
2024-10-28 14:19:31 +10:00
Ben Nguyen
fbd53726cc
Enable strict_optional for aqt/deckdescription.py (#3538)
* Enable strict_optional

* Fix mypy errors
2024-10-28 14:18:16 +10:00
Ben Nguyen
2889299670
Enable strict_optional for aqt/deckbrowser.py (#3537)
* Enable strict_optional

* Fix mypy errors
2024-10-28 14:16:42 +10:00
Jarrett Ye
0ce907fe5b
Fix/buried new cards shouldn't be counted in daily load (#3530)
* Fix/buried new cards shouldn't be counted in daily load

* exclude new cards by its type

* ./ninja format
2024-10-28 14:10:10 +10:00
Abdo
8ebb274ff2
Merge pull request #3535 from bpnguyen107/aqt-strict-optional-taglimit
Enable strict_optional for aqt/taglimit.py
2024-10-27 17:12:48 +03:00
Abdo
a240de2652
Merge branch 'main' into aqt-strict-optional-taglimit 2024-10-27 17:10:21 +03:00
Abdo
d735b4cf00
Merge pull request #3533 from bpnguyen107/aqt-strict-optional-overview
Enable strict_optional for aqt/overview.py
2024-10-27 17:08:57 +03:00
Abdo
677664dea3
Merge branch 'main' into aqt-strict-optional-overview 2024-10-27 17:06:58 +03:00
Abdo
70eade0b8f
Merge pull request #3534 from bpnguyen107/aqt-strict-optional-customstudy
Enable strict_optional for aqt/customstudy.py
2024-10-27 17:04:07 +03:00
bpnguyen107
d7ed0fee16 Fix mypy errors 2024-10-26 19:33:04 -07:00
bpnguyen107
98c62ab75f Enable strict_optional 2024-10-26 19:27:00 -07:00
bpnguyen107
c02f234ce0 Fix mypy errors 2024-10-26 19:19:20 -07:00
bpnguyen107
8189255b34 Enable strict_optional 2024-10-26 19:17:25 -07:00
bpnguyen107
364a1ada00 Fix mypy errors 2024-10-26 19:07:43 -07:00
bpnguyen107
9f002491a4 Enable strict_optional for aqt/overview.py 2024-10-26 19:07:35 -07:00
Damien Elmes
8d9251e7e5 Remove FSRS client warning
https://forums.ankiweb.net/t/anki-24-10-beta/49989/290
2024-10-26 20:38:05 +10:00
Damien Elmes
1fb4430913 Fix due date showing incorrectly in filtered deck
Regressed in #3471

Closes #3515
2024-10-26 20:13:24 +10:00
Damien Elmes
1bf10ded79 Update translations 2024-10-26 20:03:04 +10:00
Damien Elmes
5e6e19a781 Rust 1.82 2024-10-26 20:02:53 +10:00
a.r
0513940305
template_filters: make {{type:}} forwards compatible (#3525)
Make Anki treat {{type:unknown:field}} field replacements as {{type:field}} instead of {{field}}.

The previous behavior was seriously inconvenient for several reasons, including:

* Updated client aren't all released at the same time, causing an unavoidable mismatch period. Now it causes the least friction.
* Devs couldn't readily test new in-dev variants without breaking/inconveniencing their own mobile experience.
* Some users will have (potentially perpetually) outdated Anki clients and likely complain, wasting both dev & deck creator time.

This way users always get to type and especially: The front side will always render as intended.
2024-10-26 19:58:52 +10:00
Ben Nguyen
e4eaaa57ab
Enable strict_optional for aqt/importing.py (#3527)
* Enable strict_optional

* Fix mypy errors
2024-10-26 19:56:34 +10:00
Damien Elmes
97b729c5d4 Fix another non reactive property warning
I waited for the PR check to pass first, but it failed to catch this,
presumably as newly-added files don't trigger the existing checks to
re-run.
2024-10-26 19:48:48 +10:00
Jarrett Ye
eacd5bf908
Feat/add a toggle in the simulator to display time or review count (#3523)
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2024-10-26 19:42:57 +10:00
Jarrett Ye
1aa734ad28
Fix/set default easyDaysPercentages when switch preset (#3526) 2024-10-26 19:38:37 +10:00
Jarrett Ye
9a44881121
export revlogs where the rating is between 1 and 4 for research (#3524) 2024-10-26 19:38:17 +10:00
Jarrett Ye
5caeac530e
Update to FSRS-rs v1.3.5 (FSRS-5 model update) && keep three decimals for stability (#3520)
* Update to FSRS-rs v1.3.5 (FSRS-5 model update)

* keep three decimals for stability

fix https://forums.ankiweb.net/t/fsrs-5-1d-scheduling-and-learning-steps/50242/122?u=l.m.sherlock
2024-10-26 19:36:27 +10:00
Ben Nguyen
507050c876
Enable strict_optional for aqt/preferences.py (#3519)
* Enable strict_optional for aqt/preferences.py

* Fix mypy errors
2024-10-26 19:33:53 +10:00
Jarrett Ye
939cc5a268
Fix/skip suspended cards in graphs context retrievability (#3518)
* skip suspended cards in GraphsContext retrievability

* avoid i32 overflow

* avoid u32 overflow
2024-10-26 19:09:20 +10:00
user1823
7500beaba3
Fix calculation of daily load (#3516)
* Fix calculation of daily load

* Daily load in reviews/day
2024-10-26 19:05:01 +10:00
Damien Elmes
fe0f5370b0
Revert "Fix ease button alignment (#3474)" (#3522)
This reverts commit 569a4705e7.
2024-10-26 18:50:02 +10:00
Damien Elmes
7e9da83d2c Update vitest and unpin vite 2024-10-26 18:41:59 +10:00
Damien Elmes
9649bbdcaa Force cookie update for CVE
Sveltekit won't update until 3.0

https://github.com/sveltejs/kit/pull/12768
2024-10-26 18:27:10 +10:00
Damien Elmes
014620ab65
Update to stable Svelte 5 release (#3513)
* Update to stable Svelte 5 release

This causes a bunch of warnings to be omitted:

ts/routes/graphs/RangeBox.svelte:52:18
Warn: Properties of objects and arrays are not reactive unless in runes mode. Changes to this property will not cause the reactive statement to update (svelte)
                break;
            case RevlogRange.All:
                $days = 0;

They are triggered on enum references, and it appears to be a bug.
May need to report it to Svelte?

* Deps update

* Silence spurious errors + fix a real one

https://github.com/sveltejs/svelte/issues/13811
2024-10-26 18:21:45 +10:00
Damien Elmes
a9ebf842ea werkzeug CVE 2024-10-26 18:06:27 +10:00
Damien Elmes
2eee54ef41 Add missing translation
https://forums.ankiweb.net/t/translation-not-working-for-days-to-simulate/50992/2
2024-10-22 23:58:24 +10:00
Damien Elmes
31fe7f2c89 Fix error when exporting from empty cards screen
https://forums.ankiweb.net/t/bug-copy-debug-info-button-crashes-anki-24-04-and-24-06-3/50852
2024-10-22 23:24:27 +10:00
Damien Elmes
23b7d63659 Update translations 2024-10-21 18:48:37 +10:00
Damien Elmes
6adbd922f7 Rename remaining 'weights' references to 'params' 2024-10-21 18:13:23 +10:00
Damien Elmes
c45fa518d2 Use separate field to store FSRS params
Will allow the user to keep using old params with older clients
2024-10-21 18:13:23 +10:00
Jarrett Ye
26ae51fafd
Create a new kind of revlog entry for reschedule cards on change (#3508)
* create a new kind of revlog entry for Reschedule cards on change

* add comments

* exclude the rescheduled case in reviews graph
2024-10-21 16:47:01 +10:00
Damien Elmes
30e734b925 Bump Rust deps
Primarily for prost, which had incompatible changes
2024-10-21 15:34:04 +10:00
sorata
84b6d20e1d
change sort order name (#3510) 2024-10-21 15:20:45 +10:00
Jarrett Ye
b0eb2a2b97
Feat/Estimated Total Knowledge By Note & Daily Load (#3507)
* Feat/Estimated Total Knowledge By Note & Daily Load

* Update rslib/src/stats/graphs/retrievability.rs

* Update rslib/src/stats/graphs/future_due.rs
2024-10-21 15:19:42 +10:00
Jarrett Ye
6ff309e08f
Feat/option to enable FSRS short-term scheduler when (re)learning steps run out && speed up features based on simulation (#3505)
* Update to FSRS-rs v1.3.2

* add fsrs_short_term_with_steps_enabled to config

* ./ninja fix:minilints

* fix defaults_for_testing

* if current parameters are invalid, skip comparison

fix #3498

* fix redundant_field_names

* cargo clippy --fix

* Update to FSRS-rs v1.3.3

* Update to FSRS-rs v1.3.4

* Avoid an extra config lookup on each card answer (dae)
2024-10-21 15:09:07 +10:00
Jarrett Ye
b09326cddd
Feat/export dataset for research (#3511)
* Feat/export dataset for research

* add comment

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>

* target_path is required

* format

* improve efficiency to look up parent_id

* move `use` down
2024-10-18 18:57:06 +10:00
Damien Elmes
c1a2b03871
Revert "NF: Improve typing of AnkiWebView action (#3475)" (#3504)
This reverts commit 18889239d2.
2024-10-16 03:02:22 +10:00
Han Yeong-woo
25070c505a
Fully switch to File::set_times() from utime crate (#3503)
* Fully switch to File::set_times() from utime crate

* Switch to open_file()

Future me will end up wondering why we're explicitly declaring read=true

* Fix failing on windows

* Minor tidy-up (dae)

* Fix comment typo
2024-10-16 02:35:37 +10:00
Taylor Obyen
569a4705e7
Fix ease button alignment (#3474)
* Fix ease button alignment

* Make CSS not 'hacky'
2024-10-16 01:46:55 +10:00
Jarrett Ye
f804abf758
Fix/only let FSRS take over short-term schedule when steps are empty (#3496) 2024-10-16 01:16:47 +10:00
Ben Nguyen
a537d349b8
Enable strict_optional for aqt/editor.py (#3500)
* Enable strict_optional for aqt/editor.py

* Fix mypy errors in EditorWebView class

* Fix mypy errors in Editor class

* DRY

* Match same short circuiting behavior

* Convention
2024-10-16 01:08:24 +10:00
Hikaru Y.
694a5089a9
Fix 'Discard changes' dialog appearing even when no changes are made (#3495)
* Fix 'Discard changes' dialog appearing even when no changes are made

https://forums.ankiweb.net/t/anki-24-10-beta/49989/166

* Fix geometry of deck options window not being saved

evt.accept() does not seem to trigger reject().
2024-10-16 00:47:33 +10:00
Cy Pokhrel
8f4cab6a1a
Fix editor loses focus when toggling list if list item empty (#3483)
* fix editor loses focus when toggling list if list item empty

* fix CONTRIBUTORS
2024-10-16 00:38:35 +10:00
Damien Elmes
f3ca4646fc
Revert "Fully switch to File::set_times() from utime crate (#3501)" (#3502)
This reverts commit 723b5e9bcc.
2024-10-16 00:35:26 +10:00
Han Yeong-woo
723b5e9bcc
Fully switch to File::set_times() from utime crate (#3501)
* Fully switch to File::set_times() from utime crate
 
* Switch to open_file() (dae)

Future me will end up wondering why we're explicitly declaring read=true
2024-10-16 00:31:17 +10:00
Damien Elmes
b75fd94c96 Update Rust deps
- Primarily for the latest RUSTSEC on pyo3
- utime has been pinned, as they've introduced a deprecation warning
without a solution being available for folder mtimes
2024-10-15 23:00:45 +10:00
Damien Elmes
743017b471 Partially switch to File::set_times() from utime crate 2024-10-15 23:00:38 +10:00
Damien Elmes
e77632d7b2 Fix UI hanging when update check stalls
https://forums.ankiweb.net/t/anki-24-10-beta/49989/222
2024-10-15 21:32:46 +10:00
Damien Elmes
111cefe8f1 Revert "When updating all FSRS parameters at once, exclude suspended cards"
https://forums.ankiweb.net/t/memory-state-of-suspended-cards/50460/6

This reverts commit 656cfe0b9c.
2024-10-12 22:09:05 +10:00
Jarrett Ye
f00211df35
add get_revlogs API && fix the style of tooltipText of ReviewsGraph (#3490)
* add get_revlogs API

* fix tooltipText of ReviewsGraph

the style of true-retention shouldn't affect the style of tooltipText of ReviewsGraph

* More verbose wording (dae)
2024-10-12 14:49:14 +10:00
Ben Nguyen
aaf4994e6f
Enable strict_optional for aqt/data, aqt/forms, aqt/import_export (#3489)
* Added spacing

* Enable strict_optional for aqt/data

* Update CONTRIBUTORS

* Enable strict_optional for aqt/forms

* Enable strict_optional for aqt/import_export

* Fix mypy errors in import_dialog.py

* Fix mypy errors in exporting.py

* Better variable name

* Stick to assert convention
2024-10-12 14:36:15 +10:00
Damien Elmes
eae9bbc473 Update translations 2024-10-12 00:28:11 +10:00
Damien Elmes
40f9e0dc7a Fix true retention table dimensions
https://forums.ankiweb.net/t/anki-24-10-beta/49989/118
2024-10-11 23:57:47 +10:00
Damien Elmes
78b9580447 Ignore mw typing error 2024-10-11 23:47:22 +10:00
Damien Elmes
b3a85a6515 Revert "Decide if element is bold by getComputedStyle (#2453) (#2579)"
This reverts commit 9ced6be03e.

Caused a regression:
https://forums.ankiweb.net/t/anki-24-10-beta/49989/150
2024-10-11 23:34:50 +10:00
Hikaru Y.
e79060487b
Fix broken tag editor in Svelte 5 (#3488)
* Fix temporary disappearance of a tag

https://forums.ankiweb.net/t/anki-24-10-beta/49989/47

* Fix incorrect behavior after tag deletion

* Fix tag addition/selection buttons becoming invisible

Once tags were selected, subsequent deselection or selection did not
mount 'TagAddButton' or 'TagsSelectedButton' components.
2024-10-11 23:21:00 +10:00
Ben Nguyen
931e1d80f2
Enable strict_optional in aqt/. and aqt/browser (#3486)
* Boolean naming convention

* Rename no_strict_optional -> strict_optional

* Update CONTRIBUTORS

* Enable strict optional for aqt module

* Fix errors

* Enable strict optional for aqt browser

* Fix layout.py errors

* Fix find_duplicates.py errors

* Fix browser.py errors

* Revert a0 a1 names

* Fix tree.py errors

* Fix previewer.py errors

* Fix model.py errors

* Fix find_and_replace.py errors

* Fix item.py errors

* Fix toolbar.py errors

* Fix table/__init__.py errors

* Fix model.py errors

* Fix state.py errors

* Fix table.py errors

* Fix errors in card_info.py

* Fix searchbar.py errors

* Fix name

* Fix assert in browser.py

* Formatting

* Fix assert vh

* assert is not None instead of truthy

* Split _move_current() up to correct type signature (dae)

We want either index or direction, but not both.
2024-10-11 23:12:48 +10:00
Tomas Fabrizio Orsi
d4a3e4828b
ts/src/app.html: Changed from favicon.png to favicon.ico (#3485)
Signed-off-by: Tomas Fabrizio Orsi <torsi@fi.uba.ar>
2024-10-11 22:25:58 +10:00
a.r
8af63f81eb
typeanswer: NFC fix & cleanup (#3482)
* typeanswer: cleanup

* DiffNonCombining's new() used String where plain Vec is appropriate
* get rid of normalize_typed for DiffTrait again by pulling code into DiffNonCombining's new()
* two DiffNonCombining testcases

* typeanswer: return to NFC & typos
2024-10-11 20:33:08 +10:00
Arthur Milchior
18889239d2
NF: Improve typing of AnkiWebView action (#3475)
There are only two types of actions. The code does not seems to
consider this to be extandable, and the changed variable is private,
so I would expect it relatively acceptable to change the way it
work. This would improve the typing.

If this is rejected, at least, the callback should be noted as
optional, so that the IDE does not complain that `if cb` can not be
false.
2024-10-11 20:16:20 +10:00
Taylor Obyen
7439c657f0
Add card position column and always show position in card info (#3471)
* Expose original position to columns and card info

* Fix contributors

* Change routine name and return, fix SQL file, utilize coalesce inline

* Handle cards without original position

* Remove unecessary conversion
2024-10-11 20:14:07 +10:00
Jarrett Ye
a982720a42
Feat/Easy Days (#3442)
* Feat/Easy Days

* format

* add easy_days_percentages to deck_config

* configure Easy Days via table

* remove unused code

* add translatable strings & add default of easy days

* don't check easy_days_percentages when deserialize

* pass test::all_reserved_fields_are_removed

* consider next_day_at when interval_to_weekday

* remove y-axis-title created in last simulation

* EstimatedTotalKnowledge should be integer

* Reorder deck option sections (dae)

- Move FSRS to bottom left, to move it closer to the top, and so
the left and right columns appear roughly balanced when FSRS is
enabled.
- Move Easy Days above Advanced

* Don't crash if wrong number of days (dae)

* Use lower field number (dae)

Repeated fields are more compactly stored in the first 15 fields.
2024-10-11 19:47:44 +10:00
Damien Elmes
79a6a4dc53 Pretend mw is set from the start
https://github.com/ankitects/anki/pull/3476#issuecomment-2395281774

Closes #3476
2024-10-10 22:17:58 +10:00
Damien Elmes
479aee0883 Fix updated template links
I forgot to update the PR before merging.
2024-10-10 20:52:14 +10:00
sorata
d98fc142f1
Change links in error messages (#3468)
* Update template.rs

* Update template.rs

* ./check (dae)
2024-10-10 20:47:11 +10:00
Hikaru Y.
407e2dc43b
Fix issues with 'Discard changes' confirmation dialog (#3478)
* Prevent memory leak

* Fix deck option changes not detected until focus is lost

* Accurately determine if there are any pending changes

This makes it so that the confirmation dialog appears when it should,
and not when it shouldn't.
2024-10-06 14:21:00 +10:00
Jarrett Ye
598233299e
Let FSRS control short term schedule (#3375)
* graduate card when user press hard and has 0 learning steps

* fix error: useless conversion to the same type

* do the same thing to again

* fix expected `Option<u32>`, found integer

* ./ninja format

* let FSRS control short term schedule

* Update to FSRS-rs v1.3.0

* ./ninja check:clippy

* Update to FSRS-rs v1.3.1

* Pin FSRS version (dae)

https://github.com/ankidroid/Anki-Android-Backend/pull/417

* Remove redundant parens (dae)
2024-10-06 12:20:18 +10:00
Damien Elmes
378c955905 Revert "Fix ease button alignment (#3404)"
This reverts commit a262e02f9d.

Due to regression:
https://forums.ankiweb.net/t/anki-24-10-beta/49989/119
2024-10-04 22:38:50 +10:00
Damien Elmes
80ebdf1988 Flip order of question/answer actions, and ascending/descending ease
https://forums.ankiweb.net/t/anki-24-10-beta/49989/53
2024-10-04 20:52:20 +10:00
user1823
de3b1754fa
Add "open image" option to editor (#3431)
* Add "open image" option to editor

* Update qt/aqt/editor.py

Co-authored-by: Ben Nguyen <105088397+bpnguyen107@users.noreply.github.com>

* Update editor.py

* Remove unused import

* Fix "show in folder"

* Fix 'show in folder' on macOS

* Revert "Fix "show in folder""

This reverts commit cf2b33ee9422bcaf8d9e20bd4cce74e5061c13cf.

* Reimplement show_in_folder for Windows (dae)

- Avoid reusing call(), as the startupinfo we were passing in was
breaking the explorer invocation
- Attempt to bring explorer to the front after the window has been show,
as it otherwise appears under Anki (at least when running from source)

---------

Co-authored-by: Ben Nguyen <105088397+bpnguyen107@users.noreply.github.com>
Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2024-10-04 20:51:55 +10:00
Damien Elmes
85f034b144 Split true retention into multiple tables; display vertically
This prevents the page scrolling off screen on small devices. This is
a quick fix, and further tweaks to the layout are welcome.
2024-10-04 17:04:22 +10:00
Damien Elmes
12cd3ca919 Update translations 2024-10-04 16:29:47 +10:00
Damien Elmes
6aff3c5f80 Update protobuf to fix Windows crash
https://forums.ankiweb.net/t/anki-24-10-beta/49989/109
2024-10-04 16:27:13 +10:00
박현우
761fb76ba7
Allow addon page URL on AddonsDialog (#3467)
* Allow users to just copy&paste addon page URL to addon 'code' field.

https://forums.ankiweb.net/t/get-addons-allow-url-on-code-section/36370
2024-10-04 15:02:29 +10:00
mmjang
9ced6be03e
Decide if element is bold by getComputedStyle (#2453) (#2579)
* Decide if element is bold by getComputedStyle (#2453)

* Use getComputedStyle() for italics too (dae)
2024-10-02 19:37:40 +10:00
Shirish Pokhrel
2ac27585b2
Fix editor loses focus when toggling list and copy selects wrong target deck for filtered decks (#3465)
* fix copy selects wrong target deck for filtered decks
2024-10-02 18:42:41 +10:00
a.r
cfd1eba7ec
typeanswer: hoist strip_expected (#3464)
(renamed from prepare_expected)

Single use makes it likelier to get inlined, too.
2024-10-02 18:28:18 +10:00
Ben Nguyen
cc45db0e22
Fix Mnemosyne importer chokes on due dates >= 2038 (#3459)
* Fix integer overflow

* Update CONTRIBUTORS
2024-10-02 18:20:44 +10:00
Jarrett Ye
159681d9f2
Fix/Reschedule doesn't work on cards in filtered deck (#3441)
* Fix/Reschedule doesn't work on cards in filtered deck

* Update docstring (dae)
2024-10-02 18:09:25 +10:00
Taylor Obyen
d6aa95950d
Fix occlusion drift again (#3443)
* Fix occlusion drift

* Fix image editor occasionally not loading fully

* Fix occlusion disassociation when browsing

* Address oversights

* Fix translucent modifier applies to newly created shapes incorrectly

* Fix i-text turns yellow upon immediate note change

* Fix image occlusion hot keys not disabled when typing

* Improve text label creation experience

* Remove redundant functions

* Fix error when adding occlusion (dae)
2024-10-02 17:19:52 +10:00
Jarrett Ye
59969f62f5
polish graphs of simulator, true retention table and forgetting curve (#3448)
* polish graphs of simulator and forgetting curve

* True Retention: decrease precision of percentages

* apply uniform sampling rate to forgetting curve

* don't display time, only date when maxDays >= 365

* don't floor the totalDaysSinceLastReview

* correct cramming condition

* improve code-style

* polish ticks & tooltip of simulator

* remove unused import

* fix minor error of daysSinceFirstLearn

* filter out revlog entries from before the reset

https://forums.ankiweb.net/t/anki-24-10-beta/49989/63?u=l.m.sherlock

* use Math.ceil for windowSize

* fill currentColor for legend text

* remove mix-blend-mode: multiply

* tune the position of legend
2024-10-01 00:22:30 +10:00
Taylor Obyen
fdc69505e9
Fix incorrect canvas bounds calculations (#3457)
* Fix incorrect canvas bounds calculations

* Fix contributors

* Set variables to be constant
2024-10-01 00:03:38 +10:00
Voczi
343a304257
Fix error when closing deck options (#3454) 2024-09-30 23:44:20 +10:00
Jarrett Ye
db5c472e20
Fix/keep the same-day reviews for training & optimized parameters should be consistent if the inputs are consistents (#3450)
* keep the same-day reviews in feature

* Update to FSRS-rs v1.2.3

* format

* don't remove short-term reviews if not training

* Update to FSRS-rs v1.2.4
2024-09-30 23:43:26 +10:00
a.r
d9969a9f4f
lazy_static → once_cell → stabilized versions (#3447)
* Anki: Replace lazy_static with once_cell

Unify to once_cell, lazy_static's replacement. The latter in unmaintained.

* Anki: Replace once_cell with stabilized LazyCell / LazyLock as far as possible

Since 1.80: https://github.com/rust-lang/rust/issues/109736 and https://github.com/rust-lang/rust/pull/98165

Non-Thread-Safe Lazy → std::cell::LazyCell https://doc.rust-lang.org/nightly/std/cell/struct.LazyCell.html

Thread-safe SyncLazy → std::sync::LazyLock https://doc.rust-lang.org/nightly/std/sync/struct.LazyLock.html

The compiler accepted LazyCell only in minilints.

The final use in rslib/src/log.rs couldn't be replaced since get_or_try_init has not yet been standardized: https://github.com/rust-lang/rust/issues/109737

* Declare correct MSRV (dae)

Some of our deps require newer Rust versions, so this was misleading.

Updating the MSRV also allows us to use .inspect() on Option now
2024-09-30 23:35:06 +10:00
a.r
e2124cd790
typeanswer: [type:nc] – ignores combining characters (#3422)
* typeanswer: fix cleanup

Fix: Add prepare_expected back in for the 'nothing typed' & 'correctly typed' cases. This also makes expected_original redundant again.

Style: %s/provided/typed/g

Style: rename one ch → c

Testcase: whitespace_is_trimmed: added a check for the "correctly typed" path and renamed it to tags_removed (there's no whitespace?)

Testcase: empty_input_shows_as_code: changed to also check that tags get trimmed

* [type:nc] – ignores combining characters

Adds a comparison variant to [type] which ignores when combining characters of the expected field are missing from the provided input. It still shows these characters in the 'expected' line for reference.

It's useful for languages with e.g. diacritics that are required for reference (such as in dictionaries), but rarely actually learned or used in everyday writing. Among these languages: Arabic, Hebrew, Persian, Urdu.

The bool 'combining' controls it as new final parameter of both relevant compare_answer functions. On the Python side, it's set to true by default.

Use on the note templates: [type:nc:field] (only the front needs to include :nc)

This also removes the need to have both variants of words/sentences present as separate fields, to show them redundantly, etc.

* typeanswer: simplify by using nfkd throughout

Requires adjusting two testcases, but both render exactly the same in Anki itself.

On NFC vs. NKFD: https://stackoverflow.com/a/77432079

* typeanswer: 'simplify' by removing normalize_typed (requiring a bool parameter)

I'd prefer to keep this extra method.

* typeanswer: micro-optimize vectors

Should get rid of most relocations, at the expense of over-allocating.

On Vec's (String's) behavior: https://stackoverflow.com/a/72787776

* Mark `combining` as private

typeCorrect is not marked as private either, but we can at least do
the right thing for newly-added code.

* Revert "typeanswer: micro-optimize vectors"

This reverts commit 9fbacbfd19.

* Revert "typeanswer: 'simplify' by removing normalize_typed (requiring a bool parameter)"

This reverts commit df2dd3394e.
2024-09-30 23:11:51 +10:00
Damien Elmes
981b37e44d Pin setuptools to 0.69 in binary builds
Newer versions break 'import pkg_resources' from a bundled build,
due to Pyoxidizer.

https://forums.ankiweb.net/t/anki-24-10-beta/49989/66

I've had to jiggle around the requirements files so that our dev
environment continues to use the latest setuptools, as there have
been security issues with old versions.
2024-09-30 22:36:42 +10:00
Damien Elmes
fde4a85622 Revert "Pin setuptools to 0.69"
This reverts commit e4630a0a07.

This reintroduces a security warning, so we'll need a different
approach.
2024-09-30 22:19:27 +10:00
Damien Elmes
9142a22c19 Pin sass to quieten warnings
https://github.com/ankitects/anki/issues/3462
2024-09-30 22:10:59 +10:00
Damien Elmes
e4630a0a07 Pin setuptools to 0.69
Newer versions break 'import pkg_resources' from a bundled build,
due to Pyoxidizer.

https://forums.ankiweb.net/t/anki-24-10-beta/49989/66
2024-09-30 21:55:30 +10:00
Damien Elmes
20ac3450fb Add missing distro lock
By regenerating requirements on a Linux machine
2024-09-30 21:54:41 +10:00
Damien Elmes
1b7390f22d Install n2 in release entrypoint 2024-09-27 20:22:16 +10:00
Damien Elmes
201f13946d Update translations 2024-09-27 19:38:16 +10:00
Damien Elmes
7fb261c90b Backup warning needs a new string
We need a new key, as we've introduced a variable. Missed this in
the PR review.
2024-09-27 19:36:58 +10:00
Damien Elmes
cf2652f233 Bump version number 2024-09-27 19:33:44 +10:00
Jarrett Ye
79592730ee
Feat/forgetting curve in card info (#3437)
* add elapsed time into revlog-table

* add stability into revlog-table

* add Graph of forgetting curve

* fix eslint

* add radio buttons of timeRange

* add revlog filter && return [] for new card

* format

* translatable string & disable if using SM-2

* elapsedTime should skip manual or filtered review

* add HoverColumns

* fix eslint

* add stability to tooltip & use timeSpan

* reuse translatable strings

* distinguish daysSinceFirstLearn and elapsedDaysSinceLastReview

* Date x-axis & toLocaleString

* Temporarily hide elapsed/stability columns (dae)

https://github.com/ankitects/anki/pull/3437#issuecomment-2378851900
2024-09-27 19:32:40 +10:00
Damien Elmes
f3b0afcc62 Revert "Fix pasting from the primary selection (#3413)"
This reverts commit 0a879bd2ed.

Closes #3435
2024-09-25 20:59:10 +10:00
Taylor Obyen
df127b1af7
Add revert to backup option to file menu (#3434)
* Add revert to backup context item

* Fix contributors a new way

* Change relative time to filename

* Update ftl/qt/qt-accel.ftl (dae)
2024-09-25 20:21:59 +10:00
a.r
dc5fa60c8b
typeanswer: cleanups (#3415)
* typeanswer: cleanups

no functional change

* typeanswer: disambiguate

no functional change

* typeanswer: reorder

* typeanswer: skip DiffContext if nothing typed

No use to run all that code without input.

* typeanswer: skip tokenization if input is correct

No use in this case.

* typeanswer: make repo check happy (.map → .fold)

Either a new check or the call was too complex previously for it to trigger?

* Add to contributors

* typeanswer: remove slice_* functions

They're used only once in to_tokens. Easier to read this way IMHO, anyway.
2024-09-25 20:15:16 +10:00
Damien Elmes
cf17ca2f84 Revert "Fix occlusion rounding bug (#3400)"
This reverts commit 96ff4f1a4a.

This change broke adding of new occlusions on desktop:

JS error /_anki/js/editor.js:100016 Uncaught TypeError: Cannot read properties of undefined (reading 'getBoundingRect')
2024-09-25 20:04:35 +10:00
Damien Elmes
221d995180 Fix header/extra fields being collapsed on mobile
+ use a class, since this element is repeated
2024-09-25 19:51:19 +10:00
Damien Elmes
a4002783a5 Fix Back Extra field not being added 2024-09-25 19:51:19 +10:00
Damien Elmes
740d95d53f Fix inability to save occlusions on mobile 2024-09-25 19:51:18 +10:00
Abdo
bf46a5f08c
Update to Svelte 5 (#3292)
* Update to Svelte 5

* Fix `<tr> is invalid inside <table>`

* Update sveltekit-svg to match svelte version

Fixes deck options failing to load, and a bunch of warnings with
./yarn dev

* Fix graph tooltips

* Fix editor loading

* Fix MathJax editor not loading

* Formatting

* Fix new formatting errors

* Merge remote-tracking branch 'origin/main' into svelte5

* Remove slot inside EditorToolbar

I think this is just stray code left over from a refactor, but I'm
not 100% sure.

Fixes
Error: Object literal may only specify known properties, and 'children' does not exist in type '{ size: number; wrap: boolean; api?: Partial<EditorToolbarAPI> | undefined; }'. (ts)
<div class="note-editor">
    <EditorToolbar {size} {wrap} api={toolbar}>
        <slot slot="notetypeButtons" name="notetypeButtons" />

* Fix component typing error

* Comment out svelte/internal exports, so editor loads

* Fix image occlusions in editor

* Revert "Remove slot inside EditorToolbar"

This reverts commit b3095e07ac,
which prevented the Preview button from showing in the browser.

This will break our tests again.

* Update vite

* Disable routes/tmp for now

* Fix references issue in routes/tmp
2024-09-25 18:49:07 +10:00
Damien Elmes
a437003d1d Update translations 2024-09-22 19:01:20 +10:00
Jarrett Ye
3912db30bb
Feat/true retention stats (#3425)
* Feat/true retention stats

* ./ninja fix:minilints

* use translatable strings & update style

* remove card couts & add more translatable strings

* Update statistics.ftl

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* add Estimated total knowledge (cards)

---------

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>
2024-09-22 19:00:27 +10:00
Damien Elmes
5dfef8aae2 Fix formatting 2024-09-22 18:36:01 +10:00
Expertium
d29ef07637
Recall rate -> retention rate (#3433)
Let's keep the terminology consistent
2024-09-22 18:24:52 +10:00
Ben Nguyen
c2f3e63b90
Bug with “A 100 day interval will become X days.” (#3432)
* add name to about page

* use two decimal retention for calculations

* Update CONTRIBUTORS

* format

* Update CONTRIBUTORS

* Update CONTRIBUTORS

* Update CONTRIBUTORS
2024-09-22 18:24:32 +10:00
Arthur Milchior
b08e454f57
If deck options are modified, ask before closing (#3410)
* If deck options are modified, ask before closing

This imitates the way the note editor behaves. If a user assumes by
error that chanhges are automatically saved, it ensures they won't
lose them.

Also, this will eventually allows to have the same feature on
AnkiDroid. While, currently, we always ask the user whether they want
to close the deck options, even when there are no modification, which
seems to regularly frustate users (including myself).

I'm new to Svelte, please let me know whether there is a better way to
obtain the information from Svelte state that I missed.

Note that I ensured that only a boolean can be obtained. I didn't
cause the whole state to be accessible. May be useful for some
add-ons, I guess, but risks breaking too much things.

Regarding the deckoptions.py, I tried to imitate addcards.py way to
check whether the add card view can be closed. Reusing the same
function and variable name when possible.

* Update qt/aqt/deckoptions.py (dae)
2024-09-22 18:07:24 +10:00
Kris Cherven
163c10191f
Fix Qt desktop file name warning (#3419)
* Fix Qt desktop file name warning

* Update CONTRIBUTORS
2024-09-22 18:02:35 +10:00
Taylor Obyen
90661c4bfc
Track Current Deck Context from Browser (#3385)
* Update current deck from browser

* Update contributors

* Fix formatting

* Allow Add window to be opened with parameters

* Add explicit return

* Fix formatting

* Accomplish context in a more simple fashion

* Implement context menu add

* Fix contributors

* Add additional context

* Removed uneeded logic and inlined redundant funcs

* Resolve contributors conflict

* Update qt/aqt/deckbrowser.py

* Update qt/aqt/deckbrowser.py
2024-09-22 18:02:17 +10:00
Damien Elmes
722b9b53f4 Update translations 2024-09-20 22:04:52 +10:00
user1823
02d2566998
Add an option to show image from editor in folder (#3412)
* Add "Show in folder" option to images in editor

Credits: @abdnh's Reveal in File Manager add-on (https://github.com/abdnh/anki-misc/tree/master/reveal_in_file_manager)

* Refactor
2024-09-20 21:38:44 +10:00
Abdo
5bd66db3c6
Call the profile_did_open() hook earlier (#3421) 2024-09-20 21:22:27 +10:00
Abdo
847f3f6714
Fix FSRS progress update issues (#3420)
* Delay optimal FSRS params alert to ensure progress updates are reported

* Ensure progress updates arrive synchronously
2024-09-20 21:18:02 +10:00
sorata
cb3a7579de
Update tooltip text (#3418)
* Update deck-config.ftl

* Update deck-config.ftl

* remove the warning
2024-09-20 21:13:35 +10:00
Kris Cherven
0a879bd2ed
Fix pasting from the primary selection (#3413)
* Fix clipboard pasting from the primary selection

* Small renaming

* Fix submodules

* Fix pylint false positive
2024-09-20 21:00:12 +10:00
Taylor Obyen
96ff4f1a4a
Fix occlusion rounding bug (#3400)
* Fix occlusion rounding bug

* Fix contributors
2024-09-20 20:48:44 +10:00
Luke Bartholomew
1b7123aa94
Add comment about the usage of the input field in the statistics page (#3394) (#3398)
* Add comment about the usage of the input field in the statistics page (#3394)

* Fix formatting issues (#3394)

* Update ts/routes/graphs/RangeBox.svelte

Co-authored-by: Mike Hardy <github@mikehardy.net>

* Update ts/routes/graphs/RangeBox.svelte

Co-authored-by: Mike Hardy <github@mikehardy.net>

---------

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
Co-authored-by: Mike Hardy <github@mikehardy.net>
2024-09-20 20:47:04 +10:00
Ben Nguyen
77fb0fb708
Possible to show “last” subdeck name in Browser? (#3387)
* elide middle of deck names

* Update CONTRIBUTORS

* made elide mode enum

* add elide mode field

* fix enum number

* remove dataclass decorator

* Update CONTRIBUTORS

* format rust code

* Update CONTRIBUTORS

* formatting

* Update CONTRIBUTORS

* fix type hint

* Update CONTRIBUTORS
2024-09-20 20:33:28 +10:00
Abdo
73c97de5d0
Do not strip quotation marks from deck/tag names (#3407)
* Do not strip quotation marks from deck names

* Do not strip quotation marks from tag names
2024-09-11 03:56:09 +07:00
Damien Elmes
edfbbc7a62 Update translations 2024-09-11 02:54:00 +07:00
Damien Elmes
cdcd8c600b Remove redundant is_finite() check 2024-09-11 02:54:00 +07:00
sorata
9a3bdca3d1
change links to new knowledge base (#3411)
* change links to new knowledge base

* Fix formatting
2024-09-11 02:44:39 +07:00
Taylor Obyen
a262e02f9d
Fix ease button alignment (#3404)
* Fix ease button alignment

* Fix contributors part 2
2024-09-11 02:44:11 +07:00
Abdo
21df287579
Fix minimum interval warning shown when FSRS is enabled (#3409) 2024-09-11 02:21:49 +07:00
Abdo
9223b35aa0
Stop automatically adding Image Occlusion type in Add screen (#3408) 2024-09-11 02:21:37 +07:00
Abdo
880c7d366c
Fix graph averages (#3406)
* Fix graph averages

* Fix formatting
2024-09-11 02:18:53 +07:00
Gregory
f496411da8
Updated error message to provide help for import if 'Legacy Import/Export' is enabled (#3399)
* Updated error message to provide additional guidance for file import issues if Legacy Import/Export is enabled

Enhanced the error message from "Unable to read file. It probably requires a newer version of Anki to import." 
  to include a suggestion for users to try unchecking 'Legacy import/export Handling' under Preferences > Editing > 
  Import/Export if they encounter the issue.

* Update CONTRIBUTORS
2024-09-11 02:06:35 +07:00
Jarrett Ye
34809f2520
Fix/simulator crashes if no history (#3405)
* Fix/simulator crashes if no history

* ./ninja format

* remove (experimental) from ComputeOptimalRetention

* update to fsrs-rs v1.2.2
2024-09-10 23:15:33 +07:00
Damien Elmes
5335d748cf Bump Rust to 1.81 for latest CVE 2024-09-05 12:39:59 +07:00
Damien Elmes
ba18a2c6d9 Update translations 2024-09-04 12:22:53 +07:00
Damien Elmes
b241ab9492
Dependency updates (#3403)
* Bump Python deps

Primarily for flask-cors CVE

* Bump TS deps; pin license checker

Current checker is missing the binary
https://github.com/RSeidelsohn/license-checker-rseidelsohn/issues/118

* Update Rust deps

Hyper and axum are held back as we currently make use of the older
http library that reqwest pulls in
2024-09-04 12:21:50 +07:00
Jarrett Ye
b7cb0c0d00
graduate card when user presses again or hard and has 0 learning steps (#3367)
* graduate card when user press hard and has 0 learning steps

* fix error: useless conversion to the same type

* do the same thing to again

* fix expected `Option<u32>`, found integer

* ./ninja format

* Update to FSRS-rs v1.2.0

* if else -> match

* Weight length check has been moved into FSRS (dae)

* Don't mention the number of FSRS parameters (dae)

It has changed, and may change again.
2024-08-29 22:20:11 +07:00
Arthur Milchior
ce2f4136ea
Empty cards become undoable (#3386)
* Empty cards is undoable

If there was a reason for this operation not to be undoable, I can't easily guess it. My main hyposhesis was that the number of deleted card may be too big. But I realized that deleting a deck is undoable and may delete as many note.

As you may know, I realized that only the undoable operations triggered notification in AnkiDroid that we may have to update the UI. And while I just wanted to trigger more notifications, some reviewers thought it would be nicer if the operation were returning a OpChanges. So here it's done. If you would please consider merging it.

I decided to introduce a new string because the closest strings I could find currently are "Empty cards..." and the trailing commas don't seem nice in "undo". And the title, which we may not be able to reuse in all language

* Don't count cards that have already been removed (dae)
2024-08-29 20:06:41 +07:00
Abdo
58e25f12b2
Fix Svelte exports not working in Deck Options (#3382) 2024-08-29 19:12:18 +07:00
bpnguyen107
3661333185
Move 'ignore reviews before' to advanced (#3381)
* moved ignore setting to advanced

* Update CONTRIBUTORS

* Match width of other text inputs (dae)

The width was inconsistent before as well, but moving it next to
text inputs made it more obvious.
2024-08-29 19:11:56 +07:00
bpnguyen107
7a0e51afc0
.DS_Store file shown as an unused media file (#3380)
* skip ds_store file

* correct capitalization

* skip ds_store file

* correct capitalization

* Update CONTRIBUTORS
2024-08-29 18:22:23 +07:00
Abdo
40bcbe44bf
Fix field focus lost when pressing alt in the editor (#3378) 2024-08-29 17:32:24 +07:00
Themis Demetriades
0f44796b36
Fix imports of decks with file paths using special URL characters (#3377) 2024-08-29 17:19:27 +07:00
David Culley
b35b69a2d3
mypy: fix type checking error (#3365)
* refactor: fix type checking error

error: Argument 1 to "_answerCard" of "Reviewer" has incompatible type "int"; expected "Literal[1, 2, 3, 4]"  [arg-type]

* refactor: remove check that `ease` is correct number

* refactor: rename variable

* refactor: add type hint for generator function

* refactor: revise import of `functools.partial`

* refactor: invert logic of if-construct

to avoid nesting.

* refactor: properly check for `None`

* Update qt/aqt/reviewer.py
2024-08-29 17:07:06 +07:00
Jean Khawand
83fe301c1c
Add distroless Dockerfile and implement internal health check (#3366)
- rslib(http_server): add `is_running()` method
- rslib(sync): introduce `--healthcheck` argument for health probe in distroless
- doc(syncserver): add table comparing Dockerfile and Dockerfile.distroless
- Expand cross-platform support with distroless
- add `Dockerfile.distroless`

- Dockerfile: bump rust `1.79` to `1.80.1`
- Dockerfile: bump alpine `3.20` to `3.20.2`

Note: Implemented an internal health check because distroless images do not include curl, which is used to reduce image size and attack surface. For more details, see https://blog.sixeyed.com/docker-healthchecks-why-not-to-use-curl-or-iwr/
https://github.com/GoogleContainerTools/distroless

fix: failed: check:format:rust

typo

remove extra space

fix failed:check:format:rust

update doc

fetch `host` and `port` using envy

fix: failed: check:format:rust

Update doc + add dockerignore

- dockerignore: This helps avoid sending unwanted files and directories to the builder
- add new line
- I am still experimenting cross platform compilation, I am getting
4.337 From https://github.com/ankitects/rust-url
4.337  * [new ref]         bb930b8d089f4d30d7d19c12e54e66191de47b88 -> refs/commit/bb930b8d089f4d30d7d19c12e54e66191de47b88
4.397 error: failed to get `percent-encoding-iri` as a dependency of package `anki v0.0.0 (/app/rslib)`

still checking what could be the issue

fix: failed: check:format:dprint
2024-08-29 17:05:33 +07:00
Damien Elmes
be2f013cb7 Add Eros to about
A reminder that anyone who has contributed help is welcome to add themselves
in a PR.
2024-08-28 23:25:00 +07:00
Damien Elmes
a179da3827
Update dprint (#3376)
* Update amd64 docker container to Debian 11

This bumps the minimum required glibc to 2.29, which is 2019
Ubuntu/Fedora, and 2021 Debian.

Also remove the unused download of ninja

* Update to latest dprint

Unblocked by the glibc upgrade
2024-08-22 18:24:56 +07:00
Abdo
83f044491b
Ensure profile name is treated in a case-insensitive manner (#3372) 2024-08-22 17:35:48 +07:00
Jake Probst
7ea573b004
don't ignore buried cards in future due graph (#3368)
it does ignore them for the current day but not days in the future
2024-08-22 16:53:41 +07:00
David Culley
a6d5c94997
python: add missing type annotations for None values (#3364)
* refactor: explicitly add NoneType to type hints

If variable can be `None`, don't be implicit. Be explicit.
2024-08-22 16:03:44 +07:00
Jarrett Ye
922958b0ae
Update to FSRS-rs v1.1.5 (#3369) 2024-08-22 16:02:50 +07:00
Jarrett Ye
8ed9f49bdc
Feat/FSRS Simulator (#3257)
* test using existed cards

* plot new and review

* convert learning cards & use line chart

* allow draw multiple simulations in the same chart

* support hide simulation

* convert x axis to Date

* convert y from second to minute

* support clear last simulation

* remove unused import

* rename

* add hover/tooltip

* fallback to default parameters

* update default value and maximum of deckSize

* add "processing..."

* fix mistake
2024-08-22 15:34:19 +07:00
Damien Elmes
e92aaa4478 'card type, then order gathered'
https://forums.ankiweb.net/t/rename-card-type-to-card-type-then-order-gathered/48046
2024-08-19 13:24:52 +07:00
bpnguyen107
f2adf5d9ad
Hide right click copy option in deck list (#3363)
* hide copy if nothing selected

* Update CONTRIBUTORS

* type hint

* Update CONTRIBUTORS
2024-08-17 13:18:46 +07:00
bpnguyen107
c99b50c82f
Right click context menu on images not useful (#3362)
* right click and copy on image works

* renamed helper fn

* separated functionality of copy and copy image

* Update CONTRIBUTORS

* snake case

* Update CONTRIBUTORS
2024-08-17 13:18:07 +07:00
David Culley
0bbb052b42
chore: add initial configuration for pyright (#3361)
If you don't use Visual Studio Code as your text editor, and therefore
can't use the Pylance extension, but nonetheless use `pyright` as a CLI
application.
2024-08-17 13:10:02 +07:00
David Culley
9b00c50be8
chore: add mypy's cache to .gitignore file (#3360) 2024-08-17 13:09:30 +07:00
Jake Probst
c6cb4e4373
load balancer! (#3230)
* start of load balancer

* add configuration options; option to load balance per deck

* formatting

* clippy

* add myself to contributors

* cleanup

* cargo fmt

* copyright header on load_balancer.rs

* remove extra space

* more formatting

* python formatting

* ignore this being None

only doing this cause python has awful lambdas and can't
loop in a meaningful way without doing this

* only calculate notes on each day if we are trying to avoid siblings

* don't fuzz intervals if the load balancer is enabled

* force generator to eval so this actually happens

* load balance instead of fuzzing, rather than in addition to

* use builtin fuzz_bounds rather than reinvent something new

* print some debug info on how its load balancing

* clippy

* more accurately load balance only when we want to fuzz

* incorrectly doublechecking the presence of the load balancer

* more printfs for debugging

* avoid siblings -> disperse siblings

* load balance learning graduating intervals

* load balancer: respect min/max intervals; graduating easy should be at least +1 good

* filter out after-days under minimum interval

* this is an inclusive check

* switch load balancer to caching instead of on the fly calculation

* handle case where load balancer would balance outside of its bounds

* disable lb when unselecting it in preferences

* call load_balancer in StateContext::with_review_fuzz instead of next to

* rebuild load balancer when card queue is rebuilt

* remove now-unused configuration options

* add note option to notetype to enable/disable sibling dispersion

* add options to exclude decks from load balancing

* theres a lint checking that the link actually exists so I guess I'll add the anchor back in later?

* how did I even update this

* move load balancer to cardqueue

* remove per-deck balancing options

* improve determining whether to disperse siblings when load balancing

* don't recalculate notes on days every time

* remove debug code

* remove all configuration; load balancer enabled by default; disperse siblings if bury_reviews is set

* didn't fully remove caring about decks from load balancer sql query

* load balancer should only count cards in the same preset

* fuzz interval if its outside of load balancer's range

* also check minimum when bailing out of load balancer

* cleanup; make tests happy

* experimental weight-based load balance fuzzing

* take into account interval when weighting as it seems to help

* if theres no cards the interval weight is just 1.0

* make load balancer disableable through debug console

* remove debug prints

* typo

* remove debugging print

* explain a bit how load balancer works

* properly balance per preset

* use inclusive range rather than +1

* -1 type cast

* move type hint somewhere less ugly; fix comment typo

* Reuse existing deck list from parent function (dae)

Minor optimisation
2024-08-17 12:50:54 +07:00
Damien Elmes
a87a44da2c Bump Rust to 1.80.1 2024-08-17 11:29:36 +07:00
Abdo
520564da11
Integrate AnkiHub Sign-in (#3232)
* Add AnkiHub section to preferences screen

* Add short intro for AnkiWeb and AnkiHub to syncing section

* Add AnkiHub login screen

* Implement login methods in backend

* Set minimum dialog width

* Add missing colon

* Respect the ANKIHUB_APP_URL env var

This is used by the add-on.

* Simplify login error reporting

* Fix from_prefs_screen not passed to subcall

* Add missing ankihub_pb2 import

* Install AnkiHub add-on after sign-in

* Avoid .exec()

* Update ftl/core/sync.ftl

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>

* Split translation string

* Support login by username/email

* Fix entered username/email not being passed back to on_done

* Remove unused import

* Move to 'Third-party services' section

* Tweak login dialog's heading

* Remove 'third-party' from intro text

* Tweak copy

* Prefix profile keys

* Tweak strings

* Remove description from login dialog

* Remove signup links

* Clear credentials in ankihub_logout()

* Call .adjustSize()

* Title Case

* Add padding to third-party services, and fix tab order from other PR
2024-08-17 10:58:23 +07:00
bpnguyen107
acf3134e04
Rename “Change Deck” to "Select Deck" (#3266) (#3356)
* added Select Deck string

* updated CONTRIBUTORS

* update email
2024-08-15 17:30:05 +07:00
Damien Elmes
5f80ddf27d Remove outdated comments in contributing, and mention refactoring 2024-08-10 18:43:11 +07:00
David Culley
4fb6fa81ac
refactor: use not in and is not as recommended (#3351)
- https://docs.astral.sh/ruff/rules/not-is-test/
- https://docs.astral.sh/ruff/rules/not-in-test/
2024-08-10 17:55:26 +07:00
Voczi
1065941767
Add option for toggling update checks (#3346) 2024-08-10 17:46:49 +07:00
Damien Elmes
06d5256f4e Update translations 2024-08-10 16:56:30 +07:00
Damien Elmes
b27b42e6e5 Revert "Updated tooltips (#3326)"
This reverts commit c7762d4ec4.

https://github.com/ankitects/anki/pull/3331#issuecomment-2276317668
2024-08-10 16:56:30 +07:00
Damien Elmes
3b0abe7571 Revert "update review limit's name (#3331)"
This reverts commit e0de13e240.

https://github.com/ankitects/anki/pull/3331#issuecomment-2276317668
2024-08-10 16:56:30 +07:00
sorata
af8fdd8b87
reviews —> review cards (#3347) 2024-08-10 16:53:25 +07:00
Damien Elmes
872ecf481a Update translations 2024-08-08 18:37:33 +07:00
Damien Elmes
afb0790703 Revert "Rename review limit (#3320)"
This reverts commit f0933cf06c.

https://forums.ankiweb.net/t/rename-review-limit/47097/50
2024-08-08 18:37:08 +07:00
David Culley
70a063a3b9
Fix error if regex can't find the filename (#3285)
* fix: treat error if regex doesn't match

* refactor: use assertion to avoid error message
2024-08-07 16:17:37 +07:00
Dillon Baldwin
a2b4b57390
Added name to contributors list as well as addressed issue #3343. Ran ninja check and the build compiled successfully. (#3345) 2024-08-07 16:15:50 +07:00
sorata
e0de13e240
update review limit's name (#3331)
* update review limit's name

* updated tooltip for clarity

this reads more well now, given that new limit isn't max limit

* re-add maximum

* typo
2024-08-05 20:13:53 +07:00
Asuka Minato
e851d0d281
Update about.py (#3330)
* Update about.py

* Update CONTRIBUTORS
2024-08-05 15:56:04 +07:00
Jarrett Ye
1f7a84d68c
Update to FSRS-rs v1.1.4 (#3329)
* update to fsrs-rs v1.1.4
2024-08-05 15:54:10 +07:00
Damien Elmes
ca4393142e Update to Rust 1.80
https://github.com/ankitects/anki/pull/3329#issuecomment-2254538270
2024-08-05 15:37:59 +07:00
cdonat2
b1bf1c3141
Add maximize hint for models.py (#3151) (#3328)
Co-authored-by: Christian Donat <cdonat@tu-berlin.de>
2024-08-05 15:21:18 +07:00
David Culley
bab83ffce0
fix: add proper imports (#3296)
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2024-08-05 11:34:46 +07:00
David Culley
44380dd62a
Specify Python version for auto-formatters (#3325)
* chore(isort): specify Python version to be assumed

https://pycqa.github.io/isort/docs/configuration/options#python-version

Default is to assume _any_ Python 3 version could be the target.

* chore(black): specify Python target versions

https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#t-target-version

* chore(ruff): specify Python version to be assumed

https://docs.astral.sh/ruff/settings/#target-version

* chore: exclude directories from auto-formatting
2024-08-04 20:54:14 +07:00
David Culley
37a3f4708a
Refactor _addButton method of editor (#3294)
* refactor: simplify f-string

* refactor: use more readable names

* style: separate if-else-clauses by empty lines

* fix: add missing import

Properly `import os`.

* refactor: simplify variable assignment

* refactor: rename variables

* refactor: use f-string

* refactor: reorder variables

* refactor: simplify if-clause with de morgan's laws

* refactor: simplify if-else-construct

* fixup! refactor: rename variables

* Revert "refactor: use f-string"

This reverts commit 1dcb58bdab.

* Revert "fixup! refactor: rename variables"

This reverts commit 813130ba6a.
2024-08-04 20:51:45 +07:00
David Culley
c0349ea9da
Improve exception handling (#3290)
* fix: except only non-system-exiting exceptions

see https://youtu.be/zrVfY9SuO64

* chore: add myself to CONTRIBUTORS file

* refactor: explicitly specify possible exceptions

If an exception is not an Exception, there are only three options left.
see https://docs.python.org/3/library/exceptions.html#exception-hierarchy

* refactor: use BaseException for fallback

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>

* chore: add myself to contributors
2024-08-04 20:51:13 +07:00
David Culley
a5a39c9302
Fix 'NoneType object is not subscriptable' error (#3286)
* fix: ensure none of the returned values is None

Fixes TypeError 'NoneType' object is not subscriptable

* refactor: reduce code duplication using a function

* refactor: prefer KeyError over None for dicts

If the key is not in the dictionary, we want to raise a KeyError rather
than returning None. That way, we can distinguish between whether the
value was None or the key was not found.

* chore: add myself to CONTRIBUTORS file

* refactor: simplify the code
2024-08-04 20:49:45 +07:00
Damien Elmes
426790bfcb Formatting fix
For some reason this didn't get caught by my pre-push hook :-(
2024-08-01 12:24:38 +07:00
Damien Elmes
1910b9609e Drop non-working tiff support
https://forums.ankiweb.net/t/anki-fails-to-attach-tif-images-to-cards/47609
2024-08-01 12:19:35 +07:00
Expertium
2c30081e3e
SM2 -> SM-2.ftl (#3327)
Relevant: https://github.com/ankitects/anki-manual/pull/218
2024-07-26 21:24:29 +07:00
sorata
c7762d4ec4
Updated tooltips (#3326)
* Update deck-config.ftl

* Update deck-config.ftl

* Update deck-config.ftl

* Update deck-config.ftl

* Update ftl/core/deck-config.ftl
2024-07-26 19:30:35 +07:00
Damien Elmes
656309f385 Update translations 2024-07-26 18:21:01 +07:00
Expertium
f0c211389f
Ignore reviews before -> Ignore cards reviewed before.ftl (#3314)
* Ignore review before -> Ignore cards reviewed before.ftl

* Revert the change.ftl

* Update CONTRIBUTORS
2024-07-26 18:19:51 +07:00
David Culley
0743e6e40e
Update type annotations to use | operator (#3323)
* refactor: update to `|` operator

* refactor: add missing type hint

* refactor: enable `|` operator for older versions

* refactor: remove obsolete import
2024-07-26 18:15:39 +07:00
sorata
f0933cf06c
Rename review limit (#3320)
* maximum reviews/day —> maximum cards/day

* New cards ignore maximum limit
2024-07-26 18:05:33 +07:00
David Culley
3f66f995f7
style: reformat with black (#3324) 2024-07-26 17:58:57 +07:00
David Culley
363a52526e
Update type annotations (#3322)
* refactor: update Callable type hint

* refactor: update type annotations for hooks
2024-07-26 17:57:25 +07:00
David Culley
6c0857395f
Refactor getting the index of a user's language (#3311)
* refactor: rename variables of tuple

* refactor: rename function argument

* refactor: use function to get index of language

* refactor: replace for-loop

* refactor: use variable

* refactor: assert values are not None

To satisfy the type checker.

* refactor: change generator expression to for-loop
2024-07-25 12:46:59 +07:00
Damien Elmes
5c33e5ea65
Revert "About section transparent logo (#3284)" (#3315)
This reverts commit 0b38ecdbc7.
2024-07-22 02:09:40 +07:00
Damien Elmes
faa9efaff7 Latest openssl fix 2024-07-22 02:08:35 +07:00
Jarrett Ye
52ce6e6a6b
Feat/FSRS-5 (#3298)
* Feat/FSRS-5

* adapt the SimulatorConfig of FSRS-5

* update parameters from FSRS-4.5

* udpate to FSRS-rs v1.1.0

* ./ninja fix:minilints

* pass ci

* update cargo-deny to 0.14.24

* udpate to FSRS-rs v1.1.1

* update to fsrs-rs v1.1.2
2024-07-21 21:02:24 +07:00
sorata
5216fa959e
Update AutoAdvance.svelte (#3313) 2024-07-21 20:49:42 +07:00
user1823
dccb7c9b27
Update references to tooltip strings (#3312)
* Update string reference

* Update FsrsOptionsOuter.svelte
2024-07-21 17:24:41 +07:00
sorata
087f957a36
Update Tooltip (#3288)
* Update Tooltip

updated the tooltips as described here: https://forums.ankiweb.net/t/update-tooltips/46849

* Update CONTRIBUTORS

* Update deck-config.ftl

* fixed punctuation, stylistic incoherence, etc.

* Update deck-config.ftl

https://github.com/open-spaced-repetition/fsrs4anki/pull/667

* Changed string requires new key (dae)

* Minor tweaks to tense for clarity (dae)

https://github.com/ankitects/anki/pull/3288#issuecomment-2223384500
2024-07-21 16:44:37 +07:00
Abdo
b05c9d1598
Fix change_notetype_of_notes's docstring (#3304) 2024-07-21 15:26:10 +07:00
David Culley
aa6583cdd1
Refactor ephemeral_card of notes (#3307)
* refactor: fix type annotation

* fix: properly check if argument is None

Don't use Boolean expressions to implement a default value.

* fix: ensure that 'model' is not None

Don't use exceptions to control the flow.

* refactor: simplify if-else construct
2024-07-21 15:25:48 +07:00
David Culley
e213c0a6d1
refactor: use list comprehension (#3308) 2024-07-21 15:21:41 +07:00
Abdo
bb5ed4da9c
Fix unused parent tags getting cleared (#3299)
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2024-07-21 15:00:39 +07:00
David Culley
63afb0f8c6
Update type annotation syntax (#3283)
* chore: add myself to CONTRIBUTORS file

* refactor: use newer type hints for Union/Optional

* refactor: fix deprecated type annotations

use collections.abc rather than typing

* refactor: use lower letter type annotations

* style: reformat with black

* refactor: remove unused imports

* refactor: add missing imports for type hints

* fixup! refactor: use newer type hints for Union/Optional

* fix: add missing imports for type annotations

* fixup! refactor: use newer type hints for Union/Optional

* fixup! style: reformat with black

* refactor: fix remaining imports re: type hints
2024-07-21 14:00:52 +07:00
Ren Tatsumoto
412e67db3e
replace showWarning with show_warning (#3306)
* replace showWarning with show_warning

* run isort

* change imports
2024-07-21 13:22:47 +07:00
Damien Elmes
194f35617d Switch mask editor to non-conflicting shortcut
In the absence of better ideas, I've added alt

Closes #3276 and #3278
2024-07-21 13:05:56 +07:00
David Culley
af115c7fda
isort: remove settings covered by profile (#3281)
* chore: remove isort settings covered by profile

https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#custom-configuration

* chore: add myself to CONTRIBUTORS file

* chore: use black profile for isort

* chore(isort): fix configuration to skip directories

When overwriting `skip`, `.git` and others would no longer be skipped.

`extend_skip` is the correct option.

* chore(isort): skip directory `qt/bundle`
2024-07-20 18:13:12 +07:00
Damien Elmes
793fdd484d Allow Unicode-3 license 2024-07-20 18:07:06 +07:00
Damien Elmes
e13783b941 Bump cargo deny version 2024-07-20 17:59:08 +07:00
Pedro Schreiber
799912cfe3
keep-text-in-occlusion (#3277) 2024-07-20 17:48:37 +07:00
Ian Samir Yep Manzano
0b38ecdbc7
About section transparent logo (#3284)
* changed anki-logo-thin.png to version with transparent background

* Revert "changed anki-logo-thin.png to version with transparent background"

This reverts commit 4c7e826a73.

* changed anki-logo-thin.png to version with transparent background

* added name to contributors as per contribution guidelines for first PR

* fixed contributors file rather than directly modifying about file
2024-07-20 17:46:12 +07:00
David Culley
9d8782c31c
Simplify the format string (#3293)
* refactor: simplify format string

* chore: add myself to CONTRIBUTORS file
2024-07-10 21:14:51 +07:00
Jean Khawand
56a085bc21
Update base images and introduce health endpoint (#3273)
* Update base images and introduce health endpoint

sync-server: introduce `/health` endpoint to check if the service is reachable.

bump(alpine): bump alpine base image from `3.19` to `3.20`

bump(rust): bump rust-alpine build image from `1.76` to `1.79`

* fix cargo fmt

* add allow clippy::extra_unused_type_parameters

* Remove unused type param (dae)

* Route /health directly (dae)

* Fix for latest axum (dae)
2024-07-10 20:35:21 +07:00
user1823
6ec22e5118
Apply fuzz to SM2 lapse interval and respect max ivl (#3275)
* Apply fuzz to SM2 lapse interval and respect max ivl

Imo, there is no reason for not applying fuzz to SM2 lapse intervals

* Update review.rs

* Format

* Update review.rs

* Update review.rs

* Update review.rs

* Update review.rs
2024-07-10 20:28:21 +07:00
Damien Elmes
88b506413f Exclude gix from cargo-deny 2024-07-10 20:12:06 +07:00
Luc Mcgrady
fa4352f3b6
Fix profile manager used before checked for None (#3272)
* Fix: profile manager used before checked for None

* ./check
2024-07-10 20:00:15 +07:00
Abdo
daf5f68fd5
Limit cloze nesting level (#3264)
* Limit cloze nesting level

* Break cloze rendering at a lower limit
2024-07-10 19:59:31 +07:00
Rastislav Kish
e985fec9c4
A11Y: Improve the accessibility of the Preferences dialog (#3255)
* Configure buddy widgets for labels in the Preferences dialog

Labels are often used to describe the purpose of a different widget like a combobox, edit field or a spinbox by providing a textual name for their functionality. The relation between a label and a widget is typically expressed by placing the label next to the relevant object. In addition to this visual linking intended for human users, frameworks usually also offer semantic way to link labels with other widgets, so the relation can be noticed by programs like screenreaders, which can figure out the correct textual description for the focused widgets based on this information.

By default, labels on their own are not focusable elements, so users dependend on keyboard navigation and speech get to notice only the widget types (textbox, spinbox, etc.) while moving around without any contextual information if labels are not linked. When the linking is done, the component names get included as well.

QT provides the "buddy" property for QLabel, which creates a semantic link between the label and its buddy widget.

This commit configures the buddy properties on labels of the Anki Preferences dialog.

* Configure spinbox suffixes in Preferrences dialog

QSpinBox provides a suffix property. This property makes it possible to display a measurement unit next to the component value, which is linked to it both visually and semantically for the GUI framework without affecting the spinbox value itself. For purposes of accessibility, it's better to use this property than simply place a label next to the component, since it can be directly accessed by screenreaders and other assistive technology.

This commit configures suffix properties for spinboxes in the Anki Preferences dialog. Note: Removal of the original unit labels may have altered the UI a little bit.

* Assign buddy widgets in the ID and password retrieval dialog

Set buddy widgets of the labels in the Get ID and password for synchronization dialog.

* Fix positioning/size of text boxes

* Style the suffixes of Preferences' QSpinBoxes

Style QSpinBox suffixes (for those that have one) in the Preferences dialog by prepending them by a space character.
2024-07-10 19:58:47 +07:00
Abdo
d108bff862
Fix remaining accessibility warnings (#3241)
* Remove unused build var

* Fix accessibility warnings in CollapseLabel

* Fix accessibility warnings in PlainTextBadge

* Add ARIA role to Autocompleteitem

* Fix accessibility warnings in HandleBackground

* Fix accessibility warnings in HandleControl

* Fix accessibility warnings in EditorField

* Fix accessibility warnings in RichTextBadge

* Fix accessibility warnings in StickyBadge

* Remove ignored a11y warnings
2024-07-10 19:55:08 +07:00
Damien Elmes
486cc8a2ab Update translations 2024-07-06 19:08:03 +07:00
Damien Elmes
227f790d8e Update axum/reqwest for hyper 1.0 2024-07-06 18:45:32 +07:00
Damien Elmes
dca962c81e Update Rust + Rust deps 2024-07-06 18:40:38 +07:00
Damien Elmes
6b3b545a9a Some lint fixes for newer Rust 2024-07-06 18:40:37 +07:00
Damien Elmes
2a52639cd3 Update web deps
Vite held back, as current version is breaking the build
2024-07-06 18:40:37 +07:00
Damien Elmes
cd885098f7 Bump Python deps
A few tweaks were required for PyLint
2024-07-06 18:40:37 +07:00
Damien Elmes
a739d6257c Fix check:svelte/vitest running indiscriminately 2024-07-06 18:40:36 +07:00
Damien Elmes
ec96bfe315 Uyghur is RTL
https://forums.ankiweb.net/t/rlt-ui-bug-uyghur-language-gui-direction/46610
2024-07-02 19:03:29 +07:00
Damien Elmes
d678e39350 Update translations 2024-06-28 22:02:33 +08:00
Abdo
fa47e905c5
Restore $deckOptions (#3265)
* Restore $deckOptions

* Avoid error in logs when using ./yarn dev or mobile clients (dae)
2024-06-28 19:38:18 +07:00
Abdo
55d68c01d8
Shuffle identical values in filtered deck sort (#3259)
* Shuffle identical values in filtered deck sort

* Update test
2024-06-28 18:53:16 +07:00
Abdo
6232d0aec8
Fix deck config input's background color regression (#3258)
* Fix deck config input's background color regression

* Move styles to base stylesheet
2024-06-28 18:52:51 +07:00
Damien Elmes
f98fbbf298 Revert "Ensure minimum doesn't exceed maximum"
This reverts commit 37ce4e8426.

Also remove a stale comment that is no longer relevant after
b8ec76fb66
2024-06-28 19:49:23 +08:00
Jarrett Ye
6d13221ae5
Remove threshold of compute minimum recommended retention (#3246)
* remove threshold of compute minimum recommended retention

* update tool tip of compute-optimal-retention

* cargo clippy --fix

* Update FsrsOptionsOuter.svelte

* Remove 'from 0 cards' reference (dae)
2024-06-28 18:26:39 +07:00
user1823
8d11a909ed
Fix FSRS easy interval being same as good interval in relearning cards (#3256)
* Fix FSRS easy interval being same as good interval in relearning cards

https://github.com/ankitects/anki/pull/3236#issuecomment-2187787774

* Update relearning.rs

* Update relearning.rs

* Set min interval of easy to Good + 1

* Ensure minimum doesn't exceed maximum (dae)

With a maximum interval set, it would be possible to confuse with_review_fuzz()
by passing min > max.
2024-06-28 18:20:45 +07:00
antecrescent
60b25535ef
Make SvelteCheck and ViteTest respect YARN_BINARY (#3231) 2024-06-28 18:00:38 +07:00
Damien Elmes
fe86401f88 "Subjective difficulty"
https://forums.ankiweb.net/t/anki-24-06-3-rc/46403/5
2024-06-28 18:52:55 +08:00
Damien Elmes
0d8d816a0c Include error message text on page
Also remove the '500' h1 from the error

Closes #3248
2024-06-24 15:35:47 +07:00
Damien Elmes
ae1577b228 Bump version to 24.06.3 2024-06-24 14:55:43 +07:00
Damien Elmes
e4326ce801 Add Uyghur to language list 2024-06-24 14:55:16 +07:00
Damien Elmes
7bb6b186be Update translations 2024-06-24 14:49:19 +07:00
Abdo
4221e54390
Fix image occlusion flicker caused by setupI18n() (#3253) 2024-06-24 08:48:49 +01:00
James Elmore
930c97b1c7
Fix Renaming note fields not updating custom browser appearance (#3245)
* Added methods to parse browser templates

* Added method to get parsed browser templates

* Make field rename check browser templates for field updates

* Update tests

* Updated CONTRIBUTORS

* Formatting

* Refactored cloze field logic for question template into closure

* Refactored cloze field logic for answer template into closure
2024-06-24 08:39:56 +01:00
Jarrett Ye
79917bbd2d
Fix/Relearning cards' Intervals don't update after changing Desired Retention (#3236)
* Fix/Relearning cards' Intervals don't update after changing Desired Retention

* cargo clippy --fix
2024-06-22 10:44:02 +01:00
Abdo
9dc3b10fe9
Fix deck config input's background color in Qt5 (#3243) 2024-06-22 10:43:34 +01:00
Damien Elmes
e41c4573d7 Formatting fix 2024-06-20 20:43:43 +07:00
Damien Elmes
a8e3b46edd Fix deck options failing to show on Qt 5.14
https://forums.ankiweb.net/t/mac-intel-options-screen-doesnt-work-on-version-24-06-2-qt5/45819/8
2024-06-20 20:29:36 +07:00
dependabot[bot]
b9a182d8e2
Bump ws from 8.16.0 to 8.17.1 (#3237)
Bumps [ws](https://github.com/websockets/ws) from 8.16.0 to 8.17.1.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.16.0...8.17.1)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-18 06:47:35 +01:00
Damien Elmes
e473b76043 urllib3 security fix 2024-06-18 12:46:32 +07:00
dependabot[bot]
f59e381e91
Bump braces from 3.0.2 to 3.0.3 (#3233)
Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-18 06:44:35 +01:00
Damien Elmes
33a923797a Bump version to 24.06.2 2024-06-09 09:28:59 +07:00
Damien Elmes
87eb8e6cd9 Update translations 2024-06-09 09:28:34 +07:00
Aristotelis
549cc467b6
Fix IO rendering in the previewer and template editor (#3228) 2024-06-08 13:18:58 +01:00
Damien Elmes
205068a993 Remove missed debugging statement 2024-06-08 05:29:29 +07:00
Damien Elmes
5fd3821152 Bump version to 24.06.1 2024-06-08 05:21:38 +07:00
Damien Elmes
b6166bdb3c Update translations 2024-06-08 05:17:37 +07:00
Damien Elmes
847912c5d8 Remove context check bypass when ANKI_API_PORT set
This resulted in the I/O regression in #3223 not being caught with ./run,
and puts devs ast risk. It also does not currently seem to be required
(pages like graphs and deck options work correctly with ./yarn dev).
I suspect the change was made to support running of pages/*.html, which
we no longer build.
2024-06-08 05:16:56 +07:00
Damien Elmes
71311f201e Fix image occlusion error during review 2024-06-08 05:06:54 +07:00
Alexander Bocken
4fb2efb8aa
fix sveltekit respecting yarn env var (#3226)
* fix sveltekit respecting yarn env var

* adding myself to CONTRIBUTORS
2024-06-07 23:01:40 +01:00
Damien Elmes
9b4dd54312 Update translations 2024-06-06 17:24:23 +07:00
Abdo
548066f92c
Fix missing i18n module in IO review screen (#3223) 2024-06-06 11:20:40 +01:00
Abdo
e0a3768bf3
Mention missing field's name in CardTypeError (#3225) 2024-06-06 11:20:19 +01:00
Abdo
e3c6b5bf3d
Work around RuntimeError in _update_button_label() (#3224) 2024-06-06 11:19:33 +01:00
Abdo
fbb73046e0
Avoid askUser() in sync dialogs (#3222) 2024-06-03 07:49:02 +01:00
Damien Elmes
5082d9ae5c Factor flask.make_response() calls out into helper function 2024-06-03 13:42:03 +07:00
Damien Elmes
bd88d15303 Update translations 2024-06-01 15:56:19 +07:00
Damien Elmes
d957cec9e0 Add missing word 2024-06-01 15:56:01 +07:00
Damien Elmes
6ef9ba0305 Switch 404 responses to plain text
Alternative fix which closes #3220
2024-06-01 15:50:27 +07:00
Abdo
8d2e8b1e4f
Pass -- to mpv/mplayer before filename (#3219)
* Pass -- to mpv/mplayer before filename

* Pass -- in as a separate argument (dae)
2024-06-01 09:44:24 +01:00
Abdo
06f7aa393d
Add a preference to toggle LaTeX generation (#3218)
* Add a preference to toggle LaTeX generation

* Fix test

* Remove LaTeX security restrictions

* Show existing LaTeX images regardless of preference

* Lift config check out of loop (dae)

* Shift option to review settings; display warning when disabled (dae)
2024-06-01 09:26:28 +01:00
Abdo
d981a6e3c6
Reword sync conflict explanation (#3221)
* Reword sync conflict explanation

* Preserve old string for now (dae)
2024-06-01 09:05:19 +01:00
Xidorn Quan
f7b93a5012 Add StartupWMClass for anki.desktop
This ensures that the system can correctly assign the windows of Anki to the desktop launcher item, e.g. in Ubuntu's dock.

Update CONTRIBUTORS
2024-06-01 14:58:47 +07:00
Richard Romero Jr
81de39768c
Fixes shift click selection after programmatic selection in most cases, Issue #2469 (#3213)
* Fixes shift click selection after programmatic selection in most cases

* Attempting to resolve checks

* Adding comment for _move_current setCurrentIndex

* Update qt/aqt/browser/table/table.py (dae)
2024-06-01 08:54:44 +01:00
Abdo
4ab0db3127
Another try at fixing IO events issue (#3210) 2024-05-28 10:29:21 +01:00
Damien Elmes
8229383b5c Remove empty cards shortcut
It's conflicting, and will need a new combo:
https://forums.ankiweb.net/t/anki-24-06-release-candidate/44926/44
2024-05-27 05:14:27 +07:00
Damien Elmes
a7cddbbdd9 Update past yanked requests version
https://forums.ankiweb.net/t/compiling-after-cve-changes/45248
2024-05-25 16:10:45 +07:00
Damien Elmes
17a20067f3 Fix set_due_date docstring
Closes #3207
2024-05-25 16:08:45 +07:00
Voczi
9e3a34f17f
Add support for custom certificates (#3203)
* Add support for custom certificates

* Update lints

* Update licenses

* Changes after feedback

* More changes
2024-05-24 10:57:54 +01:00
user1823
1957566c39
Reschedule → Reposition (#3209) 2024-05-24 10:48:03 +01:00
Mani
c2d565ee4f
do not recreate page when toggle button used (#3208) 2024-05-24 10:47:18 +01:00
Abdo
abacdcaeda
Fix future due search missing cards on last day (#3206) 2024-05-24 10:46:38 +01:00
Abdo
a9bf702317
Call profile_did_open hook at the end of loadProfile (#3202) 2024-05-24 09:23:29 +01:00
Damien Elmes
c8f8a9cd2f Honor night mode when switching between cards in card info 2024-05-22 17:07:01 +07:00
Damien Elmes
4a55f69e48 Revert "Use SplashScreen flag for all aqt tooltips (#3194)"
This reverts commit e50a768e44.

This appears to have caused a regression with keyboard shortcuts

https://forums.ankiweb.net/t/anki-24-06-release-candidate/44926/14
2024-05-22 17:06:37 +07:00
Damien Elmes
5d0b0733c2 Add missing full stop 2024-05-22 15:38:07 +07:00
Damien Elmes
4853798105 Latest requests CVE 2024-05-21 23:51:32 +07:00
Damien Elmes
9a438ae87d Probable fix for crash when syncing from preferences
https://forums.ankiweb.net/t/windows-anki-24-04-1-crashes-with-self-hosted-sync-server/44849/6
2024-05-21 23:08:08 +07:00
Damien Elmes
c4cd8808f3 Fix import order 2024-05-17 17:11:28 +07:00
Damien Elmes
d64ea23e11 Enable svelte preprocess 2024-05-17 17:01:49 +07:00
Damien Elmes
eac3daa385 Bump version to 24.06 2024-05-17 16:40:22 +07:00
Damien Elmes
91c877e02b Tweaks to the 'optimize all presets' progress
https://forums.ankiweb.net/t/visual-bugs-with-optimization/44873
2024-05-17 15:00:01 +07:00
Damien Elmes
7efae4d95d Mnemosyne importer now handles float values for due date and interval 2024-05-17 12:34:01 +07:00
Damien Elmes
bc69f689ab Fix Mnemosyne importer clobbering source file 2024-05-17 12:34:01 +07:00
Jarrett Ye
7a1508adb7
update to fsrs-rs v0.6.4 (#3200)
* update to fsrs-rs v0.6.3

* update to fsrs-rs v0.6.4
2024-05-17 06:26:06 +01:00
Abdo
ef49e3f741
Do not show media auto sync errors (#3197)
* Do not show media auto sync errors

* is_autosync -> is_periodic_sync

* More wording improvements; fix periodic sync depending on auto sync setting (dae)
2024-05-17 06:25:10 +01:00
Jarrett Ye
2b890b0eee
Fix/ignore revlogs when there is not learn entry after the last forget entry (#3199) 2024-05-17 06:07:15 +01:00
Damien Elmes
70996146d2 flask-cors CVE 2024-05-17 11:59:19 +07:00
Damien Elmes
f639c3660a Revert "Revert "Revert "Preserve HTML formatting inside clozes (#3038)"""
This reverts commit 9c733848b8.
2024-05-17 11:51:09 +07:00
Voczi
e50a768e44
Use SplashScreen flag for all aqt tooltips (#3194)
* Set custom tooltip flag as SplashScreen

Prevents tooltip from showing when parent is out of focus

* Update CONTRIBUTORS
2024-05-15 13:13:53 +01:00
Jarrett Ye
c9dccb5217
Fix/exclude suspended cards when optimize all presets (#3198) 2024-05-15 13:12:52 +01:00
Abdo
ce8ddc84b9
Fix finished preview learning cards being repeated (#3196) 2024-05-15 12:55:25 +01:00
Abdo
998b91c1fe
Fix IO event handlers being run on normal notes (#3195) 2024-05-15 12:48:58 +01:00
Damien Elmes
c29125939d Bump some Python deps with CVEs 2024-05-07 21:54:48 +10:00
Abdo
50772eeece
Fix '366 of 365 days studied' (#3182)
* Fix '366 of 365 days studied'

* Apply nicing when GraphRange.AllTime is selected
2024-05-06 23:50:27 +10:00
Abdo
df004b0b0c
Do not clear unused parent tags (#3174)
* Do not clear unused parent tags

* Update rslib/src/storage/note/mod.rs (dae)
2024-05-06 23:49:59 +10:00
Jarrett Ye
c9c7a3133c
Use median in calculating cost and remove outliers (#3181)
* Use median in calculating cost and remove outliers

* extract fn median_secs
2024-05-02 20:16:04 +10:00
RumovZ
8ad65d40ff
Clean up #3167 (#3186)
* Revert changes to ButtonToolbar from #3167

Flex gap is still not fully supported.
Keeps a small margin increase.

* Add margin to deck config header

* Move StickyHeader into import-page
2024-05-01 20:08:19 +10:00
Mani
995d7b1fa5
fix polygon tool draw (#3184) 2024-05-01 20:03:27 +10:00
Jarrett Ye
4a05fab088
update to fsrs-rs v0.6.2 (#3171) 2024-05-01 17:55:14 +10:00
RumovZ
9418bd9c7d
Improve and unify web dialog styling (#3167)
* Rework ChangeNotetypePage with existing components

* Use disabled Select instead of LabelButton

* Don't use  button for unclickable arrow

* Rework ImportLogPage with existing components

* Improve deck options styling

* Align spacing in ChangeNotetypePage further

* Use StickyContainer on ImportPage

* Format
2024-05-01 17:49:57 +10:00
Abdo
22ac77896f
Show review count for Evaluate/Optimize button (#3170)
* Revert "Show review count with FSRS evaluation results (#3165)"

This reverts commit b7e782c7e1.

* Show review count for Evaluate/Optimize button
2024-05-01 17:02:59 +10:00
Abdo
573af9cd4c
Use key instead of code in type-in field (#3166)
* Use key instead of code in type-in field

* Use event.key for Enter
2024-05-01 16:59:11 +10:00
Damien Elmes
22ecab1a0e Ensure DB check tooltip appears in main window
https://forums.ankiweb.net/t/is-this-bug-or-the-new-modification-in-anki-desktop/44072
2024-04-30 23:21:41 +10:00
Pedro Schreiber
074becc0ce
Add keyboard shortcuts for empty cards and toggle mask on image occlusion (#3136)
* Add keyboard shortcuts for empty cards and toggle mask on image occlusion

- add shortcut for empty cards
- add shortcut for toggle mask
- set tooltips with shortcuts

use unused shortcut for empty cards

* remove unnecessary shortcut added in main.py

* change empty cards shortcut and try to fix CI error in CONTRIBUTORS

* change shortcut for empty cards for universal support
2024-04-25 17:19:38 +10:00
Abdo
b7e782c7e1
Show review count with FSRS evaluation results (#3165) 2024-04-25 17:10:41 +10:00
Lucas Scharenbroch
ee8683587a
Add number truncation before back-end translation (#3162)
* Add number-truncation before backend translation

* Round instead of truncate (conform to testcases)

* Add test-case for plural rounding-to-one corner-case

* Move rounding into generated translation code

* Change unit test to test generated function

* Round any number in generation, ignore (int vs float)

(it seems that that type distinction is frequently inaccurate)

* Update formatting
2024-04-24 02:41:40 +01:00
Jarrett Ye
2c9accf595
update optimal retention and parameters tooltip (#3148)
* update optimal retention and parameters tooltip

* Revert "update optimal retention and parameters tooltip"

This reverts commit 32fdc5c1c3.

* update optimal retention and parameters tooltip

* check num of revlogs at first

* use new translation string

* Update deck-config.ftl

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* Update deck-config.ftl

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* Update deck-config.ftl

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* Update ftl/core/deck-config.ftl

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* fix position of translation string

* Update deck-config.ftl

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>

* Update deck-config.ftl

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>

* Update deck-config.ftl

---------

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2024-04-24 02:38:52 +01:00
RumovZ
790c52f012
Svg icon (#3135)
* Add sveltekit-svg plugin to fix svg icon styling

Closes #3127.

* Unify svg icon usage

Moves all icons into ts/lib/components/icons.ts and uses a single component to render
them both with eslint and svelte-kit.

* Fix spinning revert icon not being centered

* Use svg earth icon for global label

* Add tooltip to global label icon

* Remove eslint-plugin-simple-import-sort

Imports are already sorted by dprint with conflicting rules.
2024-04-24 02:37:31 +01:00
Mani
f0f9535200
fix io draw in mobile client (#3160) 2024-04-23 22:39:26 +10:00
Harvey R
839fd7bc8b
Add minimalist mode tooltip (#3155)
* Add preferences-minimalist-mode-tooltip

* Update preferences.ui

* Update preferences.ui

* Add preferences_minimalist_mode_tooltip

* Update preferences.ui

* Update preferences.ui
2024-04-23 00:32:55 +10:00
Abdo
e6c7d89443
Fix auto sync not working on Windows shutdown (#3153)
* Fix auto sync not working on Windows shutdown

* Fix mypy error

* Use translated string
2024-04-23 00:32:00 +10:00
Damien Elmes
a188a59646 Fix adding/saving I/Os on mobile 2024-04-22 20:58:26 +10:00
Damien Elmes
a90eda2e53 Update rustls for security issue 2024-04-22 19:37:11 +10:00
Abdo
00248665d7
Avoid locale.getdefaultlocale() if possible (#3143)
* Avoid locale.getdefaultlocale() if possible

* Suppress warning

* Add comment

* Apply suggestions from code review
2024-04-19 19:52:02 +10:00
Abdo
c62e2d8df0
Fix spacebar causing stutter when editing cards (#3150)
* Fix spacebar causing stutter when editing cards

* Remove IO toolbar event handlers on unmount

* Remove nested keydown handlers
2024-04-19 19:13:56 +10:00
RumovZ
ebc6c0847a
HMR on Windows (#3144)
* Enable hot module reloading on Windows

* Update VSC launch.json and tasks.json

* Bind vite server to 127.0.0.1 (dae)

Our frontend connects via IP, and on Windows, this fails if the server
is bound to 'localhost' instead.
2024-04-17 21:23:34 +10:00
Abdo
0a706c5dd9
Ignore errors in do_window_cleanup to fix shutdown issue (#3142)
* Ignore errors in do_window_cleanup to fix shutdown issue

* Only catch RuntimeError
2024-04-17 20:50:41 +10:00
Abdo
351aa96dfc
Fix IO text size in review screen (#2986)
* Store relative font size

* Handle multi-line text

Thanks to @glutanimate
2024-04-17 20:45:40 +10:00
Damien Elmes
1a868bcaaf Ensure runner gets rebuilt in Mac CI 2024-04-17 20:23:50 +10:00
Jarrett Ye
d1b2ab5983
Return current weights if fsrs items is zero & handle error in evaluation and optimal retention (#3141)
* return current weights if fsrs_items is zero

* handle error of evaluation if items.is_empty()

* TODO: handle error of optimal retention

* Revert "TODO: handle error of optimal retention"

This reverts commit 80a5b3803e.

* Revert "handle error of evaluation if items.is_empty()"

This reverts commit 7f0a5570e7.
2024-04-17 20:18:00 +10:00
Damien Elmes
e66adcca38 alertOnError should default to true
Regressed in svelte-kit port
2024-04-17 20:13:37 +10:00
Damien Elmes
a1fa865bb2 Update translations 2024-04-13 15:02:54 +07:00
Damien Elmes
39d191edd7 Bump version 2024-04-13 15:02:46 +07:00
Loudwig
d8f2782c26
Feature Show Reminder before answer (#3064) (#3119)
* Feature Question Action Show Reminder (#3064)

Added a option in the deck config that allow the user to choose in
Autoupdate mode between showing a reminder or revealing the card.
Also added my name to the contributors

* Update ftl/core/deck-config.ftl
2024-04-13 08:39:50 +01:00
Abdo
e486d6b513
Improve typing of custom fabric.Object properties (#3134)
* Ensure increasing ordinals of new masks

* Add fabric.d.ts

* Revert "Ensure increasing ordinals of new masks"

This reverts commit dedfeec9ad.
2024-04-13 08:36:08 +01:00
Wu Yi-Wei
31439e325d
Add Margins on the Buttons on the About Page (#3137)
* Add Margins on the Buttons on the About Page

* Fix contributors

* Fix format
2024-04-12 05:21:26 +01:00
Damien Elmes
761780397b Update idna for security issue 2024-04-12 11:17:29 +07:00
user1823
0334f4ff77
Optimum → Minimum retention (#3133)
This was missed in https://github.com/ankitects/anki/pull/3129.
2024-04-11 14:49:45 +01:00
dependabot[bot]
25345b91e1
Bump vite from 5.0.12 to 5.0.13 (#3132)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.0.12 to 5.0.13.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v5.0.13/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.0.13/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-11 08:54:10 +01:00
Damien Elmes
d0c4b938cb Update translations 2024-04-11 14:09:34 +07:00
Damien Elmes
1780c89d78 Fix casing of 'historical retention' 2024-04-11 14:09:16 +07:00
Mani
477f932f35
fix select all and change ordinal in edit mode in io (#3109)
* fix select all and change ordinal in edit mode in io

* make ordinal undefined for all shapes in group/ungroup

* fix group shapes and some ui fixes

* Don't add node_modules/* to dprint deps

* use minimum ordinal when shape merged, use max ordinal++ when ungrouped, in add mode no ordinal preset so NaN

* use state for ungroup shape

* maintain existing ordinal in editing mode

* fix order of ordinal in ungroup shape

* refactor: remove for loop, use forEach
2024-04-11 08:08:07 +01:00
Antoine Q
da4551e351
Update deck-config.ftl to clarify what optimal retention means (#3129)
* Update deck-config.ftl to clarify what optimal retention means

Renaming “Optimal retention” to “Minimum recommended retention"

* Update deck-config.ftl 

Removing "Predicted" in deck-config-predicted-optimal-retention

* Update deck-config.ftl

Updating keys

* Update ftl/core/deck-config.ftl

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2024-04-10 10:29:30 +01:00
Abdo
29bdc47482
Fix IO text masks being grouped (#3128) 2024-04-10 08:36:00 +01:00
Abdo
642f29cf5e
Fix IO mask position slightly off in edit mode (#3121) 2024-04-08 16:40:22 +01:00
Escape0707
97efd49cd8
Ignore exception raised by pip_system_certs not found (#3114)
This dependency usually doesn't benefit Linux distros with requests library configured to use system certificate already. And is not packaged by most distros. Making it optional will make most Linux users' installation much easier.
2024-04-05 13:12:06 +01:00
Jarrett Ye
10d567f937
Update to FSRS-rs v0.6.1 (#3106)
* update to FSRS-rs 0.6.0

* update to crates.io version

* format

* update to FSRS-rs v0.6.01

* ./ninja fix:minilints

* update python backend code
2024-04-05 13:04:50 +01:00
Damien Elmes
00ba69b5fe Fix latest RUSTSEC warning 2024-04-05 18:35:28 +07:00
Damien Elmes
3033b54890 Another attempt at fixing rounding issue with optimal retention
Also use the previously-added translation.
2024-04-05 18:22:45 +07:00
Damien Elmes
690866b090 Update instructions for Debian 12 2024-04-04 16:34:57 +07:00
Damien Elmes
0b3b6bb7f2 Update translations 2024-04-04 15:36:31 +07:00
Damien Elmes
20aff51df8 Forgot->Reset 2024-04-04 15:36:19 +07:00
Antoine Q
068f14378e
Update about.py (#3112)
Update about.py to add my name.
2024-04-03 10:22:40 +01:00
Damien Elmes
bdc9be2bbb Ensure ankihelper is rebuilt on arch change
https://forums.ankiweb.net/t/24-04-breaks-dark-mode-on-mac/43048
2024-04-03 15:07:50 +07:00
Damien Elmes
022a95db25 Mention missing libraries 2024-04-03 14:41:28 +07:00
Damien Elmes
a5154635dc Possible fix for crash on first sync
https://forums.ankiweb.net/t/desktop-app-closes-itself-after-i-try-to-log-in/43132
2024-04-03 14:11:34 +07:00
jthulhu
3cd8c5700b
Corrected minor non-idiomatic snippet of code (#3108)
* Corrected minor non-idiomaticity.

* Added to CONTRIBUTORS.
2024-04-01 11:34:23 +01:00
Damien Elmes
7121cb5132 Fix arm64 node checksum 2024-04-01 17:17:44 +07:00
Mani
038a0189d0
highlight io shapes in answer side (#3098) 2024-03-31 10:14:11 +01:00
Abdo
31e2dc1409
Fix some cloze handling regressions (#3086)
* Place cursor inside empty clozes

* Remove empty <li> after being added
2024-03-31 10:01:17 +01:00
Damien Elmes
9c733848b8 Revert "Revert "Preserve HTML formatting inside clozes (#3038)""
This reverts commit e911b4b69a.

Trying again now that 24.04 is out.
2024-03-31 15:55:30 +07:00
Damien Elmes
9f55cf26fc
Switch to SvelteKit (#3077)
* Update to latest Node LTS

* Add sveltekit

* Split tslib into separate @generated and @tslib components

SvelteKit's path aliases don't support multiple locations, so our old
approach of using @tslib to refer to both ts/lib and out/ts/lib will no
longer work. Instead, all generated sources and their includes are
placed in a separate out/ts/generated folder, and imported via @generated
instead. This also allows us to generate .ts files, instead of needing
to output separate .d.ts and .js files.

* Switch package.json to module type

* Avoid usage of baseUrl

Incompatible with SvelteKit

* Move sass into ts; use relative links

SvelteKit's default sass support doesn't allow overriding loadPaths

* jest->vitest, graphs example working with yarn dev

* most pages working in dev mode

* Some fixes after rebasing

* Fix/silence some svelte-check errors

* Get image-occlusion working with Fabric types

* Post-rebase lock changes

* Editor is now checked

* SvelteKit build integrated into ninja

* Use the new SvelteKit entrypoint for pages like congrats/deck options/etc

* Run eslint once for ts/**; fix some tests

* Fix a bunch of issues introduced when rebasing over latest main

* Run eslint fix

* Fix remaining eslint+pylint issues; tests now all pass

* Fix some issues with a clean build

* Latest bufbuild no longer requires @__PURE__ hack

* Add a few missed dependencies

* Add yarn.bat to fix Windows build

* Fix pages failing to show when ANKI_API_PORT not defined

* Fix svelte-check and vitest on Windows

* Set node path in ./yarn

* Move svelte-kit output to ts/.svelte-kit

Sadly, I couldn't figure out a way to store it in out/ if out/ is
a symlink, as it breaks module resolution when SvelteKit is run.

* Allow HMR inside Anki

* Skip SvelteKit build when HMR is defined

* Fix some post-rebase issues

I should have done a normal merge instead.
2024-03-31 09:16:31 +01:00
1212 changed files with 41554 additions and 26771 deletions

View file

@ -1,7 +1,6 @@
FROM debian:11-slim
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND="noninteractive"
ENV PYTHONPATH=/usr/lib/python3/dist-packages
RUN useradd -d /state -m -u 998 user
@ -33,6 +32,7 @@ RUN apt-get update && apt install --yes gnupg ca-certificates && \
libssl-dev \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxi6 \
libxkbcommon-x11-0 \
libxkbcommon0 \
@ -45,12 +45,8 @@ RUN apt-get update && apt install --yes gnupg ca-certificates && \
portaudio19-dev \
python3-dev \
rsync \
# -- begin only required for arm64/debian11
ninja-build \
clang-format \
python-is-python3 \
python3-pyqt5.qtwebengine \
# -- end only required for arm64/debian11
unzip \
zstd \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /etc/buildkite-agent/hooks && chown -R user /etc/buildkite-agent

View file

@ -1,72 +0,0 @@
FROM debian:10-slim
ARG DEBIAN_FRONTEND="noninteractive"
RUN useradd -d /state -m -u 998 user
RUN apt-get update && apt install --yes gnupg ca-certificates && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 32A37959C2FA5C3C99EFBC32A79206696452D198 \
&& echo "deb https://apt.buildkite.com/buildkite-agent stable main" > /etc/apt/sources.list.d/buildkite-agent.list \
&& apt-get update \
&& apt-get install --yes --no-install-recommends \
autoconf \
bash \
buildkite-agent \
ca-certificates \
curl \
findutils \
g++ \
gcc \
git \
grep \
libdbus-1-3 \
libegl1 \
libfontconfig1 \
libgl1 \
libgstreamer-gl1.0-0 \
libgstreamer-plugins-base1.0 \
libgstreamer1.0-0 \
libnss3 \
libpulse-mainloop-glib0 \
libpulse-mainloop-glib0 \
libssl-dev \
libxcomposite1 \
libxcursor1 \
libxi6 \
libxkbcommon-x11-0 \
libxkbcommon0 \
libxkbfile1 \
libxrandr2 \
libxrender1 \
libxtst6 \
make \
pkg-config \
portaudio19-dev \
python3-dev \
rsync \
unzip \
zstd \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /etc/buildkite-agent/hooks && chown -R user /etc/buildkite-agent
COPY buildkite.cfg /etc/buildkite-agent/buildkite-agent.cfg
COPY environment /etc/buildkite-agent/hooks/environment
# Available in Debian 11 as ninja-build, but we're building with Debian 10
RUN curl -LO https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip \
&& unzip ninja-linux.zip \
&& chmod +x ninja \
&& mv ninja /usr/bin \
&& rm ninja-linux.zip
RUN mkdir /state/rust && chown user /state/rust
USER user
ENV CARGO_HOME=/state/rust/cargo
ENV RUSTUP_HOME=/state/rust/rustup
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchain none
WORKDIR /code/buildkite
ENTRYPOINT ["/usr/bin/buildkite-agent", "start"]

View file

@ -0,0 +1,11 @@
#!/bin/bash
# builds an 'anki-[amd|arm]' image for the current platform
#
# for a cross-compile on recent Docker:
# docker buildx create --use
# docker run --privileged --rm tonistiigi/binfmt --install amd64
# docker buildx build --platform linux/amd64 --tag anki-amd64 . --load
. common.inc
DOCKER_BUILDKIT=1 docker build --tag anki-${platform} .

View file

@ -0,0 +1,9 @@
#!/bin/bash
set -e
if [[ "$(uname -m)" == "x86_64" ]]; then
platform="amd"
else
platform="arm"
fi

View file

@ -1,33 +1,29 @@
#!/bin/bash
# - use 'BUILD=1 ./run.sh' to build image & run.
# - use './run.sh' to run in the foreground
# - use './run.sh serve' to daemonize.
set -e
. common.inc
if [ "$1" = "serve" ]; then
extra_args="-d --restart always"
else
extra_args="-it"
fi
if [ $(uname -m) = "aarch64" ]; then
arch=arm64
else
arch=amd64
fi
name=anki-${platform}
if [ -n "$BUILD" ]; then
DOCKER_BUILDKIT=1 docker build -f Dockerfile.${arch} --tag linci .
fi
if docker container inspect linci > /dev/null 2>&1; then
docker stop linci || true
docker container rm linci
# Stop and remove the existing container if it exists.
# This doesn't delete the associated volume.
if docker container inspect $name > /dev/null 2>&1; then
docker stop $name || true
docker container rm $name
fi
docker run $extra_args \
--name linci \
-v ci-state:/state \
--name $name \
-v ${name}-state:/state \
-e BUILDKITE_AGENT_TOKEN \
-e BUILDKITE_AGENT_TAGS \
linci
$name

View file

@ -22,7 +22,7 @@ echo "--- Ensure libs importable"
SKIP_RUN=1 ./run
echo "--- Check Rust libs"
cargo install cargo-deny --version 0.14.12
cargo install cargo-deny --version 0.14.24
cargo deny check
echo "--- Cleanup"

View file

@ -7,7 +7,12 @@ export BUILD_ROOT=/state/build
export RELEASE=2
ln -sf out/node_modules .
echo "--- Install n2"
./tools/install-n2
echo "+++ Building"
if [ $(uname -m) = "aarch64" ]; then
export PYTHONPATH=/usr/lib/python3/dist-packages
./ninja wheels:anki
else
./ninja bundle

View file

@ -7,4 +7,4 @@ mkdir -p $STATE
echo "+++ Building and testing"
ln -sf out/node_modules .
BUILD_ROOT=$STATE/build ./ninja pylib qt wheels check
SKIP_RUNNER_BUILD=0 BUILD_ROOT=$STATE/build ./ninja pylib qt wheels check

View file

@ -1,12 +1,15 @@
[env]
STRINGS_PY = { value = "out/pylib/anki/_fluent.py", relative = true }
STRINGS_JS = { value = "out/ts/lib/ftl.js", relative = true }
STRINGS_DTS = { value = "out/ts/lib/ftl.d.ts", relative = true }
STRINGS_TS = { value = "out/ts/lib/generated/ftl.ts", relative = true }
DESCRIPTORS_BIN = { value = "out/rslib/proto/descriptors.bin", relative = true }
# build script will append .exe if necessary
PROTOC = { value = "out/extracted/protoc/bin/protoc", relative = true }
PYO3_NO_PYTHON = "1"
MACOSX_DEPLOYMENT_TARGET = "10.13.4"
MACOSX_DEPLOYMENT_TARGET = "11"
PYTHONDONTWRITEBYTECODE = "1" # prevent junk files on Windows
[term]
color = "always"
[target.'cfg(all(target_env = "msvc", target_os = "windows"))']
rustflags = ["-C", "target-feature=+crt-static"]

View file

@ -0,0 +1,2 @@
- To build and check the project, use ./check in the root folder (or check.bat on Windows)
- This will format files, then run lints and unit tests.

7
.cursor/rules/i18n.md Normal file
View file

@ -0,0 +1,7 @@
- We use the fluent system+code generation for translation.
- New strings should be added to rslib/core/. Ask for the appropriate file if you're not sure.
- Assuming a string addons-you-have-count has been added to addons.ftl, that string is accessible in our different languages as follows:
- Python: from aqt.utils import tr; msg = tr.addons_you_have_count(count=3)
- TypeScript: import * as tr from "@generated/ftl"; tr.addonsYouHaveCount({count: 3})
- Rust: collection.tr.addons_you_have_count(3)
- In Qt .ui files, strings that are marked as translatable will automatically use the registered ftl strings. So a QLabel with a title 'addons_you_have_count' that is marked as translatable will automatically use the translation defined in our addons.ftl file.

View file

@ -5,8 +5,8 @@
db-path = "~/.cargo/advisory-db"
db-urls = ["https://github.com/rustsec/advisory-db"]
ignore = [
# safemem only used by makeapp
"RUSTSEC-2023-0081",
# burn depends on an unmaintained package 'paste'
"RUSTSEC-2024-0436",
]
[licenses]
@ -14,15 +14,15 @@ allow = [
"MIT",
"Apache-2.0",
"Apache-2.0 WITH LLVM-exception",
"CDLA-Permissive-2.0",
"ISC",
"MPL-2.0",
"Unicode-DFS-2016",
"BSD-2-Clause",
"BSD-3-Clause",
"OpenSSL",
"CC0-1.0",
"Unlicense",
"Zlib",
"Unicode-3.0",
]
confidence-threshold = 0.8
# eg { allow = ["Zlib"], name = "adler32", version = "*" },

3
.dockerignore Normal file
View file

@ -0,0 +1,3 @@
node_modules/
target/
out/

View file

@ -8,13 +8,6 @@
},
"markdown": {},
"toml": {},
"prettier": {
"trailingComma": "all",
"printWidth": 88,
"tabWidth": 4,
"semi": true,
"htmlWhitespaceSensitivity": "ignore"
},
"includes": ["**/*.{ts,tsx,js,jsx,cjs,mjs,json,md,toml,svelte,scss}"],
"excludes": [
".vscode",
@ -27,17 +20,17 @@
"ftl/usage",
"licenses.json",
".dmypy.json",
"qt/bundle/PyOxidizer",
"target",
".mypy_cache",
"extra"
"extra",
"ts/.svelte-kit",
"ts/vite.config.ts.timestamp*"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.85.1.wasm",
"https://plugins.dprint.dev/json-0.17.4.wasm",
"https://plugins.dprint.dev/markdown-0.15.3.wasm",
"https://plugins.dprint.dev/toml-0.5.4.wasm",
"https://plugins.dprint.dev/prettier-0.13.0.json@dc5d12b7c1bf1a4683eff317c2c87350e75a5a3dfcc127f3d5628931bfb534b1",
"https://plugins.dprint.dev/disrupted/css-0.2.2.wasm"
"https://plugins.dprint.dev/typescript-0.91.6.wasm",
"https://plugins.dprint.dev/json-0.19.3.wasm",
"https://plugins.dprint.dev/markdown-0.17.6.wasm",
"https://plugins.dprint.dev/toml-0.6.2.wasm",
"https://plugins.dprint.dev/disrupted/css-0.2.3.wasm"
]
}

View file

@ -7,7 +7,6 @@ module.exports = {
},
plugins: [
"import",
"simple-import-sort",
"@typescript-eslint",
"@typescript-eslint/eslint-plugin",
],
@ -20,8 +19,6 @@ module.exports = {
"no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"import/newline-after-import": "warn",
"import/no-useless-path-segments": "warn",
"simple-import-sort/imports": "warn",
"simple-import-sort/exports": "warn",
"prefer-const": "warn",
"no-nested-ternary": "warn",
"curly": "error",
@ -36,6 +33,7 @@ module.exports = {
],
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
},
},
{
@ -47,11 +45,12 @@ module.exports = {
rules: {
"svelte/no-at-html-tags": "off",
"svelte/valid-compile": ["error", { "ignoreWarnings": true }],
"@typescript-eslint/no-explicit-any": "off",
},
},
],
env: { browser: true, es2020: true },
ignorePatterns: ["backend_proto.d.ts", "*.svelte.d.ts", "vendor", "extra/*"],
ignorePatterns: ["backend_proto.d.ts", "*.svelte.d.ts", "vendor", "extra/*", "vite.config.ts", "hooks.client.js"],
globals: {
globalThis: false,
NodeListOf: false,

5
.gitignore vendored
View file

@ -1,4 +1,5 @@
__pycache__
.mypy_cache
.DS_Store
anki.prof
target
@ -15,3 +16,7 @@ node_modules
.ninja_deps
/extra
yarn-error.log
ts/.svelte-kit
.yarn
.claude/settings.local.json
.claude/user.md

6
.gitmodules vendored
View file

@ -6,9 +6,3 @@
path = ftl/qt-repo
url = https://github.com/ankitects/anki-desktop-ftl.git
shallow = true
[submodule "qt/bundle/PyOxidizer"]
path = qt/bundle/PyOxidizer
url = https://github.com/ankitects/PyOxidizer.git
shallow = true
update = none

View file

@ -1,10 +0,0 @@
[settings]
ensure_newline_before_comments=true
force_grid_wrap=0
include_trailing_comma=True
known_first_party=anki,aqt,tests
line_length=88
multi_line_output=3
profile=black
skip=
use_parentheses=True

110
.mypy.ini
View file

@ -1,15 +1,15 @@
[mypy]
python_version = 3.9
pretty = false
no_strict_optional = true
show_error_codes = true
check_untyped_defs = true
pretty = False
strict_optional = False
show_error_codes = True
check_untyped_defs = True
disallow_untyped_decorators = True
warn_redundant_casts = True
warn_unused_configs = True
strict_equality = true
namespace_packages = true
explicit_package_bases = true
strict_equality = True
namespace_packages = True
explicit_package_bases = True
mypy_path =
pylib,
out/pylib,
@ -18,7 +18,7 @@ mypy_path =
ftl,
pylib/tools,
python
exclude = (qt/bundle/PyOxidizer|pylib/anki/_vendor)
exclude = (pylib/anki/_vendor)
[mypy-anki.*]
disallow_untyped_defs = True
@ -26,10 +26,92 @@ disallow_untyped_defs = True
disallow_untyped_defs = False
[mypy-anki.exporting]
disallow_untyped_defs = False
[mypy-aqt]
strict_optional = True
[mypy-aqt.browser.*]
strict_optional = True
[mypy-aqt.data.*]
strict_optional = True
[mypy-aqt.forms.*]
strict_optional = True
[mypy-aqt.import_export.*]
strict_optional = True
[mypy-aqt.operations.*]
no_strict_optional = false
strict_optional = True
[mypy-aqt.editor]
strict_optional = True
[mypy-aqt.importing]
strict_optional = True
[mypy-aqt.preferences]
strict_optional = True
[mypy-aqt.overview]
strict_optional = True
[mypy-aqt.customstudy]
strict_optional = True
[mypy-aqt.taglimit]
strict_optional = True
[mypy-aqt.modelchooser]
strict_optional = True
[mypy-aqt.deckdescription]
strict_optional = True
[mypy-aqt.deckbrowser]
strict_optional = True
[mypy-aqt.studydeck]
strict_optional = True
[mypy-aqt.tts]
strict_optional = True
[mypy-aqt.mediasrv]
strict_optional = True
[mypy-aqt.changenotetype]
strict_optional = True
[mypy-aqt.clayout]
strict_optional = True
[mypy-aqt.fields]
strict_optional = True
[mypy-aqt.filtered_deck]
strict_optional = True
[mypy-aqt.editcurrent]
strict_optional = True
[mypy-aqt.deckoptions]
strict_optional = True
[mypy-aqt.notetypechooser]
strict_optional = True
[mypy-aqt.stats]
strict_optional = True
[mypy-aqt.switch]
strict_optional = True
[mypy-aqt.debug_console]
strict_optional = True
[mypy-aqt.emptycards]
strict_optional = True
[mypy-aqt.flags]
strict_optional = True
[mypy-aqt.mediacheck]
strict_optional = True
[mypy-aqt.theme]
strict_optional = True
[mypy-aqt.toolbar]
strict_optional = True
[mypy-aqt.deckchooser]
strict_optional = True
[mypy-aqt.about]
strict_optional = True
[mypy-aqt.webview]
strict_optional = True
[mypy-aqt.mediasync]
strict_optional = True
[mypy-aqt.package]
strict_optional = True
[mypy-aqt.progress]
strict_optional = True
[mypy-aqt.tagedit]
strict_optional = True
[mypy-aqt.utils]
strict_optional = True
[mypy-aqt.sync]
strict_optional = True
[mypy-anki.scheduler.base]
no_strict_optional = false
strict_optional = True
[mypy-anki._backend.rsbridge]
ignore_missing_imports = True
[mypy-anki._vendor.stringcase]
@ -37,10 +119,10 @@ disallow_untyped_defs = False
[mypy-stringcase]
ignore_missing_imports = True
[mypy-aqt.mpv]
disallow_untyped_defs=false
ignore_errors=true
disallow_untyped_defs = False
ignore_errors = True
[mypy-aqt.winpaths]
disallow_untyped_defs=false
disallow_untyped_defs = False
[mypy-win32file]
ignore_missing_imports = True
@ -83,3 +165,5 @@ ignore_missing_imports = True
ignore_missing_imports = True
[mypy-pip_system_certs.*]
ignore_missing_imports = True
[mypy-anki_audio]
ignore_missing_imports = True

8
.prettierrc Normal file
View file

@ -0,0 +1,8 @@
{
"trailingComma": "all",
"printWidth": 88,
"tabWidth": 4,
"semi": true,
"htmlWhitespaceSensitivity": "ignore",
"plugins": ["prettier-plugin-svelte"]
}

View file

@ -1,48 +0,0 @@
[MASTER]
ignore-patterns=.*_pb2.*
persistent = no
extension-pkg-whitelist=orjson,PyQt6
init-hook="import sys; sys.path.extend(['pylib/anki/_vendor', 'out/qt'])"
[REPORTS]
output-format=colorized
[MESSAGES CONTROL]
disable=
R,
line-too-long,
too-many-lines,
missing-function-docstring,
missing-module-docstring,
missing-class-docstring,
import-outside-toplevel,
wrong-import-position,
wrong-import-order,
fixme,
unused-wildcard-import,
attribute-defined-outside-init,
redefined-builtin,
wildcard-import,
broad-except,
bare-except,
unused-argument,
unused-variable,
redefined-outer-name,
global-statement,
protected-access,
arguments-differ,
arguments-renamed,
consider-using-f-string,
invalid-name,
broad-exception-raised
[BASIC]
good-names =
id,
tr,
db,
ok,
ip,
[IMPORTS]
ignored-modules = anki.*_pb2, anki.sync_pb2, win32file,pywintypes,socket,win32pipe,pyaudio,anki.scheduler_pb2,anki.notetypes_pb2

1
.python-version Normal file
View file

@ -0,0 +1 @@
3.13.5

91
.ruff.toml Normal file
View file

@ -0,0 +1,91 @@
lint.select = [
"E", # pycodestyle errors
"F", # Pyflakes errors
"PL", # Pylint rules
"I", # Isort rules
"ARG",
# "UP", # pyupgrade
# "B", # flake8-bugbear
# "SIM", # flake8-simplify
]
extend-exclude = ["*_pb2.py", "*_pb2.pyi"]
lint.ignore = [
# Docstring rules (missing-*-docstring in pylint)
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D103", # Missing docstring in public function
# Import rules (wrong-import-* in pylint)
"E402", # Module level import not at top of file
"E501", # Line too long
# pycodestyle rules
"E741", # ambiguous-variable-name
# Comment rules (fixme in pylint)
"FIX002", # Line contains TODO
# Pyflakes rules
"F402", # import-shadowed-by-loop-var
"F403", # undefined-local-with-import-star
"F405", # undefined-local-with-import-star-usage
# Naming rules (invalid-name in pylint)
"N801", # Class name should use CapWords convention
"N802", # Function name should be lowercase
"N803", # Argument name should be lowercase
"N806", # Variable in function should be lowercase
"N811", # Constant imported as non-constant
"N812", # Lowercase imported as non-lowercase
"N813", # Camelcase imported as lowercase
"N814", # Camelcase imported as constant
"N815", # Variable in class scope should not be mixedCase
"N816", # Variable in global scope should not be mixedCase
"N817", # CamelCase imported as acronym
"N818", # Error suffix in exception names
# Pylint rules
"PLW0603", # global-statement
"PLW2901", # redefined-loop-name
"PLC0415", # import-outside-top-level
"PLR2004", # magic-value-comparison
# Exception handling (broad-except, bare-except in pylint)
"BLE001", # Do not catch blind exception
# Argument rules (unused-argument in pylint)
"ARG001", # Unused function argument
"ARG002", # Unused method argument
"ARG005", # Unused lambda argument
# Access rules (protected-access in pylint)
"SLF001", # Private member accessed
# String formatting (consider-using-f-string in pylint)
"UP032", # Use f-string instead of format call
# Exception rules (broad-exception-raised in pylint)
"TRY301", # Abstract raise to an inner function
# Builtin shadowing (redefined-builtin in pylint)
"A001", # Variable shadows a Python builtin
"A002", # Argument shadows a Python builtin
"A003", # Class attribute shadows a Python builtin
]
[lint.per-file-ignores]
"**/anki/*_pb2.py" = ["ALL"]
[lint.pep8-naming]
ignore-names = ["id", "tr", "db", "ok", "ip"]
[lint.pylint]
max-args = 12
max-returns = 10
max-branches = 35
max-statements = 125
[lint.isort]
known-first-party = ["anki", "aqt", "tests"]

View file

@ -1 +1 @@
24.04
25.09.2

View file

@ -2,7 +2,7 @@
"recommendations": [
"dprint.dprint",
"ms-python.python",
"ms-python.black-formatter",
"charliermarsh.ruff",
"rust-lang.rust-analyzer",
"svelte.svelte-vscode",
"zxh404.vscode-proto3",

View file

@ -6,9 +6,13 @@
"configurations": [
{
"name": "Run",
"type": "python",
"type": "debugpy",
"request": "launch",
"program": "tools/run.py",
"args": [
// "-p",
// "My test profile"
],
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"python": "${workspaceFolder}/out/pyenv/bin/python",
@ -20,7 +24,12 @@
"PYTHONPYCACHEPREFIX": "out/pycache",
"ANKIDEV": "1",
"QTWEBENGINE_REMOTE_DEBUGGING": "8080",
"QTWEBENGINE_CHROMIUM_FLAGS": "--remote-allow-origins=http://localhost:8080"
"QTWEBENGINE_CHROMIUM_FLAGS": "--remote-allow-origins=http://localhost:8080",
"RUST_BACKTRACE": "1",
// "TRACESQL": "1",
// "HMR": "1",
"ANKI_API_PORT": "40000",
"ANKI_API_HOST": "127.0.0.1"
},
"justMyCode": true,
"preLaunchTask": "ninja"

View file

@ -2,7 +2,7 @@
"editor.formatOnSave": true,
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
}
},
"files.watcherExclude": {
@ -18,12 +18,12 @@
"out/qt",
"qt"
],
"python.formatting.provider": "black",
"python.formatting.provider": "charliermarsh.ruff",
"python.linting.mypyEnabled": false,
"python.analysis.diagnosticSeverityOverrides": {
"reportMissingModuleSource": "none"
},
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.check.allTargets": false,
"rust-analyzer.files.excludeDirs": [".bazel", "node_modules"],
"rust-analyzer.procMacro.enable": true,
// this formats 'use' blocks in a nicer way, but requires you to run
@ -31,11 +31,13 @@
"rust-analyzer.rustfmt.extraArgs": ["+nightly"],
"search.exclude": {
"**/node_modules": true,
".bazel/**": true,
"qt/bundle/PyOxidizer": true
".bazel/**": true
},
"rust-analyzer.cargo.buildScripts.enable": true,
"python.analysis.typeCheckingMode": "off",
"python.analysis.exclude": [
"out/launcher/**"
],
"terminal.integrated.env.windows": {
"PATH": "c:\\msys64\\usr\\bin;${env:Path}"
}

View file

@ -9,14 +9,8 @@
"qt"
],
"windows": {
"command": "bash",
"options": {
"env": {
"PATH": "c:\\msys64\\usr\\bin;${env:Path}"
}
},
"command": "tools/ninja.bat",
"args": [
"ninja",
"pylib",
"qt",
"extract:win_amd64_audio"

2
.yarnrc.yml Normal file
View file

@ -0,0 +1,2 @@
nodeLinker: node-modules
enableScripts: false

86
CLAUDE.md Normal file
View file

@ -0,0 +1,86 @@
# Claude Code Configuration
## Project Overview
Anki is a spaced repetition flashcard program with a multi-layered architecture. Main components:
- Web frontend: Svelte/TypeScript in ts/
- PyQt GUI, which embeds the web components in aqt/
- Python library which wraps our rust Layer (pylib/, with Rust module in pylib/rsbridge)
- Core Rust layer in rslib/
- Protobuf definitions in proto/ that are used by the different layers to
talk to each other.
## Building/checking
./check (check.bat) will format the code and run the main build & checks.
Please do this as a final step before marking a task as completed.
## Quick iteration
During development, you can build/check subsections of our code:
- Rust: 'cargo check'
- Python: './tools/dmypy', and if wheel-related, './ninja wheels'
- TypeScript/Svelte: './ninja check:svelte'
Be mindful that some changes (such as modifications to .proto files) may
need a full build with './check' first.
## Build tooling
'./check' and './ninja' invoke our build system, which is implemented in build/. It takes care of downloading required deps and invoking our build
steps.
## Translations
ftl/ contains our Fluent translation files. We have scripts in rslib/i18n
to auto-generate an API for Rust, TypeScript and Python so that our code can
access the translations in a type-safe manner. Changes should be made to
ftl/core or ftl/qt. Except for features specific to our Qt interface, prefer
the core module. When adding new strings, confirm the appropriate ftl file
first, and try to match the existing style.
## Protobuf and IPC
Our build scripts use the .proto files to define our Rust library's
non-Rust API. pylib/rsbridge exposes that API, and _backend.py exposes
snake_case methods for each protobuf RPC that call into the API.
Similar tooling creates a @generated/backend TypeScript module for
communicating with the Rust backend (which happens over POST requests).
## Fixing errors
When dealing with build errors or failing tests, invoke 'check' or one
of the quick iteration commands regularly. This helps verify your changes
are correct. To locate other instances of a problem, run the check again -
don't attempt to grep the codebase.
## Ignores
The files in out/ are auto-generated. Mostly you should ignore that folder,
though you may sometimes find it useful to view out/{pylib/anki,qt/_aqt,ts/lib/generated} when dealing with cross-language communication or our other generated sourcecode.
## Launcher/installer
The code for our launcher is in qt/launcher, with separate code for each
platform.
## Rust dependencies
Prefer adding to the root workspace, and using dep.workspace = true in the individual Rust project.
## Rust utilities
rslib/{process,io} contain some helpers for file and process operations,
which provide better error messages/context and some ergonomics. Use them
when possible.
## Rust error handling
in rslib, use error/mod.rs's AnkiError/Result and snafu. In our other Rust modules, prefer anyhow + additional context where appropriate. Unwrapping
in build scripts/tests is fine.
## Individual preferences
See @.claude/user.md

View file

@ -32,8 +32,8 @@ AMBOSS MD Inc. <https://www.amboss.com/>
Aristotelis P. <https://glutanimate.com/contact>
Erez Volk <erez.volk@gmail.com>
zjosua <zjosua@hotmail.com>
Arthur Milchior <arthur@milchior.fr>
Yngve Hoiseth <yngve@hoiseth.net>
Arthur Milchior <arthur@milchior.fr>
Ijgnd
Yoonchae Lee <bluegreenmagick@gmail.com>
Evandro Coan <github.com/evandrocoan>
@ -49,6 +49,7 @@ Sander Santema <github.com/sandersantema/>
Thomas Brownback <https://github.com/brownbat/>
Andrew Gaul <andrew@gaul.org>
kenden
Emil Hamrin <github.com/e-hamrin>
Nickolay Yudin <kelciour@gmail.com>
neitrinoweb <github.com/neitrinoweb/>
Andreas Reis <github.com/nwwt>
@ -63,6 +64,7 @@ Jakub Kaczmarzyk <jakub.kaczmarzyk@gmail.com>
Akshara Balachandra <akshara.bala.18@gmail.com>
lukkea <github.com/lukkea/>
David Allison <davidallisongithub@gmail.com>
David Allison <62114487+david-allison@users.noreply.github.com>
Tsung-Han Yu <johan456789@gmail.com>
Piotr Kubowicz <piotr.kubowicz@gmail.com>
RumovZ <gp5glkw78@relay.firefox.com>
@ -98,7 +100,7 @@ gnnoh <gerongfenh@gmail.com>
Sachin Govind <sachin.govind.too@gmail.com>
Bruce Harris <github.com/bruceharris>
Patric Cunha <patricc@agap2.pt>
Brayan Oliveira <github.com/BrayanDSO>
Brayan Oliveira <69634269+BrayanDSO@users.noreply.github.com>
Luka Warren <github.com/lukawarren>
wisherhxl <wisherhxl@gmail.com>
dobefore <1432338032@qq.com>
@ -118,7 +120,7 @@ yellowjello <github.com/yellowjello>
Ingemar Berg <github.com/ingemarberg>
Ben Kerman <ben@kermanic.org>
Euan Kemp <euank@euank.com>
Kieran Black <kieranlblack@gmail.com>
Kieran Black <kieranlblack@gmail.com>
XeR <github.com/XeR>
mgrottenthaler <github.com/mgrottenthaler>
Austin Siew <github.com/Aquafina-water-bottle>
@ -138,7 +140,7 @@ Monty Evans <montyevans@gmail.com>
Nil Admirari <https://github.com/nihil-admirari>
Michael Winkworth <github.com/SteelColossus>
Mateusz Wojewoda <kawa1.11@o2.pl>
Jarrett Ye <jarrett.ye@outlook.com>
Jarrett Ye <jarrett.ye@outlook.com>
Sam Waechter <github.com/swektr>
Michael Eliachevitch <m.eliachevitch@posteo.de>
Carlo Quick <https://github.com/CarloQuick>
@ -148,6 +150,7 @@ user1823 <92206575+user1823@users.noreply.github.com>
Gustaf Carefall <https://github.com/Gustaf-C>
virinci <github.com/virinci>
snowtimeglass <snowtimeglass@gmail.com>
brishtibheja <136738526+brishtibheja@users.noreply.github.com>
Ben Olson <github.com/grepgrok>
Akash Reddy <akashreddy2003@gmail.com>
Lucio Sauer <watermanpaint@posteo.net>
@ -169,6 +172,78 @@ Vasll <github.com/vasll>
laalsaas <laalsaas@systemli.org>
ijqq <ijqq@protonmail.ch>
AntoineQ1 <https://github.com/AntoineQ1>
jthulhu <https://github.com/jthulhu>
Escape0707 <tothesong@gmail.com>
Loudwig <https://github.com/Loudwig>
Wu Yi-Wei <https://github.com/Ianwu0812>
RRomeroJr <117.rromero@gmail.com>
Xidorn Quan <me@upsuper.org>
Alexander Bocken <alexander@bocken.org>
James Elmore <email@jameselmore.org>
Ian Samir Yep Manzano <https://github.com/isym444>
David Culley <6276049+davidculley@users.noreply.github.com>
Rastislav Kish <rastislav.kish@protonmail.com>
jake <jake@sharnoth.com>
Expertium <https://github.com/Expertium>
Christian Donat <https://github.com/cdonat2>
Asuka Minato <https://asukaminato.eu.org>
Dillon Baldwin <https://github.com/DillBal>
Voczi <https://github.com/voczi>
Ben Nguyen <105088397+bpnguyen107@users.noreply.github.com>
Themis Demetriades <themis100@outlook.com>
Luke Bartholomew <lukesbart@icloud.com>
Gregory Abrasaldo <degeemon@gmail.com>
Taylor Obyen <162023405+taylorobyen@users.noreply.github.com>
Kris Cherven <krischerven@gmail.com>
twwn <github.com/twwn>
Cy Pokhrel <cy@cy7.sh>
Park Hyunwoo <phu54321@naver.com>
Tomas Fabrizio Orsi <torsi@fi.uba.ar>
Dongjin Ouyang <1113117424@qq.com>
Sawan Sunar <sawansunar24072002@gmail.com>
hideo aoyama <https://github.com/boukendesho>
Ross Brown <rbrownwsws@googlemail.com>
🦙 <gh@siid.sh>
Lukas Sommer <sommerluk@gmail.com>
Luca Auer <lolle2000.la@gmail.com>
Niclas Heinz <nheinz@hpost.net>
Omar Kohl <omarkohl@posteo.net>
David Elizalde <david.elizalde.r.a@gmail.com>
beyondcompute <beyondcompute@gmail.com>
Yuki <https://github.com/YukiNagat0>
wackbyte <wackbyte@protonmail.com>
GithubAnon0000 <GithubAnon0000@users.noreply.github.com>
Mike Hardy <github@mikehardy.net>
Danika_Dakika <https://github.com/Danika-Dakika>
Mumtaz Hajjo Alrifai <mumtazrifai@protonmail.com>
Thomas Graves <fate@hey.com>
Jakub Fidler <jakub.fidler@protonmail.com>
Valerie Enfys <val@unidentified.systems>
Julien Chol <https://github.com/chel-ou>
ikkz <ylei.mk@gmail.com>
derivativeoflog7 <https://github.com/derivativeoflog7>
rreemmii-dev <https://github.com/rreemmii-dev>
babofitos <https://github.com/babofitos>
Jonathan Schoreels <https://github.com/JSchoreels>
JL710
Matt Brubeck <mbrubeck@limpet.net>
Yaoliang Chen <yaoliang.ch@gmail.com>
KolbyML <https://github.com/KolbyML>
Adnane Taghi <dev@soleuniverse.me>
Spiritual Father <https://github.com/spiritualfather>
Emmanuel Ferdman <https://github.com/emmanuel-ferdman>
Sunong2008 <https://github.com/Sunrongguo2008>
Marvin Kopf <marvinkopf@outlook.com>
Kevin Nakamura <grinkers@grinkers.net>
Bradley Szoke <bradleyszoke@gmail.com>
jcznk <https://github.com/jcznk>
Thomas Rixen <thomas.rixen@student.uclouvain.be>
Siyuan Mattuwu Yan <syan4@ualberta.ca>
Lee Doughty <32392044+leedoughty@users.noreply.github.com>
memchr <memchr@proton.me>
Max Romanowski <maxr777@proton.me>
Aldlss <ayaldlss@gmail.com>
********************
The text of the 3 clause BSD license follows:

5783
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,29 +1,27 @@
[workspace.package]
version = "0.0.0"
authors = ["Ankitects Pty Ltd and contributors <https://help.ankiweb.net>"]
license = "AGPL-3.0-or-later"
rust-version = "1.65"
edition = "2021"
license = "AGPL-3.0-or-later"
rust-version = "1.80"
[workspace]
members = [
"rslib",
"rslib/i18n",
"rslib/linkchecker",
"rslib/proto",
"rslib/io",
"rslib/process",
"rslib/sync",
"pylib/rsbridge",
"build/configure",
"build/ninja_gen",
"build/runner",
"ftl",
"pylib/rsbridge",
"qt/launcher",
"rslib",
"rslib/i18n",
"rslib/io",
"rslib/linkchecker",
"rslib/process",
"rslib/proto",
"rslib/sync",
"tools/minilints",
"qt/bundle/win",
"qt/bundle/mac",
]
exclude = ["qt/bundle"]
resolver = "2"
[workspace.dependencies.percent-encoding-iri]
@ -35,9 +33,8 @@ git = "https://github.com/ankitects/linkcheck.git"
rev = "184b2ca50ed39ca43da13f0b830a463861adb9ca"
[workspace.dependencies.fsrs]
version = "0.5.5"
version = "5.1.0"
# git = "https://github.com/open-spaced-repetition/fsrs-rs.git"
# rev = "58ca25ed2bc4bb1dc376208bbcaed7f5a501b941"
# path = "../open-spaced-repetition/fsrs-rs"
[workspace.dependencies]
@ -45,8 +42,8 @@ version = "0.5.5"
anki = { path = "rslib" }
anki_i18n = { path = "rslib/i18n" }
anki_io = { path = "rslib/io" }
anki_proto = { path = "rslib/proto" }
anki_process = { path = "rslib/process" }
anki_proto = { path = "rslib/proto" }
anki_proto_gen = { path = "rslib/proto_gen" }
ninja_gen = { "path" = "build/ninja_gen" }
@ -54,98 +51,101 @@ ninja_gen = { "path" = "build/ninja_gen" }
unicase = "=2.6.0" # any changes could invalidate sqlite indexes
# normal
ammonia = "3.3.0"
anyhow = "1.0.80"
apple-bundles = "0.17.0"
async-compression = { version = "0.4.6", features = ["zstd", "tokio"] }
async-stream = "0.3.5"
async-trait = "0.1.77"
axum = { version = "0.6.20", features = ["multipart", "macros", "headers"] }
axum-client-ip = "0.4.2"
blake3 = "1.5.0"
bytes = "1.5.0"
camino = "1.1.6"
chrono = { version = "0.4.34", default-features = false, features = ["std", "clock"] }
clap = { version = "4.3.24", features = ["derive"] }
coarsetime = "0.1.34"
convert_case = "0.6.0"
criterion = { version = "0.5.1" }
csv = "1.3.0"
data-encoding = "2.5.0"
ammonia = "4.1.0"
anyhow = "1.0.98"
async-compression = { version = "0.4.24", features = ["zstd", "tokio"] }
async-stream = "0.3.6"
async-trait = "0.1.88"
axum = { version = "0.8.4", features = ["multipart", "macros"] }
axum-client-ip = "1.1.3"
axum-extra = { version = "0.10.1", features = ["typed-header"] }
bitflags = "2.9.1"
blake3 = "1.8.2"
bytes = "1.10.1"
camino = "1.1.10"
chrono = { version = "0.4.41", default-features = false, features = ["std", "clock"] }
clap = { version = "4.5.40", features = ["derive"] }
coarsetime = "0.1.36"
convert_case = "0.8.0"
criterion = { version = "0.6.0" }
csv = "1.3.1"
data-encoding = "2.9.0"
difflib = "0.4.0"
flate2 = "1.0.28"
fluent = "0.16.0"
fluent-bundle = "0.15.2"
fluent-syntax = "0.11.0"
dirs = "6.0.0"
dunce = "1.0.5"
embed-resource = "3.0.4"
envy = "0.4.2"
flate2 = "1.1.2"
fluent = "0.17.0"
fluent-bundle = "0.16.0"
fluent-syntax = "0.12.0"
fnv = "1.0.7"
futures = "0.3.30"
glob = "0.3.1"
globset = "0.4.14"
futures = "0.3.31"
globset = "0.4.16"
hex = "0.4.3"
htmlescape = "0.3.1"
hyper = "0.14.28"
hyper = "1"
id_tree = "1.8.0"
inflections = "1.1.1"
intl-memoizer = "0.5.1"
itertools = "0.12.1"
junction = "1.0.0"
lazy_static = "1.4.0"
intl-memoizer = "0.5.3"
itertools = "0.14.0"
junction = "1.2.0"
libc = "0.2"
libc-stdhandle = "0.1"
maplit = "1.0.2"
nom = "7.1.3"
nom = "8.0.0"
num-format = "0.4.4"
num_cpus = "1.16.0"
num_enum = "0.7.2"
once_cell = "1.19.0"
num_cpus = "1.17.0"
num_enum = "0.7.3"
once_cell = "1.21.3"
pbkdf2 = { version = "0.12", features = ["simple"] }
phf = { version = "0.11.2", features = ["macros"] }
pin-project = "1.1.4"
plist = "1.5.1"
prettyplease = "0.2.16"
prost = "0.12.3"
prost-build = "0.12.3"
prost-reflect = "0.12.0"
prost-types = "0.12.3"
pulldown-cmark = "0.9.6"
pyo3 = { version = "0.20.3", features = ["extension-module", "abi3", "abi3-py39"] }
rand = "0.8.5"
regex = "1.10.3"
reqwest = { version = "0.11.24", default-features = false, features = ["json", "socks", "stream", "multipart"] }
rusqlite = { version = "0.30.0", features = ["trace", "functions", "collation", "bundled"] }
phf = { version = "0.11.3", features = ["macros"] }
pin-project = "1.1.10"
prettyplease = "0.2.34"
prost = "0.13"
prost-build = "0.13"
prost-reflect = "0.14.7"
prost-types = "0.13"
pulldown-cmark = "0.13.0"
pyo3 = { version = "0.25.1", features = ["extension-module", "abi3", "abi3-py39"] }
rand = "0.9.1"
rayon = "1.10.0"
regex = "1.11.1"
reqwest = { version = "0.12.20", default-features = false, features = ["json", "socks", "stream", "multipart"] }
rusqlite = { version = "0.36.0", features = ["trace", "functions", "collation", "bundled"] }
rustls-pemfile = "2.2.0"
scopeguard = "1.2.0"
serde = { version = "1.0.197", features = ["derive"] }
serde-aux = "4.5.0"
serde_json = "1.0.114"
serde_repr = "0.1.18"
serde_tuple = "0.5.0"
serde = { version = "1.0.219", features = ["derive"] }
serde-aux = "4.7.0"
serde_json = "1.0.140"
serde_repr = "0.1.20"
serde_tuple = "1.1.0"
sha1 = "0.10.6"
sha2 = { version = "0.10.8" }
simple-file-manifest = "0.11.0"
snafu = { version = "0.8.1", features = ["rust_1_61"] }
strum = { version = "0.26.1", features = ["derive"] }
syn = { version = "2.0.51", features = ["parsing", "printing"] }
tar = "0.4.40"
tempfile = "3.10.1"
sha2 = { version = "0.10.9" }
snafu = { version = "0.8.6", features = ["rust_1_61"] }
strum = { version = "0.27.1", features = ["derive"] }
syn = { version = "2.0.103", features = ["parsing", "printing"] }
tar = "0.4.44"
tempfile = "3.20.0"
termcolor = "1.4.1"
tokio = { version = "1.36", features = ["fs", "rt-multi-thread", "macros", "signal"] }
tokio-util = { version = "0.7.10", features = ["io"] }
tower-http = { version = "0.4.4", features = ["trace"] }
tracing = { version = "0.1.40", features = ["max_level_trace", "release_max_level_debug"] }
tokio = { version = "1.45", features = ["fs", "rt-multi-thread", "macros", "signal"] }
tokio-util = { version = "0.7.15", features = ["io"] }
tower-http = { version = "0.6.6", features = ["trace"] }
tracing = { version = "0.1.41", features = ["max_level_trace", "release_max_level_debug"] }
tracing-appender = "0.2.3"
tracing-subscriber = { version = "0.3.18", features = ["fmt", "env-filter"] }
tugger-windows-codesign = "0.10.0"
unic-langid = { version = "0.9.4", features = ["macros"] }
tracing-subscriber = { version = "0.3.20", features = ["fmt", "env-filter"] }
unic-langid = { version = "0.9.6", features = ["macros"] }
unic-ucd-category = "0.9.0"
unicode-normalization = "0.1.23"
utime = "0.3.1"
walkdir = "2.4.0"
which = "5.0.0"
wiremock = "0.5.22"
unicode-normalization = "0.1.24"
walkdir = "2.5.0"
which = "8.0.0"
widestring = "1.1.0"
winapi = { version = "0.3", features = ["wincon", "winreg"] }
windows = { version = "0.61.3", features = ["Media_SpeechSynthesis", "Media_Core", "Foundation_Collections", "Storage_Streams", "Win32_System_Console", "Win32_System_Registry", "Win32_System_SystemInformation", "Win32_Foundation", "Win32_UI_Shell", "Wdk_System_SystemServices"] }
wiremock = "0.6.3"
xz2 = "0.1.7"
zip = { version = "0.6.6", default-features = false, features = ["deflate", "time"] }
zstd = { version = "0.13.0", features = ["zstdmt"] }
envy = "0.4.2"
dirs = "5.0.1"
dunce = "1.0.4"
zip = { version = "4.1.0", default-features = false, features = ["deflate", "time"] }
zstd = { version = "0.13.3", features = ["zstdmt"] }
# Apply mild optimizations to our dependencies in dev mode, which among other things
# improves sha2 performance by about 21x. Opt 1 chosen due to

View file

@ -6,8 +6,6 @@ The following included source code items use a license other than AGPL3:
In the pylib folder:
* The SuperMemo importer: GPL3 and 0BSD.
* The Pauker importer: BSD-3.
* statsbg.py: CC BY 4.0.
In the qt folder:

View file

@ -1,4 +1,4 @@
# Anki
# Anki®
[![Build status](https://badge.buildkite.com/c9edf020a4aec976f9835e54751cc5409d843adbb66d043bd3.svg?branch=main)](https://buildkite.com/ankitects/anki-ci)

View file

@ -14,6 +14,7 @@ use ninja_gen::node::EsbuildScript;
use ninja_gen::node::TypescriptCheck;
use ninja_gen::python::python_format;
use ninja_gen::python::PythonTest;
use ninja_gen::rsync::RsyncFiles;
use ninja_gen::Build;
use ninja_gen::Utf8Path;
use ninja_gen::Utf8PathBuf;
@ -21,13 +22,11 @@ use ninja_gen::Utf8PathBuf;
use crate::anki_version;
use crate::python::BuildWheel;
use crate::web::copy_mathjax;
use crate::web::eslint;
pub fn build_and_check_aqt(build: &mut Build) -> Result<()> {
build_forms(build)?;
build_generated_sources(build)?;
build_data_folder(build)?;
build_macos_helper(build)?;
build_wheel(build)?;
check_python(build)?;
Ok(())
@ -39,7 +38,6 @@ fn build_forms(build: &mut Build) -> Result<()> {
let mut py_files = vec![];
for path in ui_files.resolve() {
let outpath = outdir.join(path.file_name().unwrap()).into_string();
py_files.push(outpath.replace(".ui", "_qt5.py"));
py_files.push(outpath.replace(".ui", "_qt6.py"));
}
build.add_action(
@ -114,9 +112,22 @@ fn build_data_folder(build: &mut Build) -> Result<()> {
build_js(build)?;
build_pages(build)?;
build_icons(build)?;
copy_sveltekit(build)?;
Ok(())
}
fn copy_sveltekit(build: &mut Build) -> Result<()> {
build.add_action(
"qt:aqt:data:web:sveltekit",
RsyncFiles {
inputs: inputs![":sveltekit:folder"],
target_folder: "qt/_aqt/data/web/",
strip_prefix: "$builddir/",
extra_args: "-a --delete",
},
)
}
fn build_css(build: &mut Build) -> Result<()> {
let scss_files = build.expand_inputs(inputs![glob!["qt/aqt/data/web/css/*.scss"]]);
let out_dir = Utf8Path::new("qt/_aqt/data/web/css");
@ -172,7 +183,6 @@ fn build_js(build: &mut Build) -> Result<()> {
)?;
}
let files = inputs![glob!["qt/aqt/data/web/js/*"]];
eslint(build, "aqt", "qt/aqt/data/web/js", files.clone())?;
build.add_action(
"check:typescript:aqt",
TypescriptCheck {
@ -325,46 +335,25 @@ impl BuildAction for BuildThemedIcon<'_> {
}
}
fn build_macos_helper(build: &mut Build) -> Result<()> {
if cfg!(target_os = "macos") {
build.add_action(
"qt:aqt:data:lib:libankihelper",
RunCommand {
command: ":pyenv:bin",
args: "$script $out $in",
inputs: hashmap! {
"script" => inputs!["qt/mac/helper_build.py"],
"in" => inputs![glob!["qt/mac/*.swift"]],
},
outputs: hashmap! {
"out" => vec!["qt/_aqt/data/lib/libankihelper.dylib"],
},
},
)?;
}
Ok(())
}
fn build_wheel(build: &mut Build) -> Result<()> {
build.add_action(
"wheels:aqt",
BuildWheel {
name: "aqt",
version: anki_version(),
src_folder: "qt/aqt",
gen_folder: "$builddir/qt/_aqt",
platform: None,
deps: inputs![":qt:aqt", glob!("qt/aqt/**"), "python/requirements.aqt.in"],
deps: inputs![
":qt:aqt",
glob!("qt/aqt/**"),
"qt/pyproject.toml",
"qt/hatch_build.py"
],
},
)
}
fn check_python(build: &mut Build) -> Result<()> {
python_format(
build,
"qt",
inputs![glob!("qt/**/*.py", "qt/bundle/PyOxidizer/**")],
)?;
python_format(build, "qt", inputs![glob!("qt/**/*.py")])?;
build.add_action(
"check:pytest:aqt",

View file

@ -1,505 +0,0 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::env;
use anyhow::Result;
use ninja_gen::action::BuildAction;
use ninja_gen::archives::download_and_extract;
use ninja_gen::archives::empty_manifest;
use ninja_gen::archives::with_exe;
use ninja_gen::archives::OnlineArchive;
use ninja_gen::archives::Platform;
use ninja_gen::build::BuildProfile;
use ninja_gen::cargo::CargoBuild;
use ninja_gen::cargo::RustOutput;
use ninja_gen::git::SyncSubmodule;
use ninja_gen::glob;
use ninja_gen::input::BuildInput;
use ninja_gen::inputs;
use ninja_gen::python::PythonEnvironment;
use ninja_gen::Build;
use ninja_gen::Utf8Path;
use crate::anki_version;
use crate::platform::overriden_python_target_platform;
use crate::platform::overriden_rust_target_triple;
#[derive(Debug, PartialEq, Eq)]
enum DistKind {
Standard,
Alternate,
}
impl DistKind {
fn folder_name(&self) -> &'static str {
match self {
DistKind::Standard => "std",
DistKind::Alternate => "alt",
}
}
fn name(&self) -> &'static str {
match self {
DistKind::Standard => "standard",
DistKind::Alternate => "alternate",
}
}
}
pub fn build_bundle(build: &mut Build) -> Result<()> {
// install into venv
setup_primary_venv(build)?;
install_anki_wheels(build)?;
// bundle venv into output binary + extra_files
build_pyoxidizer(build)?;
build_artifacts(build)?;
build_binary(build)?;
// package up outputs with Qt/other deps
download_dist_folder_deps(build)?;
build_dist_folder(build, DistKind::Standard)?;
// repeat for Qt5
if !targetting_macos_arm() {
if !cfg!(target_os = "macos") {
setup_qt5_venv(build)?;
}
build_dist_folder(build, DistKind::Alternate)?;
}
build_packages(build)?;
Ok(())
}
fn targetting_macos_arm() -> bool {
cfg!(all(target_os = "macos", target_arch = "aarch64"))
&& overriden_python_target_platform().is_none()
}
const WIN_AUDIO: OnlineArchive = OnlineArchive {
url: "https://github.com/ankitects/anki-bundle-extras/releases/download/anki-2022-02-09/audio-win-amd64.tar.gz",
sha256: "0815a601baba05e03bc36b568cdc2332b1cf4aa17125fc33c69de125f8dd687f",
};
const MAC_ARM_AUDIO: OnlineArchive = OnlineArchive {
url: "https://github.com/ankitects/anki-bundle-extras/releases/download/anki-2022-05-26/audio-mac-arm64.tar.gz",
sha256: "f6c4af9be59ae1c82a16f5c6307f13cbf31b49ad7b69ce1cb6e0e7b403cfdb8f",
};
const MAC_AMD_AUDIO: OnlineArchive = OnlineArchive {
url: "https://github.com/ankitects/anki-bundle-extras/releases/download/anki-2022-05-26/audio-mac-amd64.tar.gz",
sha256: "ecbb3c878805cdd58b1a0b8e3fd8c753b8ce3ad36c8b5904a79111f9db29ff42",
};
const MAC_ARM_QT6: OnlineArchive = OnlineArchive {
url: "https://github.com/ankitects/anki-bundle-extras/releases/download/anki-2024-02-29/pyqt6.6-mac-arm64.tar.zst",
sha256: "9b2ade4ae9b80506689062845e83e8c60f7fa9843545bf7bb2d11d3e2f105878",
};
const MAC_AMD_QT6: OnlineArchive = OnlineArchive {
url: "https://github.com/ankitects/anki-bundle-extras/releases/download/anki-2024-02-29/pyqt6.6-mac-amd64.tar.zst",
sha256: "dbd0871e4da22820d1fa9ab29220d631467d1178038dcab4b15169ad7f499b1b",
};
const MAC_AMD_QT5: OnlineArchive = OnlineArchive {
url: "https://github.com/ankitects/anki-bundle-extras/releases/download/anki-2022-02-09/pyqt5.14-mac-amd64.tar.gz",
sha256: "474951bed79ddb9570ee4c5a6079041772551ea77e77171d9e33d6f5e7877ec1",
};
const LINUX_QT_PLUGINS: OnlineArchive = OnlineArchive {
url: "https://github.com/ankitects/anki-bundle-extras/releases/download/anki-2023-05-02/qt-plugins-linux-amd64.tar.gz",
sha256: "66bb568aca7242bc55ad419bf5c96755ca15d2a743e1c3a09cba8b83230b138b",
};
const NSIS_PLUGINS: OnlineArchive = OnlineArchive {
url: "https://github.com/ankitects/anki-bundle-extras/releases/download/anki-2023-05-19/nsis.tar.zst",
sha256: "6133f730ece699de19714d0479c73bc848647d277e9cc80dda9b9ebe532b40a8",
};
fn download_dist_folder_deps(build: &mut Build) -> Result<()> {
let mut bundle_deps = vec![":wheels"];
if cfg!(windows) {
download_and_extract(build, "win_amd64_audio", WIN_AUDIO, empty_manifest())?;
download_and_extract(build, "nsis_plugins", NSIS_PLUGINS, empty_manifest())?;
bundle_deps.extend([":extract:win_amd64_audio", ":extract:nsis_plugins"]);
} else if cfg!(target_os = "macos") {
if targetting_macos_arm() {
download_and_extract(build, "mac_arm_audio", MAC_ARM_AUDIO, empty_manifest())?;
download_and_extract(build, "mac_arm_qt6", MAC_ARM_QT6, empty_manifest())?;
bundle_deps.extend([":extract:mac_arm_audio", ":extract:mac_arm_qt6"]);
} else {
download_and_extract(build, "mac_amd_audio", MAC_AMD_AUDIO, empty_manifest())?;
download_and_extract(build, "mac_amd_qt6", MAC_AMD_QT6, empty_manifest())?;
download_and_extract(build, "mac_amd_qt5", MAC_AMD_QT5, empty_manifest())?;
bundle_deps.extend([
":extract:mac_amd_audio",
":extract:mac_amd_qt6",
":extract:mac_amd_qt5",
]);
}
} else {
download_and_extract(
build,
"linux_qt_plugins",
LINUX_QT_PLUGINS,
empty_manifest(),
)?;
bundle_deps.extend([":extract:linux_qt_plugins"]);
}
build.add_dependency(
"bundle:deps",
inputs![bundle_deps
.iter()
.map(ToString::to_string)
.collect::<Vec<_>>()],
);
Ok(())
}
struct Venv {
label: &'static str,
path_without_builddir: &'static str,
}
impl Venv {
fn label_as_target(&self, suffix: &str) -> String {
format!(":{}{suffix}", self.label)
}
}
const PRIMARY_VENV: Venv = Venv {
label: "bundle:pyenv",
path_without_builddir: "bundle/pyenv",
};
/// Only used for copying Qt libs on Windows/Linux.
const QT5_VENV: Venv = Venv {
label: "bundle:pyenv-qt5",
path_without_builddir: "bundle/pyenv-qt5",
};
fn setup_primary_venv(build: &mut Build) -> Result<()> {
let mut qt6_reqs = inputs![
"python/requirements.bundle.txt",
if cfg!(windows) {
"python/requirements.qt6_win.txt"
} else if cfg!(target_os = "macos") {
"python/requirements.qt6_mac.txt"
} else {
"python/requirements.qt6_lin.txt"
}
];
if cfg!(windows) {
qt6_reqs = inputs![qt6_reqs, "python/requirements.win.txt"];
}
build.add_action(
PRIMARY_VENV.label,
PythonEnvironment {
folder: PRIMARY_VENV.path_without_builddir,
base_requirements_txt: "python/requirements.base.txt".into(),
requirements_txt: qt6_reqs,
extra_binary_exports: &[],
},
)?;
Ok(())
}
fn setup_qt5_venv(build: &mut Build) -> Result<()> {
let qt5_reqs = inputs![
"python/requirements.base.txt",
if cfg!(target_os = "macos") {
"python/requirements.qt5_14.txt"
} else {
"python/requirements.qt5_15.txt"
}
];
build.add_action(
QT5_VENV.label,
PythonEnvironment {
folder: QT5_VENV.path_without_builddir,
base_requirements_txt: "python/requirements.base.txt".into(),
requirements_txt: qt5_reqs,
extra_binary_exports: &[],
},
)
}
struct InstallAnkiWheels {
venv: Venv,
}
impl BuildAction for InstallAnkiWheels {
fn command(&self) -> &str {
"$pip install --force-reinstall --no-deps $in"
}
fn files(&mut self, build: &mut impl ninja_gen::build::FilesHandle) {
build.add_inputs("pip", inputs![self.venv.label_as_target(":pip")]);
build.add_inputs("in", inputs![":wheels"]);
build.add_output_stamp("bundle/wheels.stamp");
}
}
fn install_anki_wheels(build: &mut Build) -> Result<()> {
build.add_action(
"bundle:add_wheels:qt6",
InstallAnkiWheels { venv: PRIMARY_VENV },
)?;
Ok(())
}
fn build_pyoxidizer(build: &mut Build) -> Result<()> {
let offline_build = env::var("OFFLINE_BUILD").is_ok();
build.add_action(
"bundle:pyoxidizer:repo",
SyncSubmodule {
path: "qt/bundle/PyOxidizer",
offline_build,
},
)?;
build.add_action(
"bundle:pyoxidizer:bin",
CargoBuild {
inputs: inputs![":bundle:pyoxidizer:repo", glob!["qt/bundle/PyOxidizer/**"]],
// can't use ::Binary() here, as we're in a separate workspace
outputs: &[RustOutput::Data(
"bin",
&with_exe("bundle/rust/release/pyoxidizer"),
)],
target: None,
extra_args: &format!(
"--manifest-path={} --target-dir={} -p pyoxidizer",
"qt/bundle/PyOxidizer/Cargo.toml", "$builddir/bundle/rust"
),
release_override: Some(BuildProfile::Release),
},
)?;
Ok(())
}
struct BuildArtifacts {}
impl BuildAction for BuildArtifacts {
fn command(&self) -> &str {
"$runner build-artifacts $bundle_root $pyoxidizer_bin"
}
fn files(&mut self, build: &mut impl ninja_gen::build::FilesHandle) {
build.add_inputs("pyoxidizer_bin", inputs![":bundle:pyoxidizer:bin"]);
build.add_inputs("", inputs![PRIMARY_VENV.label_as_target("")]);
build.add_inputs("", inputs![":bundle:add_wheels:qt6", glob!["qt/bundle/**"]]);
build.add_variable("bundle_root", "$builddir/bundle");
build.add_outputs_ext(
"pyo3_config",
vec!["bundle/artifacts/pyo3-build-config-file.txt"],
true,
);
}
fn check_output_timestamps(&self) -> bool {
true
}
}
fn build_artifacts(build: &mut Build) -> Result<()> {
build.add_action("bundle:artifacts", BuildArtifacts {})
}
struct BuildBundle {}
impl BuildAction for BuildBundle {
fn command(&self) -> &str {
"$runner build-bundle-binary"
}
fn files(&mut self, build: &mut impl ninja_gen::build::FilesHandle) {
build.add_inputs("", inputs![":bundle:artifacts", glob!["qt/bundle/**"]]);
build.add_outputs(
"",
vec![RustOutput::Binary("anki").path(
Utf8Path::new("$builddir/bundle/rust"),
Some(
overriden_rust_target_triple()
.unwrap_or_else(|| Platform::current().as_rust_triple()),
),
// our pyoxidizer bin uses lto on the release profile
BuildProfile::Release,
)],
);
}
}
fn build_binary(build: &mut Build) -> Result<()> {
build.add_action("bundle:binary", BuildBundle {})
}
struct BuildDistFolder {
kind: DistKind,
deps: BuildInput,
}
impl BuildAction for BuildDistFolder {
fn command(&self) -> &str {
"$runner build-dist-folder $kind $out_folder "
}
fn files(&mut self, build: &mut impl ninja_gen::build::FilesHandle) {
build.add_inputs("", &self.deps);
build.add_variable("kind", self.kind.name());
let folder = match self.kind {
DistKind::Standard => "bundle/std",
DistKind::Alternate => "bundle/alt",
};
build.add_outputs("out_folder", vec![folder]);
build.add_outputs("stamp", vec![format!("{folder}.stamp")]);
}
fn check_output_timestamps(&self) -> bool {
true
}
}
fn build_dist_folder(build: &mut Build, kind: DistKind) -> Result<()> {
let mut deps = inputs![":bundle:deps", ":bundle:binary", glob!["qt/bundle/**"]];
if kind == DistKind::Alternate && !cfg!(target_os = "macos") {
deps = inputs![deps, QT5_VENV.label_as_target("")];
}
let group = match kind {
DistKind::Standard => "bundle:folder:std",
DistKind::Alternate => "bundle:folder:alt",
};
build.add_action(group, BuildDistFolder { kind, deps })
}
fn build_packages(build: &mut Build) -> Result<()> {
if cfg!(windows) {
build_windows_installers(build)
} else if cfg!(target_os = "macos") {
build_mac_app(build, DistKind::Standard)?;
if !targetting_macos_arm() {
build_mac_app(build, DistKind::Alternate)?;
}
build_dmgs(build)
} else {
build_tarball(build, DistKind::Standard)?;
build_tarball(build, DistKind::Alternate)
}
}
struct BuildTarball {
kind: DistKind,
}
impl BuildAction for BuildTarball {
fn command(&self) -> &str {
"chmod -R a+r $folder && tar -I '$zstd' --transform $transform -cf $tarball -C $folder ."
}
fn files(&mut self, build: &mut impl ninja_gen::build::FilesHandle) {
let input_folder_name = self.kind.folder_name();
let input_folder_target = format!(":bundle:folder:{input_folder_name}");
let input_folder_path = format!("$builddir/bundle/{input_folder_name}");
let version = anki_version();
let qt = match self.kind {
DistKind::Standard => "qt6",
DistKind::Alternate => "qt5",
};
let output_folder_base = format!("anki-{version}-linux-{qt}");
let output_tarball = format!("bundle/package/{output_folder_base}.tar.zst");
build.add_inputs("", inputs![input_folder_target]);
build.add_variable("zstd", "zstd -c --long -T0 -18");
build.add_variable("transform", format!("s%^.%{output_folder_base}%S"));
build.add_variable("folder", input_folder_path);
build.add_outputs("tarball", vec![output_tarball]);
}
}
fn build_tarball(build: &mut Build, kind: DistKind) -> Result<()> {
let name = kind.folder_name();
build.add_action(format!("bundle:package:{name}"), BuildTarball { kind })
}
struct BuildWindowsInstallers {}
impl BuildAction for BuildWindowsInstallers {
fn command(&self) -> &str {
"cargo run -p makeexe --target-dir=out/rust -- $version $src_root $bundle_root $out"
}
fn files(&mut self, build: &mut impl ninja_gen::build::FilesHandle) {
let version = anki_version();
let outputs = ["qt6", "qt5"].iter().map(|qt| {
let output_base = format!("anki-{version}-windows-{qt}");
format!("bundle/package/{output_base}.exe")
});
build.add_inputs("", inputs![":bundle:folder:std", ":bundle:folder:alt"]);
build.add_variable("version", &version);
build.add_variable("bundle_root", "$builddir/bundle");
build.add_outputs("out", outputs);
}
}
fn build_windows_installers(build: &mut Build) -> Result<()> {
build.add_action("bundle:package", BuildWindowsInstallers {})
}
struct BuildMacApp {
kind: DistKind,
}
impl BuildAction for BuildMacApp {
fn command(&self) -> &str {
"cargo run -p makeapp --target-dir=out/rust -- build-app $version $kind $stamp"
}
fn files(&mut self, build: &mut impl ninja_gen::build::FilesHandle) {
let folder_name = self.kind.folder_name();
build.add_inputs("", inputs![format!(":bundle:folder:{folder_name}")]);
build.add_variable("version", anki_version());
build.add_variable("kind", self.kind.name());
build.add_outputs("stamp", vec![format!("bundle/app/{folder_name}.stamp")]);
}
}
fn build_mac_app(build: &mut Build, kind: DistKind) -> Result<()> {
build.add_action(format!("bundle:app:{}", kind.name()), BuildMacApp { kind })
}
struct BuildDmgs {}
impl BuildAction for BuildDmgs {
fn command(&self) -> &str {
"cargo run -p makeapp --target-dir=out/rust -- build-dmgs $dmgs"
}
fn files(&mut self, build: &mut impl ninja_gen::build::FilesHandle) {
let version = anki_version();
let platform = if targetting_macos_arm() {
"apple"
} else {
"intel"
};
let qt = if targetting_macos_arm() {
&["qt6"][..]
} else {
&["qt6", "qt5"]
};
let dmgs = qt
.iter()
.map(|qt| format!("bundle/dmg/anki-{version}-mac-{platform}-{qt}.dmg"));
build.add_inputs("", inputs![":bundle:app"]);
build.add_outputs("dmgs", dmgs);
}
}
fn build_dmgs(build: &mut Build) -> Result<()> {
build.add_action("bundle:dmg", BuildDmgs {})
}

View file

@ -0,0 +1,44 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use anyhow::Result;
use ninja_gen::archives::download_and_extract;
use ninja_gen::archives::empty_manifest;
use ninja_gen::archives::OnlineArchive;
use ninja_gen::command::RunCommand;
use ninja_gen::hashmap;
use ninja_gen::inputs;
use ninja_gen::Build;
pub fn setup_uv_universal(build: &mut Build) -> Result<()> {
if !cfg!(target_arch = "aarch64") {
return Ok(());
}
build.add_action(
"launcher:uv_universal",
RunCommand {
command: "/usr/bin/lipo",
args: "-create -output $out $arm_bin $x86_bin",
inputs: hashmap! {
"arm_bin" => inputs![":extract:uv:bin"],
"x86_bin" => inputs![":extract:uv_mac_x86:bin"],
},
outputs: hashmap! {
"out" => vec!["launcher/uv"],
},
},
)
}
pub fn build_launcher(build: &mut Build) -> Result<()> {
setup_uv_universal(build)?;
download_and_extract(build, "nsis_plugins", NSIS_PLUGINS, empty_manifest())?;
Ok(())
}
const NSIS_PLUGINS: OnlineArchive = OnlineArchive {
url: "https://github.com/ankitects/anki-bundle-extras/releases/download/anki-2023-05-19/nsis.tar.zst",
sha256: "6133f730ece699de19714d0479c73bc848647d277e9cc80dda9b9ebe532b40a8",
};

View file

@ -2,7 +2,7 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
mod aqt;
mod bundle;
mod launcher;
mod platform;
mod pylib;
mod python;
@ -13,13 +13,14 @@ use std::env;
use anyhow::Result;
use aqt::build_and_check_aqt;
use bundle::build_bundle;
use launcher::build_launcher;
use ninja_gen::glob;
use ninja_gen::inputs;
use ninja_gen::protobuf::check_proto;
use ninja_gen::protobuf::setup_protoc;
use ninja_gen::python::setup_python;
use ninja_gen::python::setup_uv;
use ninja_gen::Build;
use platform::overriden_python_venv_platform;
use pylib::build_pylib;
use pylib::check_pylib;
use python::check_python;
@ -47,7 +48,10 @@ fn main() -> Result<()> {
check_proto(build, inputs![glob!["proto/**/*.proto"]])?;
if env::var("OFFLINE_BUILD").is_err() {
setup_python(build)?;
setup_uv(
build,
overriden_python_venv_platform().unwrap_or(build.host_platform),
)?;
}
setup_venv(build)?;
@ -57,7 +61,7 @@ fn main() -> Result<()> {
build_and_check_aqt(build)?;
if env::var("OFFLINE_BUILD").is_err() {
build_bundle(build)?;
build_launcher(build)?;
}
setup_sphinx(build)?;

View file

@ -5,18 +5,30 @@ use std::env;
use ninja_gen::archives::Platform;
/// Usually None to use the host architecture; can be overriden by setting
/// MAC_X86 to build for x86_64 on Apple Silicon
/// Please see [`overriden_python_target_platform()`] for details.
pub fn overriden_rust_target_triple() -> Option<&'static str> {
overriden_python_target_platform().map(|p| p.as_rust_triple())
overriden_python_wheel_platform().map(|p| p.as_rust_triple())
}
/// Usually None to use the host architecture; can be overriden by setting
/// MAC_X86 to build for x86_64 on Apple Silicon
pub fn overriden_python_target_platform() -> Option<Platform> {
if env::var("MAC_X86").is_ok() {
Some(Platform::MacX64)
/// Usually None to use the host architecture, except on Windows which
/// always uses x86_64, since WebEngine is unavailable for ARM64.
pub fn overriden_python_venv_platform() -> Option<Platform> {
if cfg!(target_os = "windows") {
Some(Platform::WindowsX64)
} else {
None
}
}
/// Like [`overriden_python_venv_platform`], but:
/// If MAC_X86 is set, an X86 wheel will be built on macOS ARM.
/// If LIN_ARM64 is set, an ARM64 wheel will be built on Linux AMD64.
pub fn overriden_python_wheel_platform() -> Option<Platform> {
if env::var("MAC_X86").is_ok() {
Some(Platform::MacX64)
} else if env::var("LIN_ARM64").is_ok() {
Some(Platform::LinuxArm)
} else {
overriden_python_venv_platform()
}
}

View file

@ -14,7 +14,7 @@ use ninja_gen::python::PythonTest;
use ninja_gen::Build;
use crate::anki_version;
use crate::platform::overriden_python_target_platform;
use crate::platform::overriden_python_wheel_platform;
use crate::python::BuildWheel;
use crate::python::GenPythonProto;
@ -50,7 +50,7 @@ pub fn build_pylib(build: &mut Build) -> Result<()> {
output: &format!(
"pylib/anki/_rsbridge.{}",
match build.host_platform {
Platform::WindowsX64 => "pyd",
Platform::WindowsX64 | Platform::WindowsArm => "pyd",
_ => "so",
}
),
@ -64,13 +64,12 @@ pub fn build_pylib(build: &mut Build) -> Result<()> {
BuildWheel {
name: "anki",
version: anki_version(),
src_folder: "pylib/anki",
gen_folder: "$builddir/pylib/anki",
platform: overriden_python_target_platform().or(Some(build.host_platform)),
platform: overriden_python_wheel_platform().or(Some(build.host_platform)),
deps: inputs![
":pylib:anki",
glob!("pylib/anki/**"),
"python/requirements.anki.in",
"pylib/pyproject.toml",
"pylib/hatch_build.py"
],
},
)?;

View file

@ -1,82 +1,73 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::env;
use anyhow::Result;
use ninja_gen::action::BuildAction;
use ninja_gen::archives::Platform;
use ninja_gen::build::FilesHandle;
use ninja_gen::command::RunCommand;
use ninja_gen::copy::CopyFiles;
use ninja_gen::glob;
use ninja_gen::hashmap;
use ninja_gen::input::BuildInput;
use ninja_gen::inputs;
use ninja_gen::python::python_format;
use ninja_gen::python::PythonEnvironment;
use ninja_gen::python::PythonLint;
use ninja_gen::python::PythonTypecheck;
use ninja_gen::rsync::RsyncFiles;
use ninja_gen::python::RuffCheck;
use ninja_gen::Build;
/// Normalize version string by removing leading zeros from numeric parts
/// while preserving pre-release markers (b1, rc2, a3, etc.)
fn normalize_version(version: &str) -> String {
version
.split('.')
.map(|part| {
// Check if the part contains only digits
if part.chars().all(|c| c.is_ascii_digit()) {
// Numeric part: remove leading zeros
part.parse::<u32>().unwrap_or(0).to_string()
} else {
// Mixed part (contains both numbers and pre-release markers)
// Split on first non-digit character and normalize the numeric prefix
let chars = part.chars();
let mut numeric_prefix = String::new();
let mut rest = String::new();
let mut found_non_digit = false;
for ch in chars {
if ch.is_ascii_digit() && !found_non_digit {
numeric_prefix.push(ch);
} else {
found_non_digit = true;
rest.push(ch);
}
}
if numeric_prefix.is_empty() {
part.to_string()
} else {
let normalized_prefix = numeric_prefix.parse::<u32>().unwrap_or(0).to_string();
format!("{normalized_prefix}{rest}")
}
}
})
.collect::<Vec<_>>()
.join(".")
}
pub fn setup_venv(build: &mut Build) -> Result<()> {
let platform_deps = if cfg!(windows) {
inputs![
"python/requirements.qt6_win.txt",
"python/requirements.win.txt",
]
} else if cfg!(target_os = "macos") {
inputs!["python/requirements.qt6_mac.txt",]
} else if cfg!(all(target_os = "linux", target_arch = "aarch64")) {
// system-provided Qt on ARM64
inputs![]
} else {
// normal linux
inputs!["python/requirements.qt6_lin.txt"]
};
let requirements_txt = inputs!["python/requirements.dev.txt", platform_deps];
let extra_binary_exports = &["mypy", "ruff", "pytest", "protoc-gen-mypy"];
build.add_action(
"pyenv",
PythonEnvironment {
folder: "pyenv",
base_requirements_txt: inputs!["python/requirements.base.txt"],
requirements_txt,
extra_binary_exports: &[
"pip-compile",
"pip-sync",
"mypy",
"black", // Required for offline build
"isort",
"pylint",
"pytest",
"protoc-gen-mypy", // ditto
venv_folder: "pyenv",
deps: inputs![
"pyproject.toml",
"pylib/pyproject.toml",
"qt/pyproject.toml",
"uv.lock"
],
},
)?;
// optional venvs for testing with Qt5
let mut reqs_qt5 = inputs!["python/requirements.bundle.txt"];
if cfg!(windows) {
reqs_qt5 = inputs![reqs_qt5, "python/requirements.win.txt"];
}
build.add_action(
"pyenv-qt5.15",
PythonEnvironment {
folder: "pyenv-qt5.15",
base_requirements_txt: inputs!["python/requirements.base.txt"],
requirements_txt: inputs![&reqs_qt5, "python/requirements.qt5_15.txt"],
extra_binary_exports: &[],
},
)?;
build.add_action(
"pyenv-qt5.14",
PythonEnvironment {
folder: "pyenv-qt5.14",
base_requirements_txt: inputs!["python/requirements.base.txt"],
requirements_txt: inputs![reqs_qt5, "python/requirements.qt5_14.txt"],
extra_binary_exports: &[],
extra_args: "--all-packages --extra qt --extra audio",
extra_binary_exports,
},
)?;
@ -114,7 +105,7 @@ impl BuildAction for GenPythonProto {
build.add_outputs("", python_outputs);
}
fn hide_last_line(&self) -> bool {
fn hide_progress(&self) -> bool {
true
}
}
@ -122,45 +113,66 @@ impl BuildAction for GenPythonProto {
pub struct BuildWheel {
pub name: &'static str,
pub version: String,
pub src_folder: &'static str,
pub gen_folder: &'static str,
pub platform: Option<Platform>,
pub deps: BuildInput,
}
impl BuildAction for BuildWheel {
fn command(&self) -> &str {
"$pyenv_bin $script $src $gen $out"
"$uv build --wheel --out-dir=$out_dir --project=$project_dir"
}
fn files(&mut self, build: &mut impl FilesHandle) {
build.add_inputs("pyenv_bin", inputs![":pyenv:bin"]);
build.add_inputs("script", inputs!["python/write_wheel.py"]);
build.add_inputs("", &self.deps);
build.add_variable("src", self.src_folder);
build.add_variable("gen", self.gen_folder);
if std::env::var("OFFLINE_BUILD").ok().as_deref() == Some("1") {
let uv_path =
std::env::var("UV_BINARY").expect("UV_BINARY must be set in OFFLINE_BUILD mode");
build.add_inputs("uv", inputs![uv_path]);
} else {
build.add_inputs("uv", inputs![":uv_binary"]);
}
build.add_inputs("", &self.deps);
// Set the project directory based on which package we're building
let project_dir = if self.name == "anki" { "pylib" } else { "qt" };
build.add_variable("project_dir", project_dir);
// Set environment variable for uv to use our pyenv
build.add_variable("pyenv_path", "$builddir/pyenv");
build.add_env_var("UV_PROJECT_ENVIRONMENT", "$pyenv_path");
// Set output directory
build.add_variable("out_dir", "$builddir/wheels/");
// Calculate the wheel filename that uv will generate
let tag = if let Some(platform) = self.platform {
let platform = match platform {
Platform::LinuxX64 => "manylinux_2_28_x86_64",
Platform::LinuxArm => "manylinux_2_31_aarch64",
Platform::MacX64 => "macosx_10_13_x86_64",
Platform::MacArm => "macosx_11_0_arm64",
let platform_tag = match platform {
Platform::LinuxX64 => "manylinux_2_36_x86_64",
Platform::LinuxArm => "manylinux_2_36_aarch64",
Platform::MacX64 => "macosx_12_0_x86_64",
Platform::MacArm => "macosx_12_0_arm64",
Platform::WindowsX64 => "win_amd64",
Platform::WindowsArm => "win_arm64",
};
format!("cp39-abi3-{platform}")
format!("cp39-abi3-{platform_tag}")
} else {
"py3-none-any".into()
};
// Set environment variable for hatch_build.py to use the correct platform tag
build.add_variable("wheel_tag", &tag);
build.add_env_var("ANKI_WHEEL_TAG", "$wheel_tag");
let name = self.name;
let version = &self.version;
let wheel_path = format!("wheels/{name}-{version}-{tag}.whl");
let normalized_version = normalize_version(&self.version);
let wheel_path = format!("wheels/{name}-{normalized_version}-{tag}.whl");
build.add_outputs("out", vec![wheel_path]);
}
}
pub fn check_python(build: &mut Build) -> Result<()> {
python_format(build, "ftl", inputs![glob!("ftl/**/*.py")])?;
python_format(build, "tools", inputs![glob!("tools/**/*.py")])?;
build.add_action(
@ -172,7 +184,6 @@ pub fn check_python(build: &mut Build) -> Result<()> {
"qt/tools",
"out/pylib/anki",
"out/qt/_aqt",
"ftl",
"python",
"tools",
],
@ -184,60 +195,26 @@ pub fn check_python(build: &mut Build) -> Result<()> {
},
)?;
add_pylint(build)?;
Ok(())
}
fn add_pylint(build: &mut Build) -> Result<()> {
// pylint does not support PEP420 implicit namespaces split across import paths,
// so we need to merge our pylib sources and generated files before invoking it,
// and add a top-level __init__.py
let ruff_folders = &["qt/aqt", "ftl", "pylib/tools", "tools", "python"];
let ruff_deps = inputs![
glob!["{pylib,ftl,qt,python,tools}/**/*.py"],
":pylib:anki",
":qt:aqt"
];
build.add_action(
"check:pylint:copy_pylib",
RsyncFiles {
inputs: inputs![":pylib:anki"],
target_folder: "pylint/anki",
strip_prefix: "$builddir/pylib/anki",
// avoid copying our large rsbridge binary
extra_args: "--links",
"check:ruff",
RuffCheck {
folders: ruff_folders,
deps: ruff_deps.clone(),
check_only: true,
},
)?;
build.add_action(
"check:pylint:copy_pylib",
RsyncFiles {
inputs: inputs![glob!["pylib/anki/**"]],
target_folder: "pylint/anki",
strip_prefix: "pylib/anki",
extra_args: "",
},
)?;
build.add_action(
"check:pylint:copy_pylib",
RunCommand {
command: ":pyenv:bin",
args: "$script $out",
inputs: hashmap! { "script" => inputs!["python/mkempty.py"] },
outputs: hashmap! { "out" => vec!["pylint/anki/__init__.py"] },
},
)?;
build.add_action(
"check:pylint",
PythonLint {
folders: &[
"$builddir/pylint/anki",
"qt/aqt",
"ftl",
"pylib/tools",
"tools",
"python",
],
pylint_ini: inputs![".pylintrc"],
deps: inputs![
":check:pylint:copy_pylib",
":qt:aqt",
glob!("{pylib/tools,ftl,qt,python,tools}/**/*.py")
],
"fix:ruff",
RuffCheck {
folders: ruff_folders,
deps: ruff_deps,
check_only: false,
},
)?;
@ -250,17 +227,23 @@ struct Sphinx {
impl BuildAction for Sphinx {
fn command(&self) -> &str {
if env::var("OFFLINE_BUILD").is_err() {
"$pip install sphinx sphinx_rtd_theme sphinx-autoapi \
&& $python python/sphinx/build.py"
} else {
if std::env::var("OFFLINE_BUILD").ok().as_deref() == Some("1") {
"$python python/sphinx/build.py"
} else {
"$uv sync --extra sphinx && $python python/sphinx/build.py"
}
}
fn files(&mut self, build: &mut impl FilesHandle) {
if env::var("OFFLINE_BUILD").is_err() {
build.add_inputs("pip", inputs![":pyenv:pip"]);
if std::env::var("OFFLINE_BUILD").ok().as_deref() == Some("1") {
let uv_path =
std::env::var("UV_BINARY").expect("UV_BINARY must be set in OFFLINE_BUILD mode");
build.add_inputs("uv", inputs![uv_path]);
} else {
build.add_inputs("uv", inputs![":uv_binary"]);
// Set environment variable to use the existing pyenv
build.add_variable("pyenv_path", "$builddir/pyenv");
build.add_env_var("UV_PROJECT_ENVIRONMENT", "$pyenv_path");
}
build.add_inputs("python", inputs![":pyenv:bin"]);
build.add_inputs("", &self.deps);
@ -283,8 +266,35 @@ pub(crate) fn setup_sphinx(build: &mut Build) -> Result<()> {
build.add_action(
"python:sphinx",
Sphinx {
deps: inputs![":pylib", ":qt", ":python:sphinx:copy_conf"],
deps: inputs![
":pylib",
":qt",
":python:sphinx:copy_conf",
"pyproject.toml"
],
},
)?;
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_normalize_version_basic() {
assert_eq!(normalize_version("1.2.3"), "1.2.3");
assert_eq!(normalize_version("01.02.03"), "1.2.3");
assert_eq!(normalize_version("1.0.0"), "1.0.0");
}
#[test]
fn test_normalize_version_with_prerelease() {
assert_eq!(normalize_version("1.2.3b1"), "1.2.3b1");
assert_eq!(normalize_version("01.02.03b1"), "1.2.3b1");
assert_eq!(normalize_version("1.0.0rc2"), "1.0.0rc2");
assert_eq!(normalize_version("2.1.0a3"), "2.1.0a3");
assert_eq!(normalize_version("1.2.3beta1"), "1.2.3beta1");
assert_eq!(normalize_version("1.2.3alpha1"), "1.2.3alpha1");
}
}

View file

@ -56,8 +56,7 @@ fn prepare_translations(build: &mut Build) -> Result<()> {
],
outputs: &[
RustOutput::Data("py", "pylib/anki/_fluent.py"),
RustOutput::Data("ts", "ts/lib/ftl.d.ts"),
RustOutput::Data("ts", "ts/lib/ftl.js"),
RustOutput::Data("ts", "ts/lib/generated/ftl.ts"),
],
target: None,
extra_args: "-p anki_i18n",
@ -119,8 +118,7 @@ fn build_proto_descriptors_and_interfaces(build: &mut Build) -> Result<()> {
let outputs = vec![
RustOutput::Data("descriptors.bin", "rslib/proto/descriptors.bin"),
RustOutput::Data("py", "pylib/anki/_backend_generated.py"),
RustOutput::Data("ts", "ts/lib/backend.d.ts"),
RustOutput::Data("ts", "ts/lib/backend.js"),
RustOutput::Data("ts", "ts/lib/generated/backend.ts"),
];
build.add_action(
"rslib:proto",
@ -156,7 +154,7 @@ fn build_rsbridge(build: &mut Build) -> Result<()> {
"$builddir/buildhash",
// building on Windows requires python3.lib
if cfg!(windows) {
inputs![":extract:python"]
inputs![":pyenv:bin"]
} else {
inputs![]
}
@ -171,7 +169,7 @@ fn build_rsbridge(build: &mut Build) -> Result<()> {
pub fn check_rust(build: &mut Build) -> Result<()> {
let inputs = inputs![
glob!("{rslib/**,pylib/rsbridge/**,ftl/**,build/**,tools/workspace-hack/**}"),
glob!("{rslib/**,pylib/rsbridge/**,ftl/**,build/**,qt/launcher/**,tools/minilints/**}"),
"Cargo.lock",
"Cargo.toml",
"rust-toolchain.toml",
@ -248,8 +246,8 @@ pub fn check_minilints(build: &mut Build) -> Result<()> {
let files = inputs![
glob![
"**/*.{py,rs,ts,svelte,mjs}",
"{node_modules,qt/bundle/PyOxidizer}/**"
"**/*.{py,rs,ts,svelte,mjs,md}",
"{node_modules,ts/.svelte-kit}/**"
],
"Cargo.lock"
];

View file

@ -3,21 +3,22 @@
use anyhow::Result;
use ninja_gen::action::BuildAction;
use ninja_gen::copy::CopyFiles;
use ninja_gen::glob;
use ninja_gen::hashmap;
use ninja_gen::input::BuildInput;
use ninja_gen::inputs;
use ninja_gen::node::node_archive;
use ninja_gen::node::CompileSass;
use ninja_gen::node::CompileTypescript;
use ninja_gen::node::DPrint;
use ninja_gen::node::EsbuildScript;
use ninja_gen::node::Eslint;
use ninja_gen::node::GenTypescriptProto;
use ninja_gen::node::JestTest;
use ninja_gen::node::Prettier;
use ninja_gen::node::SqlFormat;
use ninja_gen::node::SvelteCheck;
use ninja_gen::node::TypescriptCheck;
use ninja_gen::node::SveltekitBuild;
use ninja_gen::node::ViteTest;
use ninja_gen::rsync::RsyncFiles;
use ninja_gen::Build;
@ -25,6 +26,7 @@ pub fn build_and_check_web(build: &mut Build) -> Result<()> {
setup_node(build)?;
build_sass(build)?;
build_and_check_tslib(build)?;
build_sveltekit(build)?;
declare_and_check_other_libraries(build)?;
build_and_check_pages(build)?;
build_and_check_editor(build)?;
@ -35,6 +37,20 @@ pub fn build_and_check_web(build: &mut Build) -> Result<()> {
Ok(())
}
fn build_sveltekit(build: &mut Build) -> Result<()> {
build.add_action(
"sveltekit",
SveltekitBuild {
output_folder: inputs!["sveltekit"],
deps: inputs![
"ts/tsconfig.json",
glob!["ts/**", "ts/.svelte-kit/**"],
":ts:lib"
],
},
)
}
fn setup_node(build: &mut Build) -> Result<()> {
ninja_gen::node::setup_node(
build,
@ -46,8 +62,10 @@ fn setup_node(build: &mut Build) -> Result<()> {
"sass",
"tsc",
"tsx",
"jest",
"vite",
"vitest",
"protoc-gen-es",
"prettier",
],
hashmap! {
"jquery" => vec![
@ -111,55 +129,39 @@ fn setup_node(build: &mut Build) -> Result<()> {
}
fn build_and_check_tslib(build: &mut Build) -> Result<()> {
build.add_dependency("ts:lib:i18n", ":rslib:i18n:ts".into());
build.add_dependency("ts:generated:i18n", ":rslib:i18n:ts".into());
build.add_action(
"ts:lib:proto",
"ts:generated:proto",
GenTypescriptProto {
protos: inputs![glob!["proto/**/*.proto"]],
include_dirs: &["proto"],
out_dir: "out/ts/lib",
out_dir: "out/ts/lib/generated",
out_path_transform: |path| {
path.replace("proto/", "ts/lib/")
.replace("proto\\", "ts/lib\\")
path.replace("proto/", "ts/lib/generated/")
.replace("proto\\", "ts/lib/generated\\")
},
ts_transform_script: "ts/tools/markpure.ts",
},
)?;
// ensure _service files are generated by rslib
build.add_dependency("ts:lib:proto", inputs![":rslib:proto:ts"]);
// the generated _service.js files import @tslib/post, and esbuild won't be able
// to import the .ts file, so we need to generate a .js file for it
build.add_dependency("ts:generated:proto", inputs![":rslib:proto:ts"]);
// copy source files from ts/lib/generated
build.add_action(
"ts:lib:proto",
CompileTypescript {
ts_files: "ts/lib/post.ts".into(),
out_dir: "out/ts/lib",
out_path_transform: |path| path.into(),
"ts:generated:src",
CopyFiles {
inputs: inputs![glob!["ts/lib/generated/*.ts"]],
output_folder: "ts/lib/generated",
},
)?;
let src_files = inputs![glob!["ts/lib/**"]];
eslint(build, "lib", "ts/lib", inputs![":ts:lib", &src_files])?;
build.add_action(
"check:jest:lib",
jest_test("ts/lib", inputs![":ts:lib", &src_files], true),
)?;
build.add_dependency("ts:lib", inputs![":ts:generated"]);
build.add_dependency("ts:lib", src_files);
Ok(())
}
fn jest_test(folder: &str, deps: BuildInput, jsdom: bool) -> impl BuildAction + '_ {
JestTest {
folder,
deps,
jest_rc: "ts/jest.config.js".into(),
jsdom,
}
}
fn declare_and_check_other_libraries(build: &mut Build) -> Result<()> {
for (library, inputs) in [
("sveltelib", inputs![":ts:lib", glob!("ts/sveltelib/**")]),
@ -171,157 +173,36 @@ fn declare_and_check_other_libraries(build: &mut Build) -> Result<()> {
("html-filter", inputs![glob!("ts/html-filter/**")]),
] {
let library_with_ts = format!("ts:{library}");
let folder = library_with_ts.replace(':', "/");
build.add_dependency(&library_with_ts, inputs.clone());
eslint(build, library, &folder, inputs.clone())?;
if matches!(library, "domlib" | "html-filter") {
build.add_action(
&format!("check:jest:{library}"),
jest_test(&folder, inputs, true),
)?;
}
}
eslint(build, "scripts", "ts/tools", inputs![glob!("ts/tools/*")])?;
Ok(())
}
pub fn eslint(build: &mut Build, name: &str, folder: &str, deps: BuildInput) -> Result<()> {
let eslint_rc = inputs![".eslintrc.js"];
build.add_action(
format!("check:eslint:{name}"),
Eslint {
folder,
inputs: deps.clone(),
eslint_rc: eslint_rc.clone(),
fix: false,
},
)?;
build.add_action(
format!("fix:eslint:{name}"),
Eslint {
folder,
inputs: deps,
eslint_rc,
fix: true,
},
)?;
Ok(())
}
fn build_and_check_pages(build: &mut Build) -> Result<()> {
build.add_dependency("ts:tag-editor", inputs![glob!["ts/tag-editor/**"]]);
let mut build_page = |name: &str, html: bool, deps: BuildInput| -> Result<()> {
let group = format!("ts:{name}");
let deps = inputs![deps, glob!(format!("ts/{name}/**"))];
let extra_exts = if html { &["css", "html"][..] } else { &["css"] };
let entrypoint = if html {
format!("ts/routes/{name}/index.ts")
} else {
format!("ts/{name}/index.ts")
};
build.add_action(
&group,
EsbuildScript {
script: inputs!["ts/bundle_svelte.mjs"],
entrypoint: inputs![format!("ts/{name}/index.ts")],
entrypoint: inputs![entrypoint],
output_stem: &format!("ts/{name}/{name}"),
deps: deps.clone(),
extra_exts,
},
)?;
build.add_dependency("ts:pages", inputs![format!(":{group}")]);
build.add_action(
format!("check:svelte:{name}"),
SvelteCheck {
tsconfig: inputs![format!("ts/{name}/tsconfig.json")],
inputs: deps.clone(),
},
)?;
let folder = format!("ts/{name}");
eslint(build, name, &folder, deps.clone())?;
if matches!(name, "deck-options" | "change-notetype") {
build.add_action(
&format!("check:jest:{name}"),
jest_test(&folder, deps, false),
)?;
}
Ok(())
};
build_page(
"congrats",
true,
inputs![
//
":ts:lib",
":ts:components",
":sass",
],
)?;
build_page(
"deck-options",
true,
inputs![
//
":ts:lib",
":ts:components",
":ts:sveltelib",
":sass",
],
)?;
build_page(
"graphs",
true,
inputs![
//
":ts:lib",
":ts:components",
":sass",
],
)?;
build_page(
"card-info",
true,
inputs![
//
":ts:lib",
":ts:components",
":sass",
],
)?;
build_page(
"change-notetype",
true,
inputs![
//
":ts:lib",
":ts:components",
":ts:sveltelib",
":sass",
],
)?;
build_page(
"import-csv",
true,
inputs![
//
":ts:lib",
":ts:components",
":ts:sveltelib",
":ts:tag-editor",
":sass"
],
)?;
build_page(
"import-anki-package",
true,
inputs![
//
":ts:lib",
":ts:components",
":ts:sveltelib",
":sass"
],
)?;
// we use the generated .css file separately
build_page(
"editable",
@ -332,30 +213,19 @@ fn build_and_check_pages(build: &mut Build) -> Result<()> {
":ts:components",
":ts:domlib",
":ts:sveltelib",
":sass"
":sass",
":sveltekit",
],
)?;
build_page(
"image-occlusion",
"congrats",
true,
inputs![
//
":ts:lib",
":ts:components",
":ts:sveltelib",
":ts:tag-editor",
":sass"
],
)?;
build_page(
"import-page",
true,
inputs![
//
":ts:lib",
":ts:components",
":ts:sveltelib",
":sass"
":sass",
":sveltekit"
],
)?;
@ -369,11 +239,10 @@ fn build_and_check_editor(build: &mut Build) -> Result<()> {
":ts:components",
":ts:domlib",
":ts:sveltelib",
":ts:tag-editor",
":ts:html-filter",
":ts:image-occlusion",
":sass",
glob!("ts/{editable,editor}/**")
":sveltekit",
glob!("ts/{editable,editor,routes/image-occlusion}/**")
];
build.add_action(
@ -387,20 +256,15 @@ fn build_and_check_editor(build: &mut Build) -> Result<()> {
},
)?;
let group = "ts/editor";
build.add_action(
"check:svelte:editor",
SvelteCheck {
tsconfig: inputs![format!("{group}/tsconfig.json")],
inputs: editor_deps.clone(),
},
)?;
eslint(build, "editor", group, editor_deps)?;
Ok(())
}
fn build_and_check_reviewer(build: &mut Build) -> Result<()> {
let reviewer_deps = inputs![":ts:lib", glob!("ts/{reviewer,image-occlusion}/**"),];
let reviewer_deps = inputs![
":ts:lib",
glob!("ts/{reviewer,image-occlusion}/**"),
":sveltekit"
];
build.add_action(
"ts:reviewer:reviewer.js",
EsbuildScript {
@ -416,7 +280,7 @@ fn build_and_check_reviewer(build: &mut Build) -> Result<()> {
CompileSass {
input: inputs!["ts/reviewer/reviewer.scss"],
output: "ts/reviewer/reviewer.css",
deps: inputs![":sass", "ts/image-occlusion/review.scss"],
deps: inputs![":sass", "ts/routes/image-occlusion/review.scss"],
load_paths: vec!["."],
},
)?;
@ -435,31 +299,19 @@ fn build_and_check_reviewer(build: &mut Build) -> Result<()> {
CompileSass {
input: inputs!["ts/reviewer/reviewer_extras.scss"],
output: "ts/reviewer/reviewer_extras.css",
deps: inputs!["ts/image-occlusion/review.scss"],
deps: inputs!["ts/routes/image-occlusion/review.scss"],
load_paths: vec!["."],
},
)?;
build.add_action(
"check:typescript:reviewer",
TypescriptCheck {
tsconfig: inputs!["ts/reviewer/tsconfig.json"],
inputs: reviewer_deps.clone(),
},
)?;
eslint(build, "reviewer", "ts/reviewer", reviewer_deps)?;
build.add_action(
"check:jest:reviewer",
jest_test("ts/reviewer", inputs![":ts:reviewer"], false),
)?;
Ok(())
}
fn check_web(build: &mut Build) -> Result<()> {
let dprint_files = inputs![glob![
"**/*.{ts,mjs,js,md,json,toml,svelte,scss}",
"target/**"
]];
let fmt_excluded = "{target,ts/.svelte-kit,node_modules}/**";
let dprint_files = inputs![glob!["**/*.{ts,mjs,js,md,json,toml,scss}", fmt_excluded]];
let prettier_files = inputs![glob!["**/*.svelte", fmt_excluded]];
build.add_action(
"check:format:dprint",
DPrint {
@ -474,6 +326,64 @@ fn check_web(build: &mut Build) -> Result<()> {
check_only: false,
},
)?;
build.add_action(
"check:format:prettier",
Prettier {
inputs: prettier_files.clone(),
check_only: true,
},
)?;
build.add_action(
"format:prettier",
Prettier {
inputs: prettier_files,
check_only: false,
},
)?;
build.add_action(
"check:vitest",
ViteTest {
deps: inputs![
":node_modules",
":ts:generated",
glob!["ts/{svelte.config.js,vite.config.ts,tsconfig.json}"],
glob!["ts/{lib,deck-options,html-filter,domlib,reviewer,change-notetype}/**/*"],
],
},
)?;
build.add_action(
"check:svelte",
SvelteCheck {
tsconfig: inputs!["ts/tsconfig.json"],
inputs: inputs![
":node_modules",
":ts:generated",
glob!["ts/**/*", "ts/.svelte-kit/**"],
],
},
)?;
let eslint_rc = inputs![".eslintrc.cjs"];
for folder in ["ts", "qt/aqt/data/web/js"] {
let inputs = inputs![glob![format!("{folder}/**"), "ts/.svelte-kit/**"]];
build.add_action(
"check:eslint",
Eslint {
folder,
inputs: inputs.clone(),
eslint_rc: eslint_rc.clone(),
fix: false,
},
)?;
build.add_action(
"fix:eslint",
Eslint {
folder,
inputs,
eslint_rc: eslint_rc.clone(),
fix: true,
},
)?;
}
Ok(())
}
@ -497,7 +407,7 @@ pub fn check_sql(build: &mut Build) -> Result<()> {
}
fn build_and_check_mathjax(build: &mut Build) -> Result<()> {
let files = inputs![glob!["ts/mathjax/*"]];
let files = inputs![glob!["ts/mathjax/*"], ":sveltekit"];
build.add_action(
"ts:mathjax",
EsbuildScript {
@ -507,14 +417,6 @@ fn build_and_check_mathjax(build: &mut Build) -> Result<()> {
output_stem: "ts/mathjax/mathjax",
extra_exts: &[],
},
)?;
eslint(build, "mathjax", "ts/mathjax", files.clone())?;
build.add_action(
"check:typescript:mathjax",
TypescriptCheck {
tsconfig: "ts/mathjax/tsconfig.json".into(),
inputs: files,
},
)
}
@ -566,14 +468,14 @@ pub fn copy_mathjax() -> impl BuildAction {
}
fn build_sass(build: &mut Build) -> Result<()> {
build.add_dependency("sass", inputs![glob!("sass/**")]);
build.add_dependency("sass", inputs![glob!("ts/lib/sass/**")]);
build.add_action(
"css:_root-vars",
CompileSass {
input: inputs!["sass/_root-vars.scss"],
output: "sass/_root-vars.css",
deps: inputs![glob!["sass/*"]],
input: inputs!["ts/lib/sass/_root-vars.scss"],
output: "ts/lib/sass/_root-vars.css",
deps: inputs![glob!["ts/lib/sass/*"]],
load_paths: vec![],
},
)?;

View file

@ -14,8 +14,28 @@ camino.workspace = true
dunce.workspace = true
globset.workspace = true
itertools.workspace = true
lazy_static.workspace = true
maplit.workspace = true
num_cpus.workspace = true
regex.workspace = true
serde_json.workspace = true
sha2.workspace = true
walkdir.workspace = true
which.workspace = true
[target.'cfg(windows)'.dependencies]
reqwest = { workspace = true, features = ["blocking", "json", "native-tls"] }
[target.'cfg(not(windows))'.dependencies]
reqwest = { workspace = true, features = ["blocking", "json", "rustls-tls"] }
[[bin]]
name = "update_uv"
path = "src/bin/update_uv.rs"
[[bin]]
name = "update_protoc"
path = "src/bin/update_protoc.rs"
[[bin]]
name = "update_node"
path = "src/bin/update_node.rs"

View file

@ -44,11 +44,51 @@ pub trait BuildAction {
true
}
fn hide_last_line(&self) -> bool {
fn hide_progress(&self) -> bool {
false
}
fn name(&self) -> &'static str {
std::any::type_name::<Self>().split("::").last().unwrap()
std::any::type_name::<Self>()
.split("::")
.last()
.unwrap()
.split('<')
.next()
.unwrap()
}
}
#[cfg(test)]
trait TestBuildAction {}
#[cfg(test)]
impl<T: TestBuildAction + ?Sized> BuildAction for T {
fn command(&self) -> &str {
"test"
}
fn files(&mut self, _build: &mut impl FilesHandle) {}
}
#[allow(dead_code, unused_variables)]
#[test]
fn should_strip_regions_in_type_name() {
struct Bare;
impl TestBuildAction for Bare {}
assert_eq!(Bare {}.name(), "Bare");
struct WithLifeTime<'a>(&'a str);
impl TestBuildAction for WithLifeTime<'_> {}
assert_eq!(WithLifeTime("test").name(), "WithLifeTime");
struct WithMultiLifeTime<'a, 'b>(&'a str, &'b str);
impl TestBuildAction for WithMultiLifeTime<'_, '_> {}
assert_eq!(
WithMultiLifeTime("test", "test").name(),
"WithMultiLifeTime"
);
struct WithGeneric<T>(T);
impl<T> TestBuildAction for WithGeneric<T> {}
assert_eq!(WithGeneric(3).name(), "WithGeneric");
}

View file

@ -26,22 +26,21 @@ pub enum Platform {
MacX64,
MacArm,
WindowsX64,
WindowsArm,
}
impl Platform {
pub fn current() -> Self {
if cfg!(windows) {
Self::WindowsX64
} else {
let os = std::env::consts::OS;
let arch = std::env::consts::ARCH;
match (os, arch) {
("linux", "x86_64") => Self::LinuxX64,
("linux", "aarch64") => Self::LinuxArm,
("macos", "x86_64") => Self::MacX64,
("macos", "aarch64") => Self::MacArm,
_ => panic!("unsupported os/arch {os} {arch} - PR welcome!"),
}
let os = std::env::consts::OS;
let arch = std::env::consts::ARCH;
match (os, arch) {
("linux", "x86_64") => Self::LinuxX64,
("linux", "aarch64") => Self::LinuxArm,
("macos", "x86_64") => Self::MacX64,
("macos", "aarch64") => Self::MacArm,
("windows", "x86_64") => Self::WindowsX64,
("windows", "aarch64") => Self::WindowsArm,
_ => panic!("unsupported os/arch {os} {arch} - PR welcome!"),
}
}
@ -62,12 +61,13 @@ impl Platform {
Platform::MacX64 => "x86_64-apple-darwin",
Platform::MacArm => "aarch64-apple-darwin",
Platform::WindowsX64 => "x86_64-pc-windows-msvc",
Platform::WindowsArm => "aarch64-pc-windows-msvc",
}
}
}
/// Append .exe to path if on Windows.
pub fn with_exe(path: &str) -> Cow<str> {
pub fn with_exe(path: &str) -> Cow<'_, str> {
if cfg!(windows) {
format!("{path}.exe").into()
} else {

View file

@ -0,0 +1,268 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::error::Error;
use std::fs;
use std::path::Path;
use regex::Regex;
use reqwest::blocking::Client;
use serde_json::Value;
#[derive(Debug)]
struct NodeRelease {
version: String,
files: Vec<NodeFile>,
}
#[derive(Debug)]
struct NodeFile {
filename: String,
url: String,
}
fn main() -> Result<(), Box<dyn Error>> {
let release_info = fetch_node_release_info()?;
let new_text = generate_node_archive_function(&release_info)?;
update_node_text(&new_text)?;
println!("Node.js archive function updated successfully!");
Ok(())
}
fn fetch_node_release_info() -> Result<NodeRelease, Box<dyn Error>> {
let client = Client::new();
// Get the Node.js release info
let response = client
.get("https://nodejs.org/dist/index.json")
.header("User-Agent", "anki-build-updater")
.send()?;
let releases: Vec<Value> = response.json()?;
// Find the latest LTS release
let latest = releases
.iter()
.find(|release| {
// LTS releases have a non-false "lts" field
release["lts"].as_str().is_some() && release["lts"] != false
})
.ok_or("No LTS releases found")?;
let version = latest["version"]
.as_str()
.ok_or("Version not found")?
.to_string();
let files = latest["files"]
.as_array()
.ok_or("Files array not found")?
.iter()
.map(|f| f.as_str().unwrap_or(""))
.collect::<Vec<_>>();
let lts_name = latest["lts"].as_str().unwrap_or("unknown");
println!("Found Node.js LTS version: {version} ({lts_name})");
// Map platforms to their expected file keys and full filenames
let platform_mapping = vec![
(
"linux-x64",
"linux-x64",
format!("node-{version}-linux-x64.tar.xz"),
),
(
"linux-arm64",
"linux-arm64",
format!("node-{version}-linux-arm64.tar.xz"),
),
(
"darwin-x64",
"osx-x64-tar",
format!("node-{version}-darwin-x64.tar.xz"),
),
(
"darwin-arm64",
"osx-arm64-tar",
format!("node-{version}-darwin-arm64.tar.xz"),
),
(
"win-x64",
"win-x64-zip",
format!("node-{version}-win-x64.zip"),
),
(
"win-arm64",
"win-arm64-zip",
format!("node-{version}-win-arm64.zip"),
),
];
let mut node_files = Vec::new();
for (platform, file_key, filename) in platform_mapping {
// Check if this file exists in the release
if files.contains(&file_key) {
let url = format!("https://nodejs.org/dist/{version}/{filename}");
node_files.push(NodeFile {
filename: filename.clone(),
url,
});
println!("Found file for {platform}: {filename} (key: {file_key})");
} else {
return Err(
format!("File not found for {platform} (key: {file_key}): {filename}").into(),
);
}
}
Ok(NodeRelease {
version,
files: node_files,
})
}
fn generate_node_archive_function(release: &NodeRelease) -> Result<String, Box<dyn Error>> {
let client = Client::new();
// Fetch the SHASUMS256.txt file once
println!("Fetching SHA256 checksums...");
let shasums_url = format!("https://nodejs.org/dist/{}/SHASUMS256.txt", release.version);
let shasums_response = client
.get(&shasums_url)
.header("User-Agent", "anki-build-updater")
.send()?;
let shasums_text = shasums_response.text()?;
// Create a mapping from filename patterns to platform names - using the exact
// patterns we stored in files
let platform_mapping = vec![
("linux-x64.tar.xz", "LinuxX64"),
("linux-arm64.tar.xz", "LinuxArm"),
("darwin-x64.tar.xz", "MacX64"),
("darwin-arm64.tar.xz", "MacArm"),
("win-x64.zip", "WindowsX64"),
("win-arm64.zip", "WindowsArm"),
];
let mut platform_blocks = Vec::new();
for (file_pattern, platform_name) in platform_mapping {
// Find the file that ends with this pattern
if let Some(file) = release
.files
.iter()
.find(|f| f.filename.ends_with(file_pattern))
{
// Find the SHA256 for this file
let sha256 = shasums_text
.lines()
.find(|line| line.contains(&file.filename))
.and_then(|line| line.split_whitespace().next())
.ok_or_else(|| format!("SHA256 not found for {}", file.filename))?;
println!(
"Found SHA256 for {}: {} => {}",
platform_name, file.filename, sha256
);
let block = format!(
" Platform::{} => OnlineArchive {{\n url: \"{}\",\n sha256: \"{}\",\n }},",
platform_name, file.url, sha256
);
platform_blocks.push(block);
} else {
return Err(format!(
"File not found for platform {platform_name}: no file ending with {file_pattern}"
)
.into());
}
}
let function = format!(
"pub fn node_archive(platform: Platform) -> OnlineArchive {{\n match platform {{\n{}\n }}\n}}",
platform_blocks.join("\n")
);
Ok(function)
}
fn update_node_text(new_function: &str) -> Result<(), Box<dyn Error>> {
let node_rs_content = read_node_rs()?;
// Regex to match the entire node_archive function with proper multiline
// matching
let re = Regex::new(
r"(?s)pub fn node_archive\(platform: Platform\) -> OnlineArchive \{.*?\n\s*\}\s*\n\s*\}",
)?;
let updated_content = re.replace(&node_rs_content, new_function);
write_node_rs(&updated_content)?;
Ok(())
}
fn read_node_rs() -> Result<String, Box<dyn Error>> {
// Use CARGO_MANIFEST_DIR to get the crate root, then find src/node.rs
let manifest_dir =
std::env::var("CARGO_MANIFEST_DIR").map_err(|_| "CARGO_MANIFEST_DIR not set")?;
let path = Path::new(&manifest_dir).join("src").join("node.rs");
Ok(fs::read_to_string(path)?)
}
fn write_node_rs(content: &str) -> Result<(), Box<dyn Error>> {
// Use CARGO_MANIFEST_DIR to get the crate root, then find src/node.rs
let manifest_dir =
std::env::var("CARGO_MANIFEST_DIR").map_err(|_| "CARGO_MANIFEST_DIR not set")?;
let path = Path::new(&manifest_dir).join("src").join("node.rs");
fs::write(path, content)?;
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_regex_replacement() {
let sample_content = r#"Some other code
pub fn node_archive(platform: Platform) -> OnlineArchive {
match platform {
Platform::LinuxX64 => OnlineArchive {
url: "https://nodejs.org/dist/v20.11.0/node-v20.11.0-linux-x64.tar.xz",
sha256: "old_hash",
},
Platform::MacX64 => OnlineArchive {
url: "https://nodejs.org/dist/v20.11.0/node-v20.11.0-darwin-x64.tar.xz",
sha256: "old_hash",
},
}
}
More code here"#;
let new_function = r#"pub fn node_archive(platform: Platform) -> OnlineArchive {
match platform {
Platform::LinuxX64 => OnlineArchive {
url: "https://nodejs.org/dist/v21.0.0/node-v21.0.0-linux-x64.tar.xz",
sha256: "new_hash",
},
Platform::MacX64 => OnlineArchive {
url: "https://nodejs.org/dist/v21.0.0/node-v21.0.0-darwin-x64.tar.xz",
sha256: "new_hash",
},
}
}"#;
let re = Regex::new(
r"(?s)pub fn node_archive\(platform: Platform\) -> OnlineArchive \{.*?\n\s*\}\s*\n\s*\}"
).unwrap();
let result = re.replace(sample_content, new_function);
assert!(result.contains("v21.0.0"));
assert!(result.contains("new_hash"));
assert!(!result.contains("old_hash"));
assert!(result.contains("Some other code"));
assert!(result.contains("More code here"));
}
}

View file

@ -0,0 +1,125 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::error::Error;
use std::fs;
use std::path::Path;
use regex::Regex;
use reqwest::blocking::Client;
use serde_json::Value;
use sha2::Digest;
use sha2::Sha256;
fn fetch_protoc_release_info() -> Result<String, Box<dyn Error>> {
let client = Client::new();
println!("Fetching latest protoc release info from GitHub...");
// Fetch latest release info
let response = client
.get("https://api.github.com/repos/protocolbuffers/protobuf/releases/latest")
.header("User-Agent", "Anki-Build-Script")
.send()?;
let release_info: Value = response.json()?;
let assets = release_info["assets"]
.as_array()
.expect("assets should be an array");
// Map platform names to their corresponding asset patterns
let platform_patterns = [
("LinuxX64", "linux-x86_64"),
("LinuxArm", "linux-aarch_64"),
("MacX64", "osx-universal_binary"), // Mac uses universal binary for both
("MacArm", "osx-universal_binary"),
("WindowsX64", "win64"), // Windows uses x86 binary for both archs
("WindowsArm", "win64"),
];
let mut match_blocks = Vec::new();
for (platform, pattern) in platform_patterns {
// Find the asset matching the platform pattern
let asset = assets.iter().find(|asset| {
let name = asset["name"].as_str().unwrap_or("");
name.starts_with("protoc-") && name.contains(pattern) && name.ends_with(".zip")
});
if asset.is_none() {
eprintln!("No asset found for platform {platform} pattern {pattern}");
continue;
}
let asset = asset.unwrap();
let download_url = asset["browser_download_url"].as_str().unwrap();
let asset_name = asset["name"].as_str().unwrap();
// Download the file and calculate SHA256 locally
println!("Downloading and checksumming {asset_name} for {platform}...");
let response = client
.get(download_url)
.header("User-Agent", "Anki-Build-Script")
.send()?;
let bytes = response.bytes()?;
let mut hasher = Sha256::new();
hasher.update(&bytes);
let sha256 = format!("{:x}", hasher.finalize());
// Handle platform-specific match patterns
let match_pattern = match platform {
"MacX64" => "Platform::MacX64 | Platform::MacArm",
"MacArm" => continue, // Skip MacArm since it's handled with MacX64
"WindowsX64" => "Platform::WindowsX64 | Platform::WindowsArm",
"WindowsArm" => continue, // Skip WindowsArm since it's handled with WindowsX64
_ => &format!("Platform::{platform}"),
};
match_blocks.push(format!(
" {match_pattern} => {{\n OnlineArchive {{\n url: \"{download_url}\",\n sha256: \"{sha256}\",\n }}\n }}"
));
}
Ok(format!(
"pub fn protoc_archive(platform: Platform) -> OnlineArchive {{\n match platform {{\n{}\n }}\n}}",
match_blocks.join(",\n")
))
}
fn read_protobuf_rs() -> Result<String, Box<dyn Error>> {
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".to_string());
let path = Path::new(&manifest_dir).join("src/protobuf.rs");
println!("Reading {}", path.display());
let content = fs::read_to_string(path)?;
Ok(content)
}
fn update_protoc_text(old_text: &str, new_protoc_text: &str) -> Result<String, Box<dyn Error>> {
let re =
Regex::new(r"(?ms)^pub fn protoc_archive\(platform: Platform\) -> OnlineArchive \{.*?\n\}")
.unwrap();
if !re.is_match(old_text) {
return Err("Could not find protoc_archive function block to replace".into());
}
let new_content = re.replace(old_text, new_protoc_text).to_string();
println!("Original lines: {}", old_text.lines().count());
println!("Updated lines: {}", new_content.lines().count());
Ok(new_content)
}
fn write_protobuf_rs(content: &str) -> Result<(), Box<dyn Error>> {
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".to_string());
let path = Path::new(&manifest_dir).join("src/protobuf.rs");
println!("Writing to {}", path.display());
fs::write(path, content)?;
Ok(())
}
fn main() -> Result<(), Box<dyn Error>> {
let new_protoc_archive = fetch_protoc_release_info()?;
let content = read_protobuf_rs()?;
let updated_content = update_protoc_text(&content, &new_protoc_archive)?;
write_protobuf_rs(&updated_content)?;
println!("Successfully updated protoc_archive function in protobuf.rs");
Ok(())
}

View file

@ -0,0 +1,140 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::error::Error;
use std::fs;
use std::path::Path;
use regex::Regex;
use reqwest::blocking::Client;
use serde_json::Value;
fn fetch_uv_release_info() -> Result<String, Box<dyn Error>> {
let client = Client::new();
println!("Fetching latest uv release info from GitHub...");
// Fetch latest release info
let response = client
.get("https://api.github.com/repos/astral-sh/uv/releases/latest")
.header("User-Agent", "Anki-Build-Script")
.send()?;
let release_info: Value = response.json()?;
let assets = release_info["assets"]
.as_array()
.expect("assets should be an array");
// Map platform names to their corresponding asset patterns
let platform_patterns = [
("LinuxX64", "x86_64-unknown-linux-gnu"),
("LinuxArm", "aarch64-unknown-linux-gnu"),
("MacX64", "x86_64-apple-darwin"),
("MacArm", "aarch64-apple-darwin"),
("WindowsX64", "x86_64-pc-windows-msvc"),
("WindowsArm", "aarch64-pc-windows-msvc"),
];
let mut match_blocks = Vec::new();
for (platform, pattern) in platform_patterns {
// Find the asset matching the platform pattern (the binary)
let asset = assets.iter().find(|asset| {
let name = asset["name"].as_str().unwrap_or("");
name.contains(pattern) && (name.ends_with(".tar.gz") || name.ends_with(".zip"))
});
if asset.is_none() {
eprintln!("No asset found for platform {platform} pattern {pattern}");
continue;
}
let asset = asset.unwrap();
let download_url = asset["browser_download_url"].as_str().unwrap();
let asset_name = asset["name"].as_str().unwrap();
// Find the corresponding .sha256 or .sha256sum asset
let sha_asset = assets.iter().find(|a| {
let name = a["name"].as_str().unwrap_or("");
name == format!("{asset_name}.sha256") || name == format!("{asset_name}.sha256sum")
});
if sha_asset.is_none() {
eprintln!("No sha256 asset found for {asset_name}");
continue;
}
let sha_asset = sha_asset.unwrap();
let sha_url = sha_asset["browser_download_url"].as_str().unwrap();
println!("Fetching SHA256 for {platform}...");
let sha_text = client
.get(sha_url)
.header("User-Agent", "Anki-Build-Script")
.send()?
.text()?;
// The sha file is usually of the form: "<sha256> <filename>"
let sha256 = sha_text.split_whitespace().next().unwrap_or("");
match_blocks.push(format!(
" Platform::{platform} => {{\n OnlineArchive {{\n url: \"{download_url}\",\n sha256: \"{sha256}\",\n }}\n }}"
));
}
Ok(format!(
"pub fn uv_archive(platform: Platform) -> OnlineArchive {{\n match platform {{\n{}\n }}",
match_blocks.join(",\n")
))
}
fn read_python_rs() -> Result<String, Box<dyn Error>> {
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".to_string());
let path = Path::new(&manifest_dir).join("src/python.rs");
println!("Reading {}", path.display());
let content = fs::read_to_string(path)?;
Ok(content)
}
fn update_uv_text(old_text: &str, new_uv_text: &str) -> Result<String, Box<dyn Error>> {
let re = Regex::new(r"(?ms)^pub fn uv_archive\(platform: Platform\) -> OnlineArchive \{.*?\n\s*\}\s*\n\s*\}\s*\n\s*\}").unwrap();
if !re.is_match(old_text) {
return Err("Could not find uv_archive function block to replace".into());
}
let new_content = re.replace(old_text, new_uv_text).to_string();
println!("Original lines: {}", old_text.lines().count());
println!("Updated lines: {}", new_content.lines().count());
Ok(new_content)
}
fn write_python_rs(content: &str) -> Result<(), Box<dyn Error>> {
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".to_string());
let path = Path::new(&manifest_dir).join("src/python.rs");
println!("Writing to {}", path.display());
fs::write(path, content)?;
Ok(())
}
fn main() -> Result<(), Box<dyn Error>> {
let new_uv_archive = fetch_uv_release_info()?;
let content = read_python_rs()?;
let updated_content = update_uv_text(&content, &new_uv_archive)?;
write_python_rs(&updated_content)?;
println!("Successfully updated uv_archive function in python.rs");
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_update_uv_text_with_actual_file() {
let content = fs::read_to_string("src/python.rs").unwrap();
let original_lines = content.lines().count();
const EXPECTED_LINES_REMOVED: usize = 38;
let updated = update_uv_text(&content, "").unwrap();
let updated_lines = updated.lines().count();
assert_eq!(
updated_lines,
original_lines - EXPECTED_LINES_REMOVED,
"Expected line count to decrease by exactly {EXPECTED_LINES_REMOVED} lines (original: {original_lines}, updated: {updated_lines})"
);
}
}

View file

@ -271,14 +271,14 @@ impl BuildStatement<'_> {
stmt.rule_variables.push(("pool".into(), pool.into()));
}
if have_n2 {
stmt.rule_variables.push((
"hide_success".into(),
(action.hide_success() as u8).to_string(),
));
stmt.rule_variables.push((
"hide_last_line".into(),
(action.hide_last_line() as u8).to_string(),
));
if action.hide_success() {
stmt.rule_variables
.push(("hide_success".into(), "1".into()));
}
if action.hide_progress() {
stmt.rule_variables
.push(("hide_progress".into(), "1".into()));
}
}
stmt
@ -300,7 +300,7 @@ impl BuildStatement<'_> {
writeln!(buf, "build {outputs_str}: {action_name} {inputs_str}").unwrap();
for (key, value) in self.variables.iter().sorted() {
writeln!(buf, " {key} = {}", value).unwrap();
writeln!(buf, " {key} = {value}").unwrap();
}
writeln!(buf).unwrap();
@ -368,8 +368,8 @@ pub trait FilesHandle {
/// different variables. This is a shortcut for calling .expand_inputs()
/// and then .add_inputs_vec()
/// - If the variable name is non-empty, a variable of the same name will be
/// created so the file list can be accessed in the command. By convention,
/// this is often `in`.
/// created so the file list can be accessed in the command. By
/// convention, this is often `in`.
fn add_inputs(&mut self, variable: &'static str, inputs: impl AsRef<BuildInput>);
fn add_inputs_vec(&mut self, variable: &'static str, inputs: Vec<String>);
fn add_order_only_inputs(&mut self, variable: &'static str, inputs: impl AsRef<BuildInput>);
@ -392,14 +392,14 @@ pub trait FilesHandle {
/// Add outputs to the build statement. Can be called multiple times with
/// different variables.
/// - Each output automatically has $builddir/ prefixed to it if it does not
/// already start with it.
/// already start with it.
/// - If the variable name is non-empty, a variable of the same name will be
/// created so the file list can be accessed in the command. By convention,
/// this is often `out`.
/// - If subgroup is true, the files are also placed in a subgroup. Eg
/// if a rule `foo` exists and subgroup `bar` is provided, the files are
/// accessible via `:foo:bar`. The variable name must not be empty, or
/// called `out`.
/// created so the file list can be accessed in the command. By
/// convention, this is often `out`.
/// - If subgroup is true, the files are also placed in a subgroup. Eg if a
/// rule `foo` exists and subgroup `bar` is provided, the files are
/// accessible via `:foo:bar`. The variable name must not be empty, or
/// called `out`.
fn add_outputs_ext(
&mut self,
variable: impl Into<String>,
@ -476,7 +476,7 @@ impl FilesHandle for BuildStatement<'_> {
let outputs = outputs.into_iter().map(|v| {
let v = v.as_ref();
let v = if !v.starts_with("$builddir/") && !v.starts_with("$builddir\\") {
format!("$builddir/{}", v)
format!("$builddir/{v}")
} else {
v.to_owned()
};

View file

@ -162,7 +162,7 @@ impl BuildAction for CargoTest {
"cargo-nextest",
CargoInstall {
binary_name: "cargo-nextest",
args: "cargo-nextest --version 0.9.57 --locked",
args: "cargo-nextest --version 0.9.99 --locked --no-default-features --features default-no-update",
},
)?;
setup_flags(build)

View file

@ -3,6 +3,7 @@
use std::collections::HashMap;
use std::fmt::Display;
use std::sync::LazyLock;
use camino::Utf8PathBuf;
@ -118,9 +119,7 @@ pub struct Glob {
pub exclude: Option<String>,
}
lazy_static::lazy_static! {
static ref CACHED_FILES: Vec<Utf8PathBuf> = cache_files();
}
static CACHED_FILES: LazyLock<Vec<Utf8PathBuf>> = LazyLock::new(cache_files);
/// Walking the source tree once instead of for each glob yields ~4x speed
/// improvements.

View file

@ -19,24 +19,28 @@ use crate::input::BuildInput;
pub fn node_archive(platform: Platform) -> OnlineArchive {
match platform {
Platform::LinuxX64 => OnlineArchive {
url: "https://nodejs.org/dist/v18.12.1/node-v18.12.1-linux-x64.tar.xz",
sha256: "4481a34bf32ddb9a9ff9540338539401320e8c3628af39929b4211ea3552a19e",
url: "https://nodejs.org/dist/v22.17.0/node-v22.17.0-linux-x64.tar.xz",
sha256: "325c0f1261e0c61bcae369a1274028e9cfb7ab7949c05512c5b1e630f7e80e12",
},
Platform::LinuxArm => OnlineArchive {
url: "https://nodejs.org/dist/v18.12.1/node-v18.12.1-linux-arm64.tar.xz",
sha256: "3904869935b7ecc51130b4b86486d2356539a174d11c9181180cab649f32cd2a",
url: "https://nodejs.org/dist/v22.17.0/node-v22.17.0-linux-arm64.tar.xz",
sha256: "140aee84be6774f5fb3f404be72adbe8420b523f824de82daeb5ab218dab7b18",
},
Platform::MacX64 => OnlineArchive {
url: "https://nodejs.org/dist/v18.12.1/node-v18.12.1-darwin-x64.tar.xz",
sha256: "6c88d462550a024661e74e9377371d7e023321a652eafb3d14d58a866e6ac002",
url: "https://nodejs.org/dist/v22.17.0/node-v22.17.0-darwin-x64.tar.xz",
sha256: "f79de1f64df4ac68493a344bb5ab7d289d0275271e87b543d1278392c9de778a",
},
Platform::MacArm => OnlineArchive {
url: "https://nodejs.org/dist/v18.12.1/node-v18.12.1-darwin-arm64.tar.xz",
sha256: "17f2e25d207d36d6b0964845062160d9ed16207c08d09af33b9a2fd046c5896f",
url: "https://nodejs.org/dist/v22.17.0/node-v22.17.0-darwin-arm64.tar.xz",
sha256: "cc9cc294eaf782dd93c8c51f460da610cc35753c6a9947411731524d16e97914",
},
Platform::WindowsX64 => OnlineArchive {
url: "https://nodejs.org/dist/v18.12.1/node-v18.12.1-win-x64.zip",
sha256: "5478a5a2dce2803ae22327a9f8ae8494c1dec4a4beca5bbf897027380aecf4c7",
url: "https://nodejs.org/dist/v22.17.0/node-v22.17.0-win-x64.zip",
sha256: "721ab118a3aac8584348b132767eadf51379e0616f0db802cc1e66d7f0d98f85",
},
Platform::WindowsArm => OnlineArchive {
url: "https://nodejs.org/dist/v22.17.0/node-v22.17.0-win-arm64.zip",
sha256: "78355dc9ca117bb71d3f081e4b1b281855e2b134f3939bb0ca314f7567b0e621",
},
}
}
@ -94,7 +98,7 @@ impl BuildAction for YarnInstall<'_> {
}
}
fn with_cmd_ext(bin: &str) -> Cow<str> {
fn with_cmd_ext(bin: &str) -> Cow<'_, str> {
if cfg!(windows) {
format!("{bin}.cmd").into()
} else {
@ -207,6 +211,31 @@ impl BuildAction for DPrint {
}
}
pub struct Prettier {
pub inputs: BuildInput,
pub check_only: bool,
}
impl BuildAction for Prettier {
fn command(&self) -> &str {
"$yarn prettier --cache $mode $pattern"
}
fn files(&mut self, build: &mut impl build::FilesHandle) {
build.add_inputs("yarn", inputs![":yarn:bin"]);
build.add_inputs("prettier", inputs![":node_modules:prettier"]);
build.add_inputs("", &self.inputs);
build.add_variable("pattern", r#""**/*.svelte""#);
let (file_ext, mode) = if self.check_only {
("fmt", "--check")
} else {
("check", "--write")
};
build.add_variable("mode", mode);
build.add_output_stamp(format!("tests/prettier.{file_ext}"));
}
}
pub struct SvelteCheck {
pub tsconfig: BuildInput,
pub inputs: BuildInput,
@ -214,33 +243,20 @@ pub struct SvelteCheck {
impl BuildAction for SvelteCheck {
fn command(&self) -> &str {
"$svelte-check --tsconfig $tsconfig $
--fail-on-warnings --threshold warning $
--compiler-warnings $compiler_warnings"
"$yarn svelte-check:once"
}
fn files(&mut self, build: &mut impl build::FilesHandle) {
build.add_inputs("svelte-check", inputs![":node_modules:svelte-check"]);
build.add_inputs("tsconfig", &self.tsconfig);
build.add_inputs("yarn", inputs![":yarn:bin"]);
build.add_inputs("", &self.inputs);
build.add_inputs("", inputs!["yarn.lock"]);
build.add_variable(
"compiler_warnings",
[
"a11y-click-events-have-key-events",
"a11y-no-noninteractive-tabindex",
"a11y-no-static-element-interactions",
]
.iter()
.map(|warning| format!("{}$:ignore", warning))
.collect::<Vec<_>>()
.join(","),
);
let hash = simple_hash(&self.tsconfig);
build.add_output_stamp(format!("tests/svelte-check.{hash}"));
}
fn hide_last_line(&self) -> bool {
fn hide_progress(&self) -> bool {
true
}
}
@ -290,30 +306,20 @@ impl BuildAction for Eslint<'_> {
}
}
pub struct JestTest<'a> {
pub folder: &'a str,
pub struct ViteTest {
pub deps: BuildInput,
pub jest_rc: BuildInput,
pub jsdom: bool,
}
impl BuildAction for JestTest<'_> {
impl BuildAction for ViteTest {
fn command(&self) -> &str {
"$jest --config $config $env $folder"
"$yarn vitest:once"
}
fn files(&mut self, build: &mut impl build::FilesHandle) {
build.add_inputs("jest", inputs![":node_modules:jest"]);
build.add_inputs("vitest", inputs![":node_modules:vitest"]);
build.add_inputs("yarn", inputs![":yarn:bin"]);
build.add_inputs("", &self.deps);
build.add_inputs("config", &self.jest_rc);
build.add_variable("env", if self.jsdom { "--env=jsdom" } else { "" });
build.add_variable("folder", self.folder);
let hash = simple_hash(self.folder);
build.add_output_stamp(format!("tests/jest.{hash}"));
}
fn hide_last_line(&self) -> bool {
true
build.add_output_stamp("tests/vitest");
}
}
@ -451,3 +457,29 @@ impl BuildAction for CompileTypescript<'_> {
build.add_outputs("", output_files);
}
}
/// The output_folder will be declared as a build output, but each file inside
/// it is not declared, as the files will vary.
pub struct SveltekitBuild {
pub output_folder: BuildInput,
pub deps: BuildInput,
}
impl BuildAction for SveltekitBuild {
fn command(&self) -> &str {
if std::env::var("HMR").is_err() {
"$yarn build"
} else {
"echo"
}
}
fn files(&mut self, build: &mut impl build::FilesHandle) {
build.add_inputs("node_modules", inputs![":node_modules"]);
build.add_inputs("yarn", inputs![":yarn:bin"]);
build.add_inputs("", &self.deps);
build.add_inputs("", inputs!["yarn.lock"]);
build.add_output_stamp("sveltekit.marker");
build.add_outputs_ext("folder", vec!["sveltekit"], true);
}
}

View file

@ -21,26 +21,26 @@ pub fn protoc_archive(platform: Platform) -> OnlineArchive {
match platform {
Platform::LinuxX64 => {
OnlineArchive {
url: "https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protoc-21.8-linux-x86_64.zip",
sha256: "f90d0dd59065fef94374745627336d622702b67f0319f96cee894d41a974d47a",
url: "https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protoc-31.1-linux-x86_64.zip",
sha256: "96553041f1a91ea0efee963cb16f462f5985b4d65365f3907414c360044d8065",
}
}
},
Platform::LinuxArm => {
OnlineArchive {
url: "https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protoc-21.8-linux-aarch_64.zip",
sha256: "f3d8eb5839d6186392d8c7b54fbeabbb6fcdd90618a500b77cb2e24faa245cad",
url: "https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protoc-31.1-linux-aarch_64.zip",
sha256: "6c554de11cea04c56ebf8e45b54434019b1cd85223d4bbd25c282425e306ecc2",
}
}
},
Platform::MacX64 | Platform::MacArm => {
OnlineArchive {
url: "https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protoc-21.8-osx-universal_binary.zip",
sha256: "e3324d3bc2e9bc967a0bec2472e0ec73b26f952c7c87f2403197414f780c3c6c",
url: "https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protoc-31.1-osx-universal_binary.zip",
sha256: "99ea004549c139f46da5638187a85bbe422d78939be0fa01af1aa8ab672e395f",
}
}
Platform::WindowsX64 => {
},
Platform::WindowsX64 | Platform::WindowsArm => {
OnlineArchive {
url: "https://github.com/protocolbuffers/protobuf/releases/download/v21.8/protoc-21.8-win64.zip",
sha256: "3657053024faa439ff5f8c1dd2ee06bac0f9b9a3d660e99944f015a7451e87ec",
url: "https://github.com/protocolbuffers/protobuf/releases/download/v31.1/protoc-31.1-win64.zip",
sha256: "70381b116ab0d71cb6a5177d9b17c7c13415866603a0fd40d513dafe32d56c35",
}
}
}
@ -67,7 +67,7 @@ fn clang_format_archive(platform: Platform) -> OnlineArchive {
sha256: "238be68d9478163a945754f06a213483473044f5a004c4125d3d9d8d3556466e",
}
}
Platform::WindowsX64 => {
Platform::WindowsX64 | Platform::WindowsArm=> {
OnlineArchive {
url: "https://github.com/ankitects/clang-format-binaries/releases/download/anki-2021-01-09/clang-format_windows_x86_64.zip",
sha256: "7d9f6915e3f0fb72407830f0fc37141308d2e6915daba72987a52f309fbeaccc",

View file

@ -9,6 +9,7 @@ use maplit::hashmap;
use crate::action::BuildAction;
use crate::archives::download_and_extract;
use crate::archives::with_exe;
use crate::archives::OnlineArchive;
use crate::archives::Platform;
use crate::hash::simple_hash;
@ -16,82 +17,113 @@ use crate::input::BuildInput;
use crate::inputs;
use crate::Build;
/// When updating this, pyoxidizer.bzl needs updating too, but it uses different
/// files.
pub fn python_archive(platform: Platform) -> OnlineArchive {
// To update, run 'cargo run --bin update_uv'.
// You'll need to do this when bumping Python versions, as uv bakes in
// the latest known version.
// When updating Python version, make sure to update version tag in BuildWheel
// too.
pub fn uv_archive(platform: Platform) -> OnlineArchive {
match platform {
Platform::LinuxX64 => {
OnlineArchive {
url: "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.9.18+20240107-x86_64_v2-unknown-linux-gnu-install_only.tar.gz",
sha256: "9426bca501ae0a257392b10719e2e20ff5fa5e22a3ce4599d6ad0b3139f86417",
url: "https://github.com/astral-sh/uv/releases/download/0.7.13/uv-x86_64-unknown-linux-gnu.tar.gz",
sha256: "909278eb197c5ed0e9b5f16317d1255270d1f9ea4196e7179ce934d48c4c2545",
}
}
},
Platform::LinuxArm => {
OnlineArchive {
url: "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.9.18+20240107-aarch64-unknown-linux-gnu-install_only.tar.gz",
sha256: "7d19e1ecd6e582423f7c74a0c67491eaa982ce9d5c5f35f0e4289f83127abcb8",
url: "https://github.com/astral-sh/uv/releases/download/0.7.13/uv-aarch64-unknown-linux-gnu.tar.gz",
sha256: "0b2ad9fe4295881615295add8cc5daa02549d29cc9a61f0578e397efcf12f08f",
}
}
},
Platform::MacX64 => {
OnlineArchive {
url: "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.9.18+20240107-x86_64-apple-darwin-install_only.tar.gz",
sha256: "5a0bf895a5cb08d6d008140abb41bb2c8cd638a665273f7d8eb258bc89de439b",
url: "https://github.com/astral-sh/uv/releases/download/0.7.13/uv-x86_64-apple-darwin.tar.gz",
sha256: "d785753ac092e25316180626aa691c5dfe1fb075290457ba4fdb72c7c5661321",
}
}
},
Platform::MacArm => {
OnlineArchive {
url: "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.9.18+20240107-aarch64-apple-darwin-install_only.tar.gz",
sha256: "bf0cd90204a2cc6da48cae1e4b32f48c9f7031fbe1238c5972104ccb0155d368",
url: "https://github.com/astral-sh/uv/releases/download/0.7.13/uv-aarch64-apple-darwin.tar.gz",
sha256: "721f532b73171586574298d4311a91d5ea2c802ef4db3ebafc434239330090c6",
}
}
},
Platform::WindowsX64 => {
OnlineArchive {
url: "https://github.com/indygreg/python-build-standalone/releases/download/20240107/cpython-3.9.18+20240107-x86_64-pc-windows-msvc-shared-install_only.tar.gz",
sha256: "8f0544cd593984f7ecb90c685931249c579302124b9821064873f3a14ed07005",
url: "https://github.com/astral-sh/uv/releases/download/0.7.13/uv-x86_64-pc-windows-msvc.zip",
sha256: "e199b10bef1a7cc540014483e7f60f825a174988f41020e9d2a6b01bd60f0669",
}
},
Platform::WindowsArm => {
OnlineArchive {
url: "https://github.com/astral-sh/uv/releases/download/0.7.13/uv-aarch64-pc-windows-msvc.zip",
sha256: "bb40708ad549ad6a12209cb139dd751bf0ede41deb679ce7513ce197bd9ef234",
}
}
}
}
/// Returns the Python binary, which can be used to create venvs.
/// Downloads if missing.
pub fn setup_python(build: &mut Build) -> Result<()> {
// if changing this, make sure you remove out/pyenv
let python_binary = match env::var("PYTHON_BINARY") {
pub fn setup_uv(build: &mut Build, platform: Platform) -> Result<()> {
let uv_binary = match env::var("UV_BINARY") {
Ok(path) => {
assert!(
Utf8Path::new(&path).is_absolute(),
"PYTHON_BINARY must be absolute"
"UV_BINARY must be absolute"
);
path.into()
}
Err(_) => {
download_and_extract(
build,
"python",
python_archive(build.host_platform),
"uv",
uv_archive(platform),
hashmap! { "bin" => [
if cfg!(windows) { "python.exe" } else { "bin/python3"}
] },
with_exe("uv")
] },
)?;
inputs![":extract:python:bin"]
inputs![":extract:uv:bin"]
}
};
build.add_dependency("python_binary", python_binary);
build.add_dependency("uv_binary", uv_binary);
// Our macOS packaging needs access to the x86 binary on ARM.
if cfg!(target_arch = "aarch64") {
download_and_extract(
build,
"uv_mac_x86",
uv_archive(Platform::MacX64),
hashmap! { "bin" => [
with_exe("uv")
] },
)?;
}
// Our Linux packaging needs access to the ARM binary on x86
if cfg!(target_arch = "x86_64") {
download_and_extract(
build,
"uv_lin_arm",
uv_archive(Platform::LinuxArm),
hashmap! { "bin" => [
with_exe("uv")
] },
)?;
}
Ok(())
}
pub struct PythonEnvironment {
pub folder: &'static str,
pub base_requirements_txt: BuildInput,
pub requirements_txt: BuildInput,
pub deps: BuildInput,
// todo: rename
pub venv_folder: &'static str,
pub extra_args: &'static str,
pub extra_binary_exports: &'static [&'static str],
}
impl BuildAction for PythonEnvironment {
fn command(&self) -> &str {
if env::var("OFFLINE_BUILD").is_err() {
"$runner pyenv $python_binary $builddir/$pyenv_folder $system_pkgs $base_requirements $requirements"
"$runner pyenv $uv_binary $builddir/$pyenv_folder -- $extra_args"
} else {
"echo 'OFFLINE_BUILD is set. Using the existing PythonEnvironment.'"
}
@ -99,7 +131,7 @@ impl BuildAction for PythonEnvironment {
fn files(&mut self, build: &mut impl crate::build::FilesHandle) {
let bin_path = |binary: &str| -> Vec<String> {
let folder = self.folder;
let folder = self.venv_folder;
let path = if cfg!(windows) {
format!("{folder}/scripts/{binary}.exe")
} else {
@ -108,17 +140,24 @@ impl BuildAction for PythonEnvironment {
vec![path]
};
build.add_inputs("", &self.deps);
build.add_variable("pyenv_folder", self.venv_folder);
if env::var("OFFLINE_BUILD").is_err() {
build.add_inputs("python_binary", inputs![":python_binary"]);
build.add_variable("pyenv_folder", self.folder);
build.add_inputs("base_requirements", &self.base_requirements_txt);
build.add_inputs("requirements", &self.requirements_txt);
build.add_outputs_ext("pip", bin_path("pip"), true);
build.add_inputs("uv_binary", inputs![":uv_binary"]);
// Add --python flag to extra_args if PYTHON_BINARY is set
let mut args = self.extra_args.to_string();
if let Ok(python_binary) = env::var("PYTHON_BINARY") {
args = format!("--python {python_binary} {args}");
}
build.add_variable("extra_args", args);
}
build.add_outputs_ext("bin", bin_path("python"), true);
for binary in self.extra_binary_exports {
build.add_outputs_ext(*binary, bin_path(binary), true);
}
build.add_output_stamp(format!("{}/.stamp", self.venv_folder));
}
fn check_output_timestamps(&self) -> bool {
@ -146,7 +185,7 @@ impl BuildAction for PythonTypecheck {
build.add_output_stamp(format!("tests/python_typecheck.{hash}"));
}
fn hide_last_line(&self) -> bool {
fn hide_progress(&self) -> bool {
true
}
}
@ -154,31 +193,19 @@ impl BuildAction for PythonTypecheck {
struct PythonFormat<'a> {
pub inputs: &'a BuildInput,
pub check_only: bool,
pub isort_ini: &'a BuildInput,
}
impl BuildAction for PythonFormat<'_> {
fn command(&self) -> &str {
"$black -t py39 -q $check --color $in && $
$isort --color --settings-path $isort_ini $check $in"
"$ruff format $mode $in && $ruff check --select I --fix $in"
}
fn files(&mut self, build: &mut impl crate::build::FilesHandle) {
build.add_inputs("in", self.inputs);
build.add_inputs("black", inputs![":pyenv:black"]);
build.add_inputs("isort", inputs![":pyenv:isort"]);
build.add_inputs("ruff", inputs![":pyenv:ruff"]);
let hash = simple_hash(self.inputs);
build.add_env_var("BLACK_CACHE_DIR", "out/python/black.cache.{hash}");
build.add_inputs("isort_ini", self.isort_ini);
build.add_variable(
"check",
if self.check_only {
"--diff --check"
} else {
""
},
);
build.add_variable("mode", if self.check_only { "--check" } else { "" });
build.add_output_stamp(format!(
"tests/python_format.{}.{hash}",
@ -188,49 +215,52 @@ impl BuildAction for PythonFormat<'_> {
}
pub fn python_format(build: &mut Build, group: &str, inputs: BuildInput) -> Result<()> {
let isort_ini = &inputs![".isort.cfg"];
build.add_action(
&format!("check:format:python:{group}"),
format!("check:format:python:{group}"),
PythonFormat {
inputs: &inputs,
check_only: true,
isort_ini,
},
)?;
build.add_action(
&format!("format:python:{group}"),
format!("format:python:{group}"),
PythonFormat {
inputs: &inputs,
check_only: false,
isort_ini,
},
)?;
Ok(())
}
pub struct PythonLint {
pub struct RuffCheck {
pub folders: &'static [&'static str],
pub pylint_ini: BuildInput,
pub deps: BuildInput,
pub check_only: bool,
}
impl BuildAction for PythonLint {
impl BuildAction for RuffCheck {
fn command(&self) -> &str {
"$pylint --rcfile $pylint_ini -sn -j $cpus $folders"
"$ruff check $folders $mode"
}
fn files(&mut self, build: &mut impl crate::build::FilesHandle) {
build.add_inputs("", &self.deps);
build.add_inputs("pylint", inputs![":pyenv:pylint"]);
build.add_inputs("pylint_ini", &self.pylint_ini);
build.add_inputs("", inputs![".ruff.toml"]);
build.add_inputs("ruff", inputs![":pyenv:ruff"]);
build.add_variable("folders", self.folders.join(" "));
// On a 16 core system, values above 10 do not improve wall clock time,
// but waste extra cores that could be working on other tests.
build.add_variable("cpus", num_cpus::get().min(10).to_string());
build.add_variable(
"mode",
if self.check_only {
""
} else {
"--fix --unsafe-fixes"
},
);
let hash = simple_hash(&self.deps);
build.add_output_stamp(format!("tests/python_lint.{hash}"));
let kind = if self.check_only { "check" } else { "fix" };
build.add_output_stamp(format!("tests/python_ruff.{kind}.{hash}"));
}
}
@ -251,7 +281,7 @@ impl BuildAction for PythonTest {
build.add_variable("folder", self.folder);
build.add_variable(
"pythonpath",
&self.python_path.join(if cfg!(windows) { ";" } else { ":" }),
self.python_path.join(if cfg!(windows) { ";" } else { ":" }),
);
build.add_env_var("PYTHONPATH", "$pythonpath");
build.add_env_var("ANKI_TEST_MODE", "1");
@ -259,7 +289,7 @@ impl BuildAction for PythonTest {
build.add_output_stamp(format!("tests/python_pytest.{hash}"));
}
fn hide_last_line(&self) -> bool {
fn hide_progress(&self) -> bool {
true
}
}

View file

@ -30,12 +30,12 @@ impl Build {
)
.unwrap();
for (key, value) in &self.variables {
writeln!(&mut buf, "{} = {}", key, value).unwrap();
writeln!(&mut buf, "{key} = {value}").unwrap();
}
buf.push('\n');
for (key, value) in &self.pools {
writeln!(&mut buf, "pool {}\n depth = {}", key, value).unwrap();
writeln!(&mut buf, "pool {key}\n depth = {value}").unwrap();
}
buf.push('\n');

View file

@ -15,7 +15,6 @@ camino.workspace = true
clap.workspace = true
flate2.workspace = true
junction.workspace = true
reqwest = { workspace = true, features = ["rustls-tls", "rustls-tls-native-roots"] }
sha2.workspace = true
tar.workspace = true
termcolor.workspace = true
@ -24,3 +23,9 @@ which.workspace = true
xz2.workspace = true
zip.workspace = true
zstd.workspace = true
[target.'cfg(windows)'.dependencies]
reqwest = { workspace = true, features = ["native-tls"] }
[target.'cfg(not(windows))'.dependencies]
reqwest = { workspace = true, features = ["rustls-tls", "rustls-tls-native-roots"] }

View file

@ -65,7 +65,7 @@ fn sha2_data(data: &[u8]) -> String {
let mut digest = sha2::Sha256::new();
digest.update(data);
let result = digest.finalize();
format!("{:x}", result)
format!("{result:x}")
}
enum CompressionKind {

View file

@ -7,6 +7,8 @@ use std::io::Write;
use std::process::Command;
use std::time::Instant;
use anki_process::CommandExt;
use anyhow::Context;
use camino::Utf8Path;
use camino::Utf8PathBuf;
use clap::Args;
@ -65,21 +67,22 @@ pub fn run_build(args: BuildArgs) {
"MYPY_CACHE_DIR",
build_root.join("tests").join("mypy").into_string(),
)
.env("PYTHONPYCACHEPREFIX", build_root.join("pycache"))
.env(
"PYTHONPYCACHEPREFIX",
std::path::absolute(build_root.join("pycache")).unwrap(),
)
// commands will not show colors by default, as we do not provide a tty
.env("FORCE_COLOR", "1")
.env("MYPY_FORCE_COLOR", "1")
.env("TERM", std::env::var("TERM").unwrap_or_default())
// Prevents 'Warn: You must provide the URL of lib/mappings.wasm'.
// Updating svelte-check or its deps will likely remove the need for it.
.env("NODE_OPTIONS", "--no-experimental-fetch");
.env("TERM", std::env::var("TERM").unwrap_or_default());
if env::var("NINJA_STATUS").is_err() {
command.env("NINJA_STATUS", "[%f/%t; %r active; %es] ");
}
// run build
let mut status = command.status().expect("ninja not installed");
let Ok(mut status) = command.status() else {
panic!("\nn2 and ninja missing/failed. did you forget 'bash tools/install-n2'?");
};
if !status.success() && Instant::now().duration_since(start_time).as_secs() < 3 {
// if the build fails quickly, there's a reasonable chance that build.ninja
// references a file that has been renamed/deleted. We currently don't
@ -135,7 +138,7 @@ fn setup_build_root() -> Utf8PathBuf {
true
};
if create {
println!("Switching build root to {}", new_target);
println!("Switching build root to {new_target}");
std::os::unix::fs::symlink(new_target, build_root).unwrap();
}
}
@ -166,11 +169,12 @@ fn maybe_update_buildhash(build_root: &Utf8Path) {
fn get_buildhash() -> String {
let output = Command::new("git")
.args(["rev-parse", "--short=8", "HEAD"])
.output()
.expect("git");
assert!(output.status.success(),
"Invoking 'git' failed. Make sure you're building from a clone of the git repo, and that 'git' is installed.");
String::from_utf8(output.stdout).unwrap().trim().into()
.utf8_output()
.context(
"Make sure you're building from a clone of the git repo, and that 'git' is installed.",
)
.unwrap();
output.stdout.trim().into()
}
fn write_if_changed(path: &Utf8Path, contents: &str) {

View file

@ -1,62 +0,0 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::env;
use std::fs;
use std::process::Command;
use camino::Utf8PathBuf;
use clap::Args;
use crate::run::run_command;
#[derive(Args, Debug)]
pub struct BuildArtifactsArgs {
bundle_root: Utf8PathBuf,
pyoxidizer_bin: String,
}
pub fn build_artifacts(args: BuildArtifactsArgs) {
// build.rs doesn't declare inputs from venv, so we need to force a rebuild to
// ensure changes to our libs/the venv get included
let artifacts = args.bundle_root.join("artifacts");
if artifacts.exists() {
fs::remove_dir_all(&artifacts).unwrap();
}
let bundle_root = args.bundle_root.canonicalize_utf8().unwrap();
let build_folder = bundle_root.join("build");
if build_folder.exists() {
fs::remove_dir_all(&build_folder).unwrap();
}
run_command(
Command::new(&args.pyoxidizer_bin)
.args([
"--system-rust",
"run-build-script",
"qt/bundle/build.rs",
"--var",
"venv",
"out/bundle/pyenv",
"--var",
"build",
build_folder.as_str(),
])
.env("CARGO_MANIFEST_DIR", "qt/bundle")
.env("CARGO_TARGET_DIR", "out/bundle/rust")
.env("PROFILE", "release")
.env("OUT_DIR", &artifacts)
.env("TARGET", env!("TARGET"))
.env("SDKROOT", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
.env("MACOSX_DEPLOYMENT_TARGET", macos_deployment_target())
.env("CARGO_BUILD_TARGET", env!("TARGET")),
);
}
pub fn macos_deployment_target() -> &'static str {
if env!("TARGET") == "x86_64-apple-darwin" {
"10.13.4"
} else {
"11"
}
}

View file

@ -1,53 +0,0 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::process::Command;
use anki_process::CommandExt;
use camino::Utf8Path;
use camino::Utf8PathBuf;
use super::artifacts::macos_deployment_target;
use crate::run::run_command;
pub fn build_bundle_binary() {
let mut features = String::from("build-mode-prebuilt-artifacts");
if cfg!(target_os = "linux") || cfg!(target_os = "macos") {
features.push_str(",global-allocator-jemalloc,allocator-jemalloc");
}
let mut command = Command::new("cargo");
command
.args([
"build",
"--manifest-path=qt/bundle/Cargo.toml",
"--target-dir=out/bundle/rust",
"--release",
"--no-default-features",
])
.arg(format!("--features={features}"))
.env(
"DEFAULT_PYTHON_CONFIG_RS",
// included in main.rs, so relative to qt/bundle/src
"../../../out/bundle/artifacts/",
)
.env(
"PYO3_CONFIG_FILE",
Utf8Path::new("out/bundle/artifacts/pyo3-build-config-file.txt")
.canonicalize_utf8()
.unwrap(),
)
.env("MACOSX_DEPLOYMENT_TARGET", macos_deployment_target())
.env("SDKROOT", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk")
.env("CARGO_BUILD_TARGET", env!("TARGET"));
if env!("TARGET") == "x86_64-apple-darwin" {
let xcode_path = Command::run_with_output(["xcode-select", "-p"]).unwrap();
let ld_classic = Utf8PathBuf::from(xcode_path.stdout.trim())
.join("Toolchains/XcodeDefault.xctoolchain/usr/bin/ld-classic");
if ld_classic.exists() {
// work around XCode 15's default linker not supporting macOS 10.15-12.
command.env("RUSTFLAGS", &format!("-Clink-arg=-fuse-ld={ld_classic}"));
}
}
run_command(&mut command);
}

View file

@ -1,156 +0,0 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::env;
use std::fs;
use std::process::Command;
use camino::Utf8Path;
use camino::Utf8PathBuf;
use clap::Args;
use clap::ValueEnum;
use crate::paths::absolute_msys_path;
use crate::paths::unix_path;
use crate::run::run_command;
#[derive(Clone, Copy, ValueEnum, Debug)]
enum DistKind {
Standard,
Alternate,
}
#[derive(Args, Debug)]
pub struct BuildDistFolderArgs {
kind: DistKind,
folder_root: Utf8PathBuf,
}
pub fn build_dist_folder(args: BuildDistFolderArgs) {
let BuildDistFolderArgs { kind, folder_root } = args;
fs::create_dir_all(&folder_root).unwrap();
// Start with Qt, as it's the largest, and we use --delete to ensure there are
// no stale files in lib/. Skipped on macOS as Qt is handled later.
if !cfg!(target_os = "macos") {
copy_qt_from_venv(kind, &folder_root);
}
clean_top_level_files(&folder_root);
copy_binary_and_pylibs(&folder_root);
if cfg!(target_os = "linux") {
copy_linux_extras(kind, &folder_root);
} else if cfg!(windows) {
copy_windows_extras(&folder_root);
}
fs::write(folder_root.with_extension("stamp"), b"").unwrap();
}
fn copy_qt_from_venv(kind: DistKind, folder_root: &Utf8Path) {
let python39 = if cfg!(windows) { "" } else { "python3.9/" };
let qt_root = match kind {
DistKind::Standard => {
folder_root.join(format!("../pyenv/lib/{python39}site-packages/PyQt6"))
}
DistKind::Alternate => {
folder_root.join(format!("../pyenv-qt5/lib/{python39}site-packages/PyQt5"))
}
};
let src_path = absolute_msys_path(&qt_root);
let lib_path = folder_root.join("lib");
fs::create_dir_all(&lib_path).unwrap();
let dst_path = with_slash(absolute_msys_path(&lib_path));
run_command(Command::new("rsync").args([
"-a",
"--delete",
"--exclude-from",
"qt/bundle/qt.exclude",
&src_path,
&dst_path,
]));
}
fn copy_linux_extras(kind: DistKind, folder_root: &Utf8Path) {
// add README, installer, etc
run_command(Command::new("rsync").args(["-a", "qt/bundle/lin/", &with_slash(folder_root)]));
// add extra IME plugins from download
let lib_path = folder_root.join("lib");
let src_path = folder_root
.join("../../extracted/linux_qt_plugins")
.join(match kind {
DistKind::Standard => "qt6",
DistKind::Alternate => "qt5",
});
let dst_path = lib_path.join(match kind {
DistKind::Standard => "PyQt6/Qt6/plugins",
DistKind::Alternate => "PyQt5/Qt5/plugins",
});
run_command(Command::new("rsync").args(["-a", &with_slash(src_path), &with_slash(dst_path)]));
}
fn copy_windows_extras(folder_root: &Utf8Path) {
run_command(Command::new("rsync").args([
"-a",
"out/extracted/win_amd64_audio/",
&with_slash(folder_root),
]));
}
fn clean_top_level_files(folder_root: &Utf8Path) {
let mut to_remove = vec![];
for entry in fs::read_dir(folder_root).unwrap() {
let entry = entry.unwrap();
if entry.file_name() == "lib" {
continue;
} else {
to_remove.push(entry.path());
}
}
for path in to_remove {
if path.is_dir() {
fs::remove_dir_all(path).unwrap()
} else {
fs::remove_file(path).unwrap()
}
}
}
fn with_slash<P>(path: P) -> String
where
P: AsRef<str>,
{
format!("{}/", path.as_ref())
}
fn copy_binary_and_pylibs(folder_root: &Utf8Path) {
let binary = folder_root
.join("../rust")
.join(env!("TARGET"))
.join("release")
.join(if cfg!(windows) { "anki.exe" } else { "anki" });
let extra_files = folder_root
.join("../build")
.join(env!("TARGET"))
.join("release/resources/extra_files");
run_command(Command::new("rsync").args([
"-a",
"--exclude",
"PyQt6",
// misleading, as it misses the GPL PyQt, and our Rust/JS
// dependencies
"--exclude",
"COPYING.txt",
&unix_path(&binary),
&with_slash(unix_path(&extra_files)),
&with_slash(unix_path(folder_root)),
]));
let google_py = if cfg!(windows) {
folder_root.join("../pyenv/lib/site-packages/google")
} else {
folder_root.join("../pyenv/lib/python3.9/site-packages/google")
};
run_command(Command::new("rsync").args([
"-a",
&unix_path(&google_py),
&with_slash(unix_path(&folder_root.join("lib"))),
]));
}

View file

@ -7,7 +7,6 @@
mod archive;
mod build;
mod bundle;
mod paths;
mod pyenv;
mod rsync;
@ -19,11 +18,6 @@ use archive::archive_command;
use archive::ArchiveArgs;
use build::run_build;
use build::BuildArgs;
use bundle::artifacts::build_artifacts;
use bundle::artifacts::BuildArtifactsArgs;
use bundle::binary::build_bundle_binary;
use bundle::folder::build_dist_folder;
use bundle::folder::BuildDistFolderArgs;
use clap::Parser;
use clap::Subcommand;
use pyenv::setup_pyenv;
@ -48,9 +42,6 @@ enum Command {
Rsync(RsyncArgs),
Run(RunArgs),
Build(BuildArgs),
BuildArtifacts(BuildArtifactsArgs),
BuildBundleBinary,
BuildDistFolder(BuildDistFolderArgs),
#[clap(subcommand)]
Archive(ArchiveArgs),
}
@ -62,9 +53,6 @@ fn main() -> Result<()> {
Command::Rsync(args) => rsync_files(args),
Command::Yarn(args) => setup_yarn(args),
Command::Build(args) => run_build(args),
Command::BuildArtifacts(args) => build_artifacts(args),
Command::BuildBundleBinary => build_bundle_binary(),
Command::BuildDistFolder(args) => build_dist_folder(args),
Command::Archive(args) => archive_command(args)?,
};
Ok(())

View file

@ -16,8 +16,3 @@ pub fn absolute_msys_path(path: &Utf8Path) -> String {
// and \ -> /
format!("/{drive}/{}", path[7..].replace('\\', "/"))
}
/// Converts backslashes to forward slashes
pub fn unix_path(path: &Utf8Path) -> String {
path.as_str().replace('\\', "/")
}

View file

@ -1,6 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::fs;
use std::process::Command;
use camino::Utf8Path;
@ -10,12 +11,10 @@ use crate::run::run_command;
#[derive(Args)]
pub struct PyenvArgs {
python_bin: String,
uv_bin: String,
pyenv_folder: String,
initial_reqs: String,
reqs: Vec<String>,
#[arg(long, allow_hyphen_values(true))]
venv_args: Vec<String>,
#[arg(trailing_var_arg = true)]
extra_args: Vec<String>,
}
/// Set up a venv if one doesn't already exist, and then sync packages with
@ -23,35 +22,32 @@ pub struct PyenvArgs {
pub fn setup_pyenv(args: PyenvArgs) {
let pyenv_folder = Utf8Path::new(&args.pyenv_folder);
let pyenv_bin_folder = pyenv_folder.join(if cfg!(windows) { "scripts" } else { "bin" });
let pyenv_python = pyenv_bin_folder.join("python");
let pip_sync = pyenv_bin_folder.join("pip-sync");
if !pyenv_python.exists() {
run_command(
Command::new(&args.python_bin)
.args(["-m", "venv"])
.args(args.venv_args)
.arg(pyenv_folder),
);
if cfg!(windows) {
// the first install on Windows throws an error the first time pip is upgraded,
// so we install it twice and swallow the first error
let _output = Command::new(&pyenv_python)
.args(["-m", "pip", "install", "-r", &args.initial_reqs])
.output()
.unwrap();
// On first run, ninja creates an empty bin/ folder which breaks the initial
// install. But we don't want to indiscriminately remove the folder, or
// macOS Gatekeeper needs to rescan the files each time.
if pyenv_folder.exists() {
let cache_tag = pyenv_folder.join("CACHEDIR.TAG");
if !cache_tag.exists() {
fs::remove_dir_all(pyenv_folder).expect("Failed to remove existing pyenv folder");
}
run_command(Command::new(pyenv_python).args([
"-m",
"pip",
"install",
"-r",
&args.initial_reqs,
]));
}
run_command(Command::new(pip_sync).args(&args.reqs));
let mut command = Command::new(args.uv_bin);
// remove UV_* environment variables to avoid interference
for (key, _) in std::env::vars() {
if key.starts_with("UV_") || key == "VIRTUAL_ENV" {
command.env_remove(key);
}
}
run_command(
command
.env("UV_PROJECT_ENVIRONMENT", args.pyenv_folder.clone())
.args(["sync", "--locked", "--no-config"])
.args(args.extra_args),
);
// Write empty stamp file
fs::write(pyenv_folder.join(".stamp"), "").expect("Failed to write stamp file");
}

View file

@ -1,7 +1,6 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::io::ErrorKind;
use std::process::Command;
use anki_io::create_dir_all;
@ -44,7 +43,7 @@ fn split_env(s: &str) -> Result<(String, String), std::io::Error> {
if let Some((k, v)) = s.split_once('=') {
Ok((k.into(), v.into()))
} else {
Err(std::io::Error::new(ErrorKind::Other, "invalid env var"))
Err(std::io::Error::other("invalid env var"))
}
}
@ -84,7 +83,7 @@ fn split_args(args: Vec<String>) -> Vec<Vec<String>> {
pub fn run_command(command: &mut Command) {
if let Err(err) = command.ensure_success() {
println!("{}", err);
println!("{err}");
std::process::exit(1);
}
}

View file

@ -28,7 +28,11 @@ pub fn setup_yarn(args: YarnArgs) {
.arg("--ignore-scripts"),
);
} else {
run_command(Command::new(&args.yarn_bin).arg("install"));
run_command(
Command::new(&args.yarn_bin)
.arg("install")
.arg("--immutable"),
);
}
std::fs::write(args.stamp, b"").unwrap();

View file

@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2023-09-02"
channel = "nightly-2025-03-20"
profile = "minimal"
components = ["rustfmt"]

File diff suppressed because it is too large Load diff

View file

@ -3,32 +3,29 @@
For info on contributing things other than code, such as translations, decks
and add-ons, please see https://docs.ankiweb.net/contrib
With most users now on 2.1, the past 2 years have been focused on paying down some
of the technical debt that Anki's codebase has built up over the years, and making
changes that will make future maintenance and refactoring easier. A lot of Anki's
"business logic" has been migrated to Rust, which AnkiMobile and AnkiDroid
can also take advantage of - previously a lot of effort was wasted writing the same
code for each platform, and then debugging differences in the implementations.
Considerable effort has also been put into improving the Python side of things,
with type hints added to the majority of the codebase, automatic linting/formatting,
and refactoring of parts of the code.
The import/export code remains to be done, and this will likely
take a number of months to work through. Until that is complete, new features
will not be the top priority, unless they are easy wins as part of the refactoring
process.
If you are planning to contribute any non-trivial changes, please reach out
on the support site before you begin work. Some areas (primarily pylib/) are
likely to change/conflict with other work, and larger changes will likely need
to wait until the refactoring process is done.
## Help wanted
If you'd like to contribute but don't know what to work on, please take a look
at the [issues tab](https://github.com/ankitects/anki/issues) of the Anki repo
on GitHub.
## Larger changes
Before starting work on larger changes, especially ones that aren't listed on the
issue tracker, please reach out on the forums before you begin work, so we can let
you know whether they're likely to be accepted or not. When you spent a bunch of time
on a PR that ends up getting rejected, it's no fun for either you or us.
## Refactoring
Please avoid PRs that focus on refactoring. Every PR has a cost to review, and a chance
of introducing accidental regressions, and often these costs are not worth it for
slightly more elegant code.
That's not to say there's no value in refactoring. But such changes are usually better done
in a PR that happens to be working in the same area - for example, making small changes
to the code as part of fixing a bug, or a larger refactor when introducing a new feature.
## Type hints
Most of Anki's Python code now has type hints, which improve code completion,

View file

@ -61,6 +61,8 @@ This will build Anki and run it in place.
The first build will take a while, as it downloads and builds a bunch of
dependencies. When the build is complete, Anki will automatically start.
If Anki fails to start, you may need to install [extra libraries](https://docs.ankiweb.net/platform/linux/missing-libraries.html).
## Running tests/checks
To run all tests at once, from the top-level folder:
@ -83,7 +85,7 @@ When formatting issues are reported, they can be fixed with
./ninja format
```
## Fixing eslint/copyright header issues
## Fixing ruff/eslint/copyright header issues
```
./ninja fix
@ -131,7 +133,7 @@ To build wheels on Mac/Linux:
The generated wheels are in out/wheels. You can then install them by copying the paths into a pip install command.
Follow the steps [on the beta site](https://betas.ankiweb.net/#via-pypipip), but replace the
`pip install --upgrade --pre aqt[qt6]` line with something like:
`pip install --upgrade --pre aqt` line with something like:
```
/my/pyenv/bin/pip install --upgrade out/wheels/*.whl
@ -139,18 +141,6 @@ Follow the steps [on the beta site](https://betas.ankiweb.net/#via-pypipip), but
(On Windows you'll need to list out the filenames manually instead of using a wildcard).
You'll also need to install PyQt:
```
$ /my/pyenv/bin/pip install pyqt6 pyqt6-webengine
```
or
```
$ my/pyenv/bin/pip install pyqt5 pyqtwebengine
```
## Cleaning up build files
Apart from submodule checkouts, most build files go into the `out/` folder (and
@ -200,13 +190,10 @@ in the collection2.log file will also be printed on stdout.
If ANKI_PROFILE_CODE is set, Python profiling data will be written on exit.
# Binary Bundles
# Installer/launcher
Anki's official binary packages are created with `./ninja bundle`. The bundling
process was created specifically for the official builds, and is provided as-is;
we are unfortunately not able to provide assistance with any issues you may run
into when using it. You'll need to run
`git submodule update --checkout qt/bundle/PyOxidizer` first.
- The anki-release package is created/published with the scripts in qt/release.
- The installer/launcher is created with the build scripts in qt/launcher/{platform}.
## Mixing development and study

View file

@ -1,35 +1,78 @@
# This Dockerfile uses three stages.
# 1. Compile anki (and dependencies) and build python wheels.
# 2. Create a virtual environment containing anki and its dependencies.
# 3. Create a final image that only includes anki's virtual environment and required
# system packages.
# This is a user-contributed Dockerfile. No official support is available.
ARG PYTHON_VERSION="3.9"
ARG DEBIAN_FRONTEND="noninteractive"
# Build anki.
FROM python:$PYTHON_VERSION AS build
RUN curl -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.7.4/bazelisk-linux-amd64 \
> /usr/local/bin/bazel \
&& chmod +x /usr/local/bin/bazel \
# Bazel expects /usr/bin/python
&& ln -s /usr/local/bin/python /usr/bin/python
FROM ubuntu:24.04 AS build
WORKDIR /opt/anki
COPY . .
# Build python wheels.
ENV PYTHON_VERSION="3.13"
# System deps
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
git \
build-essential \
pkg-config \
libssl-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
libffi-dev \
zlib1g-dev \
liblzma-dev \
ca-certificates \
ninja-build \
rsync \
libglib2.0-0 \
libgl1 \
libx11-6 \
libxext6 \
libxrender1 \
libxkbcommon0 \
libxkbcommon-x11-0 \
libxcb1 \
libxcb-render0 \
libxcb-shm0 \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-randr0 \
libxcb-shape0 \
libxcb-xfixes0 \
libxcb-xinerama0 \
libxcb-xinput0 \
libsm6 \
libice6 \
&& rm -rf /var/lib/apt/lists/*
# install rust with rustup
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Install uv and Python 3.13 with uv
RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
&& ln -s /root/.local/bin/uv /usr/local/bin/uv
ENV PATH="/root/.local/bin:${PATH}"
RUN uv python install ${PYTHON_VERSION} --default
COPY . .
RUN ./tools/build
# Install pre-compiled Anki.
FROM python:${PYTHON_VERSION}-slim as installer
FROM python:3.13-slim AS installer
WORKDIR /opt/anki/
COPY --from=build /opt/anki/wheels/ wheels/
COPY --from=build /opt/anki/out/wheels/ wheels/
# Use virtual environment.
RUN python -m venv venv \
&& ./venv/bin/python -m pip install --no-cache-dir setuptools wheel \
&& ./venv/bin/python -m pip install --no-cache-dir /opt/anki/wheels/*.whl
# We use another build stage here so we don't include the wheels in the final image.
FROM python:${PYTHON_VERSION}-slim as final
FROM python:3.13-slim AS final
COPY --from=installer /opt/anki/venv /opt/anki/venv
ENV PATH=/opt/anki/venv/bin:$PATH
# Install run-time dependencies.
@ -59,9 +102,9 @@ RUN apt-get update \
libxrender1 \
libxtst6 \
&& rm -rf /var/lib/apt/lists/*
# Add non-root user.
RUN useradd --create-home anki
USER anki
WORKDIR /work
ENTRYPOINT ["/opt/anki/venv/bin/anki"]
LABEL maintainer="Jakub Kaczmarzyk <jakub.kaczmarzyk@gmail.com>"
ENTRYPOINT ["/opt/anki/venv/bin/anki"]

84
docs/language_bridge.md Normal file
View file

@ -0,0 +1,84 @@
Anki's codebase uses three layers.
1. The web frontend, created in Svelte and typescript,
2. The Python layer and
3. The core Rust layer.
Each layer can can makes RPC (Remote Procedure Call) to the layers below it. While it should be avoided, Python can also invoke Typescript functions. The Rust layers never make calls to the other layers. Note that it can make RPC to AnkiWeb and other servers, which is out of scope of this document.
In this document we'll provide examples of bridge between languages, explaining:
- where the RPC is declared,
- where it is called (with the appropriate imports) and
- where it is implemented.
Imitating those examples should allow you to make call and create new RPCs.
## Declaring RPCs
Let's consider the method `NewDeck` of `DecksServices`. It's declared in [decks.proto](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/proto/anki/decks.proto#L14) as `rpc NewDeck(generic.Empty) returns (Deck);`. This means this methods takes no argument (technically, an argument containing no information), and returns a [`Deck`](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/proto/anki/decks.proto#L54).
Read [protobuf](./protobuf.md) to learn more about how those input and output types are defined.
If the RPC implementation is in Python, it should be declared in the service [frontend.proto](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/proto/anki/frontend.proto#L24C3-L24C66)'s `FrontendService`. RPCs declared in any other services are implemented in Rust.
## Making a Remote Procedure Call
In this section we'll consider how to make Remote Procedure Call (RPC) from languages used in Anki. Languages used for AnkiDroid and AnkiMobile are out of scope of this document.
### Making a RPC from Python
Python can invoke the `NewDeck` method with [`col._backend.new_deck()`](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/pylib/anki/decks.py#L168). This python method takes no argument and returns a `Deck` value.
However, most Python code should not call this method directly. Instead it should call [`col.decks.new_deck()`](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/pylib/anki/decks.py#L166). Generally speaking, all back-end functions called from Python should be called through a helper method defined in `pylib/anki/`. The `_backend` part is an implementation detail that most callers should ignore. This is especially important because add-ons should expect a relatively stable API independent of the implementation details of the RPC.
### Invoking method from TypeScript
Let's consider the method [`rpc GetCsvMetadata(CsvMetadataRequest) returns (CsvMetadata);`](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/proto/anki/import_export.proto#L20) from `ImportExportService`..
It's used in the TypeScript class [`ImportCsvState`](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/ts/routes/import-csv/lib.ts#L102), as an asynchronous function. It's argument is a single javascript object, whose keys are as in [`CsvMetadataRequest`](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/proto/anki/import_export.proto#L138) and it returns a `CsvMetadata`.
The method was imported with `import { getCsvMetadata } from "@generated/backend";` and the types were imported with `import type { CsvMetadata } from "@generated/anki/import_export_pb";`. Note that it was not necessary to import the input type given that it's simply an untyped javascript object.
## Implementation
Let's now look at implementations of those RPCs.
### Implementation in Rust
The method NewDeck is implemented in Rust's [DecksService](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/rslib/src/decks/service.rs#L21) as `fn new_deck(&mut self) -> error::Result<anki_proto::decks::Deck>`. It should be noted that the method name was changed from Pascal case to snake case, and the rps's argument of type `generic.Empty` is ignored.
### Implementation in Python
Let's consider the implementation of the method [DeckOptionsRequireClose](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/qt/aqt/mediasrv.py#L578). It's defined as `def deck_options_require_close() -> bytes:`. In this case, there should be a returned value. However, it'll be ignored, so returning `b""` is perfectly fine.
Note that the incoming HTTP request is not processed on the main thread. In order to do any work with the GUI, we should call `aqt.mw.taskman.run_on_main`.
## Invoking a TypeScript method from Python
This case should be avoided if possible, as we generally should avoid
calls to the upper layer. Contrary to the previous cases, we don't use
protobuf.
### Calling a TS function.
Let's take as Example [`export function getTypedAnswer(): string | null`](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/ts/reviewer/index.ts#L35). It's an exported function, and its return type can be encoded in JSON.
It's called in the Reviewer class through [`self.web.evalWithCallback("getTypedAnswer();", self._onTypedAnswer)`](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/qt/aqt/reviewer.py#L785). The result is then sent to [`_onTypedAnswer`](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/qt/aqt/reviewer.py#L787).
If no return value is needed, `web.eval` would have been sufficient.
### Calling a Svelte method
Let's now consider the case where the method we want to call is implemented in a Svelte library. Let's take as example [`deckOptionsPendingChanges`](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/ts/routes/deck-options/%5BdeckId%5D/%2Bpage.svelte#L17). We define it with:
```js
globalThis.anki || = {};
globalThis.anki.methodName = async (): Promise<void>=>{body}
```
Note that if the function is asynchronous, you can't directly send the
result to a callback. Instead your function will have to call a post
method that will be sent to Python or Rust.
This method is called in [deckoptions.py](https://github.com/ankitects/anki/blob/acaeee91fa853e4a7a78dcddbb832d009ec3529a/qt/aqt/deckoptions.py#L68) with `self.web.eval("anki.deckOptionsPendingChanges();"`.

View file

@ -8,24 +8,16 @@ mentioned there no longer apply:
https://forums.ankiweb.net/t/guide-how-to-build-and-run-anki-from-source-with-xubuntu-20-04/12865
You can see a full list of buildtime and runtime requirements by looking at the
[Dockerfiles](../.buildkite/linux/docker/Dockerfile.amd64) used to build the
[Dockerfile](../.buildkite/linux/docker/Dockerfile) used to build the
official releases.
Glibc is required - if you are on a distro like Alpine that uses musl, things
may not work.
Users on ARM64, see the notes at the bottom of this file before proceeding.
**Ensure some basic tools are installed**:
```
$ sudo apt install bash grep findutils curl gcc g++ make git rsync ninja-build
$ sudo apt install bash grep findutils curl gcc g++ make git rsync
```
- The 'find' utility is 'findutils' on Debian.
- Your distro may call the package 'ninja' instead of 'ninja-build', or it
may not have a version new enough - if so, install from the zip mentioned in
development.md.
## Missing Libraries
@ -53,15 +45,17 @@ error while loading shared libraries: libcrypt.so.1: cannot open shared object f
To play and record audio during development, install mpv and lame.
## ARM64 support
## Glibc and Qt
Other platforms download PyQt binary wheels from PyPI. There are no PyQt wheels available
for ARM Linux, so you will need to rely on your system-provided libraries instead. Your distro
will need to have Python 3.9 or later.
Anki requires a recent glibc.
After installing the system libraries (eg 'sudo apt install python3-pyqt5.qtwebengine python3-venv'),
If you are using a distro that uses musl, Anki will not work.
You can use your system's Qt libraries if they are Qt 6.2 or later, if
you wish. After installing the system libraries (eg:
'sudo apt install python3-pyqt6.qt{quick,webengine} python3-venv pyqt6-dev-tools'),
find the place they are installed (eg '/usr/lib/python3/dist-packages'). On modern Ubuntu, you'll
need 'sudo apt remove python3-protobuf'. Then before running any commands like './run', tell Anki where
also need 'sudo apt remove python3-protobuf'. Then before running any commands like './run', tell Anki where
the packages can be found:
```
@ -69,13 +63,6 @@ export PYTHONPATH=/usr/lib/python3/dist-packages
export PYTHON_BINARY=/usr/bin/python3
```
There are a few things to be aware of:
- You should use ./run and not tools/run-qt5\*, even if your system libraries are Qt5.
- If your system libraries are Qt5, when creating an aqt wheel, the wheel will not work
on Qt6 environments.
- Some of the './ninja check' tests are broken on ARM Linux.
## Packaging considerations
Python, node and protoc are downloaded as part of the build. You can optionally define

View file

@ -1,3 +1,9 @@
ProtoBuf is a format used both to save data in storage and transmit
data between services. You can think of it as similar to JSON with
schemas, given that you can use basic types, list and records. Except
that it's usually transmitted and saved in an efficient byteform and
not in a human readable way.
# Protocol Buffers
Anki uses [different implementations of Protocol Buffers](./architecture.md#protobuf)
@ -92,12 +98,6 @@ should preferably be assigned a number between 1 and 15. If a message contains
Protobuf has an official Python implementation with an extensive [reference](https://developers.google.com/protocol-buffers/docs/reference/python-generated).
- Every message used in aqt or pylib must be added to the respective `.pylintrc`
to avoid failing type checks. The unqualified protobuf message's name must be
used, not an alias from `collection.py` for example. This should be taken into
account when choosing a message name in order to prevent skipping typechecking
a Python class of the same name.
### Typescript
Anki uses [protobuf-es](https://github.com/bufbuild/protobuf-es), which offers

View file

@ -1,32 +1,40 @@
FROM rust:1.76-alpine3.19 AS builder
FROM rust:1.85.0-alpine3.20 AS builder
ARG ANKI_VERSION
RUN apk update && apk add --no-cache build-base protobuf && rm -rf /var/cache/apk/*
RUN cargo install --git https://github.com/ankitects/anki.git \
--tag ${ANKI_VERSION} \
--root /anki-server \
anki-sync-server
--tag ${ANKI_VERSION} \
--root /anki-server \
--locked \
anki-sync-server
FROM alpine:3.19.1
FROM alpine:3.21.0
RUN adduser -D -h /home/anki anki
# Default PUID and PGID values (can be overridden at runtime). Use these to
# ensure the files on the volume have the permissions you need.
ENV PUID=1000
ENV PGID=1000
COPY --from=builder /anki-server/bin/anki-sync-server /usr/local/bin/anki-sync-server
RUN apk update && apk add --no-cache bash su-exec && rm -rf /var/cache/apk/*
RUN apk update && apk add --no-cache bash && rm -rf /var/cache/apk/*
USER anki
EXPOSE 8080
ENV SYNC_PORT=${SYNC_PORT:-"8080"}
EXPOSE ${SYNC_PORT}
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["anki-sync-server"]
# TODO - consider exposing endpoint /health to check on health cause currently it will return 404 error
# HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
# CMD wget -qO- http://localhost:${SYNC_PORT} || exit 1
# This health check will work for Anki versions 24.08.x and newer.
# For older versions, it may incorrectly report an unhealthy status, which should not be the case.
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget -qO- http://127.0.0.1:8080/health || exit 1
LABEL maintainer="Jean Khawand <jk@jeankhawand.com>"
VOLUME /anki_data
LABEL maintainer="Jean Khawand <jk@jeankhawand.com>"

View file

@ -0,0 +1,33 @@
FROM rust:1.85.0 AS builder
ARG ANKI_VERSION
RUN apt-get update && apt-get install -y build-essential protobuf-compiler && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN cargo install --git https://github.com/ankitects/anki.git \
--tag ${ANKI_VERSION} \
--root /anki-server \
--locked \
anki-sync-server
FROM gcr.io/distroless/cc-debian12
COPY --from=builder /anki-server/bin/anki-sync-server /usr/bin/anki-sync-server
# Note that as a user of the container you should NOT overwrite these values
# for safety and simplicity reasons
ENV SYNC_PORT=8080
ENV SYNC_BASE=/anki_data
EXPOSE ${SYNC_PORT}
CMD ["anki-sync-server"]
# This health check will work for Anki versions 24.08.x and newer.
# For older versions, it may incorrectly report an unhealthy status, which should not be the case.
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD ["anki-sync-server", "--healthcheck"]
VOLUME /anki_data
LABEL maintainer="Jean Khawand <jk@jeankhawand.com>"

View file

@ -10,13 +10,27 @@ the build products and runtime dependencies from the rest of your system.
- [x] [Docker](https://docs.docker.com/get-started/)
| **Aspect** | **Dockerfile** | **Dockerfile.distroless** |
| ---------------------- | ---------------------------------------------------------- | --------------------------------------------------------- |
| **Shell & Tools** | ✅ Includes shell and tools | ❌ Minimal, no shell or tools |
| **Debugging** | ✅ Easier debugging with shell and tools | ❌ Harder to debug due to minimal environment |
| **Health Checks** | ✅ Supports complex health checks | ❌ Health checks need to be simple or directly executable |
| **Image Size** | ❌ Larger image size | ✅ Smaller image size |
| **Customization** | ✅ Easier to customize with additional packages | ❌ Limited customization options |
| **Attack Surface** | ❌ Larger attack surface due to more installed packages | ✅ Reduced attack surface |
| **Libraries** | ✅ More libraries available | ❌ Limited libraries |
| **Start-up Time** | ❌ Slower start-up time due to larger image size | ✅ Faster start-up time |
| **Tool Compatibility** | ✅ Compatible with more tools and libraries | ❌ Compatibility limitations with certain tools |
| **Maintenance** | ❌ Higher maintenance due to larger image and dependencies | ✅ Lower maintenance with minimal base image |
| **Custom uid/gid** | ✅ It's possible to pass in PUID and PGID | ❌ PUID and PGID are not supported |
# Building image
To proceed with building, you must specify the Anki version you want, by replacing `<version>` with something like `23.12.1`.
To proceed with building, you must specify the Anki version you want, by replacing `<version>` with something like `24.11` and `<Dockerfile>` with the chosen Dockerfile (e.g., `Dockerfile` or `Dockerfile.distroless`)
```bash
# Ensure you are running this command inside /docs/syncserver
docker build --no-cache --build-arg ANKI_VERSION=<version> -t anki-sync-server .
# Execute this command from this directory
docker build -f <Dockerfile> --no-cache --build-arg ANKI_VERSION=<version> -t anki-sync-server .
```
# Run container
@ -25,14 +39,57 @@ Once done with build, you can proceed with running this image with the following
```bash
# this will create anki server
docker run -d -e "SYNC_USER1=admin:admin" -p 8080:8080 --name anki-sync-server anki-sync-server
docker run -d \
-e "SYNC_USER1=admin:admin" \
-p 8080:8080 \
--mount type=volume,src=anki-sync-server-data,dst=/anki_data \
--name anki-sync-server \
anki-sync-server
```
However, if you want to have multiple users, you have to use the following approach:
If the image you are using was built with `Dockerfile` you can specify the
`PUID` and `PGID` env variables for the user and group id of the process that
will run the anki-sync-server process. This is valuable when you want the files
written and read from the `/anki_data` volume to belong to a particular
user/group e.g. to access it from the host or another container. Note the the
ids chosen for `PUID` and `PGID` must not already be in use inside the
container (1000 and above is fine). For example add `-e "PUID=1050"` and `-e
"PGID=1050"` to the above command.
If you want to have multiple Anki users that can sync their devices, you can
specify multiple `SYNC_USER` as follows:
```bash
# this will create anki server with multiple users
docker run -d -e "SYNC_USER1=test:test" -e "SYNC_USER2=test2:test2" -p 8080:8080 --name anki-sync-server anki-sync-server
docker run -d \
-e "SYNC_USER1=admin:admin" \
-e "SYNC_USER2=admin2:admin2" \
-p 8080:8080 \
--mount type=volume,src=anki-sync-server-data,dst=/anki_data \
--name anki-sync-server \
anki-sync-server
```
Moreover, you can pass additional env vars mentioned [here](https://docs.ankiweb.net/sync-server.html)
Moreover, you can pass additional env vars mentioned
[here](https://docs.ankiweb.net/sync-server.html). Note that `SYNC_BASE` and
`SYNC_PORT` will be ignored. In the first case for safety reasons, to avoid
accidentally placing data outside the volume and the second for simplicity
since the internal port of the container does not matter given that you can
change the external one.
# Upgrading
If your image was built after January 2025 then you can just build a new image
and start a new container with the same configuration as the previous
container. Everything should work as expected.
If the image you were running was built **before January 2025** then it did not
contain a volume, meaning all syncserver data was stored inside the container.
If you discard the container, for example because you want to build a new
container using an updated image, then your syncserver data will be lost.
The easiest way of working around this is by ensuring at least one of your
devices is fully in sync with your syncserver before upgrading the Docker
container. Then after upgrading the container when you try to sync your device
it will tell you that the server has no data. You will then be given the option
of uploading all local data from the device to syncserver.

View file

@ -0,0 +1,30 @@
#!/bin/sh
set -o errexit
set -o nounset
set -o pipefail
# Default PUID and PGID if not provided
export PUID=${PUID:-1000}
export PGID=${PGID:-1000}
# These values are fixed and cannot be overwritten from the outside for
# convenience and safety reasons
export SYNC_PORT=8080
export SYNC_BASE=/anki_data
# Check if group exists, create if not
if ! getent group anki-group > /dev/null 2>&1; then
addgroup -g "$PGID" anki-group
fi
# Check if user exists, create if not
if ! id -u anki > /dev/null 2>&1; then
adduser -D -H -u "$PUID" -G anki-group anki
fi
# Fix ownership of mounted volumes
mkdir -p /anki_data
chown anki:anki-group /anki_data
# Run the provided command as the `anki` user
exec su-exec anki "$@"

View file

@ -9,7 +9,12 @@ You must be running 64 bit Windows 10, version 1703 or newer.
**Rustup**:
As mentioned in development.md, rustup must be installed. If you're on
ARM Windows, you must set the default target to x86_64-pc-windows-msvc.
ARM Windows and install the ARM64 version of rust-up, from this project folder,
run
```
rustup target add x86_64-pc-windows-msvc
```
**Visual Studio**:

View file

@ -16,7 +16,6 @@ camino.workspace = true
clap.workspace = true
fluent-syntax.workspace = true
itertools.workspace = true
lazy_static.workspace = true
regex.workspace = true
serde_json.workspace = true
snafu.workspace = true

@ -1 +1 @@
Subproject commit c74c15b7f82c0f184910e5b6f695b635e6d81faf
Subproject commit 480ef0da728c7ea3485c58529ae7ee02be3e5dba

View file

@ -1,5 +1,17 @@
actions-add = Add
# Action in context menu:
# In the browser sidebar, when in "Select" mode, right-click on the
# selected criteria elements. In the context menu, click on "Search" to open
# a submenu. This entry in the submenu creates a search term that matches
# cards/notes meeting ALL of the selected criteria.
# https://github.com/ankitects/anki/pull/1044
actions-all-selected = All selected
# Action in context menu:
# In the browser sidebar, when in "Select" mode, right-click on the
# selected criteria elements. In the context menu, click on "Search" to open
# a submenu. This entry in the submenu creates a search term that matches
# cards/notes meeting ANY of the selected criteria.
# https://github.com/ankitects/anki/pull/1044
actions-any-selected = Any selected
actions-cancel = Cancel
actions-choose = Choose
@ -12,6 +24,7 @@ actions-decks = Decks
actions-decrement-value = Decrement value
actions-delete = Delete
actions-export = Export
actions-empty-cards = Empty Cards
actions-filter = Filter
actions-help = Help
actions-increment-value = Increment value
@ -37,6 +50,8 @@ actions-select = Select
actions-shortcut-key = Shortcut key: { $val }
actions-suspend-card = Suspend Card
actions-set-due-date = Set Due Date
actions-toggle-load-balancer = Toggle Load Balancer
actions-grade-now = Grade Now
actions-answer-card = Answer Card
actions-unbury-unsuspend = Unbury/Unsuspend
actions-add-deck = Add Deck
@ -47,9 +62,9 @@ actions-update-card = Update Card
actions-update-deck = Update Deck
actions-forget-card = Reset Card
actions-build-filtered-deck = Build Deck
actions-add-notetype = Add Notetype
actions-remove-notetype = Remove Notetype
actions-update-notetype = Update Notetype
actions-add-notetype = Add Note Type
actions-remove-notetype = Remove Note Type
actions-update-notetype = Update Note Type
actions-update-config = Update Config
actions-card-info = Card Info
actions-previous-card-info = Previous Card Info
@ -57,10 +72,12 @@ actions-previous-card-info = Previous Card Info
# input is required before it can be performed. E.g. "Export..." vs. "Delete".
actions-with-ellipsis = { $action }...
actions-fullscreen-unsupported = Full screen mode is not supported for your video driver. Try switching to a different one from the preferences screen.
## Flags
actions-flag-number = Flag { $number }
## The same translation may used for two independent actions:
## searching for cards with a flag of the specified color, and
## toggling the flag of the specified color on a card.
actions-flag-red = Red
actions-flag-orange = Orange
actions-flag-green = Green
@ -68,9 +85,13 @@ actions-flag-blue = Blue
actions-flag-pink = Pink
actions-flag-turquoise = Turquoise
actions-flag-purple = Purple
##
actions-set-flag = Set Flag
actions-nothing-to-undo = Nothing to undo
actions-nothing-to-redo = Nothing to redo
actions-auto-advance = Auto Advance
actions-auto-advance-activated = Auto Advance enabled
actions-auto-advance-deactivated = Auto Advance disabled
actions-processing = Processing...

View file

@ -7,6 +7,6 @@ adding-history = History
adding-note-deleted = (Note deleted)
adding-shortcut = Shortcut: { $val }
adding-the-first-field-is-empty = The first field is empty.
adding-you-have-a-cloze-deletion-note = You have a cloze notetype but have not made any cloze deletions. Proceed?
adding-cloze-outside-cloze-notetype = Cloze deletion can only be used on cloze notetypes.
adding-you-have-a-cloze-deletion-note = You have a cloze note type but have not made any cloze deletions. Proceed?
adding-cloze-outside-cloze-notetype = Cloze deletion can only be used on cloze note types.
adding-cloze-outside-cloze-field = Cloze deletion can only be used in fields which use the 'cloze:' filter. This is typically the first field.

View file

@ -28,8 +28,9 @@ browsing-cards-deleted-with-deckname =
browsing-change-deck = Change Deck
browsing-change-deck2 = Change Deck...
browsing-change-note-type = Change Note Type
# Action in a context menu (right mouse-click on a card type)
browsing-change-note-type2 = Change Note Type...
browsing-change-notetype = Change Notetype
browsing-change-notetype = Change Note Type
browsing-clear-unused-tags = Clear Unused Tags
browsing-confirm-saved-search-overwrite = A saved search with the name { $name } already exists. Do you want to overwrite it?
browsing-created = Created
@ -82,6 +83,7 @@ browsing-reschedule = Reschedule
browsing-search-bar-hint = Search cards/notes (type text, then press Enter)
browsing-search-in = Search in:
browsing-search-within-formatting-slow = Search within formatting (slow)
browsing-select-deck = Select Deck
browsing-selected-notes-only = Selected notes only
browsing-shift-position-of-existing-cards = Shift position of existing cards
browsing-sidebar = Sidebar
@ -141,7 +143,7 @@ browsing-tooltip-card-modified = The last time changes were made to a card, incl
browsing-tooltip-note-modified = The last time changes were made to a note, usually field content or tag edits
browsing-tooltip-card = The name of a card's card template
browsing-tooltip-cards = The number of cards a note has
browsing-tooltip-notetype = The name of a note's notetype
browsing-tooltip-notetype = The name of a note's note type
browsing-tooltip-question = The front side of a card, customisable in the card template editor
browsing-tooltip-answer = The back side of a card, customisable in the card template editor
browsing-studied-today = Studied

View file

@ -23,13 +23,25 @@ card-stats-review-log-type-review = Review
card-stats-review-log-type-relearn = Relearn
card-stats-review-log-type-filtered = Filtered
card-stats-review-log-type-manual = Manual
card-stats-review-log-type-rescheduled = Rescheduled
card-stats-review-log-elapsed-time = Elapsed Time
card-stats-no-card = (No card to display.)
card-stats-custom-data = Custom Data
card-stats-fsrs-stability = Stability
card-stats-fsrs-difficulty = Difficulty
card-stats-fsrs-retrievability = Retrievability
card-stats-fsrs-forgetting-curve-title = Forgetting Curve
card-stats-fsrs-forgetting-curve-first-week = First Week
card-stats-fsrs-forgetting-curve-first-month = First Month
card-stats-fsrs-forgetting-curve-first-year = First Year
card-stats-fsrs-forgetting-curve-all-time = All Time
card-stats-fsrs-forgetting-curve-desired-retention = Desired Retention
## Window Titles
card-stats-current-card = Current Card ({ $context })
card-stats-previous-card = Previous Card ({ $context })
## NO NEED TO TRANSLATE. This text is no longer used by Anki, and will be removed in the future.
card-stats-fsrs-forgetting-curve-probability-of-recalling = Probability of Recall

View file

@ -20,12 +20,13 @@ card-templates-night-mode = Night Mode
# on a mobile device.
card-templates-add-mobile-class = Add Mobile Class
card-templates-preview-settings = Options
card-templates-invalid-template-number = Card template { $number } in notetype '{ $notetype }' has a problem.
card-templates-invalid-template-number = Card template { $number } in note type '{ $notetype }' has a problem.
card-templates-identical-front = The front side is identical to card template { $number }.
card-templates-no-front-field = Expected to find a field replacement on the front of the card template.
card-templates-missing-cloze = Expected to find '{ "{{" }cloze:Text{ "}}" }' or similar on the front and back of the card template.
card-templates-extraneous-cloze = 'cloze:' can only be used on cloze notetypes.
card-templates-extraneous-cloze = 'cloze:' can only be used on cloze note types.
card-templates-see-preview = See the preview for more information.
card-templates-field-not-found = Field '{ $field }' not found.
card-templates-changes-saved = Changes saved.
card-templates-discard-changes = Discard changes?
card-templates-add-card-type = Add Card Type...
@ -36,6 +37,7 @@ card-templates-card = Card { $val }
card-templates-card-types-for = Card Types for { $val }
card-templates-cloze = Cloze { $val }
card-templates-deck-override = Deck Override...
card-templates-copy-info = Copy Info to Clipboard
card-templates-delete-the-as-card-type-and = Delete the '{ $template }' card type, and its { $cards }?
card-templates-enter-deck-to-place-new = Enter deck to place new { $val } cards in, or leave blank:
card-templates-enter-new-card-position-1 = Enter new card position (1...{ $val }):
@ -58,7 +60,6 @@ card-templates-this-will-create-card-proceed =
}
card-templates-type-boxes-warning = Only one typing box per card template is supported.
card-templates-restore-to-default = Restore to Default
card-templates-restore-to-default-confirmation = This will reset all fields and templates in this notetype to their default
values, removing any extra fields/templates and their content, and any custom styling. Do you wish to proceed?
card-templates-restored-to-default = Notetype has been restored to its original state.
card-templates-restore-to-default-confirmation = This will reset all fields and templates in this note type to their default values, removing any extra fields/templates and their content, and any custom styling. Do you wish to proceed?
card-templates-restored-to-default = Note type has been restored to its original state.

View file

@ -8,7 +8,7 @@ change-notetype-will-discard-cards = Will remove the following cards:
change-notetype-fields = Fields
change-notetype-templates = Templates
change-notetype-to-from-cloze =
When changing to or from a Cloze notetype, card numbers remain unchanged.
When changing to or from a Cloze note type, card numbers remain unchanged.
If changing to a regular notetype, and there are more cloze deletions
If changing to a regular note type, and there are more cloze deletions
than available card templates, any extra cards will be removed.

View file

@ -5,6 +5,11 @@ database-check-card-properties =
[one] Fixed { $count } invalid card property.
*[other] Fixed { $count } invalid card properties.
}
database-check-card-last-review-time-empty =
{ $count ->
[one] Added last review time to { $count } card.
*[other] Added last review time to { $count } cards.
}
database-check-missing-templates =
{ $count ->
[one] Deleted { $count } card with missing template.
@ -51,7 +56,7 @@ database-check-fixed-invalid-ids =
*[other] Fixed { $count } objects with timestamps in the future.
}
# "db-check" is always in English
database-check-notetypes-recovered = One or more notetypes were missing. The notes that used them have been given new notetypes starting with "db-check", but field names and card design have been lost, so you may be better off restoring from an automatic backup.
database-check-notetypes-recovered = One or more note types were missing. The notes that used them have been given new note types starting with "db-check", but field names and card design have been lost, so you may be better off restoring from an automatic backup.
## Progress info

View file

@ -24,7 +24,7 @@ deck-config-review-limit-tooltip =
if cards are ready for review.
deck-config-limit-deck-v3 =
When studying a deck that has subdecks inside it, the limits set on each
subdeck control the maximum number of cards drawn from that particular deck.
subdeck control the maximum number of cards gathered from that particular deck.
The selected deck's limits control the total cards that will be shown.
deck-config-limit-new-bound-by-reviews =
The review limit affects the new limit. For example, if your review limit is
@ -33,9 +33,9 @@ deck-config-limit-new-bound-by-reviews =
shown.
deck-config-limit-interday-bound-by-reviews =
The review limit also affects interday learning cards. When applying the limit,
interday learning cards are fetched first, then reviews.
interday learning cards are gathered first, then review cards.
deck-config-tab-description =
- `Preset`: The limit is shared with all decks using this preset.
- `Preset`: The limit applies to all decks using this preset.
- `This deck`: The limit is specific to this deck.
- `Today only`: Make a temporary change to this deck's limit.
deck-config-new-cards-ignore-review-limit = New cards ignore review limit
@ -45,9 +45,10 @@ deck-config-new-cards-ignore-review-limit-tooltip =
will be shown regardless of the review limit.
deck-config-apply-all-parent-limits = Limits start from top
deck-config-apply-all-parent-limits-tooltip =
By default, limits start from the deck you select. If this option is enabled, the limits will
By default, the daily limits of a higher-level deck do not apply if you're studying from its subdeck.
If this option is enabled, the limits will
start from the top-level deck instead, which can be useful if you wish to study individual
sub-decks, while enforcing a total limit on cards/day.
subdecks, while enforcing a total limit on cards for the deck tree.
deck-config-affects-entire-collection = Affects the entire collection.
## Daily limit tabs: please try to keep these as short as the English version,
@ -61,7 +62,7 @@ deck-config-today-only = Today only
deck-config-learning-steps = Learning steps
# Please don't translate `1m`, `2d`
-deck-config-delay-hint = Delays are typically minutes (eg `1m`) or days (eg `2d`), but hours (eg `1h`) and seconds (eg `30s`) are also supported.
-deck-config-delay-hint = Delays are typically minutes (e.g. `1m`) or days (e.g. `2d`), but hours (e.g. `1h`) and seconds (e.g. `30s`) are also supported.
deck-config-learning-steps-tooltip =
One or more delays, separated by spaces. The first delay will be used
when you press the `Again` button on a new card, and is 1 minute by default.
@ -82,7 +83,7 @@ deck-config-new-insertion-order-tooltip =
deck-config-new-insertion-order-sequential = Sequential (oldest cards first)
deck-config-new-insertion-order-random = Random
deck-config-new-insertion-order-random-with-v3 =
With the V3 scheduler, it is better to leave this set to sequential, and
With the v3 scheduler, it is better to leave this set to sequential, and
adjust the new card gather order instead.
## Lapses section
@ -100,7 +101,7 @@ deck-config-leech-threshold-tooltip =
think of a mnemonic to help you remember it.
# See actions-suspend-card and scheduling-tag-only for the wording
deck-config-leech-action-tooltip =
`Tag Only`: Add a "leech" tag to the note, and display a pop-up.
`Tag Only`: Add a 'leech' tag to the note, and display a pop-up.
`Suspend Card`: In addition to tagging the note, hide the card until it is
manually unsuspended.
@ -112,7 +113,7 @@ deck-config-bury-new-siblings = Bury new siblings
deck-config-bury-review-siblings = Bury review siblings
deck-config-bury-interday-learning-siblings = Bury interday learning siblings
deck-config-bury-new-tooltip =
Whether other `new` cards of the same note (eg reverse cards, adjacent cloze deletions)
Whether other `new` cards of the same note (e.g. reverse cards, adjacent cloze deletions)
will be delayed until the next day.
deck-config-bury-review-tooltip = Whether other `review` cards of the same note will be delayed until the next day.
deck-config-bury-interday-learning-tooltip =
@ -120,7 +121,7 @@ deck-config-bury-interday-learning-tooltip =
will be delayed until the next day.
deck-config-bury-priority-tooltip =
When Anki gathers cards, it first gathers intraday learning cards, then
interday learning cards, then reviews, and finally new cards. This affects
interday learning cards, then review cards, and finally new cards. This affects
how burying works:
- If you have all burying options enabled, the sibling that comes earliest in
@ -131,57 +132,44 @@ deck-config-bury-priority-tooltip =
learning or review cards, and you may see both a review sibling and new sibling in the
same session.
## Ordering section
## Gather order and sort order of cards
deck-config-ordering-title = Display Order
deck-config-new-gather-priority = New card gather order
deck-config-new-gather-priority-tooltip-2 =
`Deck`: gathers cards from each deck in order, starting from the top. Cards from each deck are
`Deck`: Gathers cards from each subdeck in order, starting from the top. Cards from each subdeck are
gathered in ascending position. If the daily limit of the selected deck is reached, gathering
may stop before all decks have been checked. This order is fastest in large collections, and
can stop before all subdecks have been checked. This order is fastest in large collections, and
allows you to prioritize subdecks that are closer to the top.
`Ascending position`: gathers cards by ascending position (due #), which is typically
`Ascending position`: Gathers cards by ascending position (due #), which is typically
the oldest-added first.
`Descending position`: gathers cards by descending position (due #), which is typically
`Descending position`: Gathers cards by descending position (due #), which is typically
the latest-added first.
`Random notes`: gathers cards of randomly selected notes. When sibling burying is
disabled, this allows all cards of a note to be seen in a session (eg. both a front->back
and back->front card)
`Random notes`: Picks notes at random, then gathers all of its cards.
`Random cards`: gathers cards completely randomly.
deck-config-new-gather-priority-deck = Deck
deck-config-new-gather-priority-deck-then-random-notes = Deck then random notes
deck-config-new-gather-priority-position-lowest-first = Ascending position
deck-config-new-gather-priority-position-highest-first = Descending position
deck-config-new-gather-priority-random-notes = Random notes
deck-config-new-gather-priority-random-cards = Random cards
`Random cards`: Gathers cards in a random order.
deck-config-new-card-sort-order = New card sort order
deck-config-new-card-sort-order-tooltip-2 =
`Card type`: Displays cards in order of card type number. If you have sibling burying
disabled, this will ensure all front→back cards are seen before any back→front cards.
`Card type, then order gathered`: Shows cards in order of card type number.
Cards of each card type number are shown in the order they were gathered.
If you have sibling burying disabled, this will ensure all front→back cards are seen before any back→front cards.
This is useful to have all cards of the same note shown in the same session, but not
too close to one another.
`Order gathered`: Shows cards exactly as they were gathered. If sibling burying is disabled,
this will typically result in all cards of a note being seen one after the other.
`Card type, then random`: Like `Card type`, but shuffles the cards of each card
type number. If you use `Ascending position` to gather the oldest cards, you could use
this setting to see those cards in a random order, but still ensure cards of the same
note do not end up too close to one another.
`Card type, then random`: Shows cards in order of card type number. Cards of each card
type number are shown in a random order. This order is useful if you don't want sibling cards
to appear too close to each other, but still want the cards to appear in a random order.
`Random note, then card type`: Picks notes at random, then shows all of their siblings
`Random note, then card type`: Picks notes at random, then shows all of its cards
in order.
`Random`: Fully shuffles the gathered cards.
deck-config-sort-order-card-template-then-random = Card type, then random
deck-config-sort-order-random-note-then-template = Random note, then card type
deck-config-sort-order-random = Random
deck-config-sort-order-template-then-gather = Card type
deck-config-sort-order-gather = Order gathered
`Random`: Shows cards in a random order.
deck-config-new-review-priority = New/review order
deck-config-new-review-priority-tooltip = When to show new cards in relation to review cards.
deck-config-interday-step-priority = Interday learning/review order
@ -189,11 +177,8 @@ deck-config-interday-step-priority-tooltip =
When to show (re)learning cards that cross a day boundary.
The review limit is always applied first to interday learning cards, and
then reviews. This option will control the order the gathered cards are shown in,
then review cards. This option will control the order the gathered cards are shown in,
but interday learning cards will always be gathered first.
deck-config-review-mix-mix-with-reviews = Mix with reviews
deck-config-review-mix-show-after-reviews = Show after reviews
deck-config-review-mix-show-before-reviews = Show before reviews
deck-config-review-sort-order = Review sort order
deck-config-review-sort-order-tooltip =
The default order prioritizes cards that have been waiting longest, so that
@ -201,45 +186,93 @@ deck-config-review-sort-order-tooltip =
first. If you have a large backlog that will take more than a few days to
clear, or wish to see cards in subdeck order, you may find the alternate
sort orders preferable.
deck-config-sort-order-due-date-then-random = Due date, then random
deck-config-sort-order-due-date-then-deck = Due date, then deck
deck-config-sort-order-deck-then-due-date = Deck, then due date
deck-config-sort-order-ascending-intervals = Ascending intervals
deck-config-sort-order-descending-intervals = Descending intervals
deck-config-sort-order-ascending-ease = Ascending ease
deck-config-sort-order-descending-ease = Descending ease
deck-config-sort-order-ascending-difficulty = Ascending difficulty
deck-config-sort-order-descending-difficulty = Descending difficulty
deck-config-sort-order-relative-overdueness = Relative overdueness
deck-config-display-order-will-use-current-deck =
Anki will use the display order from the deck you
select to study, and not any subdecks it may have.
## Gather order and sort order of cards Combobox entries
# Gather new cards ordered by deck.
deck-config-new-gather-priority-deck = Deck
# Gather new cards ordered by deck, then ordered by random notes, ensuring all cards of the same note are grouped together.
deck-config-new-gather-priority-deck-then-random-notes = Deck, then random notes
# Gather new cards ordered by position number, ascending (lowest to highest).
deck-config-new-gather-priority-position-lowest-first = Ascending position
# Gather new cards ordered by position number, descending (highest to lowest).
deck-config-new-gather-priority-position-highest-first = Descending position
# Gather the cards ordered by random notes, ensuring all cards of the same note are grouped together.
deck-config-new-gather-priority-random-notes = Random notes
# Gather new cards randomly.
deck-config-new-gather-priority-random-cards = Random cards
# Sort the cards first by their type, in ascending order (alphabetically), then randomized within each type.
deck-config-sort-order-card-template-then-random = Card type, then random
# Sort the notes first randomly, then the cards by their type, in ascending order (alphabetically), within each note.
deck-config-sort-order-random-note-then-template = Random note, then card type
# Sort the cards randomly.
deck-config-sort-order-random = Random
# Sort the cards first by their type, in ascending order (alphabetically), then by the order they were gathered, in ascending order (oldest to newest).
deck-config-sort-order-template-then-gather = Card type, then order gathered
# Sort the cards by the order they were gathered, in ascending order (oldest to newest).
deck-config-sort-order-gather = Order gathered
# How new cards or interday learning cards are mixed with review cards.
deck-config-review-mix-mix-with-reviews = Mix with reviews
# How new cards or interday learning cards are mixed with review cards.
deck-config-review-mix-show-after-reviews = Show after reviews
# How new cards or interday learning cards are mixed with review cards.
deck-config-review-mix-show-before-reviews = Show before reviews
# Sort the cards first by due date, in ascending order (oldest due date to newest), then randomly within the same due date.
deck-config-sort-order-due-date-then-random = Due date, then random
# Sort the cards first by due date, in ascending order (oldest due date to newest), then by deck within the same due date.
deck-config-sort-order-due-date-then-deck = Due date, then deck
# Sort the cards first by deck, then by due date in ascending order (oldest due date to newest) within the same deck.
deck-config-sort-order-deck-then-due-date = Deck, then due date
# Sort the cards by the interval, in ascending order (shortest to longest).
deck-config-sort-order-ascending-intervals = Ascending intervals
# Sort the cards by the interval, in descending order (longest to shortest).
deck-config-sort-order-descending-intervals = Descending intervals
# Sort the cards by ease, in ascending order (lowest to highest ease).
deck-config-sort-order-ascending-ease = Ascending ease
# Sort the cards by ease, in descending order (highest to lowest ease).
deck-config-sort-order-descending-ease = Descending ease
# Sort the cards by difficulty, in ascending order (easiest to hardest).
deck-config-sort-order-ascending-difficulty = Easy cards first
# Sort the cards by difficulty, in descending order (hardest to easiest).
deck-config-sort-order-descending-difficulty = Difficult cards first
# Sort the cards by retrievability percentage, in ascending order (0% to 100%, least retrievable to most easily retrievable).
deck-config-sort-order-retrievability-ascending = Ascending retrievability
# Sort the cards by retrievability percentage, in descending order (100% to 0%, most easily retrievable to least retrievable).
deck-config-sort-order-retrievability-descending = Descending retrievability
## Timer section
deck-config-timer-title = Timer
deck-config-timer-title = Timers
deck-config-maximum-answer-secs = Maximum answer seconds
deck-config-maximum-answer-secs-tooltip =
The maximum number of seconds to record for a single review. If an answer
exceeds this time (because you stepped away from the screen for example),
the time taken will be recorded as the limit you have set.
deck-config-show-answer-timer-tooltip =
In the review screen, show a timer that counts the number of seconds you're
taking to review each card.
deck-config-stop-timer-on-answer = Stop timer on answer
On the Study screen, show a timer that counts the time you're
taking to study each card.
deck-config-stop-timer-on-answer = Stop on-screen timer on answer
deck-config-stop-timer-on-answer-tooltip =
Whether to stop the timer when the answer is revealed.
Whether to stop the on-screen timer when the answer is revealed.
This doesn't affect statistics.
## Auto Advance section
deck-config-seconds-to-show-question = Seconds to show question for
deck-config-seconds-to-show-question-tooltip-2 = When auto advance is activated, the number of seconds to wait before revealing the answer. Set to 0 to disable.
deck-config-seconds-to-show-question-tooltip-3 = When auto advance is activated, the number of seconds to wait before applying the question action. Set to 0 to disable.
deck-config-seconds-to-show-answer = Seconds to show answer for
deck-config-seconds-to-show-answer-tooltip-2 = When auto advance is activated, the number of seconds to wait before applying the answer action. Set to 0 to disable.
deck-config-question-action-show-answer = Show Answer
deck-config-question-action-show-reminder = Show Reminder
deck-config-question-action = Question action
deck-config-question-action-tool-tip = The action to perform after the question is shown, and time has elapsed.
deck-config-answer-action = Answer action
deck-config-answer-action-tooltip = The action to perform on the current card before automatically advancing to the next one.
deck-config-wait-for-audio-tooltip = Wait for audio to finish before automatically revealing answer or next question
deck-config-answer-action-tooltip-2 = The action to perform after the answer is shown, and time has elapsed.
deck-config-wait-for-audio-tooltip-2 = Wait for audio to finish before automatically applying the question action or answer action.
## Audio section
@ -247,7 +280,7 @@ deck-config-audio-title = Audio
deck-config-disable-autoplay = Don't play audio automatically
deck-config-disable-autoplay-tooltip =
When enabled, Anki will not play audio automatically.
It can be played manually by clicking/tapping on an audio icon, or by using the replay audio action.
It can be played manually by clicking/tapping on an audio icon, or by using the Replay action.
deck-config-skip-question-when-replaying = Skip question when replaying answer
deck-config-always-include-question-audio-tooltip =
Whether the question audio should be included when the Replay action is
@ -275,6 +308,22 @@ deck-config-minimum-interval-tooltip = The minimum interval given to a review ca
deck-config-custom-scheduling = Custom scheduling
deck-config-custom-scheduling-tooltip = Affects the entire collection. Use at your own risk!
## Easy Days section.
deck-config-easy-days-title = Easy Days
deck-config-easy-days-monday = Mon
deck-config-easy-days-tuesday = Tue
deck-config-easy-days-wednesday = Wed
deck-config-easy-days-thursday = Thu
deck-config-easy-days-friday = Fri
deck-config-easy-days-saturday = Sat
deck-config-easy-days-sunday = Sun
deck-config-easy-days-normal = Normal
deck-config-easy-days-reduced = Reduced
deck-config-easy-days-minimum = Minimum
deck-config-easy-days-no-normal-days = At least one day should be set to '{ deck-config-easy-days-normal }'.
deck-config-easy-days-change = Existing reviews will not be rescheduled unless '{ deck-config-reschedule-cards-on-change }' is enabled in the FSRS options.
## Adding/renaming
deck-config-add-group = Add Preset
@ -296,7 +345,7 @@ deck-config-confirm-remove-name = Remove { $name }?
deck-config-save-button = Save
deck-config-save-to-all-subdecks = Save to All Subdecks
deck-config-save-and-optimize = Optimize All Presets
deck-config-revert-button-tooltip = Restore this setting to its default value.
deck-config-revert-button-tooltip = Restore this setting to its default value?
## These strings are shown via the Description button at the bottom of the
## overview screen.
@ -323,6 +372,8 @@ deck-config-learning-step-above-graduating-interval = The graduating interval sh
deck-config-good-above-easy = The easy interval should be at least as long as the graduating interval.
deck-config-relearning-steps-above-minimum-interval = The minimum lapse interval should be at least as long as your final relearning step.
deck-config-maximum-answer-secs-above-recommended = Anki can schedule your reviews more efficiently when you keep each question short.
deck-config-too-short-maximum-interval = A maximum interval less than 6 months is not recommended.
deck-config-ignore-before-info = (Approximately) { $included }/{ $totalCards } cards will be used to optimize the FSRS parameters.
## Selecting a deck
@ -331,10 +382,8 @@ deck-config-which-deck = Which deck would you like to display options for?
## Messages related to the FSRS scheduler
deck-config-updating-cards = Updating cards: { $current_cards_count }/{ $total_cards_count }...
deck-config-invalid-weights = Parameters must be either left blank to use the defaults, or must be 17 comma-separated numbers.
deck-config-invalid-parameters = The provided FSRS parameters are invalid. Leave them blank to use the default parameters.
deck-config-not-enough-history = Insufficient review history to perform this operation.
deck-config-unable-to-determine-desired-retention =
Unable to determine an optimal retention.
deck-config-must-have-400-reviews =
{ $count ->
[one] Only { $count } review was found.
@ -343,40 +392,37 @@ deck-config-must-have-400-reviews =
# Numbers that control how aggressively the FSRS algorithm schedules cards
deck-config-weights = FSRS parameters
deck-config-compute-optimal-weights = Optimize FSRS parameters
deck-config-compute-optimal-retention = Compute optimal retention
deck-config-optimize-button = Optimize
deck-config-optimize-button = Optimize Current Preset
# Indicates that a given function or label, provided via the "text" variable, operates slowly.
deck-config-slow-suffix = { $text } (slow)
deck-config-compute-button = Compute
deck-config-ignore-before = Ignore reviews before
deck-config-optimize-all-tip = You can optimize all presets at once by using the dropdown button next to "Save".
deck-config-ignore-before = Ignore cards reviewed before
deck-config-time-to-optimize = It's been a while - using the Optimize All Presets button is recommended.
deck-config-evaluate-button = Evaluate
deck-config-desired-retention = Desired retention
deck-config-historical-retention = Historical Retention
deck-config-historical-retention = Historical retention
deck-config-smaller-is-better = Smaller numbers indicate a better fit to your review history.
deck-config-steps-too-large-for-fsrs = When FSRS is enabled, steps of 1 day or more are not recommended.
deck-config-get-params = Get Params
deck-config-fsrs-on-all-clients =
Please ensure all of your Anki clients are Anki(Mobile) 23.10+ or AnkiDroid 2.17+. FSRS will
not work correctly if one of your clients is older.
deck-config-predicted-optimal-retention = Predicted optimal retention: { $num }
deck-config-complete = { $num }% complete.
deck-config-iterations = Iteration: { $count }...
deck-config-reschedule-cards-on-change = Reschedule cards on change
deck-config-fsrs-tooltip =
Affects the entire collection.
The Free Spaced Repetition Scheduler (FSRS) is an alternative to Anki's legacy SuperMemo 2 (SM2) scheduler.
By more accurately determining when you are likely to forget, it can help you remember
more material in the same amount of time. This setting is shared by all deck presets.
The Free Spaced Repetition Scheduler (FSRS) is an alternative to Anki's legacy SuperMemo 2 (SM-2) algorithm.
By more accurately determining how likely you are to forget a card, it can help you remember
more material in the same amount of time. This setting is shared by all presets.
If you previously used the 'custom scheduling' version of FSRS, please make
sure you clear out the custom scheduling section before enabling this option.
deck-config-desired-retention-tooltip =
The default value of 0.9 will schedule cards so you have a 90% chance of remembering them when
By default, Anki schedules cards so that you have a 90% chance of remembering them when
they come up for review again. If you increase this value, Anki will show cards more frequently
to increase the chances of you remembering them. If you decrease the value, Anki will show cards
less frequently, and you will forget more of them. Be conservative when adjusting this - higher
values will greatly increase your workload, and lower values can be demoralizing when you forget
a lot of material.
deck-config-desired-retention-tooltip2 =
The workload values provided by the info box are a rough approximation. For a greater level of accuracy, use the simulator.
deck-config-historical-retention-tooltip =
When some of your review history is missing, FSRS needs to fill in the gaps. By default, it will
assume that when you did those old reviews, you remembered 90% of the material. If your old retention
@ -384,16 +430,15 @@ deck-config-historical-retention-tooltip =
the missing reviews.
Your review history may be incomplete for two reasons:
1. Because you've used the 'ignore reviews before' option.
1. Because you're using the 'ignore cards reviewed before' option.
2. Because you previously deleted review logs to free up space, or imported material from a different
SRS program.
The latter is quite rare, so unless you've used the former option, you probably don't need to adjust
this setting.
deck-config-weights-tooltip =
FSRS parameters affect how cards are scheduled. Anki will start with default parameters. Once
you've accumulated 1000+ reviews, you can use the option below to optimize the parameters to best
match your performance in decks using this preset.
The latter is quite rare, so unless you're using the former option, you probably don't need to adjust
this option.
deck-config-weights-tooltip2 =
FSRS parameters affect how cards are scheduled. Anki will start with default parameters. You can use
the option below to optimize the parameters to best match your performance in decks using this preset.
deck-config-reschedule-cards-on-change-tooltip =
Affects the entire collection, and is not saved.
@ -403,44 +448,44 @@ deck-config-reschedule-cards-on-change-tooltip =
will be changed.
deck-config-reschedule-cards-warning =
Depending on your desired retention, this can result in a large number of cards becoming
due, so is not recommended when first switching from SM2.
due, so is not recommended when first switching from SM-2.
Use this option sparingly, as it will add a review entry to each of your cards, and
increase the size of your collection.
deck-config-ignore-before-tooltip =
If set, reviews before the provided date will be ignored when optimizing & evaluating FSRS parameters.
deck-config-ignore-before-tooltip-2 =
If set, cards reviewed before the provided date will be ignored when optimizing FSRS parameters.
This can be useful if you imported someone else's scheduling data, or have changed the way you use the answer buttons.
deck-config-compute-optimal-weights-tooltip =
Once you've done 1000+ reviews in Anki, you can use the Optimize button to analyze your review history,
and automatically generate parameters that are optimal for your memory and the content you're studying.
If you have decks that vary wildly in difficulty, it is recommended to assign them separate presets, as
the parameters for easy decks and hard decks will be different. There is no need to optimize your parameters
frequently - once every few months is sufficient.
deck-config-compute-optimal-weights-tooltip2 =
When you click the Optimize button, FSRS will analyze your review history, and generate parameters that are
optimal for your memory and the content you're studying. If your decks vary wildly in subjective difficulty, it
is recommended to assign them separate presets, as the parameters for easy decks and hard decks will be different.
You don't need to optimize your parameters frequently - once every few months is sufficient.
By default, parameters will be calculated from the review history of all decks using the current preset. You can
optionally adjust the search before calculating the parameters, if you'd like to alter which cards are used for
optimizing the parameters.
deck-config-compute-optimal-retention-tooltip2 =
This tool assumes that youre starting with 0 learned cards, and will attempt to find the desired retention
value that will lead to the most material learnt, in the least amount of time. This number can be used as a
reference when deciding what to set your desired retention to. You may wish to choose a higher desired retention,
if youre willing to trade more study time for a greater recall rate. Setting your desired retention lower than
the optimum is not recommended, as it will lead to more work without benefit.
deck-config-please-save-your-changes-first = Please save your changes first.
deck-config-a-100-day-interval =
{ $days ->
[one] A 100 day interval will become { $days } day.
*[other] A 100 day interval will become { $days } days.
}
deck-config-workload-factor-change = Approximate workload: {$factor}x
(compared to {$previousDR}% desired retention)
deck-config-workload-factor-unchanged = The higher this value, the more frequently cards will be shown to you.
deck-config-desired-retention-too-low = Your desired retention is very low, which can lead to very long intervals.
deck-config-desired-retention-too-high = Your desired retention is very high, which can lead to very short intervals.
deck-config-percent-of-reviews =
{ $reviews ->
[one] { $pct }% of { $reviews } review
*[other] { $pct }% of { $reviews } reviews
}
deck-config-percent-input = { $pct }%
# This message appears during FSRS parameter optimization.
deck-config-checking-for-improvement = Checking for improvement...
deck-config-optimizing-preset = Optimizing preset { $current_count }/{ $total_count }...
deck-config-fsrs-must-be-enabled = FSRS must be enabled first.
deck-config-fsrs-params-optimal = The FSRS parameters currently appear to be optimal.
deck-config-fsrs-params-no-reviews = No reviews found. Make sure this preset is assigned to all decks (including subdecks) that you want to optimize, and try again.
deck-config-wait-for-audio = Wait for audio
deck-config-show-reminder = Show Reminder
deck-config-answer-again = Answer Again
@ -448,9 +493,69 @@ deck-config-answer-hard = Answer Hard
deck-config-answer-good = Answer Good
deck-config-days-to-simulate = Days to simulate
deck-config-desired-retention-below-optimal = Your desired retention is below optimal. Increasing it is recommended.
# Description of the y axis in the FSRS simulation
# diagram (Deck options -> FSRS) showing the total number of
# cards that can be recalled or retrieved on a specific date.
deck-config-fsrs-simulator-experimental = FSRS Simulator (Experimental)
deck-config-fsrs-simulate-desired-retention-experimental = FSRS Desired Retention Simulator (Experimental)
deck-config-fsrs-simulate-save-preset = After optimizing, please save your deck preset before running the simulator.
deck-config-fsrs-desired-retention-help-me-decide-experimental = Help Me Decide (Experimental)
deck-config-additional-new-cards-to-simulate = Additional new cards to simulate
deck-config-simulate = Simulate
deck-config-clear-last-simulate = Clear Last Simulation
deck-config-fsrs-simulator-radio-count = Reviews
deck-config-advanced-settings = Advanced Settings
deck-config-smooth-graph = Smooth graph
deck-config-suspend-leeches = Suspend leeches
deck-config-save-options-to-preset = Save Changes to Preset
deck-config-save-options-to-preset-confirm = Overwrite the options in your current preset with the options that are currently set in the simulator?
# Radio button in the FSRS simulation diagram (Deck options -> FSRS) selecting
# to show the total number of cards that can be recalled or retrieved on a
# specific date.
deck-config-fsrs-simulator-radio-memorized = Memorized
deck-config-fsrs-simulator-radio-ratio = Time / Memorized Ratio
# $time here is pre-formatted e.g. "10 Seconds"
deck-config-fsrs-simulator-ratio-tooltip = { $time } per memorized card
## Messages related to the FSRS schedulers health check. The health check determines whether the correlation between FSRS predictions and your memory is good or bad. It can be optionally triggered as part of the "Optimize" function.
# Checkbox
deck-config-health-check = Check health when optimizing
# Message box showing the result of the health check
deck-config-fsrs-bad-fit-warning = Health Check:
Your memory is difficult for FSRS to predict. Recommendations:
- Suspend or reformulate any cards you constantly forget.
- Use the answer buttons consistently. Keep in mind that "Hard" is a passing grade, not a failing grade.
- Understand before you memorize.
If you follow these suggestions, performance will usually improve over the next few months.
# Message box showing the result of the health check
deck-config-fsrs-good-fit = Health Check:
FSRS can adapt to your memory well.
## NO NEED TO TRANSLATE. This text is no longer used by Anki, and will be removed in the future.
deck-config-unable-to-determine-desired-retention =
Unable to determine a minimum recommended retention.
deck-config-predicted-minimum-recommended-retention = Minimum recommended retention: { $num }
deck-config-compute-minimum-recommended-retention = Minimum recommended retention
deck-config-compute-optimal-retention-tooltip4 =
This tool will attempt to find the desired retention value
that will lead to the most material learnt, in the least amount of time. The calculated number can serve as a reference
when deciding what to set your desired retention to. You may wish to choose a higher desired retention if youre
willing to invest more study time to achieve it. Setting your desired retention lower than the minimum
is not recommended, as it will lead to a higher workload, because of the high forgetting rate.
deck-config-plotted-on-x-axis = (Plotted on the X-axis)
deck-config-a-100-day-interval =
{ $days ->
[one] A 100 day interval will become { $days } day.
*[other] A 100 day interval will become { $days } days.
}
deck-config-fsrs-simulator-y-axis-title-time = Review Time/Day
deck-config-fsrs-simulator-y-axis-title-count = Review Count/Day
deck-config-fsrs-simulator-y-axis-title-memorized = Memorized Total
deck-config-bury-siblings = Bury siblings
deck-config-do-not-bury = Do not bury siblings
deck-config-bury-if-new = Bury if new
@ -467,9 +572,53 @@ deck-config-bury-tooltip =
When using the V3 scheduler, interday learning cards can also be buried. Interday
learning cards are cards with a current learning step of one or more days.
deck-config-seconds-to-show-question-tooltip = When auto advance is activated, the number of seconds to wait before revealing the answer. Set to 0 to disable.
deck-config-answer-action-tooltip = The action to perform on the current card before automatically advancing to the next one.
deck-config-wait-for-audio-tooltip = Wait for audio to finish before automatically revealing answer or next question.
deck-config-ignore-before-tooltip =
If set, reviews before the provided date will be ignored when optimizing & evaluating FSRS parameters.
This can be useful if you imported someone else's scheduling data, or have changed the way you use the answer buttons.
deck-config-compute-optimal-retention-tooltip =
This tool assumes you're starting with 0 cards, and will attempt to calculate the amount of material you'll
be able to retain in the given time frame. The estimated retention will greatly depend on your inputs, and
if it significantly differs from 0.9, it's a sign that the time you've allocated each day is either too low
or too high for the amount of cards you're trying to learn. This number can be useful as a reference, but it
is not recommended to copy it into the desired retention field.
deck-config-health-check-tooltip1 = This will show a warning if FSRS struggles to adapt to your memory.
deck-config-health-check-tooltip2 = Health check is performed only when using Optimize Current Preset.
deck-config-compute-optimal-retention = Compute minimum recommended retention
deck-config-predicted-optimal-retention = Minimum recommended retention: { $num }
deck-config-weights-tooltip =
FSRS parameters affect how cards are scheduled. Anki will start with default parameters. Once
you've accumulated 1000+ reviews, you can use the option below to optimize the parameters to best
match your performance in decks using this preset.
deck-config-compute-optimal-weights-tooltip =
Once you've done 1000+ reviews in Anki, you can use the Optimize button to analyze your review history,
and automatically generate parameters that are optimal for your memory and the content you're studying.
If you have decks that vary wildly in difficulty, it is recommended to assign them separate presets, as
the parameters for easy decks and hard decks will be different. There is no need to optimize your parameters
frequently - once every few months is sufficient.
By default, parameters will be calculated from the review history of all decks using the current preset. You can
optionally adjust the search before calculating the parameters, if you'd like to alter which cards are used for
optimizing the parameters.
deck-config-compute-optimal-retention-tooltip2 =
This tool assumes that youre starting with 0 learned cards, and will attempt to find the desired retention
value that will lead to the most material learnt, in the least amount of time. This number can be used as a
reference when deciding what to set your desired retention to. You may wish to choose a higher desired retention,
if youre willing to trade more study time for a greater recall rate. Setting your desired retention lower than
the minimum is not recommended, as it will lead to more work without benefit.
deck-config-compute-optimal-retention-tooltip3 =
This tool assumes that youre starting with 0 learned cards, and will attempt to find the desired retention value
that will lead to the most material learnt, in the least amount of time. To accurately simulate your learning process,
this feature requires a minimum of 400+ reviews. The calculated number can serve as a reference when deciding what to
set your desired retention to. You may wish to choose a higher desired retention, if youre willing to trade more study
time for a greater recall rate. Setting your desired retention lower than the minimum is not recommended, as it will
lead to a higher workload, because of the high forgetting rate.
deck-config-seconds-to-show-question-tooltip-2 = When auto advance is activated, the number of seconds to wait before revealing the answer. Set to 0 to disable.
deck-config-invalid-weights = Parameters must be either left blank to use the defaults, or must be 17 comma-separated numbers.
deck-config-fsrs-on-all-clients =
Please ensure all of your Anki clients are Anki(Mobile) 23.10+ or AnkiDroid 2.17+. FSRS will
not work correctly if one of your clients is older.
deck-config-optimize-all-tip = You can optimize all presets at once by using the dropdown button next to "Save".

View file

@ -5,26 +5,17 @@ decks-create-deck = Create Deck
decks_create_even_if_empty = Create/update this deck even if empty
decks-custom-steps-in-minutes = Custom steps (in minutes)
decks-deck = Deck
decks-decreasing-intervals = Decreasing intervals
decks-delete-deck = Delete Deck
decks-enable-second-filter = Enable second filter
decks-filter = Filter:
decks-filter-2 = Filter 2
decks-get-shared = Get Shared
decks-import-file = Import File
decks-increasing-intervals = Increasing intervals
decks-latest-added-first = Latest added first
decks-limit-to = Limit to
decks-minutes = minutes
decks-most-lapses = Most lapses
decks-new-deck-name = New deck name:
decks-no-deck = [no deck]
decks-oldest-seen-first = Oldest seen first
decks-order-added = Order added
decks-order-due = Order due
decks-please-select-something = Please select something.
decks-random = Random
decks-relative-overdueness = Relative overdueness
decks-repeat-failed-cards-after = Delay Repeat failed cards after
# e.g. "Delay for Again", "Delay for Hard", "Delay for Good"
decks-delay-for-button = Delay for { $button }
@ -37,3 +28,28 @@ decks-learn-header = Learn
# The count of cards waiting to be reviewed
decks-review-header = Due
decks-zero-minutes-hint = (0 = return card to original deck)
## Sort order of cards
# Combobox entry: Sort the cards by the date they were added, in ascending order (oldest to newest)
decks-order-added = Order added
# Combobox entry: Sort the cards by the date they were added, in descending order (newest to oldest)
decks-latest-added-first = Latest added first
# Combobox entry: Sort the cards by due date, in ascending order (oldest due date to newest)
decks-order-due = Order due
# Combobox entry: Sort the cards by the number of lapses, in descending order (most lapses to least lapses)
decks-most-lapses = Most lapses
# Combobox entry: Sort the cards by the interval, in ascending order (shortest to longest)
decks-increasing-intervals = Increasing intervals
# Combobox entry: Sort the cards by the interval, in descending order (longest to shortest)
decks-decreasing-intervals = Decreasing intervals
# Combobox entry: Sort the cards by the last review date, in ascending order (oldest seen to newest seen)
decks-oldest-seen-first = Oldest seen first
# Combobox entry: Sort the cards in random order
decks-random = Random
## These strings are no longer used - you do not need to translate them if they
## are not already translated.
# Combobox entry: Sort the cards by relative overdueness, in descending order (most overdue to least overdue)
decks-relative-overdueness = Relative overdueness

View file

@ -10,6 +10,7 @@ editing-center = Center
editing-change-color = Change color
editing-cloze-deletion = Cloze deletion (new card)
editing-cloze-deletion-repeat = Cloze deletion (same card)
editing-copy-image = Copy image
editing-couldnt-record-audio-have-you-installed = Couldn't record audio. Have you installed 'lame'?
editing-customize-card-templates = Customize Card Templates
editing-customize-fields = Customize Fields
@ -35,6 +36,8 @@ editing-mathjax-chemistry = MathJax chemistry
editing-mathjax-inline = MathJax inline
editing-mathjax-placeholder = Press { $accept } to accept, { $newline } for new line.
editing-media = Media
editing-open-image = Open image
editing-show-in-folder = Show in folder
editing-ordered-list = Ordered list
editing-outdent = Decrease indent
editing-paste = Paste
@ -93,6 +96,7 @@ editing-image-occlusion-rectangle-tool = Rectangle
editing-image-occlusion-ellipse-tool = Ellipse
editing-image-occlusion-polygon-tool = Polygon
editing-image-occlusion-text-tool = Text
editing-image-occlusion-fill-tool = Fill with colour
editing-image-occlusion-toggle-mask-editor = Toggle Mask Editor
editing-image-occlusion-reset = Reset Image Occlusion
editing-image-occlusion-confirm-reset = Are you sure you want to reset this image occlusion?

View file

@ -5,7 +5,7 @@ errors-100-tags-max =
A maximum of 100 tags can be selected. Listing the
tags you want instead of the ones you don't want is usually simpler, and there
is no need to select child tags if you have selected a parent tag.
errors-multiple-notetypes-selected = Please select notes from only one notetype.
errors-multiple-notetypes-selected = Please select notes from only one note type.
errors-please-check-database = Please use the Check Database action, then try again.
errors-please-check-media = Please use the Check Media action, then try again.
errors-collection-too-new = This collection requires a newer version of Anki to open.

View file

@ -40,5 +40,5 @@ exporting-processed-media-files =
*[other] Processed { $count } media files...
}
exporting-include-deck = Include deck name
exporting-include-notetype = Include notetype name
exporting-include-notetype = Include note type name
exporting-include-guid = Include unique identifier

View file

@ -8,13 +8,14 @@ importing-anki2-files-are-not-directly-importable = .anki2 files are not directl
importing-appeared-twice-in-file = Appeared twice in file: { $val }
importing-by-default-anki-will-detect-the = By default, Anki will detect the character between fields, such as a tab, comma, and so on. If Anki is detecting the character incorrectly, you can enter it here. Use \t to represent tab.
importing-cannot-merge-notetypes-of-different-kinds =
Cloze notetypes cannot be merged with regular notetypes.
Cloze note types cannot be merged with regular note types.
You may still import the file with '{ importing-merge-notetypes }' disabled.
importing-change = Change
importing-colon = Colon
importing-comma = Comma
importing-empty-first-field = Empty first field: { $val }
importing-field-separator = Field separator
importing-field-separator-guessed = Field separator (guessed)
importing-field-mapping = Field mapping
importing-field-of-file-is = Field <b>{ $val }</b> of file is:
importing-fields-separated-by = Fields separated by: { $val }
@ -33,13 +34,13 @@ importing-map-to = Map to { $val }
importing-map-to-tags = Map to Tags
importing-mapped-to = mapped to <b>{ $val }</b>
importing-mapped-to-tags = mapped to <b>Tags</b>
# the action of combining two existing notetypes to create a new one
importing-merge-notetypes = Merge notetypes
# the action of combining two existing note types to create a new one
importing-merge-notetypes = Merge note types
importing-merge-notetypes-help =
If checked, and you or the deck author altered the schema of a notetype, Anki will
If checked, and you or the deck author altered the schema of a note type, Anki will
merge the two versions instead of keeping both.
Altering a notetype's schema means adding, removing, or reordering fields or templates,
Altering a note type's schema means adding, removing, or reordering fields or templates,
or changing the sort field.
As a counterexample, changing the front side of an existing template does *not* constitute
a schema change.
@ -47,10 +48,11 @@ importing-merge-notetypes-help =
Warning: This will require a one-way sync, and may mark existing notes as modified.
importing-mnemosyne-20-deck-db = Mnemosyne 2.0 Deck (*.db)
importing-multicharacter-separators-are-not-supported-please = Multi-character separators are not supported. Please enter one character only.
importing-new-deck-will-be-created = A new deck will be created: { $name }
importing-notes-added-from-file = Notes added from file: { $val }
importing-notes-found-in-file = Notes found in file: { $val }
importing-notes-skipped-as-theyre-already-in = Notes skipped, as up-to-date copies are already in your collection: { $val }
importing-notes-skipped-update-due-to-notetype = Notes not updated, as notetype has been modified since you first imported the notes: { $val }
importing-notes-skipped-update-due-to-notetype = Notes not updated, as note type has been modified since you first imported the notes: { $val }
importing-notes-updated-as-file-had-newer = Notes updated, as file had newer version: { $val }
importing-include-reviews = Include reviews
importing-also-import-progress = Import any learning progress
@ -64,14 +66,18 @@ importing-with-deck-configs-help =
If enabled, any deck options that the deck sharer included will also be imported.
Otherwise, all decks will be assigned the default preset.
importing-packaged-anki-deckcollection-apkg-colpkg-zip = Packaged Anki Deck/Collection (*.apkg *.colpkg *.zip)
importing-pauker-18-lesson-paugz = Pauker 1.8 Lesson (*.pau.gz)
# the '|' character
importing-pipe = Pipe
# Warning displayed when the csv import preview table is clipped (some columns were hidden)
# $count is intended to be a large number (1000 and above)
importing-preview-truncated =
{ $count ->
*[other] Only the first { $count } columns are shown. If this doesn't seem right, try changing the field separator.
}
importing-rows-had-num1d-fields-expected-num2d = '{ $row }' had { $found } fields, expected { $expected }
importing-selected-file-was-not-in-utf8 = Selected file was not in UTF-8 format. Please see the importing section of the manual.
importing-semicolon = Semicolon
importing-skipped = Skipped
importing-supermemo-xml-export-xml = Supermemo XML export (*.xml)
importing-tab = Tab
importing-tag-modified-notes = Tag modified notes:
importing-text-separated-by-tabs-or-semicolons = Text separated by tabs or semicolons (*)
@ -90,10 +96,10 @@ importing-update-notes = Update notes
importing-update-notes-help =
When to update an existing note in your collection. By default, this is only done
if the matching imported note was more recently modified.
importing-update-notetypes = Update notetypes
importing-update-notetypes = Update note types
importing-update-notetypes-help =
When to update an existing notetype in your collection. By default, this is only done
if the matching imported notetype was more recently modified. Changes to template text
When to update an existing note type in your collection. By default, this is only done
if the matching imported note type was more recently modified. Changes to template text
and styling can always be imported, but for schema changes (e.g. the number or order of
fields has changed), the '{ importing-merge-notetypes }' option will also need to be enabled.
importing-note-added =
@ -148,7 +154,7 @@ importing-file = File
# "Match scope: notetype / notetype and deck". Controls how duplicates are matched.
importing-match-scope = Match scope
# Used with the 'match scope' option
importing-notetype-and-deck = Notetype and deck
importing-notetype-and-deck = Note type and deck
importing-cards-added =
{ $count ->
[one] { $count } card added.
@ -182,8 +188,8 @@ importing-conflicting-notes-skipped =
}
importing-conflicting-notes-skipped2 =
{ $count ->
[one] { $count } note was not imported, because its notetype has changed, and '{ importing-merge-notetypes }' was not enabled.
*[other] { $count } notes were not imported, because their notetype has changed, and '{ importing-merge-notetypes }' was not enabled.
[one] { $count } note was not imported, because its note type has changed, and '{ importing-merge-notetypes }' was not enabled.
*[other] { $count } notes were not imported, because their note type has changed, and '{ importing-merge-notetypes }' was not enabled.
}
importing-import-log = Import Log
importing-no-notes-in-file = No notes found in file.
@ -198,8 +204,8 @@ importing-status = Status
importing-duplicate-note-added = Duplicate note added
importing-added-new-note = New note added
importing-existing-note-skipped = Note skipped, as an up-to-date copy is already in your collection
importing-note-skipped-update-due-to-notetype = Note not updated, as notetype has been modified since you first imported the note
importing-note-skipped-update-due-to-notetype2 = Note not updated, as notetype has been modified since you first imported the note, and '{ importing-merge-notetypes }' was not enabled
importing-note-skipped-update-due-to-notetype = Note not updated, as note type has been modified since you first imported the note
importing-note-skipped-update-due-to-notetype2 = Note not updated, as note type has been modified since you first imported the note, and '{ importing-merge-notetypes }' was not enabled
importing-note-updated-as-file-had-newer = Note updated, as file had newer version
importing-note-skipped-due-to-missing-notetype = Note skipped, as its notetype was missing
importing-note-skipped-due-to-missing-deck = Note skipped, as its deck was missing
@ -211,15 +217,18 @@ importing-field-separator-help =
Please note that if this character appears in any field itself, the field has to be
quoted accordingly to the CSV standard. Spreadsheet programs like LibreOffice will
do this automatically.
It cannot be changed if the text file forces use of a specific separator via a file header.
If a file header is not present, Anki will try to guess what the separator is.
importing-allow-html-in-fields-help =
Enable this if the file contains HTML formatting. E.g. if the file contains the string
'&lt;br&gt;', it will appear as a line break on your card. On the other hand, with this
option disabled, the literal characters '&lt;br&gt;' will be rendered.
importing-notetype-help =
Newly-imported notes will have this notetype, and only existing notes with this
notetype will be updated.
Newly-imported notes will have this note type, and only existing notes with this
note type will be updated.
You can choose which fields in the file correspond to which notetype fields with the
You can choose which fields in the file correspond to which note type fields with the
mapping tool.
importing-deck-help = Imported cards will be placed in this deck.
importing-existing-notes-help =
@ -229,11 +238,12 @@ importing-existing-notes-help =
- `{ importing-preserve }`: Do nothing.
- `{ importing-duplicate }`: Create a new note.
importing-match-scope-help =
Only existing notes with the same notetype will be checked for duplicates. This can
Only existing notes with the same note type will be checked for duplicates. This can
additionally be restricted to notes with cards in the same deck.
importing-tag-all-notes-help =
These tags will be added to both newly-imported and updated notes.
importing-tag-updated-notes-help = These tags will be added to any updated notes.
importing-overview = Overview
## NO NEED TO TRANSLATE. This text is no longer used by Anki, and will be removed in the future.
@ -241,3 +251,5 @@ importing-importing-collection = Importing collection...
importing-unable-to-import-filename = Unable to import { $filename }: file type not supported
importing-notes-that-could-not-be-imported = Notes that could not be imported as note type has changed: { $val }
importing-added = Added
importing-pauker-18-lesson-paugz = Pauker 1.8 Lesson (*.pau.gz)
importing-supermemo-xml-export-xml = Supermemo XML export (*.xml)

View file

@ -1,4 +1,4 @@
notetypes-notetype = Notetype
notetypes-notetype = Note Type
## Default field names in newly created note types

View file

@ -13,6 +13,8 @@ preferences-media-is-not-backed-up = Media is not backed up. Please create a per
preferences-on-next-sync-force-changes-in = On next sync, force changes in one direction
preferences-paste-clipboard-images-as-png = Paste clipboard images as PNG
preferences-paste-without-shift-key-strips-formatting = Paste without shift key strips formatting
preferences-generate-latex-images-automatically = Generate LaTeX images (security risk)
preferences-latex-generation-disabled = LaTeX image generation is disabled in the preferences.
preferences-periodically-sync-media = Periodically sync media
preferences-please-restart-anki-to-complete-language = Please restart Anki to complete language change.
preferences-preferences = Preferences
@ -25,7 +27,6 @@ preferences-show-remaining-card-count = Show remaining card count
preferences-some-settings-will-take-effect-after = Some settings will take effect after you restart Anki.
preferences-tab-synchronisation = Synchronization
preferences-synchronize-audio-and-images-too = Synchronize audio and images too
preferences-not-logged-in = Not currently logged in to AnkiWeb.
preferences-login-successful-sync-now = Log-in successful. Save preferences and sync now?
preferences-timebox-time-limit = Timebox time limit
preferences-user-interface-size = User interface size
@ -33,12 +34,13 @@ preferences-when-adding-default-to-current-deck = When adding, default to curren
preferences-you-can-restore-backups-via-fileswitch = You can restore backups via File > Switch Profile.
preferences-legacy-timezone-handling = Legacy timezone handling (buggy, but required for AnkiDroid <= 2.14)
preferences-default-search-text = Default search text
preferences-default-search-text-example = eg. 'deck:current '
preferences-default-search-text-example = e.g. "deck:current"
preferences-theme = Theme
preferences-theme-follow-system = Follow System
preferences-theme-light = Light
preferences-theme-dark = Dark
preferences-v3-scheduler = V3 scheduler
preferences-check-for-updates = Check for program updates
preferences-ignore-accents-in-search = Ignore accents in search (slower)
preferences-backup-explanation =
Anki periodically backs up your collection. After backups are more than 2 days old,
@ -62,6 +64,7 @@ preferences-review = Review
preferences-answer-keys = Answer keys
preferences-distractions = Distractions
preferences-minimalist-mode = Minimalist mode
preferences-minimalist-mode-tooltip = Make the interface more compact/less fancy
preferences-editing = Editing
preferences-browsing = Browsing
preferences-default-deck = Default deck
@ -74,9 +77,24 @@ preferences-network-timeout = Network timeout
preferences-reset-window-sizes = Reset Window Sizes
preferences-reset-window-sizes-complete = Window sizes and locations have been reset.
preferences-shortcut-placeholder = Enter an unused shortcut key, or leave empty to disable.
preferences-third-party-services = Third-Party Services
preferences-ankihub-not-logged-in = Not currently logged in to AnkiHub.
preferences-ankiweb-intro = AnkiWeb is a free service that lets you keep your flashcard data in sync across your devices, and provides a way to recover the data if your device breaks or is lost.
preferences-ankihub-intro = AnkiHub provides collaborative deck editing and additional study tools. A paid subscription is required to access certain features.
preferences-third-party-description = Third-party services are unaffiliated with and not endorsed by Anki. Use of these services may require payment.
## URL scheme related
preferences-url-schemes = URL Schemes
preferences-url-scheme-prompt = Allowed URL Schemes (space-separated):
preferences-url-scheme-warning = Blocked attempt to open `{ $link }`, which may be a security issue.
If you trust the deck author and wish to proceed, you can add `{ $scheme }` to your allowed URL Schemes.
preferences-url-scheme-allow-once = Allow Once
preferences-url-scheme-always-allow = Always Allow
## NO NEED TO TRANSLATE. This text is no longer used by Anki, and will be removed in the future.
preferences-basic = Basic
preferences-reviewer = Reviewer
preferences-media = Media
preferences-not-logged-in = Not currently logged in to AnkiWeb.

View file

@ -142,7 +142,7 @@ scheduling-reviews = Reviews
scheduling-seconds = seconds
scheduling-set-all-decks-below-to = Set all decks below { $val } to this option group?
scheduling-set-for-all-subdecks = Set for all subdecks
scheduling-show-answer-timer = Show answer timer
scheduling-show-answer-timer = Show on-screen timer
scheduling-show-new-cards-after-reviews = Show new cards after reviews
scheduling-show-new-cards-before-reviews = Show new cards before reviews
scheduling-show-new-cards-in-order-added = Show new cards in order added
@ -172,8 +172,13 @@ scheduling-set-due-date-done =
[one] Set due date of { $cards } card.
*[other] Set due date of { $cards } cards.
}
scheduling-graded-cards-done =
{ $cards ->
[one] Graded { $cards } card.
*[other] Graded { $cards } cards.
}
scheduling-forgot-cards =
{ $cards ->
[one] Forgot { $cards } card.
*[other] Forgot { $cards } cards.
[one] Reset { $cards } card.
*[other] Reset { $cards } cards.
}

View file

@ -43,17 +43,6 @@ statistics-in-time-span-years =
[one] in { $amount } year
*[other] in { $amount } years
}
statistics-cards =
{ $cards ->
[one] { $cards } card
*[other] { $cards } cards
}
# a count of how many cards have been answered, eg "Total: 34 reviews"
statistics-reviews =
{ $reviews ->
[one] { $reviews } review
*[other] { $reviews } reviews
}
# Shown at the bottom of the deck list, and in the statistics screen.
# eg "Studied 3 cards in 13 seconds today (4.33s/card)."
# The { statistics-in-time-span-seconds } part should be pasted in from the English
@ -69,6 +58,29 @@ statistics-studied-today =
*[years] { statistics-in-time-span-years }
} today
({ $secs-per-card }s/card)
##
statistics-cards =
{ $cards ->
[one] { $cards } card
*[other] { $cards } cards
}
statistics-notes =
{ $notes ->
[one] { $notes } note
*[other] { $notes } notes
}
# a count of how many cards have been answered, eg "Total: 34 reviews"
statistics-reviews =
{ $reviews ->
[one] { $reviews } review
*[other] { $reviews } reviews
}
# This fragment of the tooltip in the FSRS simulation
# diagram (Deck options -> FSRS) shows the total number of
# cards that can be recalled or retrieved on a specific date.
statistics-memorized = {$memorized} cards memorized
statistics-today-title = Today
statistics-today-again-count = Again count:
statistics-today-type-counts = Learn: { $learnCount }, Review: { $reviewCount }, Relearn: { $relearnCount }, Filtered: { $filteredCount }
@ -86,6 +98,47 @@ statistics-counts-learning-cards = Learning
statistics-counts-relearning-cards = Relearning
statistics-counts-title = Card Counts
statistics-counts-separate-suspended-buried-cards = Separate suspended/buried cards
## Retention represents your actual retention from past reviews, in
## comparison to the "desired retention" setting of FSRS, which forecasts
## future retention. Retention is the percentage of all reviewed cards
## that were marked as "Hard," "Good," or "Easy" within a specific time period.
##
## Most of these strings are used as column / row headings in a table.
## (Excluding -title and -subtitle)
## It is important to keep these translations short so that they do not make
## the table too large to display on a single stats card.
##
## N.B. Stats cards may be very small on mobile devices and when the Stats
## window is certain sizes.
statistics-true-retention-title = Retention
statistics-true-retention-subtitle = Pass rate of cards with an interval ≥ 1 day.
statistics-true-retention-tooltip = If you are using FSRS, your retention is expected to be close to your desired retention. Please keep in mind that data for a single day is noisy, so it's better to look at monthly data.
statistics-true-retention-range = Range
statistics-true-retention-pass = Pass
statistics-true-retention-fail = Fail
# This will usually be the same as statistics-counts-total-cards
statistics-true-retention-total = Total
statistics-true-retention-count = Count
statistics-true-retention-retention = Retention
# This will usually be the same as statistics-counts-young-cards
statistics-true-retention-young = Young
# This will usually be the same as statistics-counts-mature-cards
statistics-true-retention-mature = Mature
statistics-true-retention-all = All
statistics-true-retention-today = Today
statistics-true-retention-yesterday = Yesterday
statistics-true-retention-week = Last week
statistics-true-retention-month = Last month
statistics-true-retention-year = Last year
statistics-true-retention-all-time = All time
# If there are no reviews within a specific time period, the retention
# percentage cannot be calculated and is displayed as "N/A."
statistics-true-retention-not-applicable = N/A
##
statistics-range-all-time = all
statistics-range-1-year-history = last 12 months
statistics-range-all-history = all history
@ -96,7 +149,7 @@ statistics-card-ease-title = Card Ease
statistics-card-difficulty-title = Card Difficulty
statistics-card-stability-title = Card Stability
statistics-card-stability-subtitle = The delay at which retrievability falls to 90%.
statistics-average-stability = Average stability
statistics-median-stability = Median stability
statistics-card-retrievability-title = Card Retrievability
statistics-card-ease-subtitle = The lower the ease, the more frequently a card will appear.
statistics-card-difficulty-subtitle2 = The higher the difficulty, the slower stability will increase.
@ -152,7 +205,7 @@ statistics-cards-due =
}
statistics-backlog-checkbox = Backlog
statistics-intervals-title = Review Intervals
statistics-intervals-subtitle = Delays until reviews are shown again.
statistics-intervals-subtitle = Delays until review cards are shown again.
statistics-intervals-day-range =
{ $cards ->
[one] { $cards } card with a { $daysStart }~{ $daysEnd } day interval
@ -176,6 +229,7 @@ statistics-stability-day-single =
# hour range, eg "From 14:00-15:00"
statistics-hours-range = From { $hourStart }:00~{ $hourEnd }:00
statistics-hours-correct = { $correct }/{ $total } correct ({ $percent }%)
statistics-hours-correct-info = → (not 'Again')
# the emoji depicts the graph displaying this number
statistics-hours-reviews = 📊 { $reviews } reviews
# the emoji depicts the graph displaying this number
@ -202,12 +256,21 @@ statistics-elapsed-time-years = { $amount }y
##
statistics-average-for-days-studied = Average for days studied
# This term is used in a variety of contexts to refers to the total amount of
# items (e.g., cards, mature cards, etc) for a given period, rather than the
# total of all existing items.
statistics-total = Total
statistics-days-studied = Days studied
statistics-average-answer-time-label = Average answer time
statistics-average = Average
statistics-average-interval = Average interval
statistics-median-interval = Median interval
statistics-due-tomorrow = Due tomorrow
# This string, Daily load, appears in the Future due table and represents a
# forecasted estimate of the number of cards expected to be reviewed daily in
# the future. Unlike the other strings in the table that display actual data
# derived from the current scheduling (e.g., Average, Due tomorrow),
# Daily load is a projection based on the given data.
statistics-daily-load = Daily load
# eg 5 of 15 (33.3%)
statistics-amount-of-total-with-percentage = { $amount } of { $total } ({ $percent }%)
statistics-average-over-period = Average over period
@ -226,10 +289,19 @@ statistics-cards-per-day =
[one] { $count } card/day
*[other] { $count } cards/day
}
statistics-average-ease = Average ease
statistics-average-difficulty = Average difficulty
statistics-median-ease = Median ease
statistics-median-difficulty = Median difficulty
statistics-average-retrievability = Average retrievability
statistics-estimated-total-knowledge = Estimated total knowledge
statistics-save-pdf = Save PDF
statistics-saved = Saved.
statistics-stats = stats
statistics-title = Statistics
## These strings are no longer used - you do not need to translate them if they
## are not already translated.
statistics-average-stability = Average stability
statistics-average-interval = Average interval
statistics-average-ease = Average ease
statistics-average-difficulty = Average difficulty

Some files were not shown because too many files have changed in this diff Show more