Merge pull request #7061 from NativeScript/mdonev/release-to-master-7052

chore: merge release to master
This commit is contained in:
Manol Donev
2019-03-22 13:41:03 +02:00
committed by GitHub
3 changed files with 99 additions and 34 deletions

View File

@@ -1,3 +1,29 @@
<a name="5.3.0"></a>
# [5.3.0](https://github.com/NativeScript/NativeScript/compare/5.2.1...5.3.0) (2019-03-21)
### Bug Fixes
* **android:** resource ID not found on navigation between pages with nested and single frames ([#6955](https://github.com/NativeScript/NativeScript/issues/6955)) ([33d6d1f](https://github.com/NativeScript/NativeScript/commit/33d6d1f))
* **android:** navigation between pages with single and nested frames ([#7011](https://github.com/NativeScript/NativeScript/issues/7011)) ([91d90cc](https://github.com/NativeScript/NativeScript/commit/91d90cc))
* **http:** ensure httpcontent.toFile() creates intermediate directories ([#6451](https://github.com/NativeScript/NativeScript/issues/6451)) ([d7fb9b8](https://github.com/NativeScript/NativeScript/commit/d7fb9b8))
* WrappedValue.unwrap empty string behavior ([#6900](https://github.com/NativeScript/NativeScript/issues/6900)) ([0482460](https://github.com/NativeScript/NativeScript/commit/0482460))
* **android-bottom-tabs:** use immediate transition on programmatic selectedIndex change ([#6942](https://github.com/NativeScript/NativeScript/issues/6942)) ([e9dfa20](https://github.com/NativeScript/NativeScript/commit/e9dfa20))
* **ios:** disable default tab reselect behavior ([#6968](https://github.com/NativeScript/NativeScript/issues/6968)) ([043cbf3](https://github.com/NativeScript/NativeScript/commit/043cbf3))
* **ios-webview:** report hostname lookup errors in loadFinished event ([#6988](https://github.com/NativeScript/NativeScript/issues/6988)) ([e6486f6](https://github.com/NativeScript/NativeScript/commit/e6486f6))
* **ios-webview:** loading of local-file dependency ([#6947](https://github.com/NativeScript/NativeScript/issues/6947)) ([dcad754](https://github.com/NativeScript/NativeScript/commit/dcad754)), closes [/github.com/NativeScript/NativeScript/issues/6377#issuecomment-433322681](https://github.com//github.com/NativeScript/NativeScript/issues/6377/issues/issuecomment-433322681) [#6377](https://github.com/NativeScript/NativeScript/issues/6377)
* set/unset touchListener.owner onLoaded/onUnloaded ([#6922](https://github.com/NativeScript/NativeScript/issues/6922)) ([f056167](https://github.com/NativeScript/NativeScript/commit/f056167))
### Features
* local icon handling in actionbar and tabview ([#7009](https://github.com/NativeScript/NativeScript/issues/7009)) ([cd66300](https://github.com/NativeScript/NativeScript/commit/cd66300))
* **android:** add openFile to utils ([#6895](https://github.com/NativeScript/NativeScript/issues/6895)) ([f8eee40](https://github.com/NativeScript/NativeScript/commit/f8eee40))
* **hmr:** style views at runtime ([#7012](https://github.com/NativeScript/NativeScript/issues/7012)) ([3c2c1d9](https://github.com/NativeScript/NativeScript/commit/3c2c1d9))
* **hmr:** apply changes in page styles at runtime when app root is a frame ([#6857](https://github.com/NativeScript/NativeScript/issues/6857)) ([44b8acd](https://github.com/NativeScript/NativeScript/commit/44b8acd))
* **view** expose missing backgroundSize, backgroundRepeat, and backgroundPosition properties on View class ([#7032](https://github.com/NativeScript/NativeScript/issues/7032)) ([88f2242](https://github.com/NativeScript/NativeScript/commit/88f2242))
<a name="5.2.2"></a>
## [5.2.2](https://github.com/NativeScript/NativeScript/compare/5.2.1...5.2.2) (2019-03-01)

View File

@@ -1,14 +1,10 @@
/**
* Android specific http request implementation.
*/
import { fromNativeSource } from "../../image-source";
import { screen } from "../../platform";
import { File } from "../../file-system";
// imported for definition purposes only
import * as httpModule from "../../http";
import * as imageSourceModule from "../../image-source";
import * as platformModule from "../../platform";
import * as fsModule from "../../file-system";
import { getFilenameFromUrl } from "./http-request-common";
// this is imported for definition purposes only
import * as http from "../../http";
import { NetworkAgent } from "../../debugger/debugger";
export enum HttpResponseEncoding {
@@ -28,6 +24,27 @@ function parseJSON(source: string): any {
let requestIdCounter = 0;
const pendingRequests = {};
let imageSource: typeof imageSourceModule;
function ensureImageSource() {
if (!imageSource) {
imageSource = require("image-source");
}
}
let platform: typeof platformModule;
function ensurePlatform() {
if (!platform) {
platform = require("platform");
}
}
let fs: typeof fsModule;
function ensureFileSystem() {
if (!fs) {
fs = require("file-system");
}
}
let completeCallback: org.nativescript.widgets.Async.CompleteCallback;
function ensureCompleteCallback() {
if (completeCallback) {
@@ -55,7 +72,7 @@ function onRequestComplete(requestId: number, result: org.nativescript.widgets.A
}
// read the headers
const headers: http.Headers = {};
const headers: httpModule.Headers = {};
if (result.headers) {
const jHeaders = result.headers;
const length = jHeaders.size();
@@ -97,9 +114,11 @@ function onRequestComplete(requestId: number, result: org.nativescript.widgets.A
return parseJSON(str);
},
toImage: () => {
ensureImageSource();
return new Promise<any>((resolveImage, rejectImage) => {
if (result.responseAsImage != null) {
resolveImage(fromNativeSource(result.responseAsImage));
resolveImage(imageSource.fromNativeSource(result.responseAsImage));
}
else {
rejectImage(new Error("Response content may not be converted to an Image"));
@@ -107,13 +126,15 @@ function onRequestComplete(requestId: number, result: org.nativescript.widgets.A
});
},
toFile: (destinationFilePath: string) => {
ensureFileSystem();
if (!destinationFilePath) {
destinationFilePath = getFilenameFromUrl(callbacks.url);
}
let stream: java.io.FileOutputStream;
try {
// ensure destination path exists by creating any missing parent directories
const file = File.fromPath(destinationFilePath);
const file = fs.File.fromPath(destinationFilePath);
const javaFile = new java.io.File(destinationFilePath);
stream = new java.io.FileOutputStream(javaFile);
@@ -144,7 +165,7 @@ function onRequestError(error: string, requestId: number) {
}
}
function buildJavaOptions(options: http.HttpRequestOptions) {
function buildJavaOptions(options: httpModule.HttpRequestOptions) {
if (typeof options.url !== "string") {
throw new Error("Http request must provide a valid url.");
}
@@ -177,20 +198,23 @@ function buildJavaOptions(options: http.HttpRequestOptions) {
javaOptions.headers = arrayList;
}
ensurePlatform();
// pass the maximum available image size to the request options in case we need a bitmap conversion
javaOptions.screenWidth = screen.mainScreen.widthPixels;
javaOptions.screenHeight = screen.mainScreen.heightPixels;
const screen = platform.screen.mainScreen;
javaOptions.screenWidth = screen.widthPixels;
javaOptions.screenHeight = screen.heightPixels;
return javaOptions;
}
export function request(options: http.HttpRequestOptions): Promise<http.HttpResponse> {
export function request(options: httpModule.HttpRequestOptions): Promise<httpModule.HttpResponse> {
if (options === undefined || options === null) {
// TODO: Shouldn't we throw an error here - defensive programming
return;
}
return new Promise<http.HttpResponse>((resolve, reject) => {
return new Promise<httpModule.HttpResponse>((resolve, reject) => {
try {
// initialize the options
const javaOptions = buildJavaOptions(options);
@@ -228,7 +252,7 @@ function decodeResponse(raw: any, encoding?: HttpResponseEncoding) {
return raw.toString(charsetName)
}
export function addHeader(headers: http.Headers, key: string, value: string): void {
export function addHeader(headers: httpModule.Headers, key: string, value: string): void {
if (!headers[key]) {
headers[key] = value;
} else if (Array.isArray(headers[key])) {

View File

@@ -1,18 +1,15 @@
/**
* iOS specific http request implementation.
*/
// imported for definition purposes only
import * as httpModule from "../../http";
import * as imageSourceModule from "../../image-source";
import * as fsModule from "../../file-system";
import { HttpRequestOptions, HttpResponse, Headers } from "../../http";
import * as types from "../../utils/types";
import { fromNativeSource } from "../../image-source";
import { File } from "../../file-system";
import * as utils from "../../utils/utils";
import getter = utils.ios.getter;
import * as domainDebugger from "../../debugger/debugger";
import { getFilenameFromUrl } from "./http-request-common";
const getter = utils.ios.getter;
export enum HttpResponseEncoding {
UTF8,
GBK
@@ -59,8 +56,22 @@ function ensureSessionNotFollowingRedirects() {
}
}
export function request(options: HttpRequestOptions): Promise<HttpResponse> {
return new Promise<HttpResponse>((resolve, reject) => {
let imageSource: typeof imageSourceModule;
function ensureImageSource() {
if (!imageSource) {
imageSource = require("image-source");
}
}
let fs: typeof fsModule;
function ensureFileSystem() {
if (!fs) {
fs = require("file-system");
}
}
export function request(options: httpModule.HttpRequestOptions): Promise<httpModule.HttpResponse> {
return new Promise<httpModule.HttpResponse>((resolve, reject) => {
if (!options.url) {
reject(new Error("Request url was empty."));
@@ -106,7 +117,7 @@ export function request(options: HttpRequestOptions): Promise<HttpResponse> {
if (error) {
reject(new Error(error.localizedDescription));
} else {
const headers: Headers = {};
const headers: httpModule.Headers = {};
if (response && response.allHeaderFields) {
const headerFields = response.allHeaderFields;
@@ -136,10 +147,12 @@ export function request(options: HttpRequestOptions): Promise<HttpResponse> {
toString: (encoding?: any) => NSDataToString(data, encoding),
toJSON: (encoding?: any) => parseJSON(NSDataToString(data, encoding)),
toImage: () => {
ensureImageSource();
return new Promise((resolve, reject) => {
(<any>UIImage).tns_decodeImageWithDataCompletion(data, image => {
if (image) {
resolve(fromNativeSource(image));
resolve(imageSource.fromNativeSource(image));
} else {
reject(new Error("Response content may not be converted to an Image"));
}
@@ -147,12 +160,14 @@ export function request(options: HttpRequestOptions): Promise<HttpResponse> {
});
},
toFile: (destinationFilePath?: string) => {
ensureFileSystem();
if (!destinationFilePath) {
destinationFilePath = getFilenameFromUrl(options.url);
}
if (data instanceof NSData) {
// ensure destination path exists by creating any missing parent directories
const file = File.fromPath(destinationFilePath);
const file = fs.File.fromPath(destinationFilePath);
data.writeToFileAtomically(destinationFilePath, true);
@@ -192,7 +207,7 @@ function NSDataToString(data: any, encoding?: HttpResponseEncoding): string {
return NSString.alloc().initWithDataEncoding(data, code).toString();
}
export function addHeader(headers: Headers, key: string, value: string): void {
export function addHeader(headers: httpModule.Headers, key: string, value: string): void {
if (!headers[key]) {
headers[key] = value;
} else if (Array.isArray(headers[key])) {