Skip to content

Commit

Permalink
changing to ID utility
Browse files Browse the repository at this point in the history
  • Loading branch information
mayarajan3 committed Jun 25, 2024
1 parent 4de54de commit a711fe3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions extensions/documentation/src/porting/example.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ArgumentType, BlockType, Environment, extension, scratch } from "$common";
import BlockUtility from "$root/scratch-packages/scratch-vm/src/engine/block-utility";
import { ArgumentType, BlockType, BlockUtilityWithID, Environment, extension, scratch } from "$common";
import formatMessage from './format-message'; // This should actually be an npm package and thus be 'format-message'

const details = {
Expand All @@ -20,7 +19,7 @@ export default class SomeBlocks extends extension(details) {
options: [{ text: 'Item One', value: 'itemId1' },'itemId2']
}
} of ${{ type: "number", defaultValue: 1 }}`)
myReporter(text: string, letterNum: number) {
myReporter(text: string, letterNum: number, util: BlockUtilityWithID) {
const message = formatMessage({
id: 'myReporter.result',
default: 'Letter {letterNum} of {text} is {result}.',
Expand Down
2 changes: 1 addition & 1 deletion extensions/src/.templates/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class ExtensionNameGoesHere extends extension(details) {

/** @see {ExplanationOfHatBlock} */
@(scratch.hat`Should the below block execute: ${"Boolean"}`)
/** @see {ExplanationOfBlockUtility} */
/** @see {ExplanationOfBlockUtilityWithID} */
async exampleHat(condition: boolean, util: BlockUtilityWithID) {
return util.stackFrame.isLoop === condition;
}
Expand Down
10 changes: 5 additions & 5 deletions extensions/src/common/templateDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,16 @@ type ExplanationOfHatBlock = Documentation;
type ExplanationOfBlockArg = Documentation;

/**
* You should notice that the final argument of our method is of type `BlockUtility`.
* You should notice that the final argument of our method is of type `BlockUtilityWithID`.
*
* For every Block method, you can optionally add a final parameter of type `BlockUtility`
* For every Block method, you can optionally add a final parameter of type `BlockUtilityWithID`
* which can be used to accomplish more [advanced behaviours](https://github.com/mitmedialab/prg-extension-boilerplate/tree/dev/extensions#making-use-of-the-block-utility).
* No need to worry too much about when you're first starting out, though!
*
* As is the case here, note that the inclusion of a `BlockUtility` argument does not "count"
* As is the case here, note that the inclusion of a `BlockUtilityWithID` argument does not "count"
* as an Argument for your Block.
*
* Thus, if your method **_only_** accepts a `BlockUtility` argument, then the `block` function will **not**
* Thus, if your method **_only_** accepts a `BlockUtilityWithID` argument, then the `block` function will **not**
* require (or allow) you to add a placeholder in the template literal -- similiar to the `exampleReporter` method / Block above.
*/
type ExplanationOfBlockUtility = Documentation;
type ExplanationOfBlockUtilityWithID = Documentation;

0 comments on commit a711fe3

Please sign in to comment.