Coder Social home page Coder Social logo

turbowarp / packager Goto Github PK

View Code? Open in Web Editor NEW
198.0 16.0 114.0 4.55 MB

Converts Scratch projects into HTML files, zip archives, or executable programs for Windows, macOS, and Linux.

Home Page: https://packager.turbowarp.org/

License: Mozilla Public License 2.0

JavaScript 72.94% HTML 5.27% CSS 2.02% Svelte 17.83% EJS 0.41% Swift 1.52%
scratch scratch3 windows linux macos electron nwjs javascript

packager's Introduction

TurboWarp Packager

https://packager.turbowarp.org/

Converts Scratch projects into HTML files, zip archives, or executable programs for Windows, macOS, and Linux.

Development

Install dependencies:

npm ci

Start in development mode:

npm start

Then visit http://localhost:8947. Manually refresh to see changes.

Packaged projects generated while in development mode should not be distributed. Instead, you should run a production build to significantly reduce file size of both the website and the packager.

npm run build-prod

Output will be located in the dist folder.

The general layout of src is:

  • packager: The code that downloads and packages projects.
  • p4: The Svelte website for the packager. "p4" is the name that the packager uses internally to refer to itself.
  • scaffolding: A minimal Scratch project player. Handles most of the boring details of running Scratch projects like handling mouse inputs.
  • common: Some files used by both scaffolding and the packager.
  • addons: Optional addons such as gamepad support or pointerlock.
  • locales: Translations. en.json contains the original English messages. The other languages are translated by volunteers and imported by an automated script. (you can help)
  • build: Various build-time scripts such as webpack plugins and loaders.

Tips for forks

We strive to make the packager easy to fork, even for mods that aren't based on TurboWarp. Reading this section, at least the first half, should make it much easier to do so.

Packages

If you want to change the scratch-vm/scratch-render/scratch-audio/scratch-storage/etc. used, this is simple:

  • npm install or npm link your package. The package name does not matter.
  • Update src/scaffolding/scratch-libraries.js to import the packages with the name you have. (some of our packages are prefixed with @turbowarp/ while others are still just scratch-vm -- just make sure they match yours)

Then just rebuild. You can even install a vanilla scratch-vm and all core functionality will still work (but optional features such as interpolation, high quality pen, stage size, etc. may not work)

Note that npm is a very buggy piece of software and our dependency tree is very large. Occasionally you might get errors about missing dependencies, which should go away if you run npm install.

Deployment

The packager is deployed as a simple static website. You can host it anywhere by just copying the dist folder after a build.

We use GitHub Actions and GitHub Pages to manage our deployment. If you want to do this too:

  • Fork the repository on GitHub and push your changes.
  • Go to your fork's settings on GitHub and enable GitHub Pages with the source set to GitHub Actions.
  • Go to the "Actions" tab and enable GitHub Actions if it isn't already enabled.
  • Push commits to the "master" branch.
  • In a few minutes, your site will automatically be built and deployed to GitHub Pages.

Branding

We ask that you at least take a moment to rename the website by editting src/packager/brand.js with your own app name, links, etc.

Large files

Large files such as NW.js, Electron, and WKWebView executables are stored on an external server outside of this repository. While we aren't actively removing old files (the server still serves files unused since November 2020), we can't promise they will exist forever. The packager uses a secure checksum to validate these downloads. Forks are free to use our servers, but it's easy to setup your own if you'd prefer (it's just a static file server; see src/packager/large-assets.js for more information).

Service worker

Set the environment variable ENABLE_SERVICE_WORKER to 1 to enable service worker for offline support (experimental, not 100% reliable). This is not recommended in development. Our GitHub Actions deploy script uses this by default.

Standalone builds

The packager supports generating "standalone builds" that are single HTML files containing the entire packager. Large files such as Electron binaries will still be downloaded from a remote server as needed. You can download prebuilt standalone builds from our GitHub releases. These can be useful if our website is blocked or you don't have a reliable internet connection. Note that standalone builds do not contain an update checker, so do check on your own occasionally.

To make a production standalone build locally:

npm run build-standalone-prod

The build outputs to dist/standalone.html.

Node.js module and API

See node-api-docs/README.md for Node.js API documentation.

To build the Node.js module locally:

npm run build-node-prod

License

Copyright (C) 2021-2024 Thomas Weber

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

packager's People

Contributors

dependabot[bot] avatar garbomuffin avatar hello-smile6 avatar joshpinto6 avatar martintintin3 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  avatar  avatar  avatar  avatar  avatar  avatar

packager's Issues

Add support for loading custom extensions in compiled projects

Projects that use experimental extensions will throw an error stating SecurityError: Failed to construct 'Worker': Script at (file:///) cannot be accessed from origin 'null'. Since the packager is a modified version of TurboWarp, how hard would it be to implement experimental extension support?

TurboWarp options

  • Username
  • Warp timer
  • Disable compiler
  • Framerate
  • Cloud variables
  • High quality pen
  • Turbo mode

Extra options for cloud variables

Options like:
URL - Contains and lets you set the current URL of the web page, I.e for parameters or redirects
Clipboard - Accesses the clipboard and allows you to copy or paste
Username - Changes the username in code for user input (I'm not sure how useful this would actually be but could be cool)
Eval - Evaluates Javascript code
New Tab - Let's you open a link in a new tab or window

Better error message alert

Right now it uses alert(), which isn't the greatest UX

Would be great to make a better error alert that

  • is more consistent with the current styles
  • has a button to open a github issue

Interpolation

Interpolation was merged into develop, so add support in the packager

MacOS Version does not work

So I tried converting a scratch project into a Mac compatible application but when I had tried to open the file it would not let me saying quote “The publisher cannot be verified therefore it cannot checked for viruses” or something along those lines. I would like to see this fixed so that I can use the turbo warp packager.

Add support for loading extension from file:///

vm.extensionManager.loadExtensionURL("file:/// (blah blah blah)")

Uncaught (in promise) Error: Invalid protocol
    at e.exports.loadExtensionURL (extension-manager.js:168)
    at <anonymous>:1:21

Optimize icns.js

Seems like I must've forgotten to do an optimized build because it's nearly 500KB

Drop support for forkphorus

Initially this project was "forkphorus packager v3" but it has since become "TurboWarp packager". dropping forkphorus would greatly simplify things, especially as forkphorus already has a functional packager

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.