# JsMacros

`com.jsmacrosce.jsmacros.core.library.impl.FJsMacros`

Script library for event listeners, script execution, and profile services.  

Scripts access this library as `JsMacros` for event handling, script execution, and
profile services.  
```js
const listener = JsMacros.on("Tick", JavaWrapper.methodToJava(function (event) {
  Chat.log(event.getEventName());  
}));  
JsMacros.off(listener);  
JsMacros.runScript("helper.js", null, JavaWrapper.methodToJava(function () {
  Chat.log("helper.js is done");  
}));  
```

Accessible in scripts via the global `JsMacros` variable.

## Nested types

- [EventAndContext](FJsMacros.EventAndContext.md)
- [ScriptEventListener](FJsMacros.ScriptEventListener.md)

## Methods

### assertEvent {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_assertEvent-BaseEvent-String-}

```js
assertEvent(BaseEvent event, String type): void
```

Throws [AssertionError](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/AssertionError.html) unless the event's [Event](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/Event.md) annotation value equals
`type`; also narrows the event type in generated TypeScript declarations.

**Parameters:**
- `event`: event to check
- `type`: expected event name

**Since:** 1.9.0

### createComposedEventFilterer {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_createComposedEventFilterer-EventFilterer-}

```js
createComposedEventFilterer(EventFilterer initial): FiltererComposed
```

Creates a filterer that combines conditions as OR groups of AND conditions; use its
`and` and `or` methods to add conditions.

**Parameters:**
- `initial`: initial filterer in the first AND group

**Returns:** a composed filterer initialized with `initial`

**Since:** 1.9.1

### createCustomEvent {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_createCustomEvent-String-}

```js
createCustomEvent(String eventName): EventCustom
```

Creates a named event that can carry key-value arguments. Call
[EventCustom.registerEvent()](../../../../../../../events/com/jsmacrosce/jsmacros/core/event/impl/EventCustom.md#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_registerEvent-) to register its name for subscription and GUI visibility,  
then register listeners before calling [EventCustom.trigger()](../../../../../../../events/com/jsmacrosce/jsmacros/core/event/impl/EventCustom.md#com.jsmacrosce.jsmacros.core.event.impl.EventCustom_trigger-), which dispatches
immediately without queuing. Creation and storing arguments do not dispatch.  
```js
// Store arguments, register the name, then dispatch.  
const ping = JsMacros.createCustomEvent("MyPluginPing");  
ping.putString("from", "my-plugin");  
ping.putInt("count", 1);  
ping.registerEvent();  
ping.trigger();  

// Custom events can also be passed as script arguments.  
const data = JsMacros.createCustomEvent("MyPluginJob");  
data.putString("task", "rebuild-world");  
data.putBoolean("urgent", true);  
JsMacros.runScript("worker.js", data);  
```

**Parameters:**
- `eventName`: name used to dispatch the event

**Returns:** the event object

**Since:** 1.2.8

### createEventFilterer {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_createEventFilterer-String-}

```js
createEventFilterer(String event): EventFilterer
```

Creates a filterer for an event with a registered filterer class. Filterers are checked
before the listener callback runs; available fields and setters depend on the event.  
Throws [IllegalArgumentException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) if the event is unregistered or has no filterer.  
```js
// Narrow a block-update listener to a position and block id.  
const near = JsMacros.createEventFilterer("BlockUpdate")
  .setPos(0, -60, 0)
  .setBlockId("minecraft:chest");  
JsMacros.on("BlockUpdate", near, JavaWrapper.methodToJava(function (event) {
  const pos = event.block.getBlockPos();  
  Chat.log(`the chest at ${pos.getX()}, ${pos.getY()}, ${pos.getZ()} changed`);  
}));  

// Change the filter without replacing the listener.  
near.setBlockId("minecraft:furnace").setUpdateType("ENTITY");  

// A modulus filterer can be used with any event.  
JsMacros.on("Tick", JsMacros.createModulusEventFilterer(20),  
  JavaWrapper.methodToJava(function () {
    Chat.log("about a second went by");  
  }));  
```

**Parameters:**
- `event`: registered event name with an available filterer class

**Returns:** a new filterer for the event

**Since:** 1.9.1

### createModulusEventFilterer {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_createModulusEventFilterer-int-}

```js
createModulusEventFilterer(int quotient): FiltererModulus
```

Creates a stateful filterer that passes every `quotient`th filter call; a fresh
filterer rejects calls until the threshold is reached. The count is shared by listeners
using the same filterer. The constructor applies [Math.abs(int)](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Math.html); zero and
`Integer.MIN_VALUE` make every call pass.

**Parameters:**
- `quotient`: threshold in filter calls; its absolute value is used except for
                 `Integer.MIN_VALUE`

**Returns:** the new modulus filterer

**Since:** 1.9.1

### disableAllListeners {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_disableAllListeners-String-}

```js
disableAllListeners(String event): void
```

Will also disable all listeners for the given event, including JsMacros own event listeners.

**Parameters:**
- `event`: the event to remove all listeners from

**Since:** 1.8.4

### disableAllListeners {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_disableAllListeners-}

```js
disableAllListeners(): void
```

Will also disable all listeners, including JsMacros own event listeners.

**Since:** 1.8.4

### disableScriptListeners {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_disableScriptListeners-String-}

```js
disableScriptListeners(String event): void
```

Removes script-created listeners for the given event, leaving built-in listeners untouched.  
Use [disableAllListeners(String)](#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_disableAllListeners-String-) to remove both kinds.

**Parameters:**
- `event`: the event to remove all listeners from

**Since:** 1.8.4

### disableScriptListeners {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_disableScriptListeners-}

```js
disableScriptListeners(): void
```

Removes script-created listeners for all events, leaving built-in listeners untouched.

**Since:** 1.8.4

### getConfig {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_getConfig-}

```js
getConfig(): ConfigManager
```

**Returns:** this script's configuration manager.

### getOpenContexts {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_getOpenContexts-}

```js
getOpenContexts(): List<BaseScriptContext<?>>
```

**Returns:** an immutable snapshot of currently open script contexts

**Since:** 1.4.0

### getProfile {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_getProfile-}

```js
getProfile(): BaseProfile
```

**Returns:** this script's profile.

### getServiceManager {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_getServiceManager-}

```js
getServiceManager(): ServiceManager
```

Returns the manager for this profile's background services.

**Returns:** the service manager

**Since:** 1.6.3

### invertEventFilterer {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_invertEventFilterer-EventFilterer-}

```js
invertEventFilterer(EventFilterer base): EventFilterer
```

Inverts a filterer's test result; inverting an already inverted filterer returns its base.  
Throws [IllegalArgumentException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalArgumentException.html) if `base` is `null`.

**Parameters:**
- `base`: filterer to invert

**Returns:** the inverted filterer, or its base if already inverted

**Since:** 1.9.1

### listeners {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_listeners-String-}

```js
listeners(String event): List<IEventListener>
```

**Parameters:**
- `event`: event name

**Returns:** listeners for this event other than built-in `BaseListener` instances

**Since:** 1.2.3

### off {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_off-IEventListener-}

```js
off(IEventListener listener): boolean
```

**Parameters:**
- `listener`: listener to remove

**Returns:** `true` if it was removed from an event, or `false` if it was not registered

**Since:** 1.2.3

**See:**
- [FJsMacros.off(String, IEventListener)](#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_off-String-IEventListener-)

### off {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_off-String-IEventListener-}

```js
off(String event, IEventListener listener): boolean
```

Removes a [IEventListener](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/IEventListener.md) from an event.

**Parameters:**
- `event`: event name under which the listener is registered
- `listener`: listener to remove from that event

**Returns:** `true` if it was removed from that event, or `false` if it was not registered there

**Since:** 1.2.3

**See:**
- [IEventListener](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/IEventListener.md)

### on {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_on-String-MethodWrapper-}

```js
on(String event, MethodWrapper<BaseEvent, EventContainer<?>, Object, ?> callback): IEventListener
```

Registers a listener for an event.

**Parameters:**
- `event`: registered event name; script subscriptions are not remapped from old aliases
- `callback`: calls your method as a [BiConsumer](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/BiConsumer.html)&lt;[BaseEvent](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/BaseEvent.md), [EventContainer](../../../../../../../classes/com/jsmacrosce/jsmacros/core/language/EventContainer.md)&gt;

**Returns:** the registered listener, or `null` if the callback is `null`

**Since:** 1.2.7

**See:**
- [IEventListener](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/IEventListener.md)

### on {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_on-String-boolean-MethodWrapper-}

```js
on(String event, boolean joined, MethodWrapper<BaseEvent, EventContainer<?>, Object, ?> callback): IEventListener
```

Registers a listener for an event. `joined` asks a joinable event to wait for this
listener; cancellable events wait regardless. Joined handling needs the listener to belong to
another script, because a script cannot wait on a listener in its own run.

**Parameters:**
- `event`: registered event name; script subscriptions are not remapped from old aliases
- `joined`: whether to request waiting for this listener on a joinable event; the request
              does nothing if the event is not joinable
- `callback`: calls your method as a [BiConsumer](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/BiConsumer.html)&lt;[BaseEvent](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/BaseEvent.md), [EventContainer](../../../../../../../classes/com/jsmacrosce/jsmacros/core/language/EventContainer.md)&gt;

**Returns:** the registered listener, or `null` if the callback is `null`

**Since:** 1.9.0

**See:**
- [IEventListener](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/IEventListener.md)

### on {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_on-String-EventFilterer-MethodWrapper-}

```js
on(String event, EventFilterer filterer, MethodWrapper<BaseEvent, EventContainer<?>, Object, ?> callback): IEventListener
```

Registers a listener for an event, optionally filtering which events reach the callback.

**Parameters:**
- `event`: registered event name; script subscriptions are not remapped from old aliases
- `filterer`: filterer that must support this event; `null` accepts events without filtering
- `callback`: calls your method as a [BiConsumer](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/BiConsumer.html)&lt;[BaseEvent](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/BaseEvent.md), [EventContainer](../../../../../../../classes/com/jsmacrosce/jsmacros/core/language/EventContainer.md)&gt;

**Returns:** the registered listener, or `null` if the callback is `null`

**Since:** 1.9.1

**See:**
- [IEventListener](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/IEventListener.md)

### on {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_on-String-EventFilterer-boolean-MethodWrapper-}

```js
on(String event, EventFilterer filterer, boolean joined, MethodWrapper<BaseEvent, EventContainer<?>, Object, ?> callback): IEventListener
```

Registers a listener for an event, optionally filtering which events reach the callback.  
`joined` asks a joinable event to wait for this listener; cancellable events wait
regardless. Joined handling needs the listener to belong to another script, because a script
cannot wait on a listener in its own run.

**Parameters:**
- `event`: registered event name; script subscriptions are not remapped from old aliases
- `filterer`: filterer that must support this event; `null` accepts events without filtering
- `joined`: whether to request waiting for this listener on a joinable event; the request
              does nothing if the event is not joinable
- `callback`: calls your method as a [BiConsumer](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/BiConsumer.html)&lt;[BaseEvent](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/BaseEvent.md), [EventContainer](../../../../../../../classes/com/jsmacrosce/jsmacros/core/language/EventContainer.md)&gt;

**Returns:** the registered listener, or `null` if the callback is `null`

**Since:** 1.9.1

**See:**
- [IEventListener](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/IEventListener.md)

### once {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_once-String-MethodWrapper-}

```js
once(String event, MethodWrapper<BaseEvent, EventContainer<?>, Object, ?> callback): IEventListener
```

Registers a listener that is removed when the event triggers.

**Parameters:**
- `event`: registered event name; script subscriptions are not remapped from old aliases
- `callback`: calls your method as a [BiConsumer](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/BiConsumer.html)&lt;[BaseEvent](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/BaseEvent.md), [EventContainer](../../../../../../../classes/com/jsmacrosce/jsmacros/core/language/EventContainer.md)&gt;

**Returns:** the registered listener, or `null` if the callback is `null`

**Since:** 1.2.7

**See:**
- [IEventListener](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/IEventListener.md)

### once {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_once-String-boolean-MethodWrapper-}

```js
once(String event, boolean joined, MethodWrapper<BaseEvent, EventContainer<?>, Object, ?> callback): IEventListener
```

Registers a listener that is removed when the event triggers; `joined` requests joined handling when supported.

**Parameters:**
- `event`: registered event name; script subscriptions are not remapped from old aliases
- `joined`: whether to request joined handling for a joinable event
- `callback`: calls your method as a [BiConsumer](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/BiConsumer.html)&lt;[BaseEvent](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/BaseEvent.md), [EventContainer](../../../../../../../classes/com/jsmacrosce/jsmacros/core/language/EventContainer.md)&gt;

**Returns:** the registered listener, or `null` if the callback is `null`

**Since:** 1.9.0

**See:**
- [IEventListener](../../../../../../../classes/com/jsmacrosce/jsmacros/core/event/IEventListener.md)

### runScript {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_runScript-String-}

```js
runScript(String file): EventContainer<?>
```

Runs a script file without supplying an event or completion callback.

**Parameters:**
- `file`: path of the script file

**Returns:** the container for the running script

**Since:** 1.1.5

### runScript {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_runScript-String-BaseEvent-}

```js
runScript(String file, BaseEvent fakeEvent): EventContainer<?>
```

Runs a script file with the supplied event as its trigger.

**Parameters:**
- `file`: path of the script file
- `fakeEvent`: event supplied to the script, or `null`

**Returns:** the container for the running script

**Since:** 1.6.3

### runScript {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_runScript-String-BaseEvent-MethodWrapper-}

```js
runScript(String file, BaseEvent fakeEvent, MethodWrapper<Throwable, Object, Object, ?> callback): EventContainer<?>
```

Runs a script file with an event and optional completion callback.

**Parameters:**
- `file`: path of the script file
- `fakeEvent`: event supplied to the script, or `null`
- `callback`: called when the script completes, or `null`

**Returns:** the container for the running script

**Since:** 1.6.3

**Note:** 1.1.5 - 1.6.3 didn't have fakeEvent

### runScript {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_runScript-String-String-}

```js
runScript(String language, String script): EventContainer<?>
```

Runs a script string in the specified language without a completion callback.

**Parameters:**
- `language`: script language
- `script`: script source

**Returns:** the container for the running script

**Since:** 1.2.4

### runScript {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_runScript-String-String-MethodWrapper-}

```js
runScript(String language, String script, MethodWrapper<Throwable, Object, Object, ?> callback): EventContainer<?>
```

Runs a script string in the specified language, optionally calling back when it completes.

**Parameters:**
- `language`: script language
- `script`: script source
- `callback`: completion callback, or `null`

**Returns:** the container for the running script

**Since:** 1.2.4

### runScript {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_runScript-String-String-String-MethodWrapper-}

```js
runScript(String language, String script, String file, MethodWrapper<Throwable, Object, Object, ?> callback): EventContainer<?>
```

Runs script source in the specified language, optionally using a file path as its source file and calling back on completion.  
The file path is resolved relative to this script's folder; `null` means no file path is supplied.

**Parameters:**
- `language`: script language
- `script`: script source
- `file`: optional path relative to this script's folder
- `callback`: completion callback, or `null`

**Returns:** the container for the running script

**Since:** 1.6.0

### runScript {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_runScript-String-String-String-BaseEvent-MethodWrapper-}

```js
runScript(String language, String script, String file, BaseEvent event, MethodWrapper<Throwable, Object, Object, ?> callback): EventContainer<?>
```

Runs script source in the specified language with an optional file path, event, and completion callback.  
The file path is resolved relative to this script's folder; `null` omits it. The event is supplied to the script.

**Parameters:**
- `language`: script language
- `script`: script source
- `file`: optional path relative to this script's folder
- `event`: event supplied to the script, or `null`
- `callback`: completion callback, or `null`

**Returns:** the container for the running script

**Since:** 1.7.0

### stopScript {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_stopScript-}

```js
stopScript(): void
```

Stops this script run and removes the event listeners it registered. Other runs and the
trigger that started this run are not stopped. Bound event locks are released and bound
threads are interrupted. Close sockets, screens, and other resources explicitly before
stopping; arbitrary resources are not automatically cleaned up.  

For a running service, its stop callbacks and configured resource cleanup also run. If
called from a service stop callback, that callback finishes as shutdown is already underway.  
Everywhere else the call does not return to the script: it throws
BaseScriptContext.ScriptContextClosedException, whether this call or another thread
started the shutdown, so a statement after `stopScript()` cannot run.

### waitForEvent {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_waitForEvent-String-}

```js
waitForEvent(String event): FJsMacros.EventAndContext<?>
```

Waits for the next event of the given name.

**Parameters:**
- `event`: registered event name

**Returns:** the event and its context. This form requests no explicit join, but cancellable
events still join. Release the returned context's lock promptly after processing a held event.

**Since:** 1.5.0

### waitForEvent {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_waitForEvent-String-boolean-}

```js
waitForEvent(String event, boolean join): FJsMacros.EventAndContext<?>
```

Waits for the next event, optionally requesting a join when the event supports it.

**Parameters:**
- `event`: registered event name
- `join`: whether to request joining a joinable event; cancellable events join regardless

**Returns:** the event and its context; release the context lock promptly if the event is held

**Since:** 1.9.0

### waitForEvent {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_waitForEvent-String-MethodWrapper-}

```js
waitForEvent(String event, MethodWrapper<BaseEvent, Object, Boolean, ?> filter): FJsMacros.EventAndContext<?>
```

Waits until an event arrives for which the optional filter returns true. The listener is
registered before waiting, and any currently bound event lock is released before blocking.  
There is no timeout; a filter exception ends the wait with a [RuntimeException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/RuntimeException.html).

**Parameters:**
- `event`: registered event name
- `filter`: accepts an event, or `null` to accept the first event

**Returns:** the event and its context. This form requests no explicit join, but cancellable
events still join. Release the returned context's lock promptly after processing a held event.

**Since:** 1.5.0

### waitForEvent {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_waitForEvent-String-boolean-MethodWrapper-}

```js
waitForEvent(String event, boolean join, MethodWrapper<BaseEvent, Object, Boolean, ?> filter): FJsMacros.EventAndContext<?>
```

**Parameters:**
- `event`: registered event name
- `join`: whether to request joining a joinable event; cancellable events join regardless
- `filter`: accepts an event, or `null` to accept the first event

**Returns:** the event and its context; release the context lock promptly if the event is held

**Since:** 1.9.0

### waitForEvent {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_waitForEvent-String-MethodWrapper-MethodWrapper-}

```js
waitForEvent(String event, MethodWrapper<BaseEvent, Object, Boolean, ?> filter, MethodWrapper<Object, Object, Object, ?> runBeforeWaiting): FJsMacros.EventAndContext<?>
```

Waits until an event arrives for which the optional filter returns true. Registers its listener
before running `runBeforeWaiting`, then releases any currently bound event lock before waiting.

**Parameters:**
- `event`: registered event name
- `filter`: accepts an event, or `null` to accept the first event
- `runBeforeWaiting`: callback run after listener registration and before waiting

**Returns:** the event and its context. This form requests no explicit join, but cancellable
events still join. Release the returned context's lock promptly after processing a held event.

**Since:** 1.5.0

### waitForEvent {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_waitForEvent-String-boolean-MethodWrapper-MethodWrapper-}

```js
waitForEvent(String event, boolean join, MethodWrapper<BaseEvent, Object, Boolean, ?> filter, MethodWrapper<Object, Object, Object, ?> runBeforeWaiting): FJsMacros.EventAndContext<?>
```

Waits until an event passes the optional filter. The listener is registered before
`runBeforeWaiting` runs; any currently bound event lock is released before waiting.  
There is no timeout, and filter exceptions are wrapped in a [RuntimeException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/RuntimeException.html).  
Cancellable events join regardless of `join`; other events join only when requested
and joinable. Release the returned context's lock promptly when the event is held.

**Parameters:**
- `event`: registered event name
- `join`: whether to request joining a joinable event; cancellable events join regardless
- `filter`: accepts an event, or `null` to accept the first event
- `runBeforeWaiting`: callback run after listener registration and before waiting

**Returns:** the event and its context

**Since:** 1.9.0

### wrapScriptRun {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_wrapScriptRun-String-}

```js
wrapScriptRun(String file): MethodWrapper<T, U, R, ?>
```

Creates a callback that runs the script file for each invocation, passing the triggering event to it.  
The file path is resolved from the process working directory.

**Parameters:**
- `file`: script file path

**Type Parameters:**
- `T`: callback input type
- `U`: callback context type
- `R`: callback result type

**Returns:** the wrapped script callback

**Since:** 1.7.0

### wrapScriptRun {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_wrapScriptRun-String-String-}

```js
wrapScriptRun(String language, String script): MethodWrapper<T, U, R, ?>
```

Creates a callback that runs the script source for each invocation, passing the triggering event to it.

**Parameters:**
- `language`: script language
- `script`: script source

**Type Parameters:**
- `T`: callback input type
- `U`: callback context type
- `R`: callback result type

**Returns:** the wrapped script callback

**Since:** 1.7.0

### wrapScriptRun {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_wrapScriptRun-String-String-String-}

```js
wrapScriptRun(String language, String script, String file): MethodWrapper<T, U, R, ?>
```

Creates a callback that runs the script source for each invocation, passing the triggering event to it.  
The optional file path is resolved relative to this script's folder.

**Parameters:**
- `language`: script language
- `script`: script source
- `file`: optional path relative to this script's folder

**Type Parameters:**
- `T`: callback input type
- `U`: callback context type
- `R`: callback result type

**Returns:** the wrapped script callback

**Since:** 1.7.0

### wrapScriptRunAsync {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_wrapScriptRunAsync-String-}

```js
wrapScriptRunAsync(String file): MethodWrapper<T, U, R, ?>
```

Creates an asynchronous callback that runs the script file for each invocation, passing the triggering event to it.  
The file path is resolved from the process working directory.

**Parameters:**
- `file`: script file path

**Type Parameters:**
- `T`: callback input type
- `U`: callback context type
- `R`: callback result type

**Returns:** the wrapped asynchronous script callback

**Since:** 1.7.0

### wrapScriptRunAsync {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_wrapScriptRunAsync-String-String-}

```js
wrapScriptRunAsync(String language, String script): MethodWrapper<T, U, R, ?>
```

Creates an asynchronous callback that runs the script source for each invocation, passing the triggering event to it.

**Parameters:**
- `language`: script language
- `script`: script source

**Type Parameters:**
- `T`: callback input type
- `U`: callback context type
- `R`: callback result type

**Returns:** the wrapped asynchronous script callback

**Since:** 1.7.0

### wrapScriptRunAsync {#com.jsmacrosce.jsmacros.core.library.impl.FJsMacros_wrapScriptRunAsync-String-String-String-}

```js
wrapScriptRunAsync(String language, String script, String file): MethodWrapper<T, U, R, ?>
```

Creates an asynchronous callback that runs the script source for each invocation, passing the triggering event to it.  
The optional file path is resolved relative to this script's folder.

**Parameters:**
- `language`: script language
- `script`: script source
- `file`: optional path relative to this script's folder

**Type Parameters:**
- `T`: callback input type
- `U`: callback context type
- `R`: callback result type

**Returns:** the wrapped asynchronous script callback

**Since:** 1.7.0
