From 6d81f74d19f63f41b299a7c60af4716969b0c821 Mon Sep 17 00:00:00 2001 From: "Mr.Mao" <951416545@qq.com> Date: Sat, 28 Oct 2023 16:06:11 +0800 Subject: [PATCH 1/2] fix: application extends parent injection (#65) --- packages/vue3-pixi/src/components/application/index.ts | 8 +++++++- packages/vue3-pixi/src/components/external/index.ts | 2 +- .../src/{components/external => }/utils/index.ts | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) rename packages/vue3-pixi/src/{components/external => }/utils/index.ts (74%) diff --git a/packages/vue3-pixi/src/components/application/index.ts b/packages/vue3-pixi/src/components/application/index.ts index a270de2..c0e7698 100644 --- a/packages/vue3-pixi/src/components/application/index.ts +++ b/packages/vue3-pixi/src/components/application/index.ts @@ -1,11 +1,12 @@ /* eslint-disable vue/one-component-per-file */ -import { defineComponent, h, markRaw, onMounted, onUnmounted, ref, renderSlot, warn, watch } from 'vue-demi' +import { defineComponent, getCurrentInstance, h, markRaw, onMounted, onUnmounted, ref, renderSlot, warn, watch } from 'vue-demi' import { throttle } from '@antfu/utils' import { Application as _Application } from 'pixi.js' import type { ColorSource, Container } from 'pixi.js' import type { App, PropType } from 'vue-demi' import { createApp } from '../../renderer' import { appInjectKey } from '../../composables' +import { inheritParent } from '../../utils' export interface ApplicationInst { canvas: HTMLCanvasElement @@ -36,8 +37,10 @@ export const Application = defineComponent({ resizeTo: Object as PropType, }, setup(props, { slots, expose }) { + const { appContext } = getCurrentInstance()! const canvas = ref() const pixiApp = ref() + let app: App | undefined function mount() { @@ -62,6 +65,9 @@ export const Application = defineComponent({ app = createApp({ render: () => renderSlot(slots, 'default'), }) + + inheritParent(app, appContext) + app.provide(appInjectKey, pixiApp) app.mount(pixiApp.value.stage) } diff --git a/packages/vue3-pixi/src/components/external/index.ts b/packages/vue3-pixi/src/components/external/index.ts index 72166c6..399c73a 100644 --- a/packages/vue3-pixi/src/components/external/index.ts +++ b/packages/vue3-pixi/src/components/external/index.ts @@ -2,7 +2,7 @@ import type { App, PropType } from 'vue-demi' import { createApp, defineComponent, getCurrentInstance, h, inject, onMounted, onUnmounted, ref } from 'vue-demi' import { appInjectKey } from '../../composables' -import { inheritParent } from './utils' +import { inheritParent } from '../../utils' export const External = defineComponent({ props: { diff --git a/packages/vue3-pixi/src/components/external/utils/index.ts b/packages/vue3-pixi/src/utils/index.ts similarity index 74% rename from packages/vue3-pixi/src/components/external/utils/index.ts rename to packages/vue3-pixi/src/utils/index.ts index b0aa076..ca9bfa9 100644 --- a/packages/vue3-pixi/src/components/external/utils/index.ts +++ b/packages/vue3-pixi/src/utils/index.ts @@ -1,6 +1,6 @@ import type { App, AppContext } from 'vue-demi' -export function inheritParent(app: App, appContext?: AppContext) { +export function inheritParent(app: App, appContext?: AppContext) { const parent = appContext?.app if (parent) { app.config.globalProperties = parent.config.globalProperties From f330dc5b07b4180b13674e3118af99ff7d7d3053 Mon Sep 17 00:00:00 2001 From: "Mr.Mao" <951416545@qq.com> Date: Sat, 28 Oct 2023 16:08:09 +0800 Subject: [PATCH 2/2] chore: release v0.8.4 --- package.json | 2 +- packages/vue3-pixi-projection/package.json | 2 +- packages/vue3-pixi-ui/package.json | 2 +- packages/vue3-pixi/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 748d965..4cf2f43 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vue3-pixi-monorepo", "type": "module", - "version": "0.8.3", + "version": "0.8.4", "private": true, "packageManager": "pnpm@8.9.2", "description": "Vue createRenderer for PixiJS", diff --git a/packages/vue3-pixi-projection/package.json b/packages/vue3-pixi-projection/package.json index 4f8fa8b..6e228d1 100644 --- a/packages/vue3-pixi-projection/package.json +++ b/packages/vue3-pixi-projection/package.json @@ -1,7 +1,7 @@ { "name": "vue3-pixi-projection", "type": "module", - "version": "0.8.3", + "version": "0.8.4", "description": "Vue createRenderer for PixiJS", "license": "MIT", "homepage": "https://github.com/hairyf/vue3-pixi#readme", diff --git a/packages/vue3-pixi-ui/package.json b/packages/vue3-pixi-ui/package.json index 582c057..92a4f32 100644 --- a/packages/vue3-pixi-ui/package.json +++ b/packages/vue3-pixi-ui/package.json @@ -1,7 +1,7 @@ { "name": "vue3-pixi-ui", "type": "module", - "version": "0.8.3", + "version": "0.8.4", "description": "Vue createRenderer for PixiJS", "license": "MIT", "homepage": "https://github.com/hairyf/vue3-pixi#readme", diff --git a/packages/vue3-pixi/package.json b/packages/vue3-pixi/package.json index 866ed1e..2a4e125 100644 --- a/packages/vue3-pixi/package.json +++ b/packages/vue3-pixi/package.json @@ -1,7 +1,7 @@ { "name": "vue3-pixi", "type": "module", - "version": "0.8.3", + "version": "0.8.4", "description": "Vue createRenderer for PixiJS", "license": "MIT", "homepage": "https://github.com/hairyf/vue3-pixi#readme",