Import Anki decks with their files and history

Files in content: the person's images and sounds as asset rows synced like
all content, their files kept by hash on each device, uploaded after each
sync, downloaded on demand and checked against their hash
(core/asset/AssetRepository). Rich text names them as asset:<id> URLs, in
the editor's image block and an audio block of ours; any other URL is never
fetched. Sounds play through audioplayers, one at a time. Content holding
only an image or a sound isn't blank, and lists show it as such.

The Anki import ("Import from Anki" under Add material): .apkg and .colpkg
packages in all three formats Anki has written, read on an isolate of their
own. Modern packages compress everything with zstd in frames that don't
record their size, which pure_zstd v1.0.0 refuses; our fork decodes them.
Fields become rich text by a converter of our own (lines, lists, formatting,
images, sounds, cloze deletions hidden on the front). One card per note,
the files first, studysets as chosen (flatten, sub-studysets, or tags by
subdeck), the notes' tags, and, if wanted, the review history, which FSRS
replays: the first template's reviews to the card's schedule, a reversed
note type's second to the reverse one.

Imported cards say where they came from in their first revision (card
schema 3); the dashboard doesn't count them as written. The test fixtures
are exported by Anki itself (tool/anki/make_fixtures.py).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-02 04:52:02 +02:00
commit a6d5769a2e
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -30,12 +30,20 @@ dependencies:
git:
url: https://code.halkyon.app/project-halkyon/appflowy-editor.git
ref: 0dac8a046e91ac89c0ffa13e2d603ebf50873332
# Anki packages are zip files.
archive: ^4.0.7
# Sounds in content (pronunciations): one package for all five platforms; on
# Linux it plays through GStreamer, whose development files a Linux build needs.
audioplayers: ^6.8.1
clock: ^1.1.3
crypto: ^3.0.7
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.5
equatable: ^3.0.0
expressive_loading_indicator: ^0.0.1
# Picks the files to import (and later the images to add): flutter.dev's own.
file_selector: ^1.1.0
flutter:
sdk: flutter
flutter_bloc: ^9.1.1
@ -52,14 +60,26 @@ dependencies:
go_router: ^18.0.2
halkyon_learn_client:
path: ../halkyon_learn_client
# Anki's fields are HTML; the editor brings this parser along already.
html: ^0.15.6
intl: ^0.20.3
lucide_icons_flutter: ^3.1.20
material_ui: ^1.5.0
path: ^1.9.1
path_provider: ^2.1.6
# Modern Anki packages are zstd-compressed, every frame without its content
# size, which upstream's v1.0.0 refuses. Our fork decodes them, pinned to a
# signed commit of its branch halkyon/unknown-content-size; back to upstream
# once it decodes them too.
pure_zstd:
git:
url: https://code.halkyon.app/project-halkyon/pure-zstd.git
ref: 596b63d5741d479073fbfc78377cc7dbdd342da3
serverpod_auth_idp_flutter: 4.0.3
serverpod_flutter: 4.0.3
serverpod_offline_sync_client: 0.0.8
# Anki collections are SQLite databases (the sync engine already bundles it).
sqlite3: ^3.6.0
url_launcher: ^6.3.2
window_to_front: ^0.0.4
@ -75,8 +95,6 @@ dev_dependencies:
# The sync tests (test/sync/) sign in like the app and read the server's database.
postgres: ^3.5.16
serverpod_auth_core_client: 4.0.3
# The device-migration test builds local databases like the sync engine does.
sqlite3: ^3.6.0
yaml: ^3.1.4
dependency_overrides: