ident
All repositories: gitoria
7.4 KB
// The View's READERS — realm-neutral: the same code reads values on the server and (compiled to JS) in the// browser; the browser's bundle carries this file and nothing server-only (viewserver.hl). It reads a TREE, the// syntax of a View member reflected into plain hybrids by the server (see// server.hl `tree()`), against an INSTANCE whose members supply the values.//// Tree node shapes:// { k = 'el' tag key path = [ keys… ] site attrs = [ { name text } | { name member } ] children = [ … ] }// `site` is `file:line:col` of the literal — the id its class is minted under// `tag` is what the DOM gets (a custom key kebab-cased), `key` the source key// { k = 'text' text }// { k = 'member' name } an ordered entry naming a member of the class — a SITE// { k = 'field' name path } `p.title`: a path off a member or a `for` row variable// { k = 'for' row list body } `for (row of list) { … }`, body rendered per entry// { k = 'if' cond then other } `if (cond) { … } else { … }`// { k = 'on' event } a DOM event the owning literal handles (its inline `on`)// { k = 'component' cls key path bindings ons } `Child { count = count on done(v) { … } }`:// a composed component — its own mount renders here// { k = 'other' tag } a construct this round does not render yet (if / for / on)//// `ctx` rides through every call: `ctx.slot` is the HTML a shell's `slot` member// stands for (null when rendering a page alone), `ctx.kids` the child mounts of// the instance being rendered, keyed by the component node's path joined with// '/'. A component node renders ITS mount: its own instance, its own kids.// the language has no escapes: a newline and a tab are written as themselvesstatic newline = ""static tab = " "// a component node's key in a mount's `kids`: its path, '/'-joined (a list has no// join in the language; the walk is written out)kidKey(&path) {let out = ''for (p of path) { out = out + '/' + p }return out}// THE KEY OF ONE ROW — "lists are keyed by the record's id" (CONCEPT §2), and by// the row's index where the row is not a record or carries no id (a list of strings// is one: demo-blog's paragraphs). ONE rule, called by everything that has to tell// one row from the next: the server's HTML walk below, the mount key of a row's// children (WebFramework `mountKids`), and the browser's keyed region (client.hl).// Two rows with the SAME id are two rows to the language and one key to this rule;// the browser's region gives the second one a key of its own, the server does not.rowKey(&entry, i) {if (entry != null) {let t = hlTypeName(&entry)if ((t == 'Hybrid' || t == 'Instance') && entry.id != null) { return '' + entry.id }}return '' + i}// THE KEYS OF A LIST, in order: rowKey of each row, and where one id stands twice the second and later// rows get ':' + their index (#119). The browser's region (client listKeys) keys a list the same way, so a// child of the second row of one id is its own mount on the server too, not the first row's.listKeys(&entries) {let out = []let seen = {}let ri = 0for (entry of entries) {let k = rowKey(&entry, ri)if (seen[k] != null) { k = k + ':' + ri }seen[k] = trueout.push(k)ri = ri + 1}return out}// A LITERAL'S VALUE, TYPED — COMPONENTS.md §12, "typed, not stringified". `hlSyntax`// hands a literal back as its source text and its KIND, and a reference binding carries// the value rather than the text: `Level2 { n = 1 }` gives the child a Number, so `n * 97`// is arithmetic and not "operator '*' does not apply to String and Number" (measured// 2026-09-14, demo-nested wall 3). An attribute and a text child keep the text, because// HTML is text; only what crosses into a member of another class is typed.literalValue(kind, text) {if (kind == 'number') { return toNumber(text) }if (kind == 'boolean') { return text == 'true' }if (kind == 'null_literal') { return null }return text}// THE VALUE A REFERENCE BINDING CARRIES when it is a literal or a folded static — the// one place the two are read, so the server's mount and the browser's do it alike. A// static is folded to its VALUE and carried as one ('folded'), never printed and parsed// back; a literal carries its source text and its kind, which is all the syntax has.refValue(b) {if (b.kind == 'folded') { return b.value }if (b.kind != null) { return literalValue(b.kind, b.text) }return b.text}// THE VALUE a read names: a `for` row variable in scope wins over a member of the// same name (nesting is scope); a field path walks into it.value(&node, &page, &rows) {if (node.k == 'text') { return refValue(node) }if (node.k == 'expr') { return evalExpr(&node.x, &page, &rows) }// READ IN PLACE: `v = rows[node.name]` copied the whole row value (a block with all its spans) and each// `v = v[f]` step copied the rest again, per read, per mount; a path of up to three steps is one indexed readlet name = node.namelet inRow = rows[name] != nullif (node.k == 'field') {let path = node.pathlet n = path.lengthif (n == 1) {if (inRow) { return rows[name] == null ? null : rows[name][path[0]] }return page[name] == null ? null : page[name][path[0]]}if (n == 2) {if (inRow) { return rows[name][path[0]] == null ? null : rows[name][path[0]][path[1]] }return page[name][path[0]] == null ? null : page[name][path[0]][path[1]]}}let v = nullif (inRow) { v = rows[name] } else { v = page[name] }if (node.k == 'field') {for (f of node.path) {if (v == null) { return null }v = v[f]}}return v}// A VIEW EXPRESSION (`p { "x" + n }`, `a - b`, `n > 3 ? 'big' : 'small'`) is evaluated by// the LANGUAGE'S OWN OPERATORS: this walk only picks the operator the author wrote and// applies it, so what `+` gives null and a string, what `==` says of two types, what `&&`// returns — all of it is the runtime's answer, on the server (the interpreter or a// binary) and in the browser (the client target), and hl:web has no rule of its own.// The leaves are reads (`value`) and literals. `&&`, `||` and `?:` evaluate what they// pick only, as the language does.evalExpr(&x, &page, &rows) {if (x.k == 'bin') {let l = evalExpr(&x.l, &page, &rows)let op = x.opif (op == 'logical_and') { return l && evalExpr(&x.r, &page, &rows) }if (op == 'logical_or') { return l || evalExpr(&x.r, &page, &rows) }let r = evalExpr(&x.r, &page, &rows)if (op == 'add') { return l + r }if (op == 'subtract') { return l - r }if (op == 'multiply') { return l * r }if (op == 'divide') { return l / r }if (op == 'modulo') { return l % r }if (op == 'equal') { return l == r }if (op == 'not_equal') { return l != r }if (op == 'less_than') { return l < r }if (op == 'greater_than') { return l > r }if (op == 'less_equal') { return l <= r }if (op == 'greater_equal') { return l >= r }if (op == 'bit_and') { return l & r }if (op == 'bit_or') { return l | r }if (op == 'bit_xor') { return l ^ r }if (op == 'shift_left') { return l << r }return l >> r}if (x.k == 'un') {let o = evalExpr(&x.x, &page, &rows)if (x.op == 'logical_not') { return !o }if (x.op == 'negate') { return -o }return ~o}if (x.k == 'cond') { return evalExpr(&x.c, &page, &rows) ? evalExpr(&x.a, &page, &rows) : evalExpr(&x.b, &page, &rows) }return value(&x, &page, &rows)}
Branches
Latest commits
- ccd6d0c4ident#34: browser gate: rowButton finds the row's button by namemre
- 24dd414eident#34: the shared lead, message and notice looks are statics in components/styles.hl, imported by the components (lib/looks.hl gone)mre
- 03ed26c7ident#34: access.hl: the remaining lead classes droppedmre
- 1d066c42ident#34: access.hl drops its unstyled lead class (the shared lead rule would otherwise mute it)mre
- 1e1dd7b4ident#34: the access page keeps its lead class string (the page has no ident-card, so its lead line was never muted; a shared rule would change the look)mre
- 89ac6553ident#34: the lead, message and notice lines are named with Style.pLead / pMessage / pNotice (shared bodies in lib/looks.hl) instead of class stringsmre
- e84be3deident#34: browser gate lists the Edit/Delete buttons by namemre
- fb7111faident#34: access page: unstyled test-hook classes (idrow, never, who, whoname, appname, neverrevoke) dropped; the tests use element/name selectorsmre
- 9f2ad803ident#34: notification switches: push/email by name=..., locked by aria-disabled, the switch look is the role=switch button (no switch/push/email/locked classes)mre
- e0f0ddaaident#34: inbox: the Mark read/unread button is styled as the button of its note-foot, the icon is found as the row's img (no toggle/icon classes)mre
- 16b49756ident#34: unused row classes (choice, usedrow, kind, shortid) droppedmre
- f9d6fb38ident#34: apps and identity rows: the Edit/New secret/Delete buttons carry name=..., the API key is found by its element; unused row classes (app, identity, shortid) droppedmre
- b323265aMerge branch 'f5-styles' into mainIdent
- 9ced53c3|||PR ident#33 ident#35 every component's styles live in its own Style block; styles.hl keeps the page-wide rest; the account bar is phone first (min-width: 60rem block); the avatar preview is hidden with the hidden attribute (ident#34 in part)mre
- f28333e4ident#33 ident#35: styles.hl keeps only the accent, the page column and the shared patterns; the account bar is written phone first (base rule + one min-width: 60rem block) instead of a max-width overridemre
- 5b4541fcident#33: the selector sign-in frame's rules move into embed.hl's Stylemre
- 00235f21ident#33: the per-app notification switches move into appsettings.hl's Stylemre
- 2249945cident#33: the inbox and connection list rules move into inbox.hl's Stylemre
- f2d9f79fident#33: the apps list and the secret box move into apps.hl's Stylemre
- 8370b748ident#33: the app request box moves into home.hl's Stylemre