Files
oikos/web/node_modules/postcss-scss/lib/scss-parser.js
dtoro d4d99a7473
Some checks failed
ci / build-test (push) Has been cancelled
ci / docker-build (push) Has been cancelled
feat: Phase 1 — extract the client (web SPA + desktop) to dtoro/oikos-web
Problem: the hexagonal refactor churns the backend tree for nine more
phases; the UI delivery stack (web/ SPA, cmd/desktop Wails wrapper,
compose/web image) must move to its own repo first so doc/layout
rewrites land once on a backend-only tree.

Change:
- New repo git.hubris.network/dtoro/oikos-web (v0.33.0): web/, desktop/
  (updateURL repointed to oikos-web releases), compose/, own CI (web +
  desktop jobs), own deploy script (CI-green gate, TOCTOU guard,
  version-tagged images, prune-to-3), own webhook receiver on :9798 +
  launchd unit, own compose project publishing the same 8091:80.
- Cutover executed on mac-mini in order: oikos stack's web service
  stopped+removed, oikos-web project brought up on 8091; outer Caddy
  untouched (targets the published port) — serving + Authentik flow +
  /wails 404 quirk verified post-cutover.
- Stripped from oikos: web/, cmd/desktop/, compose/web/, desktop CI
  workflow, ci.yml web job, Makefile ui/desktop/desktop-package/install
  targets, the compose web service, oikos-web from deploy.sh's fallback
  prune list; wails + go-keyring dropped from go.mod, vendor synced.
- README / CONTRIBUTING / AGENTS.md / .agents dev+operations docs now
  point at the new repo; mbse + mascot design docs carry a path note.

Risk: production SPA serving depends on the new pipeline now; rollback
is versioned-image re-up of the old web service from a pre-split
checkout (port 8091). Desktop builds installed before the split still
check dtoro/oikos releases — one manual reinstall, noted in the
oikos-web release notes.

Verification: go vet, make test (race), make generate-check, golangci
(no new findings; baseline down 400→365); post-cutover curls —
localhost:8091 200, /wails/runtime.js 404, outer Caddy 302 Authentik.
2026-08-15 22:27:52 +02:00

214 lines
5.4 KiB
JavaScript

let { Comment } = require('postcss')
let Parser = require('postcss/lib/parser')
let NestedDeclaration = require('./nested-declaration')
let scssTokenizer = require('./scss-tokenize')
class ScssParser extends Parser {
atrule(token) {
let name = token[1]
let prev = token
while (!this.tokenizer.endOfFile()) {
let next = this.tokenizer.nextToken()
if (next[0] === 'word' && next[2] === prev[3] + 1) {
name += next[1]
prev = next
} else {
this.tokenizer.back(next)
break
}
}
super.atrule(['at-word', name, token[2], prev[3]])
}
comment(token) {
if (token[4] === 'inline') {
let node = new Comment()
this.init(node, token[2])
node.raws.inline = true
let pos = this.input.fromOffset(token[3])
node.source.end = {
column: pos.col,
line: pos.line,
offset: token[3] + 1
}
let text = token[1].slice(2)
if (/^\s*$/.test(text)) {
node.text = ''
node.raws.left = text
node.raws.right = ''
} else {
let match = text.match(/^(\s*)([^]*\S)(\s*)$/)
let fixed = match[2].replace(/(\*\/|\/\*)/g, '*//*')
node.text = fixed
node.raws.left = match[1]
node.raws.right = match[3]
node.raws.text = match[2]
}
} else {
super.comment(token)
}
}
createTokenizer() {
this.tokenizer = scssTokenizer(this.input)
}
raw(node, prop, tokens, customProperty) {
super.raw(node, prop, tokens, customProperty)
if (node.raws[prop]) {
let scss = node.raws[prop].raw
node.raws[prop].raw = tokens.reduce((all, i) => {
if (i[0] === 'comment' && i[4] === 'inline') {
let text = i[1].slice(2).replace(/(\*\/|\/\*)/g, '*//*')
return all + '/*' + text + '*/'
} else {
return all + i[1]
}
}, '')
if (scss !== node.raws[prop].raw) {
node.raws[prop].scss = scss
}
}
}
rule(tokens) {
let withColon = false
let brackets = 0
let value = ''
for (let i of tokens) {
if (withColon) {
if (i[0] !== 'comment' && i[0] !== '{') {
value += i[1]
}
} else if (i[0] === 'space' && i[1].includes('\n')) {
break
} else if (i[0] === '(') {
brackets += 1
} else if (i[0] === ')') {
brackets -= 1
} else if (brackets === 0 && i[0] === ':') {
withColon = true
}
}
if (!withColon || value.trim() === '' || /^[#:A-Za-z-]/.test(value)) {
super.rule(tokens)
} else {
tokens.pop()
let node = new NestedDeclaration()
this.init(node, tokens[0][2])
let last
for (let i = tokens.length - 1; i >= 0; i--) {
if (tokens[i][0] !== 'space') {
last = tokens[i]
break
}
}
if (last[3]) {
let pos = this.input.fromOffset(last[3])
node.source.end = {
column: pos.col,
line: pos.line,
offset: last[3] + 1
}
} else {
let pos = this.input.fromOffset(last[2])
node.source.end = {
column: pos.col,
line: pos.line,
offset: last[2] + 1
}
}
while (tokens[0][0] !== 'word') {
node.raws.before += tokens.shift()[1]
}
if (tokens[0][2]) {
let pos = this.input.fromOffset(tokens[0][2])
node.source.start = {
column: pos.col,
line: pos.line,
offset: tokens[0][2]
}
}
node.prop = ''
while (tokens.length) {
let type = tokens[0][0]
if (type === ':' || type === 'space' || type === 'comment') {
break
}
node.prop += tokens.shift()[1]
}
node.raws.between = ''
let token
while (tokens.length) {
token = tokens.shift()
if (token[0] === ':') {
node.raws.between += token[1]
break
} else {
node.raws.between += token[1]
}
}
if (node.prop[0] === '_' || node.prop[0] === '*') {
node.raws.before += node.prop[0]
node.prop = node.prop.slice(1)
}
node.raws.between += this.spacesAndCommentsFromStart(tokens)
this.precheckMissedSemicolon(tokens)
for (let i = tokens.length - 1; i > 0; i--) {
token = tokens[i]
if (token[1] === '!important') {
node.important = true
let string = this.stringFrom(tokens, i)
string = this.spacesFromEnd(tokens) + string
if (string !== ' !important') {
node.raws.important = string
}
break
} else if (token[1] === 'important') {
let cache = tokens.slice(0)
let str = ''
for (let j = i; j > 0; j--) {
let type = cache[j][0]
if (str.trim().indexOf('!') === 0 && type !== 'space') {
break
}
str = cache.pop()[1] + str
}
if (str.trim().indexOf('!') === 0) {
node.important = true
node.raws.important = str
tokens = cache
}
}
if (token[0] !== 'space' && token[0] !== 'comment') {
break
}
}
this.raw(node, 'value', tokens)
if (node.value.includes(':')) {
this.checkMissedSemicolon(tokens)
}
this.current = node
}
}
}
module.exports = ScssParser