@dscvr-one/canvas-client-sdk
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -7,2 +7,3 @@ import * as CanvasInterface from '@dscvr-one/canvas-interface'; | ||
private initResponseMessage; | ||
private initialInteractionRegistered; | ||
private eventBus; | ||
@@ -14,2 +15,3 @@ constructor(); | ||
openLink(url: string): void; | ||
resize(newPayload?: CanvasInterface.User.ResizeRequestMessage['payload']): void; | ||
connectWallet(chainId: string): Promise<CanvasInterface.User.ConnectWalletResponseMessage>; | ||
@@ -23,4 +25,7 @@ signAndSendTransaction(payload: CanvasInterface.User.UnsignedTransaction & { | ||
private handleReceiveMessage; | ||
private handleInitialInteraction; | ||
private removeInitialInteractionListeners; | ||
private getWindowSize; | ||
} | ||
export { CanvasClient }; |
@@ -7,2 +7,3 @@ // src/client.ts | ||
initResponseMessage = void 0; | ||
initialInteractionRegistered = false; | ||
eventBus = new EventEmitter(); | ||
@@ -14,2 +15,4 @@ constructor() { | ||
window.addEventListener("message", this.handleReceiveMessage); | ||
window.addEventListener("click", this.handleInitialInteraction); | ||
window.addEventListener("focus", this.handleInitialInteraction); | ||
if (!document.referrer) { | ||
@@ -23,2 +26,3 @@ throw new CanvasInterface.ReferrerNotDefinedError(); | ||
window.removeEventListener("message", this.handleReceiveMessage); | ||
this.removeInitialInteractionListeners(); | ||
} | ||
@@ -51,2 +55,12 @@ get isReady() { | ||
} | ||
resize(newPayload) { | ||
const payload = newPayload ?? this.getWindowSize(); | ||
if (payload.width <= 0 || payload.height <= 0) { | ||
return; | ||
} | ||
this.sendMessage({ | ||
type: "user:resize-request", | ||
payload | ||
}); | ||
} | ||
connectWallet(chainId) { | ||
@@ -126,2 +140,21 @@ const responsePromise = new Promise( | ||
}; | ||
handleInitialInteraction = () => { | ||
this.removeInitialInteractionListeners(); | ||
if (!this.initialInteractionRegistered) { | ||
this.initialInteractionRegistered = true; | ||
this.sendMessage({ | ||
type: "user:initial-interaction-request" | ||
}); | ||
} | ||
}; | ||
removeInitialInteractionListeners() { | ||
window.removeEventListener("click", this.handleInitialInteraction); | ||
window.removeEventListener("focus", this.handleInitialInteraction); | ||
} | ||
getWindowSize() { | ||
return { | ||
width: window.document.body.clientWidth, | ||
height: window.document.body.clientHeight | ||
}; | ||
} | ||
}; | ||
@@ -128,0 +161,0 @@ |
{ | ||
"name": "@dscvr-one/canvas-client-sdk", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "SDK for iframes apps to connect to dscvr host using postMessage rpc", | ||
@@ -5,0 +5,0 @@ "type": "module", |
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
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
33513
385