Skip to content

Commit ae9855c

Browse files
committed
change dbrjs import mode
1 parent 92ac481 commit ae9855c

File tree

22 files changed

+58
-59
lines changed

22 files changed

+58
-59
lines changed

1.hello-world/1.minimum-code.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
<meta name="description" content="Quickly read barcodes with Dynamsoft Barcode Reader from a live camera stream.">
88
<meta name="keywords" content="camera based barcode reading">
99
<title>Dynamsoft Barcode Reader Sample - Hello World (Decoding via Camera)</title>
10-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/dbr.js"></script>
1110
</head>
1211

1312
<body>
1413
<h1 style="font-size: 1.5em;">Read Barcodes from a Camera</h1>
1514
<button id="btn-show-scanner">Show Barcode Scanner</button>
15+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/dbr.js"></script>
1616
<script>
1717
/** LICENSE ALERT - README
1818
*

1.hello-world/2.read-an-image.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<meta name="description" content="Read barcodes from images in no time with Dynamsoft Barcode Reader. With this online demo, you can choose a file to scan the barcodes on them.">
88
<meta name="keywords" content="read barcode from still images">
99
<title>Dynamsoft Barcode Reader Sample - Read an Image</title>
10-
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/dbr.js"></script>
1110
</head>
1211

1312
<body>
@@ -25,6 +24,7 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
2524
.sp-resultText { color: #cE5E04 }
2625
#div-cvs-container canvas { border: solid 1px gray; }
2726
</style>
27+
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/dbr.js"></script>
2828
<script>
2929
/** LICENSE ALERT - README
3030
*

1.hello-world/3.read-video-angular/src/app/barcode-scanner/barcode-scanner.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2-
import DBR from '../dbr';
2+
import { BarcodeScanner } from 'dynamsoft-javascript-barcode'
33
@Component({
44
selector: 'app-video-decode',
55
templateUrl: './barcode-scanner.component.html',
@@ -10,7 +10,7 @@ export class VideoDecodeComponent implements OnInit {
1010

1111
async ngOnInit(): Promise<void> {
1212
try {
13-
const scanner = await (this.pScanner = DBR.BarcodeScanner.createInstance());
13+
const scanner = await (this.pScanner = BarcodeScanner.createInstance());
1414
scanner.setUIElement((document.querySelector('.component-barcode-scanner') as any));
1515
scanner.onFrameRead = (results: any) => {
1616
for (const result of results) {

1.hello-world/3.read-video-angular/src/app/dbr.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import DBR from "dynamsoft-javascript-barcode";
1+
import { BarcodeReader } from 'dynamsoft-javascript-barcode';
22

33
/** LICENSE ALERT - README
44
*
@@ -14,6 +14,4 @@ import DBR from "dynamsoft-javascript-barcode";
1414

1515
/** LICENSE ALERT - THE END */
1616

17-
DBR.BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/";
18-
19-
export default DBR;
17+
BarcodeReader.engineResourcePath = 'https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/';

1.hello-world/3.read-video-angular/src/app/hello-world/hello-world.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, OnInit } from '@angular/core';
2-
import DBR from '../dbr';
2+
import '../dbr'; // import side effects. The license, engineResourcePath, so on.
3+
import { BarcodeScanner } from 'dynamsoft-javascript-barcode';
34

45
@Component({
56
selector: 'app-hello-world',
@@ -12,7 +13,7 @@ export class HelloWorldComponent implements OnInit {
1213
async ngOnInit(): Promise<void> {
1314
// Load the library on page load to speed things up.
1415
try {
15-
await DBR.BarcodeScanner.loadWasm();
16+
await BarcodeScanner.loadWasm();
1617
} catch (ex) {
1718
alert(ex.message);
1819
}

1.hello-world/3.read-video-angular/src/app/img-decode/img-decode.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2-
import DBR from '../dbr';
2+
import {BarcodeReader} from 'dynamsoft-javascript-barcode'
33

44
@Component({
55
selector: 'app-img-decode',
@@ -13,7 +13,7 @@ export class ImgDecodeComponent implements OnInit {
1313

1414
decodeImg = async (e: any) => {
1515
try {
16-
const reader = await (this.pReader = DBR.BarcodeReader.createInstance());
16+
const reader = await (this.pReader = BarcodeReader.createInstance());
1717
const results = await reader.decode(e.target.files[0]);
1818
for (const result of results) {
1919
alert(result.barcodeText);

1.hello-world/5.read-video-vue/src/components/HelloWorld.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
</template>
1414

1515
<script>
16-
import DBR from "../dbr";
16+
import "../dbr"; // import side effects. The license, engineResourcePath, so on.
17+
import { BarcodeReader } from "dynamsoft-javascript-barcode";
1718
import VideoDecode from "./VideoDecode";
1819
import ImgDecode from './ImgDecode.vue'
1920
@@ -28,7 +29,7 @@ export default {
2829
async mounted() {
2930
//Load the library on page load to speed things up.
3031
try {
31-
await DBR.BarcodeScanner.loadWasm();
32+
await BarcodeReader.loadWasm();
3233
} catch (ex) {
3334
alert(ex.message);
3435
throw ex;

1.hello-world/5.read-video-vue/src/components/ImgDecode.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</template>
44

55
<script>
6-
import DBR from "../dbr";
6+
import { BarcodeReader } from 'dynamsoft-javascript-barcode'
77
export default {
88
name: 'ImgDecode',
99
data() {
@@ -14,7 +14,7 @@ export default {
1414
methods: {
1515
async decodeImg(e) {
1616
try {
17-
const reader = await (this.pReader = DBR.BarcodeReader.createInstance());
17+
const reader = await (this.pReader = BarcodeReader.createInstance());
1818
let results = await reader.decode(e.target.files[0]);
1919
for(let result of results){
2020
alert(result.barcodeText);

1.hello-world/5.read-video-vue/src/components/VideoDecode.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</template>
2727

2828
<script>
29-
import DBR from "../dbr";
29+
import { BarcodeScanner } from 'dynamsoft-javascript-barcode'
3030
3131
export default {
3232
data() {
@@ -36,7 +36,7 @@ export default {
3636
},
3737
async mounted() {
3838
try {
39-
const scanner = await (this.pScanner = DBR.BarcodeScanner.createInstance());
39+
const scanner = await (this.pScanner = BarcodeScanner.createInstance());
4040
await scanner.setUIElement(this.$el);
4141
scanner.onFrameRead = (results) => {
4242
for (let result of results) {

1.hello-world/5.read-video-vue/src/dbr.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import DBR from "dynamsoft-javascript-barcode";
1+
import { BarcodeReader } from "dynamsoft-javascript-barcode";
22

33
/** LICENSE ALERT - README
44
*
@@ -14,6 +14,4 @@ import DBR from "dynamsoft-javascript-barcode";
1414

1515
/** LICENSE ALERT - THE END */
1616

17-
DBR.BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/";
18-
19-
export default DBR;
17+
BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@8.8.7/dist/";

0 commit comments

Comments
 (0)