ScriptingWorkspace class abstract
A workspace represents a collection of files that are likely related (usually part of a single Rive file).
Constructors
Properties
-
builtinDefinitionKeys
→ List<
String> -
no setter
- builtinDefinitions → String
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isClosing → bool
-
Whether this workspace is closing or has been closed.
When true, no further async work can be scheduled.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
autocomplete(
String scriptName, ScriptPosition position) → Future< AutocompleteResult> -
Get possible autocompletion results at
positionin script with namescriptName. Uses the Luau frontend \u2014 see autocompleteWGSL for WGSL-backed assets. -
autocompleteWGSL(
String scriptName, ScriptPosition position) → Future< AutocompleteResult> -
Get possible autocompletion results at
positionin a WGSL source with namescriptName. Uses the naga-backed WGSL frontend. -
builtinDefinition(
String key) → String -
checkNeedsRecompile(
String scriptId) → Future< bool> - Check if a script needs to be recompiled (source changed since last compile). Returns true if the script has never been compiled or if the source has changed.
-
checkScriptsWithRequires(
) → void -
clearScriptDiffSource(
String scriptId) → void -
Clear the diff source for a module with
scriptId. -
compile(
String scriptName, {bool failOnErrors = false, bool compileDependencies = false, OptimizationLevel optimizationLevel = OptimizationLevel.medium, DebugLevel debugLevel = DebugLevel.medium}) → Future< CompileResult?> -
Retrieves the bytecode for module named
scriptName. -
compileAndSign(
Iterable< String> scriptNames, Uint8List privateKey, {bool failOnErrors = false, OptimizationLevel optimizationLevel = OptimizationLevel.medium, DebugLevel debugLevel = DebugLevel.medium, int shaderOutputFlags = 0}) → Future<CompileAndSignResult?> - Retrieves the bytecode for listed modules and signature.
-
completeInsertion(
String scriptName, ScriptPosition position) → Future< InsertionCompletion> - Get extra text insertion to be auto-completed at the given position.
-
completeWork(
Completer completer, ScriptingWorkspaceResponseResult response) → void -
configureGPUFromRenderTexture(
RenderTexture? renderTexture) → void - Configures GPU contexts on this workspace from a RenderTexture. On web, extracts ore/render context pointers directly from the texture's JS renderer object, avoiding global state. On native (FFI), delegates to initGPUScripting + setOreContext + setRenderContext as before.
-
dispose(
) → void - Dispose of the workspace, any further calls will not work.
-
findInFiles(
Iterable< String> ? inclusionSet, String query, {bool caseSensitive = false, bool matchWholeWord = false, bool regularExpression = false, bool trim = true}) → Future<FindInFilesResult> -
Searches for
queryin files. IfinclusionSetis provided, only those files are searched, otherwise all non-built-in files are searched. -
format(
String scriptName) → Future< FormatResult> -
Formats module named
scriptName. -
formatParseData(
String docId) → Uint8List? - Cached FileFormat parse artifact for a document (produced by the handler's parse), or null when none exists.
-
fullProblemReport(
) → Future< List< ScriptProblemResult> > - Get an error report for all the script files in this workspace.
-
getDefinition(
String scriptName, ScriptPosition position) → Future< DefinitionResult> -
Get definition information at
positionin script with namescriptName. -
getDiffSourceLine(
String scriptId, int line) → Future< String> -
Get a specific line from the diff source for a module with
scriptId. Returns the line content when ready, or empty string if the line doesn't exist or no diff source is available. -
implementedType(
String scriptName) → Future< ImplementedType?> -
Retrieves the implemented type for module named
scriptName. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
problemReport(
String scriptName) → Future< ScriptProblemResult> -
Get an error report for a script file with identified by
scriptName. -
registerCompleter<
T> (int workId) → Future< T> -
removeLibraryImport(
int callerLibraryId, int callerLibraryVersionId, String name) → void -
Remove the import edge for
namefrom the caller scope. -
removeScriptSource(
String scriptId) → void -
requestCompileWasmAs(
{WasmSimd simd = WasmSimd.on, bool forExport = false, bool debugProbes = true, bool fuel = false}) → Future< WasmModuleResult?> -
Bakes every AnimaScript source into one wasm module against the
std tree from setRascStdDir; protocol classes register under their
workspace script id, with the file's
simdso previews match exports. A preview carries line probes, fuel, its shaders and an AOT artifact.forExportships the module alone, withdebugProbesdeciding its probes and throw messages andfuelmetering it so browsers can bound it. Its job, worker and processor modules carry fuel whenever it does. -
requestTranslateToAs(
String scriptId) → Future< AsTranslation?> -
Translates the Luau script
scriptIdto AnimaScript over the rive std library; the source carries a header listing every site the translator could not type or express. -
requestVM(
{int factoryPointer = 0}) → Future< VMResult?> - Request a fresh VM with all scripts compiled and registered in dependency order. Returns a VMResult with the VM pointer and registered module list.
-
responseForWork(
int workId) → ScriptingWorkspaceResponseResult -
rewriteRequires(
String scriptId) → Future< String> -
The statically linked source for
scriptId: every constant require resolved to its registered name. Export flows compile elsewhere without this workspace's import state, so they send this instead of raw source. -
rowHighlight(
String scriptName, int row) → Uint32List -
Get the highlight data for a single row of
scriptName. -
setAnimaScriptSource(
String scriptId, String scriptName, String source, {bool highlight = false}) → Future< HighlightResult> - Sets an AnimaScript source; the AS pool serves its highlight, diagnostics, completion and bake.
-
setAsBakeOptions(
{WasmSimd simd = WasmSimd.on}) → void -
The file's
simd, so AnimaScript diagnostics fold what a bake would before one runs. Push it before the first report and on each change. -
setBundledRascStd(
) → bool - Points AnimaScript at the std tree the native library carries, for a host with no checkout to read. False when the library carries none.
-
setDocumentSource(
String scriptId, String scriptName, String source, {required String formatScriptId, required String formatExtension, bool highlight = false}) → Future< HighlightResult> -
Set a custom format document source. Same as setScriptSource but marks
the script as a document handled by the FileFormat protocol script with
formatScriptId. Highlight, problems, autocomplete, hover, and format requests dispatch to that handler inside the workspace. An emptyformatScriptIdregisters the document with no intelligence. -
setLibraryCanonicalName(
int libraryId, int libraryVersionId, String canonicalName) → void - Canonical mangle prefix for a library version, e.g. draco@3. Compiled requires and exported wire names both derive from it, so the editor pushes one map for both.
-
setLibraryImport(
int callerLibraryId, int callerLibraryVersionId, String name, int targetLibraryId, int targetLibraryVersionId) → void -
One import edge: the caller scope pins
nameto a target library version. Root caller is (0,0). Labels live on edges, solib:requires resolve per caller. -
setLibraryScriptMode(
int libraryId, LibraryScriptMode mode) → void -
How
libraryId's AnimaScript compiles in the next preview bake. -
setOreContext(
int oreContextPointer) → void - Sets the ore::Context pointer on the workspace so that VMs created via requestVM have access to GPU scripting. Call once after GPU init.
-
setRascStdDir(
String dir) → void - rasc's std tree, which AnimaScript diagnostics resolve imports against. Must be set before the first problem report.
-
setRenderContext(
int renderContextPointer) → void - Sets the gpu::RenderContext pointer on the workspace so that VMs created via requestVM can allocate RenderCanvas objects. Call once after GPU init, alongside setOreContext.
-
setScriptDiffSource(
String scriptId, String source) → Future< HighlightResult> -
Set the diff source for a module with
scriptId. We store the diff source on the Script so subsequent calls to setScriptSource can return line level diffs with stored source when requesting highlighting data. -
setScriptScope(
String scriptId, int libraryId, int libraryVersionId) → void -
Scope for
scriptIdwithout a source push. Proxies stamp before their text hydrates, an empty source push would register a dead scoped module. -
setScriptSource(
String scriptId, String scriptName, String source, {bool highlight = false, int libraryId = 0, int libraryVersionId = 0}) → Future< HighlightResult> -
Set the
sourcecode for the script withscriptId.libraryIdandlibraryVersionIdscope it to a library version, zero scope is the host file. -
setSystemGeneratedSource(
String scriptName, String prefix, String source) → Future< HighlightResult> -
setWGSLScriptSource(
String scriptId, String scriptName, String source, {bool highlight = false}) → Future< HighlightResult> - Set a WGSL shader source. Same as setScriptSource but marks the script as WGSL so the workspace uses naga for validation/highlighting/formatting instead of Luau.
-
toString(
) → String -
A string representation of this object.
inherited
-
useRascStd(
String? dir) → bool - A std tree on disk wins, so a std edit lands without a native rebuild; without one, the library's own copy. False when neither is there.
-
workReadyCallback(
int workId) → void
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
initGPUScripting(
) → int - Initialises GPU scripting for the current platform. Call once after the native renderer is set up (i.e. after RiveNative.init completes). Returns the ore::Context pointer address, or 0 on unsupported platforms. Pass the result to setOreContext on every workspace you create.
-
make(
{bool canvasEnabled = false, bool netEnabled = false}) → ScriptingWorkspace -
canvasEnabledtypes the GPU canvas APIs;netEnabledtypes fetch(), context:decodeFile and bindable artboards, which only a runtime built with script networking has (otherwise they stay untyped). -
nativeFontBytes(
) → Uint8List