From 75c7a4409be6714d68aeca591a6d15b2bde0db89 Mon Sep 17 00:00:00 2001 From: terry feng Date: Mon, 4 Nov 2024 10:42:26 -0800 Subject: [PATCH 1/5] clean up export mixer code --- src/services/export/exportSnippets.ts | 3 ++- src/services/export/exportWebchuck.ts | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/services/export/exportSnippets.ts b/src/services/export/exportSnippets.ts index 1094705..bf91192 100644 --- a/src/services/export/exportSnippets.ts +++ b/src/services/export/exportSnippets.ts @@ -1,7 +1,8 @@ export const MIXER_JS = ` // MIXER CODE for GUI (if there are global variables) + const mixer = document.querySelector('#webchuck-gui'); const sliders = [...chuckCode.matchAll(/\\bglobal float\\s+(\\w+)\\b/g)] - .map(([, variable]) => variable); + .map(([, variable]) => variable); if (sliders.length > 0) mixer.style.display = 'flex'; diff --git a/src/services/export/exportWebchuck.ts b/src/services/export/exportWebchuck.ts index e0f8d8c..5f5fcab 100644 --- a/src/services/export/exportWebchuck.ts +++ b/src/services/export/exportWebchuck.ts @@ -100,13 +100,15 @@ async function exportWebchuck( description; // Check code for global variables to build mixer - const globals = getGlobalVariables(code); - let mixer_code = `const mixer = document.querySelector('#webchuck-gui');\n`; - mixer_code += globals.float.length > 0 ? MIXER_JS : ""; // only look at floats - wc_html = docFindReplace(wc_html, "{{{ MIXER_CODE }}}", mixer_code); - if (globals.float.length == 0) { + const mixerGlobals = getGlobalVariables(code); + let mixerCode = ""; + if (mixerGlobals.float.length == 0) { wc_html.getElementById("webchuck-gui")?.remove(); + } else { + mixerCode = MIXER_JS; } + // Set/clear mixer code + wc_html = docFindReplace(wc_html, "{{{ MIXER_CODE }}}", mixerCode); // Add in PRELOAD_FILES // get all projectFiles excluding the current active file From 1da4a19b11fac881fecc141cc517b48bc3c09e2b Mon Sep 17 00:00:00 2001 From: terry feng Date: Sun, 19 Jan 2025 17:03:45 -0800 Subject: [PATCH 2/5] Update helloSineGUI.ck typo --- public/examples/helloSineGUI.ck | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/examples/helloSineGUI.ck b/public/examples/helloSineGUI.ck index e35e3a1..79fa78c 100644 --- a/public/examples/helloSineGUI.ck +++ b/public/examples/helloSineGUI.ck @@ -3,7 +3,7 @@ * via sliders and buttons. GUI float sliders go from [0.0,1.0] */ -/* Play a sine wave and control the frecuency with the GUI */ +/* Play a sine wave and control the frequency with the GUI */ /* 1. Open the GUI Panel below and hit "Generate GUI". 2. Run the code. From 380e11133a3501e195b09157911307118f078503 Mon Sep 17 00:00:00 2001 From: terry feng Date: Sat, 25 Jan 2025 14:12:06 -0800 Subject: [PATCH 3/5] fix and update site.webmanifest for html --- public/favicon_io/site.webmanifest | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/public/favicon_io/site.webmanifest b/public/favicon_io/site.webmanifest index fa99de7..4939f35 100644 --- a/public/favicon_io/site.webmanifest +++ b/public/favicon_io/site.webmanifest @@ -1,19 +1,23 @@ { - "name": "", - "short_name": "", + "name": "WebChucK IDE", + "short_name": "WebChucK IDE", "icons": [ { - "src": "/android-chrome-192x192.png", + "src": "/favicon_io/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" }, { - "src": "/android-chrome-512x512.png", + "src": "/favicon_io/android-chrome-512x512.png", "sizes": "512x512", "type": "image/png" } ], "theme_color": "#ffffff", "background_color": "#ffffff", - "display": "standalone" + "display": "standalone", + "description": "A web-based integrated development environment (IDE) for ChucK, a programming language for real-time sound synthesis and music creation!", + "start_url": "/", + "lang": "en", + "dir": "ltr" } From ce1604d8f28370cde17ea31d7c913274669f6af5 Mon Sep 17 00:00:00 2001 From: terry feng Date: Sat, 25 Jan 2025 14:56:38 -0800 Subject: [PATCH 4/5] fix moreExamples to correctly load data assets that are plaintext --- src/components/examples/moreExamples.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/examples/moreExamples.ts b/src/components/examples/moreExamples.ts index 19c09b0..61da14f 100644 --- a/src/components/examples/moreExamples.ts +++ b/src/components/examples/moreExamples.ts @@ -13,7 +13,8 @@ import ProjectSystem from "@/components/fileExplorer/projectSystem"; import Examples from "./examples"; import DropdownElement from "../navbar/dropdownElement"; import * as JsSearch from "js-search"; -import { fetchDataFile } from "@/utils/fileLoader"; +import { isPlaintextFile } from "webchuck/dist/utils"; +import { File, fetchDataFile, fetchTextFile } from "@/utils/fileLoader"; // JSON Structure interface MoreExamplesJSON { @@ -322,8 +323,8 @@ export default class MoreExamples { } /** - * Create an item in the file explorer - * @param name + * Create a folder item in the file explorer + * @param name folder name */ static createExplorerFolder(name: string) { const item = document.createElement("button"); @@ -335,6 +336,10 @@ export default class MoreExamples { MoreExamples.moreExamplesExplorer.appendChild(item); } + /** + * Create a file item in the file explorer + * @param file ChucKExample file + */ static createExplorerFile(file: ChuckExample) { const item = document.createElement("button"); item.classList.add("explorer-item"); @@ -368,7 +373,12 @@ export default class MoreExamples { MoreExamples.previewExample.code ); MoreExamples.previewExample.data.forEach(async (url: string) => { - const file = await fetchDataFile(url); + let file: File | null = null; + if (isPlaintextFile(url)) { + file = await fetchTextFile(url); + } else { + file = await fetchDataFile(url); + } if (file !== null) { ProjectSystem.addNewFile(file.name, file.data); } From eae2b59f626981d433b8aae3a683240010f2ddc2 Mon Sep 17 00:00:00 2001 From: terry feng Date: Sat, 25 Jan 2025 15:00:02 -0800 Subject: [PATCH 5/5] format and lint --- src/components/examples/examples.ts | 6 +++--- src/components/inputPanel/inputPanelHeader.ts | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/examples/examples.ts b/src/components/examples/examples.ts index d97d5f2..c48e3cc 100644 --- a/src/components/examples/examples.ts +++ b/src/components/examples/examples.ts @@ -110,7 +110,7 @@ export default class Examples { Examples.newExample( "Hello Sine GUI", () => { - loadChuckFileFromURL("examples/helloSineGUI.ck") + loadChuckFileFromURL("examples/helloSineGUI.ck"); InputPanelHeader.setNotificationPing(0, true); }, guiNested @@ -118,7 +118,7 @@ export default class Examples { Examples.newExample( "FM Synthesis GUI", () => { - loadChuckFileFromURL("examples/fmGUI.ck") + loadChuckFileFromURL("examples/fmGUI.ck"); InputPanelHeader.setNotificationPing(0, true); }, guiNested @@ -141,7 +141,7 @@ export default class Examples { Examples.newExample( "Keyboard Organ HID", () => { - loadChuckFileFromURL("examples/keyboardHID.ck") + loadChuckFileFromURL("examples/keyboardHID.ck"); InputPanelHeader.setNotificationPing(1, true); }, hidNested diff --git a/src/components/inputPanel/inputPanelHeader.ts b/src/components/inputPanel/inputPanelHeader.ts index 9373ae0..cdad864 100644 --- a/src/components/inputPanel/inputPanelHeader.ts +++ b/src/components/inputPanel/inputPanelHeader.ts @@ -41,7 +41,7 @@ export default class InputPanelHeader { InputPanelHeader.inputContainers.push( document.querySelector("#SensorContainer")! ); - InputPanelHeader.inputPings.push( + InputPanelHeader.inputPings.push( document.querySelector("#SensorPing")! ); @@ -91,7 +91,9 @@ export default class InputPanelHeader { */ static setNotificationPing(tabIndex: number, on: boolean) { for (let i = 0; i < InputPanelHeader.inputButtons.length; i++) { - InputPanelHeader.inputToggles[i].setNotificationPing(i == tabIndex && on); + InputPanelHeader.inputToggles[i].setNotificationPing( + i == tabIndex && on + ); } } }