-
-
{{ clientId }}:
- {{ res.result.value?.serverInfo.version || '' }}
+
+
+ for {{ appName }}
+
+
+
+
+
+ Hello world! You have
+ {{ accounts.length }} accounts.
+
+
+
+ {{ acc.accountInfo.userInfo.email }} @
+ {{ acc.accountInfo.serverInfo.url }}
+ {{ acc.accountInfo.serverInfo.name }}
+
+
+
+
+ {{ clientId }}:
+ {{ res.result.value?.serverInfo.version || res.error }}
+
+
+
+ Refresh Accounts
-
-
-
diff --git a/packages/dui3/plugins/00.cefPlugin.ts b/packages/dui3/plugins/00.cefPlugin.ts
new file mode 100644
index 000000000..adf676f38
--- /dev/null
+++ b/packages/dui3/plugins/00.cefPlugin.ts
@@ -0,0 +1,26 @@
+import { ICefSharp, WebUiBindingType, MockedBindings } from '~/types'
+
+declare let CefSharp: ICefSharp
+declare let WebUIBinding: WebUiBindingType
+
+export default defineNuxtPlugin(async () => {
+ let bindings: WebUiBindingType
+
+ try {
+ if (!CefSharp) throw new Error('No global CefSharp object found.')
+ await CefSharp.BindObjectAsync('WebUIBinding')
+ console.info('Bound WebUIBinding object for CefSharp.')
+ bindings = WebUIBinding
+ } catch (e) {
+ console.error('Failed to bind CefSharp, will use mocked bindings.')
+ console.error(e)
+
+ bindings = MockedBindings
+ }
+
+ return {
+ provide: {
+ bindings
+ }
+ }
+})
diff --git a/packages/dui3/plugins/apollo.ts b/packages/dui3/plugins/apollo.ts
index 104300198..ddf4dcd77 100644
--- a/packages/dui3/plugins/apollo.ts
+++ b/packages/dui3/plugins/apollo.ts
@@ -1,34 +1,33 @@
-import { ApolloClient } from '@apollo/client/core'
-import { ApolloClients } from '@vue/apollo-composable'
-import { resolveClientConfig } from '~/lib/core/configs/apollo'
+// import { ApolloClient } from '@apollo/client/core'
+// import { ApolloClients } from '@vue/apollo-composable'
+// import { resolveClientConfig } from '~/lib/core/configs/apollo'
export default defineNuxtPlugin((nuxtApp) => {
/**
* TODO: You can use `window` here to get credentials for all of the clients
* we need from the parent connectors. The following is just an example
*/
-
- const apolloClients = {
- latest: new ApolloClient(
- // Imagine endpoint & token is resolved from window or something
- resolveClientConfig({
- httpEndpoint: 'https://latest.speckle.systems/graphql',
- authToken: () => null
- })
- ),
- xyz: new ApolloClient(
- // Imagine endpoint & token is resolved from window or something
- resolveClientConfig({
- httpEndpoint: 'https://speckle.xyz/graphql',
- authToken: () => null
- })
- )
- }
-
- nuxtApp.vueApp.provide(ApolloClients, apolloClients)
- return {
- provide: {
- apolloClients
- }
- }
+ // const { $bindings } = useNuxtApp()
+ // const apolloClients = {
+ // latest: new ApolloClient(
+ // // Imagine endpoint & token is resolved from window or something
+ // resolveClientConfig({
+ // httpEndpoint: 'https://latest.speckle.systems/graphql',
+ // authToken: () => null
+ // })
+ // ),
+ // xyz: new ApolloClient(
+ // // Imagine endpoint & token is resolved from window or something
+ // resolveClientConfig({
+ // httpEndpoint: 'https://speckle.xyz/graphql',
+ // authToken: () => null
+ // })
+ // )
+ // }
+ // nuxtApp.vueApp.provide(ApolloClients, apolloClients)
+ // return {
+ // provide: {
+ // apolloClients
+ // }
+ // }
})
diff --git a/packages/dui3/types/index.ts b/packages/dui3/types/index.ts
new file mode 100644
index 000000000..b637d3f75
--- /dev/null
+++ b/packages/dui3/types/index.ts
@@ -0,0 +1,40 @@
+/* eslint-disable @typescript-eslint/require-await */
+export type Account = {
+ id: string
+ isDefault: boolean
+ token: string
+ serverInfo: {
+ name: string
+ url: string
+ }
+ userInfo: {
+ id: string
+ avatar: string
+ email: string
+ name: string
+ commits: { totalCount: number }
+ streams: { totalCount: number }
+ }
+}
+
+export interface ICefSharp {
+ BindObjectAsync: (arg: string) => Promise
+}
+
+export type WebUiBindingType = {
+ getAccounts: () => Promise
+ sayHi: (name: string) => Promise
+ getSourceAppName: () => Promise
+}
+
+export const MockedBindings: WebUiBindingType = {
+ async getAccounts() {
+ return '[]'
+ },
+ async sayHi(name: string) {
+ return `Hi ${name} from (mocked bindings)!`
+ },
+ async getSourceAppName() {
+ return 'Mocked App'
+ }
+}