UNPKG

@pho9ubenaa/remark-mask-text-beta

Version:

A remark plugin to mask text content with block characters

158 lines 5.12 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 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 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 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 const ERROR_MESSAGES = { DELIMITER_EMPTY: "Delimiter cannot be empty", DELIMITER_WHITESPACE: "Delimiter cannot contain only whitespace", DELIMITER_TOO_LONG: "Delimiter is too long", MASK_CHAR_EMPTY: "Mask character cannot be empty", MASK_CHAR_MULTIPLE: "Mask character must be exactly one character", 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 const ERROR_DETAILS = { DELIMITER_REQUIRED: "A non-empty delimiter string is required for mask processing", DELIMITER_WHITESPACE_ISSUE: "Whitespace-only delimiters would be difficult to distinguish in text", MASK_CHAR_REQUIRED: "A non-empty mask character is required", 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 const NODE_TYPES = { TEXT: "text", HTML: "html", 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 const ERROR_TYPES = { AST_TRANSFORMATION_ERROR: "AST_TRANSFORMATION_ERROR", INVALID_NODE_STRUCTURE: "INVALID_NODE_STRUCTURE", REGEX_PROCESSING_ERROR: "REGEX_PROCESSING_ERROR", INVALID_DELIMITER: "INVALID_DELIMITER", 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 const NODE_PROPERTIES = { TYPE: "type", VALUE: "value", CHILDREN: "children", URL: "url", }; /** * Plugin metadata constants * * Why (Business Logic Background): * - Consistent plugin identification in logs * - Centralized management of plugin naming */ export const PLUGIN_METADATA = { NAME: "[remark-mask-text]", }; /** * Formatting constants used in AST manipulation * * Why (Business Logic Background): * - Centralize formatting strings * - Make formatting consistent across the codebase */ export const FORMATTING = { NODE_PATH_SEPARATOR: " -> ", 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 const NUMERIC_LIMITS = { ERROR_CONTEXT_MAX_LENGTH: 50, DEFAULT_CACHE_SIZE: 100, }; /** * Regular expression flags * * Why (Business Logic Background): * - Centralize regex flag definitions * - Document the purpose of flags used */ export const REGEX_FLAGS = { GLOBAL: "g", }; //# sourceMappingURL=constants.js.map