Skip to content

Commit

Permalink
Merge pull request #64 from pooiod/develop
Browse files Browse the repository at this point in the history
Updated things, and added extension
  • Loading branch information
someCatInTheWorld authored Nov 15, 2024
2 parents e7f2a39 + 0c9c44e commit c0b57e3
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 56 deletions.
1 change: 1 addition & 0 deletions src/lib/libraries/extensions/SuperStorage/SuperStorage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/lib/libraries/extensions/cloudstorage/CloudStorage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 12 additions & 11 deletions src/lib/libraries/extensions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import React from 'react';
import { FormattedMessage } from 'react-intl';

import VideoSharing from './VidShare/VideoSharing.svg';
import SuperStorage from './SuperStorage/SuperStorage.svg';
import NoahgptThumb from './noahgpt/costume1.svg';
import typescriptIcon from './snail-ide/typescript.svg';
import twGalleryIcon from './snail-ide/turbowarpgallery.svg';
import pmGalleryIcon from './snail-ide/penguinmodgallery.svg';
import musicIconURL from './music/music.png';
import roku from './roku/roku.png';
import share from './share/share.svg';
import cloudstorageIconURL from './cloudstorage/costume1.svg';
import cloudstorageIconURL from './cloudstorage/CloudStorage.svg';
import pythonIcon from './python/py.svg';
import extCreateIcon from './ext-create/logo.svg';
import extCreateInset from './ext-create/inset.svg';
Expand Down Expand Up @@ -229,15 +230,6 @@ const menuItems = [
description: 'Do many things via the Scratch API; you can even fetch cloud data from projects!',
featured: true
},
{
name: 'Screensharing',
extensionId: 'https://editor.snail-ide.com/screen-sharing.js',
iconURL: 'https://editor.snail-ide.com/Screensharing.png', // please forgive me the text is slightly offcenter
collaborator: 'pooiod7',
tags: ['penguinmod'],
description: 'Share your screen and get the current frame as a image.',
featured: true
},
{
name: 'VideoSharing',
extensionId: 'https://editor.snail-ide.com/VideoSharing.js',
Expand Down Expand Up @@ -541,11 +533,20 @@ const menuItems = [
name: 'Cloud Storage',
extensionId: 'https://editor.snail-ide.com/cloudstorage.js',
collaborator: 'pooiod7',
iconURL: cloudstorageIconURL, // this needs to be redone soon
iconURL: cloudstorageIconURL,
tags: ['penguinmod'],
description: 'Store data in a database, similar to Storage and Better Storage, but powered by a Snap! extension.',
featured: true
},
{
name: 'SuperStorage',
extensionId: 'https://editor.snail-ide.com/SuperStorage.js',
iconURL: SuperStorage,
tags: ['penguinmod'],
description: 'Store and retrieve data locally on device or remotely on a server.',
collaborator: 'pooiod7',
featured: true
},
{
name: 'Text to Speech 2.0',
extensionId: 'https://sharkpools-extensions.vercel.app/extension-code/Text-to-Speech.js',
Expand Down
178 changes: 178 additions & 0 deletions static/SuperStorage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
(function(Scratch) {
'use strict';

if (!Scratch.extensions.unsandboxed) {
throw new Error('This extension must run unsandboxed');
}

class StorageV2 {
constructor() {
this.currentServer = "https://storage-ext.penguinmod.com/";
this.useGlobal = true;
this.waitingForResponse = false;
this.serverFailedResponse = false;
this.serverError = "";
}

getInfo() {
return {
id: 'P7SuperStorage',
name: 'Super Storage',
color1: '#31b3d4',
color2: '#179fc2',
docsURI: 'https://pooiod7.neocities.org/markdown/#/projects/scratch/extensions/other/markdown/SuperStorage',
blocks: [
{ blockType: Scratch.BlockType.LABEL, text: "Local Storage" },
{
opcode: 'getValue',
text: 'get local [KEY]',
disableMonitor: true,
blockType: Scratch.BlockType.REPORTER,
arguments: {
KEY: { type: Scratch.ArgumentType.STRING, defaultValue: "key" }
}
},
{
opcode: 'setValue',
text: 'set local [KEY] to [VALUE]',
blockType: Scratch.BlockType.COMMAND,
arguments: {
KEY: { type: Scratch.ArgumentType.STRING, defaultValue: "key" },
VALUE: { type: Scratch.ArgumentType.STRING, defaultValue: "value" }
}
},
{
opcode: 'deleteValue',
text: 'delete local [KEY]',
blockType: Scratch.BlockType.COMMAND,
arguments: { KEY: { type: Scratch.ArgumentType.STRING, defaultValue: "key" } }
},
{
opcode: 'getKeys',
text: 'get all local stored names',
disableMonitor: true,
blockType: Scratch.BlockType.REPORTER
},
{
blockType: Scratch.BlockType.LABEL,
text: "Server Storage"
},
{
opcode: 'waitingForConnection',
text: 'waiting for server to respond?',
disableMonitor: true,
blockType: Scratch.BlockType.BOOLEAN
},
{
opcode: 'connectionFailed',
text: 'server failed to respond?',
disableMonitor: true,
blockType: Scratch.BlockType.BOOLEAN
},
{
opcode: 'serverErrorOutput',
text: 'server error',
disableMonitor: false,
blockType: Scratch.BlockType.REPORTER
},
"---",
{
opcode: 'getServerValue',
text: 'get server [KEY]',
disableMonitor: true,
blockType: Scratch.BlockType.REPORTER,
arguments: { KEY: { type: Scratch.ArgumentType.STRING, defaultValue: "key" } }
},
{
opcode: 'setServerValue',
text: 'set server [KEY] to [VALUE]',
blockType: Scratch.BlockType.COMMAND,
arguments: {
KEY: { type: Scratch.ArgumentType.STRING, defaultValue: "key" },
VALUE: { type: Scratch.ArgumentType.STRING, defaultValue: "value" }
}
},
{
opcode: 'deleteServerValue',
text: 'delete server [KEY]',
blockType: Scratch.BlockType.COMMAND,
arguments: { KEY: { type: Scratch.ArgumentType.STRING, defaultValue: "key" } }
}
]
};
}

getPrefix() {
return `P7_PROJECTSTORAGE_`;
}

getAllKeys() {
return Object.keys(localStorage).filter(key => key.startsWith(this.getPrefix())).map(key => key.replace(this.getPrefix(), ""));
}

runPenguinWebRequest(url, options, ifFailReturn) {
this.waitingForResponse = true;
this.serverFailedResponse = false;
this.serverError = "";

return fetch(url, options)
.then(response => response.ok ? response.text() : Promise.reject(response.text()))
.then(text => {
this.waitingForResponse = false;
return text;
})
.catch(err => {
this.waitingForResponse = false;
this.serverFailedResponse = true;
this.serverError = err;
return ifFailReturn;
});
}

getKeys() {
return JSON.stringify(this.getAllKeys());
}

getValue(args) {
return localStorage.getItem(this.getPrefix() + args.KEY) || "";
}

setValue(args) {
localStorage.setItem(this.getPrefix() + args.KEY, args.VALUE);
}

deleteValue(args) {
localStorage.removeItem(this.getPrefix() + args.KEY);
}

waitingForConnection() {
return this.waitingForResponse;
}

connectionFailed() {
return this.serverFailedResponse;
}

serverErrorOutput() {
return this.serverError;
}

getServerValue(args) {
return this.runPenguinWebRequest(`${this.currentServer}get?key=${args.KEY}`, null, "");
}

setServerValue(args) {
return this.runPenguinWebRequest(`${this.currentServer}set?key=${args.KEY}`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ "value": args.VALUE })
});
}

deleteServerValue(args) {
return this.runPenguinWebRequest(`${this.currentServer}delete?key=${args.KEY}`, { method: "DELETE" });
}
}

Scratch.extensions.register(new StorageV2());
})(Scratch);
58 changes: 16 additions & 42 deletions static/VideoSharing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Video sharing (v2.4.1) by pooiod7
// The successor to ScreenSharing
// Video sharing (v2.4.2) by pooiod7
// Was originally the "ScreenSharing" extension

(function(Scratch) {
'use strict';
Expand All @@ -21,7 +21,7 @@

let haswarned;
function shouldwarn(){
return Scratch.vm.runtime.isPackaged;
return !Scratch.vm.runtime.isPackaged;
}

class VideoSharing {
Expand Down Expand Up @@ -245,18 +245,12 @@
}

startScreenSharing() {
if (this.isSharing()) {
this.stopSharing();
}
if (this.isSharing()) this.stopSharing();

if (!this.canScreen()) {
return;
}
if (!this.canScreen()) return;

if (shouldwarn()) {
if (!this.warn("screen")) {
return;
}
if (!this.warn("screen")) return;
}

return new Promise((resolve) => {
Expand All @@ -283,14 +277,10 @@
}

startCameraSharing() {
if (this.isSharing()) {
this.stopSharing();
}
if (this.isSharing()) this.stopSharing();

if (shouldwarn()) {
if (!this.warn("camera")) {
return;
}
if (!this.warn("camera")) return;
}

return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -326,14 +316,10 @@
}

getHEX(args) {
if (!this.isSharing()) {
return;
}
if (!this.isSharing()) return;

var rez = args.REZ;
if (rez > 1) {
rez = 1;
}
if (rez > 1) rez = 1;
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
const width = videoElement.videoWidth * rez;
Expand All @@ -357,14 +343,10 @@
}

getPNG(args) {
if (!this.isSharing()) {
return;
}
if (!this.isSharing()) return;

var rez = args.REZ;
if (rez > 1) {
rez = 1;
}
if (rez > 1) rez = 1;
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
const width = videoElement.videoWidth * rez;
Expand All @@ -380,14 +362,10 @@
}

getJPEG(args) {
if (!this.isSharing()) {
return;
}
if (!this.isSharing()) return;

let rez = args.REZ;
if (rez > 1) {
rez = 1;
}
if (rez > 1) rez = 1;
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
const width = videoElement.videoWidth * rez;
Expand All @@ -404,14 +382,10 @@
}

getWEBP(args) {
if (!this.isSharing()) {
return;
}
if (!this.isSharing()) return;

let rez = args.REZ;
if (rez > 1) {
rez = 1;
}
if (rez > 1) rez = 1;

const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
Expand Down
Loading

0 comments on commit c0b57e3

Please sign in to comment.