diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..a261f29 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +dist/* diff --git a/dist/main.d.ts b/dist/main.d.ts index 8f30418..e7ca395 100644 --- a/dist/main.d.ts +++ b/dist/main.d.ts @@ -1,16 +1,25 @@ -/** - * 暴露 Hooks - * @description 解决 Vue 3.0 使用全局变量很麻烦的问题 - * @example - * import { usePush } from 'vue-baidu-analytics' - * const baidu = usePush(); - * baidu.pv('/'); - */ -export declare function usePush(): { - pv: (pageUrl: string) => void; - event: (category: string, action: string, label: string, value: number) => void; -}; -/** - * 定义插件 - */ -export default function install(Vue: Vue, { router, siteIdList, isDebug }: Partial): false | undefined; +import type { Options, Vue } from '@/types' +/** + * 暴露 Hooks + * @description 解决 Vue 3.0 使用全局变量很麻烦的问题 + * @example + * import { usePush } from 'vue-baidu-analytics' + * const baidu = usePush(); + * baidu.pv('/'); + */ +export declare function usePush(): { + pv: (pageUrl: string) => void + event: ( + category: string, + action: string, + label: string, + value: number + ) => void +} +/** + * 定义插件 + */ +export default function install( + Vue: Vue, + { router, siteIdList, isDebug }: Partial +): false | undefined diff --git a/dist/modules/getVueVersion.d.ts b/dist/modules/getVueVersion.d.ts index 7678875..ea5bef4 100644 --- a/dist/modules/getVueVersion.d.ts +++ b/dist/modules/getVueVersion.d.ts @@ -1,6 +1,7 @@ -/** - * 获取Vue的版本 - * @return 2=Vue2.x, 3=Vue3.x - */ -declare const getVueVersion: (Vue: Vue) => number; -export default getVueVersion; +import type { Vue } from '@/types' +/** + * 获取Vue的版本 + * @return 2=Vue2.x, 3=Vue3.x + */ +declare const getVueVersion: (Vue: Vue) => number +export default getVueVersion diff --git a/dist/types.d.ts b/dist/types.d.ts new file mode 100644 index 0000000..6716400 --- /dev/null +++ b/dist/types.d.ts @@ -0,0 +1,12 @@ +import PushBAIDU from '@m/pushBAIDU' +export interface Options { + router: any + siteIdList: string[] + isDebug: boolean +} +export interface Vue { + prototype: any + $pushBAIDU: PushBAIDU + version: number | string + config: any +} diff --git a/dist/vue-baidu-analytics.js b/dist/vue-baidu-analytics.js index f036d5a..d425fd7 100644 --- a/dist/vue-baidu-analytics.js +++ b/dist/vue-baidu-analytics.js @@ -1,255 +1,302 @@ /*! * name: vue-baidu-analytics - * version: v2.1.0 + * version: v2.2.0 * author: chengpeiquan */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.baiduAnalytics = {})); -}(this, (function (exports) { 'use strict'; +;(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' + ? factory(exports) + : typeof define === 'function' && define.amd + ? define(['exports'], factory) + : ((global = + typeof globalThis !== 'undefined' ? globalThis : global || self), + factory((global.baiduAnalytics = {}))) +})(this, function (exports) { + 'use strict' - /*! ***************************************************************************** - Copyright (c) Microsoft Corporation. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ - function __spreadArray(to, from) { - for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i]; + function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) + for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i) + ar[i] = from[i] + } + } + return to.concat(ar || from) + } - return to; + /** + * 定义基础配置 + * 官方文档 https://tongji.baidu.com/open/api/more?p=guide_overview + */ + var BAIDU = /** @class */ (function () { + function BAIDU(siteId, isDebug) { + if (siteId === void 0) { + siteId = '' + } + if (isDebug === void 0) { + isDebug = false + } + this.siteId = siteId + this.isDebug = isDebug } - - /** - * 定义基础配置 - * 官方文档 https://tongji.baidu.com/open/api/more?p=guide_overview - */ - var BAIDU = /** @class */ (function () { - function BAIDU(siteId, isDebug) { - if (siteId === void 0) { siteId = ''; } - if (isDebug === void 0) { isDebug = false; } - this.siteId = siteId; - this.isDebug = isDebug; - } - /** - * 初始化 - */ - BAIDU.prototype.init = function () { - var _a; - window._hmt = window._hmt ? window._hmt : []; - var SCRIPT = document.createElement('script'); - SCRIPT['async'] = true; - SCRIPT['src'] = "https://hm.baidu.com/hm.js?" + this.siteId; - (_a = document.querySelector('head')) === null || _a === void 0 ? void 0 : _a.appendChild(SCRIPT); - if (this.isDebug) { - console.log("[vue-baidu-analytics] siteId load done.\nsiteId: " + this.siteId); - } - }; - /** - * 设置要响应的站点 - */ - BAIDU.prototype.setAccount = function () { - window._hmt.push(['_setAccount', this.siteId]); - }; - /** - * 提交PV、UV - */ - BAIDU.prototype.trackPageview = function (pageUrl) { - // 如果页面链接没传或者无效链接,则默认为根域名 - if (!pageUrl || typeof pageUrl !== 'string') { - pageUrl = '/'; - } - // 如果页面链接带上了域名,则需要过滤掉 - if (pageUrl.includes('http')) { - var PAGE_CUT = pageUrl.split('/'); - var HOST_NAME = PAGE_CUT[0] + "//" + PAGE_CUT[2]; - pageUrl = pageUrl.replace(HOST_NAME, ''); - } - // 设置响应 id 并提交数据 - this.setAccount(); - window._hmt.push(['_trackPageview', pageUrl]); - if (this.isDebug) { - console.log("[vue-baidu-analytics] track pv done.\nsiteId: " + this.siteId + "\npageUrl: " + pageUrl); - } - }; - /** - * 提交点击事件 - */ - BAIDU.prototype.trackEvent = function (category, action, label, value) { - // 前两个是必填项 - if (typeof category !== 'string' || typeof action !== 'string' || !category || !action) { - throw new Error('[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.'); - } - // 重置一些无效的默认值 - if (!label || typeof label !== 'string') { - label = ''; - } - if (!Number(value)) { - value = 1; - } - // 设置响应id并提交数据 - this.setAccount(); - window._hmt.push(['_trackEvent', category, action, label, value]); - if (this.isDebug) { - console.log("[vue-baidu-analytics] track event done.\nsiteId: " + this.siteId + "\ncategory: " + category + "\naction: " + action + "\nlabel: " + label + "\nvalue: " + value); - } - }; - return BAIDU; - }()); - - /** - * 定义推送操作 - */ - var PushBAIDU = /** @class */ (function () { - function PushBAIDU(siteIdList, isDebug) { - this.siteIdList = __spreadArray([], siteIdList); - this.isDebug = isDebug; - } - /** - * 批量部署站点 - */ - PushBAIDU.prototype.init = function () { - var _this = this; - this.siteIdList.forEach(function (siteId) { - var SITE = new BAIDU(siteId, _this.isDebug); - SITE.init(); - }); - }; - /** - * 批量提交pv上报 - */ - PushBAIDU.prototype.pv = function (pageUrl) { - var _this = this; - this.siteIdList.forEach(function (siteId) { - var SITE = new BAIDU(siteId, _this.isDebug); - SITE.trackPageview(pageUrl); - }); - }; - /** - * 批量提交事件上报 - */ - PushBAIDU.prototype.event = function (category, action, label, value) { - var _this = this; - this.siteIdList.forEach(function (siteId) { - var SITE = new BAIDU(siteId, _this.isDebug); - SITE.trackEvent(category, action, label, value); - }); - }; - return PushBAIDU; - }()); - - /** - * 获取Vue的版本 - * @return 2=Vue2.x, 3=Vue3.x - */ - var getVueVersion = function (Vue) { - var version = 2; - // 获取Vue的版本号 - var VUE_VERSION = String(Vue.version); - // Vue 2.x - if (VUE_VERSION.slice(0, 2) === '2.') { - version = 2; - } - // Vue 3.x - if (VUE_VERSION.slice(0, 2) === '3.') { - version = 3; - } - return version; - }; - - /** - * 全局的数据 - */ - var __GLOBAL__ = { - pushBAIDU: {} - }; - /** - * 暴露 Hooks - * @description 解决 Vue 3.0 使用全局变量很麻烦的问题 - * @example - * import { usePush } from 'vue-baidu-analytics' - * const baidu = usePush(); - * baidu.pv('/'); - */ - function usePush() { - // 提交 pv - function pv(pageUrl) { - return __GLOBAL__.pushBAIDU.pv(pageUrl); - } - // 提交事件 - function event(category, action, label, value) { - return __GLOBAL__.pushBAIDU.event(category, action, label, value); - } - return { - pv: pv, - event: event - }; - } - /** - * 定义插件 - */ - function install(Vue, _a) { - var router = _a.router, siteIdList = _a.siteIdList, _b = _a.isDebug, isDebug = _b === void 0 ? false : _b; - /** - * 一些环境和参数的检查 - */ - if (typeof document === 'undefined' || typeof window === 'undefined') { - return false; - } - if (!router) { - throw new Error('[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.'); - } - if (!siteIdList) { - throw new Error('[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics siteId.'); - } - /** - * 挂载推送的方法 - */ - var pushBAIDU = new PushBAIDU(siteIdList, isDebug); - __GLOBAL__.pushBAIDU = pushBAIDU; - /** - * 挂载全局变量到 Vue 上 - * 获取Vue版本(获取失败则默认为2) - */ - var VUE_VERSION = getVueVersion(Vue) || 2; - switch (VUE_VERSION) { - case 2: - Vue.prototype.$pushBAIDU = pushBAIDU; - break; - case 3: - Vue.config.globalProperties.$pushBAIDU = pushBAIDU; - break; - } - /** - * 部署站点并初始化 - */ - if (siteIdList && Array.isArray(siteIdList)) { - pushBAIDU.init(); - } - /** - * 路由切换时执行PV上报 - */ - router.afterEach(function (to) { - // 获取要上报的链接(当前版本不需要拼接了) - var PAGE_URL = window.location.href; - // 上报数据 - pushBAIDU.pv(PAGE_URL); - }); + /** + * 初始化 + */ + BAIDU.prototype.init = function () { + var _a + window._hmt = window._hmt ? window._hmt : [] + var SCRIPT = document.createElement('script') + SCRIPT['async'] = true + SCRIPT['src'] = 'https://hm.baidu.com/hm.js?' + this.siteId + ;(_a = document.querySelector('head')) === null || _a === void 0 + ? void 0 + : _a.appendChild(SCRIPT) + if (this.isDebug) { + console.log( + '[vue-baidu-analytics] siteId load done.\nsiteId: ' + this.siteId + ) + } } + /** + * 设置要响应的站点 + */ + BAIDU.prototype.setAccount = function () { + window._hmt.push(['_setAccount', this.siteId]) + } + /** + * 提交PV、UV + */ + BAIDU.prototype.trackPageview = function (pageUrl) { + // 如果页面链接没传或者无效链接,则默认为根域名 + if (!pageUrl || typeof pageUrl !== 'string') { + pageUrl = '/' + } + // 如果页面链接带上了域名,则需要过滤掉 + if (pageUrl.startsWith('http')) { + var PAGE_CUT = pageUrl.split('/') + var HOST_NAME = PAGE_CUT[0] + '//' + PAGE_CUT[2] + pageUrl = pageUrl.replace(HOST_NAME, '') + } + // 设置响应 id 并提交数据 + this.setAccount() + window._hmt.push(['_trackPageview', pageUrl]) + if (this.isDebug) { + console.log( + '[vue-baidu-analytics] track pv done.\nsiteId: ' + + this.siteId + + '\npageUrl: ' + + pageUrl + ) + } + } + /** + * 提交点击事件 + */ + BAIDU.prototype.trackEvent = function (category, action, label, value) { + // 前两个是必填项 + if ( + typeof category !== 'string' || + typeof action !== 'string' || + !category || + !action + ) { + throw new Error( + '[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.' + ) + } + // 重置一些无效的默认值 + if (!label || typeof label !== 'string') { + label = '' + } + if (!Number(value)) { + value = 1 + } + // 设置响应id并提交数据 + this.setAccount() + window._hmt.push(['_trackEvent', category, action, label, value]) + if (this.isDebug) { + console.log( + '[vue-baidu-analytics] track event done.\nsiteId: ' + + this.siteId + + '\ncategory: ' + + category + + '\naction: ' + + action + + '\nlabel: ' + + label + + '\nvalue: ' + + value + ) + } + } + return BAIDU + })() - exports.default = install; - exports.usePush = usePush; + /** + * 定义推送操作 + */ + var PushBAIDU = /** @class */ (function () { + function PushBAIDU(siteIdList, isDebug) { + this.siteIdList = __spreadArray([], siteIdList) + this.isDebug = isDebug + } + /** + * 批量部署站点 + */ + PushBAIDU.prototype.init = function () { + var _this = this + this.siteIdList.forEach(function (siteId) { + var SITE = new BAIDU(siteId, _this.isDebug) + SITE.init() + }) + } + /** + * 批量提交pv上报 + */ + PushBAIDU.prototype.pv = function (pageUrl) { + var _this = this + this.siteIdList.forEach(function (siteId) { + var SITE = new BAIDU(siteId, _this.isDebug) + SITE.trackPageview(pageUrl) + }) + } + /** + * 批量提交事件上报 + */ + PushBAIDU.prototype.event = function (category, action, label, value) { + var _this = this + this.siteIdList.forEach(function (siteId) { + var SITE = new BAIDU(siteId, _this.isDebug) + SITE.trackEvent(category, action, label, value) + }) + } + return PushBAIDU + })() - Object.defineProperty(exports, '__esModule', { value: true }); + /** + * 获取Vue的版本 + * @return 2=Vue2.x, 3=Vue3.x + */ + var getVueVersion = function (Vue) { + var version = 2 + // 获取Vue的版本号 + var VUE_VERSION = String(Vue.version) + // Vue 2.x + if (VUE_VERSION.slice(0, 2) === '2.') { + version = 2 + } + // Vue 3.x + if (VUE_VERSION.slice(0, 2) === '3.') { + version = 3 + } + return version + } -}))); + /** + * 全局的数据 + */ + var __GLOBAL__ = { + pushBAIDU: {}, + } + /** + * 暴露 Hooks + * @description 解决 Vue 3.0 使用全局变量很麻烦的问题 + * @example + * import { usePush } from 'vue-baidu-analytics' + * const baidu = usePush(); + * baidu.pv('/'); + */ + function usePush() { + // 提交 pv + function pv(pageUrl) { + return __GLOBAL__.pushBAIDU.pv(pageUrl) + } + // 提交事件 + function event(category, action, label, value) { + return __GLOBAL__.pushBAIDU.event(category, action, label, value) + } + return { + pv: pv, + event: event, + } + } + /** + * 定义插件 + */ + function install(Vue, _a) { + var router = _a.router, + siteIdList = _a.siteIdList, + _b = _a.isDebug, + isDebug = _b === void 0 ? false : _b + /** + * 一些环境和参数的检查 + */ + if (typeof document === 'undefined' || typeof window === 'undefined') { + return false + } + if (!router) { + throw new Error( + '[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.' + ) + } + if (!siteIdList) { + throw new Error( + '[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics siteId.' + ) + } + /** + * 挂载推送的方法 + */ + var pushBAIDU = new PushBAIDU(siteIdList, isDebug) + __GLOBAL__.pushBAIDU = pushBAIDU + /** + * 挂载全局变量到 Vue 上 + * 获取Vue版本(获取失败则默认为2) + */ + var VUE_VERSION = getVueVersion(Vue) || 2 + switch (VUE_VERSION) { + case 2: + Vue.prototype.$pushBAIDU = pushBAIDU + break + case 3: + Vue.config.globalProperties.$pushBAIDU = pushBAIDU + break + } + /** + * 部署站点并初始化 + */ + if (siteIdList && Array.isArray(siteIdList)) { + pushBAIDU.init() + } + /** + * 路由切换时执行PV上报 + */ + router.afterEach(function () { + // 获取要上报的链接(当前版本不需要拼接了) + var PAGE_URL = window.location.href + // 上报数据 + pushBAIDU.pv(PAGE_URL) + }) + } + + exports.default = install + exports.usePush = usePush + + Object.defineProperty(exports, '__esModule', { value: true }) +}) //# sourceMappingURL=vue-baidu-analytics.js.map diff --git a/dist/vue-baidu-analytics.js.map b/dist/vue-baidu-analytics.js.map index f9ad5d4..246c317 100644 --- a/dist/vue-baidu-analytics.js.map +++ b/dist/vue-baidu-analytics.js.map @@ -1 +1 @@ -{"version":3,"file":"vue-baidu-analytics.js","sources":["../node_modules/tslib/tslib.es6.js","../src/modules/baidu.ts","../src/modules/pushBAIDU.ts","../src/modules/getVueVersion.ts","../src/main.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","/**\n * 定义基础配置\n * 官方文档 https://tongji.baidu.com/open/api/more?p=guide_overview\n */\nclass BAIDU {\n siteId: string;\n isDebug: boolean;\n\n constructor (siteId: string = '', isDebug: boolean = false) {\n this.siteId = siteId;\n this.isDebug = isDebug;\n }\n\n /**\n * 初始化\n */\n init () {\n window._hmt = window._hmt ? window._hmt : [];\n const SCRIPT = document.createElement('script');\n SCRIPT['async'] = true;\n SCRIPT['src'] = `https://hm.baidu.com/hm.js?${this.siteId}`;\n document.querySelector('head')?.appendChild(SCRIPT);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] siteId load done.\\nsiteId: ${this.siteId}`);\n }\n }\n\n /**\n * 设置要响应的站点\n */\n setAccount () {\n window._hmt.push(['_setAccount', this.siteId]);\n }\n\n /**\n * 提交PV、UV\n */\n trackPageview (pageUrl: string) {\n // 如果页面链接没传或者无效链接,则默认为根域名\n if ( !pageUrl || typeof pageUrl !== 'string' ) {\n pageUrl = '/';\n }\n\n // 如果页面链接带上了域名,则需要过滤掉\n if ( pageUrl.includes('http') ) {\n const PAGE_CUT = pageUrl.split('/');\n const HOST_NAME = `${PAGE_CUT[0]}//${PAGE_CUT[2]}`;\n pageUrl = pageUrl.replace(HOST_NAME, '');\n }\n\n // 设置响应 id 并提交数据\n this.setAccount();\n window._hmt.push(['_trackPageview', pageUrl]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track pv done.\\nsiteId: ${this.siteId}\\npageUrl: ${pageUrl}`);\n }\n }\n\n /**\n * 提交点击事件\n */\n trackEvent (category: string, action: string, label: string, value: number) {\n // 前两个是必填项\n if ( typeof category !== 'string' || typeof action !== 'string' || !category || !action ) {\n throw new Error('[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.');\n }\n\n // 重置一些无效的默认值\n if ( !label || typeof label !== 'string' ) {\n label = '';\n }\n\n if ( !Number(value) ) {\n value = 1;\n }\n\n // 设置响应id并提交数据\n this.setAccount();\n window._hmt.push(['_trackEvent', category, action, label, value]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track event done.\\nsiteId: ${this.siteId}\\ncategory: ${category}\\naction: ${action}\\nlabel: ${label}\\nvalue: ${value}`);\n }\n }\n}\n\nexport default BAIDU;\n","import BAIDU from '@m/baidu'\n\n/**\n * 定义推送操作\n */\nclass PushBAIDU {\n siteIdList: string[];\n isDebug: boolean;\n\n constructor (siteIdList: string[], isDebug: boolean) {\n this.siteIdList = [...siteIdList];\n this.isDebug = isDebug;\n }\n\n /**\n * 批量部署站点\n */\n init () {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.init();\n });\n }\n\n /**\n * 批量提交pv上报\n */\n pv (pageUrl: string) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackPageview(pageUrl);\n });\n }\n\n /**\n * 批量提交事件上报\n */\n event (category: string, action: string, label: string, value: number) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackEvent(category, action, label, value);\n });\n }\n\n}\n\nexport default PushBAIDU;\n","/** \r\n * 获取Vue的版本\r\n * @return 2=Vue2.x, 3=Vue3.x\r\n */\r\nconst getVueVersion = (Vue: Vue): number => {\r\n let version: number = 2;\r\n\r\n // 获取Vue的版本号\r\n const VUE_VERSION: string = String(Vue.version);\r\n\r\n // Vue 2.x\r\n if ( VUE_VERSION.slice(0, 2) === '2.' ) {\r\n version = 2; \r\n }\r\n \r\n // Vue 3.x\r\n if ( VUE_VERSION.slice(0, 2) === '3.' ) {\r\n version = 3; \r\n }\r\n \r\n return version;\r\n}\r\n\r\nexport default getVueVersion;","import PushBAIDU from '@m/pushBAIDU'\nimport getVueVersion from '@m/getVueVersion'\n\n/**\n * 全局的数据\n */\nconst __GLOBAL__ = {\n pushBAIDU: {} as PushBAIDU\n}\n\n/**\n * 暴露 Hooks\n * @description 解决 Vue 3.0 使用全局变量很麻烦的问题\n * @example\n * import { usePush } from 'vue-baidu-analytics'\n * const baidu = usePush();\n * baidu.pv('/');\n */\nexport function usePush () {\n // 提交 pv\n function pv (pageUrl: string) {\n return __GLOBAL__.pushBAIDU.pv(pageUrl);\n }\n\n // 提交事件\n function event (category: string, action: string, label: string, value: number) {\n return __GLOBAL__.pushBAIDU.event(category, action, label, value);\n }\n\n return {\n pv,\n event\n }\n}\n\n/**\n * 定义插件\n */\nexport default function install (Vue: Vue, { router, siteIdList, isDebug = false }: Partial) {\n\n /**\n * 一些环境和参数的检查\n */\n if ( typeof document === 'undefined' || typeof window === 'undefined' ) {\n return false;\n }\n\n if ( !router ) {\n throw new Error('[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.');\n }\n\n if ( !siteIdList ) {\n throw new Error('[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics siteId.');\n }\n\n /**\n * 挂载推送的方法\n */\n const pushBAIDU: PushBAIDU = new PushBAIDU(siteIdList, isDebug);\n __GLOBAL__.pushBAIDU = pushBAIDU;\n\n /**\n * 挂载全局变量到 Vue 上\n * 获取Vue版本(获取失败则默认为2)\n */\n const VUE_VERSION: number = getVueVersion(Vue) || 2;\n switch (VUE_VERSION) {\n case 2:\n Vue.prototype.$pushBAIDU = pushBAIDU;\n break;\n case 3:\n Vue.config.globalProperties.$pushBAIDU = pushBAIDU;\n break;\n }\n\n /**\n * 部署站点并初始化\n */\n if ( siteIdList && Array.isArray(siteIdList) ) {\n pushBAIDU.init();\n }\n\n /**\n * 路由切换时执行PV上报\n */\n router.afterEach( (to: To) => {\n // 获取要上报的链接(当前版本不需要拼接了)\n const PAGE_URL: string = window.location.href;\n\n // 上报数据\n pushBAIDU.pv(PAGE_URL);\n });\n}\n"],"names":["__spreadArray","to","from","i","il","length","j"],"mappings":";;;;;;;;;;;IAAA;IACA;AACA;IACA;IACA;AACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAuJO,SAASA,aAAT,CAAuBC,EAAvB,EAA2BC,IAA3B,EAAiC;IACpC,OAAK,IAAIC,CAAC,GAAG,CAAR,EAAWC,EAAE,GAAGF,IAAI,CAACG,MAArB,EAA6BC,CAAC,GAAGL,EAAE,CAACI,MAAzC,EAAiDF,CAAC,GAAGC,EAArD,EAAyDD,CAAC,IAAIG,CAAC,EAA/D,EACIL,EAAE,CAACK,CAAD,CAAF,GAAQJ,IAAI,CAACC,CAAD,CAAZ;;IACJ,SAAOF,EAAP;IACH;;ICxKD;;;;IAIA;QAIE,eAAa,MAAmB,EAAE,OAAwB;YAA7C,uBAAA,EAAA,WAAmB;YAAE,wBAAA,EAAA,eAAwB;YACxD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;SACxB;;;;QAKD,oBAAI,GAAJ;;YACE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;YAC7C,IAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YAChD,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;YACvB,MAAM,CAAC,KAAK,CAAC,GAAG,gCAA8B,IAAI,CAAC,MAAQ,CAAC;YAC5D,MAAA,QAAQ,CAAC,aAAa,CAAC,MA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AM,YAAA,EAAE,UAAU,gBAAA,EAAE,eAAe,EAAf,OAAO,mBAAG,KAAK,KAAA;;;;QAK9E,IAAK,OAAO,QAAQ,KAAK,WAAW,IAAI,OAAO,MAAM,KAAK,WAAW,EAAG;YACtE,OAAO,KAAK,CAAC;SACd;QAED,IAAK,CAAC,MAAM,EAAG;YACb,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;SAClG;QAED,IAAK,CAAC,UAAU,EAAG;YACjB,MAAM,IAAI,KAAK,CAAC,+FAA+F,CAAC,CAAC;SAClH;;;;QAKD,IAAM,SAAS,GAAc,IAAI,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAChE,UAAU,CAAC,SAAS,GAAG,SAAS,CAAC;;;;;QAMjC,IAAM,WAAW,GAAW,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpD,QAAQ,WAAW;YACjB,KAAK,CAAC;gBACJ,GAAG,CAAC,SAAS,CAAC,UAAU,GAAG,SAAS,CAAC;gBACrC,MAAM;YACR,KAAK,CAAC;gBACJ,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,GAAG,SAAS,CAAC;gBACnD,MAAM;SACT;;;;QAKD,IAAK,UAAU,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAG;YAC7C,SAAS,CAAC,IAAI,EAAE,CAAC;SAClB;;;;QAKD,MAAM,CAAC,SAAS,CAAE,UAAC,EAAM;;YAEvB,IAAM,QAAQ,GAAW,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;;YAG9C,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;SACxB,CAAC,CAAC;IACL;;;;;;;"} \ No newline at end of file +{"version":3,"file":"vue-baidu-analytics.js","sources":["../node_modules/tslib/tslib.es6.js","../src/modules/baidu.ts","../src/modules/pushBAIDU.ts","../src/modules/getVueVersion.ts","../src/main.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || from);\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","/**\n * 定义基础配置\n * 官方文档 https://tongji.baidu.com/open/api/more?p=guide_overview\n */\nclass BAIDU {\n siteId: string\n isDebug: boolean\n\n constructor(siteId: string = '', isDebug: boolean = false) {\n this.siteId = siteId\n this.isDebug = isDebug\n }\n\n /**\n * 初始化\n */\n init() {\n window._hmt = window._hmt ? window._hmt : []\n const SCRIPT = document.createElement('script')\n SCRIPT['async'] = true\n SCRIPT['src'] = `https://hm.baidu.com/hm.js?${this.siteId}`\n document.querySelector('head')?.appendChild(SCRIPT)\n\n if (this.isDebug) {\n console.log(\n `[vue-baidu-analytics] siteId load done.\\nsiteId: ${this.siteId}`\n )\n }\n }\n\n /**\n * 设置要响应的站点\n */\n setAccount() {\n window._hmt.push(['_setAccount', this.siteId])\n }\n\n /**\n * 提交PV、UV\n */\n trackPageview(pageUrl: string) {\n // 如果页面链接没传或者无效链接,则默认为根域名\n if (!pageUrl || typeof pageUrl !== 'string') {\n pageUrl = '/'\n }\n\n // 如果页面链接带上了域名,则需要过滤掉\n if (pageUrl.startsWith('http')) {\n const PAGE_CUT = pageUrl.split('/')\n const HOST_NAME = `${PAGE_CUT[0]}//${PAGE_CUT[2]}`\n pageUrl = pageUrl.replace(HOST_NAME, '')\n }\n\n // 设置响应 id 并提交数据\n this.setAccount()\n window._hmt.push(['_trackPageview', pageUrl])\n\n if (this.isDebug) {\n console.log(\n `[vue-baidu-analytics] track pv done.\\nsiteId: ${this.siteId}\\npageUrl: ${pageUrl}`\n )\n }\n }\n\n /**\n * 提交点击事件\n */\n trackEvent(category: string, action: string, label: string, value: number) {\n // 前两个是必填项\n if (\n typeof category !== 'string' ||\n typeof action !== 'string' ||\n !category ||\n !action\n ) {\n throw new Error(\n '[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.'\n )\n }\n\n // 重置一些无效的默认值\n if (!label || typeof label !== 'string') {\n label = ''\n }\n\n if (!Number(value)) {\n value = 1\n }\n\n // 设置响应id并提交数据\n this.setAccount()\n window._hmt.push(['_trackEvent', category, action, label, value])\n\n if (this.isDebug) {\n console.log(\n `[vue-baidu-analytics] track event done.\\nsiteId: ${this.siteId}\\ncategory: ${category}\\naction: ${action}\\nlabel: ${label}\\nvalue: ${value}`\n )\n }\n }\n}\n\nexport default BAIDU\n","import BAIDU from '@m/baidu'\n\n/**\n * 定义推送操作\n */\nclass PushBAIDU {\n siteIdList: string[]\n isDebug: boolean\n\n constructor(siteIdList: string[], isDebug: boolean) {\n this.siteIdList = [...siteIdList]\n this.isDebug = isDebug\n }\n\n /**\n * 批量部署站点\n */\n init() {\n this.siteIdList.forEach((siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug)\n SITE.init()\n })\n }\n\n /**\n * 批量提交pv上报\n */\n pv(pageUrl: string) {\n this.siteIdList.forEach((siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug)\n SITE.trackPageview(pageUrl)\n })\n }\n\n /**\n * 批量提交事件上报\n */\n event(category: string, action: string, label: string, value: number) {\n this.siteIdList.forEach((siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug)\n SITE.trackEvent(category, action, label, value)\n })\n }\n}\n\nexport default PushBAIDU\n","import type { Vue } from '@/types'\n\n/**\n * 获取Vue的版本\n * @return 2=Vue2.x, 3=Vue3.x\n */\nconst getVueVersion = (Vue: Vue): number => {\n let version: number = 2\n\n // 获取Vue的版本号\n const VUE_VERSION: string = String(Vue.version)\n\n // Vue 2.x\n if (VUE_VERSION.slice(0, 2) === '2.') {\n version = 2\n }\n\n // Vue 3.x\n if (VUE_VERSION.slice(0, 2) === '3.') {\n version = 3\n }\n\n return version\n}\n\nexport default getVueVersion\n","import PushBAIDU from '@m/pushBAIDU'\nimport getVueVersion from '@m/getVueVersion'\nimport type { Options, Vue } from '@/types'\n\n/**\n * 全局的数据\n */\nconst __GLOBAL__ = {\n pushBAIDU: {} as PushBAIDU,\n}\n\n/**\n * 暴露 Hooks\n * @description 解决 Vue 3.0 使用全局变量很麻烦的问题\n * @example\n * import { usePush } from 'vue-baidu-analytics'\n * const baidu = usePush();\n * baidu.pv('/');\n */\nexport function usePush() {\n // 提交 pv\n function pv(pageUrl: string) {\n return __GLOBAL__.pushBAIDU.pv(pageUrl)\n }\n\n // 提交事件\n function event(\n category: string,\n action: string,\n label: string,\n value: number\n ) {\n return __GLOBAL__.pushBAIDU.event(category, action, label, value)\n }\n\n return {\n pv,\n event,\n }\n}\n\n/**\n * 定义插件\n */\nexport default function install(\n Vue: Vue,\n { router, siteIdList, isDebug = false }: Partial\n) {\n /**\n * 一些环境和参数的检查\n */\n if (typeof document === 'undefined' || typeof window === 'undefined') {\n return false\n }\n\n if (!router) {\n throw new Error(\n '[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.'\n )\n }\n\n if (!siteIdList) {\n throw new Error(\n '[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics siteId.'\n )\n }\n\n /**\n * 挂载推送的方法\n */\n const pushBAIDU: PushBAIDU = new PushBAIDU(siteIdList, isDebug)\n __GLOBAL__.pushBAIDU = pushBAIDU\n\n /**\n * 挂载全局变量到 Vue 上\n * 获取Vue版本(获取失败则默认为2)\n */\n const VUE_VERSION: number = getVueVersion(Vue) || 2\n switch (VUE_VERSION) {\n case 2:\n Vue.prototype.$pushBAIDU = pushBAIDU\n break\n case 3:\n Vue.config.globalProperties.$pushBAIDU = pushBAIDU\n break\n }\n\n /**\n * 部署站点并初始化\n */\n if (siteIdList && Array.isArray(siteIdList)) {\n pushBAIDU.init()\n }\n\n /**\n * 路由切换时执行PV上报\n */\n router.afterEach(() => {\n // 获取要上报的链接(当前版本不需要拼接了)\n const PAGE_URL: string = window.location.href\n\n // 上报数据\n pushBAIDU.pv(PAGE_URL)\n })\n}\n"],"names":["__spreadArray","to","from","pack","arguments","length","i","l","ar","Array","prototype","slice","call","concat"],"mappings":";;;;;;;;;;;IAAA;IACA;AACA;IACA;IACA;AACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAuJO,SAASA,aAAT,CAAuBC,EAAvB,EAA2BC,IAA3B,EAAiCC,IAAjC,EAAuC;IAC1C,MAAIA,IAAI,IAAIC,SAAS,CAACC,MAAV,KAAqB,CAAjC,EAAoC,KAAK,IAAIC,CAAC,GAAG,CAAR,EAAWC,CAAC,GAAGL,IAAI,CAACG,MAApB,EAA4BG,EAAjC,EAAqCF,CAAC,GAAGC,CAAzC,EAA4CD,CAAC,EAA7C,EAAiD;IACjF,QAAIE,EAAE,IAAI,EAAEF,CAAC,IAAIJ,IAAP,CAAV,EAAwB;IACpB,UAAI,CAACM,EAAL,EAASA,EAAE,GAAGC,KAAK,CAACC,SAAN,CAAgBC,KAAhB,CAAsBC,IAAtB,CAA2BV,IAA3B,EAAiC,CAAjC,EAAoCI,CAApC,CAAL;IACTE,MAAAA,EAAE,CAACF,CAAD,CAAF,GAAQJ,IAAI,CAACI,CAAD,CAAZ;IACH;IACJ;IACD,SAAOL,EAAE,C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gBACJ,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,GAAG,SAAS,CAAA;gBAClD,MAAK;SACR;;;;QAKD,IAAI,UAAU,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC3C,SAAS,CAAC,IAAI,EAAE,CAAA;SACjB;;;;QAKD,MAAM,CAAC,SAAS,CAAC;;YAEf,IAAM,QAAQ,GAAW,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAA;;YAG7C,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAA;SACvB,CAAC,CAAA;IACJ;;;;;;;"} \ No newline at end of file diff --git a/dist/vue-baidu-analytics.min.js b/dist/vue-baidu-analytics.min.js index 946646e..3fe9acc 100644 --- a/dist/vue-baidu-analytics.min.js +++ b/dist/vue-baidu-analytics.min.js @@ -1,7 +1,189 @@ /*! * name: vue-baidu-analytics - * version: v2.1.0 + * version: v2.2.0 * author: chengpeiquan */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).baiduAnalytics={})}(this,(function(t){"use strict";var e=function(){function t(t,e){void 0===t&&(t=""),void 0===e&&(e=!1),this.siteId=t,this.isDebug=e}return t.prototype.init=function(){var t;window._hmt=window._hmt?window._hmt:[];var e=document.createElement("script");e.async=!0,e.src="https://hm.baidu.com/hm.js?"+this.siteId,null===(t=document.querySelector("head"))||void 0===t||t.appendChild(e),this.isDebug&&console.log("[vue-baidu-analytics] siteId load done.\nsiteId: "+this.siteId)},t.prototype.setAccount=function(){window._hmt.push(["_setAccount",this.siteId])},t.prototype.trackPageview=function(t){if(t&&"string"==typeof t||(t="/"),t.includes("http")){var e=t.split("/"),i=e[0]+"//"+e[2];t=t.replace(i,"")}this.setAccount(),window._hmt.push(["_trackPageview",t]),this.isDebug&&console.log("[vue-baidu-analytics] track pv done.\nsiteId: "+this.siteId+"\npageUrl: "+t)},t.prototype.trackEvent=function(t,e,i,n){if("string"!=typeof t||"string"!=typeof e||!t||!e)throw new Error("[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.");i&&"string"==typeof i||(i=""),Number(n)||(n=1),this.setAccount(),window._hmt.push(["_trackEvent",t,e,i,n]),this.isDebug&&console.log("[vue-baidu-analytics] track event done.\nsiteId: "+this.siteId+"\ncategory: "+t+"\naction: "+e+"\nlabel: "+i+"\nvalue: "+n)},t}(),i=function(){function t(t,e){this.siteIdList=function(t,e){for(var i=0,n=e.length,o=t.length;i {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.init();\n });\n }\n\n /**\n * 批量提交pv上报\n */\n pv (pageUrl: string) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackPageview(pageUrl);\n });\n }\n\n /**\n * 批量提交事件上报\n */\n event (category: string, action: string, label: string, value: number) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackEvent(category, action, label, value);\n });\n }\n\n}\n\nexport default PushBAIDU;\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from) {\r\n for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\r\n to[j] = from[i];\r\n return to;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","import PushBAIDU from '@m/pushBAIDU'\nimport getVueVersion from '@m/getVueVersion'\n\n/**\n * 全局的数据\n */\nconst __GLOBAL__ = {\n pushBAIDU: {} as PushBAIDU\n}\n\n/**\n * 暴露 Hooks\n * @description 解决 Vue 3.0 使用全局变量很麻烦的问题\n * @example\n * import { usePush } from 'vue-baidu-analytics'\n * const baidu = usePush();\n * baidu.pv('/');\n */\nexport function usePush () {\n // 提交 pv\n function pv (pageUrl: string) {\n return __GLOBAL__.pushBAIDU.pv(pageUrl);\n }\n\n // 提交事件\n function event (category: string, action: string, label: string, value: number) {\n return __GLOBAL__.pushBAIDU.event(category, action, label, value);\n }\n\n return {\n pv,\n event\n }\n}\n\n/**\n * 定义插件\n */\nexport default function install (Vue: Vue, { router, siteIdList, isDebug = false }: Partial) {\n\n /**\n * 一些环境和参数的检查\n */\n if ( typeof document === 'undefined' || typeof window === 'undefined' ) {\n return false;\n }\n\n if ( !router ) {\n throw new Error('[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.');\n }\n\n if ( !siteIdList ) {\n throw new Error('[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics siteId.');\n }\n\n /**\n * 挂载推送的方法\n */\n const pushBAIDU: PushBAIDU = new PushBAIDU(siteIdList, isDebug);\n __GLOBAL__.pushBAIDU = pushBAIDU;\n\n /**\n * 挂载全局变量到 Vue 上\n * 获取Vue版本(获取失败则默认为2)\n */\n const VUE_VERSION: number = getVueVersion(Vue) || 2;\n switch (VUE_VERSION) {\n case 2:\n Vue.prototype.$pushBAIDU = pushBAIDU;\n break;\n case 3:\n Vue.config.globalProperties.$pushBAIDU = pushBAIDU;\n break;\n }\n\n /**\n * 部署站点并初始化\n */\n if ( siteIdList && Array.isArray(siteIdList) ) {\n pushBAIDU.init();\n }\n\n /**\n * 路由切换时执行PV上报\n */\n router.afterEach( (to: To) => {\n // 获取要上报的链接(当前版本不需要拼接了)\n const PAGE_URL: string = window.location.href;\n\n // 上报数据\n pushBAIDU.pv(PAGE_URL);\n });\n}\n","/** \r\n * 获取Vue的版本\r\n * @return 2=Vue2.x, 3=Vue3.x\r\n */\r\nconst getVueVersion = (Vue: Vue): number => {\r\n let version: number = 2;\r\n\r\n // 获取Vue的版本号\r\n const VUE_VERSION: string = String(Vue.version);\r\n\r\n // Vue 2.x\r\n if ( VUE_VERSION.slice(0, 2) === '2.' ) {\r\n version = 2; \r\n }\r\n \r\n // Vue 3.x\r\n if ( VUE_VERSION.slice(0, 2) === '3.' ) {\r\n version = 3; \r\n }\r\n \r\n return version;\r\n}\r\n\r\nexport default getVueVersion;"],"names":["siteId","isDebug","this","BAIDU","window","_hmt","SCRIPT","document","createElement","querySelector","appendChild","console","log","push","pageUrl","includes","PAGE_CUT","split","HOST_NAME","replace","setAccount","category","action","label","value","Error","Number","siteIdList","to","from","i","il","length","j","PushBAIDU","forEach","_this","init","trackPageview","trackEvent","__GLOBAL__","pushBAIDU","Vue","_a","router","_b","version","VUE_VERSION","String","slice","getVueVersion","prototype","$pushBAIDU","config","globalProperties","Array","isArray","afterEach","PAGE_URL","location","href","pv","event"],"mappings":";;;;;;;;;;;;;;;;;;;oFAIA,iBAIE,WAAaA,EAAqBC,gBAArBD,mBAAqBC,MAChCC,KAAKF,OAASA,EACdE,KAAKD,QAAUA,EA4EnB,OAtEEE,iBAAA,iBACEC,OAAOC,KAAOD,OAAOC,KAAOD,OAAOC,KAAO,GAC1C,IAAMC,EAASC,SAASC,cAAc,UACtCF,EAAc,OAAI,EAClBA,EAAY,IAAI,8BAA8BJ,KAAKF,iBACnDO,SAASE,cAAc,wBAASC,YAAYJ,GAEvCJ,KAAKD,SACRU,QAAQC,IAAI,uDAAuDV,KAAKF,SAO5EG,uBAAA,WACEC,OAAOC,KAAKQ,KAAK,CAAC,cAAeX,KAAKF,UAMxCG,0BAAA,SAAeW,GAOb,GALMA,GAA8B,iBAAZA,IACtBA,EAAU,KAIPA,EAAQC,SAAS,QAAU,CAC9B,IAAMC,EAAWF,EAAQG,MAAM,KACzBC,EAAeF,EAAS,QAAOA,EAAS,GAC9CF,EAAUA,EAAQK,QAAQD,EAAW,IAIvChB,KAAKkB,aACLhB,OAAOC,KAAKQ,KAAK,CAAC,iBAAkBC,IAE/BZ,KAAKD,SACRU,QAAQC,IAAI,oDAAoDV,KAAKF,uBAAsBc,IAO/FX,u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P,EAAY1B,GAQvD,OAPAuC,EAAWC,UAAYA,ECvDH,SAACC,GACrB,IAAII,EAAkB,EAGhBC,EAAsBC,OAAON,EAAII,SAYvC,MATiC,OAA5BC,EAAYE,MAAM,EAAG,KACxBH,EAAU,GAIqB,OAA5BC,EAAYE,MAAM,EAAG,KACxBH,EAAU,GAGLA,ED6CqBI,CAAcR,IAAQ,GAEhD,KAAK,EACHA,EAAIS,UAAUC,WAAaX,EAC3B,MACF,KAAK,EACHC,EAAIW,OAAOC,iBAAiBF,WAAaX,EAOxCd,GAAc4B,MAAMC,QAAQ7B,IAC/Bc,EAAUJ,OAMZO,EAAOa,WAAW,SAAC7B,GAEjB,IAAM8B,EAAmBtD,OAAOuD,SAASC,KAGzCnB,EAAUoB,GAAGH,4BA7Df,MAAO,CACLG,GAVF,SAAa/C,GACX,OAAO0B,EAAWC,UAAUoB,GAAG/C,IAU/BgD,MANF,SAAgBzC,EAAkBC,EAAgBC,EAAeC,GAC/D,OAAOgB,EAAWC,UAAUqB,MAAMzC,EAAUC,EAAQC,EAAOC"} \ No newline at end of file +{"version":3,"file":"vue-baidu-analytics.min.js","sources":["../src/modules/baidu.ts","../src/modules/pushBAIDU.ts","../node_modules/tslib/tslib.es6.js","../src/main.ts","../src/modules/getVueVersion.ts"],"sourcesContent":["/**\n * 定义基础配置\n * 官方文档 https://tongji.baidu.com/open/api/more?p=guide_overview\n */\nclass BAIDU {\n siteId: string\n isDebug: boolean\n\n constructor(siteId: string = '', isDebug: boolean = false) {\n this.siteId = siteId\n this.isDebug = isDebug\n }\n\n /**\n * 初始化\n */\n init() {\n window._hmt = window._hmt ? window._hmt : []\n const SCRIPT = document.createElement('script')\n SCRIPT['async'] = true\n SCRIPT['src'] = `https://hm.baidu.com/hm.js?${this.siteId}`\n document.querySelector('head')?.appendChild(SCRIPT)\n\n if (this.isDebug) {\n console.log(\n `[vue-baidu-analytics] siteId load done.\\nsiteId: ${this.siteId}`\n )\n }\n }\n\n /**\n * 设置要响应的站点\n */\n setAccount() {\n window._hmt.push(['_setAccount', this.siteId])\n }\n\n /**\n * 提交PV、UV\n */\n trackPageview(pageUrl: string) {\n // 如果页面链接没传或者无效链接,则默认为根域名\n if (!pageUrl || typeof pageUrl !== 'string') {\n pageUrl = '/'\n }\n\n // 如果页面链接带上了域名,则需要过滤掉\n if (pageUrl.startsWith('http')) {\n const PAGE_CUT = pageUrl.split('/')\n const HOST_NAME = `${PAGE_CUT[0]}//${PAGE_CUT[2]}`\n pageUrl = pageUrl.replace(HOST_NAME, '')\n }\n\n // 设置响应 id 并提交数据\n this.setAccount()\n window._hmt.push(['_trackPageview', pageUrl])\n\n if (this.isDebug) {\n console.log(\n `[vue-baidu-analytics] track pv done.\\nsiteId: ${this.siteId}\\npageUrl: ${pageUrl}`\n )\n }\n }\n\n /**\n * 提交点击事件\n */\n trackEvent(category: string, action: string, label: string, value: number) {\n // 前两个是必填项\n if (\n typeof category !== 'string' ||\n typeof action !== 'string' ||\n !category ||\n !action\n ) {\n throw new Error(\n '[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.'\n )\n }\n\n // 重置一些无效的默认值\n if (!label || typeof label !== 'string') {\n label = ''\n }\n\n if (!Number(value)) {\n value = 1\n }\n\n // 设置响应id并提交数据\n this.setAccount()\n window._hmt.push(['_trackEvent', category, action, label, value])\n\n if (this.isDebug) {\n console.log(\n `[vue-baidu-analytics] track event done.\\nsiteId: ${this.siteId}\\ncategory: ${category}\\naction: ${action}\\nlabel: ${label}\\nvalue: ${value}`\n )\n }\n }\n}\n\nexport default BAIDU\n","import BAIDU from '@m/baidu'\n\n/**\n * 定义推送操作\n */\nclass PushBAIDU {\n siteIdList: string[]\n isDebug: boolean\n\n constructor(siteIdList: string[], isDebug: boolean) {\n this.siteIdList = [...siteIdList]\n this.isDebug = isDebug\n }\n\n /**\n * 批量部署站点\n */\n init() {\n this.siteIdList.forEach((siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug)\n SITE.init()\n })\n }\n\n /**\n * 批量提交pv上报\n */\n pv(pageUrl: string) {\n this.siteIdList.forEach((siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug)\n SITE.trackPageview(pageUrl)\n })\n }\n\n /**\n * 批量提交事件上报\n */\n event(category: string, action: string, label: string, value: number) {\n this.siteIdList.forEach((siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug)\n SITE.trackEvent(category, action, label, value)\n })\n }\n}\n\nexport default PushBAIDU\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || from);\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","import PushBAIDU from '@m/pushBAIDU'\nimport getVueVersion from '@m/getVueVersion'\nimport type { Options, Vue } from '@/types'\n\n/**\n * 全局的数据\n */\nconst __GLOBAL__ = {\n pushBAIDU: {} as PushBAIDU,\n}\n\n/**\n * 暴露 Hooks\n * @description 解决 Vue 3.0 使用全局变量很麻烦的问题\n * @example\n * import { usePush } from 'vue-baidu-analytics'\n * const baidu = usePush();\n * baidu.pv('/');\n */\nexport function usePush() {\n // 提交 pv\n function pv(pageUrl: string) {\n return __GLOBAL__.pushBAIDU.pv(pageUrl)\n }\n\n // 提交事件\n function event(\n category: string,\n action: string,\n label: string,\n value: number\n ) {\n return __GLOBAL__.pushBAIDU.event(category, action, label, value)\n }\n\n return {\n pv,\n event,\n }\n}\n\n/**\n * 定义插件\n */\nexport default function install(\n Vue: Vue,\n { router, siteIdList, isDebug = false }: Partial\n) {\n /**\n * 一些环境和参数的检查\n */\n if (typeof document === 'undefined' || typeof window === 'undefined') {\n return false\n }\n\n if (!router) {\n throw new Error(\n '[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.'\n )\n }\n\n if (!siteIdList) {\n throw new Error(\n '[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics siteId.'\n )\n }\n\n /**\n * 挂载推送的方法\n */\n const pushBAIDU: PushBAIDU = new PushBAIDU(siteIdList, isDebug)\n __GLOBAL__.pushBAIDU = pushBAIDU\n\n /**\n * 挂载全局变量到 Vue 上\n * 获取Vue版本(获取失败则默认为2)\n */\n const VUE_VERSION: number = getVueVersion(Vue) || 2\n switch (VUE_VERSION) {\n case 2:\n Vue.prototype.$pushBAIDU = pushBAIDU\n break\n case 3:\n Vue.config.globalProperties.$pushBAIDU = pushBAIDU\n break\n }\n\n /**\n * 部署站点并初始化\n */\n if (siteIdList && Array.isArray(siteIdList)) {\n pushBAIDU.init()\n }\n\n /**\n * 路由切换时执行PV上报\n */\n router.afterEach(() => {\n // 获取要上报的链接(当前版本不需要拼接了)\n const PAGE_URL: string = window.location.href\n\n // 上报数据\n pushBAIDU.pv(PAGE_URL)\n })\n}\n","import type { Vue } from '@/types'\n\n/**\n * 获取Vue的版本\n * @return 2=Vue2.x, 3=Vue3.x\n */\nconst getVueVersion = (Vue: Vue): number => {\n let version: number = 2\n\n // 获取Vue的版本号\n const VUE_VERSION: string = String(Vue.version)\n\n // Vue 2.x\n if (VUE_VERSION.slice(0, 2) === '2.') {\n version = 2\n }\n\n // Vue 3.x\n if (VUE_VERSION.slice(0, 2) === '3.') {\n version = 3\n }\n\n return version\n}\n\nexport default getVueVersion\n"],"names":["siteId","isDebug","this","BAIDU","window","_hmt","SCRIPT","document","createElement","querySelector","appendChild","console","log","push","pageUrl","startsWith","PAGE_CUT","split","HOST_NAME","replace","setAccount","category","action","label","value","Error","Number","siteIdList","to","from","pack","arguments","length","ar","i","l","Array","prototype","slice","call","concat","PushBAIDU","forEach","_this","init","trackPageview","trackEvent","__GLOBAL__","pushBAIDU","Vue","_a","router","_b","version","VUE_VERSION","String","getVueVersion","$pushBAIDU","config","globalProperties","isArray","afterEach","PAGE_URL","location","href","pv","event"],"mappings":";;;;;;;;;;;;;;;;;;;oFAIA,iBAIE,WAAYA,EAAqBC,gBAArBD,mBAAqBC,MAC/BC,KAAKF,OAASA,EACdE,KAAKD,QAAUA,EAyFnB,OAnFEE,iBAAA,iBACEC,OAAOC,KAAOD,OAAOC,KAAOD,OAAOC,KAAO,GAC1C,IAAMC,EAASC,SAASC,cAAc,UACtCF,EAAc,OAAI,EAClBA,EAAY,IAAI,8BAA8BJ,KAAKF,iBACnDO,SAASE,cAAc,wBAASC,YAAYJ,GAExCJ,KAAKD,SACPU,QAAQC,IACN,uDAAuDV,KAAKF,SAQlEG,uBAAA,WACEC,OAAOC,KAAKQ,KAAK,CAAC,cAAeX,KAAKF,UAMxCG,0BAAA,SAAcW,GAOZ,GALKA,GAA8B,iBAAZA,IACrBA,EAAU,KAIRA,EAAQC,WAAW,QAAS,CAC9B,IAAMC,EAAWF,EAAQG,MAAM,KACzBC,EAAeF,EAAS,QAAOA,EAAS,GAC9CF,EAAUA,EAAQK,QAAQD,EAAW,IAIvChB,KAAKkB,aACLhB,OAAOC,KAAKQ,KAAK,CAAC,iBAAkBC,IAEhCZ,KAAKD,SACPU,QAAQC,IACN,oDAAoDV,KAAKF,uBAAsBc,IAQrFX,uBAAA,SAAWkB,EAAkBC,EAAgBC,EAAeC,GAE1D,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R,iFAIJ,IAAKE,EACH,MAAM,IAAIF,MACR,iGAOJ,IAAMuB,EAAuB,IAAIP,EAAUd,EAAY1B,GAQvD,OAPA8C,EAAWC,UAAYA,ECjEH,SAACC,GACrB,IAAII,EAAkB,EAGhBC,EAAsBC,OAAON,EAAII,SAYvC,MATgC,OAA5BC,EAAYhB,MAAM,EAAG,KACvBe,EAAU,GAIoB,OAA5BC,EAAYhB,MAAM,EAAG,KACvBe,EAAU,GAGLA,EDuDqBG,CAAcP,IAAQ,GAEhD,KAAK,EACHA,EAAIZ,UAAUoB,WAAaT,EAC3B,MACF,KAAK,EACHC,EAAIS,OAAOC,iBAAiBF,WAAaT,EAOzCrB,GAAcS,MAAMwB,QAAQjC,IAC9BqB,EAAUJ,OAMZO,EAAOU,WAAU,WAEf,IAAMC,EAAmB1D,OAAO2D,SAASC,KAGzChB,EAAUiB,GAAGH,4BAnEf,MAAO,CACLG,GAfF,SAAYnD,GACV,OAAOiC,EAAWC,UAAUiB,GAAGnD,IAe/BoD,MAXF,SACE7C,EACAC,EACAC,EACAC,GAEA,OAAOuB,EAAWC,UAAUkB,MAAM7C,EAAUC,EAAQC,EAAOC"} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 2d3dfac..3ab4788 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2829,7 +2829,7 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" -tslib@2.1.0, tslib@^2.0.1: +tslib@2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a" integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A== @@ -2839,6 +2839,11 @@ tslib@^1.8.1, tslib@^1.9.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== +tslib@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.0.tgz#803b8cdab3e12ba581a4ca41c8839bbb0dacb09e" + integrity sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg== + tsutils@^3.17.1: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"