@wippy-fe/vue-utils 0.0.35
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 +24 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/package.json +25 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime warn-handler that filters `[Vue warn]: Failed to resolve component:`
|
|
3
|
+
* for tags registered via `customElements.define` (system + dynamic autoload).
|
|
4
|
+
* Build-time `compilerOptions.isCustomElement` can't enumerate dynamic
|
|
5
|
+
* registrations; this can. PascalCase typos still pass through.
|
|
6
|
+
*/
|
|
7
|
+
interface VueAppLike {
|
|
8
|
+
config: {
|
|
9
|
+
warnHandler?: ((msg: string, instance: unknown, trace: string) => void) | null;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
declare const VUE_WARN_SUPPRESSOR_INSTALLED_MARKER: unique symbol;
|
|
13
|
+
/**
|
|
14
|
+
* Installs a Vue warn-handler on `app` that suppresses component-resolution
|
|
15
|
+
* warnings for kebab-named tags (registered or pending registration).
|
|
16
|
+
* Call once after `createApp` — typically in your app bootstrap.
|
|
17
|
+
*
|
|
18
|
+
* Suppressed warnings do NOT reach `previous`. If you need a telemetry tap
|
|
19
|
+
* that sees every warning, install it FIRST so it becomes `previous` for
|
|
20
|
+
* non-suppressed warnings only.
|
|
21
|
+
*/
|
|
22
|
+
declare function installVueWarnSuppressor(app: VueAppLike): void;
|
|
23
|
+
|
|
24
|
+
export { VUE_WARN_SUPPRESSOR_INSTALLED_MARKER, installVueWarnSuppressor };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// src/vue-warn-suppressor.ts
|
|
2
|
+
var FAILED_TO_RESOLVE_RE = /Failed to resolve component:\s*([\w-]+)/;
|
|
3
|
+
var CUSTOM_ELEMENT_NAME_RE = /^[a-z][a-z0-9]*-[a-z0-9-]*$/;
|
|
4
|
+
var VUE_WARN_SUPPRESSOR_INSTALLED_MARKER = /* @__PURE__ */ Symbol.for("@wippy-fe/proxy/vue-warn-suppressor-installed");
|
|
5
|
+
function safeStr(v) {
|
|
6
|
+
if (typeof v === "string")
|
|
7
|
+
return v;
|
|
8
|
+
try {
|
|
9
|
+
return String(v);
|
|
10
|
+
} catch {
|
|
11
|
+
return "<non-serializable warning>";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function installVueWarnSuppressor(app) {
|
|
15
|
+
const cfg = app.config;
|
|
16
|
+
if (cfg[VUE_WARN_SUPPRESSOR_INSTALLED_MARKER])
|
|
17
|
+
return;
|
|
18
|
+
try {
|
|
19
|
+
cfg[VUE_WARN_SUPPRESSOR_INSTALLED_MARKER] = true;
|
|
20
|
+
} catch {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const previous = app.config.warnHandler;
|
|
24
|
+
app.config.warnHandler = (rawMsg, instance, rawTrace) => {
|
|
25
|
+
const msg = safeStr(rawMsg);
|
|
26
|
+
const trace = safeStr(rawTrace);
|
|
27
|
+
const match = msg.match(FAILED_TO_RESOLVE_RE);
|
|
28
|
+
if (match) {
|
|
29
|
+
const tag = match[1];
|
|
30
|
+
if (typeof customElements !== "undefined" && customElements.get(tag))
|
|
31
|
+
return;
|
|
32
|
+
if (CUSTOM_ELEMENT_NAME_RE.test(tag))
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (previous) {
|
|
36
|
+
try {
|
|
37
|
+
previous(msg, instance, trace);
|
|
38
|
+
} catch (err) {
|
|
39
|
+
if (typeof console !== "undefined")
|
|
40
|
+
console.error("[wippy-fe/vue-utils] previous warn-handler threw:", err);
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (typeof console !== "undefined") {
|
|
45
|
+
if (trace)
|
|
46
|
+
console.warn(`[Vue warn]: ${msg}`, `
|
|
47
|
+
${trace}`);
|
|
48
|
+
else
|
|
49
|
+
console.warn(`[Vue warn]: ${msg}`);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
VUE_WARN_SUPPRESSOR_INSTALLED_MARKER,
|
|
55
|
+
installVueWarnSuppressor
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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: unknown, 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(app: VueAppLike): void {\n const cfg = app.config as { warnHandler?: VueAppLike['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":";AAaA,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,yBAAyB,KAAuB;AAC9D,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
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wippy-fe/vue-utils",
|
|
3
|
+
"version": "0.0.35",
|
|
4
|
+
"description": "Runtime Vue utilities for Wippy micro-frontend apps — warn suppressor and other opt-in Vue helpers.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"module": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"package.json",
|
|
20
|
+
"dist/"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsup"
|
|
24
|
+
}
|
|
25
|
+
}
|