pinokiod 3.163.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 +75 -141
- 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")) {
|
|
@@ -5157,17 +5135,10 @@ body.dark .pinokio-fork-dropdown-remote, body.dark .pinokio-publish-dropdown-rem
|
|
|
5157
5135
|
}
|
|
5158
5136
|
}
|
|
5159
5137
|
|
|
5160
|
-
console.log(
|
|
5161
|
-
triggeredByUser,
|
|
5162
|
-
resolvedByGlobalSelector,
|
|
5163
|
-
skipPersistedSelection,
|
|
5164
|
-
hasPersistedSelection,
|
|
5165
|
-
explicitTarget: Boolean(explicitTarget),
|
|
5166
|
-
targetInitial: target ? target.outerHTML : null
|
|
5167
|
-
})
|
|
5138
|
+
console.log({ target, skipPersistedSelection })
|
|
5168
5139
|
if (!target && !skipPersistedSelection) {
|
|
5169
5140
|
preselected = document.querySelector('#devtab.frame-link.selected') || document.querySelector('.frame-link.selected')
|
|
5170
|
-
console.log(
|
|
5141
|
+
console.log({ preselected })
|
|
5171
5142
|
}
|
|
5172
5143
|
|
|
5173
5144
|
if (!target && persistedSelectionPayload) {
|
|
@@ -5243,7 +5214,7 @@ body.dark .pinokio-fork-dropdown-remote, body.dark .pinokio-publish-dropdown-rem
|
|
|
5243
5214
|
target = preselected
|
|
5244
5215
|
}
|
|
5245
5216
|
|
|
5246
|
-
console.log(
|
|
5217
|
+
console.log({ targetAfter: target })
|
|
5247
5218
|
|
|
5248
5219
|
if (!target) {
|
|
5249
5220
|
target = document.querySelector(".frame-link")
|
|
@@ -6221,16 +6192,7 @@ body.dark .pinokio-fork-dropdown-remote, body.dark .pinokio-publish-dropdown-rem
|
|
|
6221
6192
|
const navContainers = [document.querySelector("aside"), document.querySelector("#fs-status")]
|
|
6222
6193
|
navContainers.forEach((container) => {
|
|
6223
6194
|
if (container) {
|
|
6224
|
-
container.addEventListener("click",
|
|
6225
|
-
const frameLink = event.target?.closest && event.target.closest('.frame-link')
|
|
6226
|
-
if (frameLink) {
|
|
6227
|
-
console.log('[handleMenuClick] triggered', {
|
|
6228
|
-
origin: event.target && event.target.className,
|
|
6229
|
-
frameLink: frameLink.outerHTML
|
|
6230
|
-
})
|
|
6231
|
-
}
|
|
6232
|
-
handleMenuClick(event)
|
|
6233
|
-
})
|
|
6195
|
+
container.addEventListener("click", handleMenuClick)
|
|
6234
6196
|
}
|
|
6235
6197
|
})
|
|
6236
6198
|
setupTabLinkHover()
|
|
@@ -6309,7 +6271,6 @@ body.dark .pinokio-fork-dropdown-remote, body.dark .pinokio-publish-dropdown-rem
|
|
|
6309
6271
|
status = res.status
|
|
6310
6272
|
return res.text()
|
|
6311
6273
|
})
|
|
6312
|
-
console.log('[try_dynamic] fetched', { status, length: dynamic ? dynamic.length : 0 })
|
|
6313
6274
|
if (status == 500) {
|
|
6314
6275
|
ModalInput({
|
|
6315
6276
|
description: dynamic,
|
|
@@ -6329,10 +6290,8 @@ body.dark .pinokio-fork-dropdown-remote, body.dark .pinokio-publish-dropdown-rem
|
|
|
6329
6290
|
}
|
|
6330
6291
|
let default_selection = document.querySelector(".dynamic .submenu [data-default]")
|
|
6331
6292
|
if (default_selection) {
|
|
6332
|
-
console.log(
|
|
6293
|
+
console.log("CLICK default")
|
|
6333
6294
|
default_selection.click()
|
|
6334
|
-
} else {
|
|
6335
|
-
console.log('[try_dynamic] no default selection found after update')
|
|
6336
6295
|
}
|
|
6337
6296
|
rendered = true
|
|
6338
6297
|
} else {
|
|
@@ -6429,105 +6388,80 @@ body.dark .pinokio-fork-dropdown-remote, body.dark .pinokio-publish-dropdown-rem
|
|
|
6429
6388
|
window.addEventListener('message', (event) => {
|
|
6430
6389
|
console.log("EVENT", event)
|
|
6431
6390
|
|
|
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
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
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
|
+
}
|
|
6482
6458
|
} else {
|
|
6483
|
-
|
|
6484
|
-
}
|
|
6485
|
-
}
|
|
6486
|
-
} else if (data.launch) {
|
|
6487
|
-
const rawName = data.launch.name
|
|
6488
|
-
const escapedSelector = escapeTargetSelector(rawName)
|
|
6489
|
-
if (escapedSelector) {
|
|
6490
|
-
global_selector = `.frame-link[target="${escapedSelector}"]`
|
|
6491
|
-
} else {
|
|
6492
|
-
global_selector = null
|
|
6493
|
-
}
|
|
6494
|
-
const frameExists = Array.from(document.querySelectorAll("main.browserview iframe")).some((frame) => {
|
|
6495
|
-
return frame.name === rawName
|
|
6496
|
-
})
|
|
6497
|
-
if (!frameExists) {
|
|
6498
|
-
create_iframe(rawName, data.launch.href)
|
|
6499
|
-
}
|
|
6500
|
-
refresh()
|
|
6501
|
-
} else if (data.type === "shell-session-id") {
|
|
6502
|
-
const frameName = matchedFrameName || (typeof data.frame === 'string' ? data.frame : null)
|
|
6503
|
-
if (frameName && data.shellId) {
|
|
6504
|
-
const link = getTabLink(frameName)
|
|
6505
|
-
if (link) {
|
|
6506
|
-
link.setAttribute("data-shell", data.shellId)
|
|
6507
|
-
link.dataset.shell = data.shellId
|
|
6459
|
+
refresh()
|
|
6508
6460
|
}
|
|
6509
6461
|
}
|
|
6510
|
-
return
|
|
6511
|
-
} else if (data.type === "terminal-input") {
|
|
6512
|
-
const frameName = matchedFrameName || (typeof data.frame === 'string' ? data.frame : null)
|
|
6513
|
-
const hasContent = typeof data.hasContent === "boolean" ? data.hasContent : Boolean(data.line && data.line.length > 0)
|
|
6514
|
-
updateTabPreview(frameName, data.line || "", hasContent, Date.now())
|
|
6515
|
-
return
|
|
6516
|
-
} else if (data.type) {
|
|
6517
|
-
if (data.type === 'stream') {
|
|
6518
|
-
if (matchedFrameName) {
|
|
6519
|
-
updateTabTimestamp(matchedFrameName, Date.now())
|
|
6520
|
-
}
|
|
6521
|
-
} else if (data.type === 'result') {
|
|
6522
|
-
refresh()
|
|
6523
|
-
refresh_du()
|
|
6524
|
-
refresh_du("logs")
|
|
6525
|
-
} else {
|
|
6526
|
-
refresh()
|
|
6527
|
-
}
|
|
6528
|
-
} else {
|
|
6529
|
-
refresh()
|
|
6530
6462
|
}
|
|
6463
|
+
|
|
6464
|
+
|
|
6531
6465
|
});
|
|
6532
6466
|
refresh_du()
|
|
6533
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
|
}
|