Change to use doc comments (#7596)

This commit is contained in:
Jonathan Tran
2025-06-24 15:56:55 -04:00
committed by GitHub
parent 8d876a806e
commit 0ad619e1d2

View File

@ -30,7 +30,7 @@ export default class RustContext {
private _defaultPlanes: DefaultPlanes | null = null private _defaultPlanes: DefaultPlanes | null = null
private engineCommandManager: EngineCommandManager private engineCommandManager: EngineCommandManager
// Initialize the WASM module /** Initialize the WASM module */
async ensureWasmInit() { async ensureWasmInit() {
try { try {
await initPromise await initPromise
@ -53,7 +53,7 @@ export default class RustContext {
.catch(reportRejection) .catch(reportRejection)
} }
// Create a new context instance /** Create a new context instance */
async create(): Promise<Context> { async create(): Promise<Context> {
this.rustInstance = getModule() this.rustInstance = getModule()
@ -68,7 +68,7 @@ export default class RustContext {
return ctxInstance return ctxInstance
} }
// Execute a program. /** Execute a program. */
async execute( async execute(
node: Node<Program>, node: Node<Program>,
settings: DeepPartial<Configuration>, settings: DeepPartial<Configuration>,
@ -82,7 +82,7 @@ export default class RustContext {
path, path,
JSON.stringify(settings) JSON.stringify(settings)
) )
/* Set the default planes, safe to call after execute. */ // Set the default planes, safe to call after execute.
const outcome = execStateFromRust(result) const outcome = execStateFromRust(result)
this._defaultPlanes = outcome.defaultPlanes this._defaultPlanes = outcome.defaultPlanes
@ -96,7 +96,7 @@ export default class RustContext {
} }
} }
// Execute a program with in mock mode. /** Execute a program with in mock mode. */
async executeMock( async executeMock(
node: Node<Program>, node: Node<Program>,
settings: DeepPartial<Configuration>, settings: DeepPartial<Configuration>,
@ -122,7 +122,7 @@ export default class RustContext {
} }
} }
// Export a scene to a file. /** Export a scene to a file. */
async export( async export(
format: DeepPartial<OutputFormat3d>, format: DeepPartial<OutputFormat3d>,
settings: DeepPartial<Configuration>, settings: DeepPartial<Configuration>,
@ -150,20 +150,22 @@ export default class RustContext {
return this._defaultPlanes return this._defaultPlanes
} }
// Clear/reset the scene and bust the cache. /**
// Do not use this function unless you absolutely need to. In most cases, * Clear/reset the scene and bust the cache.
// we should just fix the cache for whatever bug you are seeing. * Do not use this function unless you absolutely need to. In most cases,
// The only time it makes sense to run this is if the engine disconnects and * we should just fix the cache for whatever bug you are seeing.
// reconnects. The rust side has no idea that happened and will think the * The only time it makes sense to run this is if the engine disconnects and
// cache is still valid. * reconnects. The rust side has no idea that happened and will think the
// Caching on the rust side accounts for changes to files outside of the * cache is still valid.
// scope of the current file the user is on. It collects all the dependencies * Caching on the rust side accounts for changes to files outside of the
// and checks if any of them have changed. If they have, it will bust the * scope of the current file the user is on. It collects all the dependencies
// cache and recompile the scene. * and checks if any of them have changed. If they have, it will bust the
// The typescript side should never raw dog clear the scene since that would * cache and recompile the scene.
// fuck with the cache as well. So if you _really_ want to just clear the scene * The typescript side should never raw dog clear the scene since that would
// AND NOT re-execute, you can use this for that. But in 99.999999% of cases just * fuck with the cache as well. So if you _really_ want to just clear the scene
// re-execute. * AND NOT re-execute, you can use this for that. But in 99.999999% of cases just
* re-execute.
*/
async clearSceneAndBustCache( async clearSceneAndBustCache(
settings: DeepPartial<Configuration>, settings: DeepPartial<Configuration>,
path?: string path?: string
@ -199,7 +201,7 @@ export default class RustContext {
return this.defaultPlanes[key] return this.defaultPlanes[key]
} }
// Send a response back to the rust side, that we got back from the engine. /** Send a response back to the rust side, that we got back from the engine. */
async sendResponse( async sendResponse(
response: Models['WebSocketResponse_type'] response: Models['WebSocketResponse_type']
): Promise<void> { ): Promise<void> {
@ -214,7 +216,7 @@ export default class RustContext {
} }
} }
// Helper to check if context instance exists /** Helper to check if context instance exists */
private async _checkInstance(): Promise<Context> { private async _checkInstance(): Promise<Context> {
if (!this.ctxInstance) { if (!this.ctxInstance) {
// Create the context instance. // Create the context instance.
@ -224,7 +226,7 @@ export default class RustContext {
return this.ctxInstance return this.ctxInstance
} }
// Clean up resources /** Clean up resources */
destroy() { destroy() {
if (this.ctxInstance) { if (this.ctxInstance) {
// In a real implementation, you might need to manually free resources // In a real implementation, you might need to manually free resources