mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(core): circular imports of SDK_VERSION
This commit is contained in:
@@ -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;
|
||||
|
||||
1
packages/core/utils/constants.android.ts
Normal file
1
packages/core/utils/constants.android.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const SDK_VERSION = android.os.Build.VERSION.SDK_INT;
|
||||
1
packages/core/utils/constants.d.ts
vendored
Normal file
1
packages/core/utils/constants.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export const SDK_VERSION: number;
|
||||
1
packages/core/utils/constants.ios.ts
Normal file
1
packages/core/utils/constants.ios.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const SDK_VERSION = parseFloat(UIDevice.currentDevice.systemVersion);
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
9
packages/core/utils/index.d.ts
vendored
9
packages/core/utils/index.d.ts
vendored
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user