fix(core): circular imports of SDK_VERSION

This commit is contained in:
Nathan Walker
2022-11-30 09:10:11 -08:00
parent 55d24d30ce
commit 82d60ae057
28 changed files with 67 additions and 41 deletions

View File

@@ -74,6 +74,20 @@ export function isDataURI(uri: string): boolean {
return firstSegment && firstSegment.indexOf('data:') === 0 && firstSegment.indexOf('base64') >= 0;
}
/**
* Get file extension from file path
* @param path file path
* @returns file extension
*/
export function getFileExtension(path: string): string {
const dotIndex = path.lastIndexOf('.');
if (dotIndex && dotIndex >= 0 && dotIndex < path.length) {
return path.substring(dotIndex);
}
return '';
}
export function mergeSort(arr, compareFunc) {
if (arr.length < 2) {
return arr;

View File

@@ -0,0 +1 @@
export const SDK_VERSION = android.os.Build.VERSION.SDK_INT;

1
packages/core/utils/constants.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export const SDK_VERSION: number;

View File

@@ -0,0 +1 @@
export const SDK_VERSION = parseFloat(UIDevice.currentDevice.systemVersion);

View File

@@ -6,7 +6,7 @@ let applicationRootPath: string;
function ensureAppRootPath() {
if (!applicationRootPath) {
applicationRootPath = knownFolders.currentApp().path;
applicationRootPath = applicationRootPath.substr(0, applicationRootPath.length - 'app/'.length);
applicationRootPath = applicationRootPath.substring(0, applicationRootPath.length - 'app/'.length);
}
}
@@ -20,8 +20,8 @@ export class Source {
constructor(uri: string, line: number, column: number) {
ensureAppRootPath();
if (uri.length > applicationRootPath.length && uri.substr(0, applicationRootPath.length) === applicationRootPath) {
this._uri = 'file://' + uri.substr(applicationRootPath.length);
if (uri.length > applicationRootPath.length && uri.substring(0, applicationRootPath.length) === applicationRootPath) {
this._uri = 'file://' + uri.substring(applicationRootPath.length);
} else {
this._uri = uri;
}

View File

@@ -1,14 +1,13 @@
import { ad } from './native-helper';
import { FileSystemAccess } from '../file-system/file-system-access';
import { Trace } from '../trace';
import { getFileExtension } from './common';
import { SDK_VERSION } from './constants';
export { ad, dataDeserialize, dataSerialize, iOSNativeHelper } from './native-helper';
export * from './layout-helper';
export * from './common';
export { Source } from './debug';
export const SDK_VERSION = android.os.Build.VERSION.SDK_INT;
const MIN_URI_SHARE_RESTRICTED_APK_VERSION = 24;
export function GC() {
@@ -72,7 +71,7 @@ function isExternalStorageAvailable(): boolean {
*/
function getMimeTypeNameFromExtension(filePath: string): string {
const mimeTypeMap = android.webkit.MimeTypeMap.getSingleton();
const extension = new FileSystemAccess().getFileExtension(filePath).replace('.', '').toLowerCase();
const extension = getFileExtension(filePath).replace('.', '').toLowerCase();
return mimeTypeMap.getMimeTypeFromExtension(extension);
}

View File

@@ -11,8 +11,6 @@ export * from './common';
export const RESOURCE_PREFIX: string;
export const FILE_PREFIX: string;
export const SDK_VERSION: number;
//@private
/**
* Used by various android event listener implementations.
@@ -177,6 +175,13 @@ export function isFontIconURI(uri: string): boolean;
*/
export function isFileOrResourcePath(path: string): boolean;
/**
* Get file extension from file path
* @param path file path
* @returns file extension
*/
export function getFileExtension(path: string): string;
/**
* Returns true if the specified URI is data URI (http://en.wikipedia.org/wiki/Data_URI_scheme).
* @param uri The URI.

View File

@@ -6,8 +6,6 @@ export * from './layout-helper';
export * from './common';
export { Source } from './debug';
export const SDK_VERSION = parseFloat(UIDevice.currentDevice.systemVersion);
export function openFile(filePath: string): boolean {
try {
const appPath = iOSNativeHelper.getCurrentAppPath();