83d8035dc2
* root + server * frontend * frontend-2 * dui3 * dui3 * tailwind theme * ui-components * preview service * viewer * viewer-sandbox * fileimport-service * webhook service * objectloader * shared * ui-components-nuxt * WIP full config * WIP full linter * eslint projectwide util * minor fix * removing redundant ci * clean up test errors * fixed prettier formatting * CI improvements * TSC lint fix * 'buildBatch' needs to be async since some batch types (like Text) require it. Removed a disabled liniting rule from ObjLoader * removed unnecessary void --------- Co-authored-by: AlexandruPopovici <alexandrupopoviciioan@gmail.com>
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
/* eslint-disable @typescript-eslint/require-await */
|
|
|
|
import { BaseBridge } from '~~/lib/bridge/base'
|
|
import type { IBinding } from '~~/lib/bindings/definitions/IBinding'
|
|
|
|
/**
|
|
* The name under which this binding will be registered.
|
|
*/
|
|
export const ITestBindingKey = 'testBinding'
|
|
|
|
/**
|
|
* A test binding interface to ensure compatbility. Ideally all host environments would implement and register it.
|
|
*/
|
|
export interface ITestBinding extends IBinding<ITestBindingEvents> {
|
|
sayHi: (name: string, count: number, sayHelloNotHi: boolean) => Promise<string[]>
|
|
goAway: () => Promise<void>
|
|
getComplexType: () => Promise<ComplexType>
|
|
shouldThrow: () => Promise<void>
|
|
triggerEvent: (eventName: string) => Promise<void>
|
|
}
|
|
|
|
export interface ITestBindingEvents {
|
|
emptyTestEvent: () => void
|
|
testEvent: (args: TestEventArgs) => void
|
|
}
|
|
|
|
export type TestEventArgs = {
|
|
name: string
|
|
isOk: boolean
|
|
count: number
|
|
}
|
|
|
|
export type ComplexType = {
|
|
id: string
|
|
count: number
|
|
}
|
|
|
|
export class MockedTestBinding extends BaseBridge {
|
|
public async sayHi(name: string, count: number, sayHelloNotHi: boolean) {
|
|
return `Hello from mocked bindings. Args: name = ${name}, count = ${count}, sayHelloNotHi = ${sayHelloNotHi.toString()}.`
|
|
}
|
|
|
|
public async goAway() {
|
|
return
|
|
}
|
|
|
|
public async getComplexType() {
|
|
return { id: 'wow', count: 42 }
|
|
}
|
|
|
|
public async shouldThrow() {
|
|
return
|
|
}
|
|
|
|
public async triggerEvent(eventName: string) {
|
|
return eventName
|
|
}
|
|
}
|