Skip to content

Commit 66c7ab5

Browse files
authoredSep 4, 2024··
fix: 785 vscode intellisense autocompletion not getting tres components props (#809)
* ci: use checkout action v4 * fix(types): remove generic from VueProps and Vnodes * chore(lint): disable annoying lint issues * fix: remove props overwrite to any on instance props type * fix(types): solved issue with vector and math representation types * fix(types): keep the export inside of the global namespace
1 parent 560435e commit 66c7ab5

21 files changed

+2453
-2779
lines changed
 

‎.github/workflows/pkg.pr.new.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
node-version: [20]
2626
steps:
2727
- name: Checkout code
28-
uses: actions/checkout@v2
28+
uses: actions/checkout@v4
2929

3030
- run: corepack enable
3131
- uses: actions/setup-node@v4

‎docs/advanced/performance.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,9 @@ To avoid errors and unwanted sideeffects, resources created programatically with
143143
import { dispose } from '@tresjs/core'
144144
import { useGLTF } from '@tresjs/cientos'
145145
146-
const { nodes } = await useGLTF(
147-
'https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/blender-cube.glb',
148-
{ draco: true },
149-
)
146+
const { nodes } = await useGLTF('https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/blender-cube.glb', {
147+
draco: true,
148+
})
150149
const model = nodes.Cube
151150
152151
onUnmounted(() => {

‎docs/advanced/primitive.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ The same pointer events available on the TresJS components are available on the
3232

3333
```html
3434
<template>
35-
<primitive
36-
:object="meshWithMaterial"
37-
@click="onClick"
38-
@pointermove="onPointerMove"
39-
/>
35+
<primitive :object="meshWithMaterial" @click="onClick" @pointermove="onPointerMove" />
4036
</template>
4137
```
4238

‎package.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -78,43 +78,43 @@
7878
"devDependencies": {
7979
"@release-it/conventional-changelog": "^8.0.1",
8080
"@stackblitz/sdk": "^1.11.0",
81-
"@tresjs/cientos": "3.9.0",
81+
"@tresjs/cientos": "4.0.2",
8282
"@tresjs/eslint-config": "^1.1.0",
83-
"@types/three": "^0.166.0",
84-
"@typescript-eslint/eslint-plugin": "^7.16.0",
85-
"@typescript-eslint/parser": "^7.16.0",
83+
"@types/three": "^0.168.0",
84+
"@typescript-eslint/eslint-plugin": "^8.4.0",
85+
"@typescript-eslint/parser": "^8.4.0",
8686
"@vitejs/plugin-vue": "^5.0.5",
8787
"@vitest/coverage-c8": "^0.33.0",
8888
"@vitest/coverage-v8": "^2.0.2",
8989
"@vitest/ui": "^2.0.2",
9090
"@vue/test-utils": "^2.4.6",
9191
"eslint": "^9.6.0",
92-
"eslint-plugin-vue": "^9.27.0",
92+
"eslint-plugin-vue": "^9.28.0",
9393
"esno": "^4.7.0",
9494
"gsap": "^3.12.5",
9595
"husky": "^9.0.11",
96-
"jsdom": "^24.1.0",
96+
"jsdom": "^25.0.0",
9797
"kolorist": "^1.8.0",
9898
"ohmyfetch": "^0.4.21",
9999
"pathe": "^1.1.2",
100100
"release-it": "^17.5.0",
101101
"rollup-plugin-analyzer": "^4.0.0",
102102
"rollup-plugin-copy": "^3.5.0",
103103
"rollup-plugin-visualizer": "^5.12.0",
104-
"sponsorkit": "^0.14.6",
105-
"three": "^0.166.1",
106-
"unocss": "^0.61.3",
107-
"unplugin": "^1.11.0",
104+
"sponsorkit": "^0.15.4",
105+
"three": "^0.168.0",
106+
"unocss": "^0.62.3",
107+
"unplugin": "^1.13.1",
108108
"unplugin-vue-components": "^0.27.2",
109-
"vite": "^5.3.3",
110-
"vite-plugin-banner": "^0.7.1",
111-
"vite-plugin-dts": "3.9.1",
109+
"vite": "^5.4.3",
110+
"vite-plugin-banner": "^0.8.0",
111+
"vite-plugin-dts": "4.1.0",
112112
"vite-plugin-inspect": "^0.8.4",
113113
"vite-plugin-require-transform": "^1.0.21",
114114
"vite-svg-loader": "^5.1.0",
115-
"vitepress": "1.3.0",
115+
"vitepress": "1.3.4",
116116
"vitest": "^2.0.2",
117-
"vue": "^3.4.31",
117+
"vue": "3.5.0",
118118
"vue-demi": "^0.14.8"
119119
}
120120
}

‎playground/.eslintrc-auto-import.json

-67
This file was deleted.

‎playground/components.d.ts

-13
This file was deleted.

‎playground/vue/.eslintrc-auto-import.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"ComponentPublicInstance": true,
55
"ComputedRef": true,
66
"EffectScope": true,
7+
"ExtractDefaultPropTypes": true,
8+
"ExtractPropTypes": true,
9+
"ExtractPublicPropTypes": true,
710
"InjectionKey": true,
811
"PropType": true,
912
"Ref": true,
@@ -59,9 +62,6 @@
5962
"watch": true,
6063
"watchEffect": true,
6164
"watchPostEffect": true,
62-
"watchSyncEffect": true,
63-
"ExtractDefaultPropTypes": true,
64-
"ExtractPropTypes": true,
65-
"ExtractPublicPropTypes": true
65+
"watchSyncEffect": true
6666
}
6767
}

‎playground/vue/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12-
"@tresjs/cientos": "3.9.0",
12+
"@tresjs/cientos": "4.0.2",
1313
"@tresjs/core": "workspace:^",
14-
"vue-router": "^4.4.0"
14+
"vue-router": "^4.4.3"
1515
},
1616
"devDependencies": {
1717
"@tresjs/leches": "0.15.0-next.3",
1818
"@tweakpane/plugin-essentials": "^0.2.0",
19-
"unplugin-auto-import": "^0.18.0",
19+
"unplugin-auto-import": "^0.18.2",
2020
"vite-plugin-glsl": "^1.2.1",
2121
"vite-plugin-qrcode": "^0.2.3",
22-
"vite-plugin-vue-devtools": "7.3.5",
23-
"vue-tsc": "^2.0.26"
22+
"vite-plugin-vue-devtools": "7.4.3",
23+
"vue-tsc": "^2.1.4"
2424
}
2525
}

‎playground/vue/src/pages/basic/index.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ const toonTealMaterial = new MeshToonMaterial({
5353
v-if="sphereExists"
5454
ref="canvasRef"
5555
v-bind="state"
56-
@render="onRender"
5756
>
5857
<TresPerspectiveCamera
59-
:position="[11, 11, 11]"
58+
:position="[0, 8, 8]"
6059
:fov="45"
6160
:near="0.1"
6261
:far="1000"

‎playground/vue/src/pages/issues/701/TheExperience.vue

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const tOrFFast = shallowRef(false)
8181
const elapsed = shallowRef(0)
8282

8383
const pool: {
84+
// eslint-disable-next-line ts/no-unsafe-function-type
8485
click: Function
8586
pos: number[]
8687
group: Group

‎playground/vue/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"module": "ESNext",
88
"moduleResolution": "bundler",
99
"paths": {
10-
"@tresjs/core": ["../../dist"]
10+
"@tresjs/core": ["../../src"]
1111
},
1212
"resolveJsonModule": true,
1313
"strict": true,

‎pnpm-lock.yaml

+2,392-2,651
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/composables/useLogger.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable unicorn/consistent-function-scoping */
12
/* eslint-disable no-console */
23
export const isProd = import.meta.env.MODE === 'production'
34

‎src/composables/useTresEventManager/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable ts/no-unsafe-function-type */
2+
/* eslint-disable unicorn/consistent-function-scoping */
13
import { shallowRef } from 'vue'
24
import type { Object3D, Object3DEventMap, Scene } from 'three'
35
import type { EmitEventFn, EmitEventName, Intersection, TresEvent, TresInstance, TresObject } from 'src/types'

‎src/core/nodeOps.test.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable unicorn/consistent-function-scoping */
12
import { beforeAll, describe, expect, it, vi } from 'vitest'
23
import * as THREE from 'three'
34
import type { Vector3 } from 'three'
@@ -867,7 +868,9 @@ describe('nodeOps', () => {
867868
try {
868869
node.dispose()
869870
}
870-
catch (e) {}
871+
catch (e) {
872+
console.error(e)
873+
}
871874
}
872875
if (node.material) { node.material.dispose() }
873876
if (node.geometry) { node.geometry.dispose() }
@@ -1626,9 +1629,9 @@ function createSimpleMeshPrimitiveTree(nodeOps) {
16261629
const nodes = []
16271630
const objects = []
16281631
const spiesByKey: Partial<Record<
1629-
keyof typeof nodesByKey,
1630-
{ material: () => void, geometry: () => void }
1631-
>> = { }
1632+
keyof typeof nodesByKey,
1633+
{ material: () => void, geometry: () => void }
1634+
>> = { }
16321635
const spies = []
16331636
const undisposed = new Set()
16341637
for (const [key, node] of Object.entries(nodesByKey)) {

‎src/core/nodeOps.ts

+2
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ export const nodeOps: (context: TresContext) => RendererOptions<TresObject, Tres
219219
try {
220220
node.dispose()
221221
}
222+
// eslint-disable-next-line unused-imports/no-unused-vars
222223
catch (e) {
223224
// NOTE: We must try/catch here. We want to remove/dispose
224225
// Vue/THREE children in bottom-up order. But THREE objects
@@ -342,6 +343,7 @@ export const nodeOps: (context: TresContext) => RendererOptions<TresObject, Tres
342343
invalidateInstance(node as TresObject)
343344
}
344345

346+
/* eslint-disable unicorn/consistent-function-scoping */
345347
function parentNode(node: TresObject): TresObject | null {
346348
return node?.__tres?.parent || null
347349
}

‎src/env.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ declare module '*.vue' {
99

1010
interface Window {
1111
__TRES__DEVTOOLS__?: {
12+
// eslint-disable-next-line ts/no-unsafe-function-type
1213
cb: Function
1314
// You can add other properties of __TRES__DEVTOOLS__ here if needed
1415
}

‎src/types/index.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable ts/method-signature-style */
12
import type { DefineComponent, VNode, VNodeRef } from 'vue'
23

34
import type * as THREE from 'three'
@@ -11,6 +12,7 @@ export type AttachType = string | AttachFnType
1112
export type DisposeType = ((self: TresInstance) => void) | boolean | 'default'
1213

1314
export type ConstructorRepresentation = new (...args: any[]) => any
15+
// eslint-disable-next-line ts/no-unsafe-function-type
1416
export type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
1517
export type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O
1618
export type Properties<T> = Pick<T, NonFunctionKeys<T>>
@@ -25,12 +27,17 @@ export type EmitEventName = 'render' | 'ready' | 'click' | 'double-click' | 'con
2527
export type EmitEventFn = (event: EmitEventName, ...args: any[]) => void
2628
export type TresCamera = THREE.OrthographicCamera | THREE.PerspectiveCamera
2729

30+
/**
31+
* Represents the properties of an instance.
32+
*
33+
* @template T - The type of the object.
34+
* @template P - The type of the arguments.
35+
*/
2836
export interface InstanceProps<T = any, P = any> {
2937
args?: Args<P>
3038
object?: T
3139
visible?: boolean
3240
dispose?: null
33-
[prop: string]: any
3441
}
3542

3643
interface TresBaseObject {
@@ -155,10 +162,10 @@ export interface EventHandlers {
155162
}
156163

157164
interface MathRepresentation {
158-
set: (...args: number[] | [THREE.ColorRepresentation]) => any
165+
set(...args: number[] | [THREE.ColorRepresentation]): any
159166
}
160167
interface VectorRepresentation extends MathRepresentation {
161-
setScalar: (s: number) => any
168+
setScalar(s: number): any
162169
}
163170

164171
export interface VectorCoordinates {
@@ -195,14 +202,14 @@ interface RaycastableRepresentation {
195202
}
196203
type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : unknown
197204

198-
export interface VueProps<P> {
199-
children?: VNode<P>[]
205+
export interface VueProps {
206+
children?: VNode[]
200207
ref?: VNodeRef
201208
key?: string | number | symbol
202209
}
203210

204211
type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
205-
Overwrite<WithMathProps<P>, VueProps<P> & EventProps<P>>
212+
Overwrite<P, WithMathProps<P> & VueProps & EventProps<P>>
206213
>
207214

208215
export type ThreeElement<T extends ConstructorRepresentation> = Mutable<

‎src/utils/createPriorityEventHook.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable unicorn/consistent-function-scoping */
12
import { createPriorityEventHook } from './createPriorityEventHook'
23

34
let updateHook = createPriorityEventHook()

‎src/utils/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ export function invalidateInstance(instance: TresObject) {
451451
}
452452

453453
export function noop(fn: string): any {
454-
// eslint-disable-next-line no-unused-expressions
454+
// eslint-disable-next-line ts/no-unused-expressions
455455
fn
456456
}
457457

‎src/utils/is.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export function bool(u: unknown): u is boolean {
2121
return u === true || u === false
2222
}
2323

24+
// eslint-disable-next-line ts/no-unsafe-function-type
2425
export function fun(u: unknown): u is Function {
2526
return typeof u === 'function'
2627
}

0 commit comments

Comments
 (0)
Please sign in to comment.