truecanvas 0.6.1 → 0.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.
- package/dist/{chunk-NAK4DQWO.js → chunk-FJO64PGM.js} +8 -0
- package/dist/{chunk-QJ5M3G4E.js → chunk-PLJRUWCS.js} +1 -0
- package/dist/{chunk-OPKROZI2.js → chunk-S5P2CHHZ.js} +31 -7
- package/dist/cli.js +6 -4
- package/dist/core/index.js +1 -1
- package/dist/editor/assets/Menu-TTrH9CSM.js +9 -0
- package/dist/editor/assets/{Menu-BGfgJ59U.css → Menu-ikkNcA3s.css} +1 -1
- package/dist/editor/assets/hub-C_YkICvy.js +2 -0
- package/dist/editor/assets/main-Dx3BpXRE.js +27 -0
- package/dist/editor/hub.html +3 -3
- package/dist/editor/index.html +3 -3
- package/dist/hub.d.ts +1 -0
- package/dist/hub.js +1 -1
- package/dist/share/index.d.ts +2 -0
- package/dist/share/index.js +1 -1
- package/package.json +1 -1
- package/dist/editor/assets/Menu-BbEG2pRj.js +0 -9
- package/dist/editor/assets/hub-DOR9_rf9.js +0 -2
- package/dist/editor/assets/main-vJb_YsG2.js +0 -27
|
@@ -564,6 +564,13 @@ async function startHub(opts) {
|
|
|
564
564
|
const store = new ProjectStore();
|
|
565
565
|
const editorDir = fileURLToPath(new URL("./editor/", import.meta.url));
|
|
566
566
|
const pkgDir = path5.resolve(path5.dirname(opts.cli), "..");
|
|
567
|
+
const version = (() => {
|
|
568
|
+
try {
|
|
569
|
+
return JSON.parse(fs5.readFileSync(path5.join(pkgDir, "package.json"), "utf8")).version;
|
|
570
|
+
} catch {
|
|
571
|
+
return "";
|
|
572
|
+
}
|
|
573
|
+
})();
|
|
567
574
|
const origin = `http://localhost:${opts.port}`;
|
|
568
575
|
const allowedHosts = /* @__PURE__ */ new Set([`localhost:${opts.port}`, `127.0.0.1:${opts.port}`]);
|
|
569
576
|
const clients = /* @__PURE__ */ new Set();
|
|
@@ -628,6 +635,7 @@ async function startHub(opts) {
|
|
|
628
635
|
const live = await Promise.all(running.map(async (dir) => [dir, await sessionsOf(dir)]));
|
|
629
636
|
return {
|
|
630
637
|
origin,
|
|
638
|
+
version,
|
|
631
639
|
active,
|
|
632
640
|
focus,
|
|
633
641
|
notice: opts.notice ?? null,
|
|
@@ -294,6 +294,32 @@ button:focus-visible { outline: 2px solid #3b82f6; outline-offset: 1px; }
|
|
|
294
294
|
: '<a class="who-btn" href="/signin?next=' + encodeURIComponent(here) + '">Sign in</a>'));
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
// a page frame of a version with a live site shows the real site, on its own origin
|
|
298
|
+
function liveSrc(path) {
|
|
299
|
+
const home = new URL(manifest.live.url);
|
|
300
|
+
const url = new URL(path || "/", home);
|
|
301
|
+
const token = home.searchParams.get("tc_access");
|
|
302
|
+
if (token) url.searchParams.set("tc_access", token);
|
|
303
|
+
return url.href;
|
|
304
|
+
}
|
|
305
|
+
const showsLive = (f) => !!(manifest.live && f.route);
|
|
306
|
+
/**
|
|
307
|
+
* A frame outside a live session: the real site for page frames of a version
|
|
308
|
+
* that has one (animations and all), the frozen copy otherwise. The frozen
|
|
309
|
+
* image stays underneath until the iframe has loaded.
|
|
310
|
+
*/
|
|
311
|
+
function restFrame(f, iframe, img) {
|
|
312
|
+
if (showsLive(f)) {
|
|
313
|
+
iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
|
|
314
|
+
iframe.setAttribute("referrerpolicy", "no-referrer");
|
|
315
|
+
iframe.src = liveSrc(f.route);
|
|
316
|
+
} else {
|
|
317
|
+
iframe.setAttribute("sandbox", "");
|
|
318
|
+
iframe.src = f.html;
|
|
319
|
+
}
|
|
320
|
+
iframe.addEventListener("load", () => { iframe.classList.add("ready"); if (showsLive(f) && img) img.style.visibility = "hidden"; });
|
|
321
|
+
}
|
|
322
|
+
|
|
297
323
|
// layout: frames at their canvas positions
|
|
298
324
|
const frames = manifest.frames;
|
|
299
325
|
const minX = Math.min(...frames.map((f) => f.x)), minY = Math.min(...frames.map((f) => f.y));
|
|
@@ -304,9 +330,8 @@ button:focus-visible { outline: 2px solid #3b82f6; outline-offset: 1px; }
|
|
|
304
330
|
el.className = "frame";
|
|
305
331
|
el.style.cssText = "left:" + (f.x - minX) + "px;top:" + (f.y - minY) + "px;width:" + f.width + "px;height:" + f.height + "px";
|
|
306
332
|
el.innerHTML = '<div class="frame-label"><b>' + esc(f.name) + "</b>" + f.width + " \xD7 " + Math.round(f.height) + (manifest.live ? '<button class="live-btn" title="Open the live site at this width"><svg width="11" height="11" viewBox="0 0 24 24" fill="currentColor"><path d="M7 4.5v15l13-7.5z"/></svg>View live</button>' : "") + "</div>" +
|
|
307
|
-
'<div class="frame-box" style="width:' + f.width + "px;height:" + f.height + 'px"><img alt="" src="' + esc(f.image) + '"><iframe
|
|
308
|
-
|
|
309
|
-
iframe.addEventListener("load", () => iframe.classList.add("ready"));
|
|
333
|
+
'<div class="frame-box" style="width:' + f.width + "px;height:" + f.height + 'px"><img alt="" src="' + esc(f.image) + '"><iframe title="' + esc(f.name) + '" scrolling="no" loading="lazy"></iframe></div>';
|
|
334
|
+
restFrame(f, el.querySelector("iframe"), el.querySelector("img"));
|
|
310
335
|
const liveBtn = el.querySelector(".live-btn");
|
|
311
336
|
if (liveBtn) liveBtn.onclick = (e) => { e.stopPropagation(); openLive(f); };
|
|
312
337
|
el.dataset.name = f.name;
|
|
@@ -465,7 +490,7 @@ button:focus-visible { outline: 2px solid #3b82f6; outline-offset: 1px; }
|
|
|
465
490
|
iframe.title = "Live site: " + f.name;
|
|
466
491
|
iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox");
|
|
467
492
|
iframe.setAttribute("referrerpolicy", "no-referrer");
|
|
468
|
-
iframe.src = manifest.live.url;
|
|
493
|
+
iframe.src = f.route ? liveSrc(f.route) : manifest.live.url;
|
|
469
494
|
liveDevice.appendChild(iframe);
|
|
470
495
|
document.getElementById("live-name").textContent = f.name;
|
|
471
496
|
document.getElementById("live-tab").href = manifest.live.url;
|
|
@@ -819,13 +844,12 @@ button:focus-visible { outline: 2px solid #3b82f6; outline-offset: 1px; }
|
|
|
819
844
|
next.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
|
|
820
845
|
next.setAttribute("referrerpolicy", "no-referrer");
|
|
821
846
|
next.src = sessionFrame(f);
|
|
847
|
+
next.addEventListener("load", () => { next.classList.add("ready"); if (img) img.style.visibility = "hidden"; });
|
|
822
848
|
} else {
|
|
823
|
-
next.setAttribute("sandbox", "");
|
|
824
849
|
next.loading = "lazy";
|
|
825
|
-
next.src = f.html;
|
|
826
850
|
if (img) img.style.visibility = "";
|
|
851
|
+
restFrame(f, next, img);
|
|
827
852
|
}
|
|
828
|
-
next.addEventListener("load", () => { next.classList.add("ready"); if (on && img) img.style.visibility = "hidden"; });
|
|
829
853
|
old.replaceWith(next);
|
|
830
854
|
}
|
|
831
855
|
renderRoom();
|
package/dist/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
readPackage,
|
|
15
15
|
runScript,
|
|
16
16
|
startHub
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-FJO64PGM.js";
|
|
18
18
|
import {
|
|
19
19
|
CHUNK,
|
|
20
20
|
decodeFrame,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
responseHeaders,
|
|
23
23
|
safePath,
|
|
24
24
|
viewerHtml
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-S5P2CHHZ.js";
|
|
26
26
|
import {
|
|
27
27
|
DEVICES,
|
|
28
28
|
Workspace,
|
|
@@ -39,12 +39,13 @@ import {
|
|
|
39
39
|
outlineDoc,
|
|
40
40
|
readDesignTokens,
|
|
41
41
|
readTokenData,
|
|
42
|
+
routeOf,
|
|
42
43
|
shadcnAdd,
|
|
43
44
|
shadcnRegistry,
|
|
44
45
|
shadcnStatus,
|
|
45
46
|
syncComponentRegistry,
|
|
46
47
|
writeCompare
|
|
47
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-PLJRUWCS.js";
|
|
48
49
|
import {
|
|
49
50
|
EditError,
|
|
50
51
|
addArgs,
|
|
@@ -144,7 +145,8 @@ async function createSnapshot(ws, shots, canvas, opts = {}) {
|
|
|
144
145
|
used.add(slug);
|
|
145
146
|
fs.writeFileSync(path.join(dir, "frames", `${slug}.html`), await freeze(raw, assets));
|
|
146
147
|
fs.writeFileSync(path.join(dir, "frames", `${slug}.png`), raw.png);
|
|
147
|
-
|
|
148
|
+
const route = f.page && ws.config.framework === "next" ? routeOf(ws.config, f.page) : void 0;
|
|
149
|
+
out.push({ name: f.frameName, x: f.x, y: f.y, width: raw.width, height: f.height ?? raw.height, theme: f.theme, device: f.device, html: `frames/${slug}.html`, image: `frames/${slug}.png`, ...route ? { route } : {} });
|
|
148
150
|
}
|
|
149
151
|
const manifest = {
|
|
150
152
|
format: 1,
|