Skip to content

Fix issue #43: Export lexical variable getter and setter blocks from core#85

Open
SurbhiAgarwal1 wants to merge 2 commits intomit-cml:mainfrom
SurbhiAgarwal1:fix-issue-43
Open

Fix issue #43: Export lexical variable getter and setter blocks from core#85
SurbhiAgarwal1 wants to merge 2 commits intomit-cml:mainfrom
SurbhiAgarwal1:fix-issue-43

Conversation

@SurbhiAgarwal1
Copy link

@SurbhiAgarwal1 SurbhiAgarwal1 commented Feb 11, 2026

Summary

Fixes #43

This PR exports the lexical_variable_get and lexical_variable_set block definitions from the core module, making them available to developers who import the plugin.

Tasks Completed:

  • Export lexical_variable_get block definition from variable-get-set.js
  • Export lexical_variable_set block definition from variable-get-set.js
  • Import blocks in core.js to ensure automatic registration
  • Add blocks as static properties on LexicalVariablesPlugin class
  • Re-export blocks from main index.js entry point
  • Add idempotent registration guard (prevents duplicate registration)
  • Update README.md with usage documentation
  • Verify all tests pass (4/4 VariableGetSet tests passing)
  • Build succeeds without errors

Why This Change?

The core fields (FieldGlobalFlydown and FieldParameterFlydown) create XML that references these blocks. Previously, when developers imported only the core module, these blocks weren't available, causing issues. Now they're automatically registered and accessible.

Testing

  • ✅ All 4 VariableGetSet tests pass
  • ✅ Build succeeds without errors
  • ✅ No new test failures introduced
  • ✅ Blocks are registered idempotently (safe to import multiple times)

Usage Examples

// Blocks are automatically registered when importing
import {LexicalVariablesPlugin} from '@mit-app-inventor/blockly-block-lexical-variables';

// Access block definitions directly
import {lexical_variable_get, lexical_variable_set} from '@mit-app-inventor/blockly-block-lexical-variables';

// Or from the core module
import {LexicalVariablesPlugin} from '@mit-app-inventor/blockly-block-lexical-variables/core';
const getterBlock = LexicalVariablesPlugin.lexical_variable_get;
const setterBlock = LexicalVariablesPlugin.lexical_variable_set;

…s from core

- Export lexical_variable_get and lexical_variable_set block definitions
- Add blocks to core.js imports so they're available when importing core
- Add idempotent registration guard to prevent duplicate registration
- Export blocks from LexicalVariablesPlugin class for easy access
- Update README with documentation about exported blocks
- All VariableGetSet tests pass (4/4)

The blocks are now automatically registered when importing either the
core or main entry point, and are accessible via exports for developers
who need to customize or override them.
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.

Add lexical variable getter and setter blocks to core

1 participant