chore: TypeScript 5.1 with Nx 16.6 migrations (#10338)

This commit is contained in:
Nathan Walker
2023-08-11 07:09:32 -07:00
committed by GitHub
parent 7a353eca14
commit d3a0f2c9a6
61 changed files with 741 additions and 483 deletions

View File

@ -1,12 +1,12 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
@ -23,7 +23,7 @@
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "plugin:@nrwl/nx/typescript"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "plugin:@nx/typescript"],
"rules": {
"no-empty": "off",
"no-useless-escape": "off",
@ -43,7 +43,7 @@
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
@ -51,6 +51,11 @@
"rules": {
"@typescript-eslint/triple-slash-reference": "off"
}
},
{
"files": "*.json",
"parser": "jsonc-eslint-parser",
"rules": {}
}
]
}

View File

@ -1,4 +1,3 @@
// Place your settings in this file to overwrite default and user settings.
{
"search.exclude": {
"**/node_modules": true,
@ -6,5 +5,6 @@
"**/platforms": true,
"**/*.js": true,
"**/*.js.map": true
}
},
"eslint.validate": ["json"]
}

View File

@ -15,7 +15,7 @@
"@nativescript/ios": "~8.5.0",
"@nativescript/webpack": "file:../../dist/packages/nativescript-webpack.tgz",
"circular-dependency-plugin": "^5.2.2",
"typescript": "~4.9.5"
"typescript": "5.1.6"
},
"gitHead": "c06800e52ee1a184ea2dffd12a6702aaa43be4e3",
"readme": "NativeScript Application"

View File

@ -474,15 +474,15 @@ export var test_RepeaterItemsGestureBindings = function () {
helper.navigateToModuleAndRunTest('ui/repeater/repeaterItems-bindingToGestures-page', null, testFunc);
};
export var test_RepeaterItemsParentBindingsShouldWork = function () {
export var test_RepeaterItemsBindingsShouldWork = function () {
var testFunc = function (page: Page) {
var repeater = <Repeater>page.getViewById('repeater');
var expectedText = page.bindingContext['parentViewProperty'];
var testPass = false;
var expectedText = page.bindingContext['items'];
var testPass: string;
var eachChildCallback = function (childItem: View) {
if (childItem instanceof Label) {
testPass = (<Label>childItem).text === expectedText;
if (testPass === false) {
testPass = (<Label>childItem).text;
if (!testPass) {
return false;
}
} else if (childItem instanceof LayoutBase) {
@ -494,7 +494,7 @@ export var test_RepeaterItemsParentBindingsShouldWork = function () {
repeater.eachChildView(eachChildCallback);
TKUnit.assertEqual(testPass, true, 'Every item should have text bound to Page binding context!');
TKUnit.assertEqual(!!testPass, true, 'Every item should have text bound to binding context!');
};
helper.navigateToModuleAndRunTest('ui/repeater/repeaterItems-bindingToGestures-page', null, testFunc);

View File

@ -1,4 +1,4 @@
function pageLoaded(args) {
export function pageLoaded(args) {
var page = args.object;
page.bindingContext = {
items: [
@ -18,8 +18,3 @@ function pageLoaded(args) {
parentViewProperty: 'Parent View Property',
};
}
exports.pageLoaded = pageLoaded;
exports.tapPage = function (args) {
console.log('Tap! ' + args + ' ' + args.object);
};

View File

@ -1,8 +1,8 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded">
<Repeater id="repeater" items="{{ items }}">
<Repeater.itemTemplate>
<GridLayout width="94" height="94" >
<Label text="{{ $parents['Page'].parentViewProperty }}" tap="{{ tapItem }}" />
<GridLayout width="94" height="94">
<Label text="{{ text }}" tap="{{ tapItem }}" />
</GridLayout>
</Repeater.itemTemplate>
</Repeater>

View File

@ -15,6 +15,6 @@
"@nativescript/android": "~8.5.0",
"@nativescript/ios": "~8.5.0",
"@nativescript/webpack": "file:../../dist/packages/nativescript-webpack.tgz",
"typescript": "~4.9.5"
"typescript": "5.1.6"
}
}

View File

@ -14,7 +14,7 @@
"@nativescript/android": "~8.5.0",
"@nativescript/ios": "~8.5.0",
"@nativescript/webpack": "file:../../dist/packages/nativescript-webpack.tgz",
"typescript": "~4.9.5"
"typescript": "5.1.6"
},
"gitHead": "8ab7726d1ee9991706069c1359c552e67ee0d1a4",
"readme": "NativeScript Application",

View File

@ -18,8 +18,8 @@ Application.on('displayed', (args) => {
Application.on('uncaughtError', (args) => {
const error = args.error;
console.warn(error.message);
if (error.nativeError) {
console.warn('native error: ' + error.nativeError);
if (error.nativeException) {
console.warn('native error: ' + error.nativeException);
}
});

View File

@ -1,3 +1,3 @@
const { getJestProjects } = require('@nrwl/jest');
const { getJestProjects } = require('@nx/jest');
export default { projects: getJestProjects() };

View File

@ -1,4 +1,4 @@
const nxPreset = require('@nrwl/jest/preset').default;
const nxPreset = require('@nx/jest/preset').default;
module.exports = {
...nxPreset,

124
migrations.json Normal file
View File

@ -0,0 +1,124 @@
{
"migrations": [
{
"cli": "nx",
"version": "16.0.0-beta.0",
"description": "Remove @nrwl/cli.",
"implementation": "./src/migrations/update-16-0-0/remove-nrwl-cli",
"package": "nx",
"name": "16.0.0-remove-nrwl-cli"
},
{
"cli": "nx",
"version": "16.0.0-beta.9",
"description": "Replace `dependsOn.projects` and `inputs` definitions with new configuration format.",
"implementation": "./src/migrations/update-16-0-0/update-depends-on-to-tokens",
"package": "nx",
"name": "16.0.0-tokens-for-depends-on"
},
{
"cli": "nx",
"version": "16.0.0-beta.0",
"description": "Replace @nrwl/nx-cloud with nx-cloud",
"implementation": "./src/migrations/update-16-0-0/update-nx-cloud-runner",
"package": "nx",
"name": "16.0.0-update-nx-cloud-runner"
},
{
"cli": "nx",
"version": "16.2.0-beta.0",
"description": "Remove outputPath from run commands",
"implementation": "./src/migrations/update-16-2-0/remove-run-commands-output-path",
"package": "nx",
"name": "16.2.0-remove-output-path-from-run-commands"
},
{
"cli": "nx",
"version": "16.6.0-beta.6",
"description": "Prefix outputs with {workspaceRoot}/{projectRoot} if needed",
"implementation": "./src/migrations/update-15-0-0/prefix-outputs",
"package": "nx",
"name": "16.6.0-prefix-outputs"
},
{
"cli": "nx",
"version": "16.0.0-beta.1",
"description": "Replace @nx/workspace with @nx/workspace",
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages",
"package": "@nx/workspace",
"name": "update-16-0-0-add-nx-packages"
},
{
"version": "16.0.0-beta.4",
"description": "Generates a plugin called 'workspace-plugin' containing your workspace generators.",
"cli": "nx",
"implementation": "./src/migrations/update-16-0-0/move-workspace-generators-to-local-plugin",
"package": "@nx/workspace",
"name": "16-0-0-move-workspace-generators-into-local-plugin"
},
{
"version": "16.0.0-beta.9",
"description": "Fix .babelrc presets if it contains an invalid entry for @nx/web/babel.",
"cli": "nx",
"implementation": "./src/migrations/update-16-0-0/fix-invalid-babelrc",
"package": "@nx/workspace",
"name": "16-0-0-fix-invalid-babelrc"
},
{
"cli": "nx",
"version": "16.0.0-beta.1",
"description": "Replace @nx/eslint-plugin with @nx/eslint-plugin",
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages",
"package": "@nx/eslint-plugin",
"name": "update-16-0-0-add-nx-packages"
},
{
"cli": "nx",
"version": "16.0.0-beta.1",
"description": "Replace @nx/node with @nx/node",
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages",
"package": "@nx/node",
"name": "update-16-0-0-add-nx-packages"
},
{
"cli": "nx",
"version": "16.0.0-beta.5",
"description": "Replace @nx/node:webpack with @nx/node:webpack",
"implementation": "./src/migrations/update-16-0-0/update-webpack-executor",
"package": "@nx/node",
"name": "update-16-0-0-update-executor"
},
{
"cli": "nx",
"version": "16.3.1-beta.0",
"description": "Replace @nx/node:webpack and @nx/node:webpack with @nx/webpack:webpack for all project targets",
"implementation": "./src/migrations/update-16-3-1/update-webpack-executor",
"package": "@nx/node",
"name": "update-16-3-1-update-executor"
},
{
"cli": "nx",
"version": "16.4.0-beta.8",
"description": "Replace @nx/node:node with @nx/js:node for all project targets",
"implementation": "./src/migrations/update-16-4-0/replace-node-executor",
"package": "@nx/node",
"name": "update-16-4-0-replace-node-executor"
},
{
"cli": "nx",
"version": "16.0.0-beta.1",
"description": "Replace @nx/jest with @nx/jest",
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages",
"package": "@nx/jest",
"name": "update-16-0-0-add-nx-packages"
},
{
"cli": "nx",
"version": "16.5.0-beta.2",
"description": "Add test-setup.ts to ignored files in production input",
"implementation": "./src/migrations/update-16-5-0/add-test-setup-to-inputs-ignore",
"package": "@nx/jest",
"name": "add-test-setup-to-inputs-ignore"
}
]
}

30
nx.json
View File

@ -6,7 +6,7 @@
},
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/nx-cloud",
"runner": "nx-cloud",
"options": {
"useDaemonProcess": false,
"cacheableOperations": ["build", "lint", "test", "ios", "android", "e2e"],
@ -18,11 +18,6 @@
}
},
"generators": {
"@nrwl/workspace": {
"library": {
"linter": "eslint"
}
},
"@nrwl/cypress": {
"cypress-project": {
"linter": "eslint"
@ -46,14 +41,6 @@
"linter": "eslint"
}
},
"@nrwl/node": {
"application": {
"linter": "eslint"
},
"library": {
"linter": "eslint"
}
},
"@nrwl/nx-plugin": {
"plugin": {
"linter": "eslint"
@ -71,6 +58,19 @@
"library": {
"linter": "eslint"
}
},
"@nx/workspace": {
"library": {
"linter": "eslint"
}
},
"@nx/node": {
"application": {
"linter": "eslint"
},
"library": {
"linter": "eslint"
}
}
},
"affected": {
@ -80,7 +80,7 @@
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"sharedGlobals": ["{workspaceRoot}/workspace.json", "{workspaceRoot}/tsconfig.json", "{workspaceRoot}/nx.json"],
"production": ["default", "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)", "!{projectRoot}/tsconfig.spec.json", "!{projectRoot}/jest.config.[jt]s"]
"production": ["default", "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)", "!{projectRoot}/tsconfig.spec.json", "!{projectRoot}/jest.config.[jt]s", "!{projectRoot}/src/test-setup.[jt]s"]
},
"targetDefaults": {
"build": {

View File

@ -18,25 +18,29 @@
"url": "https://github.com/NativeScript/NativeScript.git"
},
"dependencies": {
"@nrwl/nx-cloud": "15.3.5",
"nativescript-theme-core": "^1.0.4"
"@nx/devkit": "16.6.0",
"@swc/helpers": "~0.5.0",
"nativescript-theme-core": "^1.0.4",
"nx-cloud": "16.3.0"
},
"devDependencies": {
"@nativescript/hook": "^2.0.0",
"@nativescript/nx": "~4.2.0",
"@nrwl/cli": "15.9.2",
"@nrwl/eslint-plugin-nx": "15.9.2",
"@nrwl/jest": "15.9.2",
"@nrwl/node": "15.9.2",
"@nrwl/workspace": "15.9.2",
"@nstudio/focus": "^15.0.0",
"@nativescript/nx": "^16.5.0",
"@nstudio/focus": "^16.5.0",
"@nstudio/nps-i": "~2.0.0",
"@nx/jest": "16.6.0",
"@nx/js": "16.6.0",
"@nx/plugin": "16.6.0",
"@nx/workspace": "16.6.0",
"@prettier/plugin-xml": "^2.2.0",
"@swc-node/register": "~1.4.2",
"@swc/cli": "~0.1.62",
"@swc/core": "~1.3.51",
"@types/jest": "~29.5.0",
"@types/node": "18.7.1",
"@typescript-eslint/eslint-plugin": "^5.30.0",
"@typescript-eslint/parser": "^5.30.0",
"conventional-changelog-cli": "^2.2.2",
"@types/node": "^18.7.1",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"conventional-changelog-cli": "^3.0.0",
"copyfiles": "^2.4.0",
"css": "^3.0.0",
"css-tree": "^1.1.2",
@ -47,11 +51,12 @@
"gonzales": "^1.0.7",
"husky": "^8.0.1",
"jest": "~29.5.0",
"lint-staged": "^13.1.0",
"jest-environment-jsdom": "^29.4.1",
"lint-staged": "^13.2.0",
"module-alias": "^2.2.2",
"nativescript": "~8.5.0",
"nativescript-typedoc-theme": "1.1.0",
"nx": "15.9.2",
"nx": "16.6.0",
"parse-css": "git+https://github.com/tabatkins/parse-css.git",
"parserlib": "^1.1.1",
"prettier": "^2.6.2",
@ -59,13 +64,15 @@
"sass": "^1.45.2",
"shady-css-parser": "^0.1.0",
"tree-kill": "^1.2.2",
"ts-jest": "29.1.0",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"ts-patch": "^2.1.0",
"tslib": "^2.5.0",
"typedoc": "^0.23.24",
"typescript": "~4.9.5",
"zx": "^7.0.5"
"ts-patch": "^3.0.0",
"tslib": "^2.6.0",
"typedoc": "^0.24.8",
"typescript": "5.1.6",
"zx": "^7.0.5",
"@nx/eslint-plugin": "16.6.0",
"@nx/node": "16.6.0"
},
"lint-staged": {
"**/*": [
@ -73,4 +80,3 @@
]
}
}

View File

@ -120,6 +120,9 @@ global.UIApplicationDidChangeStatusBarOrientationNotification = 'UIApplicationDi
global.UIResponder = function () {};
global.UIResponder.extend = function () {};
global.UIViewController = function () {};
global.UIViewControllerTransitioningDelegate = function () {};
global.UIGestureRecognizer = function () {};
global.UIGestureRecognizerDelegate = function () {};
global.UIAdaptivePresentationControllerDelegate = function () {};
global.UIPopoverPresentationControllerDelegate = function () {};
global.UIContentSizeCategoryExtraSmall = 0.5;

View File

@ -4,6 +4,23 @@
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>TNSWidgets.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
@ -35,23 +52,6 @@
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
<dict>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>TNSWidgets.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>

View File

@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>22D68</string>
<string>22F82</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
@ -29,19 +29,19 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>14A309</string>
<string></string>
<key>DTPlatformName</key>
<string>macosx</string>
<key>DTPlatformVersion</key>
<string>12.3</string>
<string>13.3</string>
<key>DTSDKBuild</key>
<string>21E226</string>
<string>22E245</string>
<key>DTSDKName</key>
<string>macosx12.3</string>
<string>macosx13.3</string>
<key>DTXcode</key>
<string>1400</string>
<string>1431</string>
<key>DTXcodeBuild</key>
<string>14A309</string>
<string>14E300c</string>
<key>LSMinimumSystemVersion</key>
<string>10.15</string>
<key>UIDeviceFamily</key>

View File

@ -38,7 +38,7 @@
</data>
<key>Info.plist</key>
<data>
myeIggkwNuTIqt7xlMgf8VGsKZ8=
xHG9+nBhI2hgaqloBzaUDHtutEU=
</data>
<key>Modules/module.modulemap</key>
<data>

View File

@ -16,9 +16,9 @@
}
},
"test": {
"executor": "@nrwl/jest:jest",
"executor": "@nx/jest:jest",
"inputs": ["default", "^production"],
"outputs": ["dist/out-tsc"],
"outputs": ["{workspaceRoot}/dist/out-tsc"],
"options": {
"jestConfig": "packages/core/jest.config.ts",
"passWithNoTests": true,

View File

@ -4,7 +4,7 @@
"noEmitOnError": true,
"noEmitHelpers": true,
"declaration": true,
"noImplicitUseStrict": true,
"ignoreDeprecations": "5.0",
"removeComments": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,

View File

@ -11,6 +11,7 @@ import { Observable, PropertyChangeData, WrappedValue } from '../../../data/obse
import { Style } from '../../styling/style';
import { paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty } from '../../styling/style-properties';
import type { ModalTransition } from '../../transition/modal-transition';
import type { GestureEventData } from '../../gestures';
// TODO: Remove this import!
import { getClass } from '../../../utils/types';

View File

@ -31,7 +31,9 @@ const PFLAG_LAYOUT_REQUIRED = 1 << 2;
const majorVersion = iOSNativeHelper.MajorVersion;
export class View extends ViewCommon implements ViewDefinition {
// @ts-ignore
nativeViewProtected: UIView;
// @ts-ignore
viewController: UIViewController;
private _popoverPresentationDelegate: IOSHelper.UIPopoverPresentationControllerDelegateImp;
private _adaptivePresentationDelegate: IOSHelper.UIAdaptivePresentationControllerDelegateImp;
@ -992,8 +994,6 @@ class UIViewControllerTransitioningDelegateImpl extends NSObject implements UIVi
}
export class ContainerView extends View {
public iosOverflowSafeArea: boolean;
constructor() {
super();
this.iosOverflowSafeArea = true;
@ -1001,6 +1001,7 @@ export class ContainerView extends View {
}
export class CustomLayoutView extends ContainerView {
// @ts-ignore
nativeViewProtected: UIView;
createNativeView() {

View File

@ -279,7 +279,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
const gesture = gestureFromString(arg);
if (gesture && !this._isEvent(arg)) {
this._observe(gesture, callback, thisArg);
this._observe(gesture, callback as unknown as (data: GestureEventData) => void, thisArg);
} else {
const events = arg.split(',');
if (events.length > 0) {
@ -287,7 +287,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
const evt = events[i].trim();
const gst = gestureFromString(evt);
if (gst && !this._isEvent(arg)) {
this._observe(gst, callback, thisArg);
this._observe(gst, callback as unknown as (data: GestureEventData) => void, thisArg);
} else {
super.addEventListener(evt, callback, thisArg);
}
@ -297,7 +297,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
}
}
} else if (typeof arg === 'number') {
this._observe(<GestureTypes>arg, callback, thisArg);
this._observe(<GestureTypes>arg, callback as unknown as (data: GestureEventData) => void, thisArg);
}
}

View File

@ -1,46 +1,288 @@
import { GestureEventData, GesturesObserver as GesturesObserverDefinition } from '.';
import { View } from '../core/view';
import type { GesturesObserver as GesturesObserverDefinition } from '.';
import type { View } from '../core/view';
import type { EventData } from '../../data/observable';
export * from './touch-manager';
/**
* Events emitted during gesture lifecycle
*/
export enum GestureEvents {
/**
* When the gesture is attached to the view
* Provides access to the native gesture recognizer for further customization
*/
gestureAttached = 'gestureAttached',
/**
* When a touch down was detected
*/
touchDown = 'touchDown',
/**
* When a touch up was detected
*/
touchUp = 'touchUp',
}
/**
* Defines an enum with supported gesture types.
*/
export enum GestureTypes {
/**
* Denotes tap (click) gesture.
*/
tap = 1 << 0,
/**
* Denotes double tap gesture.
*/
doubleTap = 1 << 1,
/**
* Denotes pinch gesture.
*/
pinch = 1 << 2,
/**
* Denotes pan gesture.
*/
pan = 1 << 3,
/**
* Denotes swipe gesture.
*/
swipe = 1 << 4,
/**
* Denotes rotation gesture.
*/
rotation = 1 << 5,
/**
* Denotes long press gesture.
*/
longPress = 1 << 6,
/**
* Denotes touch action.
*/
touch = 1 << 7,
}
/**
* Defines an enum with supported gesture states.
*/
export enum GestureStateTypes {
/**
* Gesture canceled.
*/
cancelled,
/**
* Gesture began.
*/
began,
/**
* Gesture changed.
*/
changed,
/**
* Gesture ended.
*/
ended,
}
/**
* Defines an enum for swipe gesture direction.
*/
export enum SwipeDirection {
/**
* Denotes right direction for swipe gesture.
*/
right = 1 << 0,
/**
* Denotes left direction for swipe gesture.
*/
left = 1 << 1,
/**
* Denotes up direction for swipe gesture.
*/
up = 1 << 2,
/**
* Denotes down direction for swipe gesture.
*/
down = 1 << 3,
}
export namespace TouchAction {
export const down = 'down';
export const up = 'up';
export const move = 'move';
export const cancel = 'cancel';
/**
* Defines a touch action
*/
export enum TouchAction {
/**
* Down action.
*/
down = 'down',
/**
* Up action.
*/
up = 'up',
/**
* Move action.
*/
move = 'move',
/**
* Cancel action.
*/
cancel = 'cancel',
}
/**
* Provides gesture event data.
*/
export interface GestureEventData extends EventData {
/**
* Gets the type of the gesture.
*/
type: GestureTypes;
/**
* Gets the view which originates the gesture.
*/
view: View;
/**
* Gets the underlying native iOS specific [UIGestureRecognizer](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/).
*/
ios: any /* UIGestureRecognizer */;
/**
* Gets the underlying native android specific [gesture detector](http://developer.android.com/reference/android/view/GestureDetector.html).
*/
android: any;
}
/**
* Provides gesture event data.
*/
export interface TapGestureEventData extends GestureEventData {
/**
* Gets the number of pointers in the event.
*/
getPointerCount(): number;
/**
* Gets the X coordinate of this event inside the view that triggered the event
*/
getX(): number;
/**
* Gets the Y coordinate of the event inside the view that triggered the event.
*/
getY(): number;
}
/**
* Provides gesture event data.
*/
export interface TouchGestureEventData extends TapGestureEventData {
/**
* Gets action of the touch. Possible values: 'up', 'move', 'down', 'cancel'
*/
action: 'up' | 'move' | 'down' | 'cancel';
/**
* Gets the pointers that triggered the event.
* Note: In Android there is aways only one active pointer.
*/
getActivePointers(): Array<Pointer>;
/**
* Gets all pointers.
*/
getAllPointers(): Array<Pointer>;
}
/**
* Pointer is an object representing a finger (or other object) that is touching the screen.
*/
export interface Pointer {
/**
* The id of the pointer.
*/
android: any;
/**
* The UITouch object associated to the touch
*/
ios: any;
/**
* Gets the X coordinate of the pointer inside the view that triggered the event.
*/
getX(): number;
/**
* Gets the Y coordinate of the pointer inside the view that triggered the event.
*/
getY(): number;
/**
* Gests the X coordinate of the pointer inside the view that triggered the event.
* @returns The X coordinate in _Device Pixels_.
*/
getXPixels(): number;
/**
* Gets the X coordinate of the pointer inside the view that triggered the event.
* @returns The X coordinate in _Device Independent Pixels_.
*/
getXDIP(): number;
/**
* Gests the Y coordinate of the pointer inside the view that triggered the event.
* @returns The Y coordinate in _Device Pixels_.
*/
getYPixels(): number;
/**
* Gets the Y coordinate of the pointer inside the view that triggered the event.
* @returns The Y coordinate in _Device Independent Pixels_.
*/
getYDIP(): number;
}
/**
* Provides gesture event data.
*/
export interface GestureEventDataWithState extends GestureEventData {
state: number;
}
/**
* Provides gesture event data for pinch gesture.
*/
export interface PinchGestureEventData extends GestureEventDataWithState {
scale: number;
getFocusX(): number;
getFocusY(): number;
}
/**
* Provides gesture event data for swipe gesture.
*/
export interface SwipeGestureEventData extends GestureEventData {
direction: SwipeDirection;
}
/**
* Provides gesture event data for pan gesture.
*/
export interface PanGestureEventData extends GestureEventDataWithState {
deltaX: number;
deltaY: number;
}
/**
* Provides gesture event data for rotation gesture.
*/
export interface RotationGestureEventData extends GestureEventDataWithState {
rotation: number;
}
/**
* Returns a string representation of a gesture type.
* @param type - Type of the gesture.
* @param separator(optional) - Text separator between gesture type strings.
*/
export function toString(type: GestureTypes, separator?: string): string {
const types = new Array<string>();
@ -81,6 +323,10 @@ export function toString(type: GestureTypes, separator?: string): string {
// NOTE: toString could return the text of multiple GestureTypes.
// Souldn't fromString do split on separator and return multiple GestureTypes?
/**
* Returns a gesture type enum value from a string (case insensitive).
* @param type - A string representation of a gesture type (e.g. Tap).
*/
export function fromString(type: string): GestureTypes {
const t = type.trim().toLowerCase();

View File

@ -1,282 +1,8 @@
import { View } from '../core/view';
import { EventData } from '../../data/observable';
import type { View } from '../core/view';
export * from './gestures-common';
export * from './touch-manager';
/**
* Events emitted during gesture lifecycle
*/
export enum GestureEvents {
/**
* When the gesture is attached to the view
* Provides access to the native gesture recognizer for further customization
*/
gestureAttached = 'gestureAttached',
/**
* When a touch down was detected
*/
touchDown = 'touchDown',
/**
* When a touch up was detected
*/
touchUp = 'touchUp',
}
/**
* Defines an enum with supported gesture types.
*/
export enum GestureTypes {
/**
* Denotes tap (click) gesture.
*/
tap,
/**
* Denotes double tap gesture.
*/
doubleTap,
/**
* Denotes pinch gesture.
*/
pinch,
/**
* Denotes pan gesture.
*/
pan,
/**
* Denotes swipe gesture.
*/
swipe,
/**
* Denotes rotation gesture.
*/
rotation,
/**
* Denotes long press gesture.
*/
longPress,
/**
* Denotes touch action.
*/
touch,
}
/**
* Defines an enum with supported gesture states.
*/
export enum GestureStateTypes {
/**
* Gesture canceled.
*/
cancelled,
/**
* Gesture began.
*/
began,
/**
* Gesture changed.
*/
changed,
/**
* Gesture ended.
*/
ended,
}
/**
* Defines an enum for swipe gesture direction.
*/
export enum SwipeDirection {
/**
* Denotes right direction for swipe gesture.
*/
right,
/**
* Denotes left direction for swipe gesture.
*/
left,
/**
* Denotes up direction for swipe gesture.
*/
up,
/**
* Denotes down direction for swipe gesture.
*/
down,
}
/**
* Defines a touch action
*/
export namespace TouchAction {
/**
* Down action.
*/
export const down: string;
/**
* Up action.
*/
export const up: string;
/**
* Move action.
*/
export const move: string;
/**
* Cancel action.
*/
export const cancel: string;
}
/**
* Provides gesture event data.
*/
export interface GestureEventData extends EventData {
/**
* Gets the type of the gesture.
*/
type: GestureTypes;
/**
* Gets the view which originates the gesture.
*/
view: View;
/**
* Gets the underlying native iOS specific [UIGestureRecognizer](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/).
*/
ios: any /* UIGestureRecognizer */;
/**
* Gets the underlying native android specific [gesture detector](http://developer.android.com/reference/android/view/GestureDetector.html).
*/
android: any;
}
/**
* Provides gesture event data.
*/
export interface TapGestureEventData extends GestureEventData {
/**
* Gets the number of pointers in the event.
*/
getPointerCount(): number;
/**
* Gets the X coordinate of this event inside the view that triggered the event
*/
getX(): number;
/**
* Gets the Y coordinate of the event inside the view that triggered the event.
*/
getY(): number;
}
/**
* Provides gesture event data.
*/
export interface TouchGestureEventData extends TapGestureEventData {
/**
* Gets action of the touch. Possible values: 'up', 'move', 'down', 'cancel'
*/
action: 'up' | 'move' | 'down' | 'cancel';
/**
* Gets the pointers that triggered the event.
* Note: In Android there is aways only one active pointer.
*/
getActivePointers(): Array<Pointer>;
/**
* Gets all pointers.
*/
getAllPointers(): Array<Pointer>;
}
/**
* Pointer is an object representing a finger (or other object) that is touching the screen.
*/
export interface Pointer {
/**
* The id of the pointer.
*/
android: any;
/**
* The UITouch object associated to the touch
*/
ios: any;
/**
* Gets the X coordinate of the pointer inside the view that triggered the event.
*/
getX(): number;
/**
* Gets the Y coordinate of the pointer inside the view that triggered the event.
*/
getY(): number;
/**
* Gests the X coordinate of the pointer inside the view that triggered the event.
* @returns The X coordinate in _Device Pixels_.
*/
getXPixels(): number;
/**
* Gets the X coordinate of the pointer inside the view that triggered the event.
* @returns The X coordinate in _Device Independent Pixels_.
*/
getXDIP(): number;
/**
* Gests the Y coordinate of the pointer inside the view that triggered the event.
* @returns The Y coordinate in _Device Pixels_.
*/
getYPixels(): number;
/**
* Gets the Y coordinate of the pointer inside the view that triggered the event.
* @returns The Y coordinate in _Device Independent Pixels_.
*/
getYDIP(): number;
}
/**
* Provides gesture event data.
*/
export interface GestureEventDataWithState extends GestureEventData {
state: number;
}
/**
* Provides gesture event data for pinch gesture.
*/
export interface PinchGestureEventData extends GestureEventDataWithState {
scale: number;
getFocusX(): number;
getFocusY(): number;
}
/**
* Provides gesture event data for swipe gesture.
*/
export interface SwipeGestureEventData extends GestureEventData {
direction: SwipeDirection;
}
/**
* Provides gesture event data for pan gesture.
*/
export interface PanGestureEventData extends GestureEventDataWithState {
deltaX: number;
deltaY: number;
}
/**
* Provides gesture event data for rotation gesture.
*/
export interface RotationGestureEventData extends GestureEventDataWithState {
rotation: number;
}
/**
* Provides options for the GesturesObserver.
*/
@ -329,16 +55,3 @@ export class GesturesObserver {
* @param context - this argument for the callback.
*/
export function observe(target: View, type: GestureTypes, callback: (args: GestureEventData) => void, context?: any): GesturesObserver;
/**
* Returns a string representation of a gesture type.
* @param type - Type of the gesture.
* @param separator(optional) - Text separator between gesture type strings.
*/
export function toString(type: GestureTypes, separator?: string): string;
/**
* Returns a gesture type enum value from a string (case insensitive).
* @param type - A string representation of a gesture type (e.g. Tap).
*/
export function fromString(type: string): GestureTypes;

View File

@ -1,3 +1,4 @@
import { GestureTypes } from '../gestures';
import { SharedTransition, SharedTransitionAnimationType } from './shared-transition';
describe('SharedTransition', () => {
@ -44,7 +45,7 @@ describe('SharedTransition', () => {
const state = SharedTransition.getState(transition.instance.id);
expect(state.activeType).toBe(SharedTransitionAnimationType.present);
expect(state.interactive.dismiss.finishThreshold).toBe(0.6);
expect(state.interactive.dismiss.percentFormula({ deltaX: 0.9, deltaY: 0, state: 0, android: null, eventName: 'pan', ios: null, object: null, type: 3, view: null })).toBe(0.7);
expect(state.interactive.dismiss.percentFormula({ deltaX: 0.9, deltaY: 0, state: 0, android: null, eventName: 'pan', ios: null, object: null, type: GestureTypes.pan, view: null })).toBe(0.7);
expect(state.pageStart.x).toBe(200);
expect(state.pageStart.y).toBe(100);
expect(state.pageStart.spring.friction).toBe(40);

View File

@ -337,7 +337,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@ -390,7 +390,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
@ -411,6 +411,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = TNSWidgets/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.nativescript.TNSWidgets;
PRODUCT_NAME = "$(TARGET_NAME)";
@ -429,6 +430,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = TNSWidgets/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.nativescript.TNSWidgets;
PRODUCT_NAME = "$(TARGET_NAME)";
@ -440,6 +442,7 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = TNSWidgetsTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.nativescript.TNSWidgetsTests;
PRODUCT_NAME = "$(TARGET_NAME)";
@ -450,6 +453,7 @@
isa = XCBuildConfiguration;
buildSettings = {
INFOPLIST_FILE = TNSWidgetsTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.nativescript.TNSWidgetsTests;
PRODUCT_NAME = "$(TARGET_NAME)";

View File

@ -67,7 +67,7 @@
"jest-matcher-utils": "29.4.1",
"nativescript-vue-template-compiler": "2.9.3",
"ts-jest": "29.1.0",
"typescript": "~4.9.5"
"typescript": "5.1.6"
},
"peerDependencies": {
"nativescript-vue-template-compiler": "^2.8.1"

View File

@ -12,7 +12,7 @@ export default function (ctx: ts.TransformationContext) {
decorators = ts.getDecorators(node);
} else {
// fallback to old behavior on older typescript versions
decorators = node.decorators;
decorators = (node as any).decorators;
}
return !!decorators?.some((d) => {
@ -53,6 +53,6 @@ export default function (ctx: ts.TransformationContext) {
return (source: ts.SourceFile) =>
ts.factory.updateSourceFile(
source,
ts.visitNodes(source.statements, visitNode)
ts.visitNodes(source.statements, visitNode) as ts.NodeArray<ts.Statement>
);
}

View File

@ -0,0 +1,32 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
},
{
"files": ["./package.json", "./generators.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/nx-plugin-checks": "error"
}
}
]
}

View File

@ -0,0 +1,9 @@
{
"generators": {
"app": {
"implementation": "./src/generators/app",
"schema": "./src/generators/app/schema.json",
"description": "Generator app"
}
}
}

View File

@ -0,0 +1,10 @@
/* eslint-disable */
export default {
displayName: 'workspace-plugin',
preset: '../../jest.preset.js',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/tools/workspace-plugin',
};

View File

@ -0,0 +1,11 @@
{
"name": "@nativescript/workspace-plugin",
"version": "0.0.1",
"dependencies": {
"tslib": "^2.3.0"
},
"type": "commonjs",
"main": "./src/index.js",
"typings": "./src/index.d.ts",
"generators": "./generators.json"
}

View File

@ -0,0 +1,61 @@
{
"name": "workspace-plugin",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "tools/workspace-plugin/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/tools/workspace-plugin",
"main": "tools/workspace-plugin/src/index.ts",
"tsConfig": "tools/workspace-plugin/tsconfig.lib.json",
"assets": [
{
"input": "./tools/workspace-plugin/src",
"glob": "**/!(*.ts)",
"output": "./src"
},
{
"input": "./tools/workspace-plugin/src",
"glob": "**/*.d.ts",
"output": "./src"
},
{
"input": "./tools/workspace-plugin",
"glob": "generators.json",
"output": "."
},
{
"input": "./tools/workspace-plugin",
"glob": "executors.json",
"output": "."
}
]
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["tools/workspace-plugin/**/*.ts", "tools/workspace-plugin/package.json", "tools/workspace-plugin/generators.json"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "tools/workspace-plugin/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"tags": []
}

View File

@ -2,7 +2,7 @@ import { chain, externalSchematic, Rule } from '@angular-devkit/schematics';
export default function (schema: any): Rule {
return chain([
externalSchematic('@nrwl/workspace', 'lib', {
externalSchematic('@nx/workspace', 'lib', {
name: schema.name,
}),
]);

View File

@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs"
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}

View File

@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}

View File

@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
}

View File

@ -21,7 +21,8 @@
"@nativescript/core": ["packages/core/index.ts"],
"@nativescript/core/*": ["packages/core/*"],
"@nativescript/types-android": ["packages/types-android/src/index.ts"],
"@nativescript/types-ios": ["packages/types-ios/src/index.ts"]
"@nativescript/types-ios": ["packages/types-ios/src/index.ts"],
"@nativescript/workspace-plugin": ["tools/workspace-plugin/src/index.ts"]
}
},
"exclude": ["node_modules", "tmp", "platforms", "__tests__"]