runlab 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/app.js +11 -5
- package/dist/app/core/navbar.js +31 -1
- package/dist/index.js +6 -3
- package/dist/reactButton.jsx +46 -0
- package/package.json +1 -1
package/dist/app/app.js
CHANGED
|
@@ -3,12 +3,18 @@ import { createNavbar } from "./core/navbar.js";
|
|
|
3
3
|
import { FileExplorer } from "./fileExplorer/FileExplorer.js";
|
|
4
4
|
import { createTerminal } from "./terminal/terminal.js";
|
|
5
5
|
|
|
6
|
-
export function generateContainer(parentId
|
|
6
|
+
export function generateContainer(parentId) {
|
|
7
7
|
const container = document.createElement("div");
|
|
8
8
|
container.id = "runlab-container";
|
|
9
9
|
Object.assign(container.style, {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
position: "fixed",
|
|
11
|
+
inset: "0",
|
|
12
|
+
left: "0",
|
|
13
|
+
bottom: "0",
|
|
14
|
+
|
|
15
|
+
width: "100vw",
|
|
16
|
+
height: "100vh",
|
|
17
|
+
|
|
12
18
|
border: "1px solid #000",
|
|
13
19
|
display: "flex",
|
|
14
20
|
justifyContent: "center",
|
|
@@ -16,7 +22,7 @@ export function generateContainer(parentId,w,h) {
|
|
|
16
22
|
overflow: "hidden"
|
|
17
23
|
});
|
|
18
24
|
document.getElementById(parentId).appendChild(container);
|
|
19
|
-
gridTemplate("runlab-container"
|
|
25
|
+
gridTemplate("runlab-container");
|
|
20
26
|
createEditor("runlab-editor","");
|
|
21
27
|
|
|
22
28
|
// View and Editor toggle
|
|
@@ -202,7 +208,7 @@ export function setEditorActive(status = true){
|
|
|
202
208
|
//================================ SVG Warning Text ================================
|
|
203
209
|
|
|
204
210
|
const warningText = document.createElement("p");
|
|
205
|
-
warningText.textContent = "No
|
|
211
|
+
warningText.textContent = "No files selected.";
|
|
206
212
|
warningText.style.color = "#aaa";
|
|
207
213
|
warningText.style.fontSize = "0.9em";
|
|
208
214
|
warningText.style.margin = "0";
|
package/dist/app/core/navbar.js
CHANGED
|
@@ -34,7 +34,7 @@ export function createNavbar(parentId) {
|
|
|
34
34
|
});
|
|
35
35
|
ul.appendChild(leftGroup);
|
|
36
36
|
|
|
37
|
-
const menuItems = ["Run", "Help"];
|
|
37
|
+
const menuItems = ["✕", "🗗","Run", "Help"];
|
|
38
38
|
menuItems.forEach(item => {
|
|
39
39
|
const li = document.createElement("li");
|
|
40
40
|
li.textContent = item;
|
|
@@ -46,6 +46,36 @@ export function createNavbar(parentId) {
|
|
|
46
46
|
cursor: "pointer",
|
|
47
47
|
color: "#fff"
|
|
48
48
|
});
|
|
49
|
+
if (item === "✕") {
|
|
50
|
+
li.addEventListener("click", () => {
|
|
51
|
+
const app = document.getElementById("runlab-custom-div");
|
|
52
|
+
app.style.display = "none";
|
|
53
|
+
document.getElementById("runlab-custom-btn").textContent = "Show App";
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (item === "🗗"){
|
|
57
|
+
li.addEventListener("click", () => {
|
|
58
|
+
const container = document.getElementById("runlab-container");
|
|
59
|
+
let isMaximized = container.style.height === "100vh"? false: true;
|
|
60
|
+
|
|
61
|
+
if(isMaximized){
|
|
62
|
+
container.style.height = "100vh";
|
|
63
|
+
container.style.width = "100vw";
|
|
64
|
+
container.style.left = "0";
|
|
65
|
+
container.style.top = "0";
|
|
66
|
+
container.style.bottom = "0";
|
|
67
|
+
container.style.transform = "none";
|
|
68
|
+
}
|
|
69
|
+
if(!isMaximized){
|
|
70
|
+
container.style.height = "70vh";
|
|
71
|
+
container.style.width = "70vw";
|
|
72
|
+
container.style.left = "50%";
|
|
73
|
+
container.style.top = "auto";
|
|
74
|
+
container.style.bottom = "0";
|
|
75
|
+
container.style.transform = "translateX(-50%)";
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
49
79
|
if (item === "Run") {
|
|
50
80
|
li.addEventListener("click", () => {
|
|
51
81
|
sendCode(getCurrentCode(),getCurrentExtension());
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { generateContainer } from "./app/app.js";
|
|
2
2
|
import { appendViewContent } from "./app/app.js";
|
|
3
|
+
import { ReactRunlabButton } from "./reactButton.jsx";
|
|
3
4
|
|
|
4
5
|
let runtimeUrl = "";
|
|
5
6
|
function setRuntimeUrl(url) {
|
|
@@ -11,11 +12,9 @@ function getRuntimeUrl() {
|
|
|
11
12
|
|
|
12
13
|
export async function run({
|
|
13
14
|
parentId,
|
|
14
|
-
width = 1200,
|
|
15
|
-
height = 800,
|
|
16
15
|
runtimeUrl = ""
|
|
17
16
|
}) {
|
|
18
|
-
generateContainer(parentId
|
|
17
|
+
generateContainer(parentId);
|
|
19
18
|
setRuntimeUrl(runtimeUrl);
|
|
20
19
|
}
|
|
21
20
|
|
|
@@ -47,3 +46,7 @@ export async function sendCode(code, ext = "txt") {
|
|
|
47
46
|
console.error(err);
|
|
48
47
|
}
|
|
49
48
|
}
|
|
49
|
+
|
|
50
|
+
//=============================== Buttons ===============================
|
|
51
|
+
|
|
52
|
+
export { ReactRunlabButton };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { run } from "./index.js";
|
|
3
|
+
|
|
4
|
+
export function ReactRunlabButton(props = { runConfig: {} }) {
|
|
5
|
+
const { runConfig } = props;
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (typeof window !== 'undefined' && window.__runlab_started) return;
|
|
9
|
+
|
|
10
|
+
if (typeof window !== 'undefined') {
|
|
11
|
+
window.__runlab_started = true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
run(runConfig);
|
|
15
|
+
}, []);
|
|
16
|
+
|
|
17
|
+
const showApp = () => {
|
|
18
|
+
const app = document.getElementById("runlab-custom-div");
|
|
19
|
+
const btn = document.getElementById("runlab-custom-btn");
|
|
20
|
+
|
|
21
|
+
const displayStyle = window.getComputedStyle(app).display;
|
|
22
|
+
|
|
23
|
+
if (displayStyle === "none") {
|
|
24
|
+
app.style.display = "block";
|
|
25
|
+
btn.textContent = "Hide App";
|
|
26
|
+
}
|
|
27
|
+
if (displayStyle === "block") {
|
|
28
|
+
app.style.display = "none";
|
|
29
|
+
btn.textContent = "Show App";
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<button
|
|
36
|
+
id="runlab-custom-btn"
|
|
37
|
+
onClick={showApp}
|
|
38
|
+
className="show-app-button"
|
|
39
|
+
>
|
|
40
|
+
Show App
|
|
41
|
+
</button>
|
|
42
|
+
|
|
43
|
+
<div id="runlab-custom-div" style={{ display: "none" }}></div>
|
|
44
|
+
</>
|
|
45
|
+
);
|
|
46
|
+
}
|