chore: cleanup

This commit is contained in:
Nathan Walker
2025-07-22 19:06:58 -07:00
parent 0ba0ab0d59
commit b853447da2
16 changed files with 162 additions and 179 deletions

View File

@ -1,15 +0,0 @@
/**
* Provides ModuleNameResolver class used for loading files based on device capabilities.
*/ /** */
import type { PlatformContext } from './qualifier-matcher';
import type { ModuleListProvider } from './helpers';
export { PlatformContext } from './qualifier-matcher';
export class ModuleNameResolver {
constructor(context: PlatformContext, moduleListProvider?: ModuleListProvider);
resolveModuleName(path: string, ext: string): string;
clearCache(): void;
}
export function resolveModuleName(path: string, ext: string): string;

View File

@ -20,6 +20,7 @@ export class ModuleNameResolver implements ModuleNameResolverType {
let result: string = this._cache[key];
if (result === undefined) {
result = this.resolveModuleNameImpl(path, ext);
console.log('resolveModuleName result:', result);
this._cache[key] = result;
}
@ -43,13 +44,11 @@ export class ModuleNameResolver implements ModuleNameResolverType {
const candidates = this.getCandidates(path, ext);
result = findMatch(path, ext, candidates, this.context);
return result;
}
private getCandidates(path: string, ext: string): Array<string> {
const candidates = this.moduleListProvider().filter((moduleName) => moduleName.startsWith(path) && (!ext || moduleName.endsWith(ext)));
return candidates;
}
}

View File

@ -1,17 +0,0 @@
/**
* Provides ModuleNameResolver class used for loading files based on device capabilities.
*/
/**
* Used with qualifier matchers and module resolution
*/
export interface PlatformContext {
width: number;
height: number;
os: string;
deviceType: string;
}
export function findMatch(path: string, ext: string, candidates: Array<string>, context: PlatformContext): string;
export function stripQualifiers(path: string): string;

View File

@ -27,7 +27,7 @@ const minWidthHeightQualifier: QualifierSpec = {
return path.match(new RegExp(`.${MIN_WH}\\d+`, 'g'));
},
getMatchValue(value: string, context: PlatformContext): number {
const numVal = parseInt(value.substr(MIN_WH.length + 1));
const numVal = parseInt(value.substring(MIN_WH.length + 1));
if (isNaN(numVal)) {
return -1;
}
@ -49,7 +49,7 @@ const minWidthQualifier: QualifierSpec = {
return path.match(new RegExp(`.${MIN_W}\\d+`, 'g'));
},
getMatchValue(value: string, context: PlatformContext): number {
const numVal = parseInt(value.substr(MIN_W.length + 1));
const numVal = parseInt(value.substring(MIN_W.length + 1));
if (isNaN(numVal)) {
return -1;
}
@ -71,7 +71,7 @@ const minHeightQualifier: QualifierSpec = {
return path.match(new RegExp(`.${MIN_H}\\d+`, 'g'));
},
getMatchValue(value: string, context: PlatformContext): number {
const numVal = parseInt(value.substr(MIN_H.length + 1));
const numVal = parseInt(value.substring(MIN_H.length + 1));
if (isNaN(numVal)) {
return -1;
}
@ -93,7 +93,7 @@ const platformQualifier: QualifierSpec = {
return path.match(new RegExp('\\.android|\\.ios', 'g'));
},
getMatchValue(value: string, context: PlatformContext): number {
const val = value.substr(1);
const val = value.substring(1);
return val === context.os.toLowerCase() ? 1 : -1;
},
@ -107,7 +107,7 @@ const orientationQualifier: QualifierSpec = {
return path.match(new RegExp('\\.land|\\.port', 'g'));
},
getMatchValue(value: string, context: PlatformContext): number {
const val = value.substr(1);
const val = value.substring(1);
const isLandscape: number = context.width > context.height ? 1 : -1;
return val === 'land' ? isLandscape : -isLandscape;
@ -176,6 +176,8 @@ export function findMatch(path: string, ext: string, candidates: Array<string>,
result = candidates[i];
}
}
console.log(' > findMatch called with path:', path, 'and ext:', ext, 'candidates:', candidates, 'context:', context, '--- MATCH? result:', result);
console.log('. ');
return result;
}