experiments(dui3): minor changes
This commit is contained in:
@@ -2,30 +2,23 @@
|
||||
|
||||
import { BaseBridge } from '~~/lib/bridge/base'
|
||||
|
||||
export interface Event<T> {
|
||||
on: <E extends keyof T>(event: E, callback: T[E]) => void
|
||||
showDevTools: () => Promise<void>
|
||||
}
|
||||
|
||||
export const IBasicConnectorBindingKey = 'baseBinding'
|
||||
|
||||
// Needs to be agreed between Frontend and Core
|
||||
export interface IBaseBinding {
|
||||
export interface IBasicConnectorBinding
|
||||
extends Event<IBasicConnectorBindingHostEvents> {
|
||||
getAccounts: () => Promise<Account[]>
|
||||
getSourceApplicationName: () => Promise<string>
|
||||
getSourceApplicationVersion: () => Promise<string>
|
||||
getDocumentInfo: () => Promise<DocumentInfo>
|
||||
|
||||
/**
|
||||
* Subscribe to messages from the host application.
|
||||
* @param event
|
||||
* @param callback
|
||||
*/
|
||||
on: <E extends keyof IBaseBindingHostEvents>(
|
||||
event: E,
|
||||
callback: IBaseBindingHostEvents[E]
|
||||
) => void
|
||||
/**
|
||||
* Note: this method does not need to be implemented in the .NET host application base bindings,
|
||||
* it is served by the DUI3 bridge.
|
||||
*/
|
||||
showDevTools: () => Promise<void>
|
||||
}
|
||||
|
||||
export interface IBaseBindingHostEvents {
|
||||
export interface IBasicConnectorBindingHostEvents {
|
||||
displayToastNotification: (args: ToastInfo) => void
|
||||
documentChanged: () => void
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { GenericBridge } from '~/lib/bridge/generic'
|
||||
import { IRawBridge } from '~/lib/bridge/definitions'
|
||||
|
||||
import { GenericBridge } from '~/lib/bridge/generic'
|
||||
import { SketchupBridge } from '~/lib/bridge/sketchup'
|
||||
|
||||
import {
|
||||
IBaseBinding,
|
||||
IBasicConnectorBinding,
|
||||
IBasicConnectorBindingKey,
|
||||
MockedBaseBinding
|
||||
} from '~/lib/bindings/definitions/baseBindings'
|
||||
import { SketchupBridge } from '~/lib/bridge/sketchup'
|
||||
|
||||
import {
|
||||
ITestBinding,
|
||||
ITestBindingKey,
|
||||
@@ -30,11 +33,12 @@ export default defineNuxtPlugin(async () => {
|
||||
(await tryHoistBinding<ITestBinding>(ITestBindingKey)) || new MockedTestBinding()
|
||||
|
||||
// Tries to register some non-existant bindings.
|
||||
const nonExistantBindings = await tryHoistBinding<IBaseBinding>('nonExistantBindings')
|
||||
const nonExistantBindings = await tryHoistBinding('nonExistantBindings')
|
||||
|
||||
// Registers a set of default bindings.
|
||||
const baseBinding =
|
||||
(await tryHoistBinding<IBaseBinding>('baseBinding')) || new MockedBaseBinding()
|
||||
(await tryHoistBinding<IBasicConnectorBinding>(IBasicConnectorBindingKey)) ||
|
||||
new MockedBaseBinding()
|
||||
|
||||
const showDevTools = () => {
|
||||
baseBinding.showDevTools()
|
||||
|
||||
Reference in New Issue
Block a user