@huolala-tech/page-spy-mp-base
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -16,3 +16,4 @@ import { ConfigBase } from '@huolala-tech/page-spy-base'; | ||
secret: string; | ||
serializeData: boolean; | ||
}; | ||
} |
@@ -21,4 +21,5 @@ import { ConfigBase } from '@huolala-tech/page-spy-base'; | ||
secret: '', | ||
serializeData: false, | ||
}; | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { SpyConsole, PageSpyPlugin } from '@huolala-tech/page-spy-types/index'; | ||
import type { SpyConsole, PageSpyPlugin, OnInitParams, InitConfigBase } from '@huolala-tech/page-spy-types/index'; | ||
export default class ConsolePlugin implements PageSpyPlugin { | ||
@@ -7,5 +7,6 @@ name: string; | ||
proxyTypes: SpyConsole.ProxyType[]; | ||
onInit(): Promise<void>; | ||
$pageSpyConfig: InitConfigBase | null; | ||
onInit({ config }: OnInitParams<InitConfigBase>): Promise<void>; | ||
onReset(): void; | ||
printLog(data: SpyConsole.DataItem): void; | ||
} |
@@ -16,6 +16,7 @@ import { __awaiter } from "tslib"; | ||
]; | ||
this.$pageSpyConfig = null; | ||
} | ||
// eslint-disable-next-line class-methods-use-this | ||
onInit() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
onInit(_a) { | ||
return __awaiter(this, arguments, void 0, function* ({ config }) { | ||
if (ConsolePlugin.hasInitd) | ||
@@ -25,2 +26,3 @@ return; | ||
const that = this; | ||
this.$pageSpyConfig = config; | ||
this.proxyTypes.forEach((item) => { | ||
@@ -63,9 +65,18 @@ // Not using globalThis or global, cause "console" exists in any env, | ||
printLog(data) { | ||
var _a; | ||
if (data.logs && data.logs.length) { | ||
this.console[data.logType](...data.logs); | ||
// eslint-disable-next-line no-param-reassign | ||
data.logs = data.logs.map((log) => atom.transformToAtom(log)); | ||
const log = makeMessage('console', Object.assign({ time: Date.now() }, data)); | ||
socketStore.dispatchEvent('public-data', log); | ||
socketStore.broadcastMessage(log); | ||
const atomLog = makeMessage('console', Object.assign(Object.assign({}, data), { time: Date.now(), logs: data.logs.map((log) => { | ||
return atom.transformToAtom(log, false); | ||
}) })); | ||
socketStore.broadcastMessage(atomLog); | ||
if (!((_a = this.$pageSpyConfig) === null || _a === void 0 ? void 0 : _a.serializeData)) { | ||
socketStore.dispatchEvent('public-data', atomLog); | ||
} | ||
else { | ||
const serializeLog = Object.assign(Object.assign({}, atomLog), { data: Object.assign(Object.assign({}, atomLog.data), { logs: data.logs.map((log) => { | ||
return atom.transformToAtom(log, true); | ||
}) }) }); | ||
socketStore.dispatchEvent('public-data', serializeLog); | ||
} | ||
} | ||
@@ -72,0 +83,0 @@ } |
{ | ||
"name": "@huolala-tech/page-spy-mp-base", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "The base of PageSpy for miniprogram.", | ||
@@ -22,4 +22,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@huolala-tech/page-spy-base": "^1.0.1", | ||
"@huolala-tech/page-spy-types": "^1.9.1" | ||
"@huolala-tech/page-spy-base": "^1.0.2", | ||
"@huolala-tech/page-spy-types": "^1.9.2" | ||
}, | ||
@@ -51,3 +51,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "0d37b04a99d11ceaa2673516f725ae667867eb45" | ||
"gitHead": "a58bd8709a155b816e894788c507b25bf3464a11" | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
63066
1708
0