Preserve accumulated client implementation since v0.1.4, including local identities, multi-server state, chat, administration, audio and streaming controls. Refine official-source layout, original artwork, responsive composer overflow, settings navigation and chat scroll anchoring. Current verification: Node suite passes; isolated packaged chat and responsive control smokes pass without device capture. Native core is reused, not rebuilt in this pass. Strict whole-screen visual parity remains incomplete; no 1:1 or cross-platform acceptance claim. Local checkpoint only; no release or push.
142 lines
15 KiB
JavaScript
142 lines
15 KiB
JavaScript
// RECONSTRUCTED official TeamSpeak 6 reference template for QA (never product code).
|
|
// DOM chains follow the official compiled Vue render functions in the installed main.js
|
|
// (offsets below, sha256 9d6bea2e…); styling is the installed official CSS supplied by
|
|
// official-ts6-reference.mjs at run time. Icons are size-only placeholders; text comes from the
|
|
// installed official locale files where a key is known, otherwise from the shared fixture.
|
|
// Anything marked INFERENCE was not proven from a render function.
|
|
import { readFileSync } from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
// Shared synthetic data rendered by BOTH TeamsPeach (through its real event/IPC paths) and the template.
|
|
export const FIXTURE = Object.freeze({
|
|
server: 'Parity fixture / Сверка',
|
|
channel: 'cs',
|
|
otherChannel: 'Games / Игры',
|
|
self: 'ParityFixture',
|
|
mira: 'Mira / Мира',
|
|
oleg: 'Oleg / Олег',
|
|
// [official locale key, variables] — sentences are produced from the official locale template for both sides.
|
|
events: [
|
|
['channel.chat.events.client.moved.into.by_invoker', { victim: 'Mira / Мира', invoker: 'Oleg / Олег', channel: 'Games / Игры' }],
|
|
['channel.chat.events.client.joined.from_channel', { invoker: 'Oleg / Олег', channel: 'Games / Игры' }],
|
|
['server.log.events.client.timeout', { invoker: 'Oleg / Олег' }],
|
|
['channel.chat.events.client.joined.from_channel', { invoker: 'Mira / Мира', channel: 'Games / Игры' }],
|
|
],
|
|
// Client context menu of the official client for another client (order from the user's reference capture).
|
|
menu: [
|
|
{ kind: 'title', text: 'Oleg / Олег' },
|
|
{ key: 'client.action.poke.title' },
|
|
{ key: 'client.menu.change_volume', submenu: true },
|
|
{ key: 'client.connection_info.title', submenu: true },
|
|
{ kind: 'caption', key: 'universal.permissions', fallback: { en: 'Permissions', ru: 'Разрешения' } },
|
|
{ key: 'server.snapshots.preview.server_groups', submenu: true },
|
|
{ key: 'server.snapshots.result.error_type.channel_group', submenu: true },
|
|
{ key: 'universal.client_permissions' },
|
|
{ key: 'universal.channel_client_permissions' },
|
|
{ kind: 'caption', key: 'settings.whisper.whispering' },
|
|
{ key: 'settings.whisper.add_to_list', submenu: true },
|
|
{ kind: 'caption', key: 'universal.moderation' },
|
|
{ key: 'client.action.kick.channel.title', destructive: true },
|
|
{ key: 'client.action.kick.server.title', destructive: true },
|
|
{ key: 'client.action.ban.title', destructive: true },
|
|
],
|
|
// Official toolbar order (const ve @3517745 in main.js): label keys only where the locale has them.
|
|
toolbar: ['bold', 'italic', 'strike', 'underline', 'link', 'quote', 'codeblock', 'lists', 'spoiler', 'heading', 'others'],
|
|
});
|
|
|
|
export function officialLocale(dir, language) {
|
|
const flat = {}, walk = (node, prefix) => { for (const [k, v] of Object.entries(node)) typeof v === 'object' ? walk(v, `${prefix}${k}.`) : (flat[`${prefix}${k}`] = v); };
|
|
walk(JSON.parse(readFileSync(path.join(dir, 'locales', `${language}.json`), 'utf8')), '');
|
|
const t = (key, vars = {}) => flat[key] === undefined ? undefined : String(flat[key]).split(' | ')[0].replace(/\{(\w+)\}/g, (_m, name) => vars[name] ?? `{${name}}`);
|
|
return { t, has: key => key in flat };
|
|
}
|
|
|
|
export const eventSentence = (locale, [key, vars]) => locale.t(key, vars);
|
|
const escape = text => String(text).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c]);
|
|
// Official i18n slots render names as <strong> (system-compact component, main.js @~3306915).
|
|
const strongSentence = (locale, [key, vars]) => escape(locale.t(key, Object.fromEntries(Object.keys(vars).map(name => [name, `\u0000${name}\u0000`]))))
|
|
.replace(/\u0000(\w+)\u0000/g, (_m, name) => `<strong data-v-5c102790>${escape(vars[name])}</strong>`);
|
|
const icon = extra => `<div class="tsv-icon tsv-icon-primary ${extra ?? ''}" data-qa-icon="placeholder"></div>`;
|
|
|
|
export const officialTime = (date, language) => `${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')} - ${new Intl.DateTimeFormat(language, { weekday: 'short' }).format(date).replace('.', '')}`;
|
|
|
|
/**
|
|
* @param {{ stylesheets: string[], locale: ReturnType<typeof officialLocale>, language: 'en'|'ru', widths: { detail: number, tree: number, tile: number, tileHeight: number }, time: Date }} o
|
|
*/
|
|
export function referenceHtml({ stylesheets, locale, language, widths, time }) {
|
|
const label = item => item.text ?? locale.t(item.key) ?? item.fallback?.[language] ?? item.key;
|
|
const menuItem = item => item.kind === 'caption'
|
|
? `<p class="ts-style-caption" data-qa="menu-caption">${escape(label(item))}</p>`
|
|
: `<li class="tsv-item${item.destructive ? ' tsv-is-destructive' : ''}${item.kind === 'title' ? ' tsv-is-disabled' : ''}" data-qa="${item.kind === 'title' ? 'menu-title' : item.destructive ? 'menu-item menu-destructive' : 'menu-item'}">`
|
|
+ `<div class="tsv-item-container${item.kind === 'title' ? '' : ' tsv-action'}"><div class="tsv-item-content"><div class="icon-container">${icon()}</div>`
|
|
+ `<div class="tsv-item-text tsv-flex-grow"><div class="tsv-text-truncate" data-qa="menu-label">${escape(label(item))}</div></div></div></div>`
|
|
// Submenu chevron: ts-tool-menu accessoryButton → ts-button (render @3109151: div.tsv-button.tsv-button-plain.tsv-button-has-image > ts-icon-stack).
|
|
+ `${item.submenu ? `<div class="tsv-item-accessory"><div class="tsv-button tsv-tool-menu-accessory tsv-button-plain tsv-button-has-image"><div class="tsv-icon tsv-icon-stack" data-qa-icon="placeholder"></div></div></div>` : ''}<div class="tsv-item-highlight"></div></li>`;
|
|
// ts-tool-menu render (module 12898, main.js @3872578): buttons, then sections with p.ts-style-caption.
|
|
const sections = []; let current = { items: [] }; const head = [];
|
|
for (const item of FIXTURE.menu) {
|
|
if (item.kind === 'caption') { sections.push(current); current = { caption: item, items: [] }; }
|
|
else (current.caption ? current.items : head).push(item);
|
|
}
|
|
sections.push(current);
|
|
const menu = head.map(menuItem).join('') + sections.filter(s => s.caption).map(s => `<div class="ts-tool-section">${menuItem(s.caption)}${s.items.map(menuItem).join('')}</div>`).join('');
|
|
const toolbar = FIXTURE.toolbar.map(name => `<div class="tsv-button ts-chat-input-edit-toolbar-button${['lists', 'spoiler', 'heading', 'others'].includes(name) ? ' is-group' : ''}" data-qa="toolbar-button" data-name="${name}">${icon('tsv-icon-small')}${name === 'others' ? `<span>${escape(locale.t('chat.input.toolbar.group.others'))}</span>` : ''}${['lists', 'spoiler', 'heading', 'others'].includes(name) ? icon('ts-chat-input-edit-toolbar-button-expander') : ''}</div>`).join('');
|
|
// ts-chat-room-event-system-compact render (main.js @3305157, scope 5c102790 on every template element);
|
|
// channel chat passes inline-timestamp-only (time after the contents). INFERENCE: slim layout.
|
|
const events = FIXTURE.events.map(event => `<div class="ts-chat-room-event-detailed is-system slim" data-v-5c102790 data-qa="event-row">`
|
|
+ `<div class="ts-chat-message-system-body compact slim-layout" data-v-5c102790 data-qa="event-body"><div class="ts-chat-message-system-body-icon" data-v-5c102790></div>`
|
|
+ `<div class="ts-chat-message-system-body-contents ts-chat-message-system-body-contents-spaced" data-v-5c102790><span class="ts-font-small" data-v-5c102790 data-qa="event-text">${strongSentence(locale, event)}</span></div>`
|
|
+ `<span class="ts-font-minimal ts-style-caption ts-chat-message-system-time" data-v-5c102790 data-qa="event-time">${escape(officialTime(time, language))}</span></div></div>`).join('');
|
|
const channelRow = name => `<div class="qa-virtual-row" data-qa="tree-channel-row" style="height:var(--ts-tree-channel-height-default)"><div class="ts-server-tree-item-leaf channel" data-v-495a5258 data-qa="tree-channel"><div class="ts-server-tree-item-node"><div class="ts-server-tree-item-node-content channel ts-server-tree-item-key-without-chevron">${icon('tsv-server-tree-icon channel')}<span class="ts-server-tree-channel-info tsv-tree-preserve-spaces" data-qa="tree-channel-name"><span>${escape(name)}</span></span></div></div><div class="tsv-item-highlight"></div></div></div>`;
|
|
// INFERENCE: default (non-compact) client rows; virtual list wrapper heights are the official tokens.
|
|
const clientRow = name => `<div class="qa-virtual-row" data-qa="tree-client-row" style="height:var(--ts-tree-client-height-default)"><div class="ts-server-tree-item-leaf client tsv-animated-icon-on-hover" data-v-65202ae9 data-qa="tree-client"><div class="ts-server-tree-item-key ts-server-tree-item-key-without-chevron ts-server-tree-item-node-content client">${icon('tsv-server-tree-icon client normal')}<div class="ts-server-tree-client-info compact"><div class="ts-server-tree-client-info__name-row"><div class="tsv-flex-column ts-server-tree-client-info__name"><span class="ts-server-tree-item-text ts-client-nick tsv-text-truncate" data-qa="tree-client-name"><div class="ts-server-tree-item-text-wrapper tsv-text-truncate"><span class="tsv-tree-preserve-spaces">${escape(name)}</span></div></span></div></div></div></div></div></div>`;
|
|
return `<!doctype html><html lang="${language}"><head><meta charset="utf-8"><title>Reconstructed official TS6 reference (QA only)</title>
|
|
${stylesheets.map((css, index) => `<style data-layer="${index}">${css.replace(/<\/style/gi, '<\\/style')}</style>`).join('\n')}
|
|
<style data-layer="qa-layout">/* QA placement only — not an official rule. */
|
|
html,body{margin:0;background:var(--tsv-bg);} .qa-region{position:absolute;left:0;overflow:hidden;contain:layout paint}
|
|
.qa-video{width:100%;height:100%;background:linear-gradient(135deg,#25495a,#7f9aa8)}</style></head>
|
|
<body><div id="app">
|
|
<!-- Channel/detail header: ContentView render @2975904; SegmentedControl @3245057 (INFERENCE: info/chat/files are segments). -->
|
|
<section class="qa-region tsv-activity-detail tsv-activity-secondary" data-qa-region="header" style="top:0;width:${widths.detail}px">
|
|
<div class="tsv-view"><div class="tsv-header"><div class="tsv-bar tsv-content-header-bar" data-qa="header-bar">
|
|
<div class="tsv-bar-item tsv-flex-grow left tsv-no-padding"><ul class="tsv-flex-grow"><li class="tsv-item tsv-no-padding tsv-content-header-item tsv-show-animated-icon"><div class="tsv-item-container"><div class="tsv-item-content">${icon('tsv-icon-xlarge')}<div class="tsv-item-text tsv-flex-grow"><div class="tsv-text-truncate" data-qa="header-title">${escape(FIXTURE.channel)}</div></div></div></div></li></ul></div>
|
|
<div class="tsv-bar-item tsv-flex-fixed"><div class="tsv-segmented-control" data-qa="header-segments">${[0, 1, 2].map(() => `<div class="tsv-segmented-button tsv-action">${icon()}</div>`).join('')}</div></div>
|
|
</div></div><div class="ts-horizontal-separator" data-qa="header-separator"></div></div>
|
|
</section>
|
|
<!-- Screenshare tile: TSScreenshareStream render @4070145 (scope 6eee7636) inside ts-screenshare (scope 2e9fbf5f). -->
|
|
<!-- Detail-pane body: ContentView div.tsv-view > div.tsv-body.tsv-flex.tsv-body-background (secondary activity → shaded fill). -->
|
|
<section class="qa-region tsv-activity-detail tsv-activity-secondary" data-qa-region="stage" style="top:140px;width:${widths.tile + 40}px;height:${widths.tileHeight + 40}px">
|
|
<div class="tsv-view"><div class="tsv-body tsv-flex tsv-body-background" style="height:${widths.tileHeight + 40}px">
|
|
<div class="video-stream tsv-flex-center" data-v-6eee7636 data-v-2e9fbf5f data-qa="stage-tile" style="width:${widths.tile}px;height:${widths.tileHeight}px;margin:20px">
|
|
<div class="video qa-video" data-v-6eee7636></div>
|
|
<div class="always-visible-overlay" data-v-6eee7636><div class="tsv-flex" data-v-6eee7636><span class="always-visible-overlay__name tsv-text-truncate tsv-flex-shrink tsv-font-subtitle" data-v-6eee7636 data-qa="stage-name">${escape(FIXTURE.mira)}</span></div></div>
|
|
</div>
|
|
</div></div>
|
|
</section>
|
|
<!-- Chat system rows: ts-chat-room-event-system-compact render @3305157 (scope 5c102790). -->
|
|
<section class="qa-region tsv-activity-detail tsv-activity-secondary" data-qa-region="events" style="top:${widths.tileHeight + 200}px;width:${widths.detail}px">
|
|
<div class="tsv-view"><div class="tsv-body tsv-body-background"><div class="qa-events">${events}</div></div></div>
|
|
</section>
|
|
<!-- Chat input: chat-input render @3561667; toolbar order @3517745. TSButton root element is INFERENCE (div.tsv-button). -->
|
|
<section class="qa-region tsv-activity-detail tsv-activity-secondary" data-qa-region="composer" style="top:${widths.tileHeight + 360}px;width:${widths.detail}px;height:130px">
|
|
<div class="tsv-view"><div class="tsv-body tsv-body-background" style="height:130px;position:relative">
|
|
<div class="ts-chat-input-container" data-qa="composer"><div class="ts-chat-input-container-content">
|
|
<div class="ts-chat-input-edit-toolbar" data-qa="toolbar">${toolbar}</div>
|
|
<div class="ts-chat-input-container-content-inner"><div class="ts-chat-input" data-qa="composer-input"><div class="ts-chat-input-textarea-inner"><div class="ts-textarea-inner-editor"></div></div></div>
|
|
<div class="ts-chat-input-container-actions">${['ts-chat-emoji-button tsv-action-subtle', 'ts-chat-image-button tsv-action-subtle', 'ts-chat-send-button'].map(c => `<div class="tsv-button ${c}" data-qa="composer-action">${icon()}</div>`).join('')}</div></div>
|
|
</div></div>
|
|
</div></div>
|
|
</section>
|
|
<!-- Client context menu: wrapper module 25637 @520089, ts-tool-menu @3872578, ts-list-simple-cell @3222136. -->
|
|
<!-- Tree popup runtime modifiers set outer maxWidth=260px: main.js @1657900, popup Push applies style @1533700; local://official-popup-width-trace.json. -->
|
|
<!-- INFERENCE: menu floats over the detail-pane body (shaded fill) as in the reference capture. -->
|
|
<section class="qa-region tsv-activity-detail tsv-activity-secondary" data-qa-region="menu" style="top:${widths.tileHeight + 520}px;width:360px;height:520px"><div class="tsv-body-background" style="position:absolute;inset:0">
|
|
<div class="ts-context-menu active" data-qa="menu" style="position:absolute;left:20px;top:20px;max-width:260px"><div class="tsv-tool-menu tsv-list tsv-list-compact tsv-no-padding">${menu}</div></div></div>
|
|
</section>
|
|
<!-- Server tree rows: ts-server-tree-item-channel @4119733, ts-server-tree-item-client @4140768. -->
|
|
<section class="qa-region tsv-activity-main tsv-activity-primary main-pane-layout" data-qa-region="tree" style="top:${widths.tileHeight + 1060}px;width:${widths.tree}px;background:var(--tsv-servertree-bg-gradient)">
|
|
${channelRow(FIXTURE.channel)}${clientRow(FIXTURE.self)}${clientRow(FIXTURE.mira)}${channelRow(FIXTURE.otherChannel)}${clientRow(FIXTURE.oleg)}
|
|
</section>
|
|
</div></body></html>`;
|
|
}
|