@panomc/theme-core 1.0.0-dev.51 → 1.0.0-dev.53
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": "@panomc/theme-core",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.53",
|
|
4
4
|
"description": "The Pano theme engine: hooks factories, plugin engine, headless page controllers, default views and the theme CLI. Themes depend on this package instead of forking vanilla-theme.",
|
|
5
5
|
"author": "PanoMC",
|
|
6
6
|
"license": "MIT",
|
package/src/lib/api.util.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// `export { default } from` (not `import` + `export default Default`) because this
|
|
2
|
+
// shim sits inside an import cycle: kit/hooks-server.js → lib/services/auth.js → here
|
|
3
|
+
// → @panomc/sdk/core/js/api.util → $lib/Store.js → (a consumer's own api.util shim).
|
|
4
|
+
// `export default <identifier>` is an expression evaluated once while this module's
|
|
5
|
+
// body runs, not a live binding, so under a different entry order it would snapshot an
|
|
6
|
+
// uninitialized binding and publish `undefined` forever. A re-export is an indirect
|
|
7
|
+
// binding resolved at link time and read on access, so it survives the cycle. This is
|
|
8
|
+
// also the form bin/sync.js generates into themes.
|
|
3
9
|
export * from "@panomc/sdk/core/js/api.util";
|
|
4
|
-
|
|
5
|
-
export default Default;
|
|
10
|
+
export { default } from "@panomc/sdk/core/js/api.util";
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
class="list-group list-group-flush text-center bg-transparent position-relative z-1">
|
|
23
23
|
<li class="list-group-item border-0 py-2 bg-transparent">
|
|
24
24
|
<button
|
|
25
|
-
class="btn btn-link {playCardIpColor} border-0 shadow-none text-decoration-none w-100 focus-ring
|
|
25
|
+
class="btn btn-link {playCardIpColor} border-0 shadow-none text-decoration-none w-100 focus-ring play-card-ip"
|
|
26
|
+
style="--ip-len: {playCardIpLength}; --ip-max: 28px;"
|
|
26
27
|
type="button"
|
|
27
28
|
on:click={onCopyCommandTextClick}
|
|
28
29
|
use:tooltip={[
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
: $_("sidebars.home.copy"),
|
|
32
33
|
{ placement: "top", hideOnClick: false },
|
|
33
34
|
]}>
|
|
34
|
-
<b class="d-block
|
|
35
|
+
<b class="d-block" bind:this={ipEl}>{playCardIpText}</b>
|
|
35
36
|
</button>
|
|
36
37
|
</li>
|
|
37
38
|
{#if showPlayCardStatusBadge}
|
|
@@ -69,7 +70,8 @@
|
|
|
69
70
|
<div
|
|
70
71
|
class="card-header {playCardHeaderClass} p-0 rounded-top border-bottom border-5 {playCardBorderColor}">
|
|
71
72
|
<button
|
|
72
|
-
class="btn btn-{playCardBtnColor} border-0 shadow-none text-decoration-none w-100 focus-ring
|
|
73
|
+
class="btn btn-{playCardBtnColor} border-0 shadow-none text-decoration-none w-100 focus-ring py-2 play-card-ip"
|
|
74
|
+
style="--ip-len: {playCardIpLength}; --ip-max: 24px;"
|
|
73
75
|
type="button"
|
|
74
76
|
on:click={onCopyCommandTextClick}
|
|
75
77
|
use:tooltip={[
|
|
@@ -78,7 +80,7 @@
|
|
|
78
80
|
: $_("sidebars.home.copy"),
|
|
79
81
|
{ placement: "top", hideOnClick: false },
|
|
80
82
|
]}>
|
|
81
|
-
<b class="d-block
|
|
83
|
+
<b class="d-block" bind:this={ipEl}>{playCardIpText}</b>
|
|
82
84
|
</button>
|
|
83
85
|
</div>
|
|
84
86
|
<div
|
|
@@ -214,7 +216,7 @@
|
|
|
214
216
|
</script>
|
|
215
217
|
|
|
216
218
|
<script>
|
|
217
|
-
import { getContext } from "svelte";
|
|
219
|
+
import { getContext, onMount } from "svelte";
|
|
218
220
|
import { _ } from "svelte-i18n";
|
|
219
221
|
import copy from "copy-to-clipboard";
|
|
220
222
|
import tooltip from "$pano/lib/tooltip.util";
|
|
@@ -310,12 +312,96 @@
|
|
|
310
312
|
: themeSettings.playCardBorderColor;
|
|
311
313
|
|
|
312
314
|
$: playCardIpText = themeSettings.playCardIpText || $data.ipAddress;
|
|
315
|
+
// Feeds the no-JS estimate in the stylesheet; 1 keeps that division safe
|
|
316
|
+
// before the address has loaded.
|
|
317
|
+
$: playCardIpLength = String(playCardIpText || "").length || 1;
|
|
318
|
+
|
|
313
319
|
$: showPlayCardStatusBadge = themeSettings.playCardStatusBadge ?? true;
|
|
314
320
|
$: showPlayCardPlayerCount = themeSettings.playCardPlayerCount ?? true;
|
|
315
321
|
$: showPlayCardVersionInfo = themeSettings.playCardVersionInfo ?? true;
|
|
322
|
+
|
|
323
|
+
/* Address fit — see the stylesheet for why the CSS alone is not enough.
|
|
324
|
+
Measuring beats guessing at per-character width: reset to the maximum,
|
|
325
|
+
compare what the text wants against what the button gives it, and scale by
|
|
326
|
+
that ratio. Runs on mount, whenever the address changes, once webfonts have
|
|
327
|
+
settled (metrics shift under the fallback face), and on resize. */
|
|
328
|
+
const IP_MIN_PX = 13.6; // 0.85rem — matches the clamp floor
|
|
329
|
+
|
|
330
|
+
let ipEl;
|
|
331
|
+
|
|
332
|
+
function fitIpText() {
|
|
333
|
+
const el = ipEl;
|
|
334
|
+
if (!el) return;
|
|
335
|
+
|
|
336
|
+
const max = parseFloat(getComputedStyle(el).getPropertyValue("--ip-max")) || 28;
|
|
337
|
+
|
|
338
|
+
el.style.whiteSpace = "";
|
|
339
|
+
el.style.fontSize = `${max}px`;
|
|
340
|
+
|
|
341
|
+
const available = el.clientWidth;
|
|
342
|
+
if (!available) return;
|
|
343
|
+
|
|
344
|
+
// Two passes: scaling by the first ratio overshoots slightly because
|
|
345
|
+
// letter-spacing does not scale with the font, so re-measure and correct.
|
|
346
|
+
let size = max;
|
|
347
|
+
for (let pass = 0; pass < 2 && el.scrollWidth > available; pass++) {
|
|
348
|
+
size = Math.max(IP_MIN_PX, (size * available) / el.scrollWidth);
|
|
349
|
+
el.style.fontSize = `${size}px`;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// An address long enough to hit the legibility floor wraps onto a second
|
|
353
|
+
// line — still the whole address, which cutting it off would not be.
|
|
354
|
+
el.style.whiteSpace = el.scrollWidth > available ? "normal" : "";
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// Re-fit when the address changes; ipEl is undefined until mounted and on the
|
|
358
|
+
// server, so this is a no-op there.
|
|
359
|
+
$: playCardIpText, ipEl && fitIpText();
|
|
360
|
+
|
|
361
|
+
onMount(() => {
|
|
362
|
+
fitIpText();
|
|
363
|
+
|
|
364
|
+
const observer = new ResizeObserver(fitIpText);
|
|
365
|
+
if (ipEl?.parentElement) observer.observe(ipEl.parentElement);
|
|
366
|
+
|
|
367
|
+
document.fonts?.ready.then(fitIpText).catch(() => {});
|
|
368
|
+
|
|
369
|
+
return () => observer.disconnect();
|
|
370
|
+
});
|
|
316
371
|
</script>
|
|
317
372
|
|
|
318
373
|
<style>
|
|
374
|
+
/* The server address is site-supplied and routinely longer than a stock
|
|
375
|
+
"play.example.com", so the old fixed .fs-3 overflowed the card and got cut
|
|
376
|
+
off by .text-truncate — an ellipsised address is worse than useless, since
|
|
377
|
+
the whole point of the card is that you can read and copy it. It now
|
|
378
|
+
shrinks to fit instead.
|
|
379
|
+
|
|
380
|
+
This rule is the server-rendered / no-JS baseline: the button is a size
|
|
381
|
+
container, so 100cqi is exactly the width the address has to live in, and
|
|
382
|
+
0.72em is a deliberately pessimistic per-character advance — themes ship
|
|
383
|
+
very different faces (a wide serif costs far more per character than a
|
|
384
|
+
narrow sans), so this errs small rather than risk clipping. fitIpText()
|
|
385
|
+
then measures the real text on mount and hands back whatever headroom the
|
|
386
|
+
estimate gave away, which is why --ip-max is in px: it is read from here. */
|
|
387
|
+
.play-card-ip {
|
|
388
|
+
container-type: inline-size;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.play-card-ip b {
|
|
392
|
+
font-size: clamp(
|
|
393
|
+
0.85rem,
|
|
394
|
+
calc(100cqi / (var(--ip-len, 16) * 0.72)),
|
|
395
|
+
var(--ip-max, 28px)
|
|
396
|
+
);
|
|
397
|
+
line-height: 1.25;
|
|
398
|
+
white-space: nowrap;
|
|
399
|
+
overflow: hidden;
|
|
400
|
+
/* inert while nowrap holds; it only matters once fitIpText() lets an
|
|
401
|
+
over-long address wrap, and an address has no spaces to break at. */
|
|
402
|
+
overflow-wrap: anywhere;
|
|
403
|
+
}
|
|
404
|
+
|
|
319
405
|
@media (min-width: 992px) {
|
|
320
406
|
.square-card-desktop {
|
|
321
407
|
aspect-ratio: 1 / 1;
|
package/src/lib/csrf.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
// Re-export rather than `import` + `export default Default` — see api.util.js: the
|
|
2
|
+
// snapshot form publishes `undefined` if the SDK module is still in-flight because of
|
|
3
|
+
// an import cycle.
|
|
3
4
|
export * from "@panomc/sdk/core/js/csrf.js";
|
|
4
|
-
|
|
5
|
-
export default Default;
|
|
5
|
+
export { default } from "@panomc/sdk/core/js/csrf.js";
|
package/src/lib/tooltip.util.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
// Re-export rather than `import` + `export default Default` — see api.util.js: the
|
|
2
|
+
// snapshot form publishes `undefined` if the SDK module is still in-flight because of
|
|
3
|
+
// an import cycle.
|
|
3
4
|
export * from "@panomc/sdk/core/js/tooltip.util";
|
|
4
|
-
|
|
5
|
-
export default Default;
|
|
5
|
+
export { default } from "@panomc/sdk/core/js/tooltip.util";
|