ClearScript
ClearScript copied to clipboard
Provide a way to access script document information from host methods
Discussed in https://github.com/microsoft/ClearScript/discussions/667
Originally posted by cyraid July 26, 2025 In a C# method, calling from Javascript, is there a way to get Module (Document) information? I have a Javascript Plugin System that works off of a single V8 Engine (so that plugins can import Modules from other plugins).
It would be nice if something like this existed:
public static class SomeClass {
[ScriptMember("someMethod")]
public static void SomeMethod(V8DataOfSomeSort v8Data) {
// v8Data.CurrentDocument.HostData
} // Procedure //
} // Class //
//...
engine.AddHostType(typeof(SomeClass));
// Execute engine Module stuff here, then tie in a "HostData" (the plugin instance) to the Module on the C# side.
In Javascript (let's say were are in a Module):
SomeClass.someMethod();
I have a logging system, and it would be nice having which plugin the debug information is coming from when it outputs to the logging view.