Commit Graph

55 Commits

Author SHA1 Message Date
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
Damien Elmes
9aece2a7b8 rework translation handling
Instead of generating a fluent.proto file with a giant enum, create
a .json file representing the translations that downstream consumers
can use for code generation.

This enables the generation of a separate method for each translation,
with a docstring that shows the actual text, and any required arguments
listed in the function signature.

The codebase is still using the old enum for now; updating it will need
to come in future commits, and the old enum will need to be kept
around, as add-ons are referencing it.

Other changes:

- move translation code into a separate crate
- store the translations on a per-file/module basis, which will allow
us to avoid sending 1000+ strings on each JS page load in the future
- drop the undocumented support for external .ftl files, that we weren't
using
- duplicate strings in translation files are now checked for at build
time
- fix i18n test failing when run outside Bazel
- drop slog dependency in i18n module
2021-03-26 09:41:32 +10:00
Damien Elmes
afc2892f2e move to new rules_nodejs protobuf example to unblock upgrade
@hgiesel the tag editor will need to add the following to the rollup
deps:

        "//ts/lib:backend_proto",
        "//ts/lib:fluent_proto",
2021-03-20 10:24:32 +10:00
Damien Elmes
e318dafb6c Revert "sanitize deck description HTML with html-sanitize"
This reverts commit f248b71707.
2021-02-06 13:25:40 +10:00
Damien Elmes
f248b71707 sanitize deck description HTML with html-sanitize
Committing for reference; will roll back afterwards.

This adds approximately 150k to the bundled .js file in release mode.
html-sanitizer might be useful to replace our custom paste filtering
code in the future, but for now I'm not sure it's worth the extra
page load time over doing the filtering in Rust.
2021-02-06 13:25:34 +10:00
Damien Elmes
4ac9ad1407 show actual error when graphData fails
The original reason for the catch-all message was users with bad
data such as decimal intervals, but those get automatically coerced
these days. The common case should now be invalid search strings, which
we can show verbatim.
2021-01-29 14:39:05 +10:00
Henrik Giesel
5abd7ae6f3 Add bridgeCommand helper function 2021-01-26 01:25:54 +01:00
Henrik Giesel
d1980aae68 Get weekday labels via Date.prototype.toLocaleString 2021-01-21 19:38:56 +01:00
Henrik Giesel
7b14449df4 Fix one-off error for Histograms:
examples:
* x0 = -66 and x1 = -64 should yield 65-66 days ago instead of 64-65 days ago
* x0 = -2 and x1 = 0 should yield 1-2 days ago instead of 0-1 days ago
2021-01-07 17:14:31 +01:00
Henrik Giesel
ecbb08e4c5 Add gatherByQueue and gatherByCtype methods 2021-01-04 14:04:51 +01:00
Damien Elmes
3240fd2e15 remove empty es6 group; reference original ts_library instead 2021-01-02 21:18:10 +10:00
Damien Elmes
77c9db5bba plural rules and decimal separator should use bundle's language
Instead of providing the list of languages in preferred order, when
creating a bundle we need to specify the bundle language as the first
language, so that the correct plural rules are used. Fluent's docs
are misleading here; I will submit a PR to fix them.

The old behaviour caused:
https://forums.ankiweb.net/t/bug-in-review-intervals-for-some-languages-in-number-of-cards/5744
2020-12-14 14:23:49 +10:00
Damien Elmes
5bb3d7c114 format_fix -> format; rename svelte-check for consistency 2020-11-12 20:19:32 +10:00