Skip to content

feat(dnd): run dnd on the plugin host API (host.watch, value/sealed delivery, implicit-variable contract) - #101

Merged
ErickXavier merged 6 commits into
mainfrom
feat/dnd-host-api-spike
Oct 13, 2026
Merged

ErickXavier merged 6 commits into
mainfrom
feat/dnd-host-api-spike

Conversation

@ErickXavier

Copy link
Copy Markdown
Collaborator

Summary

Draft — lands with the NoJS-Server P6 work and the next lockstep release; do not merge standalone.

  • src/_host.js (new): dual-backend adapter — core-backed (CDN) and compiled-backed (NoJS-Server host API).
  • dnd runs on the host API: drag math, placeholder and pointer tracking stay client-side; the drop statement compiles to a server action with $drag/$dropIndex/$dragType/$dragEffect as schema-validated payload (ADR-021). src/dnd/contract.js declares the attrs contract.
  • Fixes found on the way: init-hook re-bind of nodes already bound to a live context killed an each inside a drop zone (8e746ca); dnd expressions are captured at init, not re-read from the DOM at event time (6e4e795, security); drag-over state cleared when a morph disables the drop zone.
  • Tests: __tests__/dnd-host.test.js (new), updates to install-rebind and dnd; jest 518 passed / 5 skipped; e2e chromium 145/145 (dnd 20/20). dist/ rebuilt.

Pairs with NoJS-Server feat/host-watch-dnd-spike (parity fixture dnd-reorder green under CDN core and compiled). Genesis: SRV-18.

The plugin init hook re-bound every [drag]/[drop] node core had
already walked, disposing and re-processing its subtree. An `each`
loop inside a [drop] zone lost its template and stopped re-rendering,
so reorders updated state but not the list.

- record the context each real dnd directive binds against
- re-bind only nodes bound to a stub or an orphan context
One package, two backends (ADR-021 dual-backend adapter). Under core the
directives behave as before; under a compiled site (registrar carries
`hostApi`) they do DOM mechanics only:

- drag: echoes the server-sealed `drag` token as $drag, reads it at
  dragstart; drag-disabled is a delivered value, watched via host.watch
- drop: reports the implicit variables to host.exec(bindingKey, payload)
  (serializable members only); drop-disabled/drop-max delivered values
- shared mechanics (placeholder, index math, classes, a11y, keyboard)
  are the same code for both backends
- plugin exposes `contract` (attr typing + implicit vars) for the compiler
- unmigrated directives register warn stubs on compiled sites instead of
  crashing or staying silently inert
The dual-backend refactor made the core backends re-read drag-disabled,
drop-disabled and drop-max from the DOM on every drag event and pass
the current text to NoJS.evaluate. Any later write to those attributes
(bound attribute, third-party script, injected markup) would then be
evaluated as an expression. Restore init-time capture, as before the
refactor. The host backend only JSON-decodes delivered values.
Host backend watches drop-disabled (host.watch): a server morph that
disables the zone mid-drag removes the drag-over/reject classes and the
placeholder; the next dragover recomputes.
Core binds null for both when the source is a `drag` element; the host
contract's server-bound list members must match.
@ErickXavier
ErickXavier marked this pull request as ready for review October 13, 2026 03:34
@ErickXavier ErickXavier changed the title feat(dnd): run drag and drop on the NoJS-Server host API (dual backend) feat(dnd): run dnd on the plugin host API (host.watch, value/sealed delivery, implicit-variable contract) Oct 13, 2026
@ErickXavier
ErickXavier merged commit 76a3f89 into main Oct 13, 2026
2 checks passed
@ErickXavier
ErickXavier deleted the feat/dnd-host-api-spike branch October 13, 2026 03:35
ErickXavier added a commit that referenced this pull request Oct 15, 2026
chore: reapply October PRs (#101, #102, #103) onto release-1.22
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