UNPKG

@pho9ubenaa/remark-mask-text-beta

Version:

A remark plugin to mask text content with block characters

158 lines (157 loc) 5.42 kB
/** * Default configuration constants for remark-mask-text plugin * * These constants define the default behavior when no custom options * are provided to the plugin. They are chosen for maximum compatibility * and clarity across different languages and contexts. * * Why (Business Logic Background): * - Eliminate magic literals and clarify the intent of configuration values * - Enable centralized management when changing default values * - Improve code readability and maintainability * - Maintain consistency in multilingual and multicultural support */ /** * Default character used to mask text content * * The hash symbol (#) is chosen because: * - Universally recognized as a masking/redaction symbol * - Available on all keyboards and character sets * - Clear visual distinction from normal text * - Commonly used in privacy and security contexts */ export declare const DEFAULT_MASK_CHARACTER = "#"; /** * Default delimiter pattern for marking text to be masked * * The double colon (::) is chosen because: * - Low collision risk with standard Markdown syntax * - Visually distinct and easy to type * - Commonly used in various markup languages * - International keyboard compatibility */ export declare const DEFAULT_MASK_DELIMITER = "::"; /** * Maximum allowed length for delimiter strings * * Why (Business Logic Background): * - Prevent performance degradation due to extremely long delimiters * - Sufficient value as a practical delimiter length limit * - Keep regex compile time reasonable */ export declare const MAX_DELIMITER_LENGTH = 10; /** * Error messages for consistent user feedback * * Why (Business Logic Background): * - Maintain consistency of error messages * - Simplify management for internationalization support * - Limit impact scope when changing messages */ export declare const ERROR_MESSAGES: { readonly DELIMITER_EMPTY: "Delimiter cannot be empty"; readonly DELIMITER_WHITESPACE: "Delimiter cannot contain only whitespace"; readonly DELIMITER_TOO_LONG: "Delimiter is too long"; readonly MASK_CHAR_EMPTY: "Mask character cannot be empty"; readonly MASK_CHAR_MULTIPLE: "Mask character must be exactly one character"; readonly MASK_CHAR_WHITESPACE: "Mask character cannot be whitespace"; }; /** * Error details for enhanced debugging * * Why (Business Logic Background): * - Provide detailed information during debugging * - Enable developers to quickly identify error causes * - Provide consistent detailed messages */ export declare const ERROR_DETAILS: { readonly DELIMITER_REQUIRED: "A non-empty delimiter string is required for mask processing"; readonly DELIMITER_WHITESPACE_ISSUE: "Whitespace-only delimiters would be difficult to distinguish in text"; readonly MASK_CHAR_REQUIRED: "A non-empty mask character is required"; readonly MASK_CHAR_WHITESPACE_ISSUE: "Whitespace characters would not provide effective masking"; }; /** * Node type constants to eliminate magic literals * * Why (Business Logic Background): * - Eliminate magic literals and improve type safety * - Improve maintainability through centralized node type management * - Support IDE auto-completion and refactoring */ export declare const NODE_TYPES: { readonly TEXT: "text"; readonly HTML: "html"; readonly LINK: "link"; }; /** * Error type constants to eliminate magic literals * * Why (Business Logic Background): * - Centralized error type management * - Improve code quality by eliminating magic literals * - Ensure consistency in error handling */ export declare const ERROR_TYPES: { readonly AST_TRANSFORMATION_ERROR: "AST_TRANSFORMATION_ERROR"; readonly INVALID_NODE_STRUCTURE: "INVALID_NODE_STRUCTURE"; readonly REGEX_PROCESSING_ERROR: "REGEX_PROCESSING_ERROR"; readonly INVALID_DELIMITER: "INVALID_DELIMITER"; readonly INVALID_MASK_CHARACTER: "INVALID_MASK_CHARACTER"; }; /** * Node property names used in AST manipulation * * Why (Business Logic Background): * - Eliminate magic string literals for property names * - Prevent typos in property access * - Enable safe refactoring with IDE support */ export declare const NODE_PROPERTIES: { readonly TYPE: "type"; readonly VALUE: "value"; readonly CHILDREN: "children"; readonly URL: "url"; }; /** * Plugin metadata constants * * Why (Business Logic Background): * - Consistent plugin identification in logs * - Centralized management of plugin naming */ export declare const PLUGIN_METADATA: { readonly NAME: "[remark-mask-text]"; }; /** * Formatting constants used in AST manipulation * * Why (Business Logic Background): * - Centralize formatting strings * - Make formatting consistent across the codebase */ export declare const FORMATTING: { readonly NODE_PATH_SEPARATOR: " -> "; readonly TRUNCATION_SUFFIX: "..."; }; /** * Numeric limits used in processing * * Why (Business Logic Background): * - Make numeric limits configurable * - Document the purpose of each limit * - Easy to adjust limits if needed */ export declare const NUMERIC_LIMITS: { readonly ERROR_CONTEXT_MAX_LENGTH: 50; readonly DEFAULT_CACHE_SIZE: 100; }; /** * Regular expression flags * * Why (Business Logic Background): * - Centralize regex flag definitions * - Document the purpose of flags used */ export declare const REGEX_FLAGS: { readonly GLOBAL: "g"; };