@wippy-fe/webcomponent-vue 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/vue-element.ts +12 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wippy-fe/webcomponent-vue",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "Vue 3 integration layer for Wippy web components — extends @wippy-fe/webcomponent-core with reactive props, Pinia, and provider injection.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -10,10 +10,10 @@
10
10
  "package.json"
11
11
  ],
12
12
  "dependencies": {
13
- "@wippy-fe/webcomponent-core": "^0.0.16"
13
+ "@wippy-fe/webcomponent-core": "^0.0.18"
14
14
  },
15
15
  "peerDependencies": {
16
- "@wippy-fe/proxy": "^0.0.16",
16
+ "@wippy-fe/proxy": "^0.0.18",
17
17
  "@iconify/vue": "^5.0.0",
18
18
  "pinia": "^2.1.0",
19
19
  "vue": "^3.5.0"
@@ -1,7 +1,7 @@
1
1
  import type { App, Component, Ref } from 'vue'
2
2
  import type { PiniaPlugin } from 'pinia'
3
3
  import { WippyElement } from '@wippy-fe/webcomponent-core'
4
- import { createPinia } from 'pinia'
4
+ import { createPinia, getActivePinia, setActivePinia } from 'pinia'
5
5
  import { createApp, ref } from 'vue'
6
6
  import { EVENT_PROVIDER, PROPS_PROVIDER, PROPS_ERROR_PROVIDER, CONTENT_PROVIDER } from './providers.ts'
7
7
 
@@ -84,6 +84,11 @@ export abstract class WippyVueElement<
84
84
  }
85
85
 
86
86
  // 2. Create Vue app + Pinia
87
+ // Save and restore the host's activePinia so this web component's
88
+ // isolated Pinia instance doesn't contaminate the global scope.
89
+ // See: https://pinia.vuejs.org/core-concepts/outside-component-usage
90
+ const hostPinia = getActivePinia()
91
+
87
92
  this._vueApp = createApp(vueConfig.rootComponent)
88
93
  const pinia = createPinia()
89
94
  if (vueConfig.piniaPlugins) {
@@ -112,6 +117,12 @@ export abstract class WippyVueElement<
112
117
 
113
118
  // 6. Mount
114
119
  this._vueApp.mount(container)
120
+
121
+ // 7. Restore the host's activePinia — prevents this web component's
122
+ // Pinia from being used by unrelated code that calls useStore()
123
+ // outside of a component setup context (e.g. axios interceptors).
124
+ if (hostPinia)
125
+ setActivePinia(hostPinia)
115
126
  }
116
127
 
117
128
  protected onUnmount(): void {