This PR converts everything (aside from electron) from CommonJS to ESM.
It is needed to reduce the changes that will happen during the migration
to Typescript (as TS does not play nice with CJS).
Basically:
- rewrite `require()` to `import`
- rewrite `module.exports` to `exports`
- introduce `ts-node` to run importers so we can convert them to TS too
Lastly, sorry for this larg-ish PR, not my preference but when I tried
to reduce its scope, I would end up with mixed commons/esm that was even
more tricky to handle.
Fixes#840 by creating application-defined SQL functions
(https://www.sqlite.org/appfunc.html) for Unicode-aware implementations
of `LOWER()` and `UPPER()`. This uses
`String.prototype.toLower/UpperCase()` JS method.
I initially wanted to just redefine `LOWER()` and `UPPER()` but due to
[sql.js not supporting the definition of deterministic
functions](https://github.com/sql-js/sql.js/issues/551), I had to just
define them as separate functions and use that in the appropriate
places. It's probably better like that anyway...
I believe this change allows for having multiple 'by' rules in the same
category. It seems to be working well for my purposes, but I would
appreciate further testing to assure there aren't regressions.
Example:
#template 300 by 2023-06
#template 3000 by 2023-08
Before this PR, having these two lines in the notes would only budget
funds for the earliest of the two strings and ignore the 3000 funding
target. With this PR, the sum of the two funding targets will be
respected.
This improves usability of narrow screen widths, and also prepares for
further optimizations that would allow us to use the sidebar largely
as-is on mobile, instead of having to have a tab bar.
---------
Co-authored-by: Matiss Janis Aboltins <matiss@mja.lv>
Part 1 of the conversion. Mostly renaming js to ts and making sure
things make still sense. Added also handy TS ESLint rules.
In order to support the various .web/.electron/... I ended up adopting
`index.d.ts` as pattern to share type definition. Let me know if that
makes sense for you too. Right now the function type definition is
duplicated, but the solution will be importing from `index.d.ts` and
using `const fn: FnDef = () => ...` that way we can keep all variants in
sync from a single type file.
Such rewrite however is better done in another PR otherwise we risk
confusing git and loosing history (rename + too many changes). Another
thing that might do in the next PR is convert all files to ESModules, as
things get confusing between CJS exports, ESM default/named and TS adds
extra complains.
Added onboarding and budget e2e tests. Also fixed an issue for
first-time flows using imports: currently people end up with a blank
white screen after importing. Instead they should see the budget table.
Related: https://github.com/actualbudget/actual/issues/583
- When parsing an amount string, consider surrounding parentheses to
mean the amount is negative.
- Ensures all input to `parseFloat()` is sanitized.
Closes: #807
This PR improves the consistency of the settings UI by moving everything
(except the budget name field on mobile) into `<Setting>` boxes.
Additionally, it adds a “Settings” option to the file dropdown menu (I
keep expecting it to be there, and I think it’s reasonable to expose it
in both locations so it’s easier to access)
I'm not sure if this is something you want but it was a simple change so
I figured I might as well contribute it. This PR allows the user to
upload `.blob` files that they may have gotten from server's
`user-files/` folder. This can be useful if the user didn't export the
file but has server backups.
---------
Co-authored-by: Jed Fox <git@jedfox.com>