Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"presets": ["react-app"],
"presets": [
"react-app",
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript"
],
"plugins": [
[
"prismjs",
Expand Down
8 changes: 8 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.4.1.cjs

checksumBehavior: "update"

npmScopes:
RaspberryPiFoundation:
npmRegistryServer: "https://npm.pkg.github.com"

npmRegistries:
"https://npm.pkg.github.com":
npmAuthToken: "${GITHUB_TOKEN}"
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ x-app: &x-app
- node_modules:/app/node_modules
- /var/run/docker.sock:/var/run/docker.sock
stdin_open: true
environment:
- GITHUB_TOKEN=${GITHUB_TOKEN}
services:
app:
<<: *x-app
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.34.2",
"private": true,
"dependencies": {
"@RaspberryPiFoundation/scratch-gui": "0.1.0-experience-cs.20251218100358",
"@apollo/client": "^3.7.8",
"@babel/core": "^7.17.10",
"@codemirror/commands": "^6.1.1",
Expand All @@ -27,6 +28,7 @@
"apollo-link-sentry": "^3.2.3",
"assert": "^2.1.0",
"axios": "^0.24.0",
"buffer": "^6.0.3",
"classnames": "^2.3.2",
"codemirror": "^6.0.1",
"container-query-polyfill": "^1.0.2",
Expand All @@ -43,8 +45,10 @@
"jest-axe": "^7.0.0",
"jest-canvas-mock": "^2.5.2",
"js-convert-case": "^4.2.0",
"js-file-download": "^0.4.12",
"jszip": "^3.10.1",
"jszip-utils": "^0.1.0",
"lodash.bindall": "^4.4.0",
"marked": "^15.0.6",
"material-symbols": "^0.27.0",
"mime-types": "^2.1.35",
Expand Down Expand Up @@ -111,6 +115,7 @@
},
"devDependencies": {
"@babel/preset-env": "^7.17.10",
"@babel/preset-typescript": "^7.28.5",
"@pmmmwh/react-refresh-webpack-plugin": "0.4.3",
"@react-three/test-renderer": "8.2.1",
"@svgr/webpack": "5.5.0",
Expand Down Expand Up @@ -187,6 +192,7 @@
"stylelint-scss": "3.12.0",
"stylelint-use-logical": "^2.1.0",
"terser-webpack-plugin": "4.2.3",
"to-string-loader": "^1.2.0",
"url-loader": "4.1.1",
"webgl-mock-threejs": "^0.0.1",
"webpack": "5.95.0",
Expand Down
91 changes: 91 additions & 0 deletions src/assets/stylesheets/ExternalStyles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,94 @@
@use "../../../node_modules/prismjs/plugins/line-highlight/prism-line-highlight.css";
@use "../../../node_modules/material-symbols/sharp.scss";
@use "../../../node_modules/plotly.js/src/css/style.scss" as plotlyStyle;
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/oldtimey-mode/oldtimey-mode.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/modal/modal.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/menu-bar/account-nav.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/menu-bar/login-dropdown.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/menu-bar/settings-menu.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/menu-bar/user-avatar.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/menu-bar/menu-bar.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/menu-bar/author-info.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/menu-bar/share-button.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/menu-bar/save-status.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/menu-bar/community-button.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/menu-bar/project-title-input.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/nineties-mode/nineties-mode.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/blocks/blocks.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/prompt/prompt.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/icon-button/icon-button.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/question/question.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/controls/controls.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/sprite-selector/sprite-selector.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/drag-layer/drag-layer.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/connection-modal/connection-modal.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/asset-panel/selector.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/asset-panel/asset-panel.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/spinner/spinner.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/watermark/watermark.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/sprite-info/sprite-info.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/backpack/backpack.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/library/library.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/sound-editor/sound-editor.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/close-button/close-button.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/meter/meter.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/stage-wrapper/stage-wrapper.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/sprite-selector-item/sprite-selector-item.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/extension-button/extension-button.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/extension-button/extension-button.raw.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/filter/filter.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/prehistoric-mode/prehistoric-mode.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/slider-prompt/slider-prompt.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/loader/loader.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/stop-all/stop-all.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/play-button/play-button.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/green-flag/green-flag.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/menu/menu.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/target-pane/target-pane.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/library-item/library-item.raw.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/library-item/library-item.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/stage/stage.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/toggle-buttons/toggle-buttons.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/tag-button/tag-button.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/crash-message/crash-message.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/debug-modal/debug-modal.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/action-menu/action-menu.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/forms/label.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/forms/input.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/language-selector/language-selector.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/gui/gui.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/stage-header/stage-header.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/record-modal/record-modal.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/webgl-modal/webgl-modal.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/button/button.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/monitor-list/monitor-list.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/browser-modal/browser-modal.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/progress-ring/progress-ring.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/delete-confirmation-prompt/delete-confirmation-prompt.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/loupe/loupe.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/divider/divider.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/context-menu/context-menu.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/waveform/waveform.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/telemetry-modal/telemetry-modal.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/audio-trimmer/audio-trimmer.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/coming-soon/coming-soon.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/box/box.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/direction-picker/direction-picker.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/direction-picker/dial.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/mic-indicator/mic-indicator.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/turbo-mode/turbo-mode.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/alerts/alerts.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/alerts/alert.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/alerts/inline-message.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/cards/card.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/stage-selector/stage-selector.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/monitor/monitor.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/delete-button/delete-button.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/components/custom-procedures/custom-procedures.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/playground/player.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/playground/blocks-only.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/playground/index.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/css/z-index.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/css/typography.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/css/units.css";
@import "../../../node_modules/@RaspberryPiFoundation/scratch-gui/src/css/colors.css";
112 changes: 98 additions & 14 deletions src/components/Editor/Project/Project.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import "react-tabs/style/react-tabs.css";
import "react-toastify/dist/ReactToastify.css";
import { useContainerQuery } from "react-container-query";
import classnames from "classnames";
import { compose } from "redux";
import { setAppElement } from "react-modal";

import "../../../assets/stylesheets/Project.scss";
import Output from "../Output/Output";
Expand All @@ -15,8 +17,23 @@ import EditorInput from "../EditorInput/EditorInput";
import ResizableWithHandle from "../../../utils/ResizableWithHandle";
import { projContainer } from "../../../utils/containerQueries";

import GUI, { AppStateHOC } from "@RaspberryPiFoundation/scratch-gui";
import ScratchIntegrationHOC from "./ScratchIntegrationHOC";
import Button from "../../Button/Button";

const WrappedGui = compose(AppStateHOC, ScratchIntegrationHOC)(GUI);
// const WrappedGUI = AppStateHOC(GUI);

const Project = (props) => {
const webComponent = useSelector((state) => state.editor.webComponent);
const [isReady, setIsReady] = useState(false);

useEffect(() => {
// Set app element to document body to avoid shadow DOM issues
setAppElement(document.body);
setIsReady(true);
}, []);

const {
nameEditable = true,
withProjectbar = true,
Expand All @@ -33,26 +50,41 @@ const Project = (props) => {
}
}, [saving, autosave]);

const [params, containerRef] = useContainerQuery(projContainer);
const [defaultWidth, setDefaultWidth] = useState("auto");
const [defaultHeight, setDefaultHeight] = useState("auto");
const [maxWidth, setMaxWidth] = useState("100%");
const [handleDirection, setHandleDirection] = useState("right");
// const [params, containerRef] = useContainerQuery(projContainer);
// const [defaultWidth, setDefaultWidth] = useState("auto");
// const [defaultHeight, setDefaultHeight] = useState("auto");
// const [maxWidth, setMaxWidth] = useState("100%");
// const [handleDirection, setHandleDirection] = useState("right");
const [loading, setLoading] = useState(true);
const [containerReady, setContainerReady] = useState(false);

useMemo(() => {
const isDesktop = params["width-larger-than-720"];
// useMemo(() => {
// const isDesktop = params["width-larger-than-720"];

setDefaultWidth(isDesktop ? "50%" : "100%");
setDefaultHeight(isDesktop ? "100%" : "50%");
setMaxWidth(isDesktop ? "75%" : "100%");
setHandleDirection(isDesktop ? "right" : "bottom");
}, [params["width-larger-than-720"]]);
// setDefaultWidth(isDesktop ? "50%" : "100%");
// setDefaultHeight(isDesktop ? "100%" : "50%");
// setMaxWidth(isDesktop ? "75%" : "100%");
// setHandleDirection(isDesktop ? "right" : "bottom");
// }, [params["width-larger-than-720"]]);

useEffect(() => {
setLoading(false);
}, []);

useEffect(() => {
// Set the app element for React Modal to the root of your web component
const appRoot =
document.querySelector("editor-wc")?.shadowRoot?.querySelector("#root") ||
document.getElementById("root");
if (appRoot) {
setAppElement(appRoot);
}
}, []);

if (!isReady) {
return <div>Loading Scratch Editor...</div>;
}

return (
<div className="proj" data-testid="project">
<div
Expand All @@ -63,7 +95,59 @@ const Project = (props) => {
{withSidebar && (
<Sidebar options={sidebarOptions} plugins={sidebarPlugins} />
)}
<div className="project-wrapper" ref={containerRef}>
<Button
buttonText="Upload Project"
onClickHandler={() => {
const input = document.createElement("input");
input.type = "file";
input.accept = ".sb3";
input.onchange = (e) => {
const file = e.target.files[0];
if (file) {
// const reader = new FileReader();
// reader.onload = (event) => {
// const arrayBuffer = event.target.result;
// // Dispatch action to load project using the arrayBuffer
// // e.g., dispatch(loadProject(arrayBuffer));

// };
// reader.readAsArrayBuffer(file);
console.log("posting message to upload file...", file);
// window.postMessage("scratch-gui-upload", { file: file });
window.postMessage(
{ type: "scratch-gui-upload", file: file },
window.location.origin,
);
}
};
input.click();
}}
type="primary"
/>
<WrappedGui
locale="en"
menuBarHidden={true}
projectId="blank-scratch-starter"
projectHost="http://localhost:3009/api/projects"
assetHost="https://editor-scratch.raspberrypi.org/api/assets"

// assetHost="/api/assets"
// basePath="/scratch-gui/"
/>
{/* <WrappedGui
// projectId={projectId}
locale={"en"}
menuBarHidden={true}
projectHost={"/api/projects"}
assetHost={"/api/assets"}
basePath={"/scratch-gui/"}
onUpdateProjectId={() => {}}
onShowCreatingRemixAlert={() => {}}
onShowRemixSuccessAlert={() => {}}
onShowSavingAlert={() => {}}
onShowSaveSuccessAlert={() => {}}
/> */}
{/* <div className="project-wrapper" ref={containerRef}>
{withProjectbar && <ProjectBar nameEditable={nameEditable} />}
{!loading && (
<div className="proj-editor-wrapper">
Expand All @@ -81,7 +165,7 @@ const Project = (props) => {
<Output />
</div>
)}
</div>
</div> */}
</div>
</div>
);
Expand Down
Loading