Skip to content
This repository has been archived by the owner on May 29, 2023. It is now read-only.

Commit

Permalink
feat: update to Angular 12 and Ivy distribution (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
waterplea committed Jan 28, 2022
1 parent 515a619 commit a3e9eaa
Show file tree
Hide file tree
Showing 16 changed files with 12,437 additions and 11,769 deletions.
32 changes: 32 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
root: true,
extends: [
// TODO: move rules to @tinkoff/eslint-config-angular
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'@tinkoff/eslint-config-angular',
],
ignorePatterns: ['projects/**/test.ts'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: [require.resolve('./tsconfig.eslint.json')],
},
parser: '@typescript-eslint/parser',
rules: {
// TODO: move rules to @tinkoff/eslint-config-angular
'@typescript-eslint/no-useless-constructor': 'off',
'@typescript-eslint/no-inferrable-types': ['error', {ignoreParameters: true}],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{accessibility: 'no-public'},
],
'@typescript-eslint/prefer-readonly': ['error'],
'no-console': ['error', {allow: ['info', 'assert', 'warn', 'error']}],

'no-prototype-builtins': 'off',
// note you must disable the base rule as it can report incorrect errors
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
},
};
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "10"
- "14"
script:
- npm run lint
- npm run build
Expand Down
12 changes: 1 addition & 11 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"sourceRoot": "projects/universal/src",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"tsConfig": "projects/universal/tsconfig.lib.json",
"project": "projects/universal/ng-package.json"
Expand All @@ -24,16 +24,6 @@
"codeCoverage": true,
"browsers": "ChromeHeadless"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/universal/tsconfig.lib.json",
"projects/universal/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**"]
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']};
23,938 changes: 12,293 additions & 11,645 deletions package-lock.json

Large diffs are not rendered by default.

112 changes: 52 additions & 60 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"name": "@ng-web-apis/universal",
"version": "1.13.0",
"scripts": {
"postinstall": "husky install",
"build": "ng build",
"postbuild": "node scripts/postbuild.js",
"test": "ng test",
"posttest": "node scripts/coveralls.js",
"lint": "ng lint",
"lint": "eslint . --fix",
"typecheck": "tsc --noEmit --skipLibCheck",
"release": "standard-version",
"release:patch": "npm run release -- --release-as patch",
Expand All @@ -32,79 +33,70 @@
"name": "Alex Inkin",
"email": "alexander@inkin.ru"
},
"contributors": ["Roman Sedov <79601794011@ya.ru> (http://marsibarsi.me/)"],
"contributors": [
"Roman Sedov <79601794011@ya.ru> (http://marsibarsi.me/)"
],
"repository": "https://github.com/ng-web-apis/universal",
"bugs": "https://github.com/ng-web-apis/universal/issues",
"homepage": "https://github.com/ng-web-apis/universal#README",
"schematics": "./schematics/collection.json",
"dependencies": {
"@angular/animations": "^7.2.15",
"@angular/common": "^7.2.15",
"@angular/compiler": "^7.2.15",
"@angular/core": "^7.2.15",
"@angular/forms": "^7.2.15",
"@angular/http": "^7.2.15",
"@angular/platform-browser": "^7.2.15",
"@angular/platform-browser-dynamic": "^7.2.15",
"@angular/platform-server": "^7.2.15",
"@angular/router": "^7.2.15",
"@ng-web-apis/common": "1.13.0",
"@nguniversal/common": "^7.1.1",
"@nguniversal/express-engine": "^7.1.1",
"@nguniversal/module-map-ngfactory-loader": "^7.1.1",
"core-js": "^2.5.4",
"rxjs": "^6.5.2",
"tslib": "^1.10.0",
"zone.js": "~0.8.29"
"@angular/common": "12.2.15",
"@angular/compiler": "12.2.15",
"@angular/core": "12.2.15",
"@angular/platform-browser": "12.2.15",
"@angular/platform-browser-dynamic": "12.2.15",
"core-js": "3.20.3",
"rxjs": "7.5.2",
"tslib": "2.3.1",
"zone.js": "0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.9",
"@angular-devkit/build-ng-packagr": "~0.13.9",
"@angular-devkit/core": "^7.3.9",
"@angular-devkit/schematics": "^7.3.9",
"@angular-devkit/schematics-cli": "~0.13.9",
"@angular/cli": "^7.3.9",
"@angular/compiler-cli": "^7.2.15",
"@angular/language-service": "^7.2.15",
"@tinkoff/linters": "^0.4.0",
"@types/express": "4.16.1",
"@types/express-serve-static-core": "4.16.2",
"@types/jasmine": "^3.3.16",
"@types/jasminewd2": "^2.0.6",
"@types/node": "~8.9.4",
"codelyzer": "^5.1.0",
"coveralls": "^3.0.5",
"ecstatic": "^4.1.2",
"express": "^4.17.1",
"http-server": "^0.11.1",
"husky": "^3.0.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.2.0",
"karma-chrome-launcher": "^3.0.0",
"karma-coverage-istanbul-reporter": "^2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"lint-staged": "^9.2.1",
"lodash": "^4.17.15",
"ng-packagr": "4.7.1",
"node-sass": "4.14.1",
"prettier": "^1.18.2",
"standard-version": "^8.0.1",
"ts-node": "^8.3.0",
"tsickle": "0.34.0",
"tslint": "^5.18.0",
"tsutils": "^3.17.1",
"typescript": "3.1.6"
"@angular-devkit/build-angular": "12.2.15",
"@angular-devkit/core": "12.2.15",
"@angular/cli": "12.2.15",
"@angular/compiler-cli": "12.2.15",
"@angular/language-service": "12.2.15",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@ng-web-apis/common": "2.0.0",
"@tinkoff/eslint-config": "^1.22.0",
"@tinkoff/eslint-config-angular": "^1.23.0",
"@tinkoff/prettier-config": "^1.22.0",
"@types/jasmine": "3.10.3",
"@types/jasminewd2": "2.0.10",
"@types/node": "9.6.61",
"coveralls": "3.1.1",
"husky": "7.0.4",
"jasmine-core": "4.0.0",
"jasmine-spec-reporter": "7.0.0",
"karma": "6.3.11",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-jasmine": "4.0.1",
"karma-jasmine-html-reporter": "1.7.0",
"lint-staged": "12.2.1",
"ng-packagr": "12.2.6",
"prettier": "2.5.1",
"standard-version": "9.3.2",
"ts-node": "9.0.0",
"tslint": "6.1.3",
"typescript": "4.3.5"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && npm run typecheck"
}
},
"lint-staged": {
"*.{js,ts,html,md,less,json}": ["prettier --write", "git add"],
"*.ts": "tslint"
"*.{js,ts,html,md,less,json}": [
"prettier --write",
"git add"
],
"*.{js,ts}": [
"eslint --fix",
"git add"
]
},
"standard-version": {
"scripts": {
Expand Down
15 changes: 14 additions & 1 deletion prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
const base = require('@tinkoff/prettier-config/angular');

module.exports = {
...require('@tinkoff/linters/prettier/prettier.config'),
...base,
overrides: [
...base.overrides,
{
files: ['*.js', '*.ts'],
options: {printWidth: 90, parser: 'typescript'},
},
{
files: '*.html',
options: {printWidth: 80, parser: 'html'},
},
],
};
4 changes: 2 additions & 2 deletions projects/universal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@ng-web-apis/universal",
"version": "1.13.0",
"peerDependencies": {
"@angular/core": ">=6.0.0",
"@ng-web-apis/common": ">=1.13.0",
"@angular/core": ">=12.0.0",
"@ng-web-apis/common": ">=2.0.0",
"@types/node": ">=10.0.0",
"rxjs": ">=6.0.0"
},
Expand Down
5 changes: 5 additions & 0 deletions projects/universal/src/classes/blob-mock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import {alwaysRejected} from '../utils/functions';

export class BlobMock implements Blob {
size = 0;
type = '';
arrayBuffer = () => alwaysRejected();
stream = () => new ReadableStream();
text = () => alwaysRejected();
slice = () => this;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ describe('UNIVERSAL_NAVIGATOR', () => {

expect(mock.userAgent).toBe('');
expect(mock.plugins.refresh).not.toThrow();
expect(mock.plugins.item(0).item(0).description).toBe('');
expect(mock.plugins.namedItem('whatever').namedItem('').suffixes).toBe('');
expect(mock.plugins.item(0)).toBeNull();
expect(mock.plugins.namedItem('whatever')).toBeNull();
});

it('Reads provided user agent', () => {
Expand Down
54 changes: 19 additions & 35 deletions projects/universal/src/constants/universal-navigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,13 @@ import {
emptyObject,
} from '../utils/functions';

const PLUGIN = new (class extends Array<MimeType> implements Plugin {
readonly description = '';
readonly filename = '';
readonly name = '';
readonly version = '';

item(): MimeType {
return {
description: '',
enabledPlugin: this,
suffixes: '',
type: '',
};
}
namedItem(): MimeType {
return {
description: '',
enabledPlugin: this,
suffixes: '',
type: '',
};
}
})();

const MIME_TYPES = new (class extends Array<Plugin> implements MimeTypeArray {
item(): Plugin {
return PLUGIN;
}
namedItem(): Plugin {
return PLUGIN;
}
refresh() {}
})();
function getArray<T>() {
return new (class extends Array<T> {
item = () => null;
namedItem = () => null;
refresh() {}
})();
}

/** For older version of TS and Angular that do not support all properties from Navigator */
interface NavigatorLike extends Navigator {
Expand All @@ -65,11 +39,21 @@ export const NAVIGATOR_MOCK: NavigatorLike = {

confirmSiteSpecificTrackingException: alwaysFalse,
confirmWebWideTrackingException: alwaysFalse,
share: alwaysRejected,
registerProtocolHandler: emptyFunction,
unregisterProtocolHandler: emptyFunction,
removeSiteSpecificTrackingException: emptyFunction,
removeWebWideTrackingException: emptyFunction,
storeSiteSpecificTrackingException: emptyFunction,
storeWebWideTrackingException: emptyFunction,

credentials: {
create: alwaysRejected,
get: alwaysRejected,
preventSilentAccess: alwaysRejected,
store: alwaysRejected,
},

msSaveBlob: alwaysFalse,
msSaveOrOpenBlob: alwaysFalse,

Expand Down Expand Up @@ -114,14 +98,14 @@ export const NAVIGATOR_MOCK: NavigatorLike = {
getSupportedConstraints: emptyObject,
getUserMedia: alwaysRejected,
},
mimeTypes: MIME_TYPES,
mimeTypes: getArray<MimeType>(),
msManipulationViewsEnabled: false,
msMaxTouchPoints: 0,
msPointerEnabled: false,
permissions: {
query: alwaysRejected,
},
plugins: MIME_TYPES,
plugins: getArray<Plugin>(),
pointerEnabled: false,
serviceWorker: {
...EVENT_TARGET,
Expand Down
3 changes: 0 additions & 3 deletions projects/universal/src/constants/universal-providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,3 @@ export const UNIVERSAL_PROVIDERS: Provider[] = [
UNIVERSAL_USER_AGENT,
UNIVERSAL_WINDOW,
];

/** @deprecated use {@link UNIVERSAL_PROVIDERS} */
export const UNIVERSAL_TOKENS = UNIVERSAL_PROVIDERS;
4 changes: 2 additions & 2 deletions projects/universal/src/constants/universal-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ const DB_REQUEST: IDBOpenDBRequest = {
};
const SELF = ['frames', 'parent', 'self', 'top', 'window'];
const WINDOW_HANDLER: ProxyHandler<Window> = {
get: (windowRef, key: keyof Window) => {
get: (windowRef, key: string) => {
if (SELF.includes(key)) {
return windowRef;
}

return key.startsWith('on') ? null : windowRef[key];
return key.startsWith('on') ? null : windowRef[key as keyof Window];
},
};

Expand Down
9 changes: 9 additions & 0 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"baseUrl": "."
},
"include": ["projects", "scripts", "**/*.js"],
"exclude": ["**/node_modules", "**/.*/"]
}
4 changes: 4 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"compileOnSave": false,
"angularCompilerOptions": {
"enableIvy": true,
"compilationMode": "partial"
},
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
Expand Down
7 changes: 0 additions & 7 deletions tslint.json

This file was deleted.

0 comments on commit a3e9eaa

Please sign in to comment.