Ver Fonte

fix: correct type exporting issues (#625)

* fix: correct type exporting issues

* chore: fix lint
Alvaro Saburido há 1 ano atrás
pai
commit
8e52cf1935

+ 1 - 1
components.d.ts

@@ -1 +1 @@
-export * from './dist/components/index.js'
+export * from './dist/src/components/index.js'

+ 1 - 1
composables.d.ts

@@ -1 +1 @@
-export * from './dist/composables/index.js'
+export * from './dist/src/composables/index.js'

+ 4 - 4
package.json

@@ -21,16 +21,16 @@
       "import": "./dist/tres.js"
     },
     "./components": {
-      "types": "./dist/components/index.d.ts"
+      "types": "./dist/src/components/index.d.ts"
     },
     "./composables": {
-      "types": "./dist/composables/index.d.ts"
+      "types": "./dist/src/composables/index.d.ts"
     },
     "./types": {
-      "types": "./dist/types/index.d.ts"
+      "types": "./dist/src/types/index.d.ts"
     },
     "./utils": {
-      "types": "./dist/utils/index.d.ts"
+      "types": "./dist/src/utils/index.d.ts"
     },
     "./*": "./*"
   },

+ 2 - 2
src/composables/useLoader/index.ts

@@ -1,8 +1,8 @@
 import { isArray } from '@alvarosabu/utils'
-import type { Object3D } from 'three'
+import type { Loader, Object3D } from 'three'
 import { useLogger } from '../useLogger'
 
-export interface TresLoader<T> extends THREE.Loader {
+export interface TresLoader<T> extends Loader {
   load(
     url: string,
     onLoad?: (result: T) => void,

+ 3 - 3
src/composables/useRaycaster/index.ts

@@ -1,5 +1,5 @@
 import { Vector2 } from 'three'
-import type { Object3D, type Intersection } from 'three'
+import type { Object3D, Intersection, Object3DEventMap } from 'three'
 import type { Ref } from 'vue'
 import { computed, onUnmounted } from 'vue'
 import type { EventHook } from '@vueuse/core'
@@ -7,7 +7,7 @@ import { createEventHook, useElementBounding, usePointer } from '@vueuse/core'
 
 import { type TresContext } from '../useTresContextProvider'
 
-export type Intersects = Intersection<THREE.Object3D<THREE.Event>>[]
+export type Intersects = Intersection<Object3D<Object3DEventMap>>[]
 interface PointerMoveEventPayload {
   intersects?: Intersects
   event: PointerEvent
@@ -19,7 +19,7 @@ interface PointerClickEventPayload {
 }
 
 export const useRaycaster = (
-  objects: Ref<THREE.Object3D[]>,
+  objects: Ref<Object3D[]>,
   { renderer, camera, raycaster }: Pick<TresContext, 'renderer' | 'camera' | 'raycaster'>,
 ) => {
   // having a separate computed makes useElementBounding work

+ 19 - 18
src/composables/useSeek/index.ts

@@ -1,3 +1,4 @@
+import type { Scene, Object3D } from 'three'
 import { useLogger } from '../useLogger'
 
 /**
@@ -7,10 +8,10 @@ import { useLogger } from '../useLogger'
  * @interface UseSeekReturn
  */
 export interface UseSeekReturn {
-  seek: (parent: THREE.Scene | THREE.Object3D, property: string, value: string) => THREE.Object3D | null
-  seekByName: (parent: THREE.Scene | THREE.Object3D, value: string) => THREE.Object3D | null
-  seekAll: (parent: THREE.Scene | THREE.Object3D, property: string, value: string) => THREE.Object3D[]
-  seekAllByName: (parent: THREE.Scene | THREE.Object3D, value: string) => THREE.Object3D[]
+  seek: (parent: Scene | Object3D, property: string, value: string) => Object3D | null
+  seekByName: (parent: Scene | Object3D, value: string) => Object3D | null
+  seekAll: (parent: Scene | Object3D, property: string, value: string) => Object3D[]
+  seekAllByName: (parent: Scene | Object3D, value: string) => Object3D[]
 }
 
 /**
@@ -25,13 +26,13 @@ export function useSeek(): UseSeekReturn {
   /**
    * Returns a child object of the parent given a property
    *
-   * @param {(THREE.Scene | THREE.Object3D)} parent
+   * @param {(Scene | Object3D)} parent
    * @param {string} property
    * @param {string} value
-   * @return {*}  {(THREE.Object3D | null)}
+   * @return {*}  {(Object3D | null)}
    */
-  function seek(parent: THREE.Scene | THREE.Object3D, property: string, value: string): THREE.Object3D | null {
-    let foundChild: THREE.Object3D | null = null
+  function seek(parent: Scene | Object3D, property: string, value: string): Object3D | null {
+    let foundChild: Object3D | null = null
 
     parent.traverse((child) => {
       if ((child as any)[property] === value) {
@@ -49,13 +50,13 @@ export function useSeek(): UseSeekReturn {
   /**
  * Returns an array of child objects of the parent given a property
  *
- * @param {(THREE.Scene | THREE.Object3D)} parent
+ * @param {(Scene | Object3D)} parent
  * @param {string} property
  * @param {string} value
- * @return {*}  {(THREE.Object3D[])}
+ * @return {*}  {(Object3D[])}
  */
-  function seekAll(parent: THREE.Scene | THREE.Object3D, property: string, value: string): THREE.Object3D[] {
-    const foundChildren: THREE.Object3D[] = []
+  function seekAll(parent: Scene | Object3D, property: string, value: string): Object3D[] {
+    const foundChildren: Object3D[] = []
 
     parent.traverse((child) => {
       if ((child as any)[property].includes(value)) {
@@ -73,22 +74,22 @@ export function useSeek(): UseSeekReturn {
   /**
    * Returns a child object of the parent given a child.name
    *
-   * @param {(THREE.Scene | THREE.Object3D)} parent
+   * @param {(Scene | Object3D)} parent
    * @param {string} value
-   * @return {*}  {(THREE.Object3D | null)}
+   * @return {*}  {(Object3D | null)}
    */
-  function seekByName(parent: THREE.Scene | THREE.Object3D, value: string): THREE.Object3D | null {
+  function seekByName(parent: Scene | Object3D, value: string): Object3D | null {
     return seek(parent, 'name', value)
   }
 
   /**
  * Returns an array of child objects of the parent given a child.name
  *
- * @param {(THREE.Scene | THREE.Object3D)} parent
+ * @param {(Scene | Object3D)} parent
  * @param {string} value
- * @return {*}  {(THREE.Object3D[])}
+ * @return {*}  {(Object3D[])}
  */
-  function seekAllByName(parent: THREE.Scene | THREE.Object3D, value: string): THREE.Object3D[] {
+  function seekAllByName(parent: Scene | Object3D, value: string): Object3D[] {
     return seekAll(parent, 'name', value)
   }
 

+ 1 - 1
types.d.ts

@@ -1 +1 @@
-export * from './dist/types/index.js'
+export * from './dist/src/types/index.js'

+ 1 - 1
utils.d.ts

@@ -1 +1 @@
-export * from './dist/utils/index.js'
+export * from './dist/src/utils/index.js'