* 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
- Fixes an issue where tasks would continue to appear active for a while
after they had finished on Unix platforms
- The latest n2 now behaves the same way as ninja when substituting
variables, so we no longer need to do the substitution ourselves.
* Implement import log screen in Svelte
* Show filename in import log screen title
* Remove unused NoteRow property
* Show number of imported notes
* Use a single nid expression
* Use 'count' as variable name for consistency
* Import from @tslib/backend instead
* Fix summary_template typing
* Fix clippy warning
* Apply suggestions from code review
* Fix imports
* Contents -> Fields
* Increase max length of browser search bar
https://github.com/ankitects/anki/pull/2568/files#r1255227035
* Fix race condition in Bootstrap tooltip destruction
https://github.com/twbs/bootstrap/issues/37474
* summary_template -> summaryTemplate
* Make show link a button
* Run import ops on Svelte side
* Fix geometry not being restored in CSV Import page
* Make VirtualTable fill available height
* Keep CSV dialog modal
* Reword importing-existing-notes-skipped
* Avoid mentioning matching based on first field
* Change tick and cross icons
* List skipped notes last
* Pure CSS spinner
* Move set_wants_abort() call to relevant dialogs
* Show number of imported cards
* Remove bold from first sentence and indent summaries
* Update UI after import operations
* Add close button to import log page
Also make virtual table react to resize event.
* Fix typing
* Make CSV dialog non-modal again
Otherwise user can't interact with browser window.
* Update window modality after import
* Commit DB and update undo actions after import op
* Split frontend proto into separate file, so backend can ignore it
Currently the automatically-generated frontend RPC methods get placed in
'backend.js' with all the backend methods; we could optionally split them
into a separate 'frontend.js' file in the future.
* Migrate import_done from a bridgecmd to a HTTP request
* Update plural form of importing-notes-added
* Move import response handling to mediasrv
* Move task callback to script section
* Avoid unnecessary :global()
* .log cannot be missing if result exists
* Move import log search handling to mediasrv
* Type common params of ImportLogDialog
* Use else if
* Remove console.log()
* Add way to test apkg imports in new log screen
* Remove unused import
* Get actual card count for CSV imports
* Use import type
* Fix typing error
* Ignore import log when checking for changes in Python layer
* Apply suggestions from code review
* Remove imported card count for now
* Avoid non-null assertion in assignment
* Change showInBrowser to take an array of notes
* Use dataclasses for import log args
* Simplify ResultWithChanges in TS
* Only abort import when window is modal
* Fix ResultWithChanges typing
* Fix Rust warnings
* Only log one duplicate per incoming note
* Update wording about note updates
* Remove caveat about found_notes
* Reduce font size
* Remove redundant map
* Give credit to loading.io
* Remove unused line
---------
Co-authored-by: RumovZ <gp5glkw78@relay.firefox.com>
Combined with the previous changes, this allows the mobile clients to
build the web components without having to set up a Python environment,
and should speed up AnkiDroid CI.
Easier to import from, and allows us to declare the output of the build
action without having to iterate over all the proto filenames. Have
confirmed it doesn't break esbuild's tree shaking.
- Don't bake modified PATH in to build.ninja; instead set it at run time.
- Add win audio in build.rs, as doing it in run.bat results in it being
added multiple times when you run multiple times.
I'd introduced maybe_reconfigure_build() after running into issues where
configure was not being invoked, but have discovered why that was happening:
the out folder path must be identical to the canonical path listed in
build.ninja, which it wasn't when a symlink was used. With this change,
we avoid having to invoke ninja twice, and get visibility into the
configure step.
This also makes rsbridge only depend on out/env, which prevents it from
being rebuilt when any reconfigure happens.
* eslint-plugin-svelte3 -> eslint-plugin-svelte
The former is deprecated, and blocks an update to Svelte 4.
Also drop unused svelte2tsx and types package.
* Drop unused symbols code for now
It may be added back in the future, but for now dropping it will save
200k from our editor bundle.
* Remove sass and caniuse-lite pins
The latter no longer seems to be required. The former was added to
suppress deprecation warnings when compiling the old bootstrap version
we have pinned. Those are hidden by the build tool now (though we really
need to address them at one point: https://github.com/ankitects/anki/issues/1385)
Also removed unused files section.
* Prevent proto compile from looking in node_modules/@types/sass
When deps are updated, tsc aborts because @types/sass is a dummy package
without an index.d.ts file.
* Filter Svelte warnings out of ./run
* Update to latest Bootstrap
This fixes the deprecation warnings we were getting during build:
bootstrap doesn't accept runtime CSS variables being set in Sass, as
it wants to apply transforms to the colors.
Closes#1385
* Start port to Svelte 4
- svelte-check tests have a bunch of failures; ./run works
- Svelte no longer exposes internals, so we can't use create_in_transition
- Also update esbuild and related components like esbuild-svelte
* Fix test failures
Had to add some more a11y warning ignores - have added
https://github.com/ankitects/anki/issues/2564 to address that in the
future.
* Remove some dependency pins
+ Remove sass, we don't need it directly
* Bump remaining JS deps that have a current semver
* Upgrade dprint/license-checker/marked
The new helper method avoids marked printing deprecation warnings to
the console.
Also remove unused lodash/long types, and move lodahs-es to devdeps
* Upgrade eslint and fluent packages
* Update @floating-ui/dom
The only dependencies remaining are currently blocked:
- Jest 29 gives some error about require vs import; may not be worth
investigating if we switch to Deno for the tests
- CodeMirror 6 is a big API change and will need work.
* Roll dprint back to an earlier version
GitHub dropped support for Ubuntu 18 runners, causing dprint's artifacts
to require a glibc version greater than what Anki CI currently has.
Also fix minilints declaring a stamp it wasn't creating. The same
approach is necessary with archives now too, as it no longer executes
under a standard "runner run".
For now, rustls is hard-coded - we could pass the desired TLS impl in
from the ./ninja script, but the runner is not recompiled frequently
anyway.
Workspace deps were introduced in Rust 1.64. They don't cover all the
cases that Hakari did unfortunately, but they are simpler to maintain,
and they avoid a couple of issues that Hakari had:
- It sometimes made updating dependencies harder due to the locked versions,
so you had to disable Hakari, do the updates, and then re-generate (
e.g. 943dddf28f)
- The current Hakari config was breaking AnkiDroid's build, as it was
stopping a cross-compile from functioning correctly.
Provides better visibility into what the build is currently doing.
Motivated by slow node.js downloads making the build appear stuck.
You can test this out by running ./tools/install-n2 then building
normally. Please report any problems, and 'cargo uninstall n2' to get
back to the old behaviour. It works on Windows, but prints a new line
each second instead of redrawing the same area.
A couple of changes were required for compatibility:
- n2 doesn't resolve $variable names inside other variables, so the
resolution needs to be done by our build generator.
- Our inputs and outputs in build.ninja need to be listed in a deterministic
order to avoid unwanted rebuilds. I've made a few other tweaks so the
build file should now be fully-deterministic.
* Fix .no-reduce-motion missing from graphs spinner, and not being honored
* Begin migration from protobuf.js -> protobuf-es
Motivation:
- Protobuf-es has a nicer API: messages are represented as classes, and
fields which should exist are not marked as nullable.
- As it uses modules, only the proto messages we actually use get included
in our bundle output. Protobuf.js put everything in a namespace, which
prevented tree-shaking, and made it awkward to access inner messages.
- ./run after touching a proto file drops from about 8s to 6s on my machine. The tradeoff
is slower decoding/encoding (#2043), but that was mainly a concern for the
graphs page, and was unblocked by
37151213cd
Approach/notes:
- We generate the new protobuf-es interface in addition to existing
protobuf.js interface, so we can migrate a module at a time, starting
with the graphs module.
- rslib:proto now generates RPC methods for TS in addition to the Python
interface. The input-arg-unrolling behaviour of the Python generation is
not required here, as we declare the input arg as a PlainMessage<T>, which
marks it as requiring all fields to be provided.
- i64 is represented as bigint in protobuf-es. We were using a patch to
protobuf.js to get it to output Javascript numbers instead of long.js
types, but now that our supported browser versions support bigint, it's
probably worth biting the bullet and migrating to bigint use. Our IDs
fit comfortably within MAX_SAFE_INTEGER, but that may not hold for future
fields we add.
- Oneofs are handled differently in protobuf-es, and are going to need
some refactoring.
Other notable changes:
- Added a --mkdir arg to our build runner, so we can create a dir easily
during the build on Windows.
- Simplified the preference handling code, by wrapping the preferences
in an outer store, instead of a separate store for each individual
preference. This means a change to one preference will trigger a redraw
of all components that depend on the preference store, but the redrawing
is cheap after moving the data processing to Rust, and it makes the code
easier to follow.
- Drop async(Reactive).ts in favour of more explicit handling with await
blocks/updating.
- Renamed add_inputs_to_group() -> add_dependency(), and fixed it not adding
dependencies to parent groups. Renamed add() -> add_action() for clarity.
* Remove a couple of unused proto imports
* Migrate card info
* Migrate congrats, image occlusion, and tag editor
+ Fix imports for multi-word proto files.
* Migrate change-notetype
* Migrate deck options
* Bump target to es2020; simplify ts lib list
Have used caniuse.com to confirm Chromium 77, iOS 14.5 and the Chrome
on Android support the full es2017-es2020 features.
* Migrate import-csv
* Migrate i18n and fix missing output types in .js
* Migrate custom scheduling, and remove protobuf.js
To mostly maintain our old API contract, we make use of protobuf-es's
ability to convert to JSON, which follows the same format as protobuf.js
did. It doesn't cover all case: users who were previously changing the
variant of a type will need to update their code, as assigning to a new
variant no longer automatically removes the old one, which will cause an
error when we try to convert back from JSON. But I suspect the large majority
of users are adjusting the current variant rather than creating a new one,
and this saves us having to write proxy wrappers, so it seems like a
reasonable compromise.
One other change I made at the same time was to rename value->kind for
the oneofs in our custom study protos, as 'value' was easily confused
with the 'case/value' output that protobuf-es has.
With protobuf.js codegen removed, touching a proto file and invoking
./run drops from about 8s to 6s.
This closes#2043.
* Allow tree-shaking on protobuf types
* Display backend error messages in our ts alert()
* Make sourcemap generation opt-in for ts-run
Considerably slows down build, and not used most of the time.
A couple of motivations for this:
- genbackend.py was somewhat messy, and difficult to change with the
lack of types. The mobile clients used it as a base for their generation,
so improving it will make life easier for them too, once they're ported.
- It will make it easier to write a .ts generator in the future
- We currently implement a bunch of helper methods on protobuf types
which don't allow us to compile the protobuf types until we compile
the Anki crate. If we change this in the future, we will be able to
do more of the compilation up-front.
We no longer need to record the services in the proto file, as we can
extract the service order from the compiled protos. Support for map types
has also been added.
* Store coordinates as ratios of full size
* Use single definition for cappedCanvasSize()
* Move I/O review code into ts/image-occlusion
A bit simpler when it's all in one place.
* Reduce number precision, and round to whole pixels
>>> n=10000
>>> for i in range(1, int(n)): assert i == round(float("%0.4f" % (i/n))*n)
* Minor typing tweak
So, it turns out that typing is mostly broken in ts/image-occlusion.
We're importing from fabric which is a js file without types, so types
like fabric.Canvas are resolving to any.
I first tried switching to `@types/fabric`, which introduced a slew of
typing errors. Wasted a few hours trying to address them, before deciding
to give up on it, since the types were not complete. Then found fabric
has a 6.0 beta that introduces typing, and spent some time with that, but
ran into some new issues as it still seems to be a work in progress.
I think we're probably best off waiting until it's out and stabilized
before sinking more effort into this.
* Refactor (de)serialization of occlusions
To make the code easier to follow/maintain, cloze deletions are now decoded/
encoded into simple data classes, which can then be converted to Fabric objects
and back. The data objects handle converting from absolute/normal positions, and
producing values suitable for writing to text (eg truncated floats).
Various other changes:
- Polygon points are now stored as 'x,y x2,y2 ...' instead of JSON in cloze
divs, as that makes the handling consistent with reading from cloze deletion
text.
- Fixed the reviewer not showing updated placement when a polygon was moved.
- Disabled rotation controls in the editor, since we don't support rotation during
review.
- Renamed hideInactive to occludeInactive, as it wasn't clear whether the former
meant to hide the occlusions, or keep them (hiding the content). It's stored
as 'oi=1' in the cloze text.
* Increase canvas size limit, and double pixels when required.
* Size canvas based on container size
This results in sharper masks when the intrinsic image size is smaller
than the container, and more legible ones when the container is smaller than
the intrinsic image size.
By using the container instead of the viewport, we account for margins,
and when the pixel ratio is 1x, the canvas size and container size should
match.
* Disable zoom animation on editor load
* Default to rectangle when adding new occlusions
* Allow users to add/update notes directly from mask editing page
* The mask editor needs to work with css pixels, not actual pixels
The canvas and image were being scaled too large, which impacted
performance.
* Migrate check_copyright to Rust
* Add a new lint to check accidental usages of /// in ts/svelte comments
* Fix a bunch of incorrect jdoc comments
* Move contributor check into minilints
Will allow users to detect the issue locally with './ninja check'
before pushing to CI.
* Make Cargo.toml consistent with other crates
* Cloze styling is not required in I/O notetype
* Use raw string for IO template
* Rename to notetype.css and use more specific ids
* Move internal i/o styling into runtime
Storing it in the notetype makes it difficult to make changes, and
makes it easier for the user to break.
* Fix misaligned occlusions
At larger screen sizes, the canvas was not increasing above its configured
size, so it ended up being placed top center instead of expanding to fit
the entire container area.
To resolve this, both the image and canvas are forced to the container
size, and the container is constrained to the size of the viewport,
with the same aspect ratio as the image.
Closes#2492