Commit Graph

132 Commits

Author SHA1 Message Date
antecrescent
60b25535ef
Make SvelteCheck and ViteTest respect YARN_BINARY (#3231) 2024-06-28 18:00:38 +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
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
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
7121cb5132 Fix arm64 node checksum 2024-04-01 17:17:44 +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
antecrescent
58ce29f461
Refactor offline build process and add offline generation of Sphinx docs (#3082)
* Simplify the offline build

The two environment variables OFFLINE_BUILD and NO_VENV jointly provide
the ability to build Anki fully offline. This commit boils them down
into just one, namely OFFLINE_BUILD.

The rationale being that first, OFFLINE_BUILD implies the use of
a custom non-networked Python environment.
Second, building Anki with a custom Python environment in a networked
setting is a use case, that we currently do not support.
Developers in need of such a solution may want to give containerized
development environments a try. Users could also look into building
Anki fully offline instead.

* Add documentation for offline builds.

* Add support for offline generation of Sphinx documentation.

Control installation of Sphinx dependencies via the network through the
OFFLINE_BUILD environment variable.

* Add documentation for offline generation of Sphinx documentation.
2024-03-27 13:51:09 +00:00
Damien Elmes
cadbb6ad8d Ensure rsbridge gets rebuilt when buildhash changes
Hopefully fixes https://forums.ankiweb.net/t/anki-24-04-beta/41792/2
2024-03-01 13:25:56 +07:00
Damien Elmes
bfaa28feda Mac Qt bundle rebuilt without .dSYM files 2024-02-29 13:33:12 +07:00
Damien Elmes
8ab18d276a Update Qt bundle to 6.6.2 2024-02-28 15:34:09 +07:00
Damien Elmes
151dd0fb34 Hard-code SDK root when building
PyOxidizer's detection seems to be failing on the machine I'm running
from.
2024-02-28 15:34:09 +07:00
Damien Elmes
09f032b2e8 Ensure PyOxidizer checked out when bundling 2024-02-13 10:56:53 +10:00
Damien Elmes
efa9c5a39a Remove inverted print statement from recent PR 2024-02-13 10:54:39 +10:00
Kai Knoblich
54b1cc5689
Honor NINJA_STATUS if already set (#2984)
* Honor NINJA_STATUS if already set

Allow build environments at downstream to use their own configured
NINJA_STATUS if set.

* Update CONTRIBUTORS
2024-02-01 14:56:14 +10:00
Kai Knoblich
42cc2c913c
Add support for offline builds (#2963)
* CONTRIBUTORS: Add myself to the contributors list

* Add support for offline builds

Downloading files during build time is a non-starter for FreeBSD ports
(and presumably for other *BSD ports and some Linux distros as well).

In order to still be able to build Anki successfully, two new
environment variables have been added that can be set accordingly:

* NO_VENV: If set, the Python system environment is used instead of
  a venv. This is necessary if there are no usable Python wheels for a
  platform, e.g. PyQt6.

* OFFLINE_BUILD: If set, the git repository synchronization (translation
  files, build hash, etc.) is skipped.

To successfully build Anki offline, following conditions must be met:

1. All required dependencies (node, Python, rust, yarn, etc.) must be
   present in the build environment.

2. The offline repositories for the translation files must be
   copied/linked to ftl/qt-repo and ftl/core-repo.

3. The Python pseudo venv needs to be setup:

   $ mkdir out/pyenv/bin
   $ ln -s /path/to/python out/pyenv/bin/python
   $ ln -s /path/to/protoc-gen-mypy out/pyenv/bin/protoc-gen-mypy

4. Create the offline cache for yarn and use its own environment
   variable YARN_CACHE_FOLDER to it:

   YARN_CACHE_FOLDER=/path/to/the/yarn/cache
   $ /path/to/yarn install --ignore-scripts

5. Build Anki:

   $ /path/to/cargo build --package runner --release --verbose --verbose
   $ OFFLINE_BUILD=1 \
     NO_VENV=1 \
     ${WRKSRC}/out/rust/release/runner build wheels
2024-01-31 09:13:46 +10:00
Damien Elmes
d6549623af Update Python
Closes #2923
2024-01-19 15:11:17 +10:00
Damien Elmes
20dc281558 Revert "Update to Qt 6.6.1 on Mac"
This reverts commit cbab96ec75.

This moves the bundle back to Qt 5.3 due to
https://forums.ankiweb.net/t/anki-23-12-mac-apple-qt6-dmg-crashing-on-browser/38783

We'll move back up when 6.6.2 comes out in mid-late Jan.
2023-12-28 18:17:50 +10:00
Abdo
3e5458b3db
Skip tests failing around rollover hour (#2909)
* Skip tests failing around rollover hour

* Set ANKI_TEST_MODE for Rust tests instead
2023-12-28 18:06:19 +10:00
Damien Elmes
425d9e3fe1 Fix mpv not working out of the box in win32 source build
Regressed in 711c28e1a5
2023-12-06 11:34:56 +10:00
Damien Elmes
cbab96ec75 Update to Qt 6.6.1 on Mac
This also fixes the Mac bundle using an old Qt version.

Linux held back due to ABI breakage; should be fixed in about a week
when PyQt 6.6.1 comes out. Windows build also fails to run - not sure
if it's the same issue or not.
2023-12-04 16:15:52 +10:00
Abdo
dc3bd3efde
Replace css_browser_selector with our own implementation (#2854)
* Replace css_browser_selector

* Add classes to root element instead of body

* Export addBrowserClasses() in reviewer_extras for mobile clients (dae)

* Avoid setting .mac on iOS devices (dae)
2023-11-30 10:57:33 +10:00
Abdo
e88dfb68a5
Load MathJax's text-chtml-full component in reviewer/previewer (#2836)
* Load MathJax's text-chtml-full in review screens

* Remove no longer needed MathJax extensions
2023-11-20 16:50:55 +10:00
Damien Elmes
a5cd3f32f4 Fix broken bundling on Windows 11
When Windows notices "install" in the filename it triggers a UAC elevation,
causing 'cargo run' to fail.
2023-11-20 12:01:34 +10:00
Damien Elmes
f9d5f422e4 Fix Android backend failing to build on Windows with n2 2023-11-08 13:31:35 +10:00
Damien Elmes
afa39e7d96 Give users a hint when they try to build from a source tarball 2023-11-04 08:35:44 +10:00
Damien Elmes
b4c9e54347 Jemalloc no longer seems to fail in cross-compile builds 2023-11-02 19:56:08 +10:00
Damien Elmes
373a63f610 Work around Xcode 15 breaking older macOS versions 2023-11-02 19:54:44 +10:00
Damien Elmes
9600f033f7 Add reviewer_extras.css
Will help with https://github.com/ankidroid/Anki-Android-Backend/issues/313
2023-10-27 03:07:31 +10:00
Damien Elmes
b2d515c8bb Update to Qt 6.5.3 on Windows/Mac
+ Fix incorrect version selection on Mac

Closes #2733 (except for Linux users)
2023-10-15 09:48:36 +10:00
Gulshan Singh
a230c754b9
Add Sphinx documentation generation functionality (#2720)
* Add Sphinx documentation generation functionality

* sphinx-docs -> python/sphinx

* Use ninja instead of make

* Update copyright info in sphinx docs

* Run sphinx-apidoc before building Sphinx docs

* Cleanup Sphinx path insertion

* Don't write build outputs into source; use autoapi

* aqt -> _aqt

* Mention sphinx in development.md

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2023-10-13 13:03:54 +10:00
Damien Elmes
d7ff99780e Improve Python Protobuf speed
upb was being included in the bundle, but not found at run time due
to src files being embedded in the binary.
2023-10-04 13:36:47 +10:00
Damien Elmes
2ab8aa002e QtQml was also required 2023-09-24 16:42:26 +10:00
Damien Elmes
52293dc371 Update Qt for Mac bundle 2023-09-24 16:24:11 +10:00
Damien Elmes
d441680984 Remove select image button in I/O
Closes #2620
2023-09-17 11:51:48 +10:00
RumovZ
850043b49b
Tooltips for CSV import and import page refactoring (#2655)
* 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.
2023-09-14 09:06:15 +10:00
RumovZ
14de8451dc
Merging Notetypes on Import (#2612)
* 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
2023-09-09 09:00:55 +10:00
Damien Elmes
6cf38b0326 Update to the latest nextest; use --locked as recommended by them 2023-09-08 07:57:15 +10:00
Damien Elmes
b29c147a5d Improve error message when command fails to run 2023-09-07 14:55:52 +10:00
Damien Elmes
25cab1c67a Revert "Revert "Pull in latest upstream n2 fixes""
Was some debug code in my status hiding patch; commit link updated.
2023-08-31 08:31:43 +10:00
Damien Elmes
1100bb6fe8 Revert "Pull in latest upstream n2 fixes"
This reverts commit e07e60495b.

Latest update has an issue on macOS.
2023-08-31 08:00:34 +10:00
Damien Elmes
e07e60495b Pull in latest upstream n2 fixes
- 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.
2023-08-31 07:40:57 +10:00
Damien Elmes
dcf91fcc50 Fix ninja compatibility 2023-08-25 02:45:16 +10:00
Damien Elmes
239e964c42
Shift output suppression into n2 (#2618)
After updating with tools/install-n2, you should now be able to see
the last line of long-running commands like cargo invocations.
2023-08-23 11:59:52 +10:00
Abdo
98715e593a
Improve presentation of importing results (#2568)
* 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>
2023-08-02 20:29:44 +10:00
Derek Dang
ca41dfeb3d
Fix a11y-noninteractive-element-interactions (#2578)
* Fix a11y-noninteractive-element-interactions

* Update CONTRIBUTORS

* Fix formatting issues

* Address a11y-noninteractive-element-interactions
2023-07-17 14:34:09 +10:00
Damien Elmes
fc0bff4166 Add updated script for transforming ftl text 2023-07-06 22:27:09 +10:00
Damien Elmes
13572a86b2 Move i18n helpers into ftl/, with a single main.rs
Clap gives us a nice help message and better arg parsing
2023-07-04 10:47:15 +10:00
Damien Elmes
79779f915e Avoid :pages prefix on ts/*, so build rule matches folder location 2023-07-03 17:24:27 +10:00
Damien Elmes
a06e2335c4 Merge the separate editor index files
They're almost the same, and the extra work competes for CPU cores
with the other build steps.
2023-07-03 17:24:27 +10:00
Damien Elmes
9f5b7e79cc Move markpure to TypeScript
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.
2023-07-03 17:24:27 +10:00