GithubHelp home page GithubHelp logo

jsbridgeplugins's Introduction

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);
};

jsbridgeplugins's People

Contributors

eminoda avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.