Skip to content

JSX ref forwarding + general-purpose Dart Node VS Code extension#66

Open
MelbourneDeveloper wants to merge 1 commit into
mainfrom
jsxvsix
Open

JSX ref forwarding + general-purpose Dart Node VS Code extension#66
MelbourneDeveloper wants to merge 1 commit into
mainfrom
jsxvsix

Conversation

@MelbourneDeveloper

Copy link
Copy Markdown
Owner

TLDR

Finish the JSX DSL by adding ref forwarding (with a cloneElement fix so ref/key survive >> recomposition) and rebrand the VS Code extension into a general-purpose "Dart Node" extension with four basic commands.

What Was Added?

  • JSX ref forwarding (packages/dart_node_react): optional ref: (a JsRef from createRef) on $div, $input, $button, $textarea, $a, $select, $form, $img, $video, $audio.
  • cloneElementWithRawChildren helper in react.dart (delegates to the existing clone machinery; no duplication).
  • vscode.version binding in dart_node_vsix.
  • Four general-purpose "Dart Node" extension commands: dartNode.hello (greeting), dartNode.showVersion (vscode.version), dartNode.echo (input box → message), dartNode.count (persisted run counter via globalState memento).
  • Tests: JSX ref leaf + recomposition tests; a globalState memento round-trip self-check + assertion.

What Was Changed or Deleted?

  • El recomposition now uses cloneElement instead of createElement. React 18 hoists ref/key out of props, so rebuilding from props dropped them whenever >> attached children; cloneElement preserves ref/key/props. This also fixes a latent key-drop on recomposition.
  • Fixed the Memento binding (extension_context.dart): get/update/keys now dispatch on the memento object via callMethod instead of unnamed @JS() externals that resolved to nonexistent globals (globalThis._mementoGet). The previous binding threw at runtime for any caller.
  • Rebranded the extension: dart-node-vsix-test / "Dart Node VSIX Test" → dart-node / "Dart Node"; ids dartNodeVsix.*dartNode.*; output channel / status bar / log labels → "Dart Node"; extensionId and package-lock.json name updated to match.
  • Deleted test/jsx/jsx_dsl_test.dart — a strict subset of jsx_test.dart (removes duplication).

How Do The Automated Tests Prove It Works?

  • packages/dart_node_react/test/jsx_test.dart (18 tests, Chrome): ref forwards to the rendered DOM node and ref survives recomposition when children are added with >> assert ref.jsRef.current is non-null after render — the second exercises the $button(ref:) >> 'Save' path that fails without the cloneElement fix. All existing DSL tests (text/nested/events/fragment/conditional/numeric/keys/spread/override) still pass.
  • packages/dart_node_vsix/test/suite/extension_activation_test.dart: globalState memento round-trips through the binding asserts the activation self-check wrote 7 and read it back. Because that round-trip runs inside activate, a broken memento binding fails activation and the entire suite — so the suite guards it.
  • packages/dart_node_vsix/test/suite/commands_test.dart: asserts all five dartNode.* commands are registered.
  • Additionally verified locally (make ci green across all three tiers): dart analyze and dart format clean; cspell clean; extension.dart compiles dart compile js -O2 with the memento dispatching globalState.get(...) / globalState.update(...) on the object (no global lookups).

Spec / Doc Changes

  • docs/plans/JSX_IMPLEMENTATION_PLAN.md: replaced "Open Questions"/"Next Steps" with Resolved Decisions, Phase Status, and a TODO checklist (Phase 1 shipped; later phases deferred).
  • packages/dart_node_vsix/README.md: added a "Bundled extension: Dart Node" section documenting the commands.

Breaking Changes

  • None for published package APIs. The library changes are additive (new optional ref params, new vscode.version getter) or bug fixes (the Memento binding now works). The id/manifest rename (dartNodeVsix.*dartNode.*, Nimblesite.dart-node-vsix-testNimblesite.dart-node) affects only the bundled demo extension (publish_to: none), not a published surface.

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