Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@bocoup/phoenix-fyre
Advanced tools
How to download and run this demo.
$ wget https://registry.npmjs.org/@bocoup/phoenix-fyre/-/phoenix-fyre-1.1.3.tgz
$ mkdir ~/my-project-name
$ tar -xf phoenix-fyre-1.1.3.tgz -C ~/my-project-name --strip=1
$ cd ~/my-project-name
$ npx http-server
Open a browser to http://localhost:8080/example.index.html
How to add a new local scratch project with flat uncompressed files to this demo project.
Follow the demo project "phoenix-fyre" download instructions in the previous "Getting this Demo Running" section.
Choose the scratch project you would like to load. You can download it from the scratch editor on scratch.mit.edu, or ask the person who made the project to send it to you.
Unzip the scratch .sb3 file and move the files into a sub-directory of this demo project's assets folder. You can do this manually by changing the downloaded scratch sb3 file extension to a .zip file extension, unzipping it and then dragging and dropping the files into this project. Or if you prefer to use the command line you can do something like:
$ unzip "Scratch Project.sb3" -d "~/my-project-name/assets/project-name"
Duplicate example.index.html
to index.html
and update the <canvas>
tag
data-source
attribute to match the name of your unziped sb3 file assets, for
example: <canvas data-source="assets/project-name/project.json"></canvas>
. If
you are using the data-path
attribute, you will also have to update that.
Check that this demo is still working working with a local server, using npx for example (requires node and npm to work):
$ cd ~/my-project-name
$ npx http-server
Open a browser to http://localhost:8080/index.html
How to integrate this player and your own scratch project with another website.
You can either start with the project you downloaded in the last section
(~/my-project-name/assets/project-name
), or download and unzip a new scratch
project.
Compress the scratch project assets as much as you can. We have a set of png
compression recommendations in our authoring guidelines for fast scratch
projects, available at https://docs.google.com/document/d/1Mriw6cCxWhNvn1wqrqSm411GboXdsuobqnWgGJ80MOE.
We recommended that you compress pngs using the "save for web method" in Photoshop,
for example. If you are working with assets from an uncompressed and un-optimized
sb3, you can also use pngquant
on the command-line to batch compress files.
Copy my-project-name
into the third-party code section of your production
project.
Copy the relevant parts of the index.html
file into the target location in
your production project, including references to the CSS and JS files at the
correct path (E.G my-project-name/base.css
, my-project-name/player.css
and
my-project-name/main.min.js
). Copy the HTML snippet <div class="stage-container">
containing a <canvas id="scratch-stage">
and any other relevant player controls.
You should also include the meta
tags apple-mobile-web-app-capable
and
viewport
as written in the example HTML in order for the embed to work
properly on mobile.
Update the <canvas>
element's data-source
attribute to match the name of
your unziped sb3 file assets, for example: data-source="assets/project-name/project.json"
.
If you are using the data-path
attribute, you will also have to update that.
The ultimate location of the embedded player assets and the scratch project assets
should be on the same origin. The player CSS and JavaScript should be on in the
same directory as the HTML file which your <canvas>
tag is in. Your <canvas>
tag
should reference a data-source
path to a project.json
that is in the same
directory as the scratch project assets it came with in the .sb3
file you
started with.
The player supports three ways of loading a project: locally from flat files (the fastest and recommended), locally/remotely from a bundled .sb3, or remotely from a scratch project id on the scratch servers (not recommended in production).
The player is embedded as a <canvas>
element with an id of scratch-stage
. If
no project is specified, then the the player looks for a scratch project .json in
assets/playground/project.json
. You can override this behavior with the
following html attributes and url parameters.
You can change the data source to a project.json or zipped .sb3 file of your choosing, or a .sb3 file:
<canvas data-source="path/to/my-project/project.json">
The above example will load a project.json
and which will look for Scratch
project assets in the same directory as the json file.
<canvas data-source="path/to/my-project.sb3">
The above example will load a my-project.sb3
and unzip it in the browser.
This is a bit slower to load, but faster to develop with, so we only recommned
this approach for development.
Fully qualified scratch project URLs also work, so you can do something like the following and expect it to load the corresponding scratch project, so long as that project is live and public:
<canvas data-source="https://projects.scratch.mit.edu/319681786"></canvas>
The data-path
attribute changes the base path for the project, so you can do
something that looks more like this:
<canvas data-source="my-project.sb" data-path="path/to/">
If you're looking to quickly iterate on the embedded player with different scratch
projects you can leave the data-source
and data-path
attributes unset and
set them in the url of the page with links like: http://localhost:8080?source=path/to/my-project.sb3 or http://localhost:8080?source=my-project.sb3&?path=path/to
You can even use fully qualified scratch project URLs in the params, like
?source=https://projects.scratch.mit.edu/319681786
for example.
This project comes with the following files:
├── assets
│ ├── playground
│ │ ├── 83a9787d4cb6f3b7632b4ddfebf74367.wav
│ │ ├── 83c36d806dc92327b9e7049a565c6bff.wav
│ │ ├── b7853f557e4426412e64bb3da6531a99.svg
│ │ ├── cd21514d0531fdffb22204e0ec5ed84a.svg
│ │ ├── e6ddc55a6ddd9cc9d84fe0b4c21e016f.svg
│ │ ├── project.json
│ ├── down.svg
│ ├── left.svg
│ ├── playground.sb3
│ ├── right.svg
│ └── up.svg
├── base.css
├── example.index.html
├── extension-worker.js
├── extension-worker.js.map
├── main.min.js
└── player.css
This directory holds images for the virtual key's styling and a default project.
This HTML file contains demo code for using the standalone player. Almost all of the contents of this file are required for production use.
These files are used for running scratch extensions in web workers.
This is a minified version of all of the JavaScript we need to run the the standalone player itself.
The player is designed to have two sets of styling instructions. base.css
contains a small amount of styling for the player to maintain Scratch's aspect ratio of 4/3 and also styling for the virtual keys UI. player.css
is suggested styling for the UI around the player. player.css
can be optional, if it conflicts with other styles needed for the page.
Minimal styling to maintain the correct aspect ratio for the Scratch player and also style the virtual keys.
Suggested styling for the UI around the player. If you are using this in addition to base.css, make sure it is linked to in the page second for intended styling.
FAQs
## Table of contents
The npm package @bocoup/phoenix-fyre receives a total of 2 weekly downloads. As such, @bocoup/phoenix-fyre popularity was classified as not popular.
We found that @bocoup/phoenix-fyre demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.