@ohbug/core 2.2.1 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +30 -24
- package/dist/index.mjs +456 -582
- package/dist/index.mjs.map +1 -0
- package/package.json +18 -19
- package/dist/index.d.ts +0 -29
- package/dist/index.js +0 -639
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["baseSchema","schema"],"sources":["../src/action.ts","../src/config.ts","../src/lib/getErrorMessage.ts","../src/lib/metadata.ts","../src/event.ts","../src/lib/verifyConfig.ts","../src/notify.ts","../src/client.ts","../src/extension.ts","../src/types.ts"],"sourcesContent":["import type { OhbugAction } from \"@ohbug/types\";\n\nexport class Action implements OhbugAction {\n readonly type: string;\n\n readonly timestamp: string;\n\n readonly message: string;\n\n readonly data: Record<string, any>;\n\n constructor(message: string, data: Record<string, any>, type: string, timestamp?: string) {\n this.type = type;\n this.timestamp = timestamp || new Date().toISOString();\n this.message = message;\n this.data = data;\n }\n}\n","import type { OhbugEventWithMethods, OhbugSchema } from \"@ohbug/types\";\nimport { isFunction, isNumber, isObject, isString, logger } from \"@ohbug/utils\";\n\nexport const schema: OhbugSchema = {\n // base\n apiKey: {\n defaultValue: undefined,\n message: \"is required\",\n validate: (value) => Boolean(value) && isString(value),\n },\n appVersion: {\n defaultValue: undefined,\n message: \"should be a string\",\n validate: (value) => value === undefined || isString(value),\n },\n appType: {\n defaultValue: undefined,\n message: \"should be a string\",\n validate: (value) => value === undefined || isString(value),\n },\n releaseStage: {\n defaultValue: \"production\",\n message: \"should be a string\",\n validate: (value) => value === undefined || isString(value),\n },\n endpoint: {\n defaultValue: \"http://localhost:6660\",\n message: \"should be a string\",\n validate: (value) => value === undefined || isString(value),\n },\n notifier: {\n defaultValue: undefined,\n message: \"should be a function\",\n validate: (value) => value === undefined || isFunction(value),\n },\n maxActions: {\n defaultValue: 30,\n message: \"should be a number between 0 and 100\",\n validate: (value) => value === undefined || (isNumber(value) && value >= 0 && value <= 100),\n },\n // hooks\n onEvent: {\n defaultValue: (event: OhbugEventWithMethods<any>) => event,\n message: \"should be a function\",\n validate: (value) => value === undefined || isFunction(value),\n },\n onNotify: {\n defaultValue: () => {},\n message: \"should be a function\",\n validate: (value) => value === undefined || isFunction(value),\n },\n // utils\n logger: {\n defaultValue: logger,\n message: \"should be null or an object with methods { log, info, warn, error }\",\n validate: (value) =>\n value === undefined ||\n (value &&\n [\"log\", \"info\", \"warn\", \"error\"].reduce<boolean>(\n (accumulator, method) => accumulator && typeof value[method] === \"function\",\n true,\n )),\n },\n // data\n user: {\n defaultValue: undefined,\n message: \"should be an object and have up to 6 attributes\",\n validate: (value) => value === undefined || (isObject(value) && Object.keys(value).length <= 6),\n },\n metadata: {\n defaultValue: undefined,\n message: \"should be an object\",\n validate: (value) => value === undefined || isObject(value),\n },\n};\n","import type { OhbugConfig } from \"@ohbug/types\";\n\nexport function getConfigErrorMessage(\n errors: Record<keyof OhbugConfig, string>,\n config: OhbugConfig,\n) {\n return new Error(`Invalid configuration\\n${Object.keys(errors)\n .map((key) => {\n return `- ${key} ${errors[key as keyof OhbugConfig]}, got ${JSON.stringify(config[key as keyof OhbugConfig])}`;\n })\n .join(\"\\n\")}\n `);\n}\n\nexport function getErrorMessage(message: string, data: any) {\n return new Error(`Invalid data\\n- ${message}, got ${JSON.stringify(data)}`);\n}\n","import type { OhbugMetadata } from \"@ohbug/types\";\n\nexport function addMetadata(map: OhbugMetadata, section: string, data: any) {\n if (!section) return;\n\n map[section] = data;\n}\n\nexport function getMetadata(map: OhbugMetadata, section: string) {\n if (map[section]) {\n return map[section];\n }\n\n return undefined;\n}\n\nexport function deleteMetadata(map: OhbugMetadata, section: string) {\n if (map[section]) {\n return delete map[section];\n }\n\n return undefined;\n}\n","import type {\n OhbugAction,\n OhbugCategory,\n OhbugClient,\n OhbugCreateEvent,\n OhbugDevice,\n OhbugEvent,\n OhbugEventWithMethods,\n OhbugMetadata,\n OhbugReleaseStage,\n OhbugSDK,\n OhbugUser,\n} from \"@ohbug/types\";\nimport { isFunction, isObject, isString } from \"@ohbug/utils\";\n\nimport { Action } from \"./action\";\nimport { getErrorMessage } from \"./lib/getErrorMessage\";\nimport { addMetadata, deleteMetadata, getMetadata } from \"./lib/metadata\";\n\nexport class Event<D> implements OhbugEventWithMethods<D> {\n readonly apiKey: string;\n\n readonly appVersion?: string;\n\n readonly appType?: string;\n\n readonly timestamp: string;\n\n readonly category?: OhbugCategory;\n\n readonly type: string;\n\n readonly sdk: OhbugSDK;\n\n readonly device: OhbugDevice;\n\n readonly detail: D;\n\n user?: OhbugUser;\n\n readonly actions?: OhbugAction[];\n\n readonly metadata: OhbugMetadata;\n\n readonly releaseStage?: OhbugReleaseStage;\n\n readonly __client?: OhbugClient;\n\n constructor(values: OhbugEvent<D>, client?: OhbugClient) {\n const {\n apiKey,\n appVersion,\n appType,\n releaseStage,\n timestamp,\n category,\n type,\n sdk,\n\n detail,\n device,\n user,\n actions,\n metadata,\n } = values;\n this.apiKey = apiKey;\n this.appVersion = appVersion;\n this.appType = appType;\n this.releaseStage = releaseStage;\n this.timestamp = timestamp;\n this.category = category;\n this.type = type;\n this.sdk = sdk;\n\n this.detail = detail;\n this.device = device;\n this.user = user;\n this.actions = actions;\n this.metadata = metadata ?? {};\n\n this.__client = client;\n }\n\n get __isOhbugEvent() {\n return true;\n }\n\n /**\n * Add an action.\n * Once the threshold is reached, the oldest actions will be deleted.\n * 新增一个动作。\n * 一旦达到阈值,最老的 Action 将被删除。\n *\n * @param message\n * @param data\n * @param type\n * @param timestamp\n */\n addAction(message: string, data: Record<string, any>, type: string, timestamp?: string): void {\n const actions = this.actions!;\n\n const targetMessage = isString(message) ? message : \"\";\n const targetData = data || {};\n const targetType = isString(type) ? type : \"\";\n\n const action = new Action(targetMessage, targetData, targetType, timestamp);\n const maxActions = this.__client?.__config.maxActions ?? 30;\n if (maxActions > 0) {\n if (actions.length >= maxActions) {\n actions.shift();\n }\n actions.push(action);\n }\n }\n\n /**\n * Get current user information\n * 获取当前的用户信息\n */\n getUser(): OhbugUser | undefined {\n return this.user;\n }\n\n /**\n * Set current user information\n * 设置当前的用户信息\n */\n setUser(user: OhbugUser): OhbugUser | undefined {\n if (isObject(user) && Object.keys(user).length <= 6) {\n this.user = { ...this.user, ...user };\n return this.getUser();\n }\n this.__client?.__logger.error(\n getErrorMessage(\"setUser should be an object and have up to 6 attributes\", user),\n );\n return undefined;\n }\n\n /**\n * Add metadata\n * 新增 metadata\n *\n * @param section\n * @param data\n */\n addMetadata(section: string, data: any) {\n return addMetadata(this.metadata, section, data);\n }\n\n /**\n * Get metadata\n * 获取 metadata\n *\n * @param section\n */\n getMetadata(section: string) {\n return getMetadata(this.metadata, section);\n }\n\n /**\n * Delete metadata\n * 删除 metadata\n *\n * @param section\n */\n deleteMetadata(section: string) {\n return deleteMetadata(this.metadata, section);\n }\n\n toJSON() {\n const {\n apiKey,\n appVersion,\n appType,\n timestamp,\n category,\n type,\n sdk,\n device,\n detail,\n user,\n actions,\n metadata,\n releaseStage,\n } = this;\n return {\n apiKey,\n appVersion,\n appType,\n timestamp,\n category,\n type,\n sdk,\n device,\n detail,\n user,\n actions,\n metadata,\n releaseStage,\n };\n }\n}\n\nexport function createEvent<D>(\n values: OhbugCreateEvent<D>,\n client: OhbugClient,\n): OhbugEventWithMethods<D> {\n const { apiKey, appVersion, appType, releaseStage } = client.__config;\n const timestamp = new Date().toISOString();\n const device = client.__device(client);\n let category: OhbugCategory;\n let type: string;\n let detail: D;\n if (\n isObject(values) &&\n Object.prototype.hasOwnProperty.call(values, \"type\") &&\n Object.prototype.hasOwnProperty.call(values, \"detail\")\n ) {\n category = values.category || \"error\";\n type = values.type;\n detail = values.detail;\n } else {\n category = \"error\";\n type = \"unknownError\";\n detail = values as unknown as D;\n }\n\n return new Event(\n {\n apiKey,\n appVersion,\n appType,\n timestamp,\n category,\n type,\n sdk: client.__sdk,\n device,\n user: client.__user,\n detail,\n actions: client.__actions,\n metadata: client.__metadata,\n releaseStage,\n },\n client,\n );\n}\n\nexport function handleEventCreated<D = any>(\n event: OhbugEventWithMethods<D>,\n client: OhbugClient,\n): OhbugEventWithMethods<D> | null {\n const funcs = [\n client.__config.onEvent,\n ...client.__extensions.map(({ onEvent }) => onEvent),\n ].filter((v) => isFunction(v)) as ((\n event: OhbugEventWithMethods<D>,\n client: OhbugClient,\n ) => OhbugEventWithMethods<D> | null)[];\n if (funcs.length === 0) {\n return event;\n }\n\n return funcs.reduce<OhbugEventWithMethods<D> | null>((previous, current) => {\n if (previous && isFunction(current)) {\n return current(previous, client);\n }\n\n return null;\n }, event);\n}\n\nexport function isEvent(eventLike: any): eventLike is OhbugEventWithMethods<any> {\n return Boolean(eventLike?.__isOhbugEvent);\n}\n","import type { OhbugConfig, OhbugSchema } from \"@ohbug/types\";\n\ninterface ConfigAndErrors {\n config: Record<keyof OhbugConfig, any>;\n errors: Record<keyof OhbugConfig, string>;\n}\nexport function verifyConfig(config: OhbugConfig, schema: OhbugSchema) {\n const keys = Object.keys(schema) as (keyof OhbugConfig)[];\n return keys.reduce<ConfigAndErrors>(\n (accumulator, key) => {\n const configValue = config[key];\n const { defaultValue, message, validate } = schema[key];\n\n if (configValue !== undefined) {\n const valid = validate(configValue);\n if (valid) {\n accumulator.config[key] = configValue;\n } else {\n accumulator.config[key] = defaultValue;\n accumulator.errors[key] = message;\n }\n } else {\n // if there is no corresponding configuration, use the default value\n // 如果没有传入相应配置 使用默认值\n accumulator.config[key] = defaultValue;\n }\n\n return accumulator;\n },\n {\n config: {} as ConfigAndErrors[\"config\"],\n errors: {} as ConfigAndErrors[\"errors\"],\n },\n );\n}\n","import type { OhbugClient, OhbugEventWithMethods } from \"@ohbug/types\";\nimport { isFunction } from \"@ohbug/utils\";\n\nfunction handleNotified<D>(event: OhbugEventWithMethods<D>, client: OhbugClient) {\n const funcs = [\n client.__config.onNotify,\n ...client.__extensions\n .filter(({ onNotify }) => isFunction(onNotify))\n .map(({ onNotify }) => onNotify),\n ];\n funcs.forEach((func) => func?.(event, client));\n}\n\n/**\n * Used to control the timing of reporting events and the related life cycle.\n *\n * @param event\n * @param client\n */\nexport async function notify<D>(\n event: OhbugEventWithMethods<D> | null,\n client: OhbugClient,\n): Promise<any> {\n if (!event) return null;\n\n let result = null;\n try {\n result = await client.__notifier(event);\n } catch (e) {\n client.__logger.error(e);\n }\n\n // Always run onNotify hooks, even if the built-in notifier failed.\n // This lets extensions (e.g. custom OTLP exporters) handle events independently.\n handleNotified(event, client);\n\n return result;\n}\n","import type {\n OhbugAction,\n OhbugClient,\n OhbugClientConstructor,\n OhbugClientConstructorValues,\n OhbugConfig,\n OhbugCreateEvent,\n OhbugDestroy,\n OhbugEventWithMethods,\n OhbugExtension,\n OhbugGetDevice,\n OhbugLoggerConfig,\n OhbugMetadata,\n OhbugNotifier,\n OhbugSDK,\n OhbugUser,\n} from \"@ohbug/types\";\nimport { isObject, isString } from \"@ohbug/utils\";\n\nimport { Action } from \"./action\";\nimport { schema as baseSchema } from \"./config\";\nimport { createEvent, handleEventCreated, isEvent } from \"./event\";\nimport { getConfigErrorMessage, getErrorMessage } from \"./lib/getErrorMessage\";\nimport { addMetadata, deleteMetadata, getMetadata } from \"./lib/metadata\";\nimport { verifyConfig } from \"./lib/verifyConfig\";\nimport { notify } from \"./notify\";\n\nexport const Client: OhbugClientConstructor = class Client implements OhbugClient {\n readonly __sdk: OhbugSDK;\n\n readonly __config: OhbugConfig;\n\n readonly __logger: OhbugLoggerConfig;\n\n readonly __device: OhbugGetDevice;\n\n readonly __notifier: OhbugNotifier;\n\n readonly __destroy?: OhbugDestroy;\n\n readonly __extensions: OhbugExtension[];\n\n readonly __actions: OhbugAction[];\n\n __user: OhbugUser;\n\n readonly __metadata: OhbugMetadata;\n\n constructor({\n sdk,\n config: baseConfig,\n schema = baseSchema,\n device,\n notifier,\n destroy,\n }: OhbugClientConstructorValues) {\n const { config, errors } = verifyConfig(baseConfig, schema);\n\n // initialization\n this.__sdk = sdk;\n this.__config = config;\n this.__logger = config.logger;\n this.__device = device;\n this.__notifier = notifier;\n this.__destroy = destroy;\n\n this.__extensions = [];\n\n this.__actions = [];\n this.__user = config.user;\n this.__metadata = {};\n if (isObject(config.metadata)) {\n Object.keys(config.metadata).forEach((key) => {\n this.addMetadata(key, config.metadata[key]);\n });\n }\n\n if (Object.keys(errors).length) {\n this.__logger.warn(getConfigErrorMessage(errors, baseConfig));\n }\n }\n\n /**\n * Load extension\n * 加载扩展\n *\n * @param extension\n */\n use(extension: OhbugExtension): OhbugClient {\n this.__extensions.push(extension);\n extension.onSetup?.(this);\n return this;\n }\n\n destroy(): void {\n if (this.__destroy) {\n this.__logger.info(\n \"%c @ohbug/core %c has been destroyed %c\",\n \"background:#333; padding: 2px 1px; color: #FFF\",\n \"background:#FF6F61; padding: 2px 1px; color: #FFF\",\n \"background:transparent\",\n );\n this.__extensions.forEach((extension) => extension.onDestroy?.(this));\n return this.__destroy?.();\n }\n }\n\n /**\n * Create an event, you will get a data body containing device actions and other information\n * 创建事件,将会得到一个含有 device actions 等信息的数据体\n *\n * @param value\n */\n createEvent<D = any>(value: OhbugCreateEvent<D>): OhbugEventWithMethods<D> | null {\n const event = createEvent(value, this);\n\n return handleEventCreated(event, this);\n }\n\n /**\n * Used to trigger the reporting interface\n * 用于触发上报接口\n *\n * @param eventLike\n * @param beforeNotify\n */\n notify<D = any>(\n eventLike: any,\n beforeNotify?: (event: OhbugEventWithMethods<D> | null) => OhbugEventWithMethods<D> | null,\n ): Promise<any> {\n let event: OhbugEventWithMethods<D> | null;\n if (Boolean(eventLike) && !isEvent(eventLike)) {\n event = this.createEvent(eventLike);\n } else {\n event = eventLike;\n }\n\n if (beforeNotify) event = beforeNotify(event);\n\n return notify<D>(event, this);\n }\n\n /**\n * Add an action.\n * Once the threshold is reached, the oldest actions will be deleted.\n * 新增一个动作。\n * 一旦达到阈值,最老的 Action 将被删除。\n *\n * @param message\n * @param data\n * @param type\n * @param timestamp\n */\n addAction(message: string, data: Record<string, any>, type: string, timestamp?: string): void {\n const actions = this.__actions;\n\n const targetMessage = isString(message) ? message : \"\";\n const targetData = data || {};\n const targetType = isString(type) ? type : \"\";\n\n const action = new Action(targetMessage, targetData, targetType, timestamp);\n const maxActions = this.__config.maxActions ?? 30;\n if (maxActions > 0) {\n if (actions.length >= maxActions) {\n actions.shift();\n }\n actions.push(action);\n }\n }\n\n /**\n * Get current user information\n * 获取当前的用户信息\n */\n getUser(): OhbugUser | undefined {\n return this.__user;\n }\n\n /**\n * Set current user information\n * 设置当前的用户信息\n */\n setUser(user: OhbugUser): OhbugUser | undefined {\n if (isObject(user) && Object.keys(user).length <= 6) {\n this.__user = { ...this.__user, ...user };\n return this.getUser();\n }\n this.__logger.warn(\n getErrorMessage(\"setUser should be an object and have up to 6 attributes\", user),\n );\n return undefined;\n }\n\n /**\n * Add metadata\n * 新增 metadata\n *\n * @param section\n * @param data\n */\n addMetadata(section: string, data: any) {\n return addMetadata(this.__metadata, section, data);\n }\n\n /**\n * Get metadata\n * 获取 metadata\n *\n * @param section\n */\n getMetadata(section: string) {\n return getMetadata(this.__metadata, section);\n }\n\n /**\n * Delete metadata\n * 删除 metadata\n *\n * @param section\n */\n deleteMetadata(section: string) {\n return deleteMetadata(this.__metadata, section);\n }\n};\n","import type { OhbugExtension } from \"@ohbug/types\";\n\nexport function defineExtension(extension: OhbugExtension) {\n if (!extension) return {} as OhbugExtension;\n return extension;\n}\n","export const EventTypes = {\n // error\n UNCAUGHT_ERROR: \"uncaughtError\", // 意料之外的错误\n RESOURCE_ERROR: \"resourceError\", // 资源加载错误\n UNHANDLEDREJECTION_ERROR: \"unhandledrejectionError\", // unhandledrejection 错误,可能包含 Promise, react render 等错误\n AJAX_ERROR: \"ajaxError\", // ajax 错误\n FETCH_ERROR: \"fetchError\", // fetch 错误\n WEBSOCKET_ERROR: \"websocketError\", // websocket 错误\n UNKNOWN_ERROR: \"unknownError\", // 未知错误\n // message\n MESSAGE: \"message\", // 主动上报的信息\n // feedback\n FEEDBACK: \"feedback\", // 反馈\n // view\n VIEW: \"view\", // 用于计算 PV/UV\n // react\n REACT: \"react\",\n // vue\n VUE: \"vue\",\n // angular\n ANGULAR: \"angular\",\n // miniapp\n MINIAPP_ERROR: \"miniappError\",\n MINIAPP_UNHANDLEDREJECTION_ERROR: \"miniappUnhandledrejectionError\",\n MINIAPP_PAGENOTFOUND_ERROR: \"miniappPagenotfoundError\",\n MINIAPP_MEMORYWARNING_ERROR: \"miniappMemorywarningError\",\n} as const;\n\nexport type EventTypes = (typeof EventTypes)[keyof typeof EventTypes];\n"],"mappings":";;AAEA,IAAa,SAAb,MAA2C;CACzC;CAEA;CAEA;CAEA;CAEA,YAAY,SAAiB,MAA2B,MAAc,WAAoB;AACxF,OAAK,OAAO;AACZ,OAAK,YAAY,8BAAa,IAAI,MAAM,EAAC,aAAa;AACtD,OAAK,UAAU;AACf,OAAK,OAAO;;;;;ACZhB,MAAa,SAAsB;CAEjC,QAAQ;EACN,cAAc,KAAA;EACd,SAAS;EACT,WAAW,UAAU,QAAQ,MAAM,IAAI,SAAS,MAAM;EACvD;CACD,YAAY;EACV,cAAc,KAAA;EACd,SAAS;EACT,WAAW,UAAU,UAAU,KAAA,KAAa,SAAS,MAAM;EAC5D;CACD,SAAS;EACP,cAAc,KAAA;EACd,SAAS;EACT,WAAW,UAAU,UAAU,KAAA,KAAa,SAAS,MAAM;EAC5D;CACD,cAAc;EACZ,cAAc;EACd,SAAS;EACT,WAAW,UAAU,UAAU,KAAA,KAAa,SAAS,MAAM;EAC5D;CACD,UAAU;EACR,cAAc;EACd,SAAS;EACT,WAAW,UAAU,UAAU,KAAA,KAAa,SAAS,MAAM;EAC5D;CACD,UAAU;EACR,cAAc,KAAA;EACd,SAAS;EACT,WAAW,UAAU,UAAU,KAAA,KAAa,WAAW,MAAM;EAC9D;CACD,YAAY;EACV,cAAc;EACd,SAAS;EACT,WAAW,UAAU,UAAU,KAAA,KAAc,SAAS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ACzC,UAAO,KAAK,SAAS;;AAEvB,OAAK,SAAS,KACZ,gBAAgB,2DAA2D,KAAK,CACjF;;;;;;;;;CAWH,YAAY,SAAiB,MAAW;AACtC,SAAO,YAAY,KAAK,YAAY,SAAS,KAAK;;;;;;;;CASpD,YAAY,SAAiB;AAC3B,SAAO,YAAY,KAAK,YAAY,QAAQ;;;;;;;;CAS9C,eAAe,SAAiB;AAC9B,SAAO,eAAe,KAAK,YAAY,QAAQ;;;;;AC3NnD,SAAgB,gBAAgB,WAA2B;AACzD,KAAI,CAAC,UAAW,QAAO,EAAE;AACzB,QAAO;;;;ACJT,MAAa,aAAa;CAExB,gBAAgB;CAChB,gBAAgB;CAChB,0BAA0B;CAC1B,YAAY;CACZ,aAAa;CACb,iBAAiB;CACjB,eAAe;CAEf,SAAS;CAET,UAAU;CAEV,MAAM;CAEN,OAAO;CAEP,KAAK;CAEL,SAAS;CAET,eAAe;CACf,kCAAkC;CAClC,4BAA4B;CAC5B,6BAA6B;CAC9B"}
|
package/package.json
CHANGED
|
@@ -1,40 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohbug/core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "Responsible for managing Ohbug's workflow",
|
|
5
|
-
"
|
|
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,
|
|
24
|
+
"types": "dist/index.d.mts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": "./dist/index.mjs",
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@ohbug/types": "2.2.
|
|
34
|
-
"@ohbug/utils": "2.0.
|
|
33
|
+
"@ohbug/types": "2.2.2",
|
|
34
|
+
"@ohbug/utils": "2.0.10"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
|
-
"
|
|
38
|
-
"dev": "tsup --watch"
|
|
37
|
+
"dev": "vp pack --watch"
|
|
39
38
|
}
|
|
40
39
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { OhbugClientConstructor, OhbugEventWithMethods, OhbugExtension } from '@ohbug/types';
|
|
2
|
-
|
|
3
|
-
declare const Client: OhbugClientConstructor;
|
|
4
|
-
|
|
5
|
-
declare function isEvent(eventLike: any): eventLike is OhbugEventWithMethods<any>;
|
|
6
|
-
|
|
7
|
-
declare function defineExtension(extension: OhbugExtension): OhbugExtension;
|
|
8
|
-
|
|
9
|
-
declare const enum EventTypes {
|
|
10
|
-
UNCAUGHT_ERROR = "uncaughtError",
|
|
11
|
-
RESOURCE_ERROR = "resourceError",
|
|
12
|
-
UNHANDLEDREJECTION_ERROR = "unhandledrejectionError",
|
|
13
|
-
AJAX_ERROR = "ajaxError",
|
|
14
|
-
FETCH_ERROR = "fetchError",
|
|
15
|
-
WEBSOCKET_ERROR = "websocketError",
|
|
16
|
-
UNKNOWN_ERROR = "unknownError",
|
|
17
|
-
MESSAGE = "message",
|
|
18
|
-
FEEDBACK = "feedback",
|
|
19
|
-
VIEW = "view",
|
|
20
|
-
REACT = "react",
|
|
21
|
-
VUE = "vue",
|
|
22
|
-
ANGULAR = "angular",
|
|
23
|
-
MINIAPP_ERROR = "miniappError",
|
|
24
|
-
MINIAPP_UNHANDLEDREJECTION_ERROR = "miniappUnhandledrejectionError",
|
|
25
|
-
MINIAPP_PAGENOTFOUND_ERROR = "miniappPagenotfoundError",
|
|
26
|
-
MINIAPP_MEMORYWARNING_ERROR = "miniappMemorywarningError"
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { Client, EventTypes, defineExtension, isEvent };
|