Explorar el Código

fix: proxy app context (#394)

* fix: proxy app context

* chore: combine imports

* chore: fix lint

* chore: release v3.2.1-next.0

* fix: object assign approach for inner app context

* chore: release v3.2.1-next.1

* fix: explicitely set app context app

* chore: release v3.2.1-next.2

* fix: revert object assign usage for setting app in appContext

* chore: release v3.2.1-next.3

* Revert "chore: fix lint"

This reverts commit a144712ad6b753afe1afe619bbca314d3437bfd5.

* chore: release v3.2.1-next.4
Alvaro Saburido hace 1 año
padre
commit
2301269aef
Se han modificado 4 ficheros con 46 adiciones y 3 borrados
  1. 35 0
      CHANGELOG.md
  2. 1 1
      package.json
  3. 2 0
      playground/src/components/TestSphere.vue
  4. 8 2
      src/components/TresCanvas.vue

+ 35 - 0
CHANGELOG.md

@@ -1,5 +1,40 @@
 
 
+## [3.2.1-next.4](https://github.com/Tresjs/tres/compare/3.2.1-next.3...3.2.1-next.4) (2023-09-11)
+
+
+### Reverts
+
+* Revert "chore: fix lint" ([f53fba9](https://github.com/Tresjs/tres/commit/f53fba955a0c3f0040ce79f52e1b756147fad4ec))
+
+## [3.2.1-next.3](https://github.com/Tresjs/tres/compare/3.2.1-next.2...3.2.1-next.3) (2023-09-11)
+
+
+### Bug Fixes
+
+* revert object assign usage for setting app in appContext ([889e022](https://github.com/Tresjs/tres/commit/889e0221ed2e8f2c6a3e4ee91413125c9bfe7281))
+
+## [3.2.1-next.2](https://github.com/Tresjs/tres/compare/3.2.1-next.1...3.2.1-next.2) (2023-09-11)
+
+
+### Bug Fixes
+
+* explicitely set app context app ([c2a758f](https://github.com/Tresjs/tres/commit/c2a758f4c63641897db7b7065fed8286a699c20e))
+
+## [3.2.1-next.1](https://github.com/Tresjs/tres/compare/3.2.1-next.0...3.2.1-next.1) (2023-09-11)
+
+
+### Bug Fixes
+
+* object assign approach for inner app context ([3a6dc31](https://github.com/Tresjs/tres/commit/3a6dc317c39cba6b2ebcdcf372eb8ccd6676ef2e))
+
+## [3.2.1-next.0](https://github.com/Tresjs/tres/compare/3.2.0...3.2.1-next.0) (2023-09-11)
+
+
+### Bug Fixes
+
+* proxy app context ([128e3a5](https://github.com/Tresjs/tres/commit/128e3a5eb7af9c3d9b76f67e4afb19d6d0f550b0))
+
 ## [3.2.0](https://github.com/Tresjs/tres/compare/3.1.1...3.2.0) (2023-09-06)
 
 

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "name": "@tresjs/core",
   "type": "module",
-  "version": "3.2.0",
+  "version": "3.2.1-next.4",
   "packageManager": "pnpm@8.3.1",
   "description": "Declarative ThreeJS using Vue Components",
   "author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",

+ 2 - 0
playground/src/components/TestSphere.vue

@@ -21,6 +21,8 @@ const pbrTexture = await useTexture({
   ambientOcclusion:
     'https://raw.githubusercontent.com/Tresjs/assets/main/textures/black-rock/Rock035_2K_AmbientOcclusion.jpg',
 })
+
+console.log('sphereRef', getCurrentInstance())
 </script>
 
 <template>

+ 8 - 2
src/components/TresCanvas.vue

@@ -6,7 +6,8 @@ import type {
   ShadowMapType,
   ToneMapping,
 } from 'three'
-import type { Ref } from 'vue'
+import type { Ref,
+  App } from 'vue'
 import {
   computed,
   onMounted,
@@ -17,7 +18,8 @@ import {
   watchEffect,
   Fragment,
   defineComponent,
-  h,
+  h, 
+  getCurrentInstance,
 } from 'vue'
 import {
   useTresContextProvider,
@@ -81,9 +83,13 @@ const slots = defineSlots<{
   default(): any
 }>()
 
+const instance = getCurrentInstance()?.appContext.app
+
 const createInternalComponent = (context: TresContext) =>
   defineComponent({
     setup() {
+      const ctx = getCurrentInstance()?.appContext
+      if (ctx) ctx.app = instance as App
       provide('useTres', context)
       provide('extend', extend)
       return () => h(Fragment, null, slots?.default ? slots.default() : [])