@ohbug/vue 2.0.0 → 2.0.3

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.
@@ -0,0 +1,15 @@
1
+ import { OhbugBaseDetail, OhbugClient } from '@ohbug/types';
2
+ import { Plugin } from 'vue';
3
+
4
+ interface VueErrorDetail extends OhbugBaseDetail {
5
+ name: string;
6
+ stack?: string;
7
+ errorInfo: string;
8
+ component?: string;
9
+ file?: string;
10
+ props?: Record<string, any>;
11
+ }
12
+
13
+ declare function createVueClient(client: OhbugClient): Plugin;
14
+
15
+ export { VueErrorDetail, createVueClient as default };
package/dist/index.js CHANGED
@@ -1,75 +1 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/index.ts
20
- var src_exports = {};
21
- __export(src_exports, {
22
- default: () => createVueClient
23
- });
24
- module.exports = __toCommonJS(src_exports);
25
-
26
- // src/install.ts
27
- var import_core = require("@ohbug/core");
28
- var getComponent = (instance) => {
29
- if ((instance == null ? void 0 : instance.$root) === instance)
30
- return { component: "Root" };
31
- const options = instance == null ? void 0 : instance.$options;
32
- const component = options == null ? void 0 : options.name;
33
- const file = options == null ? void 0 : options.__file;
34
- return {
35
- component,
36
- file
37
- };
38
- };
39
- function install(client, Vue) {
40
- const prev = Vue.config.errorHandler;
41
- const handler = (error, instance, info) => {
42
- const { component, file } = getComponent(instance);
43
- const detail = {
44
- name: error.name,
45
- message: error.message,
46
- stack: error.stack,
47
- errorInfo: info,
48
- component,
49
- file,
50
- props: instance ? instance.$options.propsData : void 0
51
- };
52
- const event = client.createEvent({
53
- category: "error",
54
- type: import_core.EventTypes.VUE,
55
- detail
56
- });
57
- client.notify(event);
58
- if (typeof console !== "undefined" && typeof console.error === "function")
59
- console.error(error);
60
- if (typeof prev === "function")
61
- prev(error, instance, info);
62
- };
63
- Vue.config.errorHandler = handler;
64
- }
65
-
66
- // src/index.ts
67
- function createVueClient(client) {
68
- return {
69
- install: (app) => {
70
- install(client, app);
71
- }
72
- };
73
- }
74
- // Annotate the CommonJS export names for ESM import in node:
75
- 0 && (module.exports = {});
1
+ var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var h=(o,e)=>{for(var r in e)l(o,r,{get:e[r],enumerable:!0})},C=(o,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of b(e))!d.call(o,t)&&t!==r&&l(o,t,{get:()=>e[t],enumerable:!(n=y(e,t))||n.enumerable});return o};var E=o=>C(l({},"__esModule",{value:!0}),o);var O={};h(O,{default:()=>s});module.exports=E(O);var u=require("@ohbug/core"),v=o=>{if((o==null?void 0:o.$root)===o)return{component:"Root"};let e=o==null?void 0:o.$options,r=e==null?void 0:e.name,n=e==null?void 0:e.__file;return{component:r,file:n}};function f(o,e){let r=e.config.errorHandler,n=(t,p,i)=>{let{component:m,file:a}=v(p),g={name:t.name,message:t.message,stack:t.stack,errorInfo:i,component:m,file:a,props:p?p.$options.propsData:void 0},c=o.createEvent({category:"error",type:u.EventTypes.VUE,detail:g});o.notify(c),typeof console<"u"&&typeof console.error=="function"&&console.error(t),typeof r=="function"&&r(t,p,i)};e.config.errorHandler=n}function s(o){return{install:e=>{f(o,e)}}}0&&(module.exports={});
package/dist/index.mjs CHANGED
@@ -1,51 +1 @@
1
- // src/install.ts
2
- import { EventTypes } from "@ohbug/core";
3
- var getComponent = (instance) => {
4
- if ((instance == null ? void 0 : instance.$root) === instance)
5
- return { component: "Root" };
6
- const options = instance == null ? void 0 : instance.$options;
7
- const component = options == null ? void 0 : options.name;
8
- const file = options == null ? void 0 : options.__file;
9
- return {
10
- component,
11
- file
12
- };
13
- };
14
- function install(client, Vue) {
15
- const prev = Vue.config.errorHandler;
16
- const handler = (error, instance, info) => {
17
- const { component, file } = getComponent(instance);
18
- const detail = {
19
- name: error.name,
20
- message: error.message,
21
- stack: error.stack,
22
- errorInfo: info,
23
- component,
24
- file,
25
- props: instance ? instance.$options.propsData : void 0
26
- };
27
- const event = client.createEvent({
28
- category: "error",
29
- type: EventTypes.VUE,
30
- detail
31
- });
32
- client.notify(event);
33
- if (typeof console !== "undefined" && typeof console.error === "function")
34
- console.error(error);
35
- if (typeof prev === "function")
36
- prev(error, instance, info);
37
- };
38
- Vue.config.errorHandler = handler;
39
- }
40
-
41
- // src/index.ts
42
- function createVueClient(client) {
43
- return {
44
- install: (app) => {
45
- install(client, app);
46
- }
47
- };
48
- }
49
- export {
50
- createVueClient as default
51
- };
1
+ import{EventTypes as c}from"@ohbug/core";var y=e=>{if((e==null?void 0:e.$root)===e)return{component:"Root"};let o=e==null?void 0:e.$options,r=o==null?void 0:o.name,p=o==null?void 0:o.__file;return{component:r,file:p}};function i(e,o){let r=o.config.errorHandler,p=(t,n,l)=>{let{component:u,file:f}=y(n),s={name:t.name,message:t.message,stack:t.stack,errorInfo:l,component:u,file:f,props:n?n.$options.propsData:void 0},m=e.createEvent({category:"error",type:c.VUE,detail:s});e.notify(m),typeof console<"u"&&typeof console.error=="function"&&console.error(t),typeof r=="function"&&r(t,n,l)};o.config.errorHandler=p}function b(e){return{install:o=>{i(e,o)}}}export{b as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohbug/vue",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
4
4
  "description": "Ohbug SDK for Vue",
5
5
  "license": "Apache-2.0",
6
6
  "author": "chenyueban <jasonchan0527@gmail.com>",
@@ -23,16 +23,15 @@
23
23
  }
24
24
  },
25
25
  "files": [
26
- "dist",
27
- "src"
26
+ "dist"
28
27
  ],
29
28
  "sideEffects": false,
30
29
  "peerDependencies": {
31
30
  "vue": "^3.0.0"
32
31
  },
33
32
  "dependencies": {
34
- "@ohbug/core": "2.0.0",
35
- "@ohbug/types": "2.0.0"
33
+ "@ohbug/core": "2.0.3",
34
+ "@ohbug/types": "2.0.3"
36
35
  },
37
36
  "devDependencies": {
38
37
  "vue": "^3.2.33"
package/src/index.ts DELETED
@@ -1,13 +0,0 @@
1
- import type { OhbugClient } from '@ohbug/types'
2
- import type { Plugin } from 'vue'
3
- import { install } from './install'
4
-
5
- export type { VueErrorDetail } from './install'
6
-
7
- export default function createVueClient(client: OhbugClient): Plugin {
8
- return {
9
- install: (app) => {
10
- install(client, app)
11
- },
12
- }
13
- }
package/src/install.ts DELETED
@@ -1,58 +0,0 @@
1
- import { EventTypes } from '@ohbug/core'
2
- import type { OhbugBaseDetail, OhbugClient } from '@ohbug/types'
3
- import type { App, ComponentPublicInstance } from 'vue'
4
-
5
- export interface VueErrorDetail extends OhbugBaseDetail {
6
- name: string
7
- stack?: string
8
- errorInfo: string
9
- component?: string
10
- file?: string
11
- props?: Record<string, any>
12
- }
13
-
14
- const getComponent = (instance: ComponentPublicInstance | null) => {
15
- if (instance?.$root === instance)
16
- return { component: 'Root' }
17
-
18
- const options = instance?.$options
19
- const component = options?.name
20
- const file = options?.__file
21
-
22
- return {
23
- component,
24
- file,
25
- }
26
- }
27
-
28
- export function install(client: OhbugClient, Vue: App) {
29
- const prev = Vue.config.errorHandler
30
-
31
- const handler = (error: Error, instance: ComponentPublicInstance | null, info: string) => {
32
- const { component, file } = getComponent(instance)
33
-
34
- const detail: VueErrorDetail = {
35
- name: error.name,
36
- message: error.message,
37
- stack: error.stack,
38
- errorInfo: info,
39
- component,
40
- file,
41
- props: instance ? instance.$options.propsData : undefined,
42
- }
43
- const event = client.createEvent<VueErrorDetail>({
44
- category: 'error',
45
- type: EventTypes.VUE,
46
- detail,
47
- })
48
-
49
- client.notify(event)
50
-
51
- if (typeof console !== 'undefined' && typeof console.error === 'function')
52
- console.error(error)
53
- if (typeof prev === 'function') prev(error, instance, info)
54
- }
55
-
56
- // @ts-expect-error type is not assignable
57
- Vue.config.errorHandler = handler
58
- }