============================================================
sigma/scriptable
A small registry + factory for creating multiple Rhino {@code Scriptable} "scopes"
(plain JavaScript objects used as execution environments / per-device workers).
Design goals
- Create multiple Scriptables that share a common parent scope (so they inherit platform APIs).
- Each Scriptable has a stable, human-readable name (for debugging and lookup).
- Maintain a shared registry under {@code _shared} so all Scriptables can be found consistently.
- Keep #list() lightweight (returns names only) to avoid REPL deep-inspection slowness.
Public API
- String) - Create a new Scriptable scope.
- String) - Clone an existing Scriptable into a new Scriptable.
- #list() - List registered Scriptable names.
- #find(String) - Find a Scriptable by name.
- #bindCurrent(String) - Register the current/root Scriptable under a name.
- #remove(String) - Unregister a Scriptable name (does not "destroy" the object).
- #getCurrentScriptable() - Exposed as {@code exports.getCurrent}.
Important behavior notes
- Unregister vs delete: #remove(String) only removes references from this registry. If a Scriptable is still referenced by variables elsewhere, it remains usable (and alive).
- Default naming: if name is omitted, the Scriptable is named {@code "Unknown#N"}.
- Scriptable naming: the created/cloned Scriptable gets a {@code __name} property and a {@code toString()} that returns the name.
Members
(static) bindCurrent
Register current/root Scriptable. Exported as {@code scriptable.bindCurrent(name)}.
(static) clone
Clone a Scriptable. Exported as {@code scriptable.clone(...)}.
(static) create
Create a new Scriptable. Exported as {@code scriptable.create(...)}.
(static) find
Find by name. Exported as {@code scriptable.find(name)}.
(static) getCurrent
Returns the current/root Scriptable from the host environment.
Exported as {@code scriptable.getCurrent()}.
(static) list
List Scriptable names. Exported as {@code scriptable.list()}.
(static) remove
Unregister by name. Exported as {@code scriptable.remove(name)}.