Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPIKE: Use custom events to trigger Scratch behaviour from the outside #6

Draft
wants to merge 5 commits into
base: experience-cs
Choose a base branch
from

Conversation

chrisroos
Copy link

We're exploring whether this is a good mechanism to trigger Scratch behaviour (e.g. load/save/remix) from outside of the Scratch UI.

floehopper and others added 5 commits January 20, 2025 16:15
* Scope the package name by organisation. This ties the package to the
RPF organisation rather than just to my user and means that, for
example, any member of the organisation can publish the package.

* Only publish package on successful builds of the experience-cs
branch.

* Use organisation-specific release version to avoid confusion with
  versions in the canonical package and use "experience-cs" string
instead of "raspberrypifoundation" to distinguish it from the package
version(s) used by the Code Club World project.

* Always publish using "latest" npm tag; not "hotfix" or "stable".

* Add `--access public` option to `npm publish` command, because scoped
packages only allow "restricted" access by default.

* We can use the GITHUB_TOKEN that is made available by default in a
  GitHub Action as the NODE_AUTH_TOKEN, although we need to add the
`packages: write` permission to the Action.

Co-authored-by: Chris Roos <[email protected]>
Co-authored-by: Chris Lowis <[email protected]>
The MenuBar is quite specific to the canonical version of the online
Scratch editor [1]. We want to make use of the scratch-gui package
without displaying the MenuBar.

Since the height of the menu bar is hard-coded as a CSS variable, I've
had to override the height calculation for the body wrapper when the
menu bar is not visible. Ideally the height of the menu bar wouldn't be
hard-coded and this wouldn't be necessary.

[1]: https://scratch.mit.edu/projects/editor
By listening for the custom `scratch-gui-save` event.

Try this by:

- Running `npm start`
- Visiting http://localhost:8601 to view the Scratch editor
- Execute `window.dispatchEvent(new Event('scratch-gui-save'));` in the
  web developer tools
- Observe the `received scratch-gui-save` and `START_MANUAL_UPDATING`
  log messages in the web developer console
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants