pinokiod 6.0.73 → 6.0.75
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
CHANGED
|
@@ -7,7 +7,7 @@ const { resolveDesktopEventWorkspace } = require("./desktop_event_router")
|
|
|
7
7
|
|
|
8
8
|
const VALID_INJECT_WORLDS = new Set(["main", "isolated"])
|
|
9
9
|
const VALID_INJECT_WHEN = new Set(["start", "end", "idle"])
|
|
10
|
-
const VALID_INJECT_FRAMES = new Set(["
|
|
10
|
+
const VALID_INJECT_FRAMES = new Set(["self", "all", "top"])
|
|
11
11
|
|
|
12
12
|
const normalizeInjectMatchList = (value) => {
|
|
13
13
|
if (!value) {
|
|
@@ -48,7 +48,7 @@ const normalizeInjectEntry = (value) => {
|
|
|
48
48
|
let match = []
|
|
49
49
|
let world = "main"
|
|
50
50
|
let when = "idle"
|
|
51
|
-
let frame = "
|
|
51
|
+
let frame = "self"
|
|
52
52
|
|
|
53
53
|
if (typeof value === "string") {
|
|
54
54
|
src = value.trim()
|
|
@@ -70,7 +70,7 @@ const normalizeInjectEntry = (value) => {
|
|
|
70
70
|
if (typeof value.frame === "string") {
|
|
71
71
|
const normalizedFrame = value.frame.trim().toLowerCase()
|
|
72
72
|
if (VALID_INJECT_FRAMES.has(normalizedFrame)) {
|
|
73
|
-
frame = normalizedFrame
|
|
73
|
+
frame = normalizedFrame === "top" ? "self" : normalizedFrame
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -214,7 +214,7 @@ const resolveInjectDescriptor = async ({ workspace, workspaceRoot, launcher, des
|
|
|
214
214
|
match: Array.isArray(descriptor.match) ? descriptor.match.slice() : ["*"],
|
|
215
215
|
world: descriptor.world || "main",
|
|
216
216
|
when: descriptor.when || "idle",
|
|
217
|
-
frame: descriptor.frame || "
|
|
217
|
+
frame: descriptor.frame || "self"
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
|
package/server/views/app.ejs
CHANGED
|
@@ -5316,33 +5316,119 @@ header.navheader .mode-selector .community-mode-toggle {
|
|
|
5316
5316
|
}
|
|
5317
5317
|
}
|
|
5318
5318
|
const parseInjectDescriptors = (value) => {
|
|
5319
|
-
if (!value) {
|
|
5319
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
5320
5320
|
return []
|
|
5321
5321
|
}
|
|
5322
5322
|
try {
|
|
5323
|
-
const parsed = JSON.parse(value)
|
|
5323
|
+
const parsed = JSON.parse(decodeURIComponent(value))
|
|
5324
5324
|
return Array.isArray(parsed) ? parsed : []
|
|
5325
5325
|
} catch (_) {
|
|
5326
5326
|
return []
|
|
5327
5327
|
}
|
|
5328
5328
|
}
|
|
5329
|
+
const logInjectDebug = (label, payload) => {
|
|
5330
|
+
try {
|
|
5331
|
+
console.log("[pinokio][inject][app]", label, payload)
|
|
5332
|
+
console.log("[pinokio][inject][app:json]", label, JSON.stringify(payload))
|
|
5333
|
+
} catch (_) {
|
|
5334
|
+
}
|
|
5335
|
+
}
|
|
5336
|
+
let injectTargetPublishScheduled = false
|
|
5337
|
+
const buildBrowserviewInjectTargets = () => {
|
|
5338
|
+
return Array.from(document.querySelectorAll("main.browserview iframe")).map((frame) => {
|
|
5339
|
+
if (!frame || typeof frame.getAttribute !== "function") {
|
|
5340
|
+
return null
|
|
5341
|
+
}
|
|
5342
|
+
return {
|
|
5343
|
+
name: frame.name || frame.getAttribute("name") || "",
|
|
5344
|
+
src: frame.getAttribute("src") || frame.src || "",
|
|
5345
|
+
inject: parseInjectDescriptors(frame.getAttribute("data-pinokio-inject"))
|
|
5346
|
+
}
|
|
5347
|
+
}).filter(Boolean)
|
|
5348
|
+
}
|
|
5349
|
+
const publishBrowserviewInjectTargets = (reason = "sync") => {
|
|
5350
|
+
const payload = {
|
|
5351
|
+
reason,
|
|
5352
|
+
pageUrl: window.location.href,
|
|
5353
|
+
targets: buildBrowserviewInjectTargets()
|
|
5354
|
+
}
|
|
5355
|
+
logInjectDebug("publish-targets", payload)
|
|
5356
|
+
try {
|
|
5357
|
+
if (window.electronAPI && typeof window.electronAPI.send === "function") {
|
|
5358
|
+
window.electronAPI.send("pinokio:update-inject-targets", payload)
|
|
5359
|
+
}
|
|
5360
|
+
} catch (_) {
|
|
5361
|
+
}
|
|
5362
|
+
}
|
|
5363
|
+
const schedulePublishBrowserviewInjectTargets = (reason = "sync") => {
|
|
5364
|
+
if (injectTargetPublishScheduled) {
|
|
5365
|
+
return
|
|
5366
|
+
}
|
|
5367
|
+
injectTargetPublishScheduled = true
|
|
5368
|
+
setTimeout(() => {
|
|
5369
|
+
injectTargetPublishScheduled = false
|
|
5370
|
+
publishBrowserviewInjectTargets(reason)
|
|
5371
|
+
}, 0)
|
|
5372
|
+
}
|
|
5373
|
+
const installBrowserviewInjectTargetObserver = () => {
|
|
5374
|
+
if (typeof MutationObserver !== "function") {
|
|
5375
|
+
return
|
|
5376
|
+
}
|
|
5377
|
+
const root = document.querySelector("main")
|
|
5378
|
+
if (!root) {
|
|
5379
|
+
return
|
|
5380
|
+
}
|
|
5381
|
+
const observer = new MutationObserver((records) => {
|
|
5382
|
+
const relevant = records.some((record) => {
|
|
5383
|
+
if (record.type === "childList") {
|
|
5384
|
+
return true
|
|
5385
|
+
}
|
|
5386
|
+
return record.type === "attributes"
|
|
5387
|
+
})
|
|
5388
|
+
if (relevant) {
|
|
5389
|
+
schedulePublishBrowserviewInjectTargets("mutation")
|
|
5390
|
+
}
|
|
5391
|
+
})
|
|
5392
|
+
observer.observe(root, {
|
|
5393
|
+
subtree: true,
|
|
5394
|
+
childList: true,
|
|
5395
|
+
attributes: true,
|
|
5396
|
+
attributeFilter: ["src", "name", "data-pinokio-inject", "class"]
|
|
5397
|
+
})
|
|
5398
|
+
schedulePublishBrowserviewInjectTargets("observer:init")
|
|
5399
|
+
}
|
|
5329
5400
|
const readLinkInjectDescriptors = (node) => {
|
|
5330
5401
|
if (!node || typeof node.getAttribute !== "function") {
|
|
5331
5402
|
return []
|
|
5332
5403
|
}
|
|
5333
|
-
|
|
5404
|
+
const raw = node.getAttribute("data-pinokio-inject")
|
|
5405
|
+
const parsed = parseInjectDescriptors(raw)
|
|
5406
|
+
logInjectDebug("read-link", {
|
|
5407
|
+
text: node.textContent ? node.textContent.trim().slice(0, 120) : "",
|
|
5408
|
+
href: node.getAttribute("href") || "",
|
|
5409
|
+
target: node.getAttribute("target") || "",
|
|
5410
|
+
hasInjectAttribute: node.hasAttribute("data-pinokio-inject"),
|
|
5411
|
+
rawInjectAttribute: raw,
|
|
5412
|
+
parsedInject: parsed
|
|
5413
|
+
})
|
|
5414
|
+
return parsed
|
|
5334
5415
|
}
|
|
5335
5416
|
const writeFrameInjectDescriptors = (frame, descriptors) => {
|
|
5336
5417
|
if (!frame || !frame.dataset) {
|
|
5337
5418
|
return
|
|
5338
5419
|
}
|
|
5339
5420
|
const normalized = Array.isArray(descriptors) ? descriptors : []
|
|
5421
|
+
logInjectDebug("write-frame", {
|
|
5422
|
+
frameName: frame.name || "",
|
|
5423
|
+
frameSrc: frame.src || "",
|
|
5424
|
+
descriptors: normalized
|
|
5425
|
+
})
|
|
5340
5426
|
if (normalized.length === 0) {
|
|
5341
5427
|
delete frame.dataset.pinokioInject
|
|
5342
5428
|
frame.removeAttribute("data-pinokio-inject")
|
|
5343
5429
|
return
|
|
5344
5430
|
}
|
|
5345
|
-
const serialized = JSON.stringify(normalized)
|
|
5431
|
+
const serialized = encodeURIComponent(JSON.stringify(normalized))
|
|
5346
5432
|
frame.dataset.pinokioInject = serialized
|
|
5347
5433
|
frame.setAttribute("data-pinokio-inject", serialized)
|
|
5348
5434
|
}
|
|
@@ -5379,6 +5465,7 @@ header.navheader .mode-selector .community-mode-toggle {
|
|
|
5379
5465
|
return false
|
|
5380
5466
|
}
|
|
5381
5467
|
}
|
|
5468
|
+
installBrowserviewInjectTargetObserver()
|
|
5382
5469
|
document.addEventListener("click", (e) => {
|
|
5383
5470
|
interacted = true
|
|
5384
5471
|
})
|
|
@@ -6453,17 +6540,24 @@ const rerenderMenuSection = (container, html) => {
|
|
|
6453
6540
|
return
|
|
6454
6541
|
}
|
|
6455
6542
|
|
|
6456
|
-
|
|
6457
|
-
|
|
6543
|
+
document.querySelector(".container").classList.add("active")
|
|
6544
|
+
document.querySelector("aside").classList.remove("active")
|
|
6458
6545
|
|
|
6459
6546
|
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6547
|
+
// Instantiate a frame with the selected target's href
|
|
6548
|
+
let url = target.href
|
|
6549
|
+
const targetInjectDescriptors = readLinkInjectDescriptors(target)
|
|
6550
|
+
logInjectDebug("render-selection", {
|
|
6551
|
+
href: target.href || "",
|
|
6552
|
+
target: target.target || "",
|
|
6553
|
+
text: target.textContent ? target.textContent.trim().slice(0, 120) : "",
|
|
6554
|
+
rawInjectAttribute: target.getAttribute("data-pinokio-inject"),
|
|
6555
|
+
parsedInject: targetInjectDescriptors
|
|
6556
|
+
})
|
|
6463
6557
|
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6558
|
+
if (!url) {
|
|
6559
|
+
return
|
|
6560
|
+
}
|
|
6467
6561
|
// document.querySelector("#open-browser").href = url
|
|
6468
6562
|
// document.querySelector("#clone-tab").setAttribute("data-href", url)
|
|
6469
6563
|
|
|
@@ -7985,6 +8079,11 @@ const rerenderMenuSection = (container, html) => {
|
|
|
7985
8079
|
return frame.name === rawName
|
|
7986
8080
|
})
|
|
7987
8081
|
if (!frameExists) {
|
|
8082
|
+
logInjectDebug("event-launch:create-iframe", {
|
|
8083
|
+
name: rawName,
|
|
8084
|
+
href: event.data.launch.href || "",
|
|
8085
|
+
launch: event.data.launch || null
|
|
8086
|
+
})
|
|
7988
8087
|
create_iframe(rawName, event.data.launch.href)
|
|
7989
8088
|
}
|
|
7990
8089
|
refresh()
|
|
@@ -12396,9 +12495,22 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
12396
12495
|
const resolveFrameInjectFromSource = (sourceWindow) => {
|
|
12397
12496
|
const record = resolveFrameSourceRecord(sourceWindow)
|
|
12398
12497
|
if (!record || !record.root || !record.root.dataset) {
|
|
12498
|
+
logInjectDebug("resolve-frame-inject:missing-record", {
|
|
12499
|
+
hasRecord: Boolean(record),
|
|
12500
|
+
hasRoot: Boolean(record && record.root),
|
|
12501
|
+
sourceMatchesKnownFrame: Boolean(record)
|
|
12502
|
+
})
|
|
12399
12503
|
return []
|
|
12400
12504
|
}
|
|
12401
|
-
|
|
12505
|
+
const raw = record.root.dataset.pinokioInject || record.root.getAttribute("data-pinokio-inject")
|
|
12506
|
+
const parsed = parseInjectDescriptors(raw)
|
|
12507
|
+
logInjectDebug("resolve-frame-inject", {
|
|
12508
|
+
frameName: record.root.name || "",
|
|
12509
|
+
frameSrc: record.root.src || "",
|
|
12510
|
+
rawInjectAttribute: raw,
|
|
12511
|
+
parsedInject: parsed
|
|
12512
|
+
})
|
|
12513
|
+
return parsed
|
|
12402
12514
|
}
|
|
12403
12515
|
|
|
12404
12516
|
const resolveFrameRootUrlFromSource = (sourceWindow) => {
|
|
@@ -12483,6 +12595,10 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
12483
12595
|
}
|
|
12484
12596
|
context.pageUrl = window.location.href
|
|
12485
12597
|
context.currentUrl = window.location.href
|
|
12598
|
+
logInjectDebug("dispatch-inject-request:start", {
|
|
12599
|
+
context,
|
|
12600
|
+
inject
|
|
12601
|
+
})
|
|
12486
12602
|
const response = await fetch("/pinokio/inject", {
|
|
12487
12603
|
method: "POST",
|
|
12488
12604
|
headers: {
|
|
@@ -12492,9 +12608,19 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
12492
12608
|
body: JSON.stringify({ context, inject })
|
|
12493
12609
|
})
|
|
12494
12610
|
if (!response.ok) {
|
|
12611
|
+
logInjectDebug("dispatch-inject-request:non-ok", {
|
|
12612
|
+
status: response.status,
|
|
12613
|
+
context,
|
|
12614
|
+
inject
|
|
12615
|
+
})
|
|
12495
12616
|
return null
|
|
12496
12617
|
}
|
|
12497
12618
|
const result = await response.json().catch(() => null)
|
|
12619
|
+
logInjectDebug("dispatch-inject-request:done", {
|
|
12620
|
+
context,
|
|
12621
|
+
inject,
|
|
12622
|
+
result
|
|
12623
|
+
})
|
|
12498
12624
|
return result && typeof result === "object" ? result : null
|
|
12499
12625
|
}
|
|
12500
12626
|
|
|
@@ -12573,10 +12699,25 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
12573
12699
|
}
|
|
12574
12700
|
}).catch(() => {})
|
|
12575
12701
|
} else if (messageType === "pinokio:inject:request") {
|
|
12702
|
+
logInjectDebug("message:inject-request", {
|
|
12703
|
+
sourceFrameUrl: resolveFrameUrlFromSource(event.source),
|
|
12704
|
+
payload: event.data
|
|
12705
|
+
})
|
|
12576
12706
|
dispatchPinokioInjectRequest(event.data, event.source).then((result) => {
|
|
12577
12707
|
if (!result || !result.ok || !event.source || typeof event.source.postMessage !== "function") {
|
|
12708
|
+
logInjectDebug("message:inject-request:skip-response", {
|
|
12709
|
+
result
|
|
12710
|
+
})
|
|
12578
12711
|
return
|
|
12579
12712
|
}
|
|
12713
|
+
logInjectDebug("message:inject-request:respond", {
|
|
12714
|
+
requestId: typeof event.data.requestId === "string" ? event.data.requestId : "",
|
|
12715
|
+
inject: extractInjectDescriptors(result),
|
|
12716
|
+
scripts: Array.isArray(result.scripts) ? result.scripts : [],
|
|
12717
|
+
context: {
|
|
12718
|
+
frameUrl: resolveFrameUrlFromSource(event.source) || ""
|
|
12719
|
+
}
|
|
12720
|
+
})
|
|
12580
12721
|
event.source.postMessage({
|
|
12581
12722
|
e: "pinokio:inject:load",
|
|
12582
12723
|
requestId: typeof event.data.requestId === "string" ? event.data.requestId : "",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
<% } %>
|
|
41
41
|
</div>
|
|
42
42
|
<% } else if (item.target === "_blank") { %>
|
|
43
|
-
<a <%=item.default ? 'data-default' : ''%> data-confirm="<%=item.confirm%>" data-index="<%=index%>" target="<%=item.target%>" data-mode="<%=item.mode%>" href="<%=item.href%>" class='btn header-item frame-link <%=item.display || ""%>'<%= item.target_full ? ` data-target-full="${item.target_full}"` : '' %><%= item.project_slug ? ` data-project-slug="${item.project_slug}"` : ''
|
|
43
|
+
<a <%=item.default ? 'data-default' : ''%> data-confirm="<%=item.confirm%>" data-index="<%=index%>" target="<%=item.target%>" data-mode="<%=item.mode%>" href="<%=item.href%>" class='btn header-item frame-link <%=item.display || ""%>'<%= item.target_full ? ` data-target-full="${item.target_full}"` : '' %><%= item.project_slug ? ` data-project-slug="${item.project_slug}"` : '' %><%- item.inject ? ` data-pinokio-inject="${encodeURIComponent(JSON.stringify(item.inject))}"` : '' %>>
|
|
44
44
|
<div class='tab'><%-item.btn%></div>
|
|
45
45
|
<% if (item.arrow) { %>
|
|
46
46
|
<i class="fa-solid fa-angle-right"></i>
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
</div>
|
|
51
51
|
</a>
|
|
52
52
|
<% } else { %>
|
|
53
|
-
<a <%=item.default ? 'data-default' : ''%> data-confirm="<%=item.confirm%>" data-index="<%=index%>" target="<%=item.target%>" data-mode="<%=item.mode%>" href="<%=item.href%>" class='btn header-item frame-link <%=item.display || ""%>'<%= item.target_full ? ` data-target-full="${item.target_full}"` : '' %> <%=item.shell_id ? `data-shell=${item.shell_id}` : ""%> <%=item.script_id ? `data-script=${item.script_id}` : ''%><%= item.project_slug ? ` data-project-slug="${item.project_slug}"` : ''
|
|
53
|
+
<a <%=item.default ? 'data-default' : ''%> data-confirm="<%=item.confirm%>" data-index="<%=index%>" target="<%=item.target%>" data-mode="<%=item.mode%>" href="<%=item.href%>" class='btn header-item frame-link <%=item.display || ""%>'<%= item.target_full ? ` data-target-full="${item.target_full}"` : '' %> <%=item.shell_id ? `data-shell=${item.shell_id}` : ""%> <%=item.script_id ? `data-script=${item.script_id}` : ''%><%= item.project_slug ? ` data-project-slug="${item.project_slug}"` : '' %><%- item.inject ? ` data-pinokio-inject="${encodeURIComponent(JSON.stringify(item.inject))}"` : '' %>>
|
|
54
54
|
<% if (item.running) { %>
|
|
55
55
|
<i class="fa-solid fa-circle"></i>
|
|
56
56
|
<% } %>
|