Skip to main content

Extension Integration

Extensions can do many things, however PenguinMod doesn't actually have many ways to access the insides of your extension. This causes buggy or broken behavior in cases like Audio extensions not working with the pause button, volume slider, and project recorder addons.

The registerExtensionIntegrationComponents function is intended to help with this.

registerExtensionIntegrationComponents

Scratch.vm.runtime.registerExtensionIntegrationComponents(extensionId, whitelistFeatures, components);

This function allows extensions to register components that are used for other PenguinMod features. This can include GUI menus, addons, or other extensions.

You can re-run this function if you need to change any information. However, the original information will be replaced, not appended to.

ParameterTypeExplanation
extensionIdstringThe ID of your extension. Should be the same ID your extension already uses elsewhere.
whitelistFeaturesArray<string>Which features to enable. See whitelistFeatures.
componentsobjectParts of your extension. See components.

whitelistFeatures

This is a list of permissions which determines what PenguinMod can do with the provided components. Passing an empty array will allow all components provided to be used by PenguinMod's features.

Generally you should use an empty array and not heavily use the components you provide, but some extensions might want to manually make support for some PenguinMod features to be in control of their behavior.

Only some components are used by each permission. You don't have to provide the components attached to a permission, but when using the whitelist, it's pointless to specify a permission that you won't provide the components for. This is an array of strings. If you want to use the whitelist, the array can contain any of these permissions:

PermissionComponentsExplanation
audioContextSuspendaudioContextsAllows PenguinMod to run AudioContext.suspend() on your AudioContexts
audioContextResumeaudioContextsAllows PenguinMod to run AudioContext.resume() on your AudioContexts
audioMediaStreamaudioContexts, audioNodesAllows PenguinMod to create media stream destinations and connect the AudioNodes to them
gainNodeSetgainNodesAllows PenguinMod to set the gain.value on your GainNodes

components

This is an object containing all of the components of your extension that you want to make work with PenguinMod's features.

KeyValueExplanation
audioContextsArray<AudioContext>Any AudioContexts being used in the extension that you want to register.
audioNodesArray<AudioNode>Any destination AudioNodes you want to register, however see audioNodes to provide these properly.
gainNodesArray<GainNode>The deepest GainNodes you want to register, see gainNodes to provide these properly.

audioNodes

These nodes should be connected to the destination of the AudioContexts provided. todo: add an exmple

gainNodes

Do not include GainNodes within the same tree of AudioNodes, only specify the GainNode closest to the AudioContext's destination. todo: add an example