* Fix steps being mistaken for seconds
* Cap steps at `u32::max` seconds
* Fix overflow of steps in Rust
* Prevent overflow of `IntervalKind`
* Prevent overflow in `revlod/mod.rs`
Also replace some `as` with `from` and `try_from` as is recommended to
highlight potential issues.
* Ensure v2 doesn't store overflowing revlog ivls
* Lower steps cap in deck options
Whereas large card intervals are converted to days, revlog intervals use
i32s to store large numbers of seconds.
* Format
* Allow theme change at runtime and add hook
* Save or restore default palette on theme change
* Update aqt widget styles on theme change
* styling fixes
- drop _light_palette, as default_palette serves the same purpose
- save default platform theme, and restore it when switching away
from nightmode
- update macOS light/dark mode on theme switch
- fix unreadable menus on Windows
* update night-mode classes on theme change
This is the easy part - CSS styling that uses standard_css or our
css variables should update automatically. The main remaining issue
is JS code that sets colors based on the theme at the time it's run -
eg the graph code, and the editor.
* switch night mode value on toggle
* expose current theme via a store; switch graphs to use it
https://github.com/ankitects/anki/issues/1471#issuecomment-972402492
* start using currentTheme in editor/components
This fixes basic editing - there are still components that need updating.
* add simple xcodeproj for code completion
* add helper to get currently-active system theme on macOS
* fix setCurrentTheme not being immediately available
* live update tag color
* style().name() doesn't work on Qt5
* automatic theme switching on Windows/Mac
* currentTheme -> pageTheme
* Replace `nightModeKey` with `pageTheme`
Co-authored-by: Damien Elmes <gpg@ankiweb.net>
* 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
* Refactor editor css, fix editor button highlight
- Avoid using webview.css
- Move more buttons css into button_mixins
* Fix DropdownItem appearance
* Fix the visuals of tags
* Make dropdown font slightly smaller
* Give SelectOption a background color
* Move some css from deck-options-base to CardStateCustomizer
* Avoid using core.scss for CardStats
* Avoid using sass/core in congrats package
* Inline core.scss into webview.scss
* Include fusion-vars for base.scss
* need to keep core.scss around for now (dae)
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
The nice thing about the symlink approach is that it allowed tsc -b
to function without any changes to the tsconfig.json file, but it meant
there were extra links we had to maintain. So instead, we just add an
extra rootDirs entry, and add two commented-out lines that can be
uncommented when wanting to build with tsc directly.
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.
The latest svelte-check has revealed we were not passing 'for' in
when we should have been. This is a quick hack to get the tests passing
again, but a better approach that actually makes this accessible again
would be good in the future.
- Means add-on authors should not need to inject any code in their build
- Should be more flexible - we can export multiple libraries if we wish,
and don't have to worry about require() being clobbered by old add-ons.
In order to split backend.proto into a more manageable size, the protobuf
handling needed to be updated. This took more time than I would have
liked, as each language handles protobuf differently:
- The Python Protobuf code ignores "package" directives, and relies
solely on how the files are laid out on disk. While it would have been
nice to keep the generated files in a private subpackage, Protobuf gets
confused if the files are located in a location that does not match
their original .proto layout, so the old approach of storing them in
_backend/ will not work. They now clutter up pylib/anki instead. I'm
rather annoyed by that, but alternatives seem to be having to add an extra
level to the Protobuf path, making the other languages suffer, or trying
to hack around the issue by munging sys.modules.
- Protobufjs fails to expose packages if they don't start with a capital
letter, despite the fact that lowercase packages are the norm in most
languages :-( This required a patch to fix.
- Rust was the easiest, as Prost is relatively straightforward compared
to Google's tools.
The Protobuf files are now stored in /proto/anki, with a separate package
for each file. I've split backend.proto into a few files as a test, but
the majority of that work is still to come.
The Python Protobuf building is a bit of a hack at the moment, hard-coding
"proto" as the top level folder, but it seems to get the job done for now.
Also changed the workspace name, as there seems to be a number of Bazel
repos moving away from the more awkward reverse DNS naming style.
I mourn the time lost trying to track this down :-(
https://github.com/protobufjs/protobuf.js/issues/1014
We can't patch the minified file in dist without essentially duplicating
it, so this change also switches from the external file to including
the src file as part of the bundle.