Przeglądaj źródła

fix: object assign approach for inner app context

alvarosabu 1 rok temu
rodzic
commit
3a6dc317c3
1 zmienionych plików z 12 dodań i 3 usunięć
  1. 12 3
      src/components/TresCanvas.vue

+ 12 - 3
src/components/TresCanvas.vue

@@ -83,13 +83,22 @@ const slots = defineSlots<{
   default(): any
 }>()
 
-const vueApp = getCurrentInstance()?.appContext.app
+const instance = getCurrentInstance()!
 
 const createInternalComponent = (context: TresContext) =>
   defineComponent({
     setup() {
-      const ctx = getCurrentInstance()?.appContext
-      if (ctx) ctx.app = vueApp as App
+      const inner = getCurrentInstance()!
+      
+      Object.assign(inner.appContext, instance.appContext)
+      //@ts-expect-error: internal property
+      Object.assign(inner.provides, inner.appContext.provides)
+      if (import.meta.env.DEV) {
+      //@ts-expect-error: internal property
+        inner.appContext.reload = () => {
+          mountCustomRenderer(context)
+        }
+      }
       provide('useTres', context)
       provide('extend', extend)
       return () => h(Fragment, null, slots?.default ? slots.default() : [])