Giter VIP home page Giter VIP logo

forkphorus's Introduction

forkphorus

forkphorus.github.io

A JavaScript/TypeScript compiler for Scratch 3, 2, and 1 projects. forkphorus is a fork of phosphorus.

Build Steps

You will need Git and Node.js.

git clone https://github.com/forkphorus/forkphorus.git
cd forkphorus
npm install

Start the development server with:

npm start

View the development server at http://localhost:8080/

Forkphorus is written in a mix of "vanilla" JavaScript and TypeScript. Most interface code is JavaScript, but the forkphorus runtime, compiler, and project player are written in TypeScript. The TypeScript files are in the src folder and changes automatically trigger rebuilds while the development server is running.

License

Unless stated otherwise (there are exceptions), files in this repository are MIT Licensed.

Parts of forkphorus are based on Sulfurous (https://sulfurous.aau.at/) and Scratch (https://scratch.mit.edu/)

License for Sulfurous:

The MIT License (MIT)
Copyright (c) 2013-2014 Nathan Dinsmore
Copyright (c) 2016 Mittagskogel
Copyright (c) 2017-2020 FRALEX

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

License for Scratch:

Copyright (c) 2016, Massachusetts Institute of Technology
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

forkphorus's People

Contributors

dependabot[bot] avatar garbomuffin avatar nathan avatar sclements avatar scratchusernamemrtbts avatar technoboy10 avatar tjvr avatar trumank avatar xeltalliv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

forkphorus's Issues

Some sounds don't play

Some sounds don't play. I think I know the cause -- audio decoding is problematic and the audiobuffernodes used by forkphorus cannot contain too much audio.

Customizable username

Right now your username is always an empty string, as if you were a signed out user. What if the user could choose their username (perhaps behind some "advanced settings" menu)? It would be kinda nice, I guess. Project creators use usernames to several things including gating features and saying things to you by name.

https://scratch.mit.edu/projects/247070325/

Please describe what you were doing to cause this error:

Loaded up the game, started the level (by pressing J), and when the yellow zone visual effect went away, phosphorus crashed.

Project URL: https://scratch.mit.edu/projects/247070325/
Project ID: 247070325
https://garbomuffin.github.io/phosphorus/#247070325
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36

Message: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
Stack:
Error: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
    at Sprite.touching (https://garbomuffin.github.io/phosphorus/phosphorus.js:1269:44)
    at eval (eval at scopedEval (https://garbomuffin.github.io/phosphorus/phosphorus.js:5128:12), <anonymous>:43:7)
    at Stage.P.runtime.P.core.Stage.step (https://garbomuffin.github.io/phosphorus/phosphorus.js:4924:13)

https://scratch.mit.edu/projects/78096056/

Describe what you were doing to cause this error:

Happened again. Tried to load this project: https://scratch.mit.edu/projects/78096056/
Dunno what's going on. I'm on a school chromebook so that might have something to do with it but idk. I've sent a bug report b4 and i got ur response, it works fine on my main PC but like i said idk


Project URL: https://scratch.mit.edu/projects/78096056/
Project ID: 78096056
https://forkphorus.github.io/#78096056
Mozilla/5.0 (X11; CrOS x86_64 11895.118.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.159 Safari/537.36

[object ProgressEvent]

https://scratch.mit.edu/projects/241565591/

If you quickly hit either "1 Player" or "2 player" (within 48 frames), then not all the tiles will render.

The problem is that the repeat (48) loop used to spawn the tiles does not run instantly as it does in Scratch 3.


Project URL: https://scratch.mit.edu/projects/241565591/
Project ID: 241565591
file:///C:/Users/Thomas/Projects/forkphorus/index.html#241565591
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0

https://scratch.mit.edu/projects/78096056/

Describe what you were doing to cause this error:

Tried to run a certain project, internal error occured.


Project URL: https://scratch.mit.edu/projects/78096056/
Project ID: 78096056
https://forkphorus.github.io/forkphorus/#78096056
Mozilla/5.0 (X11; CrOS x86_64 11895.118.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.159 Safari/537.36

Message: (object.listeners.whenSceneStarts[key] || (intermediate value)(intermediate value)).push is not a function
Stack:
TypeError: (object.listeners.whenSceneStarts[key] || (intermediate value)(intermediate value)).push is not a function
    at Object.compiler.compileListener (https://forkphorus.github.io/forkphorus/phosphorus.dist.js:5641:109)
    at compileScripts (https://forkphorus.github.io/forkphorus/phosphorus.dist.js:4699:30)
    at Object.compile (https://forkphorus.github.io/forkphorus/phosphorus.dist.js:5662:21)
    at https://forkphorus.github.io/forkphorus/phosphorus.dist.js:4387:32

https://scratch.mit.edu/projects/310906817/

Describe what you were doing to cause this error:

Beat a level


Project URL: https://scratch.mit.edu/projects/310906817/
Project ID: 310906817
https://forkphorus.github.io/#310906817
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0

Message: Argument 3 of CanvasRenderingContext2D.getImageData is not a finite floating-point value.
Stack:
trapInstanceMethod/item.obj[item.propName]</<@https://forkphorus.github.io/:209:23
spritesIntersect@https://forkphorus.github.io/phosphorus.dist.js:1412:54
touching@https://forkphorus.github.io/phosphorus.dist.js:2522:48
@https://forkphorus.github.io/phosphorus.dist.js line 5512 > eval:21:8
step@https://forkphorus.github.io/phosphorus.dist.js:5355:33

Cloud variables

Connecting to the real cloud variable server is probably a terrible idea for various reasons (behavioral differences, somehow need to get the user's auth token, etc.). However, it wouldn't be impossible for forkphorus to have its own cloud data server if it really matters. Perhaps cloud variables could be implemented as read-only at project startup or something so that you can still view cloud highscores in projects, and things like that.

fetch is inconsistent and unreliable

Projects often error while loading due to networkerrors. Our P.IO.fetch should be more persistent or reliable when fetching things.

Going back to XHR might not be a bad idea, especially for onprogress (as was attempted in the io-tasks branch)

Audio engine refactoring

Update the audio engine similar to how the other parts of phosphorus have been refactored.

  • ✔️ Make soundbank files all local
  • ✔️ Improve browser support (safari, no audio context, etc.)
  • Look into #3
  • ✔️ Look into #15
  • Implement Scratch 3 music blocks
  • Look into implementing other Scratch 3 audio effects
  • ✔️ Implement graceful audio decode error handling

TTS (text-to-speech) extension support

TTS is currently not supported, and the blocks are instead skipped.

Possible methods to add extension:

It's unclear if TTS is worth supporting as our most common niche seems to be speeding up compute-limited projects and very few of these use TTS in any significant capacity

Should add Future support to the compiler before this happens.

forkphorus to APK

I think that's a thing people want.

The problem being I know nothing about android development, so that's probably not going to happen soon.

WebGL renderer / Graphic Effects Not Supported

WebGL is faster than a 2d canvas and allows accurately applying filters. Scratch 3 and sulfurous use WebGL so forkphorus is overdue for this.

A 2d canvas should still be used as a fallback.

The P.renderer.ProjectRenderer interface is sufficiently abstract that this should be possible without affecting core code.

https://scratch.mit.edu/projects/250740608/

Describe what you were doing to cause this error:
Loading project.


Project URL: https://scratch.mit.edu/projects/250740608/
Project ID: 250740608
https://forkphorus.github.io/#250740608
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36

Message: Unknown project type (only Scratch 2 and 3 projects are supported)
Stack:
Error: Unknown project type (only Scratch 2 and 3 projects are supported)
    at https://forkphorus.github.io/player.js:178:17

Fix Scratch 2 SVG viewboxes

SVGs created by Scratch 2 have vastly incorrect viewboxes set, which can cause part of them to be cutoff very often.

https://scratch.mit.edu/projects/304369304/

Describe what you were doing to cause this error:


Project URL: https://scratch.mit.edu/projects/304369304/
Project ID: 304369304
https://forkphorus.github.io/app.html?id=304369304&turbo=false&full-screen=true
Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36

Message: textElements[Symbol.iterator] is not a function
Stack:
TypeError: textElements[Symbol.iterator] is not a function
    at patchSVG (https://forkphorus.github.io/phosphorus.dist.js:4987:28)
    at getAsText.then (https://forkphorus.github.io/phosphorus.dist.js:5010:25)

Missing Scratch 3 blocks

Sounds:

  • Change [effect] effect by [10] (missing in phosphorus; scratch 3 addition)
  • Set [effect] effect to [100] (missing in phosphorus; scratch 3 addition)

Events:

  • When [thing] > [10] (missing in phosphorus)

Sensing:

  • Loudness (missing in phosphorus) (pseudo-implemented, always returns -1)

Control

  • for in

Music: (extension)

  • Play drum
  • Rest
  • Play note
  • Set instrument

All other extensions except pen:

  • Everything

Target ES5

Target ES5 instead of ES6 to support more browsers.

Implement Scratch 3 list stringification

Directly references a list by its block in Scratch converts it to a string.

The behavior is:

  • If every item in the list is a single character long, then return all the item joined without anything between
  • Otherwise, return all the items item joined by a single space.

Forkphorus does not implement this and you currently get the JavaScript behavior of joining all the items with commas.

Optimize list watchers

Our Scratch 3 list watches are terribly slow and can really be noticed on any project that has large lists (such as my sorting algorithm projects), where a very significant time can be spent creating the list and keeping it up to date.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.