1
0
Эх сурвалжийг харах

feat: export vue compiler options for Tres custom renderer

alvarosabu 1 жил өмнө
parent
commit
5f51d09011

+ 1 - 1
.vscode/settings.json

@@ -11,7 +11,7 @@
     "editor.defaultFormatter": "esbenp.prettier-vscode"
   },
   "[typescript]": {
-    "editor.defaultFormatter": "esbenp.prettier-vscode"
+    "editor.defaultFormatter": "vscode.typescript-language-features"
   },
   "scss.lint.unknownAtRules": "ignore",
   "css.lint.unknownAtRules": "ignore",

+ 1 - 1
playground/.eslintrc-auto-import.json

@@ -60,4 +60,4 @@
     "watchSyncEffect": true,
     "toValue": true
   }
-}
+}

+ 1 - 3
playground/components.d.ts

@@ -3,11 +3,9 @@
 // @ts-nocheck
 // Generated by unplugin-vue-components
 // Read more: https://github.com/vuejs/core/pull/3399
-import '@vue/runtime-core'
-
 export {}
 
-declare module '@vue/runtime-core' {
+declare module 'vue' {
   export interface GlobalComponents {
     AnimatedModel: typeof import('./src/components/AnimatedModel.vue')['default']
     Cameras: typeof import('./src/components/Cameras.vue')['default']

+ 2 - 5
playground/vite.config.ts

@@ -5,6 +5,7 @@ import AutoImport from 'unplugin-auto-import/vite'
 import Components from 'unplugin-vue-components/vite'
 import glsl from 'vite-plugin-glsl'
 import UnoCSS from 'unocss/vite'
+import { templateCompilerOptions } from '@tresjs/core'
 
 // https://vitejs.dev/config/
 export default defineConfig({
@@ -14,11 +15,7 @@ export default defineConfig({
       script: {
         propsDestructure: true,
       },
-      template: {
-        compilerOptions: {
-          isCustomElement: tag => (tag.startsWith('Tres') && tag !== 'TresCanvas' && tag !== 'TresLeches') || tag === 'primitive',
-        },
-      },
+      ...templateCompilerOptions
     }),
     AutoImport({
       dts: true,

+ 2 - 1
src/index.ts

@@ -6,6 +6,7 @@ export * from './components'
 export * from './types'
 
 import { normalizeColor, normalizeVectorFlexibleParam } from './utils/normalize'
+import templateCompilerOptions from './utils/template-compiler-options'
 
 export interface TresOptions {
   extends?: Record<string, unknown>
@@ -24,4 +25,4 @@ const plugin: TresPlugin = {
 
 export default plugin
 
-export { normalizeColor, normalizeVectorFlexibleParam }
+export { normalizeColor, normalizeVectorFlexibleParam, templateCompilerOptions }

+ 15 - 0
src/utils/template-compiler-options.ts

@@ -0,0 +1,15 @@
+const whitelist = [
+  'TresCanvas',
+  'TresLeches',
+  'TresScene',
+]
+
+const templateCompilerOptions = {
+  template: {
+    compilerOptions: {
+      isCustomElement: (tag: string) => tag.startsWith('Tres') && !whitelist.includes(tag) || tag === 'primitive',
+    },
+  },
+};
+
+export default templateCompilerOptions