mirror of
https://github.com/ankitects/anki.git
synced 2025-11-13 16:17:13 -05:00
* 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.
186 lines
6.2 KiB
TypeScript
186 lines
6.2 KiB
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
import {
|
|
DeckConfig_Config_AnswerAction,
|
|
DeckConfig_Config_LeechAction,
|
|
DeckConfig_Config_NewCardGatherPriority,
|
|
DeckConfig_Config_NewCardInsertOrder,
|
|
DeckConfig_Config_NewCardSortOrder,
|
|
DeckConfig_Config_ReviewCardOrder,
|
|
DeckConfig_Config_ReviewMix,
|
|
} from "@generated/anki/deck_config_pb";
|
|
import * as tr from "@generated/ftl";
|
|
|
|
import type { Choice } from "$lib/components/EnumSelector.svelte";
|
|
|
|
export function newGatherPriorityChoices(): Choice<DeckConfig_Config_NewCardGatherPriority>[] {
|
|
return [
|
|
{
|
|
label: tr.deckConfigNewGatherPriorityDeck(),
|
|
value: DeckConfig_Config_NewCardGatherPriority.DECK,
|
|
},
|
|
{
|
|
label: tr.deckConfigNewGatherPriorityDeckThenRandomNotes(),
|
|
value: DeckConfig_Config_NewCardGatherPriority.DECK_THEN_RANDOM_NOTES,
|
|
},
|
|
{
|
|
label: tr.deckConfigNewGatherPriorityPositionLowestFirst(),
|
|
value: DeckConfig_Config_NewCardGatherPriority.LOWEST_POSITION,
|
|
},
|
|
{
|
|
label: tr.deckConfigNewGatherPriorityPositionHighestFirst(),
|
|
value: DeckConfig_Config_NewCardGatherPriority.HIGHEST_POSITION,
|
|
},
|
|
{
|
|
label: tr.deckConfigNewGatherPriorityRandomNotes(),
|
|
value: DeckConfig_Config_NewCardGatherPriority.RANDOM_NOTES,
|
|
},
|
|
{
|
|
label: tr.deckConfigNewGatherPriorityRandomCards(),
|
|
value: DeckConfig_Config_NewCardGatherPriority.RANDOM_CARDS,
|
|
},
|
|
];
|
|
}
|
|
|
|
export function newSortOrderChoices(): Choice<DeckConfig_Config_NewCardSortOrder>[] {
|
|
return [
|
|
{
|
|
label: tr.deckConfigSortOrderTemplateThenGather(),
|
|
value: DeckConfig_Config_NewCardSortOrder.TEMPLATE,
|
|
},
|
|
{
|
|
label: tr.deckConfigSortOrderGather(),
|
|
value: DeckConfig_Config_NewCardSortOrder.NO_SORT,
|
|
},
|
|
{
|
|
label: tr.deckConfigSortOrderCardTemplateThenRandom(),
|
|
value: DeckConfig_Config_NewCardSortOrder.TEMPLATE_THEN_RANDOM,
|
|
},
|
|
{
|
|
label: tr.deckConfigSortOrderRandomNoteThenTemplate(),
|
|
value: DeckConfig_Config_NewCardSortOrder.RANDOM_NOTE_THEN_TEMPLATE,
|
|
},
|
|
{
|
|
label: tr.deckConfigSortOrderRandom(),
|
|
value: DeckConfig_Config_NewCardSortOrder.RANDOM_CARD,
|
|
},
|
|
];
|
|
}
|
|
|
|
export function reviewOrderChoices(fsrs: boolean): Choice<DeckConfig_Config_ReviewCardOrder>[] {
|
|
return [
|
|
{
|
|
label: tr.deckConfigSortOrderDueDateThenRandom(),
|
|
value: DeckConfig_Config_ReviewCardOrder.DAY,
|
|
},
|
|
{
|
|
label: tr.deckConfigSortOrderDueDateThenDeck(),
|
|
value: DeckConfig_Config_ReviewCardOrder.DAY_THEN_DECK,
|
|
},
|
|
{
|
|
label: tr.deckConfigSortOrderDeckThenDueDate(),
|
|
value: DeckConfig_Config_ReviewCardOrder.DECK_THEN_DAY,
|
|
},
|
|
{
|
|
label: tr.deckConfigSortOrderAscendingIntervals(),
|
|
value: DeckConfig_Config_ReviewCardOrder.INTERVALS_ASCENDING,
|
|
},
|
|
{
|
|
label: tr.deckConfigSortOrderDescendingIntervals(),
|
|
value: DeckConfig_Config_ReviewCardOrder.INTERVALS_DESCENDING,
|
|
},
|
|
{
|
|
label: fsrs ? tr.deckConfigSortOrderDescendingDifficulty() : tr.deckConfigSortOrderAscendingEase(),
|
|
value: DeckConfig_Config_ReviewCardOrder.EASE_ASCENDING,
|
|
},
|
|
{
|
|
label: fsrs ? tr.deckConfigSortOrderAscendingDifficulty() : tr.deckConfigSortOrderDescendingEase(),
|
|
value: DeckConfig_Config_ReviewCardOrder.EASE_DESCENDING,
|
|
},
|
|
{
|
|
label: tr.deckConfigSortOrderRelativeOverdueness(),
|
|
value: DeckConfig_Config_ReviewCardOrder.RELATIVE_OVERDUENESS,
|
|
},
|
|
{
|
|
label: tr.deckConfigSortOrderRandom(),
|
|
value: DeckConfig_Config_ReviewCardOrder.RANDOM,
|
|
},
|
|
{
|
|
label: tr.decksOrderAdded(),
|
|
value: DeckConfig_Config_ReviewCardOrder.ADDED,
|
|
},
|
|
{
|
|
label: tr.decksLatestAddedFirst(),
|
|
value: DeckConfig_Config_ReviewCardOrder.REVERSE_ADDED,
|
|
},
|
|
];
|
|
}
|
|
|
|
export function reviewMixChoices(): Choice<DeckConfig_Config_ReviewMix>[] {
|
|
return [
|
|
{
|
|
label: tr.deckConfigReviewMixMixWithReviews(),
|
|
value: DeckConfig_Config_ReviewMix.MIX_WITH_REVIEWS,
|
|
},
|
|
{
|
|
label: tr.deckConfigReviewMixShowAfterReviews(),
|
|
value: DeckConfig_Config_ReviewMix.AFTER_REVIEWS,
|
|
},
|
|
{
|
|
label: tr.deckConfigReviewMixShowBeforeReviews(),
|
|
value: DeckConfig_Config_ReviewMix.BEFORE_REVIEWS,
|
|
},
|
|
];
|
|
}
|
|
|
|
export function leechChoices(): Choice<DeckConfig_Config_LeechAction>[] {
|
|
return [
|
|
{
|
|
label: tr.actionsSuspendCard(),
|
|
value: DeckConfig_Config_LeechAction.SUSPEND,
|
|
},
|
|
{
|
|
label: tr.schedulingTagOnly(),
|
|
value: DeckConfig_Config_LeechAction.TAG_ONLY,
|
|
},
|
|
];
|
|
}
|
|
|
|
export function newInsertOrderChoices(): Choice<DeckConfig_Config_NewCardInsertOrder>[] {
|
|
return [
|
|
{
|
|
label: tr.deckConfigNewInsertionOrderSequential(),
|
|
value: DeckConfig_Config_NewCardInsertOrder.DUE,
|
|
},
|
|
{
|
|
label: tr.deckConfigNewInsertionOrderRandom(),
|
|
value: DeckConfig_Config_NewCardInsertOrder.RANDOM,
|
|
},
|
|
];
|
|
}
|
|
|
|
export function answerChoices(): Choice<DeckConfig_Config_AnswerAction>[] {
|
|
return [
|
|
{
|
|
label: tr.studyingBuryCard(),
|
|
value: DeckConfig_Config_AnswerAction.BURY_CARD,
|
|
},
|
|
{
|
|
label: tr.deckConfigAnswerAgain(),
|
|
value: DeckConfig_Config_AnswerAction.ANSWER_AGAIN,
|
|
},
|
|
{
|
|
label: tr.deckConfigAnswerGood(),
|
|
value: DeckConfig_Config_AnswerAction.ANSWER_GOOD,
|
|
},
|
|
{
|
|
label: tr.deckConfigAnswerHard(),
|
|
value: DeckConfig_Config_AnswerAction.ANSWER_HARD,
|
|
},
|
|
{
|
|
label: tr.deckConfigShowReminder(),
|
|
value: DeckConfig_Config_AnswerAction.SHOW_REMINDER,
|
|
},
|
|
];
|
|
}
|