New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

otter-bridge

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

otter-bridge - npm Package Compare versions

Comparing version 0.0.3-alpha.18 to 0.0.3-alpha.19

1

dist/index.d.ts

@@ -29,2 +29,3 @@ declare enum GameType {

constructor(gameType?: GameType, gameName?: string);
private _waitForEnvReady;
init(): Promise<IInitRes>;

@@ -31,0 +32,0 @@ env(): Promise<envResult>;

38

dist/index.js

@@ -58,10 +58,2 @@ "use strict";

var import_urijs = __toESM(require("urijs"));
// src/env.ts
var Env = class {
};
Env.valid = typeof (window == null ? void 0 : window.flutter_inappwebview) !== "undefined";
var env_default = Env;
// src/index.ts
var GameType = /* @__PURE__ */ ((GameType2) => {

@@ -74,2 +66,5 @@ GameType2["default"] = "default";

var OtterBridge = class _OtterBridge {
constructor() {
this.valid = typeof window.flutter_inappwebview !== "undefined";
}
// Singleton instance

@@ -84,4 +79,4 @@ static get instance() {

return __async(this, arguments, function* (handlerName, params = {}) {
if (!env_default.valid) {
return Promise.reject("Not in an otter app");
if (!this.valid) {
return Promise.reject("Otter app env not ready");
}

@@ -101,5 +96,28 @@ return yield window.flutter_inappwebview.callHandler(

}
_waitForEnvReady() {
return __async(this, null, function* () {
return new Promise((resolve, reject) => {
if (OtterBridge.instance.valid)
resolve(true);
const timeout = setTimeout(() => {
OtterBridge.instance.valid = false;
resolve(false);
}, 1e4);
window.addEventListener("flutterInAppWebViewPlatformReady", function(event) {
OtterBridge.instance.valid = true;
clearTimeout(timeout);
resolve(true);
});
});
});
}
init() {
return __async(this, null, function* () {
try {
const envRes = yield this._waitForEnvReady();
if (!envRes) {
return {
clientAvailable: false
};
}
const sidRes = yield OtterBridge.instance.callHandler(

@@ -106,0 +124,0 @@ _BridgeHandler.HANDLER_ENUM.getSid

{
"name": "otter-bridge",
"version": "0.0.3-alpha.18",
"version": "0.0.3-alpha.19",
"description": "Otter game web jsbridge",

@@ -5,0 +5,0 @@ "files": [

import URI from "urijs";
import Env from "./env";

@@ -20,5 +19,7 @@ export enum GameType {

valid: boolean = typeof (window as any).flutter_inappwebview !== "undefined";
async callHandler(handlerName: string, params: any = {}) {
if (!Env.valid) {
return Promise.reject("Not in an otter app");
if (!this.valid) {
return Promise.reject("Otter app env not ready");
}

@@ -66,4 +67,27 @@ return await (window as any).flutter_inappwebview.callHandler(

private async _waitForEnvReady(): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
if (OtterBridge.instance.valid) resolve(true);
const timeout = setTimeout(() => {
OtterBridge.instance.valid = false;
resolve(false);
},10000);
window.addEventListener("flutterInAppWebViewPlatformReady", function(event) {
OtterBridge.instance.valid = true;
clearTimeout(timeout);
resolve(true);
});
});
}
async init(): Promise<IInitRes> {
try {
const envRes = await this._waitForEnvReady();
if (!envRes) {
return {
clientAvailable: false,
}
}
const sidRes = await OtterBridge.instance.callHandler(

@@ -70,0 +94,0 @@ BridgeHandler.HANDLER_ENUM.getSid,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc