Skip to content

Refactor type system to introduce framework-agnostic core layer#102

Merged
Nowely merged 23 commits intonextfrom
update-inner-types
Nov 16, 2025
Merged

Refactor type system to introduce framework-agnostic core layer#102
Nowely merged 23 commits intonextfrom
update-inner-types

Conversation

@Nowely
Copy link
Owner

@Nowely Nowely commented Nov 16, 2025

Introduce framework-agnostic core types and improve type system organization

This refactoring establishes a clear separation between framework-agnostic
core types (CoreOption, CoreMarkputProps) and framework-specific implementations
(Option, MarkedInputProps). Property names have been clarified to better
communicate their purpose.

Breaking Changes:

  • Rename Option.trigger → Option.overlayTrigger
  • Rename MarkedInputProps.trigger → MarkedInputProps.showOverlayOn
  • Rename InnerOption → CoreOption
  • Rename InnerMarkedInputProps → CoreMarkputProps
  • Rename DEFAULT_TRIGGER → DEFAULT_OVERLAY_TRIGGER
  • Restructure Store internal organization (advanced usage only)
  • Remove internal APIs from public exports

New Features:

  • CoreOption and CoreMarkputProps for framework-agnostic usage
  • Parser now accepts undefined markups for conditional configurations
  • Store now generic with proper type inference
  • Enhanced JSDoc documentation throughout
  • Improved Store domain organization

Improvements:

  • Consolidated parsing exports under single namespace
  • Simplified ref management in Store
  • Added change detection to Store proxy
  • Better separation between public API and internal implementation

Nowely and others added 13 commits November 16, 2025 01:14
### Summary

This commit refactors the `MarkedInput` component to utilize a new type, `CoreMarkputProps`, replacing the previous `InnerMarkedInputProps`. This change enhances type safety and clarity in the component's props. Additionally, the `Store` class and related functions have been updated to accommodate the new props structure, ensuring consistency across the codebase.

### Key Changes

- Replaced `InnerMarkedInputProps` with `CoreMarkputProps` in relevant files.
- Updated `parseProps` function to transform props into the new structure.
- Adjusted `Store` and `StoreProvider` to work with the new props type.
- Enhanced type definitions for better clarity and maintainability.

### Impact

This refactor improves the overall type safety and maintainability of the code, aligning with the recent changes in the core API.
### Summary

This commit refactors the `Store` class to simplify the handling of references for `container` and `overlay`. The previous `Ref` interface has been removed in favor of direct assignment, enhancing clarity and reducing complexity. Additionally, various components and hooks have been updated to reflect these changes, ensuring consistent access to the new reference structure.

### Key Changes

- Removed the `Ref` interface and replaced it with direct null assignments for `container` and `overlay`.
- Updated `setContainer` and `setOverlay` methods for managing references.
- Adjusted all components and hooks that access `refs.container` and `refs.overlay` to align with the new structure.

### Impact

This refactor improves the readability and maintainability of the code by streamlining the reference management in the `Store` class.
### Summary

This commit refactors the `Store` class to consolidate the `focus` and `input` properties into a single `nodes` object. This change simplifies access to these properties across various components and hooks, enhancing code clarity and maintainability.

### Key Changes

- Merged `focus` and `input` properties into a `nodes` object within the `Store` class.
- Updated all components and hooks to reference the new `store.nodes` structure instead of the previous individual properties.

### Impact

This refactor improves the organization of the `Store` class and ensures consistent access to node references throughout the codebase, facilitating future enhancements and reducing potential errors.
### Summary

This commit refactors the `Store` class by reorganizing its properties into distinct domain sections, improving clarity and maintainability. The properties are now categorized into Utils, Config, Document, Navigation, UI, and Overlay domains.

### Key Changes

- Grouped properties into domain-specific sections for better organization.
- Maintained existing functionality while enhancing code readability.

### Impact

This refactor streamlines the `Store` class structure, making it easier to navigate and understand, which will facilitate future development and maintenance.
### Summary

This commit refactors the `MarkedInput` and `StoreProvider` components to improve the handling of props. The `parseProps` function is now utilized in `StoreProvider` to transform props before passing them to the `Store`, ensuring that the required properties are correctly set.

### Key Changes

- Removed the direct use of `parseProps` in `MarkedInput`, simplifying its props handling.
- Updated `StoreProvider` to apply `parseProps` on incoming props, enhancing type safety and consistency.
- Adjusted `StoreProps` to extend `MarkedInputProps`, ensuring all necessary properties are included.

### Impact

These changes enhance the clarity and maintainability of the code, ensuring that props are consistently processed and passed throughout the components.
### Summary

This commit refactors the `Container` component by removing the `mergeClassNames` and `mergeStyles` utility functions, directly applying the `className` and `style` props instead. Additionally, the `parseProps` function has been updated to utilize these utilities for better prop management.

### Key Changes

- Simplified `Container` component by directly using `className` and `style` props.
- Updated `parseProps` to merge class names and styles before returning `StoreProps`.

### Impact

These changes enhance the clarity and maintainability of the `Container` component and improve the overall props handling in the application.
…ated usages

### Summary

This commit modifies the `trigger` property in the `CoreMarkputProps` interface to be optional. Corresponding changes are made in the `useCheckTrigger` hook to handle the optional nature of `trigger`, ensuring that the code remains robust and avoids potential runtime errors.

### Key Changes

- Updated `trigger` in `CoreMarkputProps` to be optional.
- Adjusted the `useCheckTrigger` hook to use non-null assertion for `trigger`, ensuring compatibility with the new optional definition.
- Removed the `trigger` property from `StoreProps` to maintain consistency with the updated interface.

### Impact

These changes enhance the flexibility of the `CoreMarkputProps` interface and improve the overall type safety in the application, allowing for better handling of optional properties.
### Summary

This commit refactors the `InnerOption` type to `CoreOption` across various files, enhancing type clarity and consistency. The changes include updating type imports and adjusting function signatures to utilize the new `CoreOption` type.

### Key Changes

- Renamed `InnerOption` to `CoreOption` in type definitions and related files.
- Updated function parameters and return types to reflect the new `CoreOption` type.
- Adjusted default options and parser functions to ensure compatibility with the new type structure.

### Impact

These changes improve type safety and maintainability throughout the codebase, ensuring a more consistent approach to handling options in the core functionality.
### Summary

This commit updates the `Parser` and `MarkupRegistry` classes to handle undefined values in markup patterns, improving flexibility in markup processing. The constructor signatures are modified to accept arrays that can include `undefined`, and the descriptor generation logic is adjusted to preserve original indices while skipping undefined entries.

### Key Changes

- Updated `Parser` constructor to accept `(Markup | undefined)[]`.
- Modified `MarkupRegistry` to filter out undefined markups while preserving their indices in descriptors.
- Adjusted related documentation to reflect the new handling of undefined values in markup patterns.

### Impact

These changes enhance the robustness of the parsing system, allowing for more versatile markup definitions and improving overall code maintainability.
### Summary

This commit refactors the `StoreProvider` component to replace the `parseProps` function with a new `normalizeProps` function, enhancing the handling of incoming props. The `normalizeProps` function merges class names and styles, ensuring consistent application of default options and improving overall prop management.

### Key Changes

- Introduced `normalizeProps` function to handle props normalization.
- Removed the `parseProps` function and its references from the codebase.
- Updated `StoreProvider` to utilize the new normalization logic for better clarity and maintainability.

### Impact

These changes streamline the props handling in `StoreProvider`, improving type safety and ensuring that default values are correctly applied, which enhances the overall robustness of the component.
…rity

- Rename MarkedInputProps.trigger → showOverlayOn (events: 'change', 'selectionChange')
- Rename Option.trigger → overlayTrigger (symbols: '@', '#', etc.)
- Rename CoreMarkputProps.trigger → showOverlayOn
- Rename CoreOption.trigger → overlayTrigger
- Rename DEFAULT_TRIGGER → DEFAULT_OVERLAY_TRIGGER
- Update all internal usages in components, utilities, tests, and stories
- Fixes naming duplication where 'trigger' was used for different purposes

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
- Introduced an IMMUTABLE_KEYS set to define properties that cannot be modified directly.
- Updated the set function to check against this set, enhancing clarity and preventing unintended mutations.
- Improved type safety by specifying the types of parameters in the set function.

These changes enhance the robustness of the Store class by ensuring that certain properties remain immutable, which contributes to better state management.
…ity and readability

- Updated TriggerFinder.find method to handle undefined options, returning early if no options are provided.
- Refactored Container component to streamline JSX structure by consolidating props into a single line for better readability.
- Adjusted useTrigger hook to align with the updated TriggerFinder method, ensuring consistent handling of options.

These changes improve the robustness of the TriggerFinder functionality and enhance the clarity of the Container component's rendering logic.
@vercel
Copy link

vercel bot commented Nov 16, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
marked-input Ready Ready Preview Comment Nov 16, 2025 5:39pm

… unused code

- Updated the `index.ts` file to export `toString` from the new `ParserV2` location, enhancing modularity.
- Removed the `toString` utility and its tests from the `text-manipulation` feature, as it is now handled by `ParserV2`.
- Adjusted the import paths in `deleteMark.ts` to reflect the new structure.

These changes improve the organization of the codebase and eliminate redundancy in the text manipulation utilities.
- Expanded the CoreOption interface to include comprehensive JSDoc comments for the `markup`, `overlayTrigger`, and `data` properties, clarifying their usage and providing examples.
- Updated the Option interface to inherit from CoreOption, emphasizing its React-specific functionality and including additional documentation for better understanding.

These changes improve the clarity and usability of the CoreOption and Option types, facilitating better integration and implementation in the codebase.
- Introduced a new `Tabs` component that allows users to create a tabbed interface with customizable tabs and active state management.
- Implemented the `useTab` hook to manage the active tab state and provide a convenient way to render the `Tabs` component.
- Updated the `index.ts` file to export the new components and hook for easy access.

These additions enhance the UI capabilities of the application by providing a reusable tabbed navigation component, improving user experience and organization of content.
…nput components

- Modified the Nested stories to utilize the new `useTab` hook for managing tabbed navigation.
- Updated the rendering logic to switch between `MarkdownInput` and `MarkedInput` based on the active tab, enhancing user interaction.
- Improved the structure of the component to ensure a clear distinction between preview and write modes.

These changes enhance the usability of the Nested stories by providing a more organized and interactive interface for users.
…lity

- Updated the rendering of the `MarkedInput` component in the `ComplexHtmlDocument` story to enhance code clarity by formatting the props across multiple lines.
- Ensured consistent spacing and structure for better maintainability.

These changes improve the overall readability of the Nested stories, making it easier for developers to understand the component's usage.
- Removed unused DEFAULT_OPTIONS import from the useTrigger hook, simplifying the code and improving clarity.
- This change enhances the maintainability of the overlay feature by reducing unnecessary dependencies.
- Consolidated parsing-related exports into a single index file, removing the deprecated ParserV2 structure.
- Updated import paths across the codebase to reflect the new organization, enhancing modularity and maintainability.
- Improved documentation comments for better understanding of the public API for parsing and text manipulation.

These changes streamline the parsing module, making it easier for developers to access and utilize the parsing functionalities.
@Nowely Nowely changed the title Update inner types Refactor type system to introduce framework-agnostic core layer Nov 16, 2025
…duce framework-agnostic types

- Renamed `trigger` to `overlayTrigger` in the documentation to align with recent code changes.
- Added a new section for framework-agnostic core types, detailing `CoreOption` and `CoreMarkputProps` for better integration.
- Included a migration guide to assist developers in updating their code to accommodate the new property names.

These updates enhance the clarity of the README and provide essential information for users transitioning to the new API structure.
…cus on current features. This change enhances clarity by eliminating outdated instructions related to property renaming.
…e documentation. This change enhances clarity by focusing on the React-specific `Option` interface and its functionality, eliminating outdated information that may confuse users.
@Nowely Nowely merged commit 9be8786 into next Nov 16, 2025
7 checks passed
@Nowely Nowely deleted the update-inner-types branch November 16, 2025 17:41
Nowely added a commit that referenced this pull request Nov 16, 2025
Introduce framework-agnostic core types and improve type system
organization

This refactoring establishes a clear separation between
framework-agnostic
core types (CoreOption, CoreMarkputProps) and framework-specific
implementations
(Option, MarkedInputProps). Property names have been clarified to better
communicate their purpose.

Breaking Changes:
- Rename Option.trigger → Option.overlayTrigger
- Rename MarkedInputProps.trigger → MarkedInputProps.showOverlayOn
- Rename InnerOption → CoreOption
- Rename InnerMarkedInputProps → CoreMarkputProps
- Rename DEFAULT_TRIGGER → DEFAULT_OVERLAY_TRIGGER
- Restructure Store internal organization (advanced usage only)
- Remove internal APIs from public exports

New Features:
- CoreOption and CoreMarkputProps for framework-agnostic usage
- Parser now accepts undefined markups for conditional configurations
- Store now generic with proper type inference
- Enhanced JSDoc documentation throughout
- Improved Store domain organization

Improvements:
- Consolidated parsing exports under single namespace
- Simplified ref management in Store
- Added change detection to Store proxy
- Better separation between public API and internal implementation

---------
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