@wippy-fe/webcomponent-vue 0.0.30 → 0.0.32
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.
- package/README.md +5 -4
- package/package.json +5 -5
- package/src/index.ts +7 -0
- package/src/vue-element.ts +28 -21
package/README.md
CHANGED
|
@@ -79,16 +79,17 @@ interface WippyVueElementConfig {
|
|
|
79
79
|
|
|
80
80
|
#### Lifecycle hooks
|
|
81
81
|
|
|
82
|
-
`WippyVueElement` implements `onMount
|
|
82
|
+
`WippyVueElement` implements `onMount` and `onUnmount` from the base class. Prop / content changes are propagated to the Vue refs via a subscription on the core's `this.reactive` adapter (set up in `onMount`, torn down via `AbortSignal` in `onUnmount`). You don't need — and should not — override `onPropsChanged` / `onContentChanged`; the bridge handles them. You can still override the other hooks from `WippyElement`:
|
|
83
83
|
|
|
84
84
|
| Hook | Available? | Notes |
|
|
85
85
|
|------|-----------|-------|
|
|
86
86
|
| `onInit(shadow)` | Override freely | Runs before CSS/container |
|
|
87
|
-
| `onMount(...)` | Implemented by WippyVueElement | Do not override — use `vueConfig` instead |
|
|
87
|
+
| `onMount(...)` | Implemented by WippyVueElement | Do not override — use `vueConfig` instead. Sets up Pinia, Vue app, providers, and bridges core's reactive adapter → Vue refs. |
|
|
88
88
|
| `onReady()` | Override freely | Runs after Vue app is mounted and state is `ready` |
|
|
89
89
|
| `onError(error)` | Override freely | Custom error handling |
|
|
90
|
-
| `onUnmount()` | Implemented by WippyVueElement | Do not override |
|
|
91
|
-
| `onPropsChanged(...)` |
|
|
90
|
+
| `onUnmount()` | Implemented by WippyVueElement | Do not override. Aborts the core-adapter bridge subscription, then unmounts the Vue app. |
|
|
91
|
+
| `onPropsChanged(...)` | Inherited from `WippyElement` (no-op) | Propagation happens via the reactive-adapter bridge instead. Overriding here works but is redundant for ref updates; reach for `this.reactive.props.subscribe(...)` if you need a custom hook. |
|
|
92
|
+
| `onContentChanged(...)` | Inherited from `WippyElement` (no-op) | Same — propagated via the bridge. |
|
|
92
93
|
|
|
93
94
|
### Provider Symbols
|
|
94
95
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wippy-fe/webcomponent-vue",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Vue 3 integration layer for Wippy web components
|
|
3
|
+
"version": "0.0.32",
|
|
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",
|
|
7
7
|
"types": "src/index.ts",
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"package.json"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@wippy-fe/webcomponent-core": "0.0.
|
|
13
|
+
"@wippy-fe/webcomponent-core": "0.0.32"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@iconify/vue": "^5.0.0",
|
|
17
17
|
"pinia": "^2.1.0",
|
|
18
18
|
"vue": "^3.5.0",
|
|
19
|
-
"@wippy-fe/proxy": "0.0.
|
|
20
|
-
"@wippy-fe/shared": "0.0.
|
|
19
|
+
"@wippy-fe/proxy": "0.0.32",
|
|
20
|
+
"@wippy-fe/shared": "0.0.32"
|
|
21
21
|
},
|
|
22
22
|
"license": "UNLICENSED"
|
|
23
23
|
}
|
package/src/index.ts
CHANGED
|
@@ -26,9 +26,16 @@ export type { WippyVueElementConfig } from './vue-element.ts'
|
|
|
26
26
|
export { define, WippyElement } from '@wippy-fe/webcomponent-core'
|
|
27
27
|
export type {
|
|
28
28
|
BroadcastEnvelope,
|
|
29
|
+
ContentListener,
|
|
30
|
+
ContentSubscription,
|
|
31
|
+
EventEmitterHandle,
|
|
29
32
|
HostCssKey,
|
|
30
33
|
LayoutBusBound,
|
|
31
34
|
ParseResult,
|
|
35
|
+
PropsListener,
|
|
36
|
+
PropsSubscription,
|
|
37
|
+
ReactiveAdapter,
|
|
38
|
+
SubscribeOptions,
|
|
32
39
|
WippyElementConfig,
|
|
33
40
|
WippyPropDefinition,
|
|
34
41
|
WippyPropsSchema,
|
package/src/vue-element.ts
CHANGED
|
@@ -47,17 +47,13 @@ export interface WippyVueElementConfig {
|
|
|
47
47
|
export abstract class WippyVueElement<
|
|
48
48
|
Props = Record<string, unknown>,
|
|
49
49
|
Events = Record<string, unknown>,
|
|
50
|
-
> extends WippyElement<Props> {
|
|
50
|
+
> extends WippyElement<Props, Events> {
|
|
51
51
|
private _vueApp: App<Element> | null = null
|
|
52
52
|
private _propsRef: Ref<Props> = ref({}) as Ref<Props>
|
|
53
53
|
private _errorsRef: Ref<string[]> = ref([])
|
|
54
54
|
private _contentRef: Ref<string | null> = ref(null)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* Phantom field to retain the Events type parameter.
|
|
58
|
-
* @internal
|
|
59
|
-
*/
|
|
60
|
-
declare readonly _events: Events
|
|
55
|
+
/** Cleanup handle for the core-adapter → Vue-ref bridge subscription. */
|
|
56
|
+
private _bridgeAbort: AbortController | null = null
|
|
61
57
|
|
|
62
58
|
/**
|
|
63
59
|
* Override to provide Vue-specific configuration.
|
|
@@ -82,7 +78,12 @@ export abstract class WippyVueElement<
|
|
|
82
78
|
// replace them.
|
|
83
79
|
const vueConfig = (this.constructor as typeof WippyVueElement).vueConfig
|
|
84
80
|
|
|
85
|
-
// 1.
|
|
81
|
+
// 1. Seed reactive refs from initial state, then bridge to the core
|
|
82
|
+
// reactive adapter so subsequent attribute / content changes
|
|
83
|
+
// propagate without manual ref writes in `onPropsChanged` /
|
|
84
|
+
// `onContentChanged`. The core adapter is the single source of
|
|
85
|
+
// truth; the Vue refs are a read-only mirror that consumers reach
|
|
86
|
+
// via `useProps()` / `useContent()` / `usePropsErrors()`.
|
|
86
87
|
this._propsRef.value = initialProps
|
|
87
88
|
this._errorsRef.value = initialErrors
|
|
88
89
|
this._contentRef.value = initialContent ?? null
|
|
@@ -92,6 +93,21 @@ export abstract class WippyVueElement<
|
|
|
92
93
|
this.emitEvent('invalid', { message: error })
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
this._bridgeAbort = new AbortController()
|
|
97
|
+
this.reactive.props.subscribe((props, errors) => {
|
|
98
|
+
this._propsRef.value = props
|
|
99
|
+
this._errorsRef.value = [...errors]
|
|
100
|
+
for (const error of errors) {
|
|
101
|
+
this.emitEvent('invalid', { message: error })
|
|
102
|
+
}
|
|
103
|
+
}, { signal: this._bridgeAbort.signal })
|
|
104
|
+
|
|
105
|
+
if (this.reactive.content) {
|
|
106
|
+
this.reactive.content.subscribe((content) => {
|
|
107
|
+
this._contentRef.value = content
|
|
108
|
+
}, { signal: this._bridgeAbort.signal })
|
|
109
|
+
}
|
|
110
|
+
|
|
95
111
|
// 2. Create Vue app + Pinia
|
|
96
112
|
// Save and restore the host's activePinia so this web component's
|
|
97
113
|
// isolated Pinia instance doesn't contaminate the global scope.
|
|
@@ -144,22 +160,13 @@ export abstract class WippyVueElement<
|
|
|
144
160
|
}
|
|
145
161
|
|
|
146
162
|
protected onUnmount(): void {
|
|
163
|
+
// Tear down the core-adapter bridge BEFORE unmounting Vue, so the
|
|
164
|
+
// Vue refs can't be mutated mid-teardown by a stray late notify.
|
|
165
|
+
this._bridgeAbort?.abort()
|
|
166
|
+
this._bridgeAbort = null
|
|
147
167
|
if (this._vueApp) {
|
|
148
168
|
this._vueApp.unmount()
|
|
149
169
|
this._vueApp = null
|
|
150
170
|
}
|
|
151
171
|
}
|
|
152
|
-
|
|
153
|
-
protected onPropsChanged(props: Props, errors: string[]): void {
|
|
154
|
-
this._propsRef.value = props
|
|
155
|
-
this._errorsRef.value = errors
|
|
156
|
-
|
|
157
|
-
for (const error of errors) {
|
|
158
|
-
this.emitEvent('invalid', { message: error })
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
protected onContentChanged(content: string | null): void {
|
|
163
|
-
this._contentRef.value = content
|
|
164
|
-
}
|
|
165
172
|
}
|