Commit Graph

233 Commits

Author SHA1 Message Date
Henrik Giesel
4a2d2a75c1 Directly include CSS from bootstrap and codemirror packages 2021-09-02 23:37:16 +02:00
Damien Elmes
767241ed46 put reviews at bottom of reviews graph
https://forums.ankiweb.net/t/new-reviews-graph-design-is-worse-than-it-was-in-2-1-40/9807
2021-08-19 21:43:00 +10:00
Damien Elmes
48c121e4f3 filtered decks w/ scheduling disabled in v3 now log reviews 2021-08-19 20:25:29 +10:00
Damien Elmes
185e9acd22 split out remaining tags, stats, media and rendering 2021-07-10 23:16:18 +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
1d4b58419e add workaround for protobufjs requiring uppercase package names
I mourn the time lost trying to track this down :-(

https://github.com/protobufjs/protobuf.js/issues/1014

We can't patch the minified file in dist without essentially duplicating
it, so this change also switches from the external file to including
the src file as part of the bundle.
2021-07-10 15:24:01 +10:00
Damien Elmes
c79f8ba88f in/out -> request/response
The saved characters weren't worth the increased difficulty when
reading, and the fact that we were deviating from protobuf norms.
2021-06-20 15:49:20 +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
Damien Elmes
7bf661ee05 fix missing cumulative overlays in graphs 2021-05-22 10:19:13 +10:00
Damien Elmes
9674860e2b tweak hover css to work with latest js deps 2021-05-07 17:57:28 +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
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
dc10e6235d Update eslint to 4.22.0 2021-04-22 19:19:39 +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
03f3dfa3d9 switch to full lodash library
Individual packages are going away in v5, and we can rely on tree
shaking to only get what we need.
2021-04-16 20:14:17 +10:00
Henrik Giesel
4a8a051999 Satisfy ./script/svelte-check 2021-04-16 03:10:39 +02:00
Henrik Giesel
efc867815a Pass the svelte check for graphs 2021-04-15 13:09:50 +02:00
Henrik Giesel
e3a3ca3f25 Inline GraphData/GraphPreferences getters/setters into WithGraphData 2021-04-15 13:09:50 +02:00
Henrik Giesel
13decbe608 Generalize ts/graphs/preferences to ts/sveltelib/preferences 2021-04-15 13:09:50 +02:00
Damien Elmes
13d415f8e3 move esbuild into separate repo
Most of our changes have been upstreamed, but the toolchain change
probably won't be merged soon, and a separate git repo will make it
easier to track upstream changes.

@hgiesel output_css=True will need to be changed to output_css="foo.css"
instead
2021-04-15 10:53:49 +10:00
Henrik Giesel
cfb9ed267f Create explicit dependencies for the congrats,editor,graphs scss files 2021-04-13 19:47:03 +02:00
Henrik Giesel
85808e4cbf Make h1 explicitly bold in Graph.svelte 2021-04-13 19:47:03 +02:00
Henrik Giesel
8f0f8f9af8 Use graphs-base and congrats-base 2021-04-13 19:47:03 +02:00
Damien Elmes
62423bd041 add missing copyright headers to *.svelte 2021-04-13 19:02:41 +10:00
Damien Elmes
e520e8df02 add missing copyright headers to *.ts 2021-04-13 18:57:08 +10:00
Damien Elmes
6e4cdc52a6 stop Svelte warnings from failing the build
+ check for them at test time
2021-04-12 14:28:09 +10:00
Damien Elmes
4975f47ea3 update to latest esbuild 2021-04-07 14:54:40 +10:00
abdo
09985ce57f Fix graph labels display in RTL layout 2021-04-02 06:25:38 +03:00
Damien Elmes
b23642d568 update $(location ...) in esbuild inject lines 2021-03-28 09:35:46 +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
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
1ca25c563f update most no-arg TR references in *.svelte 2021-03-26 19:13:30 +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
b435658acb convert no-arg TR references to method invocations in *.ts 2021-03-26 19:10:27 +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
Henrik Giesel
7655f14859 Satisfy svelte_check 2021-03-22 15:41:43 +01:00
Henrik Giesel
6ec721d550 Satisfy formatter 2021-03-22 15:25:49 +01:00
Henrik Giesel
e23b1b77b7 Partially revert "Make sure RangeBox does not trigger update on stores on creation"
This reverts commit 15b19e44b9.
2021-03-22 15:11:36 +01:00
Henrik Giesel
9bbdc616c4 Remove assignment to preferencesPromise: getPreferences will only be called once 2021-03-22 04:03:52 +01:00
Henrik Giesel
10b8a1c3cb Move async and asyncReactive to sveltelib
- sveltelib is a lib for component-agnostic svelte utils
2021-03-22 03:06:53 +01:00
Henrik Giesel
3c5233297a Avoid duplicate initial fetching with asyncReactive 2021-03-22 02:58:19 +01:00
Henrik Giesel
15b19e44b9 Make sure RangeBox does not trigger update on stores on creation 2021-03-22 02:50:16 +01:00
Henrik Giesel
0bbe38ebde Create search and days writable in GraphsPage to allow browserSearch to work 2021-03-22 02:44:08 +01:00
Henrik Giesel
9a864120b2 Fix syntax error introduced by rebase 2021-03-22 01:44:07 +01:00
Henrik Giesel
7dc74004ae Create BrowserSearch component, because we cannot read from stores within slotted content 2021-03-22 01:42:23 +01:00
Henrik Giesel
6d546b0bca Remove pending, and resort to checking for value
- once value is set, it won't be unset
2021-03-22 01:42:23 +01:00
Henrik Giesel
b3851172ba Use preferencesPromise, as refreshing is handled over stores 2021-03-22 01:42:23 +01:00
Henrik Giesel
3363c574c9 Use $-assignments instead of store.set 2021-03-22 01:42:23 +01:00
Henrik Giesel
dd2e180f9b Rename search and days to initialSearch and intitialDays in GraphsPage 2021-03-22 01:42:23 +01:00
Henrik Giesel
672eb20321 Get it to work, if you change the input
- there's still an issue on initial load
2021-03-22 01:42:23 +01:00
Henrik Giesel
3f37153558 Compiles with WithGraphData 2021-03-22 01:42:23 +01:00
Henrik Giesel
c107090906 Move Graph-specific html from GraphsPage to Graph.svelte 2021-03-22 01:42:21 +01:00
Henrik Giesel
36e14cd525 Add WithGraphData 2021-03-22 01:40:51 +01:00
Henrik Giesel
e11b31c29d Rename asyncRefresh to asyncReactive 2021-03-22 01:40:51 +01:00
Henrik Giesel
75a8b7d318 Improve implementation of asyncRefresh 2021-03-22 01:40:51 +01:00
Henrik Giesel
a9c16a3cd8 Add (probably non-working) asyncRefresh 2021-03-22 01:40:51 +01:00
Henrik Giesel
f82a02bd2e Add Svelte async hook 2021-03-22 01:40:51 +01:00
Henrik Giesel
5b9981e04a Add comment where to find global styles 2021-03-21 16:04:38 +01:00
Henrik Giesel
af307a6c4a Move ticks.scss directly into Graph.svelte 2021-03-21 15:59:11 +01:00
Damien Elmes
7d8f19e6e4 merge in Henrik's TS/Svelte refactor with some changes
- The previous commits moved the majority of the remaining global css
into components; move the remaining @emotion/css references into
ticks.scss and the styling of the Graph.svelte. This is not as elegant
as the emotion solution, but builds a whole lot faster, and most of
our styling can be scoped to a component anyway.
- Leave the .html files in ts/ for now. AnkiMobile uses them, and
AnkiDroid likely will in the future too. In the long run we'll likely
move to loading the JS into an existing page instead of loading a
separate page, but at that point we can just exclude the .html file from
copy_files_into_group() without affecting other clients.

Closes #1074
2021-03-21 23:01:18 +10:00
Damien Elmes
95ccfc1ed3 move some cumulative-overlay-specific styling out of shared css 2021-03-21 20:18:05 +10:00
Damien Elmes
9dc6e059f2 add HoverColumns.svelte for hoverzone styling 2021-03-21 19:58:39 +10:00
Damien Elmes
7bc41366e8 add CumulativeOverlay.svelte for area styling 2021-03-21 19:50:35 +10:00
Damien Elmes
6e12348cfd add Tooltip.svelte so we can encapsulating styling 2021-03-21 19:35:38 +10:00
Damien Elmes
dbe5d43ba0 bundle all Svelte css into separate file
- svelte compilation outputs a separate .css file for each component
- compilation also adds an "import foo.css" to the top of each generated
.mjs file
- when the .mjs files are bundled into app.js, esbuild creates an app.css
as well
- graphs.scss was renamed to graphs_shared.scss and imported in the
top level GraphsPage. Henrik's style refactoring would be a better path
forward, but I needed to make this change for now, as the filenames were
conflicting.
2021-03-21 16:06:36 +10:00
Damien Elmes
a581c082f6 switch from rollup to esbuild
brings the 2+ second bundle on a module like the graphs down to 90ms
2021-03-21 16:06:36 +10:00
Damien Elmes
ea7611d8cc vendor Svelte rules
The separate repo made it difficult to update the rules, and made things
more complicated than they needed to be.
2021-03-20 15:04:19 +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
Henrik Giesel
ec9c623d34 Satisfy formatter 2021-02-22 14:44:31 +01:00
Henrik Giesel
3d4323b1d4 Load graphs.js from head
* Also move script into body, to be a valid HTML document
2021-02-22 14:17:56 +01:00
Henrik Giesel
aeb6de9166 Move tooltip creation into function 2021-02-22 14:10:35 +01:00
Damien Elmes
402921dac7 ignore manually scheduled cards in hour graph 2021-02-10 09:36:51 +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
971b6726c0 Restore "Merge pull request #1007 from hgiesel/sveltesass2""
This reverts commit ffcf0aa3ca and
points to a new rules_svelte commit.

It looks like we were getting away with not listing the dep on the
rules_svelte end - the failing build turned out to be because we need
to pass sass in to our local svelte_check invocation.
2021-02-06 08:39:36 +10:00
Damien Elmes
ffcf0aa3ca Revert "Merge pull request #1007 from hgiesel/sveltesass2"
Roll back to investigate issues.

This reverts commit a31b54aa7c, reversing
changes made to 0377f7f944.
2021-02-06 08:20:10 +10:00
Henrik Giesel
fd3003a58f Use lang="scss" in CardCounts 2021-02-05 14:52:25 +01:00
Henrik Giesel
1d9cb6f613 Update setFirstWeekday with new .on() type signature 2021-02-04 14:25:51 +01:00
Damien Elmes
c009a5bda1 avoid wrapping card count text on small screens 2021-02-03 21:08:07 +10:00
Damien Elmes
0bd94659f1
Merge pull request #963 from hgiesel/ease130
Coerce ease graph min to 130 if applicable
2021-01-31 09:22:01 +10:00
Henrik Giesel
bf953d69c5 Coerce ease graph to 130 if applicable 2021-01-30 22:09:00 +01:00
Henrik Giesel
aeff3d7fac Fix ease graph building wrong query omitting ease edge cases
E.g. search for "prop:ease>=2.5" AND "prop:ease<2.55" instead of
                "prop:ease>=2.5" AND "prop:ease<2.54"
2021-01-30 13:19:27 +01:00
Henrik Giesel
cf474f7428 Fix histogram-graph building invalid query 2021-01-30 02:46:26 +01:00
Henrik Giesel
9c3473e6b4 Fix graphs tooltip position 2021-01-30 02:35:48 +01:00
Henrik Giesel
3c906977b9 Make histogram show bars again 2021-01-30 02:08:01 +01:00
Henrik Giesel
3290e5373b Remove modular d3 imports for imports from d3 bundle 2021-01-30 01:13:47 +01:00
Henrik Giesel
ecbfd898d3 Remove d3 libraries from BUILD.bazel 2021-01-30 00:04:44 +01: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
Damien Elmes
687e0b070b
Merge pull request #946 from hgiesel/dispatchtype
Correctly type createEventDispatch and dispatch
2021-01-27 20:27:08 +10:00
Damien Elmes
4a88a4749c
Merge pull request #947 from hgiesel/noclickonemptybins
No clicking on empty bins in the Histogram
2021-01-27 19:45:07 +10:00
Henrik Giesel
677f4d340c Add FutureDueShowBacklog as preferences 2021-01-27 01:15:19 +01:00
Henrik Giesel
cef92ad554 No clicking on empty bins in the Histogram 2021-01-26 13:48:36 +01:00
Henrik Giesel
e7d0c5f908 Type createEventDispatcher and dispatch 2021-01-26 12:47:17 +01:00
Henrik Giesel
5abd7ae6f3 Add bridgeCommand helper function 2021-01-26 01:25:54 +01:00
Henrik Giesel
5a987d77b2 Use browserLinksSupported preference 2021-01-25 19:12:32 +01:00
Henrik Giesel
759ed17963 Move dispatch logic from Histogram to individual graphs 2021-01-25 16:34:44 +01:00
Henrik Giesel
f767a5e6ca Make calendar only clickable, if counts > 0 2021-01-25 13:47:20 +01:00
Henrik Giesel
7f671cf837 Add search functionality to Calendar view 2021-01-25 13:47:18 +01:00
Henrik Giesel
f1c8879830 Add search functionality for ease graph 2021-01-25 13:46:44 +01:00