Extension
com.jsmacrosce.jsmacros.core.extensions.Extension
Provides an extension's identity, dependencies, initialization hook, and optional translations.
Extensions are discovered by the loader as service providers. Scripts can enumerate loaded extensions through context.getCtx().runner.extensions.getAllExtensions():
js
const extensions = context.getCtx().runner.extensions.getAllExtensions().iterator();
while (extensions.hasNext()) {
Chat.log(extensions.next().getExtensionName());
}Methods
getDependencies
Reads this extension's dependency descriptor,
jsmacrosce.ext.<name>.json. Missing dependency entries are reported to standard error and skipped; descriptor read or parse failures are propagated as runtime exceptions.Returns: resolved dependency resource URLs; empty when no entries resolve or the descriptor has no dependencies or the literal
${dependencies} placeholdergetDependenciesInternal
Resolves dependency URLs from a root-classpath JSON descriptor. A primitive
dependencies value is split on spaces and each entry is prefixed with META-INF/jsmacrosdeps/; an array supplies root-relative resource paths directly. The exact ${dependencies} primitive is treated as empty. Unresolved resources are reported to standard error and skipped. Descriptor read or parse failures and unsupported dependency formats cause runtime exceptions; other malformed data or value-conversion failures can also cause runtime exceptions.Parameters:
clazz: class used to look up the descriptor and its dependency resourcesfname: descriptor path relative to the classpath root, without a leading slash
Returns: resolved dependency resource URLs, or an empty set when dependencies are absent or the placeholder is used
getExtensionName
getTranslations
Reads this extension's translations from its
assets/jsmacros/<name>/lang/ resource directory.Parameters:
lang: language-code filename component, such asen_us
Returns: translation values keyed by their JSON object keys; empty if reading or parsing fails or the JSON root is not an object. Values that cannot be converted to strings can cause a runtime exception.
getTranslationsInternal
Reads a root-classpath JSON object as a map of string values. Read or parse failures and non-object roots produce an empty map.
Parameters:
clazz: class used to look up the resourcefname: resource path relative to the classpath root, without a leading slash
Returns: object entries converted to string values, or an empty map on read or parse failure or a non-object root; values that cannot be converted can cause a runtime exception