Commit Graph

67 Commits

Author SHA1 Message Date
Henrik Giesel
4601ebb347 Create lib/keys.ts 2021-09-09 15:37:52 +02:00
Henrik Giesel
5c2911c053 First steps toward tag selection 2021-09-09 15:37:51 +02:00
Henrik Giesel
03818b7c45 Disallow setting, deleting or defining properties on packages 2021-09-03 00:52:39 +02:00
Henrik Giesel
6e0f7c3d53 Implement register-package and export some packages
Exported packages are:
* anki/packages
* anki/shortcuts
* anki/bridgecommand
2021-08-30 14:41:40 +02:00
Damien Elmes
ab8e53f66e fix incorrect calendar day labels
https://forums.ankiweb.net/t/day-of-the-week-legend-on-heatmap/9450/7
2021-08-24 12:17:35 +10:00
Damien Elmes
12ea482c87 expose require() instead of the svelte global
- 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.
2021-08-24 10:22:07 +10:00
Damien Elmes
185e9acd22 split out remaining tags, stats, media and rendering 2021-07-10 23:16:18 +10:00
Damien Elmes
35b059ecdb split out sync, search, scheduler & config 2021-07-10 21:33:12 +10:00
Damien Elmes
9e0a295ab9 split out decks, deckconfig, notes, notetypes 2021-07-10 20:44:22 +10:00
Damien Elmes
18851ace47 split out cards and collection 2021-07-10 19:52:31 +10:00
Damien Elmes
616db33c0e refactor protobuf handling for split/import
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.
2021-07-10 19:17:05 +10:00
Damien Elmes
80b98e0db8 move protobuf into separate folder in preparation for multiple files 2021-07-09 21:02:40 +10:00
Damien Elmes
968bd1b27a specific encoding of strings.json
https://forums.ankiweb.net/t/win10-build-error-unicodedecodeerror-gbk-codec-cant-decode-byte-0x91/10714
2021-06-11 20:12:38 +10:00
Damien Elmes
dbfe12edbf use different toolbar size on Mac
see discussion on 984ab9b6fe
2021-06-05 11:28:36 +10:00
Damien Elmes
7c5e974ae5 hook up some missing translations in deck options screen 2021-05-26 14:41:18 +10:00
Damien Elmes
0026506543 update ts deps
- prettier's formatting has changed, so files needed to be reformatted
- dart is spitting out deprecation warnings like:

254 │   2: $spacer / 2,
    │      ^^^^^^^^^^^
    ╵
    bazel-out/darwin-fastbuild/bin/ts/sass/bootstrap/_variables.scss 254:6  @import
    ts/sass/button_mixins.scss 2:9                                          @use
    ts/components/ColorPicker.svelte 2:5                                    root stylesheet

DEPRECATION WARNING: Using / for division is deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div($grid-gutter-width, 2)
2021-05-26 09:37:40 +10:00
Henrik Giesel
3a18dce03f Prefer event.which over event.{key,code}
It works better with alternative Latin-based keyboard layouts
2021-05-22 17:50:23 +02:00
Henrik Giesel
c89c42dc37 Base shortcuts with letters no event.key, with symbols/numbers on event.code 2021-05-21 22:45:55 +02:00
Henrik Giesel
5ef056a23e Make numpad keys also cancel current shortcut sequence 2021-05-21 19:03:06 +02:00
Henrik Giesel
9d212487c6 Capitalize keyboard shortcut letters 2021-05-20 18:46:22 +02:00
Henrik Giesel
ddeae60854 Instead of timeouts, make non-related keypresses cancel shortcut sequences 2021-05-20 18:32:53 +02:00
Henrik Giesel
ae19ed527d Switch to keyboard shortcuts based on event.key 2021-05-20 18:28:59 +02:00
Damien Elmes
9edac805ad support card state mutator in test scheduler
Documentation to come
2021-05-17 16:59:02 +10:00
Damien Elmes
70c3b51b0b remove nested terneries and enable lint
@hgiesel would you mind quickly checking I've correctly captured
the logic here?
2021-04-23 13:00:18 +10:00
Damien Elmes
5a8b9f403d move isApplePlatform() into lib/shortcuts, and remove sveltelib file 2021-04-23 11:22:30 +10:00
Henrik Giesel
1d72599a37 Rename anki/ to lib/ for export
import _ from "anki/x";

will become

import _ from "lib/x";

to fit the directory name.
2021-04-23 10:02:28 +10:00
Henrik Giesel
5197e3b779 Prefer optionalModifiers over register multiple shortcuts 2021-04-22 18:15:25 +02:00
Henrik Giesel
31e4b79ff4 Add optionalModifiers parameter to registerShortcut 2021-04-22 17:28:38 +02:00
Henrik Giesel
7aaf7b7fe0 Add license headers 2021-04-22 16:49:30 +02:00
Henrik Giesel
57357a42a5 Satisfy formatter 2021-04-22 15:24:27 +02:00
Henrik Giesel
47809f6230 Add shortcut labels for ColorPicker and Latex items 2021-04-22 14:35:44 +02:00
Henrik Giesel
e95e78da9c Add getPlatformString for making shortcuts to platform string 2021-04-22 13:04:24 +02:00
Henrik Giesel
dc5b13eeab Use registerShortcut within WithShortcut 2021-04-22 01:15:38 +02:00
Henrik Giesel
b57810556d Add lib/shortcuts 2021-04-22 01:15:38 +02:00
Damien Elmes
094c272294 allow postrequest to send a binary body; fix WithGraphData
As far as I can tell, the existing code was transforming the encoded
protobuf data into UTF8, and we're just lucky it wasn't causing problems
with the small message we were sending.
2021-04-20 17:47:52 +10:00
Damien Elmes
377ba1471e support es6 imports in Jest tests
Switching to lodash-es caused Jest to fail. The standard Jest workflow
would be to transpile things with Bazel, but we can do it faster by
bundling with esbuild.

the log in lib.test.ts has revealed numbers are being set as Long instead
of JS numbers, and the published workaround for it is not working :-(
2021-04-17 16:38:45 +10:00
Damien Elmes
d158450e89 add macro for invoking Jest 2021-04-16 23:46:31 +10:00
Damien Elmes
c3fc07ac20 more experimental updates to deck config screen
- try out bootstrap modals - they're not perfect, but let's see how
they go for now. Won't be hard to switch to bridge commands if required.
- handle adding/renaming/removing
- add a class to manage the state
2021-04-16 23:29:21 +10:00
Damien Elmes
c49d6ce49f run black/isort on Python scripts 2021-04-14 18:22:02 +10:00
Damien Elmes
e520e8df02 add missing copyright headers to *.ts 2021-04-13 18:57:08 +10:00
Damien Elmes
26ac64526c disable Jest tests on Windows again
It looks like the templated_args change only masked the error last time;
Jest seems broken on Windows with both the patched .24 version, latest
stable, and the new beta version too, presumably because symlinks are
being handled differently on Windows somehow. It might be possible to
hack around the issue by patching the following file, but I'm not sure:

https://github.com/facebook/jest/blob/master/packages/jest-haste-map/src/crawlers/node.ts
2021-04-12 15:39:46 +10:00
Damien Elmes
9440898e60 add naturalWholeUnit() and basic tests to lib/time.ts
naturalWholeUnit() is not currently used
2021-04-12 14:42:06 +10:00
Damien Elmes
d2eb5c32f4 remove obsolete comment 2021-03-26 21:47:23 +10:00
Damien Elmes
b57e9be46f allow js to request specific i18n modules
Brings the payload on the congrats page with a non-English language
down from about 150k to 15k
2021-03-26 21:43:36 +10:00
Damien Elmes
8920a6f9ea fix handling of variables that don't match ts naming style 2021-03-26 21:34:24 +10:00
Damien Elmes
c039845c16 use singleton + free functions for i18n in ts
This allows for tree shaking, and reduces the congrats page from 150k
with the old enum solution to about 80k.
2021-03-26 20:38:44 +10:00
Damien Elmes
0de7ab87a5 drop legacy enum from ts/ 2021-03-26 19:26:35 +10:00
Damien Elmes
2e704660d6 update remaining TR references in ts/ 2021-03-26 19:24:48 +10:00
Damien Elmes
df93ed0b15 update TR references with args in *.ts; fix average answer time 2021-03-26 19:10:39 +10:00
Damien Elmes
264b9204c0 generate ts methods for translations 2021-03-26 18:11:58 +10:00