Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
One-time setup that gathers your project's design context and saves it to CLAUDE.md for future sessions.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/live/browser-script-parts.mjs
1import fs from 'node:fs';2import path from 'node:path';34export const LIVE_BROWSER_SCRIPT_PARTS = Object.freeze([5Object.freeze({ name: 'session-state', file: 'live-browser-session.js' }),6Object.freeze({ name: 'dom-helpers', file: 'live-browser-dom.js' }),7Object.freeze({ name: 'browser-ui', file: 'live-browser.js' }),8]);910export function resolveLiveBrowserScriptParts(scriptsDir, parts = LIVE_BROWSER_SCRIPT_PARTS) {11if (!scriptsDir) throw new Error('scriptsDir is required');12return parts.map((part, index) => ({13...part,14index,15path: path.join(scriptsDir, part.file),16}));17}1819export function assertLiveBrowserScriptParts(parts, exists = fs.existsSync) {20for (const part of parts) {21if (!exists(part.path)) {22throw new Error(`Live browser script part missing: ${part.name} (${part.path})`);23}24}25return parts;26}2728export function readLiveBrowserScriptParts(parts, readFile = (filePath) => fs.readFileSync(filePath, 'utf-8')) {29return parts.map((part) => ({30...part,31source: readFile(part.path),32}));33}3435export function assembleLiveBrowserScript({ token, port, vocabulary, parts }) {36const prelude =37`window.__IMPECCABLE_TOKEN__ = '${token}';\n` +38`window.__IMPECCABLE_PORT__ = ${port};\n` +39// Canonical command vocabulary (values + labels + icons). live-browser.js40// builds its action picker from this instead of an inline copy.41`window.__IMPECCABLE_VOCAB__ = ${JSON.stringify(vocabulary)};\n`;4243const body = parts.map((part) => {44const file = part.file || path.basename(part.path || '');45return `// --- impeccable live script part: ${part.name} (${file}) ---\n${part.source}`;46}).join('\n');4748return prelude + body;49}50