Skip to main content
M

dimensions

marsian/dimensions

A Dimensions-style pixel ruler for the DSH built-in browser; four crosshair arms snap to the nearest element boundary and show the pixel size.

Install

dsh plugin --profile web add github:marsian/dimensions

README

dsh-browser-element-dimensions

Dimensions for the DSH Desktop built-in browser.

Ported from the open-source Dimensions extension by Felix Niklas (MIT). Icons are the original files.

Interaction

 [crosshair] [Dimensions]      ← browser toolbar, right after the element picker
                   ↓ click
        pointer becomes a crosshair
        four arms extend to the nearest block boundary
        each arm tip prints the pixel gap
                   ↓ Esc / click again
        off

Nothing is clicked to measure — moving the pointer is enough. This is the behaviour of the original extension: distances up/down/left/right until the arm hits a border.

What was ported and what changed

AspectOriginalHere
Iconimages/icon16.png etc.same files, shipped under images/
Interactioncrosshair, four arms, per-arm numberssame
ToggleAlt+D / toolbar clicktoolbar click (no global shortcut in DSH)
Boundary detectionscreenshot → grayscale → flood fill / threshold walk in a Web Workerlive DOM walk via document.elementsFromPoint
Alt = measure areaflood fill on pixelsnot implemented

Why the boundary detection differs: the original calls chrome.tabs.captureVisibleTab and processes the resulting bitmap. A DSH browser tab is an Electron <webview>; the plugin has no screenshot access. Walking the DOM gives the same visible result and is more accurate on real markup (it snaps to element boxes rather than to colour changes, which is what you actually want when debugging CSS).

Known consequence: on images and canvas the arms stop at the element edge, not at internal colour boundaries. The original could measure inside a mockup PNG; this cannot.

Scan algorithm

// outside-in: coarsely step 4px to find the change interval, then binary search
for (let d = 4; d <= MAX; d += 4) { if (at(d) !== el0) { hi = d; break; } lo = d; }
while (hi - lo > 1) { const m = (lo + hi) >> 1; if (at(m) !== el0) hi = m; else lo = m; }

Measured cost of all four arms: 0.1–5 ms on a real page.

Important: document.elementsFromPoint() returns top-most first. Using the last element of that array yields html, which makes every arm run to the viewport edge — that bug cost one release.

Install

cd ~/.dsh/profiles/desktop
DSH_APP="/Applications/DeepSeek Harness.app"
DSH_PNPM="$DSH_APP/Contents/Resources/runtime/primary-runtime/dependencies/pnpm/bin/pnpm.mjs"
"$DSH_APP/Contents/MacOS/DeepSeek Harness" --expose-internals "$DSH_PNPM" add \
  /Users/transwarp/Documents/GitLab/astro/audit/optimizer/tools/dsh-browser-element-dimensions

Then add dsh-browser-element-dimensions to dsh.profile.bundles in the profile package.json and restart.

Use the built-in pnpm (11.x), not the system one (10.x): the profile's node_modules is linked from store v11, and store v10 fails with ERR_PNPM_UNEXPECTED_STORE.

Pre-install check

node smoke-test.mjs

Verifies the dsh.client ↔ exports["./client"] contract (missing this makes the entire profile fail to boot), that both entry points load, and that apply() does not throw on a minimal cordis context.

Licence

MIT. Original extension © Felix Niklas — see LICENSE.

Related plugins