Merge remote-tracking branch 'origin/master' into tsenov/merger-release-in-master

This commit is contained in:
SvetoslavTsenov
2019-08-14 04:16:05 +03:00
78 changed files with 695 additions and 335 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TestApp</string>
<string name="title_activity_kimera">TestApp</string>
<string name="app_name">FileQualifiers</string>
<string name="title_activity_kimera">FileQualifiers</string>
</resources>

View File

@@ -1,3 +1,5 @@
@import '~nativescript-theme-core/css/core.light.css';
.root-footer {
color: black;
background-color: lightgreen

View File

@@ -1,3 +1,6 @@
/* Currently app.land.css is never loaded */
@import '~nativescript-theme-core/css/lime.css';
.root-footer {
color: black;
background-color: lightpink;

View File

@@ -2,7 +2,7 @@
<StackLayout class="page-content">
<Label text="This is LANDSACPE page" />
<Button text="tap" tap="tap" />
<Button text="tap" tap="tap" class="btn btn-primary"/>
<Button text="navigate" tap="navigate" />

View File

@@ -2,7 +2,7 @@
<StackLayout class="page-content">
<Label text="This is DEFAULT page" />
<Button text="tap" tap="tap" />
<Button text="tap" tap="tap" class="btn btn-primary" />
<Button text="navigate" tap="navigate" />

View File

@@ -2,7 +2,7 @@
<StackLayout class="page-content">
<Label text="This is LANDSACPE other page" />
<Button text="tap" tap="tap" />
<Button text="tap" tap="tap" class="btn btn-primary"/>
<Button text="navigate" tap="navigate" />

View File

@@ -2,7 +2,7 @@
<StackLayout class="page-content">
<Label text="This is DEFAULT other page" />
<Button text="tap" tap="tap" />
<Button text="tap" tap="tap" class="btn btn-primary"/>
<Button text="navigate" tap="navigate" />

View File

@@ -1,3 +1 @@
{
"useLegacyWorkflow": false
}
{}

View File

@@ -6,18 +6,19 @@
"nativescript": {
"id": "org.nativescript.filequalifiers",
"tns-ios": {
"version": "6.0.0-2019-06-19-084246-01"
"version": "next"
},
"tns-android": {
"version": "6.0.0-2019-06-24-113546-01"
"version": "next"
}
},
"dependencies": {
"nativescript-theme-core": "^1.0.6",
"tns-core-modules": "file:../../tns-core-modules"
},
"devDependencies": {
"nativescript-dev-webpack": "next",
"tns-platform-declarations": "next",
"typescript": "3.4.1"
"typescript": "3.4.5"
}
}

View File

@@ -28,7 +28,6 @@ module.exports = env => {
// Default destination inside platforms/<platform>/...
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS";
const {
// The 'appPath' and 'appResourcesPath' values are fetched from
@@ -73,6 +72,7 @@ module.exports = env => {
itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`);
}
nsWebpack.processAppComponents(appComponents, platform);
const config = {
mode: production ? "production" : "development",
context: appFullPath,
@@ -133,6 +133,7 @@ module.exports = env => {
test: (module, chunks) => {
const moduleName = module.nameForCondition ? module.nameForCondition() : '';
return /[\\/]node_modules[\\/]/.test(moduleName) ||
/[\\/]tns-core-modules[\\/]/.test(moduleName) || // <-- Needed for snapshot builds with linked modules!
appComponents.some(comp => comp === moduleName);
},
@@ -179,13 +180,14 @@ module.exports = env => {
unitTesting,
appFullPath,
projectRoot,
ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform)
}
},
].filter(loader => !!loader)
},
{
test: /\.(ts|css|scss|less|html|xml)$/,
test: /\.(ts|css|scss|html|xml)$/,
use: "nativescript-dev-webpack/hmr/hot-loader"
},
@@ -227,7 +229,7 @@ module.exports = env => {
// Define useful constants like TNS_WEBPACK
new webpack.DefinePlugin({
"global.TNS_WEBPACK": "true",
"process": undefined,
"process": "global.process",
}),
// Remove all files from the out dir.
new CleanWebpackPlugin(itemsToClean, { verbose: !!verbose }),

View File

@@ -1,5 +1,5 @@
#app {
background-color: lightblue;
background-color: lightyellow;
}
.ui-tests-app-issue-1639-red {
@@ -20,4 +20,4 @@
.ui-tests-app-issue-1639-yellow {
color: yellow;
margin-left: 30;
}
}

View File

@@ -13,7 +13,6 @@ export function loadExamples() {
const examples = new Map<string, string>();
examples.set("btn-wrap-text-alignment-4266", "button/btn-wrap-text-alignment-4266-page");
examples.set("button-border", "button/button-border-page");
examples.set("styles", "button/styles-page");
examples.set("background", "button/background-page");
examples.set("border-playground", "button/border-playground-page");
examples.set("issue-4287", "button/issue-4287-page");

View File

@@ -1,4 +0,0 @@
export function onLoaded(args) {
var page = args.object;
page.addCss("#property { background-color: lightsalmon; }");
}

View File

@@ -45,6 +45,7 @@ export function loadExamples() {
examples.set("background-shorthand", "css/background-shorthand-page");
examples.set("background-image-linear-gradient", "css/background-image-linear-gradient-page");
examples.set("background-image", "css/background-image-page");
examples.set("styles", "css/styles-page");
return examples;
}

View File

@@ -0,0 +1,10 @@
import { addCss } from "tns-core-modules/application";
export function onLoaded(args) {
var page = args.object;
page.addCss("#property { background-color: lightsalmon; }");
}
export function onTap() {
addCss("#app { background-color: lightblue; }");
}

View File

@@ -1,9 +1,9 @@
<Page loaded="onLoaded">
<WrapLayout>
<Button id="app" automationText="app" text="app" />
<Button id="app" automationText="app" text="app" tap="onTap" />
<Button id="inline" automationText="inline" text="inline" style="background-color: lightgreen;" />
<Button id="page" automationText="page" text="page" />
<Button id="property" automationText="property" text="property" />
<Button id="import" automationText="import" text="import" />
</WrapLayout>
</Page>
</Page>

View File

@@ -0,0 +1,45 @@
import * as model from "./myview";
import { Button } from "tns-core-modules/ui/button";
import { Page } from "tns-core-modules/ui/page";
import { GridLayout, ItemSpec } from "tns-core-modules/ui/layouts/grid-layout";
export function onLoaded(args: { eventName: string, object: any }) {
var page = <Page>args.object;
page.bindingContext = new model.ViewModel();
}
export function onAddRowColumn(args: { eventName: string, object: any }) {
var layout = <GridLayout>args.object.parent.parent;
var row = new ItemSpec(1, "auto");
var column = new ItemSpec(1, "auto");
layout.addRow(row);
layout.addColumn(column);
var btn0 = new Button();
var btn1 = new Button();
btn0.id = "b0";
btn1.id = "b1";
btn0.text = "b0";
btn1.text = "b1";
layout.addChild(btn0);
layout.addChild(btn1);
GridLayout.setRow(btn0, 0);
GridLayout.setColumn(btn0, 4);
GridLayout.setRow(btn1, 4);
GridLayout.setColumn(btn1, 0);
GridLayout.setColumnSpan(btn1, 2);
GridLayout.setRowSpan(btn0, 3);
}
export function onRemoveRowColumn(args: { eventName: string, object: any }) {
var layout = <GridLayout>args.object.parent.parent;
var itemSpecs, count;
itemSpecs = layout.getRows();
count = itemSpecs.length;
layout.removeRow(itemSpecs[count - 1]);
itemSpecs = layout.getColumns();
count = itemSpecs.length;
layout.removeColumn(itemSpecs[count - 1]);
}

View File

@@ -0,0 +1,18 @@
<Page loaded="onLoaded">
<GridLayout rows="auto, 100, *, 50" columns="auto, 60, *, 40">
<!-- View Properties -->
<Button text="wh" tap="{{ onWidthHeight }}" id="widthHeight" automationText="widthHeight" style="background-color: lightblue;" />
<Button text="n" tap="{{ onMinWidthMinHeight }}" column="1" id="minWidthMinHeight" automationText="minWidthMinHeight" style="background-color: lightblue;" />
<Button text="m" tap="{{ onMargins }}" column="2" id="margins" automationText="margins" style="background-color: lightblue;" />
<Button text="a" tap="{{ onAlignments }}" row="1" id="alignments" automationText="alignments" style="background-color: lightblue;" />
<Button text="c" tap="{{ onCollapse }}" row="1" column="1" id="collapse" automationText="collapse" style="background-color: lightblue;" />
<Button text="v" tap="{{ onVisibile }}" row="1" column="2" id="visible" automationText="visible" style="background-color: lightblue;" />
<!-- Layout Properties -->
<Button text="p" tap="{{ onPaddings }}" row="2" id="paddings" automationText="paddings" style="background-color: lightgray;" />
<Button text="all" tap="{{ onAllProperties }}" row="2" column="1" id="allProperties" automationText="allProperties" style="background-color: aquamarine;" />
<StackLayout row="2" column="2">
<Button text="1" tap="onAddRowColumn" id="addRowColumn" automationText="addRowColumn" style="background-color: lightgreen;" />
<Button text="0" tap="onRemoveRowColumn" id="removeRowColumn" automationText="removeRowColumn" style="background-color: lightgreen;" />
</StackLayout>
</GridLayout>
</Page>

View File

@@ -23,6 +23,7 @@ export function loadExamples() {
examples.set("pwrap", "layouts-percent/wrap-page");
examples.set("passThroughParent", "layouts/passThroughParent-page");
examples.set("stacklayout-6059", "layouts/stacklayout-6059-page");
examples.set("grid-7295", "layouts/grid-7295-page");
examples.set("safe-area", "layouts/safe-area-page");
return examples;

View File

@@ -0,0 +1,21 @@
import { AppiumDriver, logInfo } from "nativescript-dev-appium";
import { PageObjectBaseModel } from "../../../page-object-base-model";
export class StylesPage extends PageObjectBaseModel {
private readonly app = "app";
constructor(_driver: AppiumDriver) {
super(_driver, ["css", "styles"]);
}
async btnApp() {
return this._driver.waitForElement(this.app);
}
async tapAppBtn() {
await (await this.btnApp()).tap();
logInfo(`Tap on '${this.app}' button.`);
}
}

View File

@@ -0,0 +1,41 @@
import { assert } from "chai";
import { AppiumDriver, createDriver, nsCapabilities } from "nativescript-dev-appium";
import { setImageName } from "../../../helpers/image-helper";
import { StylesPage } from "./styles-page";
const suite = "css";
const spec = "styles";
describe(`${suite}-${spec}-suite`, () => {
let driver: AppiumDriver;
let stylesPage: StylesPage;
before(async function () {
nsCapabilities.testReporter.context = this;
driver = await createDriver();
await driver.restartApp();
stylesPage = new StylesPage(driver);
await stylesPage.initSuite();
});
after(async function () {
await stylesPage.endSuite();
});
beforeEach(async function () {
driver.imageHelper.testName = setImageName(suite, spec, this.currentTest.title);
});
afterEach(async function () {
if (this.currentTest.state === "failed") {
await driver.logTestArtifacts(this.currentTest.title);
}
});
it(`${suite}-${spec}-apply`, async function () {
await stylesPage.tapAppBtn();
await driver.imageHelper.compareScreen();
assert.isTrue(driver.imageHelper.hasImageComparisonPassed());
});
});

View File

@@ -72,6 +72,23 @@ export function test_setTimeout_callbackCalledAfterSpecifiedTime() {
TKUnit.assert(completed, "Callback should be called after the specified time!");
}
export function test_setTimeout_callbackCalledWithBooleanPeriod() {
let completed = false;
// >> timer-set-false
const id = timer.setTimeout(() => {
// >> (hide)
completed = true;
// << (hide)
// @ts-ignore
}, false);
// << timer-set-false
TKUnit.waitUntilReady(() => completed, 1);
timer.clearTimeout(id);
TKUnit.assert(completed, "Callback should be called in 0 seconds!");
}
export function test_setTimeout_callbackNotCalled() {
let completed = false;

View File

@@ -556,16 +556,15 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
TKUnit.assertEqual(actualResult, this.expectedTextAlignment);
}
// TODO: fix this, broken with https://github.com/NativeScript/NativeScript/pull/7499
// public testErrorMessageWhenWrongCssIsAddedWithFile() {
// const view = this.testView;
// const page = this.testPage;
// this.waitUntilTestElementIsLoaded();
public testErrorMessageWhenWrongCssIsAddedWithFile() {
const view = this.testView;
const page = this.testPage;
this.waitUntilTestElementIsLoaded();
// view.id = "testLabel";
// page.addCssFile(fs.path.join(testDir, "label-tests-wrong-page.css"));
// TKUnit.assertNotEqual(this.errorMessage, undefined);
// }
view.id = "testLabel";
page.addCssFile(fs.path.join(testDir, "label-tests-wrong-page.css"));
TKUnit.assertNotEqual(this.errorMessage, undefined);
}
public testErrorMessageWhenWrongCssIsAdded() {
const view = this.testView;

View File

@@ -119,6 +119,60 @@ export class GridLayoutTest extends testModule.UITest<RemovalTrackingGridLayout>
TKUnit.assertEqual(this.colSpan(test), 1, "'columnSpan' property default value should be 1.");
}
public test_synonym_property_setting_column_changes_col() {
const test = new Button();
test.column = 3;
TKUnit.assertEqual(test.column, 3, "Setting column should work.");
TKUnit.assertEqual(test.col, 3, "Setting column property should affect col property.");
}
public test_synonym_property_setting_col_changes_column() {
const test = new Button();
test.col = 3;
TKUnit.assertEqual(test.col, 3, "Setting col should work.");
TKUnit.assertEqual(test.column, 3, "Setting col property should affect column property.");
}
public test_synonym_property_setColumn_should_set_col_and_column() {
const test = new Button();
GridLayout.setColumn(test, 3);
TKUnit.assertEqual(test.col, 3, "setColumn should set col");
TKUnit.assertEqual(test.column, 3, "setColumn should set column");
}
public test_synonym_property_setting_columnSpan_changes_colSpan() {
const test = new Button();
test.columnSpan = 3;
TKUnit.assertEqual(test.columnSpan, 3, "Setting columnSpan should work.");
TKUnit.assertEqual(test.colSpan, 3, "Setting columnSpan property should affect colSpan property.");
}
public test_synonym_property_setting_colSpan_changes_columnSpan() {
const test = new Button();
test.colSpan = 3;
TKUnit.assertEqual(test.colSpan, 3, "Setting colSpan should work.");
TKUnit.assertEqual(test.columnSpan, 3, "Setting colSpan property should affect columnSpan property.");
}
public test_synonym_property_setColumnSpan_should_set_colSpan_and_columnSpan() {
const test = new Button();
GridLayout.setColumnSpan(test, 3);
TKUnit.assertEqual(test.colSpan, 3, "setColumnSpan should set colSpan");
TKUnit.assertEqual(test.columnSpan, 3, "setColumnSpan should set columnSpan");
}
public test_getRow_shouldThrow_onNullValues() {
TKUnit.assertThrows(() => {
GridLayout.getRow(null);
@@ -250,17 +304,17 @@ export class GridLayoutTest extends testModule.UITest<RemovalTrackingGridLayout>
TKUnit.assertEqual(
this.row(btn),
row,
"'row' property not applied For GridLayout addChildAtCell without rowspan."
"'row' property not applied For GridLayout addChildAtCell without rowSpan."
);
TKUnit.assertEqual(
this.col(btn),
column,
"'column' property not applied For GridLayout addChildAtCell without rowspan."
"'column' property not applied For GridLayout addChildAtCell without rowSpan."
);
TKUnit.assertEqual(
this.rowSpan(btn),
defaultSpanValue,
"'rowSpan' property not applied For GridLayout addChildAtCell without rowspan."
"'rowSpan' property not applied For GridLayout addChildAtCell without rowSpan."
);
TKUnit.assertEqual(
this.colSpan(btn),

View File

@@ -54,6 +54,32 @@ export var test_XmlParser_EntityReferencesInAttributeValuesAreDecoded = function
TKUnit.assert(data === "<>\"&'", "Expected result: <>\"&'; Actual result: " + data + ";");
};
export var test_XmlParser_UnicodeEntitiesAreDecoded = function () {
var data;
var xmlParser = new xmlModule.XmlParser(function (event: xmlModule.ParserEvent) {
switch (event.eventType) {
case xmlModule.ParserEventType.Text:
data = event.data;
break;
}
});
xmlParser.parse("<element>&#x1f923;&#x2713;</element>");
TKUnit.assert(data === "\uD83E\uDD23\u2713", "Expected result: \uD83E\uDD23\u2713; Actual result: " + data + ";");
};
export var test_XmlParser_UnicodeEntitiesInAttributeValuesAreDecoded = function () {
var data;
var xmlParser = new xmlModule.XmlParser(function (event: xmlModule.ParserEvent) {
switch (event.eventType) {
case xmlModule.ParserEventType.StartElement:
data = event.attributes["text"];
break;
}
});
xmlParser.parse("<Label text=\"&#x1f923;&#x2713;\"/>");
TKUnit.assert(data === "\uD83E\uDD23\u2713", "Expected result: \uD83E\uDD23\u2713; Actual result: " + data + ";");
};
export var test_XmlParser_OnErrorIsCalledWhenAnErrorOccurs = function () {
var e;
var xmlParser = new xmlModule.XmlParser(

View File

@@ -1,6 +1,6 @@
{
"name": "tns-core-modules-widgets",
"version": "6.0.6",
"version": "6.1.0",
"description": "Native widgets used in the NativeScript framework.",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"

View File

@@ -1,6 +1,5 @@
// Require globals first so that snapshot takes __extends function.
require("globals");
import "../globals";
import { Observable, EventData } from "../data/observable";
import { View } from "../ui/core/view";
import {
@@ -118,10 +117,6 @@ export function loadAppCss(): void {
}
}
export function addCss(cssText: string): void {
events.notify(<CssChangedEventData>{ eventName: "cssChanged", object: app, cssText: cssText });
}
global.__onUncaughtError = function (error: NativeScriptError) {
events.notify(<UnhandledErrorEventData>{ eventName: uncaughtErrorEvent, object: app, android: error, ios: error, error: error });
};

View File

@@ -1,7 +1,8 @@
import {
AndroidActivityBundleEventData, AndroidActivityEventData, ApplicationEventData, OrientationChangedEventData,
AndroidApplication as AndroidApplicationDefinition, AndroidActivityNewIntentEventData,
AndroidActivityResultEventData, AndroidActivityBackPressedEventData, AndroidActivityRequestPermissionsEventData
AndroidActivityResultEventData, AndroidActivityBackPressedEventData, AndroidActivityRequestPermissionsEventData,
CssChangedEventData
} from ".";
import {
@@ -151,6 +152,14 @@ export function run(entry?: NavigationEntry | string) {
_start(entry);
}
export function addCss(cssText: string): void {
notify(<CssChangedEventData>{ eventName: "cssChanged", object: androidApp, cssText: cssText });
const rootView = getRootView();
if (rootView) {
rootView._onCssStateChange();
}
}
const CALLBACKS = "_callbacks";
export function _resetRootView(entry?: NavigationEntry | string) {

View File

@@ -168,6 +168,10 @@ export function getCssFileName(): string;
*/
export function loadAppCss();
/**
* Adds new values to the application styles.
* @param cssText - A valid styles which will be added to the current application styles.
*/
export function addCss(cssText: string): void;
/**

View File

@@ -1,9 +1,10 @@
import {
iOSApplication as IOSApplicationDefinition,
LaunchEventData,
ApplicationEventData,
OrientationChangedEventData,
LoadAppCSSEventData
CssChangedEventData,
LaunchEventData,
LoadAppCSSEventData,
OrientationChangedEventData
} from ".";
import {
@@ -349,6 +350,14 @@ export function run(entry?: string | NavigationEntry) {
_start(entry);
}
export function addCss(cssText: string): void {
notify(<CssChangedEventData>{ eventName: "cssChanged", object: <any>iosApp, cssText: cssText });
const rootView = getRootView();
if (rootView) {
rootView._onCssStateChange();
}
}
export function _resetRootView(entry?: NavigationEntry | string) {
createRootFrame.value = false;
mainEntry = typeof entry === "string" ? { moduleName: entry } : entry;

View File

@@ -4,44 +4,44 @@ if (global.TNS_WEBPACK) {
// Register "dynamically" loaded module that need to be resolved by the
// XML/component builders.
global.registerModule("text/formatted-string", () => require("text/formatted-string"));
global.registerModule("text/span", () => require("text/span"));
global.registerModule("ui/action-bar", () => require("ui/action-bar"));
global.registerModule("ui/activity-indicator", () => require("ui/activity-indicator"));
global.registerModule("ui/border", () => require("ui/border"));
global.registerModule("ui/bottom-navigation", () => require("ui/bottom-navigation"));
global.registerModule("ui/button", () => require("ui/button"));
global.registerModule("ui/content-view", () => require("ui/content-view"));
global.registerModule("ui/date-picker", () => require("ui/date-picker"));
global.registerModule("ui/frame", () => require("ui/frame"));
global.registerModule("ui/html-view", () => require("ui/html-view"));
global.registerModule("ui/image", () => require("ui/image"));
global.registerModule("ui/label", () => require("ui/label"));
global.registerModule("ui/layouts/absolute-layout", () => require("ui/layouts/absolute-layout"));
global.registerModule("ui/layouts/dock-layout", () => require("ui/layouts/dock-layout"));
global.registerModule("ui/layouts/grid-layout", () => require("ui/layouts/grid-layout"));
global.registerModule("ui/layouts/stack-layout", () => require("ui/layouts/stack-layout"));
global.registerModule("ui/layouts/flexbox-layout", () => require("ui/layouts/flexbox-layout"));
global.registerModule("ui/layouts/wrap-layout", () => require("ui/layouts/wrap-layout"));
global.registerModule("ui/list-picker", () => require("ui/list-picker"));
global.registerModule("ui/page", () => require("ui/page"));
global.registerModule("ui/placeholder", () => require("ui/placeholder"));
global.registerModule("ui/progress", () => require("ui/progress"));
global.registerModule("ui/proxy-view-container", () => require("ui/proxy-view-container"));
global.registerModule("ui/repeater", () => require("ui/repeater"));
global.registerModule("ui/scroll-view", () => require("ui/scroll-view"));
global.registerModule("ui/search-bar", () => require("ui/search-bar"));
global.registerModule("ui/segmented-bar", () => require("ui/segmented-bar"));
global.registerModule("ui/slider", () => require("ui/slider"));
global.registerModule("ui/switch", () => require("ui/switch"));
global.registerModule("ui/tab-view", () => require("ui/tab-view"));
global.registerModule("ui/tab-navigation-base/tab-strip", () => require("ui/tab-navigation-base/tab-strip"));
global.registerModule("ui/tab-navigation-base/tab-strip-item", () => require("ui/tab-navigation-base/tab-strip-item"));
global.registerModule("ui/tab-navigation-base/tab-content-item", () => require("ui/tab-navigation-base/tab-content-item"));
global.registerModule("ui/tabs", () => require("ui/tabs"));
global.registerModule("ui/web-view", () => require("ui/web-view"));
global.registerModule("ui/text-field", () => require("ui/text-field"));
global.registerModule("ui/text-view", () => require("ui/text-view"));
global.registerModule("ui/time-picker", () => require("ui/time-picker"));
global.registerModule("ui/list-view", () => require("ui/list-view"));
global.registerModule("text/formatted-string", () => require("./text/formatted-string"));
global.registerModule("text/span", () => require("./text/span"));
global.registerModule("ui/action-bar", () => require("./ui/action-bar"));
global.registerModule("ui/activity-indicator", () => require("./ui/activity-indicator"));
global.registerModule("ui/border", () => require("./ui/border"));
global.registerModule("ui/bottom-navigation", () => require("./ui/bottom-navigation"));
global.registerModule("ui/button", () => require("./ui/button"));
global.registerModule("ui/content-view", () => require("./ui/content-view"));
global.registerModule("ui/date-picker", () => require("./ui/date-picker"));
global.registerModule("ui/frame", () => require("./ui/frame"));
global.registerModule("ui/html-view", () => require("./ui/html-view"));
global.registerModule("ui/image", () => require("./ui/image"));
global.registerModule("ui/label", () => require("./ui/label"));
global.registerModule("ui/layouts/absolute-layout", () => require("./ui/layouts/absolute-layout"));
global.registerModule("ui/layouts/dock-layout", () => require("./ui/layouts/dock-layout"));
global.registerModule("ui/layouts/grid-layout", () => require("./ui/layouts/grid-layout"));
global.registerModule("ui/layouts/stack-layout", () => require("./ui/layouts/stack-layout"));
global.registerModule("ui/layouts/flexbox-layout", () => require("./ui/layouts/flexbox-layout"));
global.registerModule("ui/layouts/wrap-layout", () => require("./ui/layouts/wrap-layout"));
global.registerModule("ui/list-picker", () => require("./ui/list-picker"));
global.registerModule("ui/page", () => require("./ui/page"));
global.registerModule("ui/placeholder", () => require("./ui/placeholder"));
global.registerModule("ui/progress", () => require("./ui/progress"));
global.registerModule("ui/proxy-view-container", () => require("./ui/proxy-view-container"));
global.registerModule("ui/repeater", () => require("./ui/repeater"));
global.registerModule("ui/scroll-view", () => require("./ui/scroll-view"));
global.registerModule("ui/search-bar", () => require("./ui/search-bar"));
global.registerModule("ui/segmented-bar", () => require("./ui/segmented-bar"));
global.registerModule("ui/slider", () => require("./ui/slider"));
global.registerModule("ui/switch", () => require("./ui/switch"));
global.registerModule("ui/tab-view", () => require("./ui/tab-view"));
global.registerModule("ui/tab-navigation-base/tab-strip", () => require("./ui/tab-navigation-base/tab-strip"));
global.registerModule("ui/tab-navigation-base/tab-strip-item", () => require("./ui/tab-navigation-base/tab-strip-item"));
global.registerModule("ui/tab-navigation-base/tab-content-item", () => require("./ui/tab-navigation-base/tab-content-item"));
global.registerModule("ui/tabs", () => require("./ui/tabs"));
global.registerModule("ui/web-view", () => require("./ui/web-view"));
global.registerModule("ui/text-field", () => require("./ui/text-field"));
global.registerModule("ui/text-view", () => require("./ui/text-view"));
global.registerModule("ui/time-picker", () => require("./ui/time-picker"));
global.registerModule("ui/list-view", () => require("./ui/list-view"));
}

View File

@@ -17,7 +17,7 @@ function getFileAccess(): FileSystemAccess {
let platform: typeof platformModule;
function ensurePlatform() {
if (!platform) {
platform = require("platform");
platform = require("../platform");
}
}

View File

@@ -0,0 +1,25 @@
// Required by TypeScript compiler
import "../ts-helpers";
import "../register-module-helpers";
// This method iterates all the keys in the source exports object and copies them to the destination exports one.
// Note: the method will not check for naming collisions and will override any already existing entries in the destination exports.
global.moduleMerge = function (sourceExports: any, destExports: any) {
for (let key in sourceExports) {
destExports[key] = sourceExports[key];
}
};
global.zonedCallback = function (callback: Function): Function {
if ((<any>global).zone) {
// Zone v0.5.* style callback wrapping
return (<any>global).zone.bind(callback);
}
if ((<any>global).Zone) {
// Zone v0.6.* style callback wrapping
return (<any>global).Zone.current.wrap(callback);
} else {
return callback;
}
};

View File

@@ -0,0 +1,5 @@
{
"name" : "core",
"main" : "globals-core",
"nativescript": {}
}

View File

@@ -0,0 +1,39 @@
export function Deprecated(target: Object, key?: string | symbol, descriptor?: any) {
if (descriptor) {
const originalMethod = descriptor.value;
descriptor.value = function (...args: any[]) {
console.log(`${key.toString()} is deprecated`);
return originalMethod.apply(this, args);
};
return descriptor;
} else {
console.log(`${(target && (<any>target).name || target)} is deprecated`);
return target;
}
}
global.Deprecated = Deprecated;
export function Experimental(target: Object, key?: string | symbol, descriptor?: any) {
if (descriptor) {
const originalMethod = descriptor.value;
descriptor.value = function (...args: any[]) {
console.log(`${key.toString()} is experimental`);
return originalMethod.apply(this, args);
};
return descriptor;
} else {
console.log(`${(target && (<any>target).name || target)} is experimental`);
return target;
}
}
global.Experimental = Experimental;

View File

@@ -1,159 +1,8 @@
// Required by TypeScript compiler
import "./ts-helpers";
import "./core";
import "./register-module-helpers";
import "./polyfills/timers";
import "./polyfills/dialogs";
import "./polyfills/xhr";
import "./polyfills/fetch";
// This method iterates all the keys in the source exports object and copies them to the destination exports one.
// Note: the method will not check for naming collisions and will override any already existing entries in the destination exports.
global.moduleMerge = function (sourceExports: any, destExports: any) {
for (let key in sourceExports) {
destExports[key] = sourceExports[key];
}
};
import * as timerModule from "../timer";
import * as dialogsModule from "../ui/dialogs";
global.zonedCallback = function (callback: Function): Function {
if ((<any>global).zone) {
// Zone v0.5.* style callback wrapping
return (<any>global).zone.bind(callback);
}
if ((<any>global).Zone) {
// Zone v0.6.* style callback wrapping
return (<any>global).Zone.current.wrap(callback);
} else {
return callback;
}
};
global.registerModule("timer", () => require("timer"));
global.registerModule("ui/dialogs", () => require("ui/dialogs"));
global.registerModule("xhr", () => require("xhr"));
global.registerModule("fetch", () => require("fetch"));
(<any>global).System = {
import(path) {
return new Promise((resolve, reject) => {
try {
resolve(global.require(path));
} catch (e) {
reject(e);
}
});
}
};
function registerOnGlobalContext(name: string, module: string): void {
Object.defineProperty(global, name, {
get: function () {
// We do not need to cache require() call since it is already cached in the runtime.
let m = global.loadModule(module);
// Redefine the property to make sure the above code is executed only once.
let resolvedValue = m[name];
Object.defineProperty(global, name, { value: resolvedValue, configurable: true, writable: true });
return resolvedValue;
},
configurable: true
});
}
let snapshotGlobals;
export function install() {
if ((<any>global).__snapshot || (<any>global).__snapshotEnabled) {
if (!snapshotGlobals) {
// require in snapshot mode is cheap
const timer: typeof timerModule = require("timer");
const dialogs: typeof dialogsModule = require("ui/dialogs");
const xhr = require("xhr");
const fetch = require("fetch");
snapshotGlobals = snapshotGlobals || {
setTimeout: timer.setTimeout,
clearTimeout: timer.clearTimeout,
setInterval: timer.setInterval,
clearInterval: timer.clearInterval,
alert: dialogs.alert,
confirm: dialogs.confirm,
prompt: dialogs.prompt,
login: dialogs.login,
action: dialogs.action,
XMLHttpRequest: xhr.XMLHttpRequest,
FormData: xhr.FormData,
fetch: fetch.fetch,
Headers: fetch.Headers,
Request: fetch.Request,
Response: fetch.Response,
};
}
const consoleModule = require("console").Console;
// Object.assign call will fire an error when trying to write to a read-only property of an object, such as 'console'
global.console = global.console || new consoleModule();
Object.assign(global, snapshotGlobals);
} else {
registerOnGlobalContext("setTimeout", "timer");
registerOnGlobalContext("clearTimeout", "timer");
registerOnGlobalContext("setInterval", "timer");
registerOnGlobalContext("clearInterval", "timer");
registerOnGlobalContext("alert", "ui/dialogs");
registerOnGlobalContext("confirm", "ui/dialogs");
registerOnGlobalContext("prompt", "ui/dialogs");
registerOnGlobalContext("login", "ui/dialogs");
registerOnGlobalContext("action", "ui/dialogs");
registerOnGlobalContext("XMLHttpRequest", "xhr");
registerOnGlobalContext("FormData", "xhr");
registerOnGlobalContext("fetch", "fetch");
registerOnGlobalContext("Headers", "fetch");
registerOnGlobalContext("Request", "fetch");
registerOnGlobalContext("Response", "fetch");
}
}
install();
export function Deprecated(target: Object, key?: string | symbol, descriptor?: any) {
if (descriptor) {
const originalMethod = descriptor.value;
descriptor.value = function (...args: any[]) {
console.log(`${key.toString()} is deprecated`);
return originalMethod.apply(this, args);
};
return descriptor;
} else {
console.log(`${(target && (<any>target).name || target)} is deprecated`);
return target;
}
}
global.Deprecated = Deprecated;
export function Experimental(target: Object, key?: string | symbol, descriptor?: any) {
if (descriptor) {
const originalMethod = descriptor.value;
descriptor.value = function (...args: any[]) {
console.log(`${key.toString()} is experimental`);
return originalMethod.apply(this, args);
};
return descriptor;
} else {
console.log(`${(target && (<any>target).name || target)} is experimental`);
return target;
}
}
global.Experimental = Experimental;
import "./decorators";

View File

@@ -0,0 +1,6 @@
import "../../core";
import { installPolyfills } from "../polyfill-helpers";
global.registerModule("tns-core-modules/ui/dialogs", () => require("../../../ui/dialogs"));
installPolyfills("tns-core-modules/ui/dialogs", ["alert", "confirm", "prompt", "login", "action"]);

View File

@@ -0,0 +1,5 @@
{
"name" : "dialogs",
"main" : "dialogs",
"nativescript": {}
}

View File

@@ -0,0 +1,8 @@
import "../../core";
import "../../polyfills/xhr";
import { installPolyfills } from "../polyfill-helpers";
global.registerModule("fetch", () => require("../../../fetch"));
installPolyfills("fetch", ["fetch", "Headers", "Request", "Response"]);

View File

@@ -0,0 +1,5 @@
{
"name" : "fetch",
"main" : "fetch",
"nativescript": {}
}

View File

@@ -0,0 +1,5 @@
{
"name" : "polyfill-helpers",
"main" : "polyfill-helpers",
"nativescript": {}
}

View File

@@ -0,0 +1,26 @@
import "../../core";
function registerOnGlobalContext(moduleName: string, exportName: string): void {
Object.defineProperty(global, exportName, {
get: function () {
// We do not need to cache require() call since it is already cached in the runtime.
let m = global.loadModule(moduleName);
// Redefine the property to make sure the above code is executed only once.
let resolvedValue = m[exportName];
Object.defineProperty(global, exportName, { value: resolvedValue, configurable: true, writable: true });
return resolvedValue;
},
configurable: true
});
}
export function installPolyfills(moduleName: string, exportNames: string[]) {
if (global.__snapshot) {
const loadedModule = global.loadModule(moduleName);
exportNames.forEach(exportName => global[exportName] = loadedModule[exportName]);
} else {
exportNames.forEach(exportName => registerOnGlobalContext(moduleName, exportName));
}
}

View File

@@ -0,0 +1,5 @@
{
"name" : "timers",
"main" : "timers",
"nativescript": {}
}

View File

@@ -0,0 +1,6 @@
import "../../core";
import { installPolyfills } from "../polyfill-helpers";
global.registerModule("timer", () => require("../../../timer"));
installPolyfills("timer", ["setTimeout", "clearTimeout", "setInterval", "clearInterval"]);

View File

@@ -0,0 +1,5 @@
{
"name" : "xhr",
"main" : "xhr",
"nativescript": {}
}

View File

@@ -0,0 +1,6 @@
import "../../core";
import { installPolyfills } from "../polyfill-helpers";
global.registerModule("xhr", () => require("../../../xhr"));
installPolyfills("xhr", ["XMLHttpRequest", "FormData"]);

View File

@@ -1,7 +1,7 @@
import * as fsModule from "../../file-system";
export function getFilenameFromUrl(url: string) {
const fs: typeof fsModule = require("file-system");
const fs: typeof fsModule = require("../../file-system");
const slashPos = url.lastIndexOf("/") + 1;
const questionMarkPos = url.lastIndexOf("?");

View File

@@ -27,21 +27,21 @@ const pendingRequests = {};
let imageSource: typeof imageSourceModule;
function ensureImageSource() {
if (!imageSource) {
imageSource = require("image-source");
imageSource = require("../../image-source");
}
}
let platform: typeof platformModule;
function ensurePlatform() {
if (!platform) {
platform = require("platform");
platform = require("../../platform");
}
}
let fs: typeof fsModule;
function ensureFileSystem() {
if (!fs) {
fs = require("file-system");
fs = require("../../file-system");
}
}

View File

@@ -56,14 +56,14 @@ function ensureSessionNotFollowingRedirects() {
let imageSource: typeof imageSourceModule;
function ensureImageSource() {
if (!imageSource) {
imageSource = require("image-source");
imageSource = require("../../image-source");
}
}
let fs: typeof fsModule;
function ensureFileSystem() {
if (!fs) {
fs = require("file-system");
fs = require("../../file-system");
}
}

View File

@@ -188,10 +188,10 @@ function rpEntities(s, d, x, z) {
};
if (d) {
return String.fromCharCode(d);
return String.fromCodePoint(d);
};
return String.fromCharCode(parseInt(x, 16));
return String.fromCodePoint(parseInt(x, 16));
};
function unEntities(s, i) {

View File

@@ -3,6 +3,11 @@ import { screen, device } from "../platform/platform";
import * as appCommonModule from "../application/application-common";
import { PlatformContext, findMatch } from "./qualifier-matcher";
import { registerModulesFromFileSystem } from "./non-bundle-workflow-compat";
import {
isEnabled as traceEnabled,
write as traceWrite,
categories as traceCategories
} from "../trace";
export class ModuleNameResolver implements ModuleNameResolverDefinition {
private _cache = {};
@@ -18,6 +23,10 @@ export class ModuleNameResolver implements ModuleNameResolverDefinition {
this._cache[key] = result;
}
if (traceEnabled()) {
traceWrite(`path: '${path}' with ext: '${ext}' resolved: '${result}'`, traceCategories.ModuleNameResolver);
}
return result;
}
@@ -52,6 +61,10 @@ export class ModuleNameResolver implements ModuleNameResolverDefinition {
let resolverInstance: ModuleNameResolver;
export function resolveModuleName(path: string, ext: string): string {
if (global.__snapshot) {
return resolveModuleSnapshot(path, ext);
}
if (!resolverInstance) {
resolverInstance = new ModuleNameResolver({
width: screen.mainScreen.widthDIPs,
@@ -64,6 +77,20 @@ export function resolveModuleName(path: string, ext: string): string {
return resolverInstance.resolveModuleName(path, ext);
}
function resolveModuleSnapshot(path, ext) {
traceWrite(`Resolving module in SNAPSHOT context - path: '${path}' with ext: '${ext}'`, traceCategories.ModuleNameResolver);
// Platform module when in snapshot. So resolve modules with default android phone.
// NB: The only module name that should ever be resolved while in snapshot is app.css, because it is
// applied explicitly in the snapshot by [NativeScriptSnapshotPlugin](https://github.com/NativeScript/nativescript-dev-webpack/blob/48b26f412fd70c19dc0b9c7763e08e9505a0ae11/plugins/NativeScriptSnapshotPlugin/index.js#L48-L56)
return new ModuleNameResolver({
width: 400,
height: 800,
os: "Android",
deviceType: "Phone"
}).resolveModuleName(path, ext);
}
export function clearCache() {
if (resolverInstance) {
resolverInstance.clearCache();

View File

@@ -1,11 +1,27 @@
import * as fs from "../file-system/file-system";
import * as appCommonModule from "../application/application-common";
import {
isEnabled as traceEnabled,
write as traceWrite,
categories as traceCategories
} from "../trace";
const cache = new Set<string>();
let initialized = false;
function register(name, loader) {
function register(name: string, loader: (name?: string) => void) {
if (traceEnabled()) {
traceWrite(`[Compat] Register module: ${name}`, traceCategories.ModuleNameResolver);
}
global.registerModule(name, loader);
if (name.startsWith("tns_modules")) {
const nonTnsModulesName = name.substr("tns_modules".length + 1);
if (traceEnabled()) {
traceWrite(`[Compat] Register module: ${nonTnsModulesName}`, traceCategories.ModuleNameResolver);
}
global.registerModule(nonTnsModulesName, loader);
}
}
function processFile(file: fs.File) {
@@ -35,27 +51,41 @@ function processFile(file: fs.File) {
let name = filePathRelativeToApp.substr(0, filePathRelativeToApp.length - "package.json".length - 1);
let requirePath = fs.path.join(file.parent.path, json.main);
if (name.startsWith("tns_modules")) {
name = name.substr("tns_modules".length + 1);
}
register(name, () => global.require(requirePath));
}
}
}
function processFolder(path: string) {
/**
* Processes folder and returns true if folder was not empty.
* @param Folder path
*/
function processFolder(path: string): boolean {
if (cache.has(path)) {
return true;
}
cache.add(path);
if (traceEnabled()) {
traceWrite(`[Compat] Processing folder: ${path}`, traceCategories.ModuleNameResolver);
}
let folderEmpty = true;
if (fs.Folder.exists(path)) {
const folder = fs.Folder.fromPath(path);
folder.eachEntity((file) => {
if (file instanceof fs.File) {
processFile(file);
folderEmpty = false;
}
return true;
});
}
return !folderEmpty;
}
/**
@@ -66,25 +96,25 @@ function processFolder(path: string) {
export function registerModulesFromFileSystem(moduleName: string) {
initialize();
if (cache.has(moduleName)) {
return;
}
cache.add(moduleName);
let folderProcessed = false;
let parentFolderProcessed = false;
// moduleName is a folder with package.json
const path = fs.path.join(fs.knownFolders.currentApp().path, moduleName);
if (fs.Folder.exists(path)) {
processFolder(path);
return;
folderProcessed = processFolder(path);
}
// moduleName is file - load all files in it's folder
// moduleName is file - load all files in its parent folder
const parentName = moduleName.substr(0, moduleName.lastIndexOf(fs.path.separator));
const parentFolderPath = fs.path.join(fs.knownFolders.currentApp().path, parentName);
if (fs.Folder.exists(parentFolderPath)) {
processFolder(parentFolderPath);
parentFolderProcessed = processFolder(parentFolderPath);
}
// Return only if we processed the actual folder or its parent folder.
// If the parent folder is empty we should still check tns_modules
// as this might be just a name of a plugin (ex. "nativescript-ui-autocomplete")
if (folderProcessed || (parentFolderProcessed && parentName)) {
return;
}
@@ -92,8 +122,6 @@ export function registerModulesFromFileSystem(moduleName: string) {
const tnsModulesPath = fs.path.join(fs.knownFolders.currentApp().path, "tns_modules", moduleName);
if (fs.Folder.exists(tnsModulesPath)) {
processFolder(tnsModulesPath);
return;
}
// moduleName a file in tns_modules/plugin. Avoid traversing the whole tns_modules folder if parentName is empty
@@ -101,8 +129,6 @@ export function registerModulesFromFileSystem(moduleName: string) {
const tnsParentFolderPath = fs.path.join(fs.knownFolders.currentApp().path, "tns_modules", parentName);
if (fs.Folder.exists(tnsParentFolderPath)) {
processFolder(tnsParentFolderPath);
return;
}
}
}

View File

@@ -82,6 +82,7 @@ declare namespace NodeJS {
__onUncaughtError: (error: NativeScriptError) => void;
__onDiscardedError: (error: NativeScriptError) => void;
TNS_WEBPACK?: boolean;
__snapshot?: boolean;
__requireOverride?: (name: string, dir: string) => any;
}
}

View File

@@ -1,7 +1,7 @@
{
"name": "tns-core-modules",
"description": "Telerik NativeScript Core Modules",
"version": "6.0.6",
"version": "6.1.0",
"homepage": "https://www.nativescript.org",
"repository": {
"type": "git",
@@ -26,7 +26,7 @@
"license": "Apache-2.0",
"typings": "tns-core-modules.d.ts",
"dependencies": {
"tns-core-modules-widgets": "6.0.6",
"tns-core-modules-widgets": "next",
"tslib": "^1.9.3"
},
"devDependencies": {

View File

@@ -16,6 +16,9 @@ function createHandlerAndGetId(): number {
}
export function setTimeout(callback: Function, milliseconds = 0, ...args): number {
// Cast to Number
milliseconds += 0;
const id = createHandlerAndGetId();
const invoke = () => callback(...args);
const zoneBound = zonedCallback(invoke);
@@ -48,6 +51,9 @@ export function clearTimeout(id: number): void {
}
export function setInterval(callback: Function, milliseconds = 0, ...args): number {
// Cast to Number
milliseconds += 0;
const id = createHandlerAndGetId();
const handler = timeoutHandler;
const invoke = () => callback(...args);

View File

@@ -48,6 +48,9 @@ class TimerTargetImpl extends NSObject {
}
function createTimerAndGetId(callback: Function, milliseconds: number, shouldRepeat: boolean): number {
// Cast to Number
milliseconds += 0;
timerId++;
let id = timerId;
let timerTarget = TimerTargetImpl.initWithCallback(callback, id, shouldRepeat);

View File

@@ -101,6 +101,7 @@ export module categories {
export const Animation: string;
export const Transition: string;
export const Livesync: string;
export const ModuleNameResolver: string;
export const separator: string;
export const All: string;

View File

@@ -131,21 +131,16 @@ export module categories {
export const Animation = "Animation";
export const Transition = "Transition";
export const Livesync = "Livesync";
export const ModuleNameResolver = "ModuleNameResolver";
export const separator = ",";
export const All = VisualTreeEvents + separator
+ Layout + separator
+ Style + separator
+ ViewHierarchy + separator
+ NativeLifecycle + separator
+ Debug + separator
+ Navigation + separator
+ Test + separator
+ Binding + separator
+ Error + separator
+ Animation + separator
+ Transition + separator
+ Livesync;
export const All = [
VisualTreeEvents, Layout, Style,
ViewHierarchy, NativeLifecycle,
Debug, Navigation, Test, Binding,
Error, Animation, Transition, Livesync,
ModuleNameResolver]
.join(separator);
export function concat(): string {
let result: string;

View File

@@ -22,6 +22,7 @@ export * from "../tab-navigation-base/tab-navigation-base";
export * from "../tab-navigation-base/tab-strip";
export * from "../tab-navigation-base/tab-strip-item";
const maxTabsCount = 5;
const majorVersion = iosUtils.MajorVersion;
const isPhone = device.deviceType === "Phone";
@@ -491,6 +492,9 @@ export class BottomNavigation extends TabNavigationBase {
return;
}
// Limit both tabContentItems and tabStripItems to 5 in order to prevent iOS 'more' button
items = items.slice(0, maxTabsCount);
const controllers = NSMutableArray.alloc<UIViewController>().initWithCapacity(length);
const states = getTitleAttributesForStates(this);

View File

@@ -53,7 +53,7 @@ const createComponentInstance = profile("createComponentInstance", (elementName:
// Create instance of the component.
instance = new instanceType();
} catch (ex) {
const debug: typeof debugModule = require("utils/debug");
const debug: typeof debugModule = require("../../../utils/debug");
throw new debug.ScopeError(ex, "Module '" + resolvedModuleName + "' not found for element '" + (namespace ? namespace + ":" : "") + elementName + "'.");
}

View File

@@ -3,6 +3,8 @@ export function sanitizeModuleName(moduleName: string, removeExtension: boolean
if (moduleName.startsWith("~/")) {
moduleName = moduleName.substring(2);
} else if (moduleName.startsWith("~")) {
moduleName = moduleName.substring(1);
} else if (moduleName.startsWith("/")) {
moduleName = moduleName.substring(1);
}

View File

@@ -98,8 +98,16 @@ export abstract class ViewBase extends Observable {
dock: "left" | "top" | "right" | "bottom";
row: number;
col: number;
/**
* Setting `column` property is the same as `col`
*/
column: number;
rowSpan: number;
colSpan: number;
/**
* Setting `columnSpan` property is the same as `colSpan`
*/
columnSpan: number;
domNode: DOMNode;
order: Order;

View File

@@ -37,7 +37,7 @@ function ensuredomNodeModule(): void {
let styleScopeModule: typeof ssm;
function ensureStyleScopeModule() {
if (!styleScopeModule) {
styleScopeModule = require("ui/styling/style-scope");
styleScopeModule = require("../../styling/style-scope");
}
}
@@ -210,8 +210,10 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
dock: "left" | "top" | "right" | "bottom";
row: number;
col: number;
column: number; // synonym for "col"
rowSpan: number;
colSpan: number;
columnSpan: number; // synonym for "columnSpan"
order: Order;
flexGrow: FlexGrow;

View File

@@ -34,7 +34,7 @@ import * as am from "../../animation";
let animationModule: typeof am;
function ensureAnimationModule() {
if (!animationModule) {
animationModule = require("ui/animation");
animationModule = require("../../animation");
}
}

View File

@@ -78,7 +78,7 @@ export module capitalizationType {
let frame: typeof frameModule;
export function getCurrentPage(): Page {
if (!frame) {
frame = require("ui/frame");
frame = require("../frame");
}
let topmostFrame = frame.topmost();
@@ -108,7 +108,7 @@ let textField: View;
export function getButtonColors(): { color: Color, backgroundColor: Color } {
if (!button) {
const Button = require("ui/button").Button;
const Button = require("../button").Button;
button = new Button;
if (isIOS) {
button._setupUI({});
@@ -127,7 +127,7 @@ export function getButtonColors(): { color: Color, backgroundColor: Color } {
export function getLabelColor(): Color {
if (!label) {
const Label = require("ui/label").Label;
const Label = require("../label").Label;
label = new Label;
if (isIOS) {
label._setupUI({});
@@ -144,7 +144,7 @@ export function getLabelColor(): Color {
export function getTextFieldColor(): Color {
if (!textField) {
const TextField = require("ui/text-field").TextField;
const TextField = require("../text-field").TextField;
textField = new TextField();
if (isIOS) {
textField._setupUI({});

View File

@@ -207,6 +207,10 @@ function showUIAlertController(alertController: UIAlertController) {
let viewController: UIViewController = currentView.ios;
if (viewController.presentedViewController) {
viewController = viewController.presentedViewController;
}
if (!(currentView.ios instanceof UIViewController)) {
const parentWithController = iosView.getParentWithViewController(currentView);
viewController = parentWithController ? parentWithController.viewController : undefined;

View File

@@ -177,7 +177,7 @@ export module AnimationCurve {
export const linear = "linear";
export const spring = "spring";
export function cubicBezier(x1: number, y1: number, x2: number, y2: number): Object {
animation = animation || require("ui/animation");
animation = animation || require("../animation");
return new animation.CubicBezierAnimationCurve(x1, y1 , x2, y2);
}

View File

@@ -2,7 +2,7 @@ import { setActivityCallbacks, AndroidActivityCallbacks } from "./frame";
import * as globals from "../../globals";
import * as appModule from "../../application";
if ((<any>global).__snapshot || (<any>global).__snapshotEnabled) {
if (global.__snapshot) {
globals.install();
}

View File

@@ -46,7 +46,7 @@ let fragmentId = -1;
export let moduleLoaded: boolean;
if (global && global.__inspector) {
const devtools = require("tns-core-modules/debugger/devtools-elements");
const devtools = require("../../debugger/devtools-elements");
devtools.attachDOMInspectorEventCallbacks(global.__inspector);
devtools.attachDOMInspectorCommandCallbacks(global.__inspector);
}
@@ -754,7 +754,7 @@ function ensureFragmentClass() {
}
// this require will apply the FragmentClass implementation
require("ui/frame/fragment");
require("./fragment");
if (!fragmentClass) {
throw new Error("Failed to initialize the extended androidx.fragment.app.Fragment class");

View File

@@ -30,7 +30,7 @@ export class Frame extends View {
* This method will require the module and will check for a Page property in the exports of the module.
* @param pageModuleName The name of the module to require starting from the application root.
* For example if you want to navigate to page called "myPage.js" in a folder called "subFolder" and your root folder is "app" you can call navigate method like this:
* const frames = require("ui/frame");
* const frames = require("tns-core-modules/ui/frame");
* frames.topmost().navigate("app/subFolder/myPage");
*/
navigate(pageModuleName: string);

View File

@@ -8,7 +8,7 @@ import * as utils from "../../utils/utils";
let httpRequest: typeof httpRequestModule;
function ensureHttpRequest() {
if (!httpRequest) {
httpRequest = require("http/http-request");
httpRequest = require("../../http/http-request");
}
}

View File

@@ -16,6 +16,20 @@ View.prototype.col = 0;
View.prototype.rowSpan = 1;
View.prototype.colSpan = 1;
Object.defineProperty(View.prototype, "column", {
get(this: View): number { return this.col; },
set(this: View, value: number) { this.col = value; },
enumerable: true,
configurable: true
});
Object.defineProperty(View.prototype, "columnSpan", {
get(this: View): number { return this.colSpan; },
set(this: View, value: number) { this.colSpan = value; },
enumerable: true,
configurable: true
});
function validateItemSpec(itemSpec: ItemSpec): void {
if (!itemSpec) {
throw new Error("Value cannot be undefined.");

View File

@@ -35,11 +35,13 @@ import * as kam from "../animation/keyframe-animation";
let keyframeAnimationModule: typeof kam;
function ensureKeyframeAnimationModule() {
if (!keyframeAnimationModule) {
keyframeAnimationModule = require("ui/animation/keyframe-animation");
keyframeAnimationModule = require("../animation/keyframe-animation");
}
}
import * as capm from "./css-animation-parser";
import { sanitizeModuleName } from "../builder/module-name-sanitizer";
import { resolveModuleName } from "../../module-name-resolver";
let cssAnimationParserModule: typeof capm;
function ensureCssAnimationParserModule() {
if (!cssAnimationParserModule) {
@@ -80,25 +82,26 @@ class CSSSource {
public static fromURI(uri: string, keyframes: KeyframesMap): CSSSource {
// webpack modules require all file paths to be relative to /app folder
let appRelativeUri = CSSSource.pathRelativeToApp(uri);
const appRelativeUri = CSSSource.pathRelativeToApp(uri);
const sanitizedModuleName = sanitizeModuleName(appRelativeUri);
const resolvedModuleName = resolveModuleName(sanitizedModuleName, "css");
try {
const cssOrAst = global.loadModule(appRelativeUri, true);
const cssOrAst = global.loadModule(resolvedModuleName, true);
if (cssOrAst) {
if (typeof cssOrAst === "string") {
// raw-loader
return CSSSource.fromSource(cssOrAst, keyframes, appRelativeUri);
return CSSSource.fromSource(cssOrAst, keyframes, resolvedModuleName);
} else if (typeof cssOrAst === "object" && cssOrAst.type === "stylesheet" && cssOrAst.stylesheet && cssOrAst.stylesheet.rules) {
// css-loader
return CSSSource.fromAST(cssOrAst, keyframes, appRelativeUri);
return CSSSource.fromAST(cssOrAst, keyframes, resolvedModuleName);
} else {
// css2json-loader
return CSSSource.fromSource(cssOrAst.toString(), keyframes, appRelativeUri);
return CSSSource.fromSource(cssOrAst.toString(), keyframes, resolvedModuleName);
}
}
} catch (e) {
// TODO: Commented as this prints error in playground: https://github.com/NativeScript/NativeScript/issues/7497
// traceWrite(`Could not load CSS from ${uri}: ${e}`, traceCategories.Error, traceMessageType.error);
traceWrite(`Could not load CSS from ${uri}: ${e}`, traceCategories.Error, traceMessageType.error);
}
return CSSSource.fromFile(appRelativeUri, keyframes);
@@ -320,12 +323,17 @@ function onLiveSync(args: applicationCommon.CssChangedEventData): void {
loadCss(applicationCommon.getCssFileName());
}
const loadCss = profile(`"style-scope".loadCss`, (cssFile: string) => {
if (!cssFile) {
const loadCss = profile(`"style-scope".loadCss`, (cssModule: string) => {
if (!cssModule) {
return undefined;
}
const result = CSSSource.fromURI(cssFile, applicationKeyframes).selectors;
// safely remove "./" as global CSS should be resolved relative to app folder
if (cssModule.startsWith("./")) {
cssModule = cssModule.substr(2);
}
const result = CSSSource.fromURI(cssModule, applicationKeyframes).selectors;
if (result.length > 0) {
applicationSelectors = result;
mergeCssSelectors();
@@ -335,6 +343,11 @@ const loadCss = profile(`"style-scope".loadCss`, (cssFile: string) => {
applicationCommon.on("cssChanged", onCssChanged);
applicationCommon.on("livesync", onLiveSync);
// Call to this method is injected in the application in:
// - no-snapshot - code injected in app.ts by [bundle-config-loader](https://github.com/NativeScript/nativescript-dev-webpack/blob/9b1e34d8ef838006c9b575285c42d2304f5f02b5/bundle-config-loader.ts#L85-L92)
// - with-snapshot - code injected in snapshot bundle by [NativeScriptSnapshotPlugin](https://github.com/NativeScript/nativescript-dev-webpack/blob/48b26f412fd70c19dc0b9c7763e08e9505a0ae11/plugins/NativeScriptSnapshotPlugin/index.js#L48-L56)
// Having the app.css loaded in snapshot provides significant boost in startup (when using the ns-theme ~150 ms). However, because app.css is resolved at build-time,
// when the snapshot is created - there is no way to use file qualifiers or change the name of on app.css
export const loadAppCSS = profile("\"style-scope\".loadAppCSS", (args: applicationCommon.LoadAppCSSEventData) => {
loadCss(args.cssFile);
applicationCommon.off("loadAppCss", loadAppCSS);

View File

@@ -89,20 +89,9 @@ export module ios {
export const MajorVersion = NSString.stringWithString(UIDevice.currentDevice.systemVersion).intValue;
export function openFile(filePath: string): boolean {
try {
const appPath = getCurrentAppPath();
const path = filePath.replace("~", appPath);
console.log("utils.ios.openFile() is deprecated; use utils.openFile() instead");
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
controller.delegate = new UIDocumentInteractionControllerDelegateImpl();
return controller.presentPreviewAnimated(true);
}
catch (e) {
traceWrite("Error in openFile", traceCategories.Error, traceMessageType.error);
}
return false;
return openFileAtRootModule(filePath);
}
export function getCurrentAppPath(): string {
@@ -146,6 +135,26 @@ export module ios {
}
export function openFile(filePath: string): boolean {
try {
const appPath = ios.getCurrentAppPath();
const path = filePath.replace("~", appPath);
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
controller.delegate = new UIDocumentInteractionControllerDelegateImpl();
return controller.presentPreviewAnimated(true);
}
catch (e) {
traceWrite("Error in openFile", traceCategories.Error, traceMessageType.error);
}
return false;
}
// Need this so that we can use this function inside the ios module (avoid name clashing).
const openFileAtRootModule = openFile;
export function GC() {
__collect();
}

View File

@@ -106,16 +106,15 @@ function _HandleAmpEntities(found, decimalValue, hexValue, wordValue) {
}
var res = _ampCodes.get(wordValue);
if (res) {
return String.fromCharCode(res);
return String.fromCodePoint(res);
}
return found;
}
if (decimalValue) {
return String.fromCharCode(parseInt(decimalValue, 10));
return String.fromCodePoint(parseInt(decimalValue, 10));
}
return String.fromCharCode(parseInt(hexValue, 16));
return String.fromCodePoint(parseInt(hexValue, 16));
}
;
var XmlParser = (function () {
function XmlParser(onEvent, onError, processNamespaces) {
this._processNamespaces = processNamespaces;

View File

@@ -88,7 +88,7 @@ function _generateAmpMap(): any {
}
// android-specific implementation, which pre-populates the map to get it saved into the heap blob
if ((<any>global).__snapshot) {
if (global.__snapshot) {
_ampCodes = _generateAmpMap();
}
@@ -100,17 +100,17 @@ function _HandleAmpEntities(found: string, decimalValue: string, hexValue: strin
}
const res = _ampCodes.get(wordValue);
if (res) {
return String.fromCharCode(res);
return String.fromCodePoint(res);
}
// Invalid word; so we just return it
return found;
}
if (decimalValue) {
return String.fromCharCode(parseInt(decimalValue, 10));
return String.fromCodePoint(parseInt(decimalValue, 10));
}
return String.fromCharCode(parseInt(hexValue, 16));
return String.fromCodePoint(parseInt(hexValue, 16));
}
export class XmlParser implements definition.XmlParser {

View File

@@ -1,6 +1,6 @@
{
"name": "tns-platform-declarations",
"version": "6.0.6",
"version": "6.1.0",
"description": "Platform-specific TypeScript declarations for NativeScript for accessing native objects",
"main": "",
"scripts": {