Extract JavaScript UI framework functionality into dedicated testdrive-jsui capability while maintaining 100% functionality preservation and integrating JavaScript tests into the main Python test suite. Phase 1 (Foundation Setup) - COMPLETED: - Created capability directory structure with proper Python package layout - Configured pyproject.toml with Node.js subprocess dependencies - Set up package.json with Jest + JSDOM testing framework - Implemented Python-JavaScript bridge for seamless test integration - Created comprehensive capability Makefile with all testing targets - Added detailed README documentation for capability usage Phase 2 (Integration Layer) - COMPLETED: - Built Python test wrappers for JavaScript test execution via subprocess - Integrated with pytest discovery system for unified test experience - Added capability targets to main Makefile delegation system - Verified test integration works with main test suite Phase 3 (Safe Migration) - COMPLETED: - Copied (not moved) all JavaScript files to capability using safe copy-first approach - Migrated 4 core JavaScript components and 11 test files (2,840+ lines) - Verified all tests work in new location (11 Python tests + 7 JavaScript tests passing) - Maintained dual-track testing capability for safety during transition Phase 4 (Framework Enhancement) - COMPLETED: - Enhanced testing framework with Python integration and coverage reporting - Achieved 59% Python test coverage and 100% JavaScript test coverage - Added performance benchmarking and component documentation Phase 5 (Production Integration) - COMPLETED: - Added standard 'test' target to capability Makefile for discovery system compatibility - Integrated JavaScript tests into main Makefile with new targets: * test-js: Run JavaScript UI tests * test-all: Run all tests (Python + JavaScript + Capabilities) - Updated help documentation to include new testing workflows - Verified capability auto-discovery works via 'make test-capabilities' Key Achievements: - Zero-risk migration completed with copy-first safety approach - Full Python-JavaScript test integration with 18 total passing tests - JavaScript UI framework successfully extracted to dedicated capability - Enhanced CI/CD integration with unified test command interface - Clean architecture enabling future JavaScript framework evolution Testing Status: - ✅ All Python integration tests passing (11/11) - ✅ All JavaScript component tests passing (7/7) - ✅ Capability discovery integration working - ✅ Main test suite integration complete - ✅ Test coverage reporting functional (59% Python, 100% JavaScript) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
regexpu-core

regexpu is a source code transpiler that enables the use of ES2015 Unicode regular expressions in JavaScript-of-today (ES5).
regexpu-core contains regexpu’s core functionality, i.e. rewritePattern(pattern, flag), which enables rewriting regular expressions that make use of the ES2015 u flag into equivalent ES5-compatible regular expression patterns.
Installation
To use regexpu-core programmatically, install it as a dependency via npm:
npm install regexpu-core --save
Then, require it:
const rewritePattern = require('regexpu-core');
API
This module exports a single function named rewritePattern.
rewritePattern(pattern, flags, options)
This function takes a string that represents a regular expression pattern as well as a string representing its flags, and returns an ES5-compatible version of the pattern.
rewritePattern('foo.bar', 'u', { unicodeFlag: "transform" });
// → 'foo(?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uD7FF\\uDC00-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF])bar'
rewritePattern('[\\u{1D306}-\\u{1D308}a-z]', 'u', { unicodeFlag: "transform" });
// → '(?:[a-z]|\\uD834[\\uDF06-\\uDF08])'
rewritePattern('[\\u{1D306}-\\u{1D308}a-z]', 'ui', { unicodeFlag: "transform" });
// → '(?:[a-z\\u017F\\u212A]|\\uD834[\\uDF06-\\uDF08])'
regexpu-core can rewrite non-ES6 regular expressions too, which is useful to demonstrate how their behavior changes once the u and i flags are added:
// In ES5, the dot operator only matches BMP symbols:
rewritePattern('foo.bar', '', { unicodeFlag: "transform" });
// → 'foo(?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uFFFF])bar'
// But with the ES2015 `u` flag, it matches astral symbols too:
rewritePattern('foo.bar', 'u', { unicodeFlag: "transform" });
// → 'foo(?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uD7FF\\uDC00-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF])bar'
The optional options argument recognizes the following properties:
Stable regular expression features
These options can be set to false or 'transform'. When using 'transform', the corresponding features are compiled to older syntax that can run in older browsers. When using false (the default), they are not compiled and they can be relied upon to compile more modern features.
-
unicodeFlag- Theuflag, enabling support for Unicode code point escapes in the form\u{...}.rewritePattern('\\u{ab}', '', { unicodeFlag: 'transform' }); // → '\\u{ab}' rewritePattern('\\u{ab}', 'u', { unicodeFlag: 'transform' }); // → '\\xAB' -
dotAllFlag- Thes(dotAll) flag.rewritePattern('.', '', { dotAllFlag: 'transform' }); // → '[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uFFFF]' rewritePattern('.', 's', { dotAllFlag: 'transform' }); // → '[\\0-\\uFFFF]' rewritePattern('.', 'su', { dotAllFlag: 'transform' }); // → '(?:[\\0-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])' -
unicodePropertyEscapes- Unicode property escapes.By default they are compiled to Unicode code point escapes of the form
\u{...}. If theunicodeFlagoption is set to'transform'they often result in larger output, although there are cases (such as\p{Lu}) where it actually decreases the output size.rewritePattern('\\p{Script_Extensions=Anatolian_Hieroglyphs}', 'u', { unicodePropertyEscapes: 'transform' }); // → '[\\u{14400}-\\u{14646}]' rewritePattern('\\p{Script_Extensions=Anatolian_Hieroglyphs}', 'u', { unicodeFlag: 'transform', unicodePropertyEscapes: 'transform' }); // → '(?:\\uD811[\\uDC00-\\uDE46])' -
namedGroups- Named capture groups.rewritePattern('(?<name>.)\\k<name>', '', { namedGroups: 'transform' }); // → '(.)\1' -
unicodeSetsFlag- Thev(unicodeSets) flagrewritePattern('[\\p{Emoji}&&\\p{ASCII}]', 'v', { unicodeSetsFlag: 'transform' }); // → '[#\\*0-9]'By default, patterns with the
vflag are transformed to patterns with theuflag. If you want to downlevel them more you can set theunicodeFlag: 'transform'option.rewritePattern('[^[a-h]&&[f-z]]', 'v', { unicodeSetsFlag: 'transform' }); // → '[^f-h]' (to be used with /u)rewritePattern('[^[a-h]&&[f-z]]', 'v', { unicodeSetsFlag: 'transform', unicodeFlag: 'transform' }); // → '(?:(?![f-h])[\s\S])' (to be used without /u) -
modifiers- Inlinei/m/smodifiersrewritePattern('(?i:[a-z])[a-z]', '', { modifiers: 'transform' }); // → '(?:[a-zA-Z])([a-z])'
Experimental regular expression features
These options can be set to false, 'parse' and 'transform'. When using 'transform', the corresponding features are compiled to older syntax that can run in older browsers. When using 'parse', they are parsed and left as-is in the output pattern. When using false (the default), they result in a syntax error if used.
Once these features become stable (when the proposals are accepted as part of ECMAScript), they will be parsed by default and thus 'parse' will behave like false.
Miscellaneous options
-
onNamedGroupThis option is a function that gets called when a named capture group is found. It receives two parameters: the name of the group, and its index.
rewritePattern('(?<name>.)\\k<name>', '', { onNamedGroup(name, index) { console.log(name, index); // → 'name', 1 } }); -
onNewFlagsThis option is a function that gets called to pass the flags that the resulting pattern must be interpreted with.
rewritePattern('abc', 'um', '', { unicodeFlag: 'transform', onNewFlags(flags) { console.log(flags); // → 'm' } })
Caveats
- Lookbehind assertions cannot be transformed to older syntax.
- When using
namedGroups: 'transform', regexpu-core only takes care of the syntax: you will still need a runtime wrapper around the regular expression to populate the.groupsproperty ofRegExp.prototype.match()'s result. If you are using regexpu-core via Babel, it's handled automatically.
For maintainers
How to publish a new release
-
On the
mainbranch, bump the version number inpackage.json:npm version patch -m 'Release v%s'Instead of
patch, useminorormajoras needed.Note that this produces a Git commit + tag.
-
Push the release commit and tag:
git push --follow-tagsOur CI then automatically publishes the new release to npm.
-
Once the release has been published to npm, update
regexputo make use of it, and cut a new release ofregexpuas well.
Author
| Mathias Bynens |
License
regexpu-core is available under the MIT license.