Skip to content

Commit 230038b

Browse files
committed
Update to angular 10
1 parent 04f3e30 commit 230038b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+10902
-8770
lines changed

.browserslistrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# For the full list of supported browsers by the Angular framework, please see:
6+
# https://angular.io/guide/browser-support
7+
8+
# You can see what browsers were selected by your queries by running:
9+
# npx browserslist
10+
11+
last 1 Chrome version
12+
last 1 Firefox version
13+
last 2 Edge major versions
14+
last 2 Safari major versions
15+
last 2 iOS major versions
16+
Firefox ESR
17+
not IE 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line.
18+
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Editor configuration, see http://editorconfig.org
1+
# Editor configuration, see https://editorconfig.org
22
root = true
33

44
[*]
@@ -8,6 +8,9 @@ indent_size = 2
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11+
[*.ts]
12+
quote_type = single
13+
1114
[*.md]
1215
max_line_length = off
1316
trim_trailing_whitespace = false

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44
/dist
55
/tmp
66
/out-tsc
7+
# Only exists if Bazel was run
8+
/bazel-out
79

810
# dependencies
911
/node_modules
1012

13+
# profiling files
14+
chrome-profiler-events*.json
15+
speed-measure-plugin*.json
16+
1117
# IDEs and editors
1218
/.idea
1319
.project
@@ -23,6 +29,7 @@
2329
!.vscode/tasks.json
2430
!.vscode/launch.json
2531
!.vscode/extensions.json
32+
.history/*
2633

2734
# misc
2835
/.sass-cache

LICENSE renamed to LICENCE

File renamed without changes.

README.md

Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
## Demo
1818

19-
*Coming soon...*
19+
_Coming soon..._
2020

2121
## Installation
2222

@@ -32,19 +32,16 @@ npm install --save quagga ngx-barcode-scanner
3232

3333
```typescript
3434
//demo.module.ts
35-
import { NgModule } from '@angular/core';
36-
import { BrowserModule } from '@angular/platform-browser';
35+
import { NgModule } from "@angular/core";
36+
import { BrowserModule } from "@angular/platform-browser";
3737

38-
import { BarecodeScannerLivestreamModule } from 'ngx-barcode-scanner';
39-
import { Demo } from './demo.component';
38+
import { BarecodeScannerLivestreamModule } from "ngx-barcode-scanner";
39+
import { Demo } from "./demo.component";
4040

4141
@NgModule({
42-
declarations: [Demo],
43-
imports: [
44-
BrowserModule,
45-
BarecodeScannerLivestreamModule
46-
],
47-
bootstrap: [Demo]
42+
declarations: [Demo],
43+
imports: [BrowserModule, BarecodeScannerLivestreamModule],
44+
bootstrap: [Demo],
4845
})
4946
export class DemoModule {}
5047
```
@@ -55,64 +52,52 @@ This component creates a barcode scanner.
5552

5653
```typescript
5754
//demo.component.ts
58-
import { Component, ViewChild, AfterViewInit } from '@angular/core';
59-
import { BarecodeScannerLivestreamComponent } from 'ngx-barcode-scanner';
60-
55+
import { Component, ViewChild, AfterViewInit } from "@angular/core";
56+
import { BarecodeScannerLivestreamComponent } from "ngx-barcode-scanner";
6157

6258
@Component({
63-
selector: 'demo-app',
59+
selector: "demo-app",
6460
template: `
65-
<barcode-scanner-livestream type="code_128" (valueChanges)="onValueChanges($event)" (started)="onStarted"></barcode-scanner-livestream>
61+
<barcode-scanner-livestream
62+
type="code_128"
63+
(valueChanges)="onValueChanges($event)"
64+
(started)="(onStarted)"
65+
></barcode-scanner-livestream>
6666
<div [hidden]="!barcodeValue">
67-
{{barcodeValue}}
67+
{{ barcodeValue }}
6868
</div>
69-
`
69+
`,
7070
})
71-
export class Demo implements AfterViewInit{
72-
73-
@ViewChild(BarecodeScannerLivestreamComponent)
74-
barecodeScanner: BarecodeScannerLivestreamComponent;
71+
export class Demo implements AfterViewInit {
72+
@ViewChild(BarecodeScannerLivestreamComponent)
73+
barecodeScanner: BarecodeScannerLivestreamComponent;
7574

76-
barcodeValue;
75+
barcodeValue;
7776

78-
ngAfterViewInit() {
79-
this.barecodeScanner.start();
80-
}
77+
ngAfterViewInit() {
78+
this.barecodeScanner.start();
79+
}
8180

82-
onValueChanges(result){
83-
this.barcodeValue = result.codeResult.code;
84-
}
81+
onValueChanges(result) {
82+
this.barcodeValue = result.codeResult.code;
83+
}
8584

86-
onStarted(started){
87-
console.log(started);
88-
}
85+
onStarted(started) {
86+
console.log(started);
87+
}
8988
}
9089
```
9190

9291
## Development
9392

9493
### Development server
9594

96-
Open a command line and run `ng build ngx-barcode-scanner --watch` for incremental build of the library
97-
98-
Run `npm run start` for a dev server, on the example app. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
95+
Run `ng serve` or `npm run start` for a dev server, on the example app. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
9996

10097
### Build
10198

10299
Run `npm run build` to build the project. The build artifacts will be stored in the `dist/` directory.
103100

104-
### Package
105-
106-
Run `npm run package` to package the project.
107-
The project can then be installed with `npm install <relative_dir>/dist/ngx-barcode-scanner/ngx-barcode-scanner-<version>.tgz`
108-
109-
### Release
110-
111-
- Bump the version in package.json
112-
- Commit and push to github
113-
- Login to your npm account with `npm login`
114-
- Publish to npm repository with `npm run release`
115-
116101
## Known issues
117102

118103
Access to the camera is restricted on iOS when running in a Progressive Web App. Live streaming will not work in this case.

angular.json

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
"newProjectRoot": "projects",
55
"projects": {
66
"ngx-barcode-scanner-app": {
7+
"projectType": "application",
8+
"schematics": {
9+
"@schematics/angular:component": {
10+
"style": "scss"
11+
}
12+
},
713
"root": "",
814
"sourceRoot": "src",
9-
"projectType": "application",
1015
"prefix": "app",
11-
"schematics": {},
1216
"architect": {
1317
"build": {
1418
"builder": "@angular-devkit/build-angular:browser",
@@ -17,13 +21,14 @@
1721
"index": "src/index.html",
1822
"main": "src/main.ts",
1923
"polyfills": "src/polyfills.ts",
20-
"tsConfig": "src/tsconfig.app.json",
24+
"tsConfig": "tsconfig.app.json",
25+
"aot": true,
2126
"assets": [
2227
"src/favicon.ico",
2328
"src/assets"
2429
],
2530
"styles": [
26-
"src/styles.css"
31+
"src/styles.scss"
2732
],
2833
"scripts": []
2934
},
@@ -40,10 +45,21 @@
4045
"sourceMap": false,
4146
"extractCss": true,
4247
"namedChunks": false,
43-
"aot": true,
4448
"extractLicenses": true,
4549
"vendorChunk": false,
46-
"buildOptimizer": true
50+
"buildOptimizer": true,
51+
"budgets": [
52+
{
53+
"type": "initial",
54+
"maximumWarning": "2mb",
55+
"maximumError": "5mb"
56+
},
57+
{
58+
"type": "anyComponentStyle",
59+
"maximumWarning": "6kb",
60+
"maximumError": "10kb"
61+
}
62+
]
4763
}
4864
}
4965
},
@@ -69,36 +85,31 @@
6985
"options": {
7086
"main": "src/test.ts",
7187
"polyfills": "src/polyfills.ts",
72-
"tsConfig": "src/tsconfig.spec.json",
73-
"karmaConfig": "src/karma.conf.js",
74-
"styles": [
75-
"src/styles.css"
76-
],
77-
"scripts": [],
88+
"tsConfig": "tsconfig.spec.json",
89+
"karmaConfig": "karma.conf.js",
7890
"assets": [
7991
"src/favicon.ico",
8092
"src/assets"
81-
]
93+
],
94+
"styles": [
95+
"src/styles.scss"
96+
],
97+
"scripts": []
8298
}
8399
},
84100
"lint": {
85101
"builder": "@angular-devkit/build-angular:tslint",
86102
"options": {
87103
"tsConfig": [
88-
"src/tsconfig.app.json",
89-
"src/tsconfig.spec.json"
104+
"tsconfig.app.json",
105+
"tsconfig.spec.json",
106+
"e2e/tsconfig.json"
90107
],
91108
"exclude": [
92109
"**/node_modules/**"
93110
]
94111
}
95-
}
96-
}
97-
},
98-
"ngx-barcode-scanner-app-e2e": {
99-
"root": "e2e/",
100-
"projectType": "application",
101-
"architect": {
112+
},
102113
"e2e": {
103114
"builder": "@angular-devkit/build-angular:protractor",
104115
"options": {
@@ -110,33 +121,24 @@
110121
"devServerTarget": "ngx-barcode-scanner-app:serve:production"
111122
}
112123
}
113-
},
114-
"lint": {
115-
"builder": "@angular-devkit/build-angular:tslint",
116-
"options": {
117-
"tsConfig": "e2e/tsconfig.e2e.json",
118-
"exclude": [
119-
"**/node_modules/**"
120-
]
121-
}
122124
}
123125
}
124126
},
125127
"ngx-barcode-scanner": {
128+
"projectType": "library",
126129
"root": "projects/ngx-barcode-scanner",
127130
"sourceRoot": "projects/ngx-barcode-scanner/src",
128-
"projectType": "library",
129131
"prefix": "lib",
130132
"architect": {
131133
"build": {
132-
"builder": "@angular-devkit/build-ng-packagr:build",
134+
"builder": "@angular-devkit/build-angular:ng-packagr",
133135
"options": {
134136
"tsConfig": "projects/ngx-barcode-scanner/tsconfig.lib.json",
135137
"project": "projects/ngx-barcode-scanner/ng-package.json"
136138
},
137139
"configurations": {
138140
"production": {
139-
"project": "projects/ngx-barcode-scanner/ng-package.prod.json"
141+
"tsConfig": "projects/ngx-barcode-scanner/tsconfig.lib.prod.json"
140142
}
141143
}
142144
},
@@ -161,7 +163,6 @@
161163
}
162164
}
163165
}
164-
}
165-
},
166+
}},
166167
"defaultProject": "ngx-barcode-scanner-app"
167-
}
168+
}

e2e/protractor.conf.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
// @ts-check
12
// Protractor configuration file, see link for more information
23
// https://github.com/angular/protractor/blob/master/lib/config.ts
34

4-
const { SpecReporter } = require('jasmine-spec-reporter');
5+
const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
56

7+
/**
8+
* @type { import("protractor").Config }
9+
*/
610
exports.config = {
711
allScriptsTimeout: 11000,
812
specs: [
913
'./src/**/*.e2e-spec.ts'
1014
],
1115
capabilities: {
12-
'browserName': 'chrome'
16+
browserName: 'chrome'
1317
},
1418
directConnect: true,
1519
baseUrl: 'http://localhost:4200/',
@@ -21,8 +25,12 @@ exports.config = {
2125
},
2226
onPrepare() {
2327
require('ts-node').register({
24-
project: require('path').join(__dirname, './tsconfig.e2e.json')
28+
project: require('path').join(__dirname, './tsconfig.json')
2529
});
26-
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
30+
jasmine.getEnv().addReporter(new SpecReporter({
31+
spec: {
32+
displayStacktrace: StacktraceOption.PRETTY
33+
}
34+
}));
2735
}
2836
};

e2e/src/app.e2e-spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { browser, logging } from 'protractor';
12
import { AppPage } from './app.po';
23

34
describe('workspace-project App', () => {
@@ -9,6 +10,15 @@ describe('workspace-project App', () => {
910

1011
it('should display welcome message', () => {
1112
page.navigateTo();
12-
expect(page.getParagraphText()).toEqual('Welcome to ngx-barcode-scanner-app!');
13+
});
14+
15+
afterEach(async () => {
16+
// Assert that there are no errors emitted from the browser
17+
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
18+
expect(logs).not.toContain(
19+
jasmine.objectContaining({
20+
level: logging.Level.SEVERE,
21+
} as logging.Entry)
22+
);
1323
});
1424
});

0 commit comments

Comments
 (0)