grpc-protobufjs-devtools for Google Chrome

grpc-protobufjs-devtools

扩展程序 : grpc-protobufjs-devtools for Google Chrome
版本 : 0.0.3
提供方 : 由ttshangxiang提供

添加至Google Chrome

概述

grpc-protobufjs-devtools for Google Chromegrpc, proto, protobufjs, devtools, chrome, extensions### use
1, 使用node和protobufjs创建proto.js。
“` javascript
const pbjs = require("protobufjs/cli/pbjs");
const fs = require('fs');
const path = require('path');
const glob = require('glob');

const protoPath = 'src/proto/**/*.proto'; // origin path
const protos = glob.sync(protoPath);

pbjs.main([ "–target", "json-module", "-w", "commonjs", …protos], function(err, output) {
if (err)
throw err;
// target path
fs.writeFileSync(path.resolve(__dirname, './src/xxx/proto.js'), output);
});
“`
2, 挂载json字符串到window。
“` javascript
const $root = require('./src/xxx/proto.js');
window.__DEVTOOLS_PROTO_JSON_STRING__ = JSON.stringify($root.toJSON({keepComments: true}));
“`

Leave a Reply

您的电子邮箱地址不会被公开。 必填项已用*标注