@wippy-fe/vue-utils 0.0.63 → 0.0.65
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 +13 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,19 @@
|
|
|
4
4
|
* Build-time `compilerOptions.isCustomElement` can't enumerate dynamic
|
|
5
5
|
* registrations; this can. PascalCase typos still pass through.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The slice of Vue's `App` this module touches, duck-typed so the package takes no
|
|
9
|
+
* dependency on `vue`.
|
|
10
|
+
*
|
|
11
|
+
* `TInstance` is Vue's `ComponentPublicInstance | null`, inferred from the app that is
|
|
12
|
+
* passed in. A fixed `unknown` here would reject a real `App`: `warnHandler` is a
|
|
13
|
+
* property, so under `strictFunctionTypes` its parameters are compared contravariantly
|
|
14
|
+
* and `(msg, instance: ComponentPublicInstance | null, trace) => void` is not assignable
|
|
15
|
+
* to `(msg, instance: unknown, trace) => void`.
|
|
16
|
+
*/
|
|
17
|
+
interface VueAppLike<TInstance = unknown> {
|
|
8
18
|
config: {
|
|
9
|
-
warnHandler?: ((msg: string, instance:
|
|
19
|
+
warnHandler?: ((msg: string, instance: TInstance, trace: string) => void) | null;
|
|
10
20
|
};
|
|
11
21
|
}
|
|
12
22
|
declare const VUE_WARN_SUPPRESSOR_INSTALLED_MARKER: unique symbol;
|
|
@@ -19,6 +29,6 @@ declare const VUE_WARN_SUPPRESSOR_INSTALLED_MARKER: unique symbol;
|
|
|
19
29
|
* that sees every warning, install it FIRST so it becomes `previous` for
|
|
20
30
|
* non-suppressed warnings only.
|
|
21
31
|
*/
|
|
22
|
-
declare function installVueWarnSuppressor(app: VueAppLike): void;
|
|
32
|
+
declare function installVueWarnSuppressor<TInstance>(app: VueAppLike<TInstance>): void;
|
|
23
33
|
|
|
24
34
|
export { VUE_WARN_SUPPRESSOR_INSTALLED_MARKER, installVueWarnSuppressor };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vue-warn-suppressor.ts"],"sourcesContent":["/**\n * Runtime warn-handler that filters `[Vue warn]: Failed to resolve component:`\n * for tags registered via `customElements.define` (system + dynamic autoload).\n * Build-time `compilerOptions.isCustomElement` can't enumerate dynamic\n * registrations; this can. PascalCase typos still pass through.\n */\n\ninterface VueAppLike {\n config: {\n warnHandler?: ((msg: string, instance:
|
|
1
|
+
{"version":3,"sources":["../src/vue-warn-suppressor.ts"],"sourcesContent":["/**\n * Runtime warn-handler that filters `[Vue warn]: Failed to resolve component:`\n * for tags registered via `customElements.define` (system + dynamic autoload).\n * Build-time `compilerOptions.isCustomElement` can't enumerate dynamic\n * registrations; this can. PascalCase typos still pass through.\n */\n\n/**\n * The slice of Vue's `App` this module touches, duck-typed so the package takes no\n * dependency on `vue`.\n *\n * `TInstance` is Vue's `ComponentPublicInstance | null`, inferred from the app that is\n * passed in. A fixed `unknown` here would reject a real `App`: `warnHandler` is a\n * property, so under `strictFunctionTypes` its parameters are compared contravariantly\n * and `(msg, instance: ComponentPublicInstance | null, trace) => void` is not assignable\n * to `(msg, instance: unknown, trace) => void`.\n */\ninterface VueAppLike<TInstance = unknown> {\n config: {\n warnHandler?: ((msg: string, instance: TInstance, trace: string) => void) | null\n }\n}\n\nconst FAILED_TO_RESOLVE_RE = /Failed to resolve component:\\s*([\\w-]+)/\n\n// Mirror in @wippy-fe/vite-plugin's `validateComponentPackage` — keep in sync.\nconst CUSTOM_ELEMENT_NAME_RE = /^[a-z][a-z0-9]*-[a-z0-9-]*$/\n\n// Symbol.for so dual bundle copies share marker identity across realms.\nexport const VUE_WARN_SUPPRESSOR_INSTALLED_MARKER = Symbol.for('@wippy-fe/proxy/vue-warn-suppressor-installed')\n\nfunction safeStr(v: unknown): string {\n if (typeof v === 'string')\n return v\n try {\n return String(v)\n }\n catch {\n return '<non-serializable warning>'\n }\n}\n\n/**\n * Installs a Vue warn-handler on `app` that suppresses component-resolution\n * warnings for kebab-named tags (registered or pending registration).\n * Call once after `createApp` — typically in your app bootstrap.\n *\n * Suppressed warnings do NOT reach `previous`. If you need a telemetry tap\n * that sees every warning, install it FIRST so it becomes `previous` for\n * non-suppressed warnings only.\n */\nexport function installVueWarnSuppressor<TInstance>(app: VueAppLike<TInstance>): void {\n const cfg = app.config as { warnHandler?: VueAppLike<TInstance>['config']['warnHandler'] } & Record<symbol, unknown>\n if (cfg[VUE_WARN_SUPPRESSOR_INSTALLED_MARKER])\n return\n try {\n cfg[VUE_WARN_SUPPRESSOR_INSTALLED_MARKER] = true\n }\n catch {\n // Frozen config — can't install. Bail without crashing bootstrap.\n return\n }\n\n const previous = app.config.warnHandler\n app.config.warnHandler = (rawMsg, instance, rawTrace) => {\n const msg = safeStr(rawMsg)\n const trace = safeStr(rawTrace)\n const match = msg.match(FAILED_TO_RESOLVE_RE)\n if (match) {\n const tag = match[1]\n if (typeof customElements !== 'undefined' && customElements.get(tag))\n return\n if (CUSTOM_ELEMENT_NAME_RE.test(tag))\n return\n }\n if (previous) {\n // Isolate previous-handler throws — warnHandler runs inside Vue's\n // render path, an uncaught throw would surface as a render error.\n try {\n previous(msg, instance, trace)\n }\n catch (err) {\n if (typeof console !== 'undefined')\n console.error('[wippy-fe/vue-utils] previous warn-handler threw:', err)\n }\n return\n }\n // Vue default: msg + trace as separate args so DevTools formats the stack.\n // Only pass the trace arg when non-empty — matches Vue's own warn format.\n if (typeof console !== 'undefined') {\n if (trace)\n console.warn(`[Vue warn]: ${msg}`, `\\n${trace}`)\n else\n console.warn(`[Vue warn]: ${msg}`)\n }\n }\n}\n"],"mappings":";AAuBA,IAAM,uBAAuB;AAG7B,IAAM,yBAAyB;AAGxB,IAAM,uCAAuC,uBAAO,IAAI,+CAA+C;AAE9G,SAAS,QAAQ,GAAoB;AACnC,MAAI,OAAO,MAAM;AACf,WAAO;AACT,MAAI;AACF,WAAO,OAAO,CAAC;AAAA,EACjB,QACM;AACJ,WAAO;AAAA,EACT;AACF;AAWO,SAAS,yBAAoC,KAAkC;AACpF,QAAM,MAAM,IAAI;AAChB,MAAI,IAAI,oCAAoC;AAC1C;AACF,MAAI;AACF,QAAI,oCAAoC,IAAI;AAAA,EAC9C,QACM;AAEJ;AAAA,EACF;AAEA,QAAM,WAAW,IAAI,OAAO;AAC5B,MAAI,OAAO,cAAc,CAAC,QAAQ,UAAU,aAAa;AACvD,UAAM,MAAM,QAAQ,MAAM;AAC1B,UAAM,QAAQ,QAAQ,QAAQ;AAC9B,UAAM,QAAQ,IAAI,MAAM,oBAAoB;AAC5C,QAAI,OAAO;AACT,YAAM,MAAM,MAAM,CAAC;AACnB,UAAI,OAAO,mBAAmB,eAAe,eAAe,IAAI,GAAG;AACjE;AACF,UAAI,uBAAuB,KAAK,GAAG;AACjC;AAAA,IACJ;AACA,QAAI,UAAU;AAGZ,UAAI;AACF,iBAAS,KAAK,UAAU,KAAK;AAAA,MAC/B,SACO,KAAK;AACV,YAAI,OAAO,YAAY;AACrB,kBAAQ,MAAM,qDAAqD,GAAG;AAAA,MAC1E;AACA;AAAA,IACF;AAGA,QAAI,OAAO,YAAY,aAAa;AAClC,UAAI;AACF,gBAAQ,KAAK,eAAe,GAAG,IAAI;AAAA,EAAK,KAAK,EAAE;AAAA;AAE/C,gBAAQ,KAAK,eAAe,GAAG,EAAE;AAAA,IACrC;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wippy-fe/vue-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.65",
|
|
4
4
|
"description": "Runtime Vue utilities for Wippy micro-frontend apps — warn suppressor and other opt-in Vue helpers.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
"package.json",
|
|
20
20
|
"dist/"
|
|
21
21
|
],
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"vue": "^3.5.39"
|
|
24
|
+
},
|
|
22
25
|
"scripts": {
|
|
23
26
|
"build": "tsup",
|
|
24
27
|
"clean": "rimraf dist"
|