-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
792371e
commit 285138b
Showing
6 changed files
with
101 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>PocketBlocks Embedded</title> | ||
<script type="module" crossorigin src="/js/proxy.js"></script> | ||
<style> | ||
.demo-title { | ||
text-align: center; | ||
} | ||
.demo { | ||
overflow: auto; | ||
padding: 10px; | ||
} | ||
.ops { | ||
padding: 10px; | ||
} | ||
.ops button { | ||
margin-right: 10px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1 class="demo-title">PocketBlocks Embedded</h1> | ||
<div id="app" class="demo"></div> | ||
<script type="module" src="/src/embedded.ts"></script> | ||
<script> | ||
window.onload = async function () { | ||
const url = new URL(location.href); | ||
const appId = url.searchParams.get("appId"); | ||
const baseUrl = url.searchParams.get("baseUrl") || location.origin; | ||
if (!appId) { | ||
return; | ||
} | ||
const instance = await $pbl.bootstrapAppAt( | ||
appId, | ||
document.querySelector("#app"), | ||
{ | ||
baseUrl, | ||
moduleInputs: { userName: "Lucy" }, | ||
} | ||
); | ||
|
||
instance?.on("moduleOutputChange", (output) => { | ||
console.info("output change:", output); | ||
}); | ||
|
||
instance?.on("moduleEventTriggered", (eventName) => { | ||
console.info("event triggered:", eventName); | ||
}); | ||
|
||
document.querySelector("#app-ops")?.addEventListener("click", (e) => { | ||
const target = e.target; | ||
const key = target.dataset.key; | ||
if (key === "setModuleInputs") { | ||
instance?.setModuleInputs({ | ||
userName: "Tom", | ||
}); | ||
} | ||
if (key === "invokeMethod") { | ||
instance?.invokeMethod("setSlider"); | ||
} | ||
}); | ||
}; | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//Just a file to trick Vite Build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as sdk from "./index.sdk"; | ||
|
||
// @ts-nocheck | ||
import "./index.less"; | ||
import "virtual:globals"; | ||
|
||
// @ts-ignore | ||
window.$openblocks_sdk = sdk; | ||
// @ts-ignore | ||
window.$pbl = sdk; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters