@terra-money/terra.js
Advanced tools
Comparing version 0.4.14-rc.0 to 0.4.14-rc.1
@@ -0,7 +1,18 @@ | ||
import { Msg } from '../core/Msg'; | ||
declare type SendDataType = 'connect' | 'post'; | ||
interface SendData { | ||
id: number | string; | ||
type: SendDataType; | ||
[key: string]: any; | ||
} | ||
export declare class Extension { | ||
static instance: Extension; | ||
private inpageStream; | ||
private sequence; | ||
constructor(); | ||
send(data: object): void; | ||
send(data: SendData): void; | ||
on(name: string, callback: (payload: any) => void): void; | ||
connect(): number; | ||
post(msgs: Msg[]): number; | ||
} | ||
export {}; |
@@ -8,2 +8,3 @@ "use strict"; | ||
function Extension() { | ||
this.sequence = 1; | ||
if (Extension.instance) { | ||
@@ -18,2 +19,4 @@ return Extension.instance; | ||
} | ||
// low level function for sending message to extension. | ||
// Do not use this function unless you know what you are doing. | ||
Extension.prototype.send = function (data) { | ||
@@ -27,2 +30,19 @@ this.inpageStream.write(data); | ||
}; | ||
Extension.prototype.connect = function () { | ||
var id = this.sequence++; | ||
this.send({ | ||
id: id, | ||
type: 'connect', | ||
}); | ||
return id; | ||
}; | ||
Extension.prototype.post = function (msgs) { | ||
var id = this.sequence++; | ||
this.send({ | ||
id: id, | ||
type: 'post', | ||
msgs: msgs.map(function (msg) { return msg.toJSON(); }), | ||
}); | ||
return id; | ||
}; | ||
return Extension; | ||
@@ -29,0 +49,0 @@ }()); |
{ | ||
"version": "0.4.14-rc.0", | ||
"version": "0.4.14-rc.1", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
5481001
16391