jukebox
All repositories: gitoria
27.3 KB
// The framework's STYLESHEET — the Style convention of COMPONENTS §4, as the// archived hl:web implemented it (archive/hlweb-v1/plugins-web/web_css.hl), re-read// 2026-09-12 after a version built from the doc alone got most of it wrong.//// STRUCTURE FROM THE SYNTAX, VALUES FROM THE INSTANCE. A hybrid's keys come back// alphabetical, so the ORDER of rules, declarations and media conditions is read// off the syntax (hlSyntax entries are authored order) while every VALUE is read// off the constructed instance at the same path — the language has already folded// the statics (`background = dark`) and merged `base + { … }` by then.//// WHAT A RULE NAME MEANS (the archive's `placesFor`, per file):// `@root` / `':root'` a CONTRIBUTION: collected from every file into ONE// `:root { }` at the top of the sheet, in order// `'@media …'` / `@media` a BLOCK of rules: collected at the END of the sheet,// (`@supports`, the same shape and place for the other two queries// `@container`) (ticket #66, proposal 5)// one `@media` per distinct query, first-seen order;// `@media { minWidth = 960 … }` composes the query from// conditions (number → px, string verbatim); any number of// different bare ones may stand in one block (read off the// syntax, see SYNTAX), inside a rule the feature-named scalars// are the conditions (hybriel#257)// `'@keyframes name'` an ANIMATION: its stops (`'from'`, `to`, `'50%'`) with// their declarations, emitted where it stands (ticket #66, 4)// selector-shaped verbatim (`'.icon'`, `'#page-anchor'`, `'a:hover'`)// referenced `Style.x` the class the View wrote (tag-prefix strip): `.x`, or// `tag.stripped`// `#x` id the View writes `id = 'x'` on an element: `#x` (R3)// `#x` local otherwise matched by NAME to this file's elements `x` (and// a composed child's root for `#Child`): `tag.<file class>`// own-name a rule named like an element of this file's View (or// body/html): the TAG selector, no class// anything else DEAD: a build error naming the file and the rule// In a STYLES FILE (root members, no View) a bare name is a tag, kebab-cased.// NESTED under a rule, a name of PSEUDOS is that rule's pseudo-class, not a// descendant: `a { hover { … } }` → `a:hover` (ticket #66, proposal 1).// A rule with no declarations and nested rules is a CONTAINER: not emitted.// Two rules emitting one selector with different bodies: refused.import HlwCssVar from './cssvar.hl'static NL = ""static SELECTOR_CHARS = ":-.#>[]()*+~,/ %@=^|!"static HEADER = "/* GENERATED by hl:web — ONE global stylesheet.Components author their Style rules per file; only the rules a View actuallyREFERENCES are emitted (dead rules are dropped and listed at boot). Class namesfollow the tag-prefix strip rule: rule `headerMain` referenced inside `header`emits class=\"main\" under the TAG-QUALIFIED selector `header.main`; under anyother tag it keeps `.headerMain`. */"Boolean minify = falseview = null // the View walk: kebab, className, localClass live theregen = 0 // the analysis generation the syntax handles belong to// per sheetparts = []seen = {}dead = []mediaOrder = []mediaParts = []rootDecls = []// ---- names ----------------------------------------------------------------------// ---- css variables (creator's ruling 2026-09-13) --------------------------------// `bg = var('#FFF')` declares a custom property as a VALUE; the walker names it after// its member, writes it into the sheet's one `:root`, and rewrites every use.static counter = { n = 0 }// `var('#FFF', dark = '#000')` carries its dark-scheme value too (ticket #66,// proposal 2): the sheet writes it into `:root` under `(prefers-color-scheme: dark)`static var = (value, dark = null) => {counter.n = counter.n + 1return new HlwCssVar(value = value, id = counter.n, dark = dark)}static DARK = '@media (prefers-color-scheme: dark)'// ---- units as functions (ticket #66, proposal 3) ---------------------------------// a number is emitted unitless as written; `rem(1.5)`, `px(12)`, `pct(50)` answer the// TEXT with its unit — '1.5rem', '12px', '50%' — so a value says what it measuresstatic rem = (n) => { return '' + n + 'rem' }static px = (n) => { return '' + n + 'px' }static pct = (n) => { return '' + n + '%' }vars = {} // id → { name value } for the sheet being builtvarNames = {} // name → trueisVar(v) { return v != null && hlTypeName(v) == 'Instance' }// the variables a file's root members declare, named after the membercollectVars(f) {for (r of fileRules(f)) {if (!r.isBlock && isVar(r.value)) {r.value.name = r.keyvars['' + r.value.id] = { name = r.key; value = r.value.value; }varNames[r.key] = true}}// a token the file INHERITS: its own instance's copy, under the parent's name (ticket #39)if (f.aliases != null) {for (a of f.aliases) {a.value.name = a.keyvars['' + a.value.id] = { name = a.key; value = a.value.value; }}}return null}// a value's text with every variable reference resolved: a variable itself →// var(--name); a composed string carries placeholders var(--hlv<id>) → var(--name)varText(v) {if (isVar(v)) {let d = vars['' + v.id]if (d == null) { hlError("a css variable is used before any styles file declared it as a root member — `name = var(…)` at the root of the styles file") }return 'var(--' + view.kebab(d.name) + ')'}let s = '' + vif (s.indexOf('var(--hlv') < 0) { return s }for (id of vars.keys()) { s = s.replaceAll('var(--hlv' + id + ')', 'var(--' + view.kebab(vars[id].name) + ')') }return s}// the pseudo-classes a nested entry may name, camelCase as written (kebab-cased on emit)static PSEUDOS = ['hover', 'focus', 'focusVisible', 'focusWithin', 'active', 'visited', 'target','disabled', 'enabled', 'checked', 'required', 'optional', 'valid', 'invalid', 'readOnly','placeholderShown', 'firstChild', 'lastChild', 'onlyChild', 'firstOfType', 'lastOfType', 'empty']isPseudo(name) { return PSEUDOS.includes(name) }// Split only selector-list commas; functional pseudos, attributes, strings and// escaped commas belong to their selector (hybriel#408).selectorParts(String source) {let out = []let part = ''let depth = 0let brackets = 0let quote = ''let escaped = falsefor (c of source) {if (escaped) { part = part + c escaped = false }else if (c.charCodeAt(0) == 92) { part = part + c escaped = true }else if (quote != '') {part = part + cif (c == quote) { quote = '' }} else if (c == ',' && depth == 0 && brackets == 0) {out.push(part.trim())part = ''} else {part = part + cif (c == "'" || c == '"') { quote = c }else if (c == '[') { brackets = brackets + 1 }else if (c == ']') { brackets = brackets - 1 }else if (brackets == 0 && c == '(') { depth = depth + 1 }else if (brackets == 0 && c == ')') { depth = depth - 1 }}}out.push(part.trim())return out}// the selectors a nested entry composes under its enclosing rule's `sels`: a// pseudo-class sticks to each (`a:hover`), anything else is a descendant (`a span`)nestedSels(Hybrid f, Hybrid sels, String key) {let out = []if (isPseudo(key)) {for (p of sels) {let composed = []for (s of selectorParts(p)) { composed.push(s + ':' + view.kebab(key)) }out.push(composed.join(', '))}return out}let kidSels = selectorsFor(f, key)// a tag that only a COMPOSED component's View renders (hybriel#243): `'.bar' { 'img' { … } }`// is `.bar img` when Child, composed inside `.bar`, has the imgif (kidSels.length == 0 && f.deepTags != null && f.deepTags.includes(key)) { kidSels = [view.domTag(key)] }// a tag a CALLER writes into this component's slot (hybriel#270): it lands inside the elementif (kidSels.length == 0 && f.fillTags != null && f.fillTags.includes(view.domTag(key))) { kidSels = [view.domTag(key)] }for (p of sels) {for (s of kidSels) {let composed = []for (outer of selectorParts(p)) {for (child of selectorParts(s)) { composed.push(outer + ' ' + child) }}out.push(composed.join(', '))}}return out}isKeyframes(name) { return name == '@keyframes' || name.startsWith('@keyframes ') }isRootBlock(name) { return name == '@root' || name == ':root' }// THE THREE QUERIES share one shape: `@media`, `@supports`, `@container` — bare with// conditions as scalars, or spelled out in the keystatic QUERIES = ['@media', '@supports', '@container']queryKind(name) {for (k of QUERIES) {if (name == k || name.startsWith(k + ' ') || name.startsWith(k + '(')) { return k }}return ''}isMediaBlock(name) { return queryKind(name) != '' }// THE FEATURES a bare query inside a rule reads as conditions, camelCase as written.// `width`, `height`, `color` and `grid` are also declarations and stay declarations// there: write `minWidth` / `maxWidth` (and `minHeight`, `maxHeight`) for a size.static MEDIA_FEATURES = ['aspectRatio', 'orientation', 'resolution', 'pointer', 'hover', 'anyPointer', 'anyHover','prefersColorScheme', 'prefersReducedMotion', 'prefersContrast', 'prefersReducedData', 'prefersReducedTransparency','displayMode', 'overflowBlock', 'overflowInline', 'update', 'scan', 'colorGamut', 'colorIndex', 'monochrome','forcedColors', 'invertedColors', 'scripting', 'videoDynamicRange', 'dynamicRange']static RANGE_FEATURES = ['width', 'height', 'aspectRatio', 'resolution', 'color', 'colorIndex', 'monochrome']static CONTAINER_FEATURES = ['inlineSize', 'blockSize', 'aspectRatio', 'orientation']isFeature(kind, name) {if (kind == '@media') {if (MEDIA_FEATURES.includes(name)) { return true }if (name.length > 3 && (name.startsWith('min') || name.startsWith('max'))) {rest = name.slice(3, name.length)low = rest.charAt(0).toLowerCase() + rest.slice(1, rest.length)return RANGE_FEATURES.includes(low)}return false}if (kind == '@container') {if (CONTAINER_FEATURES.includes(name)) { return true }if (name.length > 3 && (name.startsWith('min') || name.startsWith('max'))) {rest = name.slice(3, name.length)low = rest.charAt(0).toLowerCase() + rest.slice(1, rest.length)return ['width', 'height', 'inlineSize', 'blockSize', 'aspectRatio'].includes(low)}}return false}mediaLiteral(name) { return name.slice(queryKind(name).length, name.length).trim() }localName(name) { return name.startsWith('#') ? name.slice(1) : '' }selectorShaped(name) {if (name.length == 0) { return false }if ('0123456789'.indexOf(name.charAt(0)) >= 0) { return true }let i = 0while (i < name.length) {if (SELECTOR_CHARS.indexOf(name.charAt(i)) >= 0) { return true }i = i + 1}return false}// ---- one block's syntax, with its values --------------------------------------// the entries of a hybrid node: [{ key node value isBlock }] in authored order,// values read off `hybrid` (the instance's evaluated member at the same path)entriesOf(key, node, hybrid) {let out = []let n = node == 0 ? null : hlSyntax(gen, key, node)if (n == null || n.tag != 'object_expression') {// A MERGED RULE (`extR = baseR + { top = 'auto' }`, COMPONENTS §4: "Style gets it// for free") has no literal to read: its entries are the merged VALUE's, and a// nested block is read the same way. It used to read as no entries at all, so the// View wrote the class and the sheet carried no rule for it (mission 322 row 9).if (isHybridValue(hybrid)) {for (k of hybrid.keys()) { out.push({ key = k; node = 0; value = hybrid[k]; isBlock = isHybridValue(hybrid[k]); }) }}return out}own = hybrid == SYNTAXfor (h of n.entries) {let e = hlSyntax(gen, key, h)if (e != null && e.tag == 'object_property') {if (e.key.indexOf('&') >= 0) {hlError("hl:web: " + key + ':' + e.line + ':' + e.col + " — '&' in Style key '" + e.key + "' is refused. Apply a class with Style.name on the element, or write the whole selector quoted without '&'")}let v = hlSyntax(gen, key, e.value)if (own) {out.push(syntaxEntry(key, e, v))} else {val = hybrid != null ? hybrid[e.key] : null// A static hybrid has no syntax block here; its evaluated value is the rule (W219, #253).out.push({ key = e.key; node = e.value; value = val; isBlock = (v != null && v.tag == 'object_expression') || isHybridValue(val); })}}}return markRepeated(key, out)}// THE VALUES OF A BLOCK THAT THE INSTANCE CANNOT HOLD (hybriel#257). Two members of one// name are one member in the constructed instance, so a query written twice// (`@media { minWidth … }` and `@media { maxWidth … }`) cannot be read from it by name.// Every occurrence of such a name is marked SYNTAX: its entries, at any depth, are read// off the source in place, where each block has its own position. Only a literal can be// read that way (a string, a number, a boolean); a name or a call inside such a block// is a located error that says what to do.static SYNTAX = '[read from the syntax]'syntaxEntry(key, e, v) {if (v != null && v.tag == 'object_expression') { return { key = e.key; node = e.value; value = SYNTAX; isBlock = true; } }if (v == null || v.tag != 'literal') {hlError("'" + e.key + "' in " + key + " sits in a query that is written more than once in one block, and such a block's values are read off the source, where only a literal (a string or a number) can be read. Write '" + e.key + "' as a literal, or give the queries distinct keys ('@media (min-width: 60rem)' = { … })")}let val = v.textif (v.kind == 'number') { val = toNumber(v.text) }if (v.kind == 'boolean') { val = v.text == 'true' }return { key = e.key; node = e.value; value = val; isBlock = false; }}// a query name that occurs more than once among the entries of one block: every// occurrence is read from the syntax (see SYNTAX)markRepeated(key, entries) {count = {}for (e of entries) {if (isMediaBlock(e.key)) { count[e.key] = count[e.key] == null ? 1 : count[e.key] + 1 }}out = []for (e of entries) {if (count[e.key] != null && count[e.key] > 1 && e.value != SYNTAX) {sn = hlSyntax(gen, key, e.node)if (sn == null || sn.tag != 'object_expression') {hlError("'" + e.key + "' in " + key + " is written more than once and one of them is not a block literal — write each as { … } or give the queries distinct keys")}out.push({ key = e.key; node = e.node; value = SYNTAX; isBlock = true; })} else {out.push(e)}}return out}// a hybrid VALUE (a rule), as opposed to a scalar declaration or a var() tokenisHybridValue(v) { return v != null && hlTypeName(v) == 'Hybrid' }// a value as CSS text: a string as written, a number unitless, a static already// folded, a css variable (or a string composed with one) resolved to var(--name)text(v) {return varText(v)}declLine(k, v) {if (minify) { return view.kebab(k) + ':' + text(v) + ';' }return ' ' + view.kebab(k) + ': ' + text(v) + ';' + NL}// a media condition: `minWidth = 960` → `(min-width: 960px)`, a string verbatimcondition(k, v) {if (hlTypeName(v) == 'Number') { return '(' + view.kebab(k) + ': ' + v + 'px)' }return '(' + view.kebab(k) + ': ' + v + ')'}// the whole prelude, `@media (a) and (b)`: an enclosing query of the SAME kind is// joined with `and`; one of another kind cannot be, in a sheet written flatqueryText(kind, outer, literal, conds, name) {let parts = []if (outer != '') {if (!outer.startsWith(kind + ' ')) { hlError("'" + name + "' stands inside '" + outer + "' — two kinds of query cannot be joined into one; write the block beside it, not inside") }parts.push(outer.slice(kind.length + 1, outer.length))}if (literal != '') { parts.push(literal) }for (c of conds) { parts.push(c) }let out = ''for (p of parts) { out = out == '' ? p : out + ' and ' + p }return kind + ' ' + out}// ---- where a rule lands (the archive's placesFor) -------------------------------// `f` is the file block: { key cls refs tags hasView isStyles }; refs are what the// View wrote ([{ tag rule }]), tags the element names the file's own View renders.selectorsFor(f, name) {if (f.isStyles) {if (selectorShaped(name)) { return [name] }return [view.domTag(name)]}let local = localName(name)// the View writes `id = 'x'`: `#x` is that id, nothing else (ticket #51, R3)if (local != '' && f.ids != null && f.ids.includes(view.kebab(local))) { return [view.kebab(name)] }if (local != '' && !selectorShaped(local)) {let out = []for (r of f.refs) {if (r.rule == name) {let sel = view.domTag(r.tag) + '.' + view.localClass(f.key)if (!out.includes(sel)) { out.push(sel) }}}return out}if (selectorShaped(name)) { return [name] }let classes = []for (r of f.refs) {if (r.rule == name) {let cls = view.className(name, r.tag)if (!classes.includes(cls)) { classes.push(cls) }}}if (classes.length == 0) {if (f.tags.includes(name) || name == 'body' || name == 'html') { return [view.domTag(name)] }return []}let out = []for (cls of classes) {if (cls == name) { out.push('.' + view.kebab(cls)) }else { out.push(view.domTag(name.slice(0, name.length - cls.length)) + '.' + view.kebab(cls)) }}return out}// ---- emission -------------------------------------------------------------------// Normalize CSS whitespace only outside quoted strings and attribute brackets.cssWhitespace(source) {let out = ''let quote = ''let brackets = 0let escaped = falselet pending = falsefor (c of source) {if (escaped) { out = out + c escaped = false }else if (c.charCodeAt(0) == 92) {if (pending && out != '') { out = out + ' ' }pending = falseout = out + cescaped = true} else if (quote != '') {out = out + cif (c == quote) { quote = '' }} else if (brackets == 0 && c.trim() == '') { pending = true }else {if (pending && out != '') { out = out + ' ' }pending = falseout = out + cif (c == "'" || c == '"') { quote = c }else if (c == '[') { brackets = brackets + 1 }else if (c == ']') { brackets = brackets - 1 }}}return out}putRule(f, name, selector, body, query) {selector = cssWhitespace(selector)query = cssWhitespace(query)let first = seen[query + '|' + selector]if (first != null) {if (first.body == body) { return null }let msg = "style rule '" + selector + "' is emitted twice with different bodies — '" + first.rule + "' in " + first.file + " and '" + name + "' in " + f.key + " both emit that selector; put the declarations in ONE rule, or rename one of them"// printed first: an app's own `on Error` that ends the start with exit(1) takes the error and its text with it (hybriel#247)console.log('error: ' + msg)hlError(msg)}seen[query + '|' + selector] = { body = body; rule = name; file = f.key; }if (query == '') {parts.push(minify ? selector + '{' + body + '}' : NL + selector + ' {' + NL + body + '}' + NL)} else {mediaPut(query, selector, body)}return null}mediaPut(query, selector, body) {if (!mediaOrder.includes(query)) { mediaOrder.push(query) }// inside a media block every line is indented two spaces (the archive's goldens)let inner = minify ? selector + '{' + body + '}' : ' ' + selector + ' {' + NL + ' ' + body.replace(NL + ' ', NL + ' ') + ' }' + NLmediaParts.push({ query = query; text = inner; })return null}// ONE RULE: its own declarations under `sels`, its nested rules composed below it// (descendant), its media blocks under the query; a container emits nothing itselfemitRule(f, name, sels, entries, query) {let body = ''let kids = []let medias = []for (e of entries) {if (e.isBlock) {if (isMediaBlock(e.key)) { medias.push(e) } else { kids.push(e) }} else if (e.value != null) {body = body + declLine(e.key, e.value)}}if (body != '') {for (sel of sels) { putRule(f, name, sel, body, query) }}for (k of kids) {if (isKeyframes(k.key)) { hlError("'" + k.key + "' inside '" + name + "' in " + f.key + " — an animation is not a rule's child: write it at the top of the Style or of the styles file") }let composed = nestedSels(f, sels, k.key)if (composed.length == 0) {dead.push(f.key + ' ' + f.cls + '.' + name + ' ' + k.key)} else {emitRule(f, name + ' ' + k.key, composed, entriesOf(f.key, k.node, k.value), query)}}for (m of medias) {// a query inside a query of the SAME kind joins with `and` (queryText refuses another kind)mediaBlock(f, m.key, m.node, m.value, sels, name, query)}return null}// ONE `@media` BLOCK, at the top of a Style (prefixes empty) or inside a rule// (prefixes = the enclosing rule's selectors): scalar entries are CONDITIONS// (only for the bare `@media` spelling), block entries are RULES under the query;// inside a rule, scalar entries are the ENCLOSING RULE's declarations under it.mediaBlock(f, name, node, hybrid, prefixes, outer, outerQuery) {let literal = mediaLiteral(name)let conds = []let own = ''let rules = []let overrides = ''for (e of entriesOf(f.key, node, hybrid)) {if (e.isBlock) { rules.push(e) }// a css VARIABLE re-assigned under the query: `bg = '#000'` inside// `@media { prefersColorScheme = 'dark' … }` is `:root { --bg: #000 }` thereelse if (prefixes.length == 0 && varNames[e.key] != null) { overrides = overrides + declLine('--' + view.kebab(e.key), e.value) }else if (literal == '' && prefixes.length == 0) { conds.push(condition(e.key, e.value)) }// INSIDE A RULE a bare query's scalars are its conditions when they name a feature// (`pointer = 'coarse'`, `minWidth = 960`) and the rule's declarations otherwiseelse if (literal == '' && isFeature(queryKind(name), e.key)) { conds.push(condition(e.key, e.value)) }else if (prefixes.length > 0) { own = own + declLine(e.key, e.value) }else { hlError("'" + name + "' already spells its query out, so '" + e.key + "' is a declaration directly inside an at-rule — put it in a rule inside the block") }}if (prefixes.length > 0 && literal == '' && conds.length == 0) {hlError("'" + name + "' inside '" + outer + "' in " + f.key + " names no condition. Inside a rule a bare query takes its conditions as scalars named after a feature (`pointer = 'coarse'`, `minWidth = 960`; `width` and `height` alone are declarations, write `minWidth`), or spell it out: '" + queryKind(name) + " (min-width: 60rem)' = { … }")}let q = queryText(queryKind(name), outerQuery, literal, conds, name)if (overrides != '') { putRule(f, name, ':root', overrides, q) }if (own != '') { for (sel of prefixes) { putRule(f, outer, sel, own, q) } }for (r of rules) {if (isMediaBlock(r.key)) { mediaBlock(f, r.key, r.node, r.value, prefixes, outer, q) }else if (isKeyframes(r.key)) { hlError("'" + r.key + "' inside '" + name + "' in " + f.key + " — an animation is not scoped by a query: write it at the top of the Style or of the styles file") }else {let composed = prefixes.length > 0 ? nestedSels(f, prefixes, r.key) : selectorsFor(f, r.key)if (composed.length == 0) { dead.push(f.key + ' ' + f.cls + '.' + r.key + ' (in ' + name + ')') }else { emitRule(f, r.key, composed, entriesOf(f.key, r.node, r.value), q) }}}return null}// a file's rules in authored order: [{ key node value isBlock }] — a component's// Style entries, or a styles file's root members (its inherits' first)fileRules(f) {return f.rules}// ONE `'@keyframes name' = { 'from' = { … } to { … } '50%' = { … } }`: every entry is// a stop, its key the stop's selector verbatim, its entries declarationskeyframes(f, r) {let name = r.key.slice(10, r.key.length).trim()if (name == '') { hlError("'@keyframes' in " + f.key + " names no animation — write the name into the key: '@keyframes fade' = { 'from' = { opacity = 0 } to { opacity = 1 } }") }let body = ''for (st of entriesOf(f.key, r.node, r.value)) {if (!st.isBlock) { hlError("'" + st.key + "' in '" + r.key + "' (" + f.key + ") is a declaration, and an animation holds stops — 'from', to, '50%' — each a block of declarations") }let decls = ''for (d of entriesOf(f.key, st.node, st.value)) {if (d.isBlock) { hlError("'" + d.key + "' in the stop '" + st.key + "' of '" + r.key + "' (" + f.key + ") is a block — a stop holds declarations only") }if (d.value != null) { decls = decls + (minify ? declLine(d.key, d.value) : ' ' + declLine(d.key, d.value)) }}body = body + (minify ? st.key + '{' + decls + '}' : ' ' + st.key + ' {' + NL + decls + ' }' + NL)}putRule(f, r.key, '@keyframes ' + name, body, '')return null}// ---- the sheet ------------------------------------------------------------------// `files` are the blocks in cascade order: the styles file (with its inherits// walked first by the caller), then every served component.sheet(files) {parts = []seen = {}dead = []mediaOrder = []mediaParts = []rootDecls = []vars = {}varNames = {}for (f of files) { collectVars(f) }// the declared variables come first in :root, in declaration order; their dark// values open the dark-scheme query with a :root of their own (an explicit// `@media { prefersColorScheme = 'dark' … }` re-assignment lands after it and wins)let darkBody = ''for (f of files) {for (r of fileRules(f)) {if (!r.isBlock && isVar(r.value)) {rootDecls.push(declLine('--' + view.kebab(r.key), r.value.value))if (r.value.dark != null) { darkBody = darkBody + declLine('--' + view.kebab(r.key), r.value.dark) }}}}if (darkBody != '') { mediaPut(DARK, ':root', darkBody) }for (f of files) {for (r of fileRules(f)) {if (!r.isBlock) {// a scalar root member of a styles file is not a rule (a variable was taken above)} else if (isMediaBlock(r.key)) {mediaBlock(f, r.key, r.node, r.value, [], '', '')} else if (isKeyframes(r.key)) {keyframes(f, r)} else if (isRootBlock(r.key)) {for (d of entriesOf(f.key, r.node, r.value)) {if (d.isBlock) { hlError("'" + r.key + "' holds custom properties only — '" + d.key + "' is a rule; put it beside the block, not inside it") }rootDecls.push(declLine(d.key, d.value))}} else {let sels = selectorsFor(f, r.key)if (sels.length == 0) { dead.push(f.key + ' ' + f.cls + '.' + r.key + ' bound to nothing (no reference, no matching element)') }else { emitRule(f, r.key, sels, entriesOf(f.key, r.node, r.value), '') }}}}let out = minify ? '' : HEADERif (rootDecls.length > 0) {let body = ''for (d of rootDecls) { body = body + d }out = out + (minify ? ':root{' + body + '}' : NL + ':root {' + NL + body + '}' + NL)}for (p of parts) { out = out + p }for (q of mediaOrder) {let inner = ''for (p of mediaParts) { if (p.query == q) { inner = inner + p.text } }out = out + (minify ? q + '{' + inner + '}' : NL + q + ' {' + NL + inner + '}' + NL)}if (dead.length > 0) {// A RULE THAT MATCHES NOTHING IS A BUILD ERROR (hybriel#243), not a log line: the// page would ship without it and nothing on the page says solet all = ''for (d of dead) { all = all + NL + ' ' + d }hlError('hl:web: style rules that match nothing in their file, nor in any component it composes (file.rule):' + all + NL + 'Reference the rule with Style.rule on an element, name an element of the View, write the selector whole (\'.bar section h2\'), or delete the rule')}return out}
Branches
Latest commits
- 10f8a8c8Merge branch 'code-order' into mainJukebox
- 204fc828Merge branch 'day72' into mainJukebox
- 95f5faae|||PR jukebox#7 Drop needless let declarationsmre
- 33072bb5|||PR Record day72 gates and Chrome proofmre
- 95f2cd73|||PR Use typed parent methods for screen playback and local server facesmre
- 6422a020Sync media-player at 51c3818mre
- b582ba1cVendor complete Hybriel day72 plugin setmre
- 02dccbc9Merge branch 'records-1119' into mainJukebox
- a39e1c23|||PR Records: missions 013-015, reconnect fix livemre
- fc7db075Merge branch 'reconnect-retry' into mainJukebox
- ac6f4c6fL2: plain declaration for a in pickedNextmre
- 2f335086Review round 2: only an explicit queue pick drops pend (not the automatic advance); jb23 records every source changemre
- 3eb6695fReview fixes: action generation, queue pick clears pend, Previous/Next retry the decided request, typed handlersmre
- 7a53c0c2|||PR A tap lost to a dead socket plays after reconnect (mission 015)mre
- 1f0cd77bMerge branch 'records-day41' into mainJukebox
- 67be229f|||PR Records: day41 live (PR #4), mission 012, statusmre
- 0bb027daconductor: caramboleyo is the user, not owner/creatorApollo
- 04f5d9d5Merge branch 'day41' into mainJukebox
- 8ed6da45|||PR README: media-player pin df9e7dfmre
- d5d45fc3|||PR media-player df9e7df (repeat-one fix), sync pin and SOURCEmre