Skip to content

Commit

Permalink
fix mp plugin webpack mp sdk wrongly pack & fix react-native sdk upda…
Browse files Browse the repository at this point in the history
…teRoomInfo without client info
  • Loading branch information
qkang07 committed Nov 28, 2024
1 parent 12b700a commit f4f6574
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 262 deletions.
2 changes: 0 additions & 2 deletions packages/page-spy-mp-base/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import commonjs from '@rollup/plugin-commonjs';
import nodeResolve from '@rollup/plugin-node-resolve';
import json from '@rollup/plugin-json';
import replace from '@rollup/plugin-replace';
import terser from '@rollup/plugin-terser';
import { DEFAULT_EXTENSIONS } from '@babel/core';
import fs from 'fs';

Expand All @@ -21,7 +20,6 @@ const plugins = [
replace({
preventAssignment: true,
}),
terser(),
];

/**
Expand Down
1 change: 1 addition & 0 deletions packages/page-spy-mp-base/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class PageSpy {
config,
atom,
client: PageSpy.client,
mp,
});

this.init();
Expand Down
7 changes: 7 additions & 0 deletions packages/page-spy-mp-base/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { InitConfigBase, OnInitParams } from '@huolala-tech/page-spy-types';

export type AsyncCallback<R = void, E = any> = {
success?: (res: R) => void;
fail?: (error: E) => void;
Expand Down Expand Up @@ -323,3 +325,8 @@ export type MPSDK = MPUIAPI &
MPNetworkAPI &
MPSystemAPI &
MPRouterAPI;

export interface MPPluginInitParams<T extends InitConfigBase>
extends OnInitParams<T> {
mp: MPSDK;
}
7 changes: 5 additions & 2 deletions packages/page-spy-plugin-mp-data-harbor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
type Client,
type SocketStoreBase,
psLog,
MPPluginInitParams,
setMPSDK,
} from '@huolala-tech/page-spy-mp-base';

interface DataHarborConfig {
Expand Down Expand Up @@ -75,10 +77,11 @@ export default class MPDataHarborPlugin implements PageSpyPlugin {
socketStore,
config,
client,
}: OnInitParams<InitConfigBase>) {
mp,
}: MPPluginInitParams<InitConfigBase>) {
if (MPDataHarborPlugin.hasInited) return;
MPDataHarborPlugin.hasInited = true;

setMPSDK(mp);
this.$pageSpyConfig = config;
this.$socketStore = socketStore;
this.client = client;
Expand Down
227 changes: 0 additions & 227 deletions packages/page-spy-plugin-mp-data-harbor/src/plugin.ts

This file was deleted.

5 changes: 2 additions & 3 deletions packages/page-spy-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"version": "2.0.0-beta.1",
"description": "An SDK of PageSpy for debugging react native app",
"license": "MIT",
"main": "dist/cjs/index.min.js",
"module": "dist/esm/index.min.js",
"main": "dist/esm/index.min.js",
"types": "dist/types/index.d.ts",
"files": [
"dist"
Expand All @@ -29,7 +28,6 @@
"watch": "rollup -c -w"
},
"dependencies": {
"@huolala-tech/page-spy-base": "^2.0.0-beta.1",
"@huolala-tech/page-spy-types": "^2.0.0-beta.1",
"promise": "^8.3.0"
},
Expand All @@ -39,6 +37,7 @@
"@babel/preset-env": "^7.14.1",
"@babel/preset-typescript": "^7.13.0",
"@babel/runtime": "^7.13.0",
"@huolala-tech/page-spy-base": "^2.0.0-beta.1",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
Expand Down
5 changes: 0 additions & 5 deletions packages/page-spy-react-native/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ export default {
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true,
},
{
file: pkg.module,
format: 'esm',
sourcemap: true,
},
Expand Down
25 changes: 14 additions & 11 deletions packages/page-spy-react-native/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
isArray,
isClass,
psLog,
} from '@huolala-tech/page-spy-base';
} from '@huolala-tech/page-spy-base/dist/utils';
import { Client } from '@huolala-tech/page-spy-base/dist/client';
import type {
PageSpyPlugin,
Expand Down Expand Up @@ -57,16 +57,7 @@ class PageSpy {
];
}

static client: Client = new Client({
osType: osMap[Platform.OS] || 'unknown',
osVersion: String(Platform.Version),
browserType: 'react-native',
browserVersion: `${rnv.major}.${rnv.minor}.${rnv.patch}${
rnv.prerelease ? '-' + rnv.prerelease : ''
}`,
framework: 'react-native',
sdk: 'rn',
});
static client: Client;

request: Request | null = null;

Expand Down Expand Up @@ -145,6 +136,7 @@ class PageSpy {

socketStore.connectable = true;
socketStore.getPageSpyConfig = () => this.config.get();
socketStore.getClient = () => PageSpy.client;
socketStore.messageCapacity = messageCapacity;
}

Expand Down Expand Up @@ -203,6 +195,17 @@ class PageSpy {
}
}

PageSpy.client = new Client({
osType: osMap[Platform.OS] || 'unknown',
osVersion: String(Platform.Version),
browserType: 'react-native',
browserVersion: `${rnv.major}.${rnv.minor}.${rnv.patch}${
rnv.prerelease ? '-' + rnv.prerelease : ''
}`,
framework: 'react-native',
sdk: 'rn',
});

const INTERNAL_PLUGINS = [
new ConsolePlugin(),
new ErrorPlugin(),
Expand Down
4 changes: 3 additions & 1 deletion packages/page-spy-react-native/src/plugins/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import type {
OnInitParams,
SpyBase,
} from '@huolala-tech/page-spy-types';
import { atom, getRandomId, makeMessage } from '@huolala-tech/page-spy-base';
import { getRandomId } from '@huolala-tech/page-spy-base/dist/utils';
import { atom } from '@huolala-tech/page-spy-base/dist/atom';
import { makeMessage } from '@huolala-tech/page-spy-base/dist/message';
import socketStore from '../helpers/socket';
import type { InitConfig } from '../config';

Expand Down
Loading

0 comments on commit f4f6574

Please sign in to comment.