Skip to content

Commit

Permalink
docs: various changes/improvements (#90)
Browse files Browse the repository at this point in the history
* Update inputs.md

* Update hello-world.md

* Update inputs.md

* Update unsandboxed.md

* Update unsandboxed.md

* Update better-development-server.md

* Update assorted-apis.md

* Update hello-world.md
  • Loading branch information
LilyMakesThings authored Jan 21, 2024
1 parent 837e506 commit 28cccb3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
4 changes: 3 additions & 1 deletion docs/development/extensions/assorted-apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ These three properties determine, respectively, the color of the blocks, the col

<ExtensionCode title="color">{require("!raw-loader!@site/static/example-extensions/color.js")}</ExtensionCode>

Different block color modes (such as **High Contrast**, **Dark** and any "Addons" presets) are automatically generated based on these values.

## docsURI

docsURI adds a button at the start of the block list that opens a page for people to learn more about how your extension works.
Expand All @@ -22,7 +24,7 @@ docsURI adds a button at the start of the block list that opens a page for peopl

## disableMonitor

Scratch will automatically show a checkbox to show a variable monitor by REPORTER blocks with no arguments (other people call this a "readout" or "watcher"). To disable this, set disableMonitor to true on the block.
Scratch will automatically show a checkbox to show a variable monitor by REPORTER blocks with no inputs. Note that in TurboWarp, this applies to BOOLEAN blocks too. To disable this, set disableMonitor to true on the block.

Note that, even if disableMonitor is set, it is still possible for someone to manually create a monitor using a modified (or old) version of the extension or other tools.

Expand Down
2 changes: 1 addition & 1 deletion docs/development/extensions/better-development-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ npm run dev

Now navigate to [http://localhost:8000](http://localhost:8000) -- you should see a list similar to [extensions.turbowarp.org](https://extensions.turbowarp.org/). For now, we're not going to worry about the list, we're just going to use the development server part.

The place to save your extension JS is in the `extensions` folder inside of the repository. If you intend to submit these to us later, you should create a user folder for your extensions. For example, if your username is `TestMuffin`, you might save your fetching extension in the folder `extensions/TestMuffin/fetch.js` and load it using http://localhost:8000/TestMuffin/fetch.js. The extension should then also use an ID similar to `testmuffinfetch`.
The place to save your extension JS is in the `extensions` folder inside of the repository. If you intend to submit these to us later, you should create a user folder for your extensions. For example, if your username is `TestMuffin`, you might save your fetching extension in the folder `extensions/TestMuffin/fetch.js` and load it using http://localhost:8000/TestMuffin/fetch.js. The extension should then also use an ID that contains your username, such as `testmuffinfetch`.

The local development server is set up with the correct headers so that you don't need to manually hard refresh to ensure your script changes apply, and it tries to mimic the real extensions.turbowarp.org website as much as possible. It also includes TypeScript hints for many common Scratch APIs and ESLint rules for common mistakes.

Expand Down
9 changes: 5 additions & 4 deletions docs/development/extensions/hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ Make sure to always call register() exactly once. If you don't call it, your ext
}
```
When you call register(), Scratch will then call the getInfo() function on the provided object. This object must return an object with metadata about the extension. Some required fields are `id`, `name`, and `blocks`. Here's a short summary of those:
When you call register(), Scratch will then call the getInfo() function on the provided object. This object must return an object with metadata about the extension. Some of the fields are `id`, `name`, and `blocks`. Here's a short summary of those:
| | Type | Description |
|:-:|:-:|:-:|
| id | string | A unique ID used only by this extension. Multiple extensions cannot share the same ID. Can only use the letters a-z and 0-9 -- no uppercase letters, spaces, or special characters. |
| name | string | The name of the extension that appears in the toolbox. |
| id | string | A unique ID used only by this extension. Multiple extensions cannot share the same ID. Can only use the letters a-z and 0-9 -- no spaces or special characters. |
| name | string | The name of the extension that appears in the toolbox. If not provided, it will default to the extension id. |
| blocks | array | A list of objects that describe the blocks in the project. |
Here's a short summary of what each block should have:
Expand All @@ -82,7 +82,8 @@ These are the acceptable values for blockType:
|Scratch.BlockType.COMMAND|A block that doesn't report a value|move 10 steps|
|Scratch.BlockType.REPORTER|A round block that reports a string or number|x position, costume name|
|Scratch.BlockType.BOOLEAN|A block with pointy edges that reports a boolean (true or false)|mouse down|
|Scratch.BlockType.HAT|A block that starts in response to events. Discussed later.|when this sprite clicked|
|Scratch.BlockType.HAT|A block that starts in response to specific conditions. Discussed later.|when loudness > 10|
|Scratch.BlockType.EVENT|A block that starts in response exclusively to events. Discussed later.|when this sprite clicked|
While other BlockTypes do exist, they do not work well and will not be discussed at this time.
Expand Down
4 changes: 3 additions & 1 deletion docs/development/extensions/inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ These are the acceptible values for type:
|Scratch.ArgumentType.MATRIX|A 5x5 matrix represented in binary| 11101010101... |
|Scratch.ArgumentType.NOTE|A note on a piano keyboard.| ? |
|Scratch.ArgumentType.IMAGE|Displays an inline image, not actually an input. Described later.| N/A |
|Scratch.ArgumentType.COSTUME|Names of costumes within that sprite.| costume1 |
|Scratch.ArgumentType.SOUND|Names of sounds within that sprite.| recording1 |

Next, Scratch needs to know where to put each of the arguments in the block. Are they at the start, end, or somewhere in the middle? It can't guess, so you have to tell it. To do this, you use the `text` property on the block by using `[ARGUMENT_NAME]` syntax to denote where each input goes. Each argument in the `arguments` object should appear in `text` exactly once. Arguments can be in any order; it doesn't matter.

Expand Down Expand Up @@ -80,7 +82,7 @@ To make an argument into a menu, set its `type` to `Scratch.ArgumentType.STRING`

A field is an argument that can only be set to a fixed string. As an example, see the input in the "stop all" block. An input is an argument that can be set to any value. As an example, see the steps input in the "move 10 steps" block or the costume input in the "switch costume" block. You almost always want an input, not a field.

While it is possible to set the menu object itself to an array, this is highly discouraged as it implicitly sets `acceptReporters` to `false` which, again, is almost never what you want. Almost every menu you use should explicitly set `acceptReporters` to true so that it is an "input" instead of a "field". Note that switching an argument from a field to an input or the other way around is a backward-incompatible change. The only exception to this rule is when using [event-based hat blocks](./hats), which will be discussed much later.
While it is possible to set the menu object itself to an array, this is highly discouraged as it implicitly sets `acceptReporters` to `false` which, again, is almost never what you want. Almost every menu you use should explicitly set `acceptReporters` to true so that it is an "input" instead of a "field". The only exception to this rule is when using [event-based hat blocks](./hats), which will be discussed much later. Note that switching an argument from a field to an input or the other way around is a backward-incompatible change.

The default value will typically be the first item in the menu's item list. The item list must not be empty.

Expand Down
8 changes: 8 additions & 0 deletions docs/development/extensions/unsandboxed.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ If the extension MUST be run unsandboxed, add this around the start:
}
```

If you're using the `vm`, `runtime` or `Cast` APIs a lot, common practise is to define them around the start to save time:

```js
const vm = Scratch.vm;
const runtime = vm.runtime;
const Cast = Scratch.Cast; // Discussed later.
```

## Permissioned APIs

Whereas sandboxed extensions are free to use APIs such as fetch() as they please, unsandboxed extensions should instead ask for permission before making a request to any remote service. This gives the user control over their privacy. While there is no technical measures enforcing this at runtime, it is required for all extensions on [extensions.turbowarp.org](https://extensions.turbowarp.org).
Expand Down

0 comments on commit 28cccb3

Please sign in to comment.