node_modules/svelte2tsx/index.js
/**
 * Returns a Svelte-compatible component name from a filename. Svelte
 * components must use capitalized tags, so we try to transform the filename.
 *
 * https://svelte.dev/docs#Tags
 */
Returns a Svelte-compatible component name from a filename. Svelte
components must use capitalized tags, so we try to transform the filename.


Returns a Svelte - compatible component name from a filename . Svelte components must use capitalized tags so we try to transform the filename .
function classNameFromFilename(filename, appendSuffix) {
    var _a;
    try {
        const withoutExtensions = (_a = path__default['default'].parse(filename).name) === null || _a === void 0 ? void 0 : _a.split('.')[0];
        const withoutInvalidCharacters = withoutExtensions
            .split('')
            .filter((char) => /[A-Za-z$_\d-]/.test(char))
            .join('');
        const firstValidCharIdx = withoutInvalidCharacters
            .split('')
            .findIndex((char) => /[A-Za-z]/.test(char));
        const withoutLeadingInvalidCharacters = withoutInvalidCharacters.substr(firstValidCharIdx);
        const inPascalCase = pascalCase.pascalCase(withoutLeadingInvalidCharacters);
        const finalName = firstValidCharIdx === -1 ? `A${inPascalCase}` : inPascalCase;
        return `${finalName}${appendSuffix ? COMPONENT_SUFFIX : ''}`;
    }
    catch (error) {
        console.warn(`Failed to create a name for the component class from filename ${filename}`);
        return undefined;
    }
}
function classNameFromFilename ( filename , appendSuffix ) { var _a ; try { const withoutExtensions = ( _a = path__default [ 'default' ] . parse ( filename ) . name ) === null || _a === void 0 ? void 0 : _a . split ( '.' ) [ 0 ] ; const withoutInvalidCharacters = withoutExtensions . split ( '' ) . filter ( ( char ) => / [A-Za-z$_\d-] / . test ( char ) ) . join ( '' ) ; const firstValidCharIdx = withoutInvalidCharacters . split ( '' ) . findIndex ( ( char ) => / [A-Za-z] / . test ( char ) ) ; const withoutLeadingInvalidCharacters = withoutInvalidCharacters . substr ( firstValidCharIdx ) ; const inPascalCase = pascalCase . pascalCase ( withoutLeadingInvalidCharacters ) ; const finalName = firstValidCharIdx === - 1 ? ` ${ inPascalCase } ` : inPascalCase ; return ` ${ finalName } ${ appendSuffix ? COMPONENT_SUFFIX : '' } ` ; } catch ( error ) { console . warn ( ` ${ filename } ` ) ; return undefined ; } }
Returns a Svelte-compatible component name from a filename.
Returns a Svelte - compatible component name from a filename .
// Although "-" is invalid, we leave it in, pascal-case-handling will throw it out later // Although _ and $ are valid first characters for classes, they are invalid first characters // for tag names. For a better import autocompletion experience, we therefore throw them out.