Skip to content

feat: Angular 15 support #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 30, 2022
4 changes: 2 additions & 2 deletions apps/nativescript-demo-ng/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"@nativescript-community/ui-material-bottom-navigation": "^7.0.0"
},
"devDependencies": {
"@nativescript/android": "~8.3.0",
"@nativescript/ios": "~8.3.0",
"@nativescript/android": "~8.4.0",
"@nativescript/ios": "~8.4.0",
"@nativescript/unit-test-runner": "^3.0.1"
}
}
3 changes: 2 additions & 1 deletion apps/nativescript-demo-ng/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "nativescript-demo-ng",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/nativescript-demo-ng/src",
"projectType": "application",
Expand Down Expand Up @@ -71,7 +72,7 @@
},
"test": {
"executor": "@nativescript/nx:test",
"outputs": ["coverage/apps/nativescript-demo-ng"],
"outputs": ["{workspaceRoot}/coverage/apps/nativescript-demo-ng"],
"options": {
"coverage": false
},
Expand Down
2 changes: 1 addition & 1 deletion apps/nativescript-demo-ng/src/app/item/items.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ModalDialogService, NativeDialogService } from '@nativescript/angular';
templateUrl: './items.component.html',
})
export class ItemsComponent implements OnInit {
message = 'Hello Angular 13!';
message = 'Hello Angular 15!';
items: Array<Item>;

constructor(private itemService: ItemService, private nativeDialog: NativeDialogService, private modalDialog: ModalDialogService, private http: HttpClient) {}
Expand Down
2 changes: 1 addition & 1 deletion apps/nativescript-demo-ng/src/app/item3/items.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ModalDialogService, NativeDialogService } from '@nativescript/angular';
templateUrl: './items.component.html',
})
export class ItemsComponent implements OnInit {
message = 'Hello Angular 13!';
message = 'Hello Angular 15!';
items: Array<Item>;

constructor(private itemService: ItemService, private nativeDialog: NativeDialogService, private modalDialog: ModalDialogService, private http: HttpClient) {}
Expand Down
22 changes: 10 additions & 12 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@
"affected": {
"defaultBase": "main"
},
"implicitDependencies": {
"workspace.json": "*",
"package.json": {
"dependencies": "*",
"devDependencies": "*"
},
"tsconfig.base.json": "*",
"tslint.json": "*",
".eslintrc.json": "*",
"nx.json": "*"
},
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/nx-cloud",
Expand All @@ -34,7 +23,16 @@
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"targetDefaults": {
"build": {
"dependsOn": ["^build"]
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"test": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"sharedGlobals": ["{workspaceRoot}/workspace.json", "{workspaceRoot}/tsconfig.base.json", "{workspaceRoot}/tslint.json", "{workspaceRoot}/nx.json"],
"production": ["default", "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)", "!{projectRoot}/tsconfig.spec.json", "!{projectRoot}/jest.config.[jt]s"]
}
}
66 changes: 33 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"private": true,
"scripts": {
"clean": "npx rimraf hooks node_modules package-lock.json yarn.lock && npm i --legacy-peer-deps",
"clean": "npx rimraf hooks node_modules package-lock.json && yarn",
"clean.all": "npm run clean && nx run-many --target=clean --all",
"postinstall": "husky install",
"nx": "nx",
Expand Down Expand Up @@ -35,44 +35,44 @@
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
},
"dependencies": {
"@angular/animations": "14.2.3",
"@angular/common": "14.2.3",
"@angular/compiler": "14.2.3",
"@angular/core": "14.2.3",
"@angular/forms": "14.2.3",
"@angular/platform-browser": "14.2.3",
"@angular/platform-browser-dynamic": "14.2.3",
"@angular/router": "14.2.3",
"@nativescript/core": "~8.3.4",
"@angular/animations": "15.0.1",
"@angular/common": "15.0.1",
"@angular/compiler": "15.0.1",
"@angular/core": "15.0.1",
"@angular/forms": "15.0.1",
"@angular/platform-browser": "15.0.1",
"@angular/platform-browser-dynamic": "15.0.1",
"@angular/router": "15.0.1",
"@nativescript/core": "~8.4.0",
"@nativescript/theme": "~3.0.2",
"@ngx-translate/core": "~14.0.0",
"@nrwl/nx-cloud": "^15.0.2",
"nativescript-ngx-fonticon": "~7.0.0",
"rxjs": "^7.5.6",
"zone.js": "~0.11.8"
"zone.js": "~0.12.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "14.2.3",
"@angular-eslint/eslint-plugin": "14.0.3",
"@angular-eslint/eslint-plugin-template": "14.0.3",
"@angular-eslint/template-parser": "14.0.3",
"@angular/compiler-cli": "14.2.3",
"@angular-devkit/build-angular": "15.0.1",
"@angular-eslint/eslint-plugin": "14.0.4",
"@angular-eslint/eslint-plugin-template": "14.0.4",
"@angular-eslint/template-parser": "14.0.4",
"@angular/compiler-cli": "15.0.1",
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
"@nativescript/types": "~8.3.1",
"@nativescript/types": "~8.4.0",
"@nativescript/unit-test-runner": "^3.0.4",
"@nativescript/webpack": "~5.0.8",
"@ngtools/webpack": "14.2.3",
"@nrwl/angular": "14.7.11",
"@nrwl/cli": "14.7.11",
"@nrwl/eslint-plugin-nx": "14.7.11",
"@nrwl/jest": "14.7.11",
"@nrwl/js": "14.7.11",
"@nrwl/node": "14.7.11",
"@nrwl/workspace": "14.7.11",
"@nstudio/angular": "14.3.0",
"@nstudio/nativescript": "14.3.0",
"@nstudio/nativescript-angular": "14.3.0",
"@nstudio/xplat": "14.3.0",
"@nativescript/webpack": "~5.0.12",
"@ngtools/webpack": "15.0.1",
"@nrwl/angular": "15.2.1",
"@nrwl/cli": "15.2.1",
"@nrwl/eslint-plugin-nx": "15.2.1",
"@nrwl/jest": "15.2.1",
"@nrwl/js": "15.2.1",
"@nrwl/node": "15.2.1",
"@nrwl/workspace": "15.2.1",
"@nstudio/angular": "15.0.2",
"@nstudio/nativescript": "15.0.2",
"@nstudio/nativescript-angular": "15.0.2",
"@nstudio/xplat": "15.0.2",
"@types/jasmine": "4.3.0",
"@types/jest": "28.1.8",
"@types/node": "^18.7.13",
Expand All @@ -93,8 +93,8 @@
"karma-nativescript-launcher": "0.4.0",
"karma-sinon": "^1.0.5",
"lint-staged": "^13.0.3",
"ng-packagr": "14.2.1",
"nx": "14.7.11",
"ng-packagr": "15.0.1",
"nx": "15.2.1",
"nyc": "15.1.0",
"postcss": "^8.4.16",
"postcss-import": "14.1.0",
Expand All @@ -106,7 +106,7 @@
"ts-jest": "28.0.8",
"ts-node": "10.9.1",
"tslib": "^2.4.0",
"typescript": "~4.7.2"
"typescript": "~4.8.0"
},
"xplat": {
"prefix": "nativescript",
Expand Down
3 changes: 2 additions & 1 deletion packages/angular/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "angular",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/angular/src",
"projectType": "library",
Expand All @@ -23,7 +24,7 @@
"jestConfig": "packages/angular/jest.config.ts",
"passWithNoTests": true
},
"outputs": ["coverage/packages/angular"]
"outputs": ["{workspaceRoot}/coverage/packages/angular"]
}
},
"tags": []
Expand Down
50 changes: 50 additions & 0 deletions packages/angular/src/lib/legacy/router/ns-route-reuse-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface CacheItem {
key: string;
state: DetachedRouteHandle;
isModal: boolean;
markedForDeletion?: boolean;
}

const getSnapshotKey = function (snapshot: ActivatedRouteSnapshot): string {
Expand Down Expand Up @@ -52,6 +53,28 @@ class DetachedStateCache {
}
}

public markCurrentForClear() {
for (const item of this.cache) {
item.markedForDeletion = true;
}
}

public clearMarked() {
// try to preserve same order as .clear()
for (let i = this.cache.length - 1; i >= 0; i--) {
const cacheItem = this.cache[i];
if (cacheItem.markedForDeletion) {
const state = <any>cacheItem.state;
if (!state.componentRef) {
throw new Error('No componentRef found in DetachedRouteHandle');
}

destroyComponentRef(state.componentRef);
this.cache.splice(i, 1);
}
}
}

public clearModalCache() {
let removedItemsCount = 0;
const hasModalPages = this.cache.some((cacheItem) => {
Expand Down Expand Up @@ -259,6 +282,14 @@ export class NSRouteReuseStrategy implements RouteReuseStrategy {
}
}

markCacheForClear(outletKey: string) {
const cache = this.cacheByOutlet[outletKey];

if (cache) {
cache.markCurrentForClear();
}
}

popCache(outletKey: string) {
const cache = this.cacheByOutlet[outletKey];

Expand All @@ -272,6 +303,25 @@ export class NSRouteReuseStrategy implements RouteReuseStrategy {
}
}

markCacheForPop(outletKey: string) {
const cache = this.cacheByOutlet[outletKey];

if (cache) {
const item = cache.peek();
if (item) {
item.markedForDeletion = true;
}
}
}

clearMarkedCache(outletKey: string) {
const cache = this.cacheByOutlet[outletKey];

if (cache) {
cache.clearMarked();
}
}

clearModalCache(outletKey: string) {
const cache = this.cacheByOutlet[outletKey];

Expand Down
Loading