pinokiod 3.162.0 → 3.164.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/package.json +1 -1
- package/server/public/common.js +1 -6
- package/server/views/app.ejs +70 -117
- package/server/views/d.ejs +2 -22
package/package.json
CHANGED
package/server/public/common.js
CHANGED
|
@@ -28,7 +28,7 @@ function collectPostMessageTargets(contextWindow) {
|
|
|
28
28
|
return targets;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function pinokioBroadcastMessage(payload, targetOrigin = '*', contextWindow = null
|
|
31
|
+
function pinokioBroadcastMessage(payload, targetOrigin = '*', contextWindow = null) {
|
|
32
32
|
const ctx = (contextWindow && typeof contextWindow === 'object') ? contextWindow : window;
|
|
33
33
|
let dispatched = false;
|
|
34
34
|
let targets;
|
|
@@ -37,11 +37,6 @@ function pinokioBroadcastMessage(payload, targetOrigin = '*', contextWindow = nu
|
|
|
37
37
|
} catch (_) {
|
|
38
38
|
targets = new Set();
|
|
39
39
|
}
|
|
40
|
-
if (includeCurrent) {
|
|
41
|
-
try {
|
|
42
|
-
targets.add(ctx);
|
|
43
|
-
} catch (_) {}
|
|
44
|
-
}
|
|
45
40
|
if (targets.size === 0) {
|
|
46
41
|
return dispatched;
|
|
47
42
|
}
|
package/server/views/app.ejs
CHANGED
|
@@ -4979,28 +4979,6 @@ body.dark .pinokio-fork-dropdown-remote, body.dark .pinokio-publish-dropdown-rem
|
|
|
4979
4979
|
}
|
|
4980
4980
|
return null
|
|
4981
4981
|
}
|
|
4982
|
-
const forwardEventToParent = (payload) => {
|
|
4983
|
-
if (!payload || typeof payload !== 'object' || payload === null) {
|
|
4984
|
-
return
|
|
4985
|
-
}
|
|
4986
|
-
if (window.parent === window) {
|
|
4987
|
-
return
|
|
4988
|
-
}
|
|
4989
|
-
const forwardingPayload = Object.assign({}, payload, { __pinokioForwarded: true })
|
|
4990
|
-
let forwarded = false
|
|
4991
|
-
if (typeof window.PinokioBroadcastMessage === 'function') {
|
|
4992
|
-
try {
|
|
4993
|
-
forwarded = window.PinokioBroadcastMessage(forwardingPayload, '*', window)
|
|
4994
|
-
} catch (_) {
|
|
4995
|
-
forwarded = false
|
|
4996
|
-
}
|
|
4997
|
-
}
|
|
4998
|
-
if (!forwarded) {
|
|
4999
|
-
try {
|
|
5000
|
-
window.parent.postMessage(forwardingPayload, '*')
|
|
5001
|
-
} catch (_) {}
|
|
5002
|
-
}
|
|
5003
|
-
}
|
|
5004
4982
|
const getTarget = (href) => {
|
|
5005
4983
|
let u
|
|
5006
4984
|
if (href.startsWith("http")) {
|
|
@@ -6410,105 +6388,80 @@ body.dark .pinokio-fork-dropdown-remote, body.dark .pinokio-publish-dropdown-rem
|
|
|
6410
6388
|
window.addEventListener('message', (event) => {
|
|
6411
6389
|
console.log("EVENT", event)
|
|
6412
6390
|
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6391
|
+
// only process the event it's coming from pinokio
|
|
6392
|
+
let origin = event.origin
|
|
6393
|
+
if (origin) {
|
|
6394
|
+
let port = new URL(origin).port || 80
|
|
6395
|
+
if (String(port) === String(location.port) || /https:\/\/.*pinokio\..*(localhost|co)/.test(origin)) {
|
|
6396
|
+
//if (String(port) === "<%=port%>" || /https:\/\/pinokio\..*localhost/.test(origin)) {
|
|
6397
|
+
//if (String(port) === "<%=port%>") {
|
|
6398
|
+
if (event.data) {
|
|
6399
|
+
if (event.data.action) {
|
|
6400
|
+
if (event.data.action.type === "newtab") {
|
|
6401
|
+
addTab(event.data.action.url)
|
|
6402
|
+
} else if (event.data.action.type === "title") {
|
|
6403
|
+
} else if (event.data.action.type === "location") {
|
|
6404
|
+
let url = event.data.action.url
|
|
6405
|
+
//document.querySelector("#location").value = url
|
|
6406
|
+
let pathname = new URL(url).pathname
|
|
6407
|
+
if (pathname.startsWith("/run")) {
|
|
6408
|
+
document.querySelector("#location").value = pathname.slice(4)
|
|
6409
|
+
} else {
|
|
6410
|
+
document.querySelector("#location").value = pathname
|
|
6411
|
+
}
|
|
6412
|
+
}
|
|
6413
|
+
} else if (event.data.launch) {
|
|
6414
|
+
const rawName = event.data.launch.name
|
|
6415
|
+
const escapedSelector = escapeTargetSelector(rawName)
|
|
6416
|
+
if (escapedSelector) {
|
|
6417
|
+
global_selector = `.frame-link[target="${escapedSelector}"]`
|
|
6418
|
+
} else {
|
|
6419
|
+
global_selector = null
|
|
6420
|
+
}
|
|
6421
|
+
const frameExists = Array.from(document.querySelectorAll("main.browserview iframe")).some((frame) => {
|
|
6422
|
+
return frame.name === rawName
|
|
6423
|
+
})
|
|
6424
|
+
if (!frameExists) {
|
|
6425
|
+
create_iframe(rawName, event.data.launch.href)
|
|
6426
|
+
}
|
|
6427
|
+
refresh()
|
|
6428
|
+
} else if (event.data.type === "shell-session-id") {
|
|
6429
|
+
const frameName = resolveFrameName(event.data.frame, event.source)
|
|
6430
|
+
if (frameName && event.data.shellId) {
|
|
6431
|
+
const link = getTabLink(frameName)
|
|
6432
|
+
if (link) {
|
|
6433
|
+
link.setAttribute("data-shell", event.data.shellId)
|
|
6434
|
+
link.dataset.shell = event.data.shellId
|
|
6435
|
+
}
|
|
6436
|
+
}
|
|
6437
|
+
return
|
|
6438
|
+
} else if (event.data.type === "terminal-input") {
|
|
6439
|
+
const frameName = resolveFrameName(event.data.frame, event.source)
|
|
6440
|
+
const hasContent = typeof event.data.hasContent === "boolean" ? event.data.hasContent : Boolean(event.data.line && event.data.line.length > 0)
|
|
6441
|
+
updateTabPreview(frameName, event.data.line || "", hasContent, Date.now())
|
|
6442
|
+
return
|
|
6443
|
+
} else if (event.data.type) {
|
|
6444
|
+
if (event.data.type === 'stream') {
|
|
6445
|
+
const frameName = resolveFrameName(null, event.source)
|
|
6446
|
+
updateTabTimestamp(frameName, Date.now())
|
|
6447
|
+
} else if (event.data.type === 'result') {
|
|
6448
|
+
refresh()
|
|
6449
|
+
refresh_du()
|
|
6450
|
+
refresh_du("logs")
|
|
6451
|
+
} else {
|
|
6452
|
+
if (event.data.type === 'start') {
|
|
6453
|
+
ignorePersistedSelection = true
|
|
6454
|
+
}
|
|
6455
|
+
refresh()
|
|
6456
|
+
}
|
|
6457
|
+
}
|
|
6463
6458
|
} else {
|
|
6464
|
-
|
|
6459
|
+
refresh()
|
|
6465
6460
|
}
|
|
6466
6461
|
}
|
|
6467
|
-
} else if (data.launch) {
|
|
6468
|
-
const rawName = data.launch.name
|
|
6469
|
-
const escapedSelector = escapeTargetSelector(rawName)
|
|
6470
|
-
if (escapedSelector) {
|
|
6471
|
-
global_selector = `.frame-link[target="${escapedSelector}"]`
|
|
6472
|
-
} else {
|
|
6473
|
-
global_selector = null
|
|
6474
|
-
}
|
|
6475
|
-
const frameExists = Array.from(document.querySelectorAll("main.browserview iframe")).some((frame) => {
|
|
6476
|
-
return frame.name === rawName
|
|
6477
|
-
})
|
|
6478
|
-
if (!frameExists) {
|
|
6479
|
-
create_iframe(rawName, data.launch.href)
|
|
6480
|
-
}
|
|
6481
|
-
refresh()
|
|
6482
|
-
} else if (data.type === "shell-session-id") {
|
|
6483
|
-
const frameName = matchedFrameName || (typeof data.frame === 'string' ? data.frame : null)
|
|
6484
|
-
if (frameName && data.shellId) {
|
|
6485
|
-
const link = getTabLink(frameName)
|
|
6486
|
-
if (link) {
|
|
6487
|
-
link.setAttribute("data-shell", data.shellId)
|
|
6488
|
-
link.dataset.shell = data.shellId
|
|
6489
|
-
}
|
|
6490
|
-
}
|
|
6491
|
-
return
|
|
6492
|
-
} else if (data.type === "terminal-input") {
|
|
6493
|
-
const frameName = matchedFrameName || (typeof data.frame === 'string' ? data.frame : null)
|
|
6494
|
-
const hasContent = typeof data.hasContent === "boolean" ? data.hasContent : Boolean(data.line && data.line.length > 0)
|
|
6495
|
-
updateTabPreview(frameName, data.line || "", hasContent, Date.now())
|
|
6496
|
-
return
|
|
6497
|
-
} else if (data.type) {
|
|
6498
|
-
if (data.type === 'stream') {
|
|
6499
|
-
if (matchedFrameName) {
|
|
6500
|
-
updateTabTimestamp(matchedFrameName, Date.now())
|
|
6501
|
-
}
|
|
6502
|
-
} else if (data.type === 'result') {
|
|
6503
|
-
refresh()
|
|
6504
|
-
refresh_du()
|
|
6505
|
-
refresh_du("logs")
|
|
6506
|
-
} else {
|
|
6507
|
-
refresh()
|
|
6508
|
-
}
|
|
6509
|
-
} else {
|
|
6510
|
-
refresh()
|
|
6511
6462
|
}
|
|
6463
|
+
|
|
6464
|
+
|
|
6512
6465
|
});
|
|
6513
6466
|
refresh_du()
|
|
6514
6467
|
refresh_du("logs")
|
package/server/views/d.ejs
CHANGED
|
@@ -593,32 +593,12 @@ const launchTab = (tab) => {
|
|
|
593
593
|
const href = appendSessionParam(baseHref, session)
|
|
594
594
|
const target = appendSessionParam(baseTarget, session)
|
|
595
595
|
|
|
596
|
-
|
|
596
|
+
window.parent.postMessage({
|
|
597
597
|
launch: {
|
|
598
598
|
name: target,
|
|
599
599
|
href
|
|
600
600
|
}
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
let posted = false
|
|
604
|
-
if (typeof window !== 'undefined' && typeof window.PinokioBroadcastMessage === 'function') {
|
|
605
|
-
try {
|
|
606
|
-
posted = window.PinokioBroadcastMessage(payload, '*', window, true)
|
|
607
|
-
} catch (_) {
|
|
608
|
-
posted = false
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
if (!posted) {
|
|
613
|
-
try {
|
|
614
|
-
window.parent.postMessage(payload, '*')
|
|
615
|
-
} catch (_) {}
|
|
616
|
-
if (window.parent && window.parent !== window && typeof window.postMessage === 'function') {
|
|
617
|
-
try {
|
|
618
|
-
window.postMessage(payload, '*')
|
|
619
|
-
} catch (_) {}
|
|
620
|
-
}
|
|
621
|
-
}
|
|
601
|
+
}, "*")
|
|
622
602
|
|
|
623
603
|
return true
|
|
624
604
|
}
|