@tarojs/plugin-react-devtools 3.5.0-beta.4 → 3.5.0-beta.7

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.js CHANGED
@@ -5,90 +5,90 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var helper = require('@tarojs/helper');
6
6
  var shared = require('@tarojs/shared');
7
7
 
8
- const spawn = require('cross-spawn');
9
- const detectPort = require('detect-port');
10
- function index (ctx, options) {
11
- if (process.env.NODE_ENV === 'production' || options.enabled === false)
12
- return;
13
- const port = Number(options.port || '8097');
14
- detectPort(port, (err, availablePort) => {
15
- if (err) {
16
- // eslint-disable-next-line no-console
17
- console.log(`detectport 错误:${err}`);
18
- }
19
- if (availablePort === port) {
20
- // eslint-disable-next-line no-console
21
- console.log(helper.chalk.yellow('\n提示 ') + '正在启动 react-devtools...\n');
22
- spawn(require.resolve('react-devtools/bin'), { env: Object.assign(Object.assign({}, process.env), { PORT: port }) });
23
- }
24
- });
25
- ctx.registerMethod({
26
- name: 'onSetupClose',
27
- fn(platform) {
28
- injectRuntimePath(platform);
29
- }
30
- });
31
- ctx.modifyWebpackChain(({ chain }) => {
32
- chain
33
- .plugin('definePlugin')
34
- .tap(args => {
35
- const config = args[0];
36
- config.__REACT_DEVTOOLS_PORT__ = port;
37
- return args;
38
- });
39
- // 最理想是可以使用 definePlugin 设置 __REACT_DEVTOOLS_GLOBAL_HOOK__: window.__REACT_DEVTOOLS_GLOBAL_HOOK__
40
- // 但是 providerPlugin 不会识别 definePlugin 改写的 window 从而注入 window,可能是两个插件的调用时机问题
41
- // 因此使用 loader 魔改 react-reconciler,代替 definePlugin
42
- chain.merge({
43
- module: {
44
- rule: {
45
- 'plugin-react-devtools': {
46
- test: /react-reconciler\.(production|development)/,
47
- loader: require.resolve('./loader')
48
- }
49
- }
50
- }
51
- });
52
- });
53
- ctx.modifyRunnerOpts(({ opts }) => {
54
- var _a;
55
- if (shared.isString(opts.compiler)) {
56
- opts.compiler = {
57
- type: opts.compiler
58
- };
59
- }
60
- if (opts.compiler.type === 'webpack5') {
61
- (_a = opts.compiler).prebundle || (_a.prebundle = {});
62
- const prebundle = opts.compiler.prebundle;
63
- if (prebundle.enable === false)
64
- return;
65
- // 代替 ./loader 里的功能
66
- const taroReactDevtoolsPlugin = {
67
- name: 'taroReactDevtoolsPlugin',
68
- setup(build) {
69
- build.onLoad({ filter: /react-reconciler\.(production|development)/ }, ({ path }) => {
70
- const content = helper.fs.readFileSync(path).toString();
71
- return {
72
- contents: content.replace(/__REACT_DEVTOOLS_GLOBAL_HOOK__/g, 'window.__REACT_DEVTOOLS_GLOBAL_HOOK__')
73
- };
74
- });
75
- }
76
- };
77
- prebundle.esbuild || (prebundle.esbuild = {});
78
- const esbuildConfig = prebundle.esbuild;
79
- esbuildConfig.plugins || (esbuildConfig.plugins = []);
80
- esbuildConfig.plugins.push(taroReactDevtoolsPlugin);
81
- }
82
- });
83
- }
84
- function injectRuntimePath(platform) {
85
- const injectedPath = 'post:@tarojs/plugin-react-devtools/dist/runtime';
86
- if (shared.isArray(platform.runtimePath)) {
87
- platform.runtimePath.push(injectedPath);
88
- }
89
- else if (shared.isString(platform.runtimePath)) {
90
- platform.runtimePath = [platform.runtimePath, injectedPath];
91
- }
8
+ const spawn = require('cross-spawn');
9
+ const detectPort = require('detect-port');
10
+ function index (ctx, options) {
11
+ if (process.env.NODE_ENV === 'production' || options.enabled === false)
12
+ return;
13
+ const port = Number(options.port || '8097');
14
+ detectPort(port, (err, availablePort) => {
15
+ if (err) {
16
+ // eslint-disable-next-line no-console
17
+ console.log(`detectPort 错误:${err}`);
18
+ }
19
+ if (availablePort === port) {
20
+ // eslint-disable-next-line no-console
21
+ console.log(helper.chalk.yellow('\n提示 ') + '正在启动 react-devtools...\n');
22
+ spawn(require.resolve('react-devtools/bin'), { env: Object.assign(Object.assign({}, process.env), { PORT: port }) });
23
+ }
24
+ });
25
+ ctx.registerMethod({
26
+ name: 'onSetupClose',
27
+ fn(platform) {
28
+ injectRuntimePath(platform);
29
+ }
30
+ });
31
+ ctx.modifyWebpackChain(({ chain }) => {
32
+ chain
33
+ .plugin('definePlugin')
34
+ .tap(args => {
35
+ const config = args[0];
36
+ config.__REACT_DEVTOOLS_PORT__ = port;
37
+ return args;
38
+ });
39
+ // 最理想是可以使用 definePlugin 设置 __REACT_DEVTOOLS_GLOBAL_HOOK__: window.__REACT_DEVTOOLS_GLOBAL_HOOK__
40
+ // 但是 providerPlugin 不会识别 definePlugin 改写的 window 从而注入 window,可能是两个插件的调用时机问题
41
+ // 因此使用 loader 魔改 react-reconciler,代替 definePlugin
42
+ chain.merge({
43
+ module: {
44
+ rule: {
45
+ 'plugin-react-devtools': {
46
+ test: /react-reconciler\.(production|development)/,
47
+ loader: require.resolve('./loader')
48
+ }
49
+ }
50
+ }
51
+ });
52
+ });
53
+ ctx.modifyRunnerOpts(({ opts }) => {
54
+ var _a;
55
+ if (shared.isString(opts.compiler)) {
56
+ opts.compiler = {
57
+ type: opts.compiler
58
+ };
59
+ }
60
+ if (opts.compiler.type === 'webpack5') {
61
+ (_a = opts.compiler).prebundle || (_a.prebundle = {});
62
+ const prebundle = opts.compiler.prebundle;
63
+ if (prebundle.enable === false)
64
+ return;
65
+ // 代替 ./loader 里的功能
66
+ const taroReactDevtoolsPlugin = {
67
+ name: 'taroReactDevtoolsPlugin',
68
+ setup(build) {
69
+ build.onLoad({ filter: /react-reconciler\.(production|development)/ }, ({ path }) => {
70
+ const content = helper.fs.readFileSync(path).toString();
71
+ return {
72
+ contents: content.replace(/__REACT_DEVTOOLS_GLOBAL_HOOK__/g, 'window.__REACT_DEVTOOLS_GLOBAL_HOOK__')
73
+ };
74
+ });
75
+ }
76
+ };
77
+ prebundle.esbuild || (prebundle.esbuild = {});
78
+ const esbuildConfig = prebundle.esbuild;
79
+ esbuildConfig.plugins || (esbuildConfig.plugins = []);
80
+ esbuildConfig.plugins.push(taroReactDevtoolsPlugin);
81
+ }
82
+ });
83
+ }
84
+ function injectRuntimePath(platform) {
85
+ const injectedPath = 'post:@tarojs/plugin-react-devtools/dist/runtime';
86
+ if (shared.isArray(platform.runtimePath)) {
87
+ platform.runtimePath.push(injectedPath);
88
+ }
89
+ else if (shared.isString(platform.runtimePath)) {
90
+ platform.runtimePath = [platform.runtimePath, injectedPath];
91
+ }
92
92
  }
93
93
 
94
94
  exports["default"] = index;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { chalk, fs } from '@tarojs/helper'\nimport type { IPluginContext, TaroPlatformBase } from '@tarojs/service'\nimport { isArray, isString } from '@tarojs/shared'\n\nconst spawn = require('cross-spawn')\nconst detectPort = require('detect-port')\n\ninterface IOptions {\n enabled?: boolean\n port?: string\n}\n\nexport default function (ctx: IPluginContext, options: IOptions) {\n if (process.env.NODE_ENV === 'production' || options.enabled === false) return\n\n const port = Number(options.port || '8097')\n\n detectPort(port, (err, availablePort) => {\n if (err) {\n // eslint-disable-next-line no-console\n console.log(`detectport 错误:${err}`)\n }\n\n if (availablePort === port) {\n // eslint-disable-next-line no-console\n console.log(chalk.yellow('\\n提示 ') + '正在启动 react-devtools...\\n')\n spawn(require.resolve('react-devtools/bin'), { env: { ...process.env, PORT: port } })\n }\n })\n\n ctx.registerMethod({\n name: 'onSetupClose',\n fn (platform: TaroPlatformBase) {\n injectRuntimePath(platform)\n }\n })\n\n ctx.modifyWebpackChain(({ chain }) => {\n chain\n .plugin('definePlugin')\n .tap(args => {\n const config = args[0]\n config.__REACT_DEVTOOLS_PORT__ = port\n return args\n })\n\n // 最理想是可以使用 definePlugin 设置 __REACT_DEVTOOLS_GLOBAL_HOOK__: window.__REACT_DEVTOOLS_GLOBAL_HOOK__\n // 但是 providerPlugin 不会识别 definePlugin 改写的 window 从而注入 window,可能是两个插件的调用时机问题\n // 因此使用 loader 魔改 react-reconciler,代替 definePlugin\n chain.merge({\n module: {\n rule: {\n 'plugin-react-devtools': {\n test: /react-reconciler\\.(production|development)/,\n loader: require.resolve('./loader')\n }\n }\n }\n })\n })\n\n ctx.modifyRunnerOpts(({ opts }) => {\n if (isString(opts.compiler)) {\n opts.compiler = {\n type: opts.compiler\n }\n }\n if (opts.compiler.type === 'webpack5') {\n opts.compiler.prebundle ||= {}\n const prebundle = opts.compiler.prebundle\n if (prebundle.enable === false) return\n\n // 代替 ./loader 里的功能\n const taroReactDevtoolsPlugin = {\n name: 'taroReactDevtoolsPlugin',\n setup (build) {\n build.onLoad({ filter: /react-reconciler\\.(production|development)/ }, ({ path }) => {\n const content = fs.readFileSync(path).toString()\n return {\n contents: content.replace(/__REACT_DEVTOOLS_GLOBAL_HOOK__/g, 'window.__REACT_DEVTOOLS_GLOBAL_HOOK__')\n }\n })\n }\n }\n\n prebundle.esbuild ||= {}\n const esbuildConfig = prebundle.esbuild\n esbuildConfig.plugins ||= []\n esbuildConfig.plugins.push(taroReactDevtoolsPlugin)\n }\n })\n}\n\nfunction injectRuntimePath (platform: TaroPlatformBase) {\n const injectedPath = 'post:@tarojs/plugin-react-devtools/dist/runtime'\n if (isArray(platform.runtimePath)) {\n platform.runtimePath.push(injectedPath)\n } else if (isString(platform.runtimePath)) {\n platform.runtimePath = [platform.runtimePath, injectedPath]\n }\n}\n"],"names":["chalk","isString","fs","isArray"],"mappings":";;;;;;;AAIA,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AACpC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAOhB,cAAA,EAAA,GAAmB,EAAE,OAAiB,EAAA;AAC7D,IAAA,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,OAAO,CAAC,OAAO,KAAK,KAAK;QAAE,OAAM;IAE9E,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,CAAA;IAE3C,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,EA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AACH,KAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAE,QAA0B,EAAA;IACpD,MAAM,YAAY,GAAG,iDAAiD,CAAA;AACtE,IAAA,IAAIC,cAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;AACjC,QAAA,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;AACxC,KAAA;AAAM,SAAA,IAAIF,eAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACzC,QAAQ,CAAC,WAAW,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;AAC5D,KAAA;AACH;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { chalk, fs } from '@tarojs/helper'\nimport type { IPluginContext, TaroPlatformBase } from '@tarojs/service'\nimport { isArray, isString } from '@tarojs/shared'\n\nconst spawn = require('cross-spawn')\nconst detectPort = require('detect-port')\n\ninterface IOptions {\n enabled?: boolean\n port?: string\n}\n\nexport default function (ctx: IPluginContext, options: IOptions) {\n if (process.env.NODE_ENV === 'production' || options.enabled === false) return\n\n const port = Number(options.port || '8097')\n\n detectPort(port, (err, availablePort) => {\n if (err) {\n // eslint-disable-next-line no-console\n console.log(`detectPort 错误:${err}`)\n }\n\n if (availablePort === port) {\n // eslint-disable-next-line no-console\n console.log(chalk.yellow('\\n提示 ') + '正在启动 react-devtools...\\n')\n spawn(require.resolve('react-devtools/bin'), { env: { ...process.env, PORT: port } })\n }\n })\n\n ctx.registerMethod({\n name: 'onSetupClose',\n fn (platform: TaroPlatformBase) {\n injectRuntimePath(platform)\n }\n })\n\n ctx.modifyWebpackChain(({ chain }) => {\n chain\n .plugin('definePlugin')\n .tap(args => {\n const config = args[0]\n config.__REACT_DEVTOOLS_PORT__ = port\n return args\n })\n\n // 最理想是可以使用 definePlugin 设置 __REACT_DEVTOOLS_GLOBAL_HOOK__: window.__REACT_DEVTOOLS_GLOBAL_HOOK__\n // 但是 providerPlugin 不会识别 definePlugin 改写的 window 从而注入 window,可能是两个插件的调用时机问题\n // 因此使用 loader 魔改 react-reconciler,代替 definePlugin\n chain.merge({\n module: {\n rule: {\n 'plugin-react-devtools': {\n test: /react-reconciler\\.(production|development)/,\n loader: require.resolve('./loader')\n }\n }\n }\n })\n })\n\n ctx.modifyRunnerOpts(({ opts }) => {\n if (isString(opts.compiler)) {\n opts.compiler = {\n type: opts.compiler\n }\n }\n if (opts.compiler.type === 'webpack5') {\n opts.compiler.prebundle ||= {}\n const prebundle = opts.compiler.prebundle\n if (prebundle.enable === false) return\n\n // 代替 ./loader 里的功能\n const taroReactDevtoolsPlugin = {\n name: 'taroReactDevtoolsPlugin',\n setup (build) {\n build.onLoad({ filter: /react-reconciler\\.(production|development)/ }, ({ path }) => {\n const content = fs.readFileSync(path).toString()\n return {\n contents: content.replace(/__REACT_DEVTOOLS_GLOBAL_HOOK__/g, 'window.__REACT_DEVTOOLS_GLOBAL_HOOK__')\n }\n })\n }\n }\n\n prebundle.esbuild ||= {}\n const esbuildConfig = prebundle.esbuild\n esbuildConfig.plugins ||= []\n esbuildConfig.plugins.push(taroReactDevtoolsPlugin)\n }\n })\n}\n\nfunction injectRuntimePath (platform: TaroPlatformBase) {\n const injectedPath = 'post:@tarojs/plugin-react-devtools/dist/runtime'\n if (isArray(platform.runtimePath)) {\n platform.runtimePath.push(injectedPath)\n } else if (isString(platform.runtimePath)) {\n platform.runtimePath = [platform.runtimePath, injectedPath]\n }\n}\n"],"names":["chalk","isString","fs","isArray"],"mappings":";;;;;;;AAIA,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AACpC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAOhB,cAAA,EAAA,GAAmB,EAAE,OAAiB,EAAA;AAC7D,IAAA,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,OAAO,CAAC,OAAO,KAAK,KAAK;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,OAAO,KAArB,aAAa,CAAC,OAAO,GAAK,EAAE,CAAA,CAAA;AAC5B,YAAA,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;AACpD,SAAA;AACH,KAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAE,QAA0B,EAAA;IACpD,MAAM,YAAY,GAAG,iDAAiD,CAAA;AACtE,IAAA,IAAIC,cAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;AACjC,QAAA,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;AACxC,KAAA;AAAM,SAAA,IAAIF,eAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACzC,QAAQ,CAAC,WAAW,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;AAC5D,KAAA;AACH;;;;"}
package/dist/loader.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- function loader (str) {
4
- str = str.replace(/__REACT_DEVTOOLS_GLOBAL_HOOK__/g, 'window.__REACT_DEVTOOLS_GLOBAL_HOOK__');
5
- return str;
3
+ function loader (str) {
4
+ str = str.replace(/__REACT_DEVTOOLS_GLOBAL_HOOK__/g, 'window.__REACT_DEVTOOLS_GLOBAL_HOOK__');
5
+ return str;
6
6
  }
7
7
 
8
8
  module.exports = loader;
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sources":["../src/loader.ts"],"sourcesContent":["export default function (str) {\n str = str.replace(/__REACT_DEVTOOLS_GLOBAL_HOOK__/g, 'window.__REACT_DEVTOOLS_GLOBAL_HOOK__')\n return str\n}\n"],"names":[],"mappings":";;AAAc,eAAA,EAAW,GAAG,EAAA;IAC1B,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,iCAAiC,EAAE,uCAAuC,CAAC,CAAA;AAC7F,IAAA,OAAO,GAAG,CAAA;AACZ;;;;"}
1
+ {"version":3,"file":"loader.js","sources":["../src/loader.ts"],"sourcesContent":["export default function (str) {\n str = str.replace(/__REACT_DEVTOOLS_GLOBAL_HOOK__/g, 'window.__REACT_DEVTOOLS_GLOBAL_HOOK__')\n return str\n}\n"],"names":[],"mappings":";;AAAc,eAAA,EAAW,GAAG,EAAA;IACxB,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,iCAAiC,EAAE,uCAAuC,CAAC,CAAC;AAC9F,IAAA,OAAO,GAAG,CAAC;AACf;;;;"}
package/dist/runtime.js CHANGED
@@ -1,80 +1,80 @@
1
1
  import Taro from '@tarojs/taro';
2
2
 
3
- const ALIPAY = 'alipay';
4
- class WebSocket {
5
- constructor(url) {
6
- this.url = url;
7
- this.readyState = this.CONNECTING;
8
- Taro.connectSocket({
9
- url
10
- })
11
- .then(ws => {
12
- this._ws = ws;
13
- ws.onClose(res => {
14
- this.readyState = this.CLOSED;
15
- this.onclose(res);
16
- });
17
- ws.onError(res => {
18
- this.readyState = this.CLOSED;
19
- this.onerror(res);
20
- });
21
- ws.onMessage(res => {
22
- if (res.data.includes('"event":"highlightNativeElement"')) {
23
- // 元素高亮暂时不实现,需要魔改 backend 的代码
24
- return;
25
- }
26
- this.onmessage(res);
27
- });
28
- if (this.readyState !== this.OPEN) {
29
- ws.onOpen(res => {
30
- this.readyState = this.OPEN;
31
- this.onopen(res);
32
- });
33
- }
34
- else {
35
- // 支付宝全局的 onSocketOpen 已触发过了,直接调用 onopen
36
- this.onopen({});
37
- }
38
- });
39
- // 支付宝只支持一个 socket 连接,且 onSocketOpen 的触发时机比 connectSocket 回调的时机早
40
- if (process.env.TARO_ENV === ALIPAY) {
41
- Taro.onSocketOpen(() => {
42
- this.readyState = this.OPEN;
43
- });
44
- }
45
- }
46
- send(data) {
47
- this._ws.send({
48
- data
49
- });
50
- }
51
- close(code, reason) {
52
- this.readyState = this.CLOSING;
53
- this._ws.close({
54
- code: code || 1000,
55
- reason: reason || ''
56
- });
57
- }
58
- get CONNECTING() {
59
- return 0;
60
- }
61
- get OPEN() {
62
- return 1;
63
- }
64
- get CLOSING() {
65
- return 2;
66
- }
67
- get CLOSED() {
68
- return 3;
69
- }
3
+ const ALIPAY = 'alipay';
4
+ class WebSocket {
5
+ constructor(url) {
6
+ this.url = url;
7
+ this.readyState = this.CONNECTING;
8
+ Taro.connectSocket({
9
+ url
10
+ })
11
+ .then(ws => {
12
+ this._ws = ws;
13
+ ws.onClose(res => {
14
+ this.readyState = this.CLOSED;
15
+ this.onclose(res);
16
+ });
17
+ ws.onError(res => {
18
+ this.readyState = this.CLOSED;
19
+ this.onerror(res);
20
+ });
21
+ ws.onMessage(res => {
22
+ if (res.data.includes('"event":"highlightNativeElement"')) {
23
+ // 元素高亮暂时不实现,需要魔改 backend 的代码
24
+ return;
25
+ }
26
+ this.onmessage(res);
27
+ });
28
+ if (this.readyState !== this.OPEN) {
29
+ ws.onOpen(res => {
30
+ this.readyState = this.OPEN;
31
+ this.onopen(res);
32
+ });
33
+ }
34
+ else {
35
+ // 支付宝全局的 onSocketOpen 已触发过了,直接调用 onopen
36
+ this.onopen({});
37
+ }
38
+ });
39
+ // 支付宝只支持一个 socket 连接,且 onSocketOpen 的触发时机比 connectSocket 回调的时机早
40
+ if (process.env.TARO_ENV === ALIPAY) {
41
+ Taro.onSocketOpen(() => {
42
+ this.readyState = this.OPEN;
43
+ });
44
+ }
45
+ }
46
+ send(data) {
47
+ this._ws.send({
48
+ data
49
+ });
50
+ }
51
+ close(code, reason) {
52
+ this.readyState = this.CLOSING;
53
+ this._ws.close({
54
+ code: code || 1000,
55
+ reason: reason || ''
56
+ });
57
+ }
58
+ get CONNECTING() {
59
+ return 0;
60
+ }
61
+ get OPEN() {
62
+ return 1;
63
+ }
64
+ get CLOSING() {
65
+ return 2;
66
+ }
67
+ get CLOSED() {
68
+ return 3;
69
+ }
70
70
  }
71
71
 
72
- const { connectToDevTools } = require('./backend');
73
- const ws = new WebSocket(`ws://127.0.0.1:${__REACT_DEVTOOLS_PORT__}`);
74
- connectToDevTools({
75
- // host: string (defaults to "localhost") - Websocket will connect to this host.
76
- port: __REACT_DEVTOOLS_PORT__,
77
- // useHttps: boolean (defaults to false) - Websocket should use a secure protocol (wss).
78
- websocket: ws // Custom websocket to use. Overrides host and port settings if provided.
72
+ const { connectToDevTools } = require('./backend');
73
+ const ws = new WebSocket(`ws://127.0.0.1:${__REACT_DEVTOOLS_PORT__}`);
74
+ connectToDevTools({
75
+ // host: string (defaults to "localhost") - Websocket will connect to this host.
76
+ port: __REACT_DEVTOOLS_PORT__,
77
+ // useHttps: boolean (defaults to false) - Websocket should use a secure protocol (wss).
78
+ websocket: ws // Custom websocket to use. Overrides host and port settings if provided.
79
79
  });
80
80
  //# sourceMappingURL=runtime.js.map
package/package.json CHANGED
@@ -1,14 +1,8 @@
1
1
  {
2
2
  "name": "@tarojs/plugin-react-devtools",
3
- "version": "3.5.0-beta.4",
3
+ "version": "3.5.0-beta.7",
4
4
  "description": "Taro 小程序端支持使用 React DevTools 的插件",
5
5
  "main": "index.js",
6
- "scripts": {
7
- "dev": "rollup -c -w",
8
- "build": "rollup -c",
9
- "test": "jest",
10
- "test:dev": "jest --watch"
11
- },
12
6
  "files": [
13
7
  "dist",
14
8
  "index.js",
@@ -28,12 +22,18 @@
28
22
  },
29
23
  "homepage": "https://github.com/NervJS/taro#readme",
30
24
  "dependencies": {
31
- "@tarojs/helper": "3.5.0-beta.4",
32
- "@tarojs/shared": "3.5.0-beta.4",
33
- "@tarojs/taro": "3.5.0-beta.4",
25
+ "@tarojs/helper": "3.5.0-beta.7",
26
+ "@tarojs/service": "3.5.0-beta.7",
27
+ "@tarojs/shared": "3.5.0-beta.7",
28
+ "@tarojs/taro": "3.5.0-beta.7",
34
29
  "cross-spawn": "^7.0.3",
35
30
  "detect-port": "^1.3.0",
36
31
  "react-devtools": "4.14.0"
37
32
  },
38
- "gitHead": "7aca7841ed7e2af1b182ff5d24e91f44730ce783"
39
- }
33
+ "scripts": {
34
+ "dev": "rollup -c -w",
35
+ "build": "rollup -c",
36
+ "test": "jest",
37
+ "test:dev": "jest --watch"
38
+ }
39
+ }