@1agh/maude 1.6.1 → 1.6.3
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.
|
@@ -33,7 +33,12 @@ import { sizingModeOf, sizingModePatch } from '../sizing-mode.ts';
|
|
|
33
33
|
// same "pull only pure logic into the client bundle" shape as the imports
|
|
34
34
|
// above (a type-only SyncStatusSnapshot import that Bun erases).
|
|
35
35
|
import { syncPresentation } from '../sync/presentation.ts';
|
|
36
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
canvasTokenRefreshDelay,
|
|
38
|
+
canvasUrl,
|
|
39
|
+
setLiveCanvasToken,
|
|
40
|
+
withCanvasToken,
|
|
41
|
+
} from './canvas-url.js';
|
|
37
42
|
import { applyEditRequest } from './apply-edit-request.ts';
|
|
38
43
|
import { createIndexLoader } from './index-loader.ts';
|
|
39
44
|
import {
|
|
@@ -10917,10 +10922,7 @@ function App() {
|
|
|
10917
10922
|
setLiveCanvasToken(token);
|
|
10918
10923
|
// To the canvas origin only, never '*': a frame the canvas content
|
|
10919
10924
|
// navigated elsewhere must not be handed the capability.
|
|
10920
|
-
|
|
10921
|
-
try {
|
|
10922
|
-
target = new URL(cfg.canvasOrigin, location.href).origin;
|
|
10923
|
-
} catch {}
|
|
10925
|
+
const target = canvasTarget();
|
|
10924
10926
|
if (target) {
|
|
10925
10927
|
for (const el of iframesRef.current.values()) {
|
|
10926
10928
|
try {
|
|
@@ -10929,7 +10931,36 @@ function App() {
|
|
|
10929
10931
|
}
|
|
10930
10932
|
}
|
|
10931
10933
|
schedule(token);
|
|
10934
|
+
return token;
|
|
10935
|
+
}
|
|
10936
|
+
function canvasTarget() {
|
|
10937
|
+
try {
|
|
10938
|
+
return new URL(cfg.canvasOrigin, location.href).origin;
|
|
10939
|
+
} catch {
|
|
10940
|
+
return null;
|
|
10941
|
+
}
|
|
10942
|
+
}
|
|
10943
|
+
// A FRAME WHOSE OWN DOCUMENT WAS REFUSED AS EXPIRED. The re-mint above
|
|
10944
|
+
// reaches a running canvas's fetches, but not a frame that re-navigates
|
|
10945
|
+
// itself (a hard reload, a laptop that slept past the cadence): that load
|
|
10946
|
+
// carries the URL it was built with, and the canvas origin answers with a
|
|
10947
|
+
// small page that asks us for a fresh capability (hub studio-proxy). Mint
|
|
10948
|
+
// one and point just that frame at it — no "reload the project".
|
|
10949
|
+
let reviving = false;
|
|
10950
|
+
async function onExpired(e) {
|
|
10951
|
+
if (e.data?.dgn !== 'canvas-expired' || e.origin !== canvasTarget() || reviving) return;
|
|
10952
|
+
reviving = true;
|
|
10953
|
+
try {
|
|
10954
|
+
const token = await refresh();
|
|
10955
|
+
if (!token) return;
|
|
10956
|
+
for (const el of iframesRef.current.values()) {
|
|
10957
|
+
if (el.contentWindow === e.source) el.src = withCanvasToken(el.src, token);
|
|
10958
|
+
}
|
|
10959
|
+
} finally {
|
|
10960
|
+
reviving = false;
|
|
10961
|
+
}
|
|
10932
10962
|
}
|
|
10963
|
+
window.addEventListener('message', onExpired);
|
|
10933
10964
|
schedule(cfg.canvasToken);
|
|
10934
10965
|
// A background tab's timers are throttled; one woken past its due time
|
|
10935
10966
|
// re-mints at once rather than on the throttled tick.
|
|
@@ -10941,6 +10972,7 @@ function App() {
|
|
|
10941
10972
|
stopped = true;
|
|
10942
10973
|
clearTimeout(timer);
|
|
10943
10974
|
document.removeEventListener('visibilitychange', onVisible);
|
|
10975
|
+
window.removeEventListener('message', onExpired);
|
|
10944
10976
|
};
|
|
10945
10977
|
}, [cfg?.canvasToken, cfg?.canvasOrigin]);
|
|
10946
10978
|
|
|
@@ -46,6 +46,21 @@ export function canvasTokenRefreshDelay(token, now = Date.now()) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* The same canvas URL carrying a different capability. Used when a frame's
|
|
51
|
+
* own document was refused as expired (a hard reload, a laptop that slept
|
|
52
|
+
* past the re-mint): only `t` changes, so the frame comes back where it was.
|
|
53
|
+
*/
|
|
54
|
+
export function withCanvasToken(src, token) {
|
|
55
|
+
try {
|
|
56
|
+
const u = new URL(src);
|
|
57
|
+
u.searchParams.set('t', token);
|
|
58
|
+
return u.toString();
|
|
59
|
+
} catch {
|
|
60
|
+
return src;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
49
64
|
export function urlOf(p) {
|
|
50
65
|
return '/' + p.split('/').map(encodeURIComponent).join('/');
|
|
51
66
|
}
|
|
@@ -89,6 +89,12 @@ export function createGitLifecycle(ctx: Context, registry: Registry): GitLifecyc
|
|
|
89
89
|
// filesystems / git implementations fire spurious events on packfile
|
|
90
90
|
// operations too — the readHead diff above filters noise.
|
|
91
91
|
watcher = watch(headPath, { persistent: false }, () => schedule());
|
|
92
|
+
// An 'error' with no listener is thrown and exits the studio (the
|
|
93
|
+
// 2026-10-02 cell crash loop came from a sibling watcher). Log and stop.
|
|
94
|
+
watcher.on('error', (err) => {
|
|
95
|
+
console.warn('[git-lifecycle] .git/HEAD watcher error — stopped:', err.message);
|
|
96
|
+
watcher?.close();
|
|
97
|
+
});
|
|
92
98
|
} catch (err) {
|
|
93
99
|
console.warn(
|
|
94
100
|
'[git-lifecycle] failed to watch .git/HEAD:',
|