@ohbug/vue 2.0.9 → 2.0.11

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 CHANGED
@@ -16,15 +16,13 @@ pnpm instal @ohbug/browser @ohbug/vue
16
16
  Vue3
17
17
 
18
18
  ```javascript
19
- import Vue from 'vue'
20
- import Ohbug from '@ohbug/browser'
21
- import OhbugVue from '@ohbug/vue'
19
+ import Vue from "vue";
20
+ import Ohbug from "@ohbug/browser";
21
+ import OhbugVue from "@ohbug/vue";
22
22
 
23
- const client = Ohbug.setup({ apiKey: 'YOUR_API_KEY' })
23
+ const client = Ohbug.setup({ apiKey: "YOUR_API_KEY" });
24
24
 
25
- Vue.createApp(App)
26
- .use(OhbugVue(client))
27
- .mount('#app')
25
+ Vue.createApp(App).use(OhbugVue(client)).mount("#app");
28
26
  ```
29
27
 
30
28
  Vue2
@@ -39,6 +37,6 @@ const client = Ohbug.setup({ apiKey: "YOUR_API_KEY" });
39
37
  OhbugVue(client).install(Vue);
40
38
 
41
39
  new Vue({
42
- render: (h) => h(App)
40
+ render: (h) => h(App),
43
41
  }).$mount("#app");
44
42
  ```
package/dist/index.d.mts CHANGED
@@ -1,24 +1,28 @@
1
- import { OhbugBaseDetail, OhbugClient } from '@ohbug/types';
1
+ import { OhbugBaseDetail, OhbugClient } from "@ohbug/types";
2
2
 
3
+ //#region src/types.d.ts
3
4
  interface Vue {
4
- config: {
5
- errorHandler?: any;
6
- warnHandler?: any;
7
- silent?: boolean;
8
- };
5
+ config: {
6
+ errorHandler?: any;
7
+ warnHandler?: any;
8
+ silent?: boolean;
9
+ };
9
10
  }
10
-
11
+ //#endregion
12
+ //#region src/install.d.ts
11
13
  interface VueErrorDetail extends OhbugBaseDetail {
12
- name: string;
13
- stack?: string;
14
- errorInfo: string;
15
- component?: string;
16
- file?: string;
17
- props?: Record<string, any>;
14
+ name: string;
15
+ stack?: string;
16
+ errorInfo: string;
17
+ component?: string;
18
+ file?: string;
19
+ props?: Record<string, any>;
18
20
  }
19
-
21
+ //#endregion
22
+ //#region src/index.d.ts
20
23
  declare function createVueClient(client: OhbugClient): {
21
- install: (app: Vue) => void;
24
+ install: (app: Vue) => void;
22
25
  };
23
-
24
- export { VueErrorDetail, createVueClient as default };
26
+ //#endregion
27
+ export { type VueErrorDetail, createVueClient as default };
28
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,53 +1,47 @@
1
- // src/install.ts
2
1
  import { EventTypes } from "@ohbug/core";
3
- var getComponent = (instance) => {
4
- if ((instance == null ? void 0 : instance.$root) === instance) {
5
- return { component: "Root" };
6
- }
7
- const options = instance == null ? void 0 : instance.$options;
8
- const component = options == null ? void 0 : options.name;
9
- const file = options == null ? void 0 : options.__file;
10
- return {
11
- component,
12
- file
13
- };
2
+ //#region src/install.ts
3
+ const getComponent = (instance) => {
4
+ if (!instance) return {};
5
+ if (instance.$root === instance || instance.$ && instance.$.root === instance.$) return { component: "Root" };
6
+ const type = instance.$?.type;
7
+ const options = instance.$options;
8
+ return {
9
+ component: type?.__name || type?.name || options?.name || void 0,
10
+ file: type?.__file || options?.__file || void 0
11
+ };
14
12
  };
15
13
  function install(client, Vue) {
16
- const prev = Vue.config.errorHandler;
17
- const handler = (error, instance, info) => {
18
- const { component, file } = getComponent(instance);
19
- const detail = {
20
- name: error.name,
21
- message: error.message,
22
- stack: error.stack,
23
- errorInfo: info,
24
- component,
25
- file,
26
- props: instance ? instance.$options.propsData : void 0
27
- };
28
- const event = client.createEvent({
29
- category: "error",
30
- type: EventTypes.VUE,
31
- detail
32
- });
33
- client.notify(event);
34
- if (typeof console !== "undefined" && typeof console.error === "function") {
35
- console.error(error);
36
- }
37
- if (typeof prev === "function")
38
- prev(error, instance, info);
39
- };
40
- Vue.config.errorHandler = handler;
14
+ const prev = Vue.config.errorHandler;
15
+ const handler = (error, instance, info) => {
16
+ const { component, file } = getComponent(instance);
17
+ const detail = {
18
+ name: error.name,
19
+ message: error.message,
20
+ stack: error.stack,
21
+ errorInfo: info,
22
+ component,
23
+ file,
24
+ props: instance?.$props ?? instance?.$options?.propsData
25
+ };
26
+ const event = client.createEvent({
27
+ category: "error",
28
+ type: EventTypes.VUE,
29
+ detail
30
+ });
31
+ client.notify(event);
32
+ if (typeof console !== "undefined" && typeof console.error === "function") console.error(error);
33
+ if (typeof prev === "function") prev(error, instance, info);
34
+ };
35
+ Vue.config.errorHandler = handler;
41
36
  }
42
-
43
- // src/index.ts
37
+ //#endregion
38
+ //#region src/index.ts
44
39
  function createVueClient(client) {
45
- return {
46
- install: (app) => {
47
- install(client, app);
48
- }
49
- };
40
+ return { install: (app) => {
41
+ install(client, app);
42
+ } };
50
43
  }
51
- export {
52
- createVueClient as default
53
- };
44
+ //#endregion
45
+ export { createVueClient as default };
46
+
47
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/install.ts","../src/index.ts"],"sourcesContent":["import { EventTypes } from \"@ohbug/core\";\nimport type { OhbugBaseDetail, OhbugClient } from \"@ohbug/types\";\n\nimport type { Vue } from \"./types\";\n\nexport interface VueErrorDetail extends OhbugBaseDetail {\n name: string;\n stack?: string;\n errorInfo: string;\n component?: string;\n file?: string;\n props?: Record<string, any>;\n}\n\nconst getComponent = (instance: any): { component?: string; file?: string } => {\n if (!instance) return {};\n\n // Vue 2: instance.$root === instance\n // Vue 3: instance.$ exists and instance.$.root === instance.$\n if (instance.$root === instance || (instance.$ && instance.$.root === instance.$)) {\n return { component: \"Root\" };\n }\n\n // Vue 3: instance.$.type holds the component definition\n const type = instance.$?.type;\n const options = instance.$options;\n\n // Priority: Vue 3 <script setup> __name > Vue 3 name > Vue 2 name\n const component = type?.__name || type?.name || options?.name || undefined;\n\n // Priority: Vue 3 __file > Vue 2 __file\n const file = type?.__file || options?.__file || undefined;\n\n return { component, file };\n};\n\nexport function install(client: OhbugClient, Vue: Vue) {\n const prev = Vue.config.errorHandler;\n\n const handler = (error: Error, instance: any, info: string) => {\n const { component, file } = getComponent(instance);\n\n const detail: VueErrorDetail = {\n name: error.name,\n message: error.message,\n stack: error.stack,\n errorInfo: info,\n component,\n file,\n // Vue 3 uses $props, Vue 2 uses $options.propsData\n props: instance?.$props ?? instance?.$options?.propsData,\n };\n const event = client.createEvent<VueErrorDetail>({\n category: \"error\",\n type: EventTypes.VUE,\n detail,\n });\n\n void client.notify(event);\n\n if (typeof console !== \"undefined\" && typeof console.error === \"function\") {\n console.error(error);\n }\n if (typeof prev === \"function\") prev(error, instance, info);\n };\n\n Vue.config.errorHandler = handler;\n}\n","import type { OhbugClient } from \"@ohbug/types\";\n\nimport { install } from \"./install\";\nimport type { Vue } from \"./types\";\nexport type { VueErrorDetail } from \"./install\";\n\nexport default function createVueClient(client: OhbugClient) {\n return {\n install: (app: Vue) => {\n install(client, app);\n },\n };\n}\n"],"mappings":";;AAcA,MAAM,gBAAgB,aAAyD;AAC7E,KAAI,CAAC,SAAU,QAAO,EAAE;AAIxB,KAAI,SAAS,UAAU,YAAa,SAAS,KAAK,SAAS,EAAE,SAAS,SAAS,EAC7E,QAAO,EAAE,WAAW,QAAQ;CAI9B,MAAM,OAAO,SAAS,GAAG;CACzB,MAAM,UAAU,SAAS;AAQzB,QAAO;EAAE,WALS,MAAM,UAAU,MAAM,QAAQ,SAAS,QAAQ,KAAA;EAK7C,MAFP,MAAM,UAAU,SAAS,UAAU,KAAA;EAEtB;;AAG5B,SAAgB,QAAQ,QAAqB,KAAU;CACrD,MAAM,OAAO,IAAI,OAAO;CAExB,MAAM,WAAW,OAAc,UAAe,SAAiB;EAC7D,MAAM,EAAE,WAAW,SAAS,aAAa,SAAS;EAElD,MAAM,SAAyB;GAC7B,MAAM,MAAM;GACZ,SAAS,MAAM;GACf,OAAO,MAAM;GACb,WAAW;GACX;GACA;GAEA,OAAO,UAAU,UAAU,UAAU,UAAU;GAChD;EACD,MAAM,QAAQ,OAAO,YAA4B;GAC/C,UAAU;GACV,MAAM,WAAW;GACjB;GACD,CAAC;AAEG,SAAO,OAAO,MAAM;AAEzB,MAAI,OAAO,YAAY,eAAe,OAAO,QAAQ,UAAU,WAC7D,SAAQ,MAAM,MAAM;AAEtB,MAAI,OAAO,SAAS,WAAY,MAAK,OAAO,UAAU,KAAK;;AAG7D,KAAI,OAAO,eAAe;;;;AC5D5B,SAAwB,gBAAgB,QAAqB;AAC3D,QAAO,EACL,UAAU,QAAa;AACrB,UAAQ,QAAQ,IAAI;IAEvB"}
package/package.json CHANGED
@@ -1,43 +1,42 @@
1
1
  {
2
2
  "name": "@ohbug/vue",
3
- "version": "2.0.9",
3
+ "version": "2.0.11",
4
4
  "description": "Ohbug SDK for Vue",
5
- "license": "Apache-2.0",
6
- "author": "chenyueban <jasonchan0527@gmail.com>",
7
- "homepage": "https://github.com/ohbug-org/ohbug",
5
+ "homepage": "https://github.com/ohbug-org/ohbug#readme",
8
6
  "bugs": {
9
7
  "url": "https://github.com/ohbug-org/ohbug/issues"
10
8
  },
9
+ "license": "Apache-2.0",
10
+ "author": {
11
+ "name": "xinyao",
12
+ "email": "hi@xinyao.me"
13
+ },
11
14
  "repository": {
12
15
  "type": "git",
13
- "url": "https://github.com/ohbug-org/ohbug"
14
- },
15
- "main": "dist/index.js",
16
- "module": "dist/index.mjs",
17
- "types": "dist/index.d.ts",
18
- "exports": {
19
- ".": {
20
- "require": "./dist/index.js",
21
- "import": "./dist/index.mjs",
22
- "types": "./dist/index.d.ts"
23
- }
16
+ "url": "git+https://github.com/ohbug-org/ohbug.git"
24
17
  },
18
+ "funding": "https://github.com/sponsors/xinyao27",
25
19
  "files": [
26
20
  "dist"
27
21
  ],
22
+ "type": "module",
28
23
  "sideEffects": false,
29
- "peerDependencies": {
30
- "vue": "2.x || 3.x"
31
- },
32
- "dependencies": {
33
- "@ohbug/types": "2.2.0",
34
- "@ohbug/core": "2.2.0"
24
+ "types": "dist/index.d.mts",
25
+ "exports": {
26
+ ".": "./dist/index.mjs",
27
+ "./package.json": "./package.json"
35
28
  },
36
29
  "publishConfig": {
37
30
  "access": "public"
38
31
  },
32
+ "dependencies": {
33
+ "@ohbug/core": "2.2.2",
34
+ "@ohbug/types": "2.2.2"
35
+ },
36
+ "peerDependencies": {
37
+ "vue": "2.x || 3.x"
38
+ },
39
39
  "scripts": {
40
- "build": "tsup",
41
- "dev": "tsup --watch"
40
+ "dev": "vp pack --watch"
42
41
  }
43
42
  }
package/dist/index.d.ts DELETED
@@ -1,24 +0,0 @@
1
- import { OhbugBaseDetail, OhbugClient } from '@ohbug/types';
2
-
3
- interface Vue {
4
- config: {
5
- errorHandler?: any;
6
- warnHandler?: any;
7
- silent?: boolean;
8
- };
9
- }
10
-
11
- interface VueErrorDetail extends OhbugBaseDetail {
12
- name: string;
13
- stack?: string;
14
- errorInfo: string;
15
- component?: string;
16
- file?: string;
17
- props?: Record<string, any>;
18
- }
19
-
20
- declare function createVueClient(client: OhbugClient): {
21
- install: (app: Vue) => void;
22
- };
23
-
24
- export { VueErrorDetail, createVueClient as default };
package/dist/index.js DELETED
@@ -1,76 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- default: () => createVueClient
24
- });
25
- module.exports = __toCommonJS(src_exports);
26
-
27
- // src/install.ts
28
- var import_core = require("@ohbug/core");
29
- var getComponent = (instance) => {
30
- if ((instance == null ? void 0 : instance.$root) === instance) {
31
- return { component: "Root" };
32
- }
33
- const options = instance == null ? void 0 : instance.$options;
34
- const component = options == null ? void 0 : options.name;
35
- const file = options == null ? void 0 : options.__file;
36
- return {
37
- component,
38
- file
39
- };
40
- };
41
- function install(client, Vue) {
42
- const prev = Vue.config.errorHandler;
43
- const handler = (error, instance, info) => {
44
- const { component, file } = getComponent(instance);
45
- const detail = {
46
- name: error.name,
47
- message: error.message,
48
- stack: error.stack,
49
- errorInfo: info,
50
- component,
51
- file,
52
- props: instance ? instance.$options.propsData : void 0
53
- };
54
- const event = client.createEvent({
55
- category: "error",
56
- type: import_core.EventTypes.VUE,
57
- detail
58
- });
59
- client.notify(event);
60
- if (typeof console !== "undefined" && typeof console.error === "function") {
61
- console.error(error);
62
- }
63
- if (typeof prev === "function")
64
- prev(error, instance, info);
65
- };
66
- Vue.config.errorHandler = handler;
67
- }
68
-
69
- // src/index.ts
70
- function createVueClient(client) {
71
- return {
72
- install: (app) => {
73
- install(client, app);
74
- }
75
- };
76
- }