Allowing some decks to be FSRS and some SM-2 will lead to confusing
behavior when sorting on SM-2 or FSRS-specific fields, or when moving
cards between decks.
* Pack FSRS data into card.data
* Update FSRS card data when preset or weights change
+ Show FSRS stats in card stats
* Show a warning when there's a limited review history
* Add some translations; tweak UI
* Fix default requested retention
* Add browser columns, fix calculation of R
* Property searches
eg prop:d>0.1
* Integrate FSRS into reviewer
* Warn about long learning steps
* Hide minimum interval when FSRS is on
* Don't apply interval multiplier to FSRS intervals
* Expose memory state to Python
* Don't set memory state on new cards
* Port Jarret's new tests; add some helpers to make tests more compact
https://github.com/open-spaced-repetition/fsrs-rs/pull/64
* Fix learning cards not being given memory state
* Require update to v3 scheduler
* Don't exclude single learning step when calculating memory state
* Use relearning step when learning steps unavailable
* Update docstring
* fix single_card_revlog_to_items (#2656)
* not need check the review_kind for unique_dates
* add email address to CONTRIBUTORS
* fix last first learn & keep early review
* cargo fmt
* cargo clippy --fix
* Add Jarrett to about screen
* Fix fsrs_memory_state being initialized to default in get_card()
* Set initial memory state on graduate
* Update to latest FSRS
* Fix experiment.log being empty
* Fix broken colpkg imports
Introduced by "Update FSRS card data when preset or weights change"
* Update memory state during (re)learning; use FSRS for graduating intervals
* Reset memory state when cards are manually rescheduled as new
* Add difficulty graph; hide eases when FSRS enabled
* Add retrievability graph
* Derive memory_state from revlog when it's missing and shouldn't be
---------
Co-authored-by: Jarrett Ye <jarrett.ye@outlook.com>
* Make enum selector generic
* Refactor ImportCsvPage to support tooltips
* Improve csv import defaults
* Unify import pages
* Improve import page styling
* Fix life cycle issue with import properties
* Remove size constraints to fix scrollbar styling
* Add help strings and urls to csv import page
* Show ErrorPage on ImportPage error
* Fix escaping of import path
* Unify ImportPage and ImportLogPage
* Apply suggestions from code review (dae)
* Fix import progress
* Fix preview overflowing container
* Don't include <br> in FileIoErrors (dae)
e.g. 500: Failed to read '/home/dae/foo2.csv':<br>stream did not contain valid UTF-8
I thought about using {@html ...} here, but that's a potential security issue,
as the filename is not something we control.
* Remember original id when importing notetype
* Reuse notetypes with matching original id
* Add field and template ids
* Enable merging imported notetypes
* Fix test
Note should be updated if the incoming note's notetype is
remapped to the existing note's notetype.
On the other hand, it should be skipped if its notetype id is mapped
to some new notetype.
* Change field and template ids to i32
* Add merge notetypes flag to proto message
* Add dialog for apkg import
* Move HelpModal into components
* Generalize import dialog
* Move SettingTitle into components
* Add help modal to ImportAnkiPackagePage
* Move SwitchRow into components
* Fix backend method import
* Make testable in browser
* Fix broken modal
* Wrap in container and fix margins
* Update commented Anki version of new proto fields
* Check ids when comparing notetype schemas
* Add tooltip for merging notetypes.
* Allow updating notes regardless of mtime
* Gitignore yarn-error.log
* Allow updating notetypes regardless of mtime
* Fix apkg help carousel
* Use i64s for template and field ids
* Add option to omit importing scheduling info
* Restore last settings in apkg import dialog
* Display error when getting metadata in webview
* Update manual links for apkg importing
* Apply suggestions from code review
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
* Omit schduling -> Import all cards as new cards
* Tweak importing-update-notes-help
* UpdateCondition → ImportAnkiPackageUpdateCondition
* Load keyboard.ftl
* Skip updating dupes in 'update alwyas' case
* Explain more when merging notetypes is required
* "omit scheduling" → "with scheduling"
* Skip updating notetype dupes if 'update always'
* Merge duplicated notetypes from previous imports
* Fix rebase aftermath
* Fix panic when merging
* Clarify 'update notetypes' help
* Mention 'merge notetypes' in the log
* Add a test which covers the previously panicking path
* Use nested ftl messages to ensure consistency
* Make order of merged fields deterministic
* Rewrite test to trigger panic
* Update version comment on new fields
Prettier by default tries to preserve whitespace around inline tags,
which can prevent problems such as a space before the period in
'<a>text</a>.':
https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting
Unfortunately only standard HTML block elements are excluded from this
behaviour, so all of our Svelte components are treated the same way, even
if they are block-based, or used in a way where the extra whitespace
doesn't matter. This makes the code somewhat harder to read.
Changing this option does carry the risk that rogue spaces will creep
into our UI in the future as code is formatted, but as there don't appear
to be any such issues with this initial reformat, I think the improved
readability may justify the relatively small risk.
(for upgrading users, please see the notes at the bottom)
Bazel brought a lot of nice things to the table, such as rebuilds based on
content changes instead of modification times, caching of build products,
detection of incorrect build rules via a sandbox, and so on. Rewriting the build
in Bazel was also an opportunity to improve on the Makefile-based build we had
prior, which was pretty poor: most dependencies were external or not pinned, and
the build graph was poorly defined and mostly serialized. It was not uncommon
for fresh checkouts to fail due to floating dependencies, or for things to break
when trying to switch to an older commit.
For day-to-day development, I think Bazel served us reasonably well - we could
generally switch between branches while being confident that builds would be
correct and reasonably fast, and not require full rebuilds (except on Windows,
where the lack of a sandbox and the TS rules would cause build breakages when TS
files were renamed/removed).
Bazel achieves that reliability by defining rules for each programming language
that define how source files should be turned into outputs. For the rules to
work with Bazel's sandboxing approach, they often have to reimplement or
partially bypass the standard tools that each programming language provides. The
Rust rules call Rust's compiler directly for example, instead of using Cargo,
and the Python rules extract each PyPi package into a separate folder that gets
added to sys.path.
These separate language rules allow proper declaration of inputs and outputs,
and offer some advantages such as caching of build products and fine-grained
dependency installation. But they also bring some downsides:
- The rules don't always support use-cases/platforms that the standard language
tools do, meaning they need to be patched to be used. I've had to contribute a
number of patches to the Rust, Python and JS rules to unblock various issues.
- The dependencies we use with each language sometimes make assumptions that do
not hold in Bazel, meaning they either need to be pinned or patched, or the
language rules need to be adjusted to accommodate them.
I was hopeful that after the initial setup work, things would be relatively
smooth-sailing. Unfortunately, that has not proved to be the case. Things
frequently broke when dependencies or the language rules were updated, and I
began to get frustrated at the amount of Anki development time I was instead
spending on build system upkeep. It's now about 2 years since switching to
Bazel, and I think it's time to cut losses, and switch to something else that's
a better fit.
The new build system is based on a small build tool called Ninja, and some
custom Rust code in build/. This means that to build Anki, Bazel is no longer
required, but Ninja and Rust need to be installed on your system. Python and
Node toolchains are automatically downloaded like in Bazel.
This new build system should result in faster builds in some cases:
- Because we're using cargo to build now, Rust builds are able to take advantage
of pipelining and incremental debug builds, which we didn't have with Bazel.
It's also easier to override the default linker on Linux/macOS, which can
further improve speeds.
- External Rust crates are now built with opt=1, which improves performance
of debug builds.
- Esbuild is now used to transpile TypeScript, instead of invoking the TypeScript
compiler. This results in faster builds, by deferring typechecking to test/check
time, and by allowing more work to happen in parallel.
As an example of the differences, when testing with the mold linker on Linux,
adding a new message to tags.proto (which triggers a recompile of the bulk of
the Rust and TypeScript code) results in a compile that goes from about 22s on
Bazel to about 7s in the new system. With the standard linker, it's about 9s.
Some other changes of note:
- Our Rust workspace now uses cargo-hakari to ensure all packages agree on
available features, preventing unnecessary rebuilds.
- pylib/anki is now a PEP420 implicit namespace, avoiding the need to merge
source files and generated files into a single folder for running. By telling
VSCode about the extra search path, code completion now works with generated
files without needing to symlink them into the source folder.
- qt/aqt can't use PEP420 as it's difficult to get rid of aqt/__init__.py.
Instead, the generated files are now placed in a separate _aqt package that's
added to the path.
- ts/lib is now exposed as @tslib, so the source code and generated code can be
provided under the same namespace without a merging step.
- MyPy and PyLint are now invoked once for the entire codebase.
- dprint will be used to format TypeScript/json files in the future instead of
the slower prettier (currently turned off to avoid causing conflicts). It can
automatically defer to prettier when formatting Svelte files.
- svelte-check is now used for typechecking our Svelte code, which revealed a
few typing issues that went undetected with the old system.
- The Jest unit tests now work on Windows as well.
If you're upgrading from Bazel, updated usage instructions are in docs/development.md and docs/build.md. A summary of the changes:
- please remove node_modules and .bazel
- install rustup (https://rustup.rs/)
- install rsync if not already installed (on windows, use pacman - see docs/windows.md)
- install Ninja (unzip from https://github.com/ninja-build/ninja/releases/tag/v1.11.1 and
place on your path, or from your distro/homebrew if it's 1.10+)
- update .vscode/settings.json from .vscode.dist
* Include base styles in graphs-base.scss
This includes the custom scrollbar styles, which were missing on the stats page.
* Set responsive grid layout on GraphsPage, use TitledContainer component
+ use global button style, tweak input appearance and other small changes
* Improve margins on GraphsPage
* Redesign deck config, swap tooltips for help modals, link to manual
* Replace canvas-inset with canvas-code for custom scheduling
* Make section header link to manual too
* Include elevation Sass library
* Remove two unused exports
* Fix tabbed spinboxes
* Update ftl/core/deck-config.ftl
* Update ftl/core/deck-config.ftl
* Fix format
* Make border-radius and box-shadow more subtle
* Fix margin for vertical aspect ratio
* Make direct hover on info badge apply effect instantly
* Add redirect line to manual underneath chapter
* Make eslint sort our imports
* fix missing deps in eslint rule (dae)
Caught on Linux due to the stricter sandboxing
* Remove exports-last eslint rule (for now?)
* Adjust browserslist settings
- We use ResizeObserver which is not supported in browsers like KaiOS,
Baidu or Android UC
* Raise minimum iOS version 13.4
- It's the first version that supports ResizeObserver
* Apply new eslint rules to sort imports
* Add componentHook functionality
* Register package NoteEditor
* Rename OldEditorAdapter to NoteEditor
* Expose instances in component-hook as well
* Rename NoteTypeButtons to NotetypeButtons
* Move PreviewButton initialization to BrowserEditor.svelte
* Remove focusInRichText
- Same thing can be done by inspecting activeInput
* Satisfy formatter
* Fix remaining rebase issues
* Add .bazel to .prettierignore
* Rename currentField and activeInput to focused{Field,Input}
* Move identifier to lib and registration to sveltelib
* Fix Dynamic component insertion
* Simplify editingInputIsRichText
* Give extra warning in svelte/svelte.ts
- This was caused by doing a rename of a files, that only differed in
case: NoteTypeButtons.svelte to NotetypeButtons.svelte
- It was quite tough to figure out, and this console.log might make it
easier if it ever happens again
* Change signature of contextProperty
* Add ts/typings for add-on definition files
* Add Anki types in typings/common/index.d.ts
* Export without .svelte suffix
It conflicts with how Svelte types its packages
* Fix left over .svelte import from editor.py
* Rename NoteTypeButtons to unrelated to ensure case-only rename
* Rename back to NotetypeButtons.svelte
* Remove unused component-hook.ts, Fix typing in lifecycle-hooks
* Merge runtime-require and register-package into one file
+ Give some preliminary types to require
* Rename uiDidLoad to loaded
* Fix eslint / svelte-check
* Rename context imports to noteEditorContext
* Fix import name mismatch
- I wonder why these issues are not caught by svelte-check?
* Rename two missed usages of uiDidLoad
* Fix ButtonDropdown from having wrong border-radius
* Uniformly rename libraries to packages
- I don't have a strong opinion on whether to name them libraries or
packages, I just think we should have a uniform name.
- JS/TS only uses the terms "module" and "namespace", however `package`
is a reserved keyword for future use, whereas `library` is not.
* Refactor registration.ts into dynamic-slotting
- This is part of an effort to refactor the dynamic slotting (extending
buttons) functionality out of components like ButtonGroup.
* Remove dynamically-slottable logic from ButtonToolbar
* Use DynamicallySlottable in editor-toolbar
* Fix no border radius on indentation button dropdown
* Fix AddonButtons
* Remove Item/ButtonGroupItem in deck-options, where it's not necessary
* Remove unnecessary uses of Item and ButtonGroupItem
* Fix remaining tests
* Fix relative imports
* Revert change return value of remapBinToSrcDir to ./bazel/out...
* Remove typings directory
* Adjust comments for dynamic-slottings
* Refactor out Placeholder from CardInfo.svelte
* Add breakpoint parameter for Container
- Use `Container` component inside `TitledContainer`
* Build Item into Row
- Use Row in DeckOptionsPage instead of just Item
* Reengineer Container/Row/Col CSS
* Inline Badges next to Labels when Lable spans multiple rows
* Adjust margins for mobile
* Implement Col component breakpoints
* Move card-info to use new Container and Row components
* Join StickyHeader and StickyFooter to StickyContainer
* Remove default middle vertical-alignment for Badges again
* Satisfy tests
* Restore inline gutters in change-notetype Mapper
* Add some comment to Col and Container
* Fix breaking behavior in DeckOptionsPage when multi-column
* Add back toolbar left padding to counter-act buttongroup right margins
* Make Label in SwitchRow take more of available space
Merging note: the typing changes were fixed in a separate PR.
* Put rootDirs into subprojects
- typings do not work for any ts or svelte files
- if we set the 'rootDirs' in ts/tsconfig.json to '../bazel-bin/ts' and then inherit
them from e.g. editor, the root will be changed to '../../bazel-bin/ts',
however editor needs look in '../../bazel-bin/ts/editor' instead.
* Rename i18n and i18n_helpers to i18n-generated and i18n
- This way, we can restrict the awkwardness of importing files outside
the ts directory within lib
* Fix missing typing of i18n and backend_proto by adding back symlinks
* Split up i18n-generated into i18n-{translate,modules}
* Change i18n from singleton to functions
* Revert "Put rootDirs into subprojects"
This partially reverts commit e1d4292ce3979e7b7ee21bf3951b8a462d45c29c.
It seems like this might not be necessary after all.
However some other change made on this branch seems to have fixed
the .svelte.d.ts imports
* Introduce i18n-bundles to remove circular import
There was a circular import i18n.ts <-> i18n-translate.ts
* Create own directory for i18n
* Move lib/i18n/translate to lib/translate
* This restores tree shaking
* Update tsconfig libs and module
* es2018-2020 have wide support on all modern browsers including
* Switch bundles and langs inside i18n to variables again
* Add missing copyright header
* Rename translate.ts to ftl.ts
* Remove the symlinks again
I added them to fix to have completion for tr, however this would have
also have meant to abandon the tree shaking.
As we want to have tree shaking, it's also not necessary to have the
symlinks anymore
* Revert "Update tsconfig libs and module"
This reverts commit 0a96776a475e9901c1f9f3407c726d1d002fb9ef.
* move withCollapsedWhitespace back to i18n/utils
* Add back /ts as in rootDirs
ts_library() is deprecated and will presumably be dropped from a
future rules_nodejs, and it wasn't working with the jest tests
after updating, so we switch over to ts_project().
There are some downsides:
- It's a bit slower, as the worker mode doesn't appear to function
at the moment.
- Getting it working with a mix of source files and generated files
was quite tricky, especially as things behave differently on Windows,
and differently when editing with VS Code. Solved with a small patch
to the rules, and a wrapper script that copies everything into the
bin folder first. To keep VS Code working correctly as well, the built
files are symlinked into the source folder.
- TS libraries are not implicitly linked to node_modules, so they
can't be imported with an absolute name like "lib/proto" - we need
to use relative paths like "../lib/proto" instead. Adjusting "paths"
in tsconfig.json makes it work for TS compilation, but then it fails
at the esbuild stage. We could resolve it by wrapping the TS
libraries in a subsequent js_library() call, but that has the downside
of losing the transient dependencies, meaning they need to be listed
again. Alternatively we might be able to solve it in the future by
adjusting esbuild, but for now the paths have been made relative to
keep things simple.
Upsides:
- Along with updates to the Svelte tooling, Svelte typing has improved.
All exports made in a Svelte file are now visible to other files that
import them, and we no longer rebuild the Svelte files when TS files
are updated, as the Svelte files do no type checking themselves, and
are just a simple transpilation. Svelte-check now works on Windows again,
and there should be no errors when editing in VS Code after you've
built the project. The only downside seems to be that cmd+clicking
on a Svelte imports jumps to the .d.ts file instead of the original now;
presumably they'll fix that in a future plugin update.
- Each subfolder now has its own tsconfig.json, and tsc can be called
directly for testing purposes (but beware it will place build products
in the source tree): ts/node_modules/.bin/tsc -b ts
- We can drop the custom esbuild_toolchain, as it's included in the
latest rules_nodejs.
Other changes:
- "image_module_support" is moved into lib/, and imported with
<reference types=...>
- Images are now imported directly from their npm package; the
extra copy step has been removed.
Windows users may need to use "bazel clean" before building this,
due to old files lying around in the build folder.