Files
oikos/web/node_modules/postcss/lib/fromJSON.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

108 lines
2.7 KiB
JavaScript

'use strict'
let AtRule = require('./at-rule')
let Comment = require('./comment')
let Declaration = require('./declaration')
let Input = require('./input')
let PreviousMap = require('./previous-map')
let Root = require('./root')
let Rule = require('./rule')
function hydrateInputs(json, inputs) {
if (!json.inputs) return inputs
return json.inputs.map(input => {
let inputHydrated = { ...input, __proto__: Input.prototype }
if (inputHydrated.map) {
inputHydrated.map = {
...inputHydrated.map,
__proto__: PreviousMap.prototype
}
}
return inputHydrated
})
}
function constructNode(json, inputs, children) {
let defaults = { ...json }
delete defaults.inputs
delete defaults.nodes
if (defaults.source) {
let { inputId, ...source } = defaults.source
defaults.source = source
if (inputId != null) {
defaults.source.input = inputs[inputId]
}
}
let node
if (defaults.type === 'root') {
node = new Root(defaults)
} else if (defaults.type === 'decl') {
node = new Declaration(defaults)
} else if (defaults.type === 'rule') {
node = new Rule(defaults)
} else if (defaults.type === 'comment') {
node = new Comment(defaults)
} else if (defaults.type === 'atrule') {
node = new AtRule(defaults)
} else {
throw new Error('Unknown node type: ' + json.type)
}
// Rehydrated children are attached after construction. Passing them
// through the container constructor would re-run insertion spacing
// normalization and overwrite each child's own `raws.before`.
if (children) {
node.nodes = children
for (let child of children) child.parent = node
}
return node
}
function fromJSON(json, inputs) {
if (Array.isArray(json)) return json.map(n => fromJSON(n))
// An explicit stack instead of recursive calls to survive deeply
// nested trees. Children are rehydrated before their parent node
// is constructed.
let result
let stack = [
{ childIndex: 0, children: [], inputs: hydrateInputs(json, inputs), json }
]
while (stack.length > 0) {
let frame = stack[stack.length - 1]
let jsonNodes = frame.json.nodes
if (jsonNodes && frame.childIndex < jsonNodes.length) {
let childJson = jsonNodes[frame.childIndex]
frame.childIndex += 1
stack.push({
childIndex: 0,
children: [],
inputs: hydrateInputs(childJson, frame.inputs),
json: childJson
})
continue
}
stack.pop()
let node = constructNode(
frame.json,
frame.inputs,
jsonNodes ? frame.children : undefined
)
if (stack.length > 0) {
stack[stack.length - 1].children.push(node)
} else {
result = node
}
}
return result
}
module.exports = fromJSON
fromJSON.default = fromJSON