@wippy-fe/webcomponent-vue 0.0.36 → 0.0.37

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/dist/index.d.ts CHANGED
@@ -151,9 +151,12 @@ interface TypedProviders<Props, Events> {
151
151
  declare function createProviders<Props, Events = Record<string, unknown>>(): TypedProviders<Props, Events>;
152
152
 
153
153
  /**
154
- * Vue-specific configuration returned by `static get vueConfig()`.
154
+ * The heavy half of a Vue element's config — the root component, its plugins,
155
+ * and providers. Either supplied eagerly on `WippyVueElementConfig` or returned
156
+ * by `lazyConfig()` from a dynamically-imported chunk (so the element shell can
157
+ * stay tiny and load the framework + component tree on first connect).
155
158
  */
156
- interface WippyVueElementConfig {
159
+ interface WippyVueMountConfig {
157
160
  /** The root Vue component to mount. */
158
161
  rootComponent: Component;
159
162
  /** Additional Vue plugins to install (beyond Pinia which is always installed). */
@@ -165,6 +168,21 @@ interface WippyVueElementConfig {
165
168
  /** Extra providers to inject into the Vue app. */
166
169
  providers?: (app: App, element: WippyVueElement<any, any>) => void;
167
170
  }
171
+ /**
172
+ * Vue-specific configuration returned by `static get vueConfig()`.
173
+ *
174
+ * Provide EITHER an eager `rootComponent` (+ optional plugins/providers) for a
175
+ * normal element, OR `lazyConfig` for a thin shell that defers the heavy parts:
176
+ * when `lazyConfig` is set and `rootComponent` is omitted, `onMount` shows a
177
+ * `<wippy-loading>` placeholder, awaits `lazyConfig()` (typically `() =>
178
+ * import('./internals').then(m => ({ rootComponent: m.Root, providers: m.boot }))`),
179
+ * then mounts. The props/events bridge + lifecycle stay here, so the lazily
180
+ * imported chunk only carries the framework + component tree.
181
+ */
182
+ interface WippyVueElementConfig extends Partial<WippyVueMountConfig> {
183
+ /** Lazily resolve the mount config (root + plugins + providers) on first connect. */
184
+ lazyConfig?: () => Promise<WippyVueMountConfig>;
185
+ }
168
186
  /**
169
187
  * Vue 3 integration for Wippy web components.
170
188
  *
@@ -205,4 +223,4 @@ declare abstract class WippyVueElement<Props = Record<string, unknown>, Events =
205
223
  protected onUnmount(): void;
206
224
  }
207
225
 
208
- export { CONTENT_PROVIDER, EVENT_PROVIDER, HOST_PROVIDER, LAYOUT_BUS_PROVIDER, PANEL_ID_PROVIDER, PROPS_ERROR_PROVIDER, PROPS_PROVIDER, type TypedProviders, WippyVueElement, type WippyVueElementConfig, createProviders, useContent, useEvents, useHost, useLayoutBus, usePanelId, useProps, usePropsErrors };
226
+ export { CONTENT_PROVIDER, EVENT_PROVIDER, HOST_PROVIDER, LAYOUT_BUS_PROVIDER, PANEL_ID_PROVIDER, PROPS_ERROR_PROVIDER, PROPS_PROVIDER, type TypedProviders, WippyVueElement, type WippyVueElementConfig, type WippyVueMountConfig, createProviders, useContent, useEvents, useHost, useLayoutBus, usePanelId, useProps, usePropsErrors };
package/dist/index.js CHANGED
@@ -80,45 +80,73 @@ var WippyVueElement = class extends WippyElement {
80
80
  for (const error of initialErrors) {
81
81
  this.emitEvent("invalid", { message: error });
82
82
  }
83
- this._bridgeAbort = new AbortController();
83
+ const bridgeAbort = new AbortController();
84
+ this._bridgeAbort = bridgeAbort;
84
85
  this.reactive.props.subscribe((props, errors) => {
85
86
  this._propsRef.value = props;
86
87
  this._errorsRef.value = [...errors];
87
88
  for (const error of errors) {
88
89
  this.emitEvent("invalid", { message: error });
89
90
  }
90
- }, { signal: this._bridgeAbort.signal });
91
+ }, { signal: bridgeAbort.signal });
91
92
  if (this.reactive.content) {
92
93
  this.reactive.content.subscribe((content) => {
93
94
  this._contentRef.value = content;
94
- }, { signal: this._bridgeAbort.signal });
95
+ }, { signal: bridgeAbort.signal });
95
96
  }
96
- const hostPinia = getActivePinia();
97
- this._vueApp = createApp(vueConfig.rootComponent);
98
- const pinia = createPinia();
99
- if (vueConfig.piniaPlugins) {
100
- for (const plugin of vueConfig.piniaPlugins)
101
- pinia.use(plugin);
102
- }
103
- this._vueApp.use(pinia);
104
- if (vueConfig.plugins) {
105
- for (const plugin of vueConfig.plugins) {
106
- this._vueApp.use(plugin);
97
+ const mountApp = (mountConfig) => {
98
+ if (bridgeAbort.signal.aborted)
99
+ return;
100
+ const hostPinia = getActivePinia();
101
+ const app = createApp(mountConfig.rootComponent);
102
+ this._vueApp = app;
103
+ const pinia = createPinia();
104
+ if (mountConfig.piniaPlugins) {
105
+ for (const plugin of mountConfig.piniaPlugins)
106
+ pinia.use(plugin);
107
107
  }
108
+ app.use(pinia);
109
+ if (mountConfig.plugins) {
110
+ for (const plugin of mountConfig.plugins)
111
+ app.use(plugin);
112
+ }
113
+ app.provide(PROPS_PROVIDER, this._propsRef);
114
+ app.provide(PROPS_ERROR_PROVIDER, this._errorsRef);
115
+ app.provide(EVENT_PROVIDER, this.emitEvent.bind(this));
116
+ app.provide(CONTENT_PROVIDER, this._contentRef);
117
+ app.provide(PANEL_ID_PROVIDER, getWippyPanelId(this));
118
+ app.provide(LAYOUT_BUS_PROVIDER, getWippyHostBus(this));
119
+ app.provide(HOST_PROVIDER, getWippyHost(this));
120
+ if (mountConfig.providers)
121
+ mountConfig.providers(app, this);
122
+ app.mount(container);
123
+ if (hostPinia)
124
+ setActivePinia(hostPinia);
125
+ };
126
+ if (vueConfig.rootComponent) {
127
+ mountApp(vueConfig);
128
+ } else if (vueConfig.lazyConfig) {
129
+ const loader = document.createElement("wippy-loading");
130
+ loader.setAttribute("no-bg", "");
131
+ container.appendChild(loader);
132
+ vueConfig.lazyConfig().then((mountConfig) => {
133
+ if (bridgeAbort.signal.aborted)
134
+ return;
135
+ loader.remove();
136
+ mountApp(mountConfig);
137
+ }).catch((err) => {
138
+ if (bridgeAbort.signal.aborted)
139
+ return;
140
+ const message = err instanceof Error ? err.message : String(err);
141
+ const errorEl = document.createElement("wippy-error");
142
+ errorEl.setAttribute("title", "Failed to load");
143
+ errorEl.setAttribute("message", message);
144
+ loader.replaceWith(errorEl);
145
+ this.emitEvent("error", { message });
146
+ });
147
+ } else {
148
+ throw new Error("WippyVueElement vueConfig must provide rootComponent or lazyConfig");
108
149
  }
109
- this._vueApp.provide(PROPS_PROVIDER, this._propsRef);
110
- this._vueApp.provide(PROPS_ERROR_PROVIDER, this._errorsRef);
111
- this._vueApp.provide(EVENT_PROVIDER, this.emitEvent.bind(this));
112
- this._vueApp.provide(CONTENT_PROVIDER, this._contentRef);
113
- this._vueApp.provide(PANEL_ID_PROVIDER, getWippyPanelId(this));
114
- this._vueApp.provide(LAYOUT_BUS_PROVIDER, getWippyHostBus(this));
115
- this._vueApp.provide(HOST_PROVIDER, getWippyHost(this));
116
- if (vueConfig.providers) {
117
- vueConfig.providers(this._vueApp, this);
118
- }
119
- this._vueApp.mount(container);
120
- if (hostPinia)
121
- setActivePinia(hostPinia);
122
150
  }
123
151
  onUnmount() {
124
152
  this._bridgeAbort?.abort();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/providers.ts","../src/vue-element.ts","../src/index.ts"],"sourcesContent":["import type { LayoutBusBound } from '@wippy-fe/webcomponent-core'\r\nimport type { InjectionKey, Ref } from 'vue'\r\nimport { inject } from 'vue'\r\n\r\n// ── Base injection keys (untyped) ────────────────────────────\r\n\r\n/** Injection key for the event emitter function. */\r\nexport const EVENT_PROVIDER = Symbol('wippy:emit') as InjectionKey<\r\n (event: string, detail?: unknown) => void\r\n>\r\n\r\n/** Injection key for the reactive props ref. */\r\nexport const PROPS_PROVIDER = Symbol('wippy:props') as InjectionKey<Ref<Record<string, unknown>>>\r\n\r\n/** Injection key for the reactive props error ref. */\r\nexport const PROPS_ERROR_PROVIDER = Symbol('wippy:props_error') as InjectionKey<Ref<string[]>>\r\n\r\n/** Injection key for reactive content from child <template data-type=\"...\"> elements. */\r\nexport const CONTENT_PROVIDER = Symbol('wippy:content') as InjectionKey<Ref<string | null>>\r\n\r\n/**\r\n * Injection key for the panelId this web component lives in (when\r\n * mounted inside a managed-layout `kind: 'component'` panel). `null`\r\n * outside a managed-layout host.\r\n */\r\nexport const PANEL_ID_PROVIDER = Symbol('wippy:panel-id') as InjectionKey<string | null>\r\n\r\n/**\r\n * Injection key for the panel-bound layout bus. Use to publish or\r\n * subscribe to in-tab broadcasts. `null` outside a managed-layout\r\n * host.\r\n */\r\nexport const LAYOUT_BUS_PROVIDER = Symbol('wippy:layout-bus') as InjectionKey<LayoutBusBound | null>\r\n\r\n/**\r\n * Injection key for the panel-scoped `host` wrapper attached by the\r\n * managed-layout shell. Same shape as the iframe-side `host`; layout\r\n * broadcast / send / on are routed through the panel-bound bus so\r\n * sourcePanelId attribution is correct. `null` outside a managed-layout\r\n * host (callers fall back to importing `host` from `@wippy-fe/proxy`).\r\n */\r\nexport const HOST_PROVIDER = Symbol('wippy:host') as InjectionKey<unknown>\r\n\r\n// ── Composables (typed) ──────────────────────────────────────\r\n\r\n/**\r\n * Inject the reactive props ref, typed to your component's props interface.\r\n *\r\n * Must be called inside a Vue component's `setup()` that lives within a `WippyVueElement`.\r\n *\r\n * ```ts\r\n * const props = useProps<ComponentProps>()\r\n * // props is Ref<ComponentProps>\r\n * console.log(props.value.maxFileSize)\r\n * ```\r\n */\r\nexport function useProps<Props>(): Ref<Props> {\r\n const props = inject(PROPS_PROVIDER)\r\n if (!props)\r\n throw new Error('useProps() must be called inside a WippyVueElement')\r\n return props as unknown as Ref<Props>\r\n}\r\n\r\n/**\r\n * Inject the typed event emitter, constrained to your component's event map.\r\n *\r\n * Must be called inside a Vue component's `setup()` that lives within a `WippyVueElement`.\r\n *\r\n * ```ts\r\n * const emit = useEvents<Events>()\r\n * emit('upload-complete', { fileId: '123', status: 'done' }) // fully typed\r\n * ```\r\n */\r\nexport function useEvents<Events>(): <K extends keyof Events>(event: K, detail: Events[K]) => void {\r\n const emit = inject(EVENT_PROVIDER)\r\n if (!emit)\r\n throw new Error('useEvents() must be called inside a WippyVueElement')\r\n return emit as unknown as <K extends keyof Events>(event: K, detail: Events[K]) => void\r\n}\r\n\r\n/**\r\n * Inject the reactive prop validation errors ref.\r\n *\r\n * Must be called inside a Vue component's `setup()` that lives within a `WippyVueElement`.\r\n *\r\n * ```ts\r\n * const errors = usePropsErrors()\r\n * // errors is Ref<string[]>\r\n * ```\r\n */\r\nexport function usePropsErrors(): Ref<string[]> {\r\n const errors = inject(PROPS_ERROR_PROVIDER)\r\n if (!errors)\r\n throw new Error('usePropsErrors() must be called inside a WippyVueElement')\r\n return errors\r\n}\r\n\r\n/**\r\n * Inject the reactive content ref (from child `<template data-type=\"...\">` elements).\r\n *\r\n * Must be called inside a Vue component's `setup()` within a `WippyVueElement`\r\n * that has `contentTemplate` configured.\r\n *\r\n * ```ts\r\n * const content = useContent()\r\n * // content is Ref<string | null>\r\n * ```\r\n */\r\nexport function useContent(): Ref<string | null> {\r\n const content = inject(CONTENT_PROVIDER)\r\n if (!content)\r\n throw new Error('useContent() must be called inside a WippyVueElement with contentTemplate configured')\r\n return content\r\n}\r\n\r\n/**\r\n * Inject the current panelId (from `data-wippy-panel-id` set by the\r\n * managed-layout `ComponentResolver`). Returns `null` outside a\r\n * managed-layout host or when not inside a `kind: 'component'` panel.\r\n *\r\n * **Status: Draft 1 (preview).** Part of the managed-layout API; see\r\n * `managed-layout.md` in the gen-2-chat repo. Field names may change\r\n * between minor releases until a production consumer drives the\r\n * corner cases out.\r\n *\r\n * ```ts\r\n * const panelId = usePanelId()\r\n * if (panelId) console.log('I am the', panelId, 'panel')\r\n * ```\r\n */\r\nexport function usePanelId(): string | null {\r\n return inject(PANEL_ID_PROVIDER, null)\r\n}\r\n\r\n/**\r\n * Inject the panel-bound layout bus. `null` outside a managed-layout\r\n * host. Use to publish on the in-tab bus or subscribe to broadcasts\r\n * targeted at this panel.\r\n *\r\n * **Status: Draft 1 (preview).** Part of the managed-layout API; see\r\n * `managed-layout.md` in the gen-2-chat repo.\r\n *\r\n * ```ts\r\n * const bus = useLayoutBus()\r\n * bus?.subscribe(({ channel, payload, sourcePanelId }) => { ... })\r\n * bus?.broadcast('open-chat', { token: '...' })\r\n * ```\r\n */\r\nexport function useLayoutBus(): LayoutBusBound | null {\r\n return inject(LAYOUT_BUS_PROVIDER, null)\r\n}\r\n\r\n/**\r\n * Inject the panel-scoped `host` wrapper. `null` outside a\r\n * managed-layout host. Subclass code that needs a host in non-layout\r\n * contexts can fall back to `import { host } from '@wippy-fe/proxy'`.\r\n *\r\n * Pass the host shape as the type parameter to access fields like\r\n * `layout.broadcast`. The default `H = unknown` keeps callers honest\r\n * about narrowing before use.\r\n *\r\n * **Status: Draft 1 (preview).** Part of the managed-layout API; see\r\n * `managed-layout.md` in the gen-2-chat repo.\r\n *\r\n * ```ts\r\n * import type { ProxyApiInstance } from '@wippy-fe/proxy'\r\n *\r\n * const host = useHost<ProxyApiInstance['host']>()\r\n * host?.layout.broadcast('open-chat', { token })\r\n * host?.layout.updatePanel('right', { route: '/foo' })\r\n * ```\r\n */\r\nexport function useHost<H = unknown>(): H | null {\r\n return inject(HOST_PROVIDER, null) as H | null\r\n}\r\n\r\n// ── createProviders (typed injection keys) ───────────────────\r\n\r\n/**\r\n * Typed provider keys for a specific component.\r\n */\r\nexport interface TypedProviders<Props, Events> {\r\n EVENT_PROVIDER: InjectionKey<<K extends keyof Events>(event: K, detail: Events[K]) => void>\r\n PROPS_PROVIDER: InjectionKey<Ref<Props>>\r\n PROPS_ERROR_PROVIDER: InjectionKey<Ref<string[]>>\r\n}\r\n\r\n/**\r\n * Creates typed provider injection keys for a specific component.\r\n *\r\n * Use this if you prefer raw `inject(KEY)` over the composable helpers.\r\n * Returns the same Symbol instances with narrowed types.\r\n *\r\n * ```ts\r\n * export const { EVENT_PROVIDER, PROPS_PROVIDER, PROPS_ERROR_PROVIDER } =\r\n * createProviders<ComponentProps, Events>()\r\n * ```\r\n */\r\nexport function createProviders<Props, Events = Record<string, unknown>>(): TypedProviders<Props, Events> {\r\n return {\r\n EVENT_PROVIDER: EVENT_PROVIDER as unknown as TypedProviders<Props, Events>['EVENT_PROVIDER'],\r\n PROPS_PROVIDER: PROPS_PROVIDER as unknown as TypedProviders<Props, Events>['PROPS_PROVIDER'],\r\n PROPS_ERROR_PROVIDER,\r\n }\r\n}\r\n","import type { PiniaPlugin } from 'pinia'\r\nimport type { App, Component, Ref } from 'vue'\r\nimport { getWippyHost, getWippyHostBus, getWippyPanelId, WippyElement } from '@wippy-fe/webcomponent-core'\r\nimport { createPinia, getActivePinia, setActivePinia } from 'pinia'\r\nimport { createApp, ref } from 'vue'\r\nimport { CONTENT_PROVIDER, EVENT_PROVIDER, HOST_PROVIDER, LAYOUT_BUS_PROVIDER, PANEL_ID_PROVIDER, PROPS_ERROR_PROVIDER, PROPS_PROVIDER } from './providers.ts'\r\n\r\n/**\r\n * Vue-specific configuration returned by `static get vueConfig()`.\r\n */\r\nexport interface WippyVueElementConfig {\r\n /** The root Vue component to mount. */\r\n rootComponent: Component\r\n /** Additional Vue plugins to install (beyond Pinia which is always installed). */\r\n plugins?: Array<{ install: (app: App) => void }>\r\n /** Pinia plugins to install (e.g., createWippyPersist()). */\r\n piniaPlugins?: PiniaPlugin[]\r\n /** Extra providers to inject into the Vue app. */\r\n providers?: (app: App, element: WippyVueElement<any, any>) => void\r\n}\r\n\r\n/**\r\n * Vue 3 integration for Wippy web components.\r\n *\r\n * Generic over `Props` (parsed prop object type) and `Events` (event map).\r\n * These flow through to typed hooks, reactive refs, and composable helpers.\r\n *\r\n * Usage:\r\n * ```ts\r\n * class MyElement extends WippyVueElement<MyProps, MyEvents> {\r\n * static get wippyConfig(): WippyElementConfig<MyProps> {\r\n * return { propsSchema: pkg.wippy.props, inlineCss: stylesText }\r\n * }\r\n * static get vueConfig() {\r\n * return { rootComponent: MyApp }\r\n * }\r\n * }\r\n * ```\r\n *\r\n * In Vue components, use the typed composable helpers:\r\n * ```ts\r\n * const props = useProps<MyProps>()\r\n * const emit = useEvents<MyEvents>()\r\n * const errors = usePropsErrors()\r\n * ```\r\n */\r\nexport abstract class WippyVueElement<\r\n Props = Record<string, unknown>,\r\n Events = Record<string, unknown>,\r\n> extends WippyElement<Props, Events> {\r\n private _vueApp: App<Element> | null = null\r\n private _propsRef: Ref<Props> = ref({}) as Ref<Props>\r\n private _errorsRef: Ref<string[]> = ref([])\r\n private _contentRef: Ref<string | null> = ref(null)\r\n /** Cleanup handle for the core-adapter → Vue-ref bridge subscription. */\r\n private _bridgeAbort: AbortController | null = null\r\n\r\n /**\r\n * Override to provide Vue-specific configuration.\r\n */\r\n static get vueConfig(): WippyVueElementConfig {\r\n throw new Error('WippyVueElement subclass must override static get vueConfig()')\r\n }\r\n\r\n protected onMount(\r\n _shadow: ShadowRoot,\r\n container: HTMLElement,\r\n initialProps: Props,\r\n initialErrors: string[],\r\n initialContent?: string | null,\r\n _isRemount?: boolean,\r\n ): void {\r\n // On reconnect (`_isRemount === true`) the previous Vue app was\r\n // already torn down by `onUnmount`, which calls `_vueApp.unmount()`\r\n // and detaches Vue's rendered DOM from the reused container. So we\r\n // can construct a fresh Vue app here — no special-case branch needed.\r\n // If the container ever holds residual children, Vue's mount will\r\n // replace them.\r\n const vueConfig = (this.constructor as typeof WippyVueElement).vueConfig\r\n\r\n // 1. Seed reactive refs from initial state, then bridge to the core\r\n // reactive adapter so subsequent attribute / content changes\r\n // propagate without manual ref writes in `onPropsChanged` /\r\n // `onContentChanged`. The core adapter is the single source of\r\n // truth; the Vue refs are a read-only mirror that consumers reach\r\n // via `useProps()` / `useContent()` / `usePropsErrors()`.\r\n this._propsRef.value = initialProps\r\n this._errorsRef.value = initialErrors\r\n this._contentRef.value = initialContent ?? null\r\n\r\n // Emit initial errors as invalid events\r\n for (const error of initialErrors) {\r\n this.emitEvent('invalid', { message: error })\r\n }\r\n\r\n this._bridgeAbort = new AbortController()\r\n this.reactive.props.subscribe((props, errors) => {\r\n this._propsRef.value = props\r\n this._errorsRef.value = [...errors]\r\n for (const error of errors) {\r\n this.emitEvent('invalid', { message: error })\r\n }\r\n }, { signal: this._bridgeAbort.signal })\r\n\r\n if (this.reactive.content) {\r\n this.reactive.content.subscribe((content) => {\r\n this._contentRef.value = content\r\n }, { signal: this._bridgeAbort.signal })\r\n }\r\n\r\n // 2. Create Vue app + Pinia\r\n // Save and restore the host's activePinia so this web component's\r\n // isolated Pinia instance doesn't contaminate the global scope.\r\n // See: https://pinia.vuejs.org/core-concepts/outside-component-usage\r\n const hostPinia = getActivePinia()\r\n\r\n this._vueApp = createApp(vueConfig.rootComponent)\r\n const pinia = createPinia()\r\n if (vueConfig.piniaPlugins) {\r\n for (const plugin of vueConfig.piniaPlugins)\r\n pinia.use(plugin)\r\n }\r\n this._vueApp.use(pinia)\r\n\r\n // 3. Install extra plugins\r\n if (vueConfig.plugins) {\r\n for (const plugin of vueConfig.plugins) {\r\n this._vueApp.use(plugin)\r\n }\r\n }\r\n\r\n // 4. Provide standard injection keys\r\n this._vueApp.provide(PROPS_PROVIDER, this._propsRef as Ref<Record<string, unknown>>)\r\n this._vueApp.provide(PROPS_ERROR_PROVIDER, this._errorsRef)\r\n this._vueApp.provide(EVENT_PROVIDER, this.emitEvent.bind(this))\r\n this._vueApp.provide(CONTENT_PROVIDER, this._contentRef)\r\n\r\n // 4b. Managed-layout integration. The `ComponentResolver` (host\r\n // side) sets `dataset.wippyPanelId` and `__wippyHostBus` on this\r\n // element BEFORE insertion, so they're available now in\r\n // `connectedCallback`. Outside a managed-layout host both are\r\n // null — composables tolerate the null path.\r\n this._vueApp.provide(PANEL_ID_PROVIDER, getWippyPanelId(this))\r\n this._vueApp.provide(LAYOUT_BUS_PROVIDER, getWippyHostBus(this))\r\n this._vueApp.provide(HOST_PROVIDER, getWippyHost(this))\r\n\r\n // 5. Custom providers\r\n if (vueConfig.providers) {\r\n vueConfig.providers(this._vueApp, this)\r\n }\r\n\r\n // 6. Mount\r\n this._vueApp.mount(container)\r\n\r\n // 7. Restore the host's activePinia — prevents this web component's\r\n // Pinia from being used by unrelated code that calls useStore()\r\n // outside of a component setup context (e.g. axios interceptors).\r\n if (hostPinia)\r\n setActivePinia(hostPinia)\r\n }\r\n\r\n protected onUnmount(): void {\r\n // Tear down the core-adapter bridge BEFORE unmounting Vue, so the\r\n // Vue refs can't be mutated mid-teardown by a stray late notify.\r\n this._bridgeAbort?.abort()\r\n this._bridgeAbort = null\r\n if (this._vueApp) {\r\n this._vueApp.unmount()\r\n this._vueApp = null\r\n }\r\n }\r\n}\r\n","// Providers: base symbols, composables, and createProviders utility\r\nexport {\r\n CONTENT_PROVIDER,\r\n createProviders,\r\n EVENT_PROVIDER,\r\n HOST_PROVIDER,\r\n LAYOUT_BUS_PROVIDER,\r\n PANEL_ID_PROVIDER,\r\n PROPS_ERROR_PROVIDER,\r\n PROPS_PROVIDER,\r\n useContent,\r\n useEvents,\r\n useHost,\r\n useLayoutBus,\r\n usePanelId,\r\n useProps,\r\n usePropsErrors,\r\n} from './providers.ts'\r\nexport type { TypedProviders } from './providers.ts'\r\n\r\n// Vue layer\r\nexport { WippyVueElement } from './vue-element.ts'\r\nexport type { WippyVueElementConfig } from './vue-element.ts'\r\n\r\n// Re-export core for convenience\r\nexport { define, WippyElement } from '@wippy-fe/webcomponent-core'\r\nexport type {\r\n BroadcastEnvelope,\r\n ContentListener,\r\n ContentSubscription,\r\n EventEmitterHandle,\r\n HostCssKey,\r\n LayoutBusBound,\r\n ParseResult,\r\n PropsListener,\r\n PropsSubscription,\r\n ReactiveAdapter,\r\n SubscribeOptions,\r\n WippyElementConfig,\r\n WippyPropDefinition,\r\n WippyPropsSchema,\r\n} from '@wippy-fe/webcomponent-core'\r\n"],"mappings":";;;;;AAEA,SAAS,cAAc;AAKhB,IAAM,iBAAiB,uBAAO,YAAY;AAK1C,IAAM,iBAAiB,uBAAO,aAAa;AAG3C,IAAM,uBAAuB,uBAAO,mBAAmB;AAGvD,IAAM,mBAAmB,uBAAO,eAAe;AAO/C,IAAM,oBAAoB,uBAAO,gBAAgB;AAOjD,IAAM,sBAAsB,uBAAO,kBAAkB;AASrD,IAAM,gBAAgB,uBAAO,YAAY;AAezC,SAAS,WAA8B;AAC5C,QAAM,QAAQ,OAAO,cAAc;AACnC,MAAI,CAAC;AACH,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AAe,aAAa,IAAI,CAAC;AAGtD,QAAI,UAAU,WAAW;AACvB,gBAAU,UAAU,KAAK,SAAS,IAAI;AAAA,IACxC;AAGA,SAAK,QAAQ,MAAM,SAAS;AAK5B,QAAI;AACF,qBAAe,SAAS;AAAA,EAC5B;AAAA,EAEU,YAAkB;AAG1B,SAAK,cAAc,MAAM;AACzB,SAAK,eAAe;AACpB,QAAI,KAAK,SAAS;AAChB,WAAK,QAAQ,QAAQ;AACrB,WAAK,UAAU;AAAA,IACjB;AAAA,EACF;AACF;;;AClJA,SAAS,QAAQ,gBAAAA,qBAAoB;","names":["WippyElement"]}
1
+ {"version":3,"sources":["../src/providers.ts","../src/vue-element.ts","../src/index.ts"],"sourcesContent":["import type { LayoutBusBound } from '@wippy-fe/webcomponent-core'\r\nimport type { InjectionKey, Ref } from 'vue'\r\nimport { inject } from 'vue'\r\n\r\n// ── Base injection keys (untyped) ────────────────────────────\r\n\r\n/** Injection key for the event emitter function. */\r\nexport const EVENT_PROVIDER = Symbol('wippy:emit') as InjectionKey<\r\n (event: string, detail?: unknown) => void\r\n>\r\n\r\n/** Injection key for the reactive props ref. */\r\nexport const PROPS_PROVIDER = Symbol('wippy:props') as InjectionKey<Ref<Record<string, unknown>>>\r\n\r\n/** Injection key for the reactive props error ref. */\r\nexport const PROPS_ERROR_PROVIDER = Symbol('wippy:props_error') as InjectionKey<Ref<string[]>>\r\n\r\n/** Injection key for reactive content from child <template data-type=\"...\"> elements. */\r\nexport const CONTENT_PROVIDER = Symbol('wippy:content') as InjectionKey<Ref<string | null>>\r\n\r\n/**\r\n * Injection key for the panelId this web component lives in (when\r\n * mounted inside a managed-layout `kind: 'component'` panel). `null`\r\n * outside a managed-layout host.\r\n */\r\nexport const PANEL_ID_PROVIDER = Symbol('wippy:panel-id') as InjectionKey<string | null>\r\n\r\n/**\r\n * Injection key for the panel-bound layout bus. Use to publish or\r\n * subscribe to in-tab broadcasts. `null` outside a managed-layout\r\n * host.\r\n */\r\nexport const LAYOUT_BUS_PROVIDER = Symbol('wippy:layout-bus') as InjectionKey<LayoutBusBound | null>\r\n\r\n/**\r\n * Injection key for the panel-scoped `host` wrapper attached by the\r\n * managed-layout shell. Same shape as the iframe-side `host`; layout\r\n * broadcast / send / on are routed through the panel-bound bus so\r\n * sourcePanelId attribution is correct. `null` outside a managed-layout\r\n * host (callers fall back to importing `host` from `@wippy-fe/proxy`).\r\n */\r\nexport const HOST_PROVIDER = Symbol('wippy:host') as InjectionKey<unknown>\r\n\r\n// ── Composables (typed) ──────────────────────────────────────\r\n\r\n/**\r\n * Inject the reactive props ref, typed to your component's props interface.\r\n *\r\n * Must be called inside a Vue component's `setup()` that lives within a `WippyVueElement`.\r\n *\r\n * ```ts\r\n * const props = useProps<ComponentProps>()\r\n * // props is Ref<ComponentProps>\r\n * console.log(props.value.maxFileSize)\r\n * ```\r\n */\r\nexport function useProps<Props>(): Ref<Props> {\r\n const props = inject(PROPS_PROVIDER)\r\n if (!props)\r\n throw new Error('useProps() must be called inside a WippyVueElement')\r\n return props as unknown as Ref<Props>\r\n}\r\n\r\n/**\r\n * Inject the typed event emitter, constrained to your component's event map.\r\n *\r\n * Must be called inside a Vue component's `setup()` that lives within a `WippyVueElement`.\r\n *\r\n * ```ts\r\n * const emit = useEvents<Events>()\r\n * emit('upload-complete', { fileId: '123', status: 'done' }) // fully typed\r\n * ```\r\n */\r\nexport function useEvents<Events>(): <K extends keyof Events>(event: K, detail: Events[K]) => void {\r\n const emit = inject(EVENT_PROVIDER)\r\n if (!emit)\r\n throw new Error('useEvents() must be called inside a WippyVueElement')\r\n return emit as unknown as <K extends keyof Events>(event: K, detail: Events[K]) => void\r\n}\r\n\r\n/**\r\n * Inject the reactive prop validation errors ref.\r\n *\r\n * Must be called inside a Vue component's `setup()` that lives within a `WippyVueElement`.\r\n *\r\n * ```ts\r\n * const errors = usePropsErrors()\r\n * // errors is Ref<string[]>\r\n * ```\r\n */\r\nexport function usePropsErrors(): Ref<string[]> {\r\n const errors = inject(PROPS_ERROR_PROVIDER)\r\n if (!errors)\r\n throw new Error('usePropsErrors() must be called inside a WippyVueElement')\r\n return errors\r\n}\r\n\r\n/**\r\n * Inject the reactive content ref (from child `<template data-type=\"...\">` elements).\r\n *\r\n * Must be called inside a Vue component's `setup()` within a `WippyVueElement`\r\n * that has `contentTemplate` configured.\r\n *\r\n * ```ts\r\n * const content = useContent()\r\n * // content is Ref<string | null>\r\n * ```\r\n */\r\nexport function useContent(): Ref<string | null> {\r\n const content = inject(CONTENT_PROVIDER)\r\n if (!content)\r\n throw new Error('useContent() must be called inside a WippyVueElement with contentTemplate configured')\r\n return content\r\n}\r\n\r\n/**\r\n * Inject the current panelId (from `data-wippy-panel-id` set by the\r\n * managed-layout `ComponentResolver`). Returns `null` outside a\r\n * managed-layout host or when not inside a `kind: 'component'` panel.\r\n *\r\n * **Status: Draft 1 (preview).** Part of the managed-layout API; see\r\n * `managed-layout.md` in the gen-2-chat repo. Field names may change\r\n * between minor releases until a production consumer drives the\r\n * corner cases out.\r\n *\r\n * ```ts\r\n * const panelId = usePanelId()\r\n * if (panelId) console.log('I am the', panelId, 'panel')\r\n * ```\r\n */\r\nexport function usePanelId(): string | null {\r\n return inject(PANEL_ID_PROVIDER, null)\r\n}\r\n\r\n/**\r\n * Inject the panel-bound layout bus. `null` outside a managed-layout\r\n * host. Use to publish on the in-tab bus or subscribe to broadcasts\r\n * targeted at this panel.\r\n *\r\n * **Status: Draft 1 (preview).** Part of the managed-layout API; see\r\n * `managed-layout.md` in the gen-2-chat repo.\r\n *\r\n * ```ts\r\n * const bus = useLayoutBus()\r\n * bus?.subscribe(({ channel, payload, sourcePanelId }) => { ... })\r\n * bus?.broadcast('open-chat', { token: '...' })\r\n * ```\r\n */\r\nexport function useLayoutBus(): LayoutBusBound | null {\r\n return inject(LAYOUT_BUS_PROVIDER, null)\r\n}\r\n\r\n/**\r\n * Inject the panel-scoped `host` wrapper. `null` outside a\r\n * managed-layout host. Subclass code that needs a host in non-layout\r\n * contexts can fall back to `import { host } from '@wippy-fe/proxy'`.\r\n *\r\n * Pass the host shape as the type parameter to access fields like\r\n * `layout.broadcast`. The default `H = unknown` keeps callers honest\r\n * about narrowing before use.\r\n *\r\n * **Status: Draft 1 (preview).** Part of the managed-layout API; see\r\n * `managed-layout.md` in the gen-2-chat repo.\r\n *\r\n * ```ts\r\n * import type { ProxyApiInstance } from '@wippy-fe/proxy'\r\n *\r\n * const host = useHost<ProxyApiInstance['host']>()\r\n * host?.layout.broadcast('open-chat', { token })\r\n * host?.layout.updatePanel('right', { route: '/foo' })\r\n * ```\r\n */\r\nexport function useHost<H = unknown>(): H | null {\r\n return inject(HOST_PROVIDER, null) as H | null\r\n}\r\n\r\n// ── createProviders (typed injection keys) ───────────────────\r\n\r\n/**\r\n * Typed provider keys for a specific component.\r\n */\r\nexport interface TypedProviders<Props, Events> {\r\n EVENT_PROVIDER: InjectionKey<<K extends keyof Events>(event: K, detail: Events[K]) => void>\r\n PROPS_PROVIDER: InjectionKey<Ref<Props>>\r\n PROPS_ERROR_PROVIDER: InjectionKey<Ref<string[]>>\r\n}\r\n\r\n/**\r\n * Creates typed provider injection keys for a specific component.\r\n *\r\n * Use this if you prefer raw `inject(KEY)` over the composable helpers.\r\n * Returns the same Symbol instances with narrowed types.\r\n *\r\n * ```ts\r\n * export const { EVENT_PROVIDER, PROPS_PROVIDER, PROPS_ERROR_PROVIDER } =\r\n * createProviders<ComponentProps, Events>()\r\n * ```\r\n */\r\nexport function createProviders<Props, Events = Record<string, unknown>>(): TypedProviders<Props, Events> {\r\n return {\r\n EVENT_PROVIDER: EVENT_PROVIDER as unknown as TypedProviders<Props, Events>['EVENT_PROVIDER'],\r\n PROPS_PROVIDER: PROPS_PROVIDER as unknown as TypedProviders<Props, Events>['PROPS_PROVIDER'],\r\n PROPS_ERROR_PROVIDER,\r\n }\r\n}\r\n","import type { PiniaPlugin } from 'pinia'\r\nimport type { App, Component, Ref } from 'vue'\r\nimport { getWippyHost, getWippyHostBus, getWippyPanelId, WippyElement } from '@wippy-fe/webcomponent-core'\r\nimport { createPinia, getActivePinia, setActivePinia } from 'pinia'\r\nimport { createApp, ref } from 'vue'\r\nimport { CONTENT_PROVIDER, EVENT_PROVIDER, HOST_PROVIDER, LAYOUT_BUS_PROVIDER, PANEL_ID_PROVIDER, PROPS_ERROR_PROVIDER, PROPS_PROVIDER } from './providers.ts'\r\n\r\n/**\r\n * The heavy half of a Vue element's config — the root component, its plugins,\r\n * and providers. Either supplied eagerly on `WippyVueElementConfig` or returned\r\n * by `lazyConfig()` from a dynamically-imported chunk (so the element shell can\r\n * stay tiny and load the framework + component tree on first connect).\r\n */\r\nexport interface WippyVueMountConfig {\r\n /** The root Vue component to mount. */\r\n rootComponent: Component\r\n /** Additional Vue plugins to install (beyond Pinia which is always installed). */\r\n plugins?: Array<{ install: (app: App) => void }>\r\n /** Pinia plugins to install (e.g., createWippyPersist()). */\r\n piniaPlugins?: PiniaPlugin[]\r\n /** Extra providers to inject into the Vue app. */\r\n providers?: (app: App, element: WippyVueElement<any, any>) => void\r\n}\r\n\r\n/**\r\n * Vue-specific configuration returned by `static get vueConfig()`.\r\n *\r\n * Provide EITHER an eager `rootComponent` (+ optional plugins/providers) for a\r\n * normal element, OR `lazyConfig` for a thin shell that defers the heavy parts:\r\n * when `lazyConfig` is set and `rootComponent` is omitted, `onMount` shows a\r\n * `<wippy-loading>` placeholder, awaits `lazyConfig()` (typically `() =>\r\n * import('./internals').then(m => ({ rootComponent: m.Root, providers: m.boot }))`),\r\n * then mounts. The props/events bridge + lifecycle stay here, so the lazily\r\n * imported chunk only carries the framework + component tree.\r\n */\r\nexport interface WippyVueElementConfig extends Partial<WippyVueMountConfig> {\r\n /** Lazily resolve the mount config (root + plugins + providers) on first connect. */\r\n lazyConfig?: () => Promise<WippyVueMountConfig>\r\n}\r\n\r\n/**\r\n * Vue 3 integration for Wippy web components.\r\n *\r\n * Generic over `Props` (parsed prop object type) and `Events` (event map).\r\n * These flow through to typed hooks, reactive refs, and composable helpers.\r\n *\r\n * Usage:\r\n * ```ts\r\n * class MyElement extends WippyVueElement<MyProps, MyEvents> {\r\n * static get wippyConfig(): WippyElementConfig<MyProps> {\r\n * return { propsSchema: pkg.wippy.props, inlineCss: stylesText }\r\n * }\r\n * static get vueConfig() {\r\n * return { rootComponent: MyApp }\r\n * }\r\n * }\r\n * ```\r\n *\r\n * In Vue components, use the typed composable helpers:\r\n * ```ts\r\n * const props = useProps<MyProps>()\r\n * const emit = useEvents<MyEvents>()\r\n * const errors = usePropsErrors()\r\n * ```\r\n */\r\nexport abstract class WippyVueElement<\r\n Props = Record<string, unknown>,\r\n Events = Record<string, unknown>,\r\n> extends WippyElement<Props, Events> {\r\n private _vueApp: App<Element> | null = null\r\n private _propsRef: Ref<Props> = ref({}) as Ref<Props>\r\n private _errorsRef: Ref<string[]> = ref([])\r\n private _contentRef: Ref<string | null> = ref(null)\r\n /** Cleanup handle for the core-adapter → Vue-ref bridge subscription. */\r\n private _bridgeAbort: AbortController | null = null\r\n\r\n /**\r\n * Override to provide Vue-specific configuration.\r\n */\r\n static get vueConfig(): WippyVueElementConfig {\r\n throw new Error('WippyVueElement subclass must override static get vueConfig()')\r\n }\r\n\r\n protected onMount(\r\n _shadow: ShadowRoot,\r\n container: HTMLElement,\r\n initialProps: Props,\r\n initialErrors: string[],\r\n initialContent?: string | null,\r\n _isRemount?: boolean,\r\n ): void {\r\n // On reconnect (`_isRemount === true`) the previous Vue app was\r\n // already torn down by `onUnmount`, which calls `_vueApp.unmount()`\r\n // and detaches Vue's rendered DOM from the reused container. So we\r\n // can construct a fresh Vue app here — no special-case branch needed.\r\n // If the container ever holds residual children, Vue's mount will\r\n // replace them.\r\n const vueConfig = (this.constructor as typeof WippyVueElement).vueConfig\r\n\r\n // 1. Seed reactive refs from initial state, then bridge to the core\r\n // reactive adapter so subsequent attribute / content changes\r\n // propagate without manual ref writes in `onPropsChanged` /\r\n // `onContentChanged`. The core adapter is the single source of\r\n // truth; the Vue refs are a read-only mirror that consumers reach\r\n // via `useProps()` / `useContent()` / `usePropsErrors()`.\r\n this._propsRef.value = initialProps\r\n this._errorsRef.value = initialErrors\r\n this._contentRef.value = initialContent ?? null\r\n\r\n // Emit initial errors as invalid events\r\n for (const error of initialErrors) {\r\n this.emitEvent('invalid', { message: error })\r\n }\r\n\r\n const bridgeAbort = new AbortController()\r\n this._bridgeAbort = bridgeAbort\r\n this.reactive.props.subscribe((props, errors) => {\r\n this._propsRef.value = props\r\n this._errorsRef.value = [...errors]\r\n for (const error of errors) {\r\n this.emitEvent('invalid', { message: error })\r\n }\r\n }, { signal: bridgeAbort.signal })\r\n\r\n if (this.reactive.content) {\r\n this.reactive.content.subscribe((content) => {\r\n this._contentRef.value = content\r\n }, { signal: bridgeAbort.signal })\r\n }\r\n\r\n // 2. Create + mount the Vue app from the resolved mount config. Factored\r\n // out so it runs either synchronously (eager `rootComponent`) or after\r\n // `lazyConfig()` resolves (thin-shell path).\r\n const mountApp = (mountConfig: WippyVueMountConfig): void => {\r\n // Bail if the element was disconnected while `lazyConfig()` was in flight.\r\n if (bridgeAbort.signal.aborted)\r\n return\r\n\r\n // Save and restore the host's activePinia so this web component's\r\n // isolated Pinia instance doesn't contaminate the global scope.\r\n // See: https://pinia.vuejs.org/core-concepts/outside-component-usage\r\n const hostPinia = getActivePinia()\r\n\r\n const app = createApp(mountConfig.rootComponent)\r\n this._vueApp = app\r\n const pinia = createPinia()\r\n if (mountConfig.piniaPlugins) {\r\n for (const plugin of mountConfig.piniaPlugins)\r\n pinia.use(plugin)\r\n }\r\n app.use(pinia)\r\n\r\n // Install extra plugins\r\n if (mountConfig.plugins) {\r\n for (const plugin of mountConfig.plugins)\r\n app.use(plugin)\r\n }\r\n\r\n // Provide standard injection keys\r\n app.provide(PROPS_PROVIDER, this._propsRef as Ref<Record<string, unknown>>)\r\n app.provide(PROPS_ERROR_PROVIDER, this._errorsRef)\r\n app.provide(EVENT_PROVIDER, this.emitEvent.bind(this))\r\n app.provide(CONTENT_PROVIDER, this._contentRef)\r\n\r\n // Managed-layout integration. The `ComponentResolver` (host side) sets\r\n // `dataset.wippyPanelId` and `__wippyHostBus` on this element BEFORE\r\n // insertion, so they're available now. Outside a managed-layout host\r\n // both are null — composables tolerate the null path.\r\n app.provide(PANEL_ID_PROVIDER, getWippyPanelId(this))\r\n app.provide(LAYOUT_BUS_PROVIDER, getWippyHostBus(this))\r\n app.provide(HOST_PROVIDER, getWippyHost(this))\r\n\r\n // Custom providers\r\n if (mountConfig.providers)\r\n mountConfig.providers(app, this)\r\n\r\n app.mount(container)\r\n\r\n // Restore the host's activePinia — prevents this web component's Pinia\r\n // from being used by unrelated code that calls useStore() outside of a\r\n // component setup context (e.g. axios interceptors).\r\n if (hostPinia)\r\n setActivePinia(hostPinia)\r\n }\r\n\r\n // 3. Eager `rootComponent` → mount now. Otherwise `lazyConfig` → show a\r\n // `<wippy-loading>` placeholder and mount once the heavy chunk resolves.\r\n if (vueConfig.rootComponent) {\r\n mountApp(vueConfig as WippyVueMountConfig)\r\n }\r\n else if (vueConfig.lazyConfig) {\r\n const loader = document.createElement('wippy-loading')\r\n loader.setAttribute('no-bg', '')\r\n container.appendChild(loader)\r\n vueConfig.lazyConfig()\r\n .then((mountConfig) => {\r\n if (bridgeAbort.signal.aborted)\r\n return\r\n loader.remove()\r\n mountApp(mountConfig)\r\n })\r\n .catch((err) => {\r\n if (bridgeAbort.signal.aborted)\r\n return\r\n // The lazy chunk failed to load (offline / 404 / bad bundle). Swap the\r\n // spinner for a visible <wippy-error> so the element doesn't sit on a\r\n // perpetual loading placeholder; also emit `error` for programmatic\r\n // consumers. (Both wippy-loading/wippy-error are registered together\r\n // by loading.js, which is injected alongside this shell.)\r\n const message = err instanceof Error ? err.message : String(err)\r\n const errorEl = document.createElement('wippy-error')\r\n errorEl.setAttribute('title', 'Failed to load')\r\n errorEl.setAttribute('message', message)\r\n loader.replaceWith(errorEl)\r\n this.emitEvent('error', { message })\r\n })\r\n }\r\n else {\r\n throw new Error('WippyVueElement vueConfig must provide rootComponent or lazyConfig')\r\n }\r\n }\r\n\r\n protected onUnmount(): void {\r\n // Tear down the core-adapter bridge BEFORE unmounting Vue, so the\r\n // Vue refs can't be mutated mid-teardown by a stray late notify.\r\n this._bridgeAbort?.abort()\r\n this._bridgeAbort = null\r\n if (this._vueApp) {\r\n this._vueApp.unmount()\r\n this._vueApp = null\r\n }\r\n }\r\n}\r\n","// Providers: base symbols, composables, and createProviders utility\r\nexport {\r\n CONTENT_PROVIDER,\r\n createProviders,\r\n EVENT_PROVIDER,\r\n HOST_PROVIDER,\r\n LAYOUT_BUS_PROVIDER,\r\n PANEL_ID_PROVIDER,\r\n PROPS_ERROR_PROVIDER,\r\n PROPS_PROVIDER,\r\n useContent,\r\n useEvents,\r\n useHost,\r\n useLayoutBus,\r\n usePanelId,\r\n useProps,\r\n usePropsErrors,\r\n} from './providers.ts'\r\nexport type { TypedProviders } from './providers.ts'\r\n\r\n// Vue layer\r\nexport { WippyVueElement } from './vue-element.ts'\r\nexport type { WippyVueElementConfig, WippyVueMountConfig } from './vue-element.ts'\r\n\r\n// Re-export core for convenience\r\nexport { define, WippyElement } from '@wippy-fe/webcomponent-core'\r\nexport type {\r\n BroadcastEnvelope,\r\n ContentListener,\r\n ContentSubscription,\r\n EventEmitterHandle,\r\n HostCssKey,\r\n LayoutBusBound,\r\n ParseResult,\r\n PropsListener,\r\n PropsSubscription,\r\n ReactiveAdapter,\r\n SubscribeOptions,\r\n WippyElementConfig,\r\n WippyPropDefinition,\r\n WippyPropsSchema,\r\n} from '@wippy-fe/webcomponent-core'\r\n"],"mappings":";;;;;AAEA,SAAS,cAAc;AAKhB,IAAM,iBAAiB,uBAAO,YAAY;AAK1C,IAAM,iBAAiB,uBAAO,aAAa;AAG3C,IAAM,uBAAuB,uBAAO,mBAAmB;AAGvD,IAAM,mBAAmB,uBAAO,eAAe;AAO/C,IAAM,oBAAoB,uBAAO,gBAAgB;AAOjD,IAAM,sBAAsB,uBAAO,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36",
3
+ "version": "0.0.37",
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
  "license": "UNLICENSED",
@@ -20,14 +20,14 @@
20
20
  "dist/"
21
21
  ],
22
22
  "dependencies": {
23
- "@wippy-fe/webcomponent-core": "^0.0.36"
23
+ "@wippy-fe/webcomponent-core": "^0.0.37"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@iconify/vue": "^5.0.0",
27
27
  "pinia": "^2.1.0",
28
28
  "vue": "^3.5.0",
29
- "@wippy-fe/proxy": "^0.0.36",
30
- "@wippy-fe/shared": "^0.0.36"
29
+ "@wippy-fe/proxy": "^0.0.37",
30
+ "@wippy-fe/shared": "^0.0.37"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsup",