Merge branch 'master' of github.com:NativeScript/NativeScript

# Conflicts:
#	packages/core/application/index.d.ts
This commit is contained in:
Martin Guillon
2020-09-10 16:05:56 +02:00
16 changed files with 183 additions and 145 deletions

View File

@ -1,3 +1,32 @@
## [7.0.2](https://github.com/NativeScript/NativeScript/compare/7.0.0...7.0.2) (2020-09-10)
### Bug Fixes
* **core:** autoSystemAppearanceChanged typings in ambient context fix ([c30a9c3](https://github.com/NativeScript/NativeScript/commit/c30a9c3e3569e0367056bfd80fa730ae79e29066))
* **core:** bundle-config-loader global handling ([#8838](https://github.com/NativeScript/NativeScript/issues/8838)) ([1623a56](https://github.com/NativeScript/NativeScript/commit/1623a567b6eaa195d075936103d2f7d829e1fa07))
* **webpack:** verify now works properly ([f7713c4](https://github.com/NativeScript/NativeScript/commit/f7713c40a63959c2b5934a25bd3577f07d0401c0))
## [7.0.1](https://github.com/NativeScript/NativeScript/compare/7.0.0...7.0.1) (2020-09-09)
### Bug Fixes
* **webpack:** react config ([#8822](https://github.com/NativeScript/NativeScript/issues/8822)) ([354b935](https://github.com/NativeScript/NativeScript/commit/354b935c6a334de3d418495b11674a799293a8bd))
* invalid cli tag version ([#8821](https://github.com/NativeScript/NativeScript/issues/8821)) ([d51abef](https://github.com/NativeScript/NativeScript/commit/d51abef6bfeb66ed647d5bd2e1711d0ce9d07113))
* **webpack:** apply-css-loader not applying css ([#8811](https://github.com/NativeScript/NativeScript/issues/8811)) ([c1a2d54](https://github.com/NativeScript/NativeScript/commit/c1a2d543b8a9aad0551ae5bb445ef4e08bac99b2))
* **webpack:** Change NativeClass properties to enumerable ([#8813](https://github.com/NativeScript/NativeScript/issues/8813)) ([e4a2930](https://github.com/NativeScript/NativeScript/commit/e4a2930c6a019e3b65a7968afe4fa2653246ecf4))
### Features
* **core:** boolean to disable systemAppearanceChanged (theme) ([#8827](https://github.com/NativeScript/NativeScript/issues/8827)) ([5286adf](https://github.com/NativeScript/NativeScript/commit/5286adf081cb75ea17251edd498266be7fe7189a))
* **core:** export additional properties for plugin usage ([#8835](https://github.com/NativeScript/NativeScript/issues/8835)) ([a2e1aa2](https://github.com/NativeScript/NativeScript/commit/a2e1aa246e6a9cbdd6d2c4647c9740ef411ad51a))
# [7.0.0](https://github.com/NativeScript/NativeScript/compare/6.5.15...7.0.0) (2020-09-03)

View File

@ -1,8 +1,11 @@
{
"main": "main.js",
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/NativeScript/NativeScript.git"
},
"scripts": {
"clean": "npx rimraf hooks node_modules platforms package-lock.json && npm i"
},

View File

@ -1,8 +1,11 @@
{
"main": "main.js",
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/NativeScript/NativeScript.git"
},
"dependencies": {
"nativescript-theme-core": "file:../../node_modules/nativescript-theme-core",
"@nativescript/core": "file:../../packages/core"

View File

@ -1,4 +1,10 @@
import { AppiumDriver, IRectangle, logInfo, logWarn, Point } from "nativescript-dev-appium";
import {
AppiumDriver,
IRectangle,
logInfo,
logWarn,
Point
} from "nativescript-dev-appium";
export enum ElementCacheStrategy {
allAtOnce,
@ -18,12 +24,15 @@ export class NavigationHelper {
private _cachedElements: ICachedElement;
private _currentSuite: ICachedElement;
constructor(protected _driver: AppiumDriver, protected _suitMainPageNavigationLinks: Array<string>, private _elemtsCacheStrategy: ElementCacheStrategy = ElementCacheStrategy.onload) {
}
constructor(
protected _driver: AppiumDriver,
protected _suitMainPageNavigationLinks: Array<string>,
private _elementsCacheStrategy: ElementCacheStrategy = ElementCacheStrategy.onload
) {}
async initSuite() {
if (this._elemtsCacheStrategy === ElementCacheStrategy.allAtOnce
|| this._elemtsCacheStrategy === ElementCacheStrategy.onload) {
async initSuite(): Promise<void> {
if (this._elementsCacheStrategy === ElementCacheStrategy.allAtOnce
|| this._elementsCacheStrategy === ElementCacheStrategy.onload) {
if (this._currentSuite) {
while (this._currentSuite.parent) {
this._currentSuite = this._currentSuite.parent;
@ -31,7 +40,7 @@ export class NavigationHelper {
} else {
if (!this._cachedElements || this._cachedElements.children.size === 0) {
this._cachedElements = { name: "initSuite", children: new Map<string, ICachedElement>() };
if (this._elemtsCacheStrategy === ElementCacheStrategy.allAtOnce) {
if (this._elementsCacheStrategy === ElementCacheStrategy.allAtOnce) {
await this.cacheAllElements(this._cachedElements);
}
}
@ -43,12 +52,12 @@ export class NavigationHelper {
await this.navigateToSuitMainPage();
}
async endSuite() {
logInfo("End of suit 'button' tests!");
async endSuite(): Promise<void> {
logInfo(`End of suit 'button' tests!`);
await this._driver.takeScreenshot("end_button_suit");
}
async navigateToSuitMainPage() {
async navigateToSuitMainPage(): Promise<void> {
for (let index = 0; index < this._suitMainPageNavigationLinks.length; index++) {
const mainPage = this._suitMainPageNavigationLinks[index];
await this.navigateToSample(mainPage);
@ -59,7 +68,7 @@ export class NavigationHelper {
logInfo(`Navigate to ${sample}`);
const sampleName = sample.toLowerCase();
if (this._elemtsCacheStrategy === ElementCacheStrategy.allAtOnce) {
if (this._elementsCacheStrategy === ElementCacheStrategy.allAtOnce) {
if (!this._currentSuite.children.has(sampleName)) {
await this.cacheAllElements(this._currentSuite);
}
@ -69,7 +78,7 @@ export class NavigationHelper {
const sampleElement = this._currentSuite.children.get(sampleName).rect;
await this._driver.clickPoint(sampleElement.x + (sampleElement.width / 2), sampleElement.y + (sampleElement.height / 2));
this._currentSuite = this._currentSuite.children.get(sampleName);
} else if (this._elemtsCacheStrategy === ElementCacheStrategy.onload) {
} else if (this._elementsCacheStrategy === ElementCacheStrategy.onload) {
if (this._currentSuite.children.has(sampleName)) {
const sampleElement = this._currentSuite.children.get(sampleName).rect;
await this._driver.clickPoint(sampleElement.x + (sampleElement.width / 2), sampleElement.y + (sampleElement.height / 2));
@ -94,14 +103,14 @@ export class NavigationHelper {
async navigateBackToSuitMainPage() {
logInfo(`Navigate to back`);
if (this._elemtsCacheStrategy === ElementCacheStrategy.allAtOnce
|| this._elemtsCacheStrategy === ElementCacheStrategy.onload) {
if (this._elementsCacheStrategy === ElementCacheStrategy.allAtOnce
|| this._elementsCacheStrategy === ElementCacheStrategy.onload) {
this._currentSuite = this._currentSuite && this._currentSuite.parent;
}
await this._driver.navBack();
}
async swipeBackToSuitMainPage() {
async swipeBackToSuitMainPage(): Promise<void> {
logInfo(`Swipe to back`);
const startPoint = <Point>{};
const endPoint = <Point>{};
@ -115,20 +124,29 @@ export class NavigationHelper {
await this._driver.swipe(startPoint, endPoint);
} else {
logWarn("Swipe back is not supported from android!");
logWarn(`Swipe back is not supported from android!`);
}
}
private async cacheAllElements(cachedElements: ICachedElement) {
const allSamples = await this._driver.findElementsByClassName(this._driver.locators.button);
private async cacheAllElements(cachedElements: ICachedElement): Promise<void> {
const allSamples = await this._driver.findElementsByClassName(this._driver.locators.button);
for (let index = 0; index < allSamples.length; index++) {
const element = allSamples[index];
const rect = await element.getRectangle();
const text = (await element.text()).toLowerCase();
if (!cachedElements.children.has(text)) {
console.log(text);
cachedElements.children.set(text, { parent: cachedElements, name: text, rect: rect, children: new Map() });
}
const text = (await element.text()).toLowerCase();
if (cachedElements.children.has(text)) continue
logInfo(text);
cachedElements.children.set(
text,
{
parent: cachedElements,
name: text,
rect: rect,
children: new Map()
}
);
}
}
}

View File

@ -1,8 +1,11 @@
{
"main": "main.js",
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/NativeScript/NativeScript.git"
},
"dependencies": {
"nativescript-theme-core": "file:../../node_modules/nativescript-theme-core",
"@nativescript/core": "file:../../packages/core"

View File

@ -1,6 +1,6 @@
{
"name": "nativescript",
"version": "7.0.0",
"version": "7.0.2",
"license": "MIT",
"config": {
"npm_alias": "npm"
@ -36,7 +36,11 @@
"webpack:test": "cd packages/webpack && npm run tsc && npm run jasmine",
"webpack:build": "cd packages/webpack npm run setup && mkdir -p ../../dist/packages && mv \"$(npm pack | tail -n 1)\" ../../dist/packages/nativescript-webpack.tgz"
},
"private": true,
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/NativeScript/NativeScript.git"
},
"dependencies": {
"nativescript-theme-core": "^1.0.4"
},

View File

@ -1,4 +1,4 @@
import { NavigationEntry } from '../ui/frame';
import { NavigationEntry } from '../ui/frame';
import { View } from '../ui/core/view';
import { Observable, EventData } from '../data/observable';
@ -57,7 +57,7 @@ export const systemAppearanceChangedEvent: string;
/**
* Boolean to enable/disable systemAppearanceChanged
*/
export let autoSystemAppearanceChanged = true;
export let autoSystemAppearanceChanged: boolean;
/**
* enable/disable systemAppearanceChanged

View File

@ -358,3 +358,6 @@ export function initGlobal() {
};
}
}
if (!global.NativeScriptHasInitGlobal) {
initGlobal();
}

View File

@ -8,7 +8,7 @@
export type { NativeScriptConfig } from './config';
export { iOSApplication, AndroidApplication } from './application';
export type { ApplicationEventData, LaunchEventData, OrientationChangedEventData, UnhandledErrorEventData, DiscardedErrorEventData, CssChangedEventData, LoadAppCSSEventData, AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, AndroidActivityNewIntentEventData, AndroidActivityBackPressedEventData, SystemAppearanceChangedEventData } from './application';
import { systemAppearanceChanged, getMainEntry, getRootView, _resetRootView, getResources, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, run, orientation, getNativeApplication, hasLaunched, systemAppearance } from './application';
import { systemAppearanceChanged, getMainEntry, getRootView, _resetRootView, getResources, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, notify, hasListeners, run, orientation, getNativeApplication, hasLaunched, systemAppearance } from './application';
export declare const Application: {
launchEvent: string;
displayedEvent: string;
@ -32,6 +32,8 @@ export declare const Application: {
addCss: typeof addCss;
on: typeof on;
off: typeof off;
notify: typeof notify;
hasListeners: typeof hasListeners;
run: typeof run;
orientation: typeof orientation;
getNativeApplication: typeof getNativeApplication;
@ -113,6 +115,10 @@ export declare const Utils: {
android: typeof androidUtils;
ad: typeof androidUtils;
ios: typeof iosUtils;
setTimeout: typeof setTimeout;
setInterval: typeof setInterval;
clearInterval: typeof clearInterval;
clearTimeout: typeof clearTimeout;
Source: typeof Source;
ClassInfo: typeof ClassInfo;
getClass: typeof getClass;

View File

@ -6,7 +6,7 @@ nsGlobals.initGlobal();
export { iOSApplication, AndroidApplication } from './application';
export type { ApplicationEventData, LaunchEventData, OrientationChangedEventData, UnhandledErrorEventData, DiscardedErrorEventData, CssChangedEventData, LoadAppCSSEventData, AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, AndroidActivityNewIntentEventData, AndroidActivityBackPressedEventData, SystemAppearanceChangedEventData } from './application';
import { launchEvent, displayedEvent, uncaughtErrorEvent, discardedErrorEvent, suspendEvent, resumeEvent, exitEvent, lowMemoryEvent, orientationChangedEvent, systemAppearanceChanged, systemAppearanceChangedEvent, getMainEntry, getRootView, _resetRootView, getResources, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, run, orientation, getNativeApplication, hasLaunched, android as appAndroid, ios as iosApp, systemAppearance } from './application';
import { launchEvent, displayedEvent, uncaughtErrorEvent, discardedErrorEvent, suspendEvent, resumeEvent, exitEvent, lowMemoryEvent, orientationChangedEvent, systemAppearanceChanged, systemAppearanceChangedEvent, getMainEntry, getRootView, _resetRootView, getResources, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, notify, hasListeners, run, orientation, getNativeApplication, hasLaunched, android as appAndroid, ios as iosApp, systemAppearance } from './application';
export const Application = {
launchEvent,
displayedEvent,
@ -30,7 +30,9 @@ export const Application = {
loadAppCss,
addCss,
on,
off,
off,
notify,
hasListeners,
run,
orientation,
getNativeApplication,
@ -103,7 +105,8 @@ export { profile, enable as profilingEnable, disable as profilingDisable, time a
export type { InstrumentationMode, TimerInfo } from './profiling';
export { encoding } from './text';
// for developers to be explicit if they desire around globals (allows access via Utils below)
import { setTimeout, setInterval, clearInterval, clearTimeout } from './timer';
export * from './trace';
export * from './ui';
@ -133,7 +136,11 @@ export const Utils = {
android: androidUtils,
// legacy (a lot of plugins use the shorthand "ad" Utils.ad instead of Utils.android)
ad: androidUtils,
ios: iosUtils,
ios: iosUtils,
setTimeout,
setInterval,
clearInterval,
clearTimeout,
Source,
ClassInfo,
getClass,

View File

@ -3,7 +3,7 @@
"main": "index",
"types": "index.d.ts",
"description": "NativeScript Core Modules",
"version": "7.0.0",
"version": "7.0.2",
"homepage": "https://nativescript.org",
"repository": {
"type": "git",

View File

@ -74,7 +74,7 @@ export type { TabStripItemEventData } from './tab-navigation-base/tab-strip';
export { TabStripItem } from './tab-navigation-base/tab-strip-item';
export { TabView, TabViewItem } from './tab-view';
export { Tabs } from './tabs';
export { TextBase, getTransformedText } from './text-base';
export { TextBase, getTransformedText, letterSpacingProperty, textAlignmentProperty, textDecorationProperty, textTransformProperty, whiteSpaceProperty, lineHeightProperty } from './text-base';
export type { TextTransform } from './text-base';
export { FormattedString } from './text-base/formatted-string';
export { Span } from './text-base/span';

View File

@ -1,6 +1,6 @@
{
"name": "@nativescript/webpack",
"version": "3.0.1",
"version": "3.0.4",
"main": "index",
"description": "Webpack plugin for NativeScript",
"homepage": "https://nativescript.org",

View File

@ -1,3 +1,7 @@
/**
* @see https://github.com/NativeScript/NativeScript/tree/feat/ns7-finishing-touches/packages/webpack/templates
* @see https://github.com/NativeScript/NativeScript/pull/8801/files
*/
const webpackConfig = require("./webpack.typescript");
const webpack = require("webpack");
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
@ -8,105 +12,77 @@ module.exports = (env) => {
const production = env.production;
const isAnySourceMapEnabled = !!env.sourceMap || !!env.hiddenSourceMap;
const babelOptions = {
sourceMaps: isAnySourceMapEnabled ? "inline" : false,
babelrc: false,
presets: [
// https://github.com/Microsoft/TypeScript-Babel-Starter
"@babel/env",
"@babel/typescript",
"@babel/react"
],
plugins: [
...(
hmr && !production ?
[
require.resolve('react-refresh/babel')
] :
[]
),
["@babel/plugin-proposal-class-properties", { loose: true }]
]
};
const baseConfig = webpackConfig(env);
// Remove ts-loader as we'll be using Babel to transpile the TypeScript instead.
baseConfig.module.rules = baseConfig.module.rules.filter((rule) => {
const isTsLoader = rule.use && rule.use.loader === "ts-loader";
return !isTsLoader;
});
/** Find the rule for transpiling ts files ("ts-loader"), and modify it to test for .tsx files too. */
const tsxRule = baseConfig.module.rules.find(rule => rule.use && rule.use.loader === "ts-loader");
tsxRule.test = /\.(ts|tsx)$/;
tsxRule.use = [
/**
* Add React Refresh HMR support.
* @see https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/55028c6355b31e697e21bf3e9a48613a7b94bee7/examples/typescript-without-babel/webpack.config.js#L18-L21
*/
hmr && !production && {
loader: "babel-loader",
options: {
sourceMaps: isAnySourceMapEnabled ? "inline" : false,
babelrc: false,
plugins: ['react-refresh/babel']
}
},
tsxRule.use,
].filter(Boolean);
// Modify "nativescript-dev-webpack/hmr/hot-loader" to test for .tsx files
// (and also js(x) files, which it should have been doing to begin with!)
baseConfig.module.rules.some(rule => {
const isNativeScriptDevWebpackHotLoader = rule.use === "nativescript-dev-webpack/hmr/hot-loader";
if(isNativeScriptDevWebpackHotLoader){
rule.test = /\.(ts|tsx|js|jsx|css|scss|html|xml)$/;
}
return isNativeScriptDevWebpackHotLoader; // Break loop once we've found the one.
});
baseConfig.module.rules.push(
{
test: /\.[jt]s(x?)$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
options: babelOptions
}
],
}
/**
* Modify "nativescript-dev-webpack/hmr/hot-loader" to test for .tsx files
* (and also js files, which it should have been doing to begin with!)
*/
const nativeScriptDevWebpackHotLoader = baseConfig.module.rules.find(rule =>
rule.use === "@nativescript/webpack/hmr/hot-loader"
);
nativeScriptDevWebpackHotLoader.test = /\.(ts|tsx|js|css|scss|html|xml)$/;
baseConfig.resolve.extensions = [".ts", ".tsx", ".js", ".jsx", ".scss", ".css"];
/** We don't officially support JSX. Makes the webpack config rather more complicated to set up. */
baseConfig.resolve.extensions = [".tsx", ...baseConfig.resolve.extensions];
baseConfig.resolve.alias["react-dom"] = "react-nativescript";
// Remove ForkTsCheckerWebpackPlugin because, now that we're using Babel, we'll leave type-checking to the IDE instead.
baseConfig.plugins = baseConfig.plugins.filter(plugin => {
const isForkTsCheckerWebpackPlugin = plugin && plugin.constructor && plugin.constructor.name === "ForkTsCheckerWebpackPlugin";
return !isForkTsCheckerWebpackPlugin;
});
/** Augment NativeScript's existing DefinePlugin definitions with a few more of our own. */
const existingDefinePlugin = baseConfig.plugins.find(plugin =>
plugin && plugin.constructor && plugin.constructor.name === "DefinePlugin"
);
baseConfig.plugins.splice(
baseConfig.plugins.indexOf(existingDefinePlugin),
1,
new webpack.DefinePlugin({
...existingDefinePlugin.definitions,
/** For various libraries in the React ecosystem. */
"__DEV__": production ? "false" : "true",
"__TEST__": "false",
/**
* Primarily for React Fast Refresh plugin, but technically the allowHmrInProduction option could be used instead.
* Worth including anyway, as there are plenty of Node libraries that use this flag.
*/
"process.env.NODE_ENV": JSON.stringify(production ? "production" : "development"),
}),
);
// Augment NativeScript's existing DefinePlugin definitions with a few more of our own.
let existingDefinePlugin;
baseConfig.plugins = baseConfig.plugins.filter(plugin => {
const isDefinePlugin = plugin && plugin.constructor && plugin.constructor.name === "DefinePlugin";
existingDefinePlugin = plugin;
return !isDefinePlugin;
});
const newDefinitions = {
...existingDefinePlugin.definitions,
/* For various libraries in the React ecosystem. */
"__DEV__": production ? "false" : "true",
"__TEST__": "false",
/*
* Primarily for React Fast Refresh plugin, but technically the forceEnable option could be used instead.
* Worth including anyway, as there are plenty of Node libraries that use this flag.
*/
"process.env.NODE_ENV": JSON.stringify(production ? "production" : "development"),
};
baseConfig.plugins.unshift(new webpack.DefinePlugin(newDefinitions));
/**
* Set forceEnable to `true` if you want to use HMR on a production build.
*/
const forceEnable = false;
if(hmr && (!production || forceEnable)){
if(hmr && !production){
baseConfig.plugins.push(new ReactRefreshWebpackPlugin({
/**
* Maybe one day we'll implement an Error Overlay, but the work involved is too daunting for now.
* @see https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/79#issuecomment-644324557
*/
overlay: false,
forceEnable,
/**
* If you (temporarily) want to enable HMR on a production build:
* 1) Set `forceEnable` to `true`
* 2) Remove the `!production` condition on `tsxRule` to ensure that babel-loader gets used.
*/
forceEnable: false,
}));
} else {
baseConfig.plugins = baseConfig.plugins.filter(p => !(p && p.constructor && p.constructor.name === "HotModuleReplacementPlugin"));
}
return baseConfig;
};
};

View File

@ -5,7 +5,7 @@ const {
getPackageJson,
getProjectDir,
writePackageJson,
} = require("../projectHelpers");
} = require("../helpers/projectHelpers");
const { forceUpdateProjectFiles } = require("../helpers/projectFilesManager");
const { forceUpdateProjectDeps } = require("../helpers/dependencyManager");

View File

@ -300,12 +300,8 @@
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
{
"command": "./build.sh"
},
{
"command": "cp -R dist/package/platforms/* ../../packages/core/platforms"
}
"./build.sh",
"cp -R dist/package/platforms/* ../../packages/core/platforms"
],
"cwd": "packages/ui-mobile-base",
"parallel": false
@ -337,12 +333,8 @@
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
{
"command": "npm run tsc"
},
{
"command": "npm run jasmine"
}
"npm run tsc",
"npm run jasmine"
],
"cwd": "packages/webpack",
"parallel": false
@ -353,15 +345,9 @@
"outputs": ["dist/packages"],
"options": {
"commands": [
{
"command": "npm run setup"
},
{
"command": "mkdir -p ../../dist/packages"
},
{
"command": "mv \"$(npm pack | tail -n 1)\" ../../dist/packages/nativescript-webpack.tgz"
}
"npm run setup",
"mkdir -p ../../dist/packages",
"mv \"$(npm pack | tail -n 1)\" ../../dist/packages/nativescript-webpack.tgz"
],
"cwd": "packages/webpack",
"parallel": false