// shared/icons.js — minimal outline SVG sprite for ZDDC tools. // // Vendored from Lucide (https://lucide.dev, ISC). Only the 16 // file-type glyphs the browse tree maps to are bundled; total weight // is ~4.5 KB of SVG path data. Each symbol viewBox is 0 0 24 24 with // no stroke/fill attributes — those are applied at the call site via // CSS so the icons inherit `currentColor` and tint with the theme. // // API: // window.zddc.icons.inject() // mount sprite into once // window.zddc.icons.html('icon-foo') // → '' // window.zddc.icons.ID // string set of valid symbol ids // // Callers concat html() output into innerHTML the same way they // previously concat'd emoji glyphs. The injected sprite is hidden // (`display:none` on the outer ) so it costs zero layout. // // Why a sprite (rather than per-row inline paths): a hundred tree // rows × 300 bytes of duplicated path data is 30 KB of churn on // every re-render. With , each row carries only a ~60-byte // reference. The sprite is parsed once. (function () { 'use strict'; if (!window.zddc) window.zddc = {}; if (window.zddc.icons) return; // ── Sprite (Lucide outline glyphs, viewBox 24×24) ────────────────────── // Concatenated from upstream lucide-static@1.16.0 SVGs; class/style // attributes stripped. Order matches the icons-mapped block below // so a diff against Lucide's source stays readable. var SYMBOLS = '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' // Lightweight outline chevron — used by the tree as the // expand/collapse affordance. The single glyph rotates 90° // via CSS to indicate the expanded state, so we only ship // one path instead of two. + '' + '' + ''; var injected = false; function inject() { if (injected) return; // insertAdjacentHTML on body parses the SVG namespace correctly // across all modern browsers (innerHTML on a
wrapper has // historically tripped over in some engines). var sprite = '' + SYMBOLS + ''; if (document.body) { document.body.insertAdjacentHTML('afterbegin', sprite); injected = true; } else { document.addEventListener('DOMContentLoaded', inject, { once: true }); } } // Produces the per-row markup callers concat into innerHTML. // Bundles the size + stroke defaults inline so the SVG renders // correctly even before the page CSS runs (e.g. mid-paint). function html(symbolId) { return ''; } window.zddc.icons = { inject: inject, html: html }; })();