Skip to content

🔗 Defines the communication layer between mobile native(iOS/Android) and webview using JSON Schema and automatically generates SDK code. (TypeScript, Swift, Kotlin)

Notifications You must be signed in to change notification settings

daangn/metabridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

metabridge

Usage

# Install CLI
$ yarn add --dev @metabridge/cli @metabridge/plugin-typescript

# Generate code
$ yarn metabridge-cli \
$   --plugin @metabridge/plugin-typescript \
$   --schema ./somewhere/mySchema.json \
$   --output ./somewhere/__generated__/mySdk.ts
import { makeMyBridge } from "./somewhere/__generated__/mySdk";

const myBridge = makeMyBridge({
  driver: {
    onQueried(queryName, req) {
      // ...your business logic for transport layer
      return res;
    },
  },
});

// It strictly typed
myBridge.pushRouter({
  // ...
});

Available Plugins

  • @metabridge/plugin-typescript: TypeScript SDK
  • @metabridge/plugin-typescript-docs: TypeScript SDK Documentations (for WebView)
  • @metabridge/plugin-kotlin: Kotlin Stub
  • @metabridge/plugin-swift: Swift Stub

How to implement the JavaScript Driver

Just implement this

export interface MetaBridgeDriver {
  onQueried: (queryName: string, requestBody: any) => Promise<any>;
  onSubscribed: (
    subscriptionName: string,
    requestBody: any,
    listener: (error: Error | null, response: any | null) => void
  ) => () => void;
}

Contributors

About

🔗 Defines the communication layer between mobile native(iOS/Android) and webview using JSON Schema and automatically generates SDK code. (TypeScript, Swift, Kotlin)

Topics

Resources

Stars

Watchers

Forks

Languages