Skip to content

Commit e0ab988

Browse files
authored
Merge pull request #7 from processing/p5js-mode
P5js mode
2 parents f85e3bc + 88f6ebd commit e0ab988

34 files changed

+6401
-180
lines changed

.github/ISSUE_TEMPLATE/2_enhancement.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/3_feature-request.yml

Lines changed: 0 additions & 77 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release p5.js Mode
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version_number:
6+
description: "What is the revision number?"
7+
required: true
8+
version_pretty:
9+
description: "What is the pretty version name?"
10+
required: true
11+
12+
jobs:
13+
release:
14+
name: Release p5.js Mode
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
steps:
19+
- name: Checkout Repository
20+
uses: actions/checkout@v4
21+
- name: Install Java
22+
uses: actions/setup-java@v4
23+
with:
24+
distribution: 'temurin'
25+
java-version: '17.0.8'
26+
- name: Setup Gradle
27+
uses: gradle/actions/setup-gradle@v4
28+
- name: Build with Gradle
29+
run: ./gradlew createPdex createZip
30+
31+
- name: Set Version Number
32+
run: |
33+
VERSION_NUMBER=${{ github.event.inputs.version_number }}
34+
VERSION_PRETTY=${{ github.event.inputs.version_pretty }}
35+
sed -i "s/^version=.*$/version=$VERSION_NUMBER/" p5js/mode/mode.properties
36+
sed -i "s/^prettyVersion=.*$/prettyVersion=$VERSION_PRETTY/" p5js/mode/mode.properties
37+
38+
- name: Upload to Release
39+
uses: svenstaro/upload-release-action@v2
40+
with:
41+
repo_token: ${{ secrets.GITHUB_TOKEN }}
42+
file: p5js/build/p5js.*
43+
tag: p5js-v${{ github.event.inputs.version_number }}
44+
file_glob: true
45+
overwrite: true
46+
47+
- name: Upload Properties to Release
48+
uses: svenstaro/upload-release-action@v2
49+
with:
50+
repo_token: ${{ secrets.GITHUB_TOKEN }}
51+
file: p5js/build/mode/mode.properties
52+
asset_name: p5js.txt
53+
tag: p5js-v${{ github.event.inputs.version_number }}
54+
overwrite: true
55+

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ tasks.register("includeProcessingResources"){
419419
"includeJavaMode",
420420
"includeSharedAssets",
421421
"includeProcessingExamples",
422-
"includeProcessingWebsiteExamples",
422+
// "includeProcessingWebsiteExamples",
423423
"includeJavaModeResources",
424424
"renameWindres"
425425
)

app/src/processing/app/Base.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public class Base {
110110

111111
/** Only one built-in Mode these days, removing the extra fluff. */
112112
private Mode coreMode;
113+
private Mode p5jsMode;
113114

114115
// TODO can these be Set objects, or are they expected to be in order?
115116
private List<ModeContribution> contribModes;
@@ -729,6 +730,7 @@ public void tallyUpdatesAvailable() {
729730
public List<Mode> getModeList() {
730731
List<Mode> outgoing = new ArrayList<>();
731732
outgoing.add(coreMode);
733+
outgoing.add(p5jsMode);
732734
if (contribModes != null) {
733735
for (ModeContribution contrib : contribModes) {
734736
outgoing.add(contrib.getMode());
@@ -739,19 +741,25 @@ public List<Mode> getModeList() {
739741

740742

741743
void buildCoreModes() {
742-
ModeContribution javaModeContrib =
743-
ModeContribution.load(this, Platform.getContentFile("modes/java"),
744-
getDefaultModeIdentifier());
744+
ModeContribution javaModeContrib = ModeContribution.load(this, Platform.getContentFile("modes/java"), getDefaultModeIdentifier());
745+
ModeContribution p5jsModeContrib = ModeContribution.load(this, Platform.getContentFile("modes/p5js"), "processing.p5js.p5js");
745746
if (javaModeContrib == null) {
746747
Messages.showError("Startup Error",
747-
"Could not load Java Mode, please reinstall Processing.",
748-
new Exception("ModeContribution.load() was null"));
748+
"Could not load Java Mode, please reinstall Processing.",
749+
new Exception("ModeContribution.load() was null"));
749750

750751
} else {
751752
// PDE X calls getModeList() while it's loading, so coreModes must be set
752753
//coreModes = new Mode[] { javaModeContrib.getMode() };
753754
coreMode = javaModeContrib.getMode();
754755
}
756+
if (p5jsModeContrib == null) {
757+
Messages.showError("Startup Error",
758+
"Could not load p5.js Mode, please reinstall Processing.",
759+
new Exception("ModeContribution.load() was null"));
760+
} else {
761+
p5jsMode = p5jsModeContrib.getMode();
762+
}
755763
}
756764

757765

p5js/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# p5.js Mode
2+
3+
## Installation
4+
5+
(Tested with Processing 4.4.7 on MacOS Monterey 12.7.6)
6+
7+
Install the mode by double-clicking the released `.pdex` file. After Processing has started up, hit "Yes" on the opening dialog, and let the mode get installed into your Processing sketchbook folder. Currently, you need to restart Processing to have the new p5.js mode show up in the mode dropdown. (This will be looked into for the September release candiate that will be published until September 30 end of day.)
8+
9+
After restarting Processing, choose “p5.js” from the mode dropdown. If `pnpm` is not found on your system, Processing will automatically install it and the LTS Node version. The status bar in the PDE will tell you once it is ready for you to code on your sketch.
10+
11+
## Demo
12+
13+
https://github.com/user-attachments/assets/f934430d-a71c-4995-8e20-92471e400013
14+
15+
## Features
16+
17+
- Auto-install of `pnpm`, Node, and all dependencies for running p5.js code inside the PDE
18+
- Error reporting
19+
- [Syntax highlighting](https://github.com/stephanmax/processing4/wiki/Syntax-Highlighting)
20+
- Installing `npm` dependencies
21+
22+
## Known Issues/ToDos
23+
24+
- Installation
25+
- Prepare and test `.pdex` for Windows
26+
- Editor UI/UX
27+
- Better information in the status bar (`pnpm` version, remove status messages in due time)
28+
- More stability around processes/coroutines (repeatedly pressing Run button should simplu restart the sketch)
29+
- Better/responsive npm (de-)install UI
30+
- Mode options
31+
- Start sketch in correct dimensions
32+
- Update `index.html` if sketch files are changed
33+
- Button to open dev tools in Electron
34+
- Hiding non-sketch files from tabs
35+
- Ignore `node_modules` when saving/exporting
36+
- Error handling
37+
- Run linter for error messaging without having to run the sketch
38+
- Remove error messaging when error is fixed
39+
- Features
40+
- Stand-alone app export

0 commit comments

Comments
 (0)