Skip to content

New extension: Cross-Project#2518

Open
ampelc wants to merge 24 commits into
TurboWarp:masterfrom
ampelc:mesh
Open

New extension: Cross-Project#2518
ampelc wants to merge 24 commits into
TurboWarp:masterfrom
ampelc:mesh

Conversation

@ampelc

@ampelc ampelc commented May 30, 2026

Copy link
Copy Markdown

Per the docs:

Mesh lets you communicate with other projects running in the same browser or in TurboWarp Desktop, using special versions of variables and broadcasts. This allows you to for example, create a game that talks to another project running at the same time.

This was actually a real feature in Scratch 1.4.

TODO: ws integration (though that can be added at a later time).

This is a copy of #2382 which is from an account I am now locked out of.

8to16 and others added 20 commits January 9, 2026 21:52
…into mesh

* 'mesh' of ssh://github.com/ampelectrecuted/twextensions:
  [Automated] Update translations 2026-01-03 (TurboWarp#2378)
  SharkPool/Camera: Fix critical regression from previous commit (TurboWarp#2376)
  SharkPool/Camera V2 -- Fix hidden sprites not receiving camera updates (TurboWarp#2372)
  [Automated] Update translations 2025-12-31 (TurboWarp#2374)
  text.js -- Add array of regex matches block (TurboWarp#2306)
  Revert "SharkPool/CameraV2 -- Fix hidden sprites not receiving camera updates" (TurboWarp#2371)
  cursor: translate cursor menu (TurboWarp#2076)
  SharkPool/CameraV2: Fix hidden sprites not receiving camera updates (TurboWarp#2359)
  local-storage: fix it generally not working (TurboWarp#2368)
  [Automated] Update translations 2025-12-20 (TurboWarp#2362)
  [Automated] Update translations 2025-12-17 (TurboWarp#2360)
  [Automated] Update translations 2025-12-13 (TurboWarp#2358)
  build(deps): bump @turbowarp/types from `c54f2cc` to `938c3ab` (TurboWarp#2355)
…into mesh

* 'mesh' of ssh://github.com/ampelectrecuted/twextensions:
  8to16/mesh: remove old debugging log
@ampelc ampelc requested a review from a team as a code owner May 30, 2026 21:51
@github-actions github-actions Bot added the pr: new extension Pull requests that add a new extension label May 30, 2026
@SharkPool-SP

Copy link
Copy Markdown
Collaborator

I dont think 'Mesh' is the greatest name for this

@GarboMuffin

GarboMuffin commented May 31, 2026

Copy link
Copy Markdown
Member

Is this meaningfully compatible or equivalent with the Scratch 1.4 feature enough to justify giving it the same name?

@ampelc ampelc changed the title New extension: Mesh New extension: Cross-Project May 31, 2026
@ampelc

ampelc commented May 31, 2026

Copy link
Copy Markdown
Author

Is this meaningfully compatible or equivalent with the Scratch 1.4 feature enough to justify giving it the same name?

actually not really

since mesh might be confusing to some anyways i've renamed this to cross-project

@Brackets-Coder

Copy link
Copy Markdown
Contributor

!format

@SharkPool-SP SharkPool-SP left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this extension, but do these first. I can also make a better banner for you if you want

Comment thread extensions/8to16/mesh.js
vm.runtime.extensionStorage["8to16mesh"] = { messages: [], variables: {} };
});
vm.runtime.on("PROJECT_LOADED", () => {
vm.runtime.extensionManager.refreshBlocks();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vm.extensionManager.refreshBlocks() takes in arguments to refresh a specific extension palette. For optimization, use your extension id as the first argument

Comment thread extensions/8to16/mesh.js
...getMeshages(),
name,
];
vm.extensionManager.refreshBlocks();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment thread extensions/8to16/mesh.js
vm.runtime.extensionStorage["8to16mesh"].messages = getMeshages().filter(
(n) => n !== name
);
vm.extensionManager.refreshBlocks();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment thread extensions/8to16/mesh.js
...getMeshVars(),
[name]: "",
};
vm.extensionManager.refreshBlocks();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment thread extensions/8to16/mesh.js
vm.runtime.extensionStorage["8to16mesh"].variables = Object.fromEntries(
Object.entries(getMeshVars()).filter((v) => v[0] !== name)
);
vm.extensionManager.refreshBlocks();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment thread extensions/8to16/mesh.js
id: "eightxtwoMesh",
name: Scratch.translate("Cross-Project"),
docsURI: "https://extensions.turbowarp.org/8to16/mesh",
color1: "#4cdab2",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make the block color a bit darker so you can see the block text better

Comment thread extensions/8to16/mesh.js
await new Promise((resolve) => {
const poll = () => {
if (finishedWaits[BROADCAST] >= connectedUsers) resolve();
else setTimeout(poll, 25);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing with runtime.on("AFTER_EXECUTE"), alternatively use util.yield(), which I can give examples for.

Comment thread extensions/8to16/mesh.js
// Init the broadcastchannel
const bc = new BroadcastChannel("extensions.turbowarp.org/8to16/mesh");
let connectedUsers = 0;
let finishedWaits = {};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change {} to Object.create(null) since keys are set by users, which means they can set dangerous keys like toString or prototype

Comment thread extensions/8to16/mesh.js
let finishedWaits = {};

if (!vm.runtime.extensionStorage["8to16mesh"])
vm.runtime.extensionStorage["8to16mesh"] = { messages: [], variables: {} };

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change {} to Object.create(null) since keys are set by users, which means they can set dangerous keys like toString or prototype

Comment thread extensions/8to16/mesh.js
if (!vm.runtime.extensionStorage["8to16mesh"])
vm.runtime.extensionStorage["8to16mesh"] = { messages: [], variables: {} };
vm.runtime.on("RUNTIME_DISPOSED", () => {
vm.runtime.extensionStorage["8to16mesh"] = { messages: [], variables: {} };

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change {} to Object.create(null) since keys are set by users, which means they can set dangerous keys like toString or prototype

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: new extension Pull requests that add a new extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants