Skip to content

fix: run Lattish on non-DOM hosts (the tish VM, AppKit) - #18

Merged
spacedevin merged 1 commit into
mainfrom
fix/non-dom-hosts
Oct 5, 2026
Merged

spacedevin merged 1 commit into
mainfrom
fix/non-dom-hosts

Conversation

@spacedevin

Copy link
Copy Markdown
Member

Moo renders @moo/ui plugin views with Lattish inside a capability-free tish VM, and its launcher UI through an AppKit host. Neither has a DOM, so four browser assumptions broke:

  • Component ids. fnIdString stashed _lattishFnId on the component function. Tish functions don't accept property writes, and Map has no function keys, so ids now live in a small identity table (one entry per component type).
  • Scheduling. Flushes and effects always used queueMicrotask. A host config can now provide schedule(cb) to run them on its own loop (an AppKit run loop, a plugin VM's thread). The DOM host doesn't set it, so it keeps using microtasks.
  • Profiling. The perf hooks and the __lattishSetStateProbe read window directly. They now go through activeHost.profiler(), which the DOM host defines as window when it exists, so browser behaviour is the same.
  • undefined. Comparisons against the undefined global became typeof x === "undefined", which works on every tish backend.

Tests: tish test test/jsx-runtime.test.tish passes 5/5, and npm run test:dom passes. The Lattish patch failed, remount line in the DOM run is printed on main too.

- Component ids live in an identity table instead of a property on the function: tish functions
  don't accept property writes and Map has no function keys.
- A host config may provide schedule(cb) for deferred flushes and effects; the DOM host keeps
  queueMicrotask.
- Profiling and the setState probe read from activeHost.profiler() instead of window.
- typeof x === "undefined" instead of comparing to the undefined global.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@spacedevin
spacedevin merged commit 2ca8a67 into main Oct 5, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant