DSH-Arch-Setup/plugins/dsh-fullwidth/lib/client.js
Шурупов Илья Викторович cf9443753e Add one-command Arch DSH setup
Package the portable DSH profiles, local plugins, desktop integration, Firefox wrapper, and ownership-aware installer lifecycle. Bundle checksum-pinned OpenVSCode, editor extensions, translation assets, and cloudflared so unreliable upstream artifact downloads cannot break a clean installation.
2026-09-12 19:13:36 +03:00

72 lines
2.7 KiB
JavaScript

/**
* dsh-fullwidth — browser half.
*
* The whole chat column width is driven by one CSS custom property,
* `--dsh-chat-content-width`, defined as a hardcoded `748px` on the
* ConversationRoot element. The composer/input width derives from it
* (`--dsh-composer-card-max-width: calc(var(--dsh-chat-content-width) + 32px)`),
* as do the user bubbles. So overriding that single variable widens the
* transcript AND the input box together.
*
* We can't target the ConversationRoot class directly — it is content-hashed
* and changes between builds — so we set the variable on every element with
* `!important`. `!important` beats the app's normal declaration regardless of
* selector specificity, so the override wins on the root element too, and the
* value inherits/derives everywhere it is consumed.
*
* Rebind the width by editing CONTENT_WIDTH below.
* @module dsh-fullwidth/client
*/
window.__ModuleLoader__.load({
id: "dsh-fullwidth",
factory: (require) => {
var module = { exports: {} };
var exports = module.exports;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
// ---- CONFIG (edit here) -----------------------------------------------
// Width of the chat transcript + composer. Percentages fill the pane and
// leave symmetric gutters; use a px value or min()/clamp() to cap it on
// very wide monitors. Examples:
// "100%" — edge to edge, no gutter
// "96%" — full width, tiny gutter
// "min(1600px, 94%)" — full width but never wider than 1600px
// "clamp(748px, 92%, 1800px)"— original min, grow to 92%, cap at 1800px
const CONTENT_WIDTH = "min(1600px, 94%)";
// -----------------------------------------------------------------------
const STYLE_ID = "dsh-fullwidth-style";
const cssText = "*{--dsh-chat-content-width:" + CONTENT_WIDTH + " !important;}";
/** Insert (or update) the override <style>, returning a cleanup fn. */
function install() {
let el = document.getElementById(STYLE_ID);
if (!el) {
el = document.createElement("style");
el.id = STYLE_ID;
(document.head || document.documentElement).appendChild(el);
}
el.textContent = cssText;
return () => {
const node = document.getElementById(STYLE_ID);
if (node) node.remove();
};
}
/** No client services required — this is pure CSS. */
const inject = [];
/** Client plugin body: inject the width override (with HMR-safe cleanup). */
function apply(ctx) {
if (ctx && typeof ctx.effect === "function") {
ctx.effect(install, "dsh-fullwidth: chat content-width override");
} else {
install();
}
}
exports.apply = apply;
exports.inject = inject;
return module.exports;
},
});