Commit Graph
702 Commits
Author SHA1 Message Date
David Lechner 03f6c004db sponsor: add new button and dialog
Issue: https://github.com/pybricks/support/issues/719
2022-10-28 18:01:39 -05:00
David Lechner ede6f80f49 explorer/newFileWizard: add empty file option
Fixes: https://github.com/pybricks/pybricks-code/issues/771
2022-10-28 18:01:39 -05:00
David Lechner 7810a8ee87 components/hubPicker: use images instead of text 2022-10-28 18:01:39 -05:00
David Lechner 90b04f85b3 webpack: add hack to remove unused icons
This follows the suggestions from [1] to reduce the package size by
only including the icons we are actually using. This gets the main
module small enough to avoid the CRA "The bundle size is significantly
larger than recommended." warning (gzipped size is < 512KB).

[1]: https://github.com/palantir/blueprint/issues/2193
2022-10-27 13:17:51 -05:00
David Lechner 694b064683 remove unnecessary {} 2022-10-27 13:17:51 -05:00
David Lechner 0725203d66 app: lazy-load terminal
This changes the terminal sagas and components to be lazy loaded to
improve time until first render.
2022-10-27 13:17:51 -05:00
David Lechner c49f37f5e4 editor: lazy load
This makes the required changes needed to make the editor components
and sagas lazy-load to improve the time before the first render of the
app.

This is done by making sure we only import types from the monaco editor
module anywhere other than the saga and the component modules and using
React.lazy to lazy-load the component and start the sagas.

This cuts the main bundle time to less than 1/2 so load time should be
over twice as fast now.
2022-10-27 13:17:51 -05:00
David Lechner 0f56bb7174 app/actions: drop didStart
This action is no longer used.
2022-10-27 13:17:51 -05:00
David Lechner 509c635a07 ble/sagas: add workaround for BlueZ quirk
The 'gattserverdisconnected' event is called before the device is
actually disconnected, so if the user tries to connect again
immediately, the web browser will show a still "paired" device, but
selecting this devices results in an infinite wait. This is a bug in
Chromium, but we can work around it by adding a delay to give BlueZ
time to actually disconnect the device.

Closes: https://github.com/pybricks/support/issues/600
2022-10-26 16:20:08 -05:00
David Lechner 57c87da464 editor: disable word-based suggestions
This turns off the default word-based suggestions. This was useful when
we didn't have proper code completion but now can be distracting.

Fixes: https://github.com/pybricks/support/issues/757
2022-10-25 13:48:02 -05:00
David Lechner e41a297922 editor: close tab on middle-click
Fixes: https://github.com/pybricks/support/issues/758
2022-10-25 12:57:07 -05:00
David Lechner ed8394bf84 pybricksMicropython/lib: handle exceptions when parsing
The new code parsing library raises exceptions when there are syntax
errors, so this needs to be handled.

Fixes: https://github.com/pybricks/support/issues/755
2022-10-25 11:50:06 -05:00
David Lechner cc37548e36 pybricksMicropython/lib: replace parser
This replaces the Python parsing library. The python-ast package has
really poor performance (many seconds to parse a 500 line file). The
new package can parse a file about 100 times faster.
2022-10-24 15:29:17 -05:00
laurensvalkandDavid Lechner a673a45b03 text: Don't say that dashes are allowed. (#1247)
* text: Don't say that dashes are allowed.

This was missed in https://github.com/pybricks/pybricks-code/commit/8b19ad58662186d2295a6241e8c3f84fbfd45809

* explorer/fileNameForGroup: remove dash from translaction dict

Co-authored-by: David Lechner <david@lechnology.com>
2022-10-24 20:07:35 +00:00
David Lechner 397ea60354 ReplButton: disable when hub doesn't support it
Fixes: https://github.com/pybricks/support/issues/743
2022-10-21 16:26:43 -05:00
David Lechner 964c18f12e ble/sagas: fix blePybricksServiceDidNotReceiveHubCapabilities firmware version
We were using the version from the @pybricks/firmware package but we
really want the version from the connected device.
2022-10-21 16:26:43 -05:00
David Lechner fa00c0aea6 firmware/sagas: fix progress alerts
These were being replaced (dismissed then new alert) instead of updated.
2022-10-21 16:26:43 -05:00
David Lechner 4400c0663e alerts/UnexpectedErrorAlert: fix not showing message
This was not showing the actual error message.

Also hide the technical details when no stack trace is available.
2022-10-21 16:26:43 -05:00
dependabot[bot]andDavid Lechner 49cc0e2126 build(deps): bump @pybricks/firmware from 6.0.1 to 6.1.0 (#1243)
* build(deps): bump @pybricks/firmware from 6.0.1 to 6.1.0

Bumps [@pybricks/firmware](https://github.com/pybricks/pybricks-micropython/tree/HEAD/npm/firmware) from 6.0.1 to 6.1.0.
- [Release notes](https://github.com/pybricks/pybricks-micropython/releases)
- [Changelog](https://github.com/pybricks/pybricks-micropython/blob/master/npm/firmware/CHANGELOG.md)
- [Commits](https://github.com/pybricks/pybricks-micropython/commits/HEAD/npm/firmware)

---
updated-dependencies:
- dependency-name: "@pybricks/firmware"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* update firmware version in test

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Lechner <david@lechnology.com>
2022-10-21 20:05:10 +00:00
David Lechner 7e726fffaf mpy/alerts: implement compiler error
This shows the output from mpy-cross and has a button to go to the
error.
2022-10-19 18:26:37 -05:00
David Lechner e5ab52b250 explorer/fileNameFormGroup: fix fix-it for dash in file name 2022-10-19 18:26:37 -05:00
David Lechner fc4cb8eb78 alerts: add alertsHideAlert actions
This is used instead of using toaster.dismiss() directly.
2022-10-19 18:26:37 -05:00
David Lechner 28cf87c356 alerts: allow overriding key
This adds an optional key parameter to alertsShowAlert() to allow
overriding the key. This allows us to call flashProgress using that
action instead of having to use the toaster directly.
2022-10-19 18:26:37 -05:00
David Lechner fa27649fe3 toasterTypes: change toaster to ref
Instead of rendering the toaster separate from the main index, add it
there so we can inherit all of the context providers. This requires
passing the ref object instead of the toaster instance itself, so
sagas have to be updated.
2022-10-19 18:26:37 -05:00
David Lechner be9272ca9c pybricksMicropython: implement appending imports
This implements appending compiled imported modules for the multi-mpy6
file format.
2022-10-19 18:26:37 -05:00
David Lechner 8b19ad5866 pybricksMicropython: don't allow files with dash
Since we are adding user imports, we need to make sure all file names
are valid module names, so this means we can't use a dash.
2022-10-19 18:26:37 -05:00
David Lechner 5948952174 hub: fix tooltip when download complete
The tooltip was still showing "Downloading... 100%" after downloading
was complete instead of returning to the normal tooltip.
2022-10-17 13:44:21 -05:00
David Lechner bd0b276ea5 hub/sagas: fix scaling of download progress
This was missed in 06b204dd53.

Fixes: https://github.com/pybricks/pybricks-code/issues/1219
2022-10-17 13:44:21 -05:00
David Lechner e67ae1c52b use "error" when type is Error
This renames "err" to "error" when the type is Error for consistency
(fixes redux complaints about non-serializable err).
2022-10-17 13:44:21 -05:00
David Lechner 06b204dd53 hub/sagas: fix handleDownloadAndRun slicing
Some of the math was assuming i was incremented with ++ instead += chunkSize.
2022-10-17 11:16:28 -05:00
David Lechner 960a3163ed add support for Pybricks Profile v1.2.0
This adds support to the BLE Pybricks Profile v1.2.0. This includes a
new method to download and run programs and a new file format for the
user program.

Code for the old download and run is kept for backwards compatibility.
However, the PnP ID characteristic is no longer optional, so the
minimum Pybricks Profile is now v1.1.0.
2022-10-14 16:21:18 -05:00
David Lechner db43cb3e99 remove use of deprecated DomException code property 2022-10-14 16:21:18 -05:00
David Lechner eb26bfcf1b index: ignore value action properties
This was making noise in the browser console log.
2022-10-14 16:21:18 -05:00
David Lechner 6675310390 spelling 2022-10-14 16:21:18 -05:00
189cda94b1 build(deps): bump xterm and xterm-addon-fit (#1146)
* build(deps): bump xterm and xterm-addon-fit

Bumps [xterm](https://github.com/xtermjs/xterm.js) and [xterm-addon-fit](https://github.com/xtermjs/xterm.js). These dependencies needed to be updated together.

Updates `xterm` from 4.19.0 to 5.0.0
- [Release notes](https://github.com/xtermjs/xterm.js/releases)
- [Commits](https://github.com/xtermjs/xterm.js/compare/4.19.0...5.0.0)

Updates `xterm-addon-fit` from 0.5.0 to 0.6.0
- [Release notes](https://github.com/xtermjs/xterm.js/releases)
- [Commits](https://github.com/xtermjs/xterm.js/compare/0.5...0.6)

---
updated-dependencies:
- dependency-name: xterm
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: xterm-addon-fit
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* [dependabot skip] Fix yarn.lock

* fix breaking changes for xterm.js 5.x

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-fix <dependabot-fix@example.com>
Co-authored-by: David Lechner <david@pybricks.com>
2022-09-17 18:14:24 +00:00
6c373c302c build(deps): bump pyodide from 0.21.2 to 0.21.3 (#1144)
* build(deps): bump pyodide from 0.21.2 to 0.21.3

Bumps [pyodide](https://github.com/pyodide/pyodide) from 0.21.2 to 0.21.3.
- [Release notes](https://github.com/pyodide/pyodide/releases)
- [Commits](https://github.com/pyodide/pyodide/compare/0.21.2...0.21.3)

---
updated-dependencies:
- dependency-name: pyodide
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* [dependabot skip] Fix yarn.lock

* update patch for pyodide 0.21.3

* make use of new pyodide version export

* fix breaking change in loadPyodide indexURL

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-fix <dependabot-fix@example.com>
Co-authored-by: David Lechner <david@pybricks.com>
2022-09-17 18:05:44 +00:00
David Lechner 56630ef2cf firmware/installPybricksDialog: drop support for including custom main.py
This removes the UI and internal support for selecting a file to include
as the main.py when flashing firmware. This feature was removed in the
firmware starting with firmware metadata v2.0.0 so the firmware that
ships with Pybricks code won't be able to do this in the near future.
So, it doesn't make sense to keep this feature only for old firmware.

It is still possible to replace the main.py in old firmware.zip files
and flash that way.
2022-09-14 18:12:34 -05:00
David Lechner 9811807d09 firmware: add support for firmware.metadata.json v2.0.0
This adds support for the new firmware.metadata.json v2.0.0 which drops
support for appending a main.py file to the firmware.
2022-09-14 17:58:54 -05:00
David Lechner c4d98638b1 firmware/actions: fix error type check
we need to check that it matches the error interface, not that it is
an instance of an error
2022-09-14 17:38:19 -05:00
David Lechner 0bd4a7a282 Merge remote-tracking branch 'origin/master' into dlech 2022-09-13 14:24:43 -05:00
David Lechner 7e2404d583 pybricksMicropython: add support for peer file code completion
This allows importing user-created files and getting code completion
for those imports. This is done by mirroring the dexie-based file
system used by the editor to the emscripten based file system used
by pyodide. In the future, ideally we would have some sort of shared
file system, but this works for now.

Note: completing `from ` doesn't list user files/modules because of
filters in the pybricks-jedi python package but completing
`from my_file import ` does work as expected.
2022-09-13 14:19:29 -05:00
9994e8f4b4 build(deps): bump jest and @types/jest (#1131)
* build(deps): bump jest and @types/jest

Bumps [jest](https://github.com/facebook/jest/tree/HEAD/packages/jest) and [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest). These dependencies needed to be updated together.

Updates `jest` from 28.1.3 to 29.0.3
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/jest/commits/v29.0.3/packages/jest)

Updates `@types/jest` from 28.1.8 to 29.0.1
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest)

---
updated-dependencies:
- dependency-name: jest
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: "@types/jest"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* [dependabot skip] Fix yarn.lock

* update test snapshots for jest 29

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-fix <dependabot-fix@example.com>
Co-authored-by: David Lechner <david@pybricks.com>
2022-09-13 17:06:24 +00:00
David Lechner f24db4a89b implement cache bursting based on http header version
In 096eea7, we made use of APIs that require special http headers to be
configured on the server. This had a side effect of causing the
documentation iframe to not load because the browser would cache the
headers of the iframe index.html page.

We can work around this by providing a header version to do cache
bursting via a query parameter on this page.
2022-09-09 11:33:20 -05:00
David Lechner 76462a0f4a python-worker: enable offline use
This makes the required changes to use Pyodide and Python packages
offline and use a fixed version of the Python packages instead of
fetching the latest from PyPI.

There were a number of issues encountered with Pyodide webpack
compatibility that were fixed using `yarn patch`:
- https://github.com/pyodide/pyodide/pull/3080
- https://github.com/pyodide/pyodide/pull/3085
- https://github.com/pyodide/pyodide/issues/3086
- https://github.com/pyodide/pyodide/issues/3087

Issue: https://github.com/pybricks/pybricks-code/issues/932
2022-09-08 13:43:00 -05:00
David Lechner 4e77efb34f installPybricksDialog: add feature to install custom firmware
This restores the ability to drag and drop a custom firmware file to
flash the firmware on the hub.

Fixes: https://github.com/pybricks/pybricks-code/issues/1020
2022-09-06 14:14:57 -05:00
David Lechner ebb8900efe installPybricksDialog: make use of isMounted hook
This simplifies the code a bit by using an existing hook.
2022-09-06 11:10:49 -05:00
David Lechner b447bd7a3a replace use of deprecated IToaster and IToastProps 2022-09-06 10:56:38 -05:00
David Lechner 677d285ef2 installPybricksDialog: move unsupported hubs to separate component 2022-09-03 14:06:25 -05:00
David Lechner b4e1c8293d replace use of deprecated IRef 2022-09-01 11:45:59 -05:00
David Lechner d59fe813e9 fix explorer import silently ignored when invalid file name
This finishes a TODO to handle allowing the user to rename a file
with an invalid file name when import files from the file system.

Fixes: https://github.com/pybricks/support/issues/717
2022-08-31 17:39:28 -05:00