pinokiod 3.158.0 → 3.160.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.158.0",
3
+ "version": "3.160.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -91,11 +91,22 @@ class Socket {
91
91
  });
92
92
  this.ws.addEventListener('close', () => {
93
93
  console.log('Disconnected from WebSocket endpoint', { error: this.error, result: this.result });
94
- if (typeof window !== 'undefined' && window.parent && window.parent !== window) {
95
- try {
96
- window.parent.postMessage({ type: 'pinokio:socket-closed' }, '*')
97
- } catch (err) {
98
- console.debug('postMessage error', err)
94
+ if (typeof window !== 'undefined') {
95
+ const payload = { type: 'pinokio:socket-closed' }
96
+ let dispatched = false
97
+ if (typeof window.PinokioBroadcastMessage === 'function') {
98
+ try {
99
+ dispatched = window.PinokioBroadcastMessage(payload, '*', window)
100
+ } catch (err) {
101
+ console.debug('postMessage error', err)
102
+ }
103
+ }
104
+ if (!dispatched && window.parent && window.parent !== window) {
105
+ try {
106
+ window.parent.postMessage(payload, '*')
107
+ } catch (err) {
108
+ console.debug('postMessage error', err)
109
+ }
99
110
  }
100
111
  }
101
112
  resolve()
@@ -1,5 +1,58 @@
1
1
  const CAPTURE_MIN_SIZE = 32;
2
2
 
3
+ function collectPostMessageTargets(contextWindow) {
4
+ const ctx = contextWindow || window;
5
+ const targets = new Set();
6
+ const addTarget = (candidate) => {
7
+ if (!candidate || candidate === ctx) {
8
+ return;
9
+ }
10
+ try {
11
+ if (typeof candidate.postMessage !== 'function') {
12
+ return;
13
+ }
14
+ } catch (_) {
15
+ return;
16
+ }
17
+ targets.add(candidate);
18
+ };
19
+ try {
20
+ addTarget(ctx.parent);
21
+ } catch (_) {}
22
+ try {
23
+ addTarget(ctx.top);
24
+ } catch (_) {}
25
+ try {
26
+ addTarget(ctx.opener);
27
+ } catch (_) {}
28
+ return targets;
29
+ }
30
+
31
+ function pinokioBroadcastMessage(payload, targetOrigin = '*', contextWindow = null) {
32
+ const ctx = (contextWindow && typeof contextWindow === 'object') ? contextWindow : window;
33
+ let dispatched = false;
34
+ let targets;
35
+ try {
36
+ targets = collectPostMessageTargets(ctx);
37
+ } catch (_) {
38
+ targets = new Set();
39
+ }
40
+ if (targets.size === 0) {
41
+ return dispatched;
42
+ }
43
+ targets.forEach((target) => {
44
+ try {
45
+ target.postMessage(payload, targetOrigin);
46
+ dispatched = true;
47
+ } catch (_) {}
48
+ });
49
+ return dispatched;
50
+ }
51
+
52
+ if (typeof window !== 'undefined' && typeof window.PinokioBroadcastMessage !== 'function') {
53
+ window.PinokioBroadcastMessage = pinokioBroadcastMessage;
54
+ }
55
+
3
56
  async function uploadCapture(blob, filename) {
4
57
  const fd = new FormData();
5
58
  fd.append('file', blob, filename);
@@ -1716,9 +1769,22 @@ if (typeof hotkeys === 'function') {
1716
1769
  attemptLeadership();
1717
1770
  })();
1718
1771
  const refreshParent = (e) => {
1719
- // if (window.parent === window.top) {
1720
- window.parent.postMessage(e, "*")
1721
- // }
1772
+ let dispatched = false;
1773
+ if (typeof window !== 'undefined' && typeof window.PinokioBroadcastMessage === 'function') {
1774
+ try {
1775
+ dispatched = window.PinokioBroadcastMessage(e, '*', window);
1776
+ } catch (_) {
1777
+ dispatched = false;
1778
+ }
1779
+ }
1780
+ if (dispatched) {
1781
+ return;
1782
+ }
1783
+ try {
1784
+ if (window.parent && window.parent !== window && typeof window.parent.postMessage === 'function') {
1785
+ window.parent.postMessage(e, '*');
1786
+ }
1787
+ } catch (_) {}
1722
1788
  }
1723
1789
  let tippyInstances = [];
1724
1790
  const COMPACT_LAYOUT_QUERY = '(max-width: 768px)';
@@ -128,7 +128,7 @@
128
128
  }
129
129
 
130
130
  .files-app__sidebar {
131
- width: 280px;
131
+ max-width: 280px;
132
132
  background: var(--sidebar-color);
133
133
  border-right: 1px solid var(--border-color);
134
134
  display: flex;
@@ -44,7 +44,7 @@
44
44
 
45
45
  submit(line, meta = {}) {
46
46
  const win = this.getWindow()
47
- if (!win || !win.parent || typeof win.parent.postMessage !== "function") {
47
+ if (!win) {
48
48
  return
49
49
  }
50
50
  const safeLine = (line || "").replace(/[\x00-\x1F\x7F]/g, "")
@@ -52,12 +52,29 @@
52
52
  const truncated = preview.length > this.limit ? `${preview.slice(0, this.limit)}...` : preview
53
53
  const hadLineBreak = Boolean(meta && meta.hadLineBreak)
54
54
  const meaningful = truncated.length > 0 || hadLineBreak
55
- win.parent.postMessage({
55
+ const payload = {
56
56
  type: "terminal-input",
57
57
  frame: this.getFrameName(),
58
58
  line: truncated,
59
59
  hasContent: meaningful
60
- }, "*")
60
+ }
61
+
62
+ let dispatched = false
63
+ if (typeof global.PinokioBroadcastMessage === "function") {
64
+ try {
65
+ dispatched = global.PinokioBroadcastMessage(payload, "*", win)
66
+ } catch (_) {
67
+ dispatched = false
68
+ }
69
+ }
70
+ if (dispatched) {
71
+ return
72
+ }
73
+ try {
74
+ if (win.parent && win.parent !== win && typeof win.parent.postMessage === "function") {
75
+ win.parent.postMessage(payload, "*")
76
+ }
77
+ } catch (_) {}
61
78
  }
62
79
  }
63
80
 
@@ -6386,6 +6386,7 @@ body.dark .pinokio-fork-dropdown-remote, body.dark .pinokio-publish-dropdown-rem
6386
6386
  init.click()
6387
6387
  }
6388
6388
  window.addEventListener('message', (event) => {
6389
+ console.log("EVENT", event)
6389
6390
 
6390
6391
  // only process the event it's coming from pinokio
6391
6392
  let origin = event.origin
@@ -196,23 +196,57 @@ body.dark #status-window b {
196
196
  background: rgba(127, 91, 243, 0.9);
197
197
  transition: width 0.2s;
198
198
  }
199
+ @media only screen and (max-width: 768px) {
200
+ body {
201
+ flex-direction: column !important;
202
+ }
203
+ }
199
204
  </style>
200
205
  <link href="/terminal.css" rel="stylesheet"/>
201
206
  <script>
202
207
  let shell_id
203
208
  let lastNotifiedShellId = null
209
+ const postMessageToAncestors = (payload) => {
210
+ if (!payload || typeof payload !== "object") {
211
+ return false
212
+ }
213
+ if (typeof window !== "undefined" && typeof window.PinokioBroadcastMessage === "function") {
214
+ try {
215
+ if (window.PinokioBroadcastMessage(payload, "*", window)) {
216
+ return true
217
+ }
218
+ } catch (_) {}
219
+ }
220
+ const targets = new Set()
221
+ try {
222
+ if (window.parent && window.parent !== window && typeof window.parent.postMessage === "function") {
223
+ targets.add(window.parent)
224
+ }
225
+ } catch (_) {}
226
+ try {
227
+ if (window.top && window.top !== window && typeof window.top.postMessage === "function") {
228
+ targets.add(window.top)
229
+ }
230
+ } catch (_) {}
231
+ let dispatched = false
232
+ targets.forEach((target) => {
233
+ try {
234
+ target.postMessage(payload, "*")
235
+ dispatched = true
236
+ } catch (_) {}
237
+ })
238
+ return dispatched
239
+ }
204
240
  const notifyShellSession = (id) => {
205
241
  if (!id || id === lastNotifiedShellId) {
206
242
  return
207
243
  }
208
244
  lastNotifiedShellId = id
209
- if (window && window.parent && typeof window.parent.postMessage === "function") {
210
- window.parent.postMessage({
211
- type: "shell-session-id",
212
- frame: window.name || null,
213
- shellId: id
214
- }, "*")
215
- }
245
+ postMessageToAncestors({
246
+ type: "shell-session-id",
247
+ frame: window.name || null,
248
+ shellId: id
249
+ })
216
250
  }
217
251
  function buildBinaryRpcPayload(rpc, fileEntries) {
218
252
  const metadata = {
@@ -294,19 +328,16 @@ document.addEventListener("DOMContentLoaded", async () => {
294
328
  this.inputTracker.submit(line)
295
329
  return
296
330
  }
297
- if (!window || !window.parent || typeof window.parent.postMessage !== "function") {
298
- return
299
- }
300
331
  const safeLine = (line || "").replace(/[\x00-\x1F\x7F]/g, "")
301
332
  const preview = safeLine.trim()
302
333
  const limit = 200
303
334
  const truncated = preview.length > limit ? preview.slice(0, limit) + "..." : preview
304
- window.parent.postMessage({
335
+ postMessageToAncestors({
305
336
  type: "terminal-input",
306
337
  frame: window.name || null,
307
338
  line: truncated,
308
339
  hasContent: truncated.length > 0
309
- }, "*")
340
+ })
310
341
  }
311
342
  write(text) {
312
343
  if (text !== "\u0007") {
@@ -172,11 +172,48 @@ body.dark #status-window b {
172
172
  body.frozen {
173
173
  overflow: auto !important;
174
174
  }
175
+ @media only screen and (max-width: 768px) {
176
+ body {
177
+ flex-direction: column !important;
178
+ }
179
+ }
175
180
  </style>
176
181
  <link href="/terminal.css" rel="stylesheet"/>
177
182
  <script>
178
183
  let shell_id
179
184
  Dropzone.autoDiscover = false;
185
+ function postMessageToAncestors(payload) {
186
+ if (!payload || typeof payload !== "object") {
187
+ return false
188
+ }
189
+ if (typeof window !== "undefined" && typeof window.PinokioBroadcastMessage === "function") {
190
+ try {
191
+ if (window.PinokioBroadcastMessage(payload, "*", window)) {
192
+ return true
193
+ }
194
+ } catch (_) {}
195
+ }
196
+ const targets = new Set()
197
+ try {
198
+ if (window.parent && window.parent !== window && typeof window.parent.postMessage === "function") {
199
+ targets.add(window.parent)
200
+ }
201
+ } catch (_) {}
202
+ try {
203
+ if (window.top && window.top !== window && typeof window.top.postMessage === "function") {
204
+ targets.add(window.top)
205
+ }
206
+ } catch (_) {}
207
+ let dispatched = false
208
+ targets.forEach((target) => {
209
+ try {
210
+ target.postMessage(payload, "*")
211
+ dispatched = true
212
+ } catch (_) {}
213
+ })
214
+ return dispatched
215
+ }
216
+
180
217
  function buildBinaryRpcPayload(rpc, fileEntries) {
181
218
  const metadata = {
182
219
  rpc,
@@ -283,21 +320,18 @@ document.addEventListener("DOMContentLoaded", async () => {
283
320
  this.inputTracker.submit(line, meta)
284
321
  return
285
322
  }
286
- if (!window || !window.parent || typeof window.parent.postMessage !== "function") {
287
- return
288
- }
289
323
  const safeLine = (line || "").replace(/[\x00-\x1F\x7F]/g, "")
290
324
  const preview = safeLine.trim()
291
325
  const limit = 200
292
326
  const truncated = preview.length > limit ? preview.slice(0, limit) + "..." : preview
293
327
  const hadLineBreak = Boolean(meta && meta.hadLineBreak)
294
328
  const meaningful = truncated.length > 0 || hadLineBreak
295
- window.parent.postMessage({
329
+ postMessageToAncestors({
296
330
  type: "terminal-input",
297
331
  frame: window.name || null,
298
332
  line: truncated,
299
333
  hasContent: meaningful
300
- }, "*")
334
+ })
301
335
  }
302
336
  write(text) {
303
337
  if (text !== "\u0007") {