experiments(dui3): added test bindings

This commit is contained in:
Dimitrie Stefanescu
2023-07-14 11:28:17 +01:00
parent 520a65c73c
commit 77aad568bc
3 changed files with 33 additions and 42 deletions
@@ -1,8 +1,3 @@
// Needs to be agreed between Frontend and Rhino
export interface IRhinoRandomBinding {
makeGreeting: (name: string) => Promise<string>
}
// Needs to be agreed between Frontend and Core
export interface IBaseBinding {
getAccounts: () => Promise<Account[]>
@@ -10,10 +5,6 @@ export interface IBaseBinding {
getSourceApplicationVersion: () => Promise<string>
getDocumentInfo: () => Promise<DocumentInfo>
// TODO:
getFileState: () => Promise<FileState>
updateFileState: (state: FileState) => Promise<void>
/**
* Subscribe to messages from the host application.
* @param event
@@ -48,33 +39,15 @@ export type Account = {
}
}
export type FileState = {
models: ModelCard[]
}
export type ModelCard = {
serverUrl: string // we need to select the correct account
modelId: string // we need to assemble the gql query properly
projectId: string
type: 'sender' | 'receiver'
status?: 'idle' | 'inprogress' | 'error' | 'warning' | 'disabled' | 'expired' //???
// settings: Record<string,unknown>???
// report: Record<string,unknown>???
// progress: Record<string, unknown> // ??? send status, receive status
}
export type DocumentInfo = {
location: string
name: string
id: string
}
// NOTE: just a reminder for now
export type ToastInfo = {
text: string
details?: string
type: 'info' | 'error' | 'warning'
}
export type SelectionChangedInfo = {
objectIds: string[]
humanReadableSummary?: string
}
@@ -0,0 +1,25 @@
export interface ITestBinding {
sayHi: (name: string, count: number, sayHelloNotHi: boolean) => Promise<string[]>
goAway: () => Promise<void>
getComplexType: () => Promise<ComplexType>
on: <E extends keyof ITestBindingEvents>(
event: E,
callback: ITestBindingEvents[E]
) => 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
}
+7 -14
View File
@@ -1,11 +1,9 @@
import { GenericBridge } from '~/lib/bridge/generic'
import { IRawBridge } from '~/lib/bridge/definitions'
import {
IBaseBinding,
IRhinoRandomBinding
} from '~/lib/bindings/definitions/baseBindings'
import { IBaseBinding } from '~/lib/bindings/definitions/baseBindings'
import { SketchupBridge } from '~/lib/bridge/sketchup'
import { ITestBinding } from '~/lib/bindings/definitions/testBindings'
// Makes TS happy
declare let globalThis: Record<string, unknown> & {
@@ -20,21 +18,16 @@ declare let globalThis: Record<string, unknown> & {
* strip or customize functionality from the ui itself.
*/
export default defineNuxtPlugin(async () => {
const baseBinding = await tryHoistBinding<IBaseBinding>('baseBinding')
const testBindings = await tryHoistBinding<ITestBinding>('testBindings')
const nonExistantBindings = await tryHoistBinding<IBaseBinding>('nonExistantBindings')
const rhinoRandomBinding = await tryHoistBinding<IRhinoRandomBinding>(
'rhinoRandomBinding'
)
const sketchupRandomBinding = await tryHoistBinding<unknown>('sketchupRandomBinding')
const baseBinding = await tryHoistBinding<IBaseBinding>('baseBinding')
return {
provide: {
baseBinding,
rhinoRandomBinding,
sketchupRandomBinding
testBindings,
nonExistantBindings,
baseBinding
}
}
})