Skip to content

Commit 21caedd

Browse files
committed
Remove unwanted indentation changes in legacy code
1 parent 42617e4 commit 21caedd

File tree

1 file changed

+137
-137
lines changed

1 file changed

+137
-137
lines changed

src/JSInterop/Microsoft.JSInterop.JS/src/src/Microsoft.JSInterop.ts

Lines changed: 137 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,20 @@ export module DotNet {
138138
jsonRevivers.push(reviver);
139139
}
140140

141-
/**
142-
* Invokes the specified .NET public method synchronously. Not all hosting scenarios support
143-
* synchronous invocation, so if possible use invokeMethodAsync instead.
144-
*
145-
* @deprecated Use DotNetObject to invoke instance methods instead.
146-
* @param assemblyName The short name (without key/version or .dll extension) of the .NET assembly containing the method.
147-
* @param methodIdentifier The identifier of the method to invoke. The method must have a [JSInvokable] attribute specifying this identifier.
148-
* @param args Arguments to pass to the method, each of which must be JSON-serializable.
149-
* @returns The result of the operation.
150-
*/
151-
export function invokeMethod<T>(assemblyName: string, methodIdentifier: string, ...args: any[]): T | null {
152-
const dispatcher = getDefaultCallDispatcher();
153-
return dispatcher.invokeDotNetStaticMethod<T>(assemblyName, methodIdentifier, ...args);
154-
}
141+
/**
142+
* Invokes the specified .NET public method synchronously. Not all hosting scenarios support
143+
* synchronous invocation, so if possible use invokeMethodAsync instead.
144+
*
145+
* @deprecated Use DotNetObject to invoke instance methods instead.
146+
* @param assemblyName The short name (without key/version or .dll extension) of the .NET assembly containing the method.
147+
* @param methodIdentifier The identifier of the method to invoke. The method must have a [JSInvokable] attribute specifying this identifier.
148+
* @param args Arguments to pass to the method, each of which must be JSON-serializable.
149+
* @returns The result of the operation.
150+
*/
151+
export function invokeMethod<T>(assemblyName: string, methodIdentifier: string, ...args: any[]): T | null {
152+
const dispatcher = getDefaultCallDispatcher();
153+
return dispatcher.invokeDotNetStaticMethod<T>(assemblyName, methodIdentifier, ...args);
154+
}
155155

156156
/**
157157
* Invokes the specified .NET public method asynchronously.
@@ -271,29 +271,29 @@ export function invokeMethod<T>(assemblyName: string, methodIdentifier: string,
271271
}
272272

273273
interface PendingAsyncCall<T> {
274-
resolve: (value?: T | PromiseLike<T>) => void;
275-
reject: (reason?: any) => void;
274+
resolve: (value?: T | PromiseLike<T>) => void;
275+
reject: (reason?: any) => void;
276276
}
277277

278278
/**
279279
* Represents the type of result expected from a JS interop call.
280280
*/
281281
// eslint-disable-next-line no-shadow
282282
export enum JSCallResultType {
283-
Default = 0,
284-
JSObjectReference = 1,
285-
JSStreamReference = 2,
286-
JSVoidResult = 3,
283+
Default = 0,
284+
JSObjectReference = 1,
285+
JSStreamReference = 2,
286+
JSVoidResult = 3,
287287
}
288288

289289
/**
290290
* Represents the type of operation that should be performed in JS.
291291
*/
292292
export enum JSCallType {
293-
FunctionCall = 1,
294-
NewCall = 2,
295-
GetValue = 3,
296-
SetValue = 4
293+
FunctionCall = 1,
294+
NewCall = 2,
295+
GetValue = 3,
296+
SetValue = 4
297297
}
298298

299299
/**
@@ -317,106 +317,106 @@ export function invokeMethod<T>(assemblyName: string, methodIdentifier: string,
317317
* Represents the ability to dispatch calls from JavaScript to a .NET runtime.
318318
*/
319319
export interface DotNetCallDispatcher {
320-
/**
321-
* Optional. If implemented, invoked by the runtime to perform a synchronous call to a .NET method.
322-
*
323-
* @param assemblyName The short name (without key/version or .dll extension) of the .NET assembly holding the method to invoke. The value may be null when invoking instance methods.
324-
* @param methodIdentifier The identifier of the method to invoke. The method must have a [JSInvokable] attribute specifying this identifier.
325-
* @param dotNetObjectId If given, the call will be to an instance method on the specified DotNetObject. Pass null or undefined to call static methods.
326-
* @param argsJson JSON representation of arguments to pass to the method.
327-
* @returns JSON representation of the result of the invocation.
328-
*/
329-
invokeDotNetFromJS?(assemblyName: string | null, methodIdentifier: string, dotNetObjectId: number | null, argsJson: string): string | null;
330-
331-
/**
332-
* Invoked by the runtime to begin an asynchronous call to a .NET method.
333-
*
334-
* @param callId A value identifying the asynchronous operation. This value should be passed back in a later call from .NET to JS.
335-
* @param assemblyName The short name (without key/version or .dll extension) of the .NET assembly holding the method to invoke. The value may be null when invoking instance methods.
336-
* @param methodIdentifier The identifier of the method to invoke. The method must have a [JSInvokable] attribute specifying this identifier.
337-
* @param dotNetObjectId If given, the call will be to an instance method on the specified DotNetObject. Pass null to call static methods.
338-
* @param argsJson JSON representation of arguments to pass to the method.
339-
*/
340-
beginInvokeDotNetFromJS(callId: number, assemblyName: string | null, methodIdentifier: string, dotNetObjectId: number | null, argsJson: string): void;
341-
342-
/**
343-
* Invoked by the runtime to complete an asynchronous JavaScript function call started from .NET
344-
*
345-
* @param callId A value identifying the asynchronous operation.
346-
* @param succeded Whether the operation succeeded or not.
347-
* @param resultOrError The serialized result or the serialized error from the async operation.
348-
*/
349-
endInvokeJSFromDotNet(callId: number, succeeded: boolean, resultOrError: any): void;
350-
351-
/**
352-
* Invoked by the runtime to transfer a byte array from JS to .NET.
353-
* @param id The identifier for the byte array used during revival.
354-
* @param data The byte array being transferred for eventual revival.
355-
*/
356-
sendByteArray(id: number, data: Uint8Array): void;
320+
/**
321+
* Optional. If implemented, invoked by the runtime to perform a synchronous call to a .NET method.
322+
*
323+
* @param assemblyName The short name (without key/version or .dll extension) of the .NET assembly holding the method to invoke. The value may be null when invoking instance methods.
324+
* @param methodIdentifier The identifier of the method to invoke. The method must have a [JSInvokable] attribute specifying this identifier.
325+
* @param dotNetObjectId If given, the call will be to an instance method on the specified DotNetObject. Pass null or undefined to call static methods.
326+
* @param argsJson JSON representation of arguments to pass to the method.
327+
* @returns JSON representation of the result of the invocation.
328+
*/
329+
invokeDotNetFromJS?(assemblyName: string | null, methodIdentifier: string, dotNetObjectId: number | null, argsJson: string): string | null;
330+
331+
/**
332+
* Invoked by the runtime to begin an asynchronous call to a .NET method.
333+
*
334+
* @param callId A value identifying the asynchronous operation. This value should be passed back in a later call from .NET to JS.
335+
* @param assemblyName The short name (without key/version or .dll extension) of the .NET assembly holding the method to invoke. The value may be null when invoking instance methods.
336+
* @param methodIdentifier The identifier of the method to invoke. The method must have a [JSInvokable] attribute specifying this identifier.
337+
* @param dotNetObjectId If given, the call will be to an instance method on the specified DotNetObject. Pass null to call static methods.
338+
* @param argsJson JSON representation of arguments to pass to the method.
339+
*/
340+
beginInvokeDotNetFromJS(callId: number, assemblyName: string | null, methodIdentifier: string, dotNetObjectId: number | null, argsJson: string): void;
341+
342+
/**
343+
* Invoked by the runtime to complete an asynchronous JavaScript function call started from .NET
344+
*
345+
* @param callId A value identifying the asynchronous operation.
346+
* @param succeded Whether the operation succeeded or not.
347+
* @param resultOrError The serialized result or the serialized error from the async operation.
348+
*/
349+
endInvokeJSFromDotNet(callId: number, succeeded: boolean, resultOrError: any): void;
350+
351+
/**
352+
* Invoked by the runtime to transfer a byte array from JS to .NET.
353+
* @param id The identifier for the byte array used during revival.
354+
* @param data The byte array being transferred for eventual revival.
355+
*/
356+
sendByteArray(id: number, data: Uint8Array): void;
357357
}
358358

359359
/**
360360
* Represents the ability to facilitate function call dispatching between JavaScript and a .NET runtime.
361361
*/
362362
export interface ICallDispatcher {
363-
/**
364-
* Invokes the specified synchronous JavaScript function.
365-
*
366-
* @param invocationInfo Configuration of the interop call.
367-
*/
368-
invokeJSFromDotNet(invocationInfo: JSInvocationInfo): string | null;
369-
370-
/**
371-
* Invokes the specified synchronous or asynchronous JavaScript function.
372-
*
373-
* @param invocationInfo Configuration of the interop call.
374-
*/
375-
beginInvokeJSFromDotNet(invocationInfo: JSInvocationInfo): Promise<any> | null;
376-
377-
/**
378-
* Receives notification that an async call from JS to .NET has completed.
379-
* @param asyncCallId The identifier supplied in an earlier call to beginInvokeDotNetFromJS.
380-
* @param success A flag to indicate whether the operation completed successfully.
381-
* @param resultJsonOrExceptionMessage Either the operation result as JSON, or an error message.
382-
*/
383-
endInvokeDotNetFromJS(asyncCallId: string, success: boolean, resultJsonOrExceptionMessage: string): void;
384-
385-
/**
386-
* Invokes the specified .NET public static method synchronously. Not all hosting scenarios support
387-
* synchronous invocation, so if possible use invokeMethodAsync instead.
388-
*
389-
* @param assemblyName The short name (without key/version or .dll extension) of the .NET assembly containing the method.
390-
* @param methodIdentifier The identifier of the method to invoke. The method must have a [JSInvokable] attribute specifying this identifier.
391-
* @param args Arguments to pass to the method, each of which must be JSON-serializable.
392-
* @returns The result of the operation.
393-
*/
394-
invokeDotNetStaticMethod<T>(assemblyName: string, methodIdentifier: string, ...args: any[]): | null;
395-
396-
/**
397-
* Invokes the specified .NET public static method asynchronously.
398-
*
399-
* @param assemblyName The short name (without key/version or .dll extension) of the .NET assembly containing the method.
400-
* @param methodIdentifier The identifier of the method to invoke. The method must have a [JSInvokable] attribute specifying this identifier.
401-
* @param args Arguments to pass to the method, each of which must be JSON-serializable.
402-
* @returns A promise representing the result of the operation.
403-
*/
404-
invokeDotNetStaticMethodAsync<T>(assemblyName: string, methodIdentifier: string, ...args: any[]): Promise<T>;
405-
406-
/**
407-
* Receives notification that a byte array is being transferred from .NET to JS.
408-
* @param id The identifier for the byte array used during revival.
409-
* @param data The byte array being transferred for eventual revival.
410-
*/
411-
receiveByteArray(id: number, data: Uint8Array): void
412-
413-
/**
414-
* Supplies a stream of data being sent from .NET.
415-
*
416-
* @param streamId The identifier previously passed to JSRuntime's BeginTransmittingStream in .NET code.
417-
* @param stream The stream data.
418-
*/
419-
supplyDotNetStream(streamId: number, stream: ReadableStream): void;
363+
/**
364+
* Invokes the specified synchronous JavaScript function.
365+
*
366+
* @param invocationInfo Configuration of the interop call.
367+
*/
368+
invokeJSFromDotNet(invocationInfo: JSInvocationInfo): string | null;
369+
370+
/**
371+
* Invokes the specified synchronous or asynchronous JavaScript function.
372+
*
373+
* @param invocationInfo Configuration of the interop call.
374+
*/
375+
beginInvokeJSFromDotNet(invocationInfo: JSInvocationInfo): Promise<any> | null;
376+
377+
/**
378+
* Receives notification that an async call from JS to .NET has completed.
379+
* @param asyncCallId The identifier supplied in an earlier call to beginInvokeDotNetFromJS.
380+
* @param success A flag to indicate whether the operation completed successfully.
381+
* @param resultJsonOrExceptionMessage Either the operation result as JSON, or an error message.
382+
*/
383+
endInvokeDotNetFromJS(asyncCallId: string, success: boolean, resultJsonOrExceptionMessage: string): void;
384+
385+
/**
386+
* Invokes the specified .NET public static method synchronously. Not all hosting scenarios support
387+
* synchronous invocation, so if possible use invokeMethodAsync instead.
388+
*
389+
* @param assemblyName The short name (without key/version or .dll extension) of the .NET assembly containing the method.
390+
* @param methodIdentifier The identifier of the method to invoke. The method must have a [JSInvokable] attribute specifying this identifier.
391+
* @param args Arguments to pass to the method, each of which must be JSON-serializable.
392+
* @returns The result of the operation.
393+
*/
394+
invokeDotNetStaticMethod<T>(assemblyName: string, methodIdentifier: string, ...args: any[]): | null;
395+
396+
/**
397+
* Invokes the specified .NET public static method asynchronously.
398+
*
399+
* @param assemblyName The short name (without key/version or .dll extension) of the .NET assembly containing the method.
400+
* @param methodIdentifier The identifier of the method to invoke. The method must have a [JSInvokable] attribute specifying this identifier.
401+
* @param args Arguments to pass to the method, each of which must be JSON-serializable.
402+
* @returns A promise representing the result of the operation.
403+
*/
404+
invokeDotNetStaticMethodAsync<T>(assemblyName: string, methodIdentifier: string, ...args: any[]): Promise<T>;
405+
406+
/**
407+
* Receives notification that a byte array is being transferred from .NET to JS.
408+
* @param id The identifier for the byte array used during revival.
409+
* @param data The byte array being transferred for eventual revival.
410+
*/
411+
receiveByteArray(id: number, data: Uint8Array): void
412+
413+
/**
414+
* Supplies a stream of data being sent from .NET.
415+
*
416+
* @param streamId The identifier previously passed to JSRuntime's BeginTransmittingStream in .NET code.
417+
* @param stream The stream data.
418+
*/
419+
supplyDotNetStream(streamId: number, stream: ReadableStream): void;
420420
}
421421

422422
class CallDispatcher implements ICallDispatcher {
@@ -606,23 +606,23 @@ export function invokeMethod<T>(assemblyName: string, methodIdentifier: string,
606606
this.completePendingCall(parseInt(asyncCallId, 10), success, resultOrError);
607607
}
608608

609-
invokeDotNetStaticMethod<T>(assemblyName: string, methodIdentifier: string, ...args: any[]): T | null {
610-
return this.invokeDotNetMethod<T>(assemblyName, methodIdentifier, null, args);
611-
}
609+
invokeDotNetStaticMethod<T>(assemblyName: string, methodIdentifier: string, ...args: any[]): T | null {
610+
return this.invokeDotNetMethod<T>(assemblyName, methodIdentifier, null, args);
611+
}
612612

613613
invokeDotNetStaticMethodAsync<T>(assemblyName: string, methodIdentifier: string, ...args: any[]): Promise<T> {
614614
return this.invokeDotNetMethodAsync<T>(assemblyName, methodIdentifier, null, args);
615615
}
616616

617-
invokeDotNetMethod<T>(assemblyName: string | null, methodIdentifier: string, dotNetObjectId: number | null, args: any[] | null): T | null {
617+
invokeDotNetMethod<T>(assemblyName: string | null, methodIdentifier: string, dotNetObjectId: number | null, args: any[] | null): T | null {
618618
if (this._dotNetCallDispatcher.invokeDotNetFromJS) {
619619
const argsJson = stringifyArgs(this, args);
620620
const resultJson = this._dotNetCallDispatcher.invokeDotNetFromJS(assemblyName, methodIdentifier, dotNetObjectId, argsJson);
621621
return resultJson ? parseJsonWithRevivers(this, resultJson) : null;
622622
}
623623

624-
throw new Error("The current dispatcher does not support synchronous calls from JS to .NET. Use invokeDotNetMethodAsync instead.");
625-
}
624+
throw new Error("The current dispatcher does not support synchronous calls from JS to .NET. Use invokeDotNetMethodAsync instead.");
625+
}
626626

627627
invokeDotNetMethodAsync<T>(assemblyName: string | null, methodIdentifier: string, dotNetObjectId: number | null, args: any[] | null): Promise<T> {
628628
if (assemblyName && dotNetObjectId) {
@@ -750,9 +750,9 @@ export function invokeMethod<T>(assemblyName: string, methodIdentifier: string,
750750
constructor(private readonly _id: number, private readonly _callDispatcher: CallDispatcher) {
751751
}
752752

753-
public invokeMethod<T>(methodIdentifier: string, ...args: any[]): T | null {
754-
return this._callDispatcher.invokeDotNetMethod<T>(null, methodIdentifier, this._id, args);
755-
}
753+
public invokeMethod<T>(methodIdentifier: string, ...args: any[]): T | null {
754+
return this._callDispatcher.invokeDotNetMethod<T>(null, methodIdentifier, this._id, args);
755+
}
756756

757757
public invokeMethodAsync<T>(methodIdentifier: string, ...args: any[]): Promise<T> {
758758
return this._callDispatcher.invokeDotNetMethodAsync<T>(null, methodIdentifier, this._id, args);
@@ -837,16 +837,16 @@ export function invokeMethod<T>(assemblyName: string, methodIdentifier: string,
837837

838838
function createJSCallResult(returnValue: any, resultType: JSCallResultType) {
839839
switch (resultType) {
840-
case JSCallResultType.Default:
841-
return returnValue;
842-
case JSCallResultType.JSObjectReference:
843-
return createJSObjectReference(returnValue);
844-
case JSCallResultType.JSStreamReference:
845-
return createJSStreamReference(returnValue);
846-
case JSCallResultType.JSVoidResult:
847-
return null;
848-
default:
849-
throw new Error(`Invalid JS call result type '${resultType}'.`);
840+
case JSCallResultType.Default:
841+
return returnValue;
842+
case JSCallResultType.JSObjectReference:
843+
return createJSObjectReference(returnValue);
844+
case JSCallResultType.JSStreamReference:
845+
return createJSStreamReference(returnValue);
846+
case JSCallResultType.JSVoidResult:
847+
return null;
848+
default:
849+
throw new Error(`Invalid JS call result type '${resultType}'.`);
850850
}
851851
}
852852

0 commit comments

Comments
 (0)