Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

eminoda/JSBridgePlugins

Repository files navigation

webpack-jsbridge-plugin

A webpack plugin to proxy jsBridge request on JSBridge Server, then you can develop on pc browser without real phones.

Usage

// vue.config.js
const JSBridgePlugin = require("webpack-jsbridge-plugin");
module.exports = defineConfig({
 configureWebpack: {
 plugins: [
 new JSBridgePlugin({
 port: 3300,
 origin: ["http://192.168.13.115:8080"],
 }),
 ],
 },
});

Attention πŸ”Š

In this plugin, the following JavaScript APIs are exposed for both Android and iOS:

call app sdk:

window.androidJS.nativeMethod // android
window.webkit.messageHandlers.nativeObject.postMessage // ios

sdk callback:

window.receiveMessage

If you define other methods, you will need to customize some methods to override them:

// override mock, ι€šθΏ‡ inject 注ε…₯
window.youSDKMethod = (arg1, arg2) => {
 const data = { arg1, arg2 };
 return window.$jsBridge.invoke(data);
};
window.youSDKCallback = (arg1, arg2)=>{
 onst data = { arg1, arg2 };
 window.receiveMessage(data)
}
// override jsbridge, ι€šθΏ‡ server public 覆盖
window.$jsBridge.invoke = (data) => {
 const { arg1, arg2 } = data;
 return window.youSDKMethod(arg1, arg2);
};
window.receiveMessage = (data) => {
 const { arg1, arg2 } = data;
 window.youSDKCallback(arg1, arg2);
};

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /