-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pass all provides down to custom renderer (#806)
* feat: pass all provides down to custom renderer * chore: eslint auto import * fix: solve precedence issue and added dedicated playground * chore: disable eslint console rule in playground * feat: provide inject reactivity seems to work now * chore: remove unsued import * feature: just removed console log after testing in another package * feat: opt-out flag for disabling provide bridge * feat: correct the precedence of provide keys * chore: fix lint * feat: changed flag to positive * docs: correct back the docs
- Loading branch information
1 parent
fd3b599
commit b4a3866
Showing
12 changed files
with
214 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
"globals": { | ||
"Component": true, | ||
"ComponentPublicInstance": true, | ||
"ComputedRef": true, | ||
"EffectScope": true, | ||
"ExtractDefaultPropTypes": true, | ||
"ExtractPropTypes": true, | ||
"ExtractPublicPropTypes": true, | ||
"InjectionKey": true, | ||
"PropType": true, | ||
"Ref": true, | ||
"VNode": true, | ||
"WritableComputedRef": true, | ||
"computed": true, | ||
"createApp": true, | ||
"customRef": true, | ||
"defineAsyncComponent": true, | ||
"defineComponent": true, | ||
"effectScope": true, | ||
"getCurrentInstance": true, | ||
"getCurrentScope": true, | ||
"h": true, | ||
"inject": true, | ||
"isProxy": true, | ||
"isReactive": true, | ||
"isReadonly": true, | ||
"isRef": true, | ||
"markRaw": true, | ||
"nextTick": true, | ||
"onActivated": true, | ||
"onBeforeMount": true, | ||
"onBeforeUnmount": true, | ||
"onBeforeUpdate": true, | ||
"onDeactivated": true, | ||
"onErrorCaptured": true, | ||
"onMounted": true, | ||
"onRenderTracked": true, | ||
"onRenderTriggered": true, | ||
"onScopeDispose": true, | ||
"onServerPrefetch": true, | ||
"onUnmounted": true, | ||
"onUpdated": true, | ||
"provide": true, | ||
"reactive": true, | ||
"readonly": true, | ||
"ref": true, | ||
"resolveComponent": true, | ||
"shallowReactive": true, | ||
"shallowReadonly": true, | ||
"shallowRef": true, | ||
"toRaw": true, | ||
"toRef": true, | ||
"toRefs": true, | ||
"toValue": true, | ||
"triggerRef": true, | ||
"unref": true, | ||
"useAttrs": true, | ||
"useCssModule": true, | ||
"useCssVars": true, | ||
"useSlots": true, | ||
"watch": true, | ||
"watchEffect": true, | ||
"watchPostEffect": true, | ||
"watchSyncEffect": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- ProvideBridge.vue --> | ||
<script setup lang="ts"> | ||
import { provide } from 'vue' | ||
|
||
interface Props { | ||
keysValues: Record<string, any> | ||
} | ||
const props = withDefaults(defineProps<Props>(), { | ||
keysValues: () => ({}), | ||
}) | ||
for (const [key, value] of Object.entries(props.keysValues)) { | ||
provide(key, value) | ||
} | ||
</script> | ||
|
||
<template> | ||
<TresGroup> | ||
<slot></slot> | ||
</TresGroup> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
playground/vue/src/pages/issues/732/ProvideInjectExperience.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<script setup lang="ts"> | ||
import { TresCanvas } from '@tresjs/core' | ||
import SubComponentWithInject from './SubComponentWithInject.vue' | ||
provide('test', '✅ Precedence is correct') | ||
</script> | ||
|
||
<template> | ||
<TresCanvas clear-color="#82DBC5"> | ||
<TresPerspectiveCamera :position="[11, 11, 11]" :look-at="[0, 0, 0]" /> | ||
<SubComponentWithInject /> | ||
<TresGridHelper /> | ||
<TresAmbientLight :intensity="1" /> | ||
</TresCanvas> | ||
</template> |
24 changes: 24 additions & 0 deletions
24
playground/vue/src/pages/issues/732/SubComponentWithInject.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- eslint-disable no-console --> | ||
<script setup lang="ts"> | ||
import { inject, watchEffect } from 'vue' | ||
|
||
const awiwi = inject('awiwi') | ||
const bululu = inject('bululu') | ||
const vRoute = inject('v-route') | ||
console.log(inject('test')) | ||
|
||
watchEffect(() => console.log('tres:awiwi', awiwi?.a)) | ||
|
||
watchEffect(() => console.log('tres:bululu', bululu?.value)) | ||
|
||
watchEffect(() => console.log('tres:v-route', vRoute)) | ||
|
||
watchEffect(() => console.log('tres:useTres', inject('useTres'))) | ||
</script> | ||
|
||
<template> | ||
<TresMesh> | ||
<TresBoxGeometry :args="[1, 1, 1]" /> | ||
<TresMeshNormalMaterial /> | ||
</TresMesh> | ||
</template> |
20 changes: 20 additions & 0 deletions
20
playground/vue/src/pages/issues/732/SubVueComponentWithInject.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script setup lang="ts"> | ||
import { inject, watchEffect } from 'vue' | ||
const awiwi = inject('awiwi') | ||
const bululu = inject('bululu') | ||
// eslint-disable-next-line no-console | ||
watchEffect(() => console.log('vue:awiwi', awiwi?.a)) | ||
// eslint-disable-next-line no-console | ||
watchEffect(() => console.log('vue:bululu', bululu?.value)) | ||
// eslint-disable-next-line no-console | ||
watchEffect(() => console.log('vue:v-route', inject('v-route'))) | ||
// eslint-disable-next-line no-console | ||
watchEffect(() => console.log('vue:useTres', inject('useTres'))) | ||
</script> | ||
|
||
<template> | ||
<p>awiwi: {{ awiwi }}</p> | ||
<p>bululu: {{ bululu }}</p> | ||
<p>v-route: {{ inject('v-route') }}</p> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script setup lang="ts"> | ||
import { provide, reactive } from 'vue' | ||
import ProvideInjectExperience from './ProvideInjectExperience.vue' | ||
import SubVueComponentWithInject from './SubVueComponentWithInject.vue' | ||
const obj = reactive({ | ||
a: 1, | ||
}) | ||
const bululu = ref(1) | ||
provide('awiwi', obj) | ||
provide('bululu', bululu) | ||
provide('test', '❌ Precendence is incorrect') | ||
function onClick() { | ||
obj.a++ | ||
bululu.value++ | ||
} | ||
</script> | ||
|
||
<template> | ||
<button @click="onClick">Click me </button> | ||
<SubVueComponentWithInject /> | ||
<ProvideInjectExperience /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters