mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 12:57:42 +08:00
chore: cleanup
This commit is contained in:
15
packages/core/module-name-resolver/index.d.ts
vendored
15
packages/core/module-name-resolver/index.d.ts
vendored
@ -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;
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user