yach-jsapi
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -18,3 +18,4 @@ import './entry/index'; | ||
env: import("./lib/sdk/sdkLib").IENV; | ||
ready: (readyCallback: () => void) => void; | ||
}; | ||
export default yy; |
@@ -11,5 +11,9 @@ "use strict"; | ||
var e = getUA(), i = /Yach/i.test(e), a = /iPhone|iPad|iPod|iOS/i.test(e) && i, t = /Android/i.test(e) && i, d = /Pc/i.test(e); | ||
var v, l = '*', o = []; | ||
i && (o = e.match(/Yach\/([a-zA-Z0-9.-]+)/)); | ||
v = o[1] || ''; | ||
// let v:string, | ||
// l='*', | ||
// o=[]; | ||
// | ||
// i && (o = e.match(/Yach\/([a-zA-Z0-9.-]+)/)); | ||
// v = o[1]||''; | ||
var l; | ||
var p = a ? sdkLib_1.ENV_ENUM.ios : t ? sdkLib_1.ENV_ENUM.android : d ? sdkLib_1.ENV_ENUM.pc : sdkLib_1.ENV_ENUM.notInYach; | ||
@@ -19,3 +23,3 @@ "undefined" != typeof navigator && (l = navigator.language || "*"); | ||
platform: p, | ||
version: v, | ||
version: undefined, | ||
language: l | ||
@@ -22,0 +26,0 @@ }; |
@@ -52,3 +52,4 @@ "use strict"; | ||
if (window !== window.top) { | ||
window.top.postMessage(n.getPayload(), '*'); | ||
// chrome低版本必须用字符串 | ||
window.top.postMessage(JSON.stringify(n.getPayload()), '*'); | ||
_this.addPending(n); | ||
@@ -61,2 +62,3 @@ return n; | ||
window.addEventListener('message', function (msg) { | ||
console.log(msg, 'recieve'); | ||
var data = msg.data || {}; | ||
@@ -63,0 +65,0 @@ var type = data.type; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var pc_1 = require("../bridge/pc"); | ||
var Sdk = /** @class */ (function () { | ||
@@ -30,7 +31,9 @@ function Sdk(env) { | ||
}); | ||
}).catch(function (error) { | ||
// bridgeInitFn方法抛出的错粗 | ||
console.log(error); | ||
}); | ||
} | ||
}, | ||
ready: function (fn) { | ||
_this.bridgeInitFn().then(function () { | ||
fn(); | ||
}); | ||
} | ||
@@ -46,6 +49,10 @@ }; | ||
this.platformConfigMap[platform] = value; | ||
if (platform === 'pc') { | ||
//初始化 | ||
pc_1.PcBridgeInit(); | ||
} | ||
}; | ||
; | ||
Sdk.prototype.bridgeInitFn = function () { | ||
// 注册失败,平台环境不对再调用api就肯定失败,同事确定只初始化一次监听事件 | ||
// 平台环境不对再调用api就肯定失败 | ||
if (this.bridgeInitFnPromise) | ||
@@ -55,7 +62,3 @@ return this.bridgeInitFnPromise; | ||
if (o) { | ||
this.bridgeInitFnPromise = o.bridgeInit().catch(function (error) { | ||
// pc注册监听事件等失败 | ||
var n = 'init jsbridge failed' + error; | ||
return Promise.reject(n); | ||
}); | ||
this.bridgeInitFnPromise = o.bridgeInit(); | ||
} | ||
@@ -93,5 +96,2 @@ else { | ||
}); | ||
}).catch(function (error) { | ||
// bridgeInitFn方法抛出的错粗 | ||
console.log(error); | ||
}); | ||
@@ -98,0 +98,0 @@ return; |
@@ -44,2 +44,3 @@ export declare enum ENV_ENUM { | ||
env: IENV; | ||
ready: (readyCallback: () => void) => void; | ||
} | ||
@@ -46,0 +47,0 @@ export interface IConfigCoreMap { |
@@ -7,5 +7,5 @@ "use strict"; | ||
yachSdk_1.yachSdk.setPlatform({ | ||
platform: sdkLib_1.ENV_ENUM.pc, | ||
platform: sdkLib_1.ENV_ENUM.android, | ||
authMethod: 'config', | ||
bridgeInit: function () { return Promise.resolve(mobile_1.mobileBridge); } | ||
}); |
@@ -7,7 +7,7 @@ "use strict"; | ||
yachSdk_1.yachSdk.setPlatform({ | ||
platform: sdkLib_1.ENV_ENUM.pc, | ||
platform: sdkLib_1.ENV_ENUM.ios, | ||
authMethod: 'config', | ||
bridgeInit: function () { return Promise.resolve().then(function () { | ||
bridgeInit: function () { return Promise.resolve(mobile_1.mobileBridge).then(function () { | ||
return mobile_1.mobileBridge; | ||
}); } | ||
}); |
@@ -6,10 +6,8 @@ "use strict"; | ||
var pc_1 = require("../lib/bridge/pc"); | ||
var pc_2 = require("../lib/bridge/pc"); | ||
yachSdk_1.yachSdk.setPlatform({ | ||
platform: sdkLib_1.ENV_ENUM.pc, | ||
authMethod: 'config', | ||
bridgeInit: function () { return Promise.resolve(pc_2.PcBridgeInit).then(function (fn) { | ||
fn(); | ||
bridgeInit: function () { return Promise.resolve().then(function () { | ||
return pc_1.pcBridge; | ||
}); } | ||
}); |
{ | ||
"name": "yach-jsapi", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
783
26478