diff --git a/README.md b/README.md index 791afe48..ca158121 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,15 @@ Get the basic features working with plain/native JavaScript or within a framewor * [**Hello World in Angular**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/angular): Read single barcode from camera in an Angular application. * [**Hello World in React**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/react): Read single barcode from camera in a React application. * [**Hello World in Vue**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/vue): Read single barcode from camera in a Vue application. +* [**Hello World in Svelte**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/svelte): Read single barcode from camera in a Svelte application. +* [**Hello World in Capacitor**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/capacitor): Read single barcode from camera in a Capacitor application. +* [**Hello World in Webview**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/webview): Read single barcode from camera in a Webview application. +* [**Hello World in Typescript**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/native-ts): Read single barcode from camera in a Typescript application. +* [**Hello World in Electron**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/electron): Read single barcode from camera in a Electron application. +* [**Hello World in Blazor**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/blazor): Read single barcode from camera in a Blazor application. +* [**Hello World in RequireJS**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/requirejs.html): Read single barcode from camera in a RequireJS application. +* [**Hello World in ES6**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/es6.html): Read single barcode from camera in a ES6 application. +* [**Hello World in PWA**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/pwa): Read single barcode from camera in a PWA application. **Scan multiple barcodes** diff --git a/barcode-scanner-api-samples/scan-multiple-barcodes/README.md b/barcode-scanner-api-samples/scan-multiple-barcodes/README.md index c1df723a..06dc7bd7 100644 --- a/barcode-scanner-api-samples/scan-multiple-barcodes/README.md +++ b/barcode-scanner-api-samples/scan-multiple-barcodes/README.md @@ -112,4 +112,13 @@ Multiple samples are provided for single barcode scanning. These samples can be * [**Use customized template**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/use-customized-template): Use different customized templates for scanning various barcode types. * [**Hello World in Angular**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/angular): Read single barcode from camera in an Angular application. * [**Hello World in React**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/react): Read single barcode from camera in a React application. -* [**Hello World in Vue**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/vue): Read single barcode from camera in a Vue application. \ No newline at end of file +* [**Hello World in Vue**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/vue): Read single barcode from camera in a Vue application. +* [**Hello World in Svelte**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/svelte): Read single barcode from camera in a Svelte application. +* [**Hello World in Capacitor**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/capacitor): Read single barcode from camera in a Capacitor application. +* [**Hello World in Webview**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/webview): Read single barcode from camera in a Webview application. +* [**Hello World in Typescript**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/native-ts): Read single barcode from camera in a Typescript application. +* [**Hello World in Electron**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/electron): Read single barcode from camera in a Electron application. +* [**Hello World in Blazor**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/blazor): Read single barcode from camera in a Blazor application. +* [**Hello World in RequireJS**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/requirejs.html): Read single barcode from camera in a RequireJS application. +* [**Hello World in ES6**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/es6.html): Read single barcode from camera in a ES6 application. +* [**Hello World in PWA**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/pwa): Read single barcode from camera in a PWA application. \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/README.md b/barcode-scanner-api-samples/scan-single-barcode/README.md index d2836d05..35cbba46 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/README.md +++ b/barcode-scanner-api-samples/scan-single-barcode/README.md @@ -131,6 +131,15 @@ It allows users to dynamically select a scanning template (e.g., DPM, Dot Code, * [**Hello World in Angular**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/angular): Read single barcode from camera in an Angular application. * [**Hello World in React**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/react): Read single barcode from camera in a React application. * [**Hello World in Vue**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/vue): Read single barcode from camera in a Vue application. +* [**Hello World in Svelte**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/svelte): Read single barcode from camera in a Svelte application. +* [**Hello World in Capacitor**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/capacitor): Read single barcode from camera in a Capacitor application. +* [**Hello World in Webview**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/webview): Read single barcode from camera in a Webview application. +* [**Hello World in Typescript**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/native-ts): Read single barcode from camera in a Typescript application. +* [**Hello World in Electron**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/electron): Read single barcode from camera in a Electron application. +* [**Hello World in Blazor**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/blazor): Read single barcode from camera in a Blazor application. +* [**Hello World in RequireJS**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/requirejs.html): Read single barcode from camera in a RequireJS application. +* [**Hello World in ES6**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/es6.html): Read single barcode from camera in a ES6 application. +* [**Hello World in PWA**](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-single-barcode/pwa): Read single barcode from camera in a PWA application. Scan multiple barcodes: diff --git a/barcode-scanner-api-samples/scan-single-barcode/angular/README.md b/barcode-scanner-api-samples/scan-single-barcode/angular/README.md index a4431426..e31e5b7c 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/angular/README.md +++ b/barcode-scanner-api-samples/scan-single-barcode/angular/README.md @@ -19,7 +19,7 @@ npm install ### 2. Run the App ```bash -ng serve +npm run start ``` Then open your browser at http://localhost:4200 to view the sample app. diff --git a/barcode-scanner-api-samples/scan-single-barcode/angular/package.json b/barcode-scanner-api-samples/scan-single-barcode/angular/package.json index 1a14307c..f3cf9924 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/angular/package.json +++ b/barcode-scanner-api-samples/scan-single-barcode/angular/package.json @@ -5,8 +5,7 @@ "ng": "ng", "start": "ng serve", "build": "ng build", - "watch": "ng build --watch --configuration development", - "test": "ng test" + "watch": "ng build --watch --configuration development" }, "private": true, "dependencies": { diff --git a/barcode-scanner-api-samples/scan-single-barcode/angular/public/favicon.ico b/barcode-scanner-api-samples/scan-single-barcode/angular/public/favicon.ico deleted file mode 100644 index 57614f9c..00000000 Binary files a/barcode-scanner-api-samples/scan-single-barcode/angular/public/favicon.ico and /dev/null differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/angular/src/app/app.component.html b/barcode-scanner-api-samples/scan-single-barcode/angular/src/app/app.component.html index ead93434..1e505568 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/angular/src/app/app.component.html +++ b/barcode-scanner-api-samples/scan-single-barcode/angular/src/app/app.component.html @@ -1,8 +1,7 @@

Hello World for Angular

-
-
+
diff --git a/barcode-scanner-api-samples/scan-single-barcode/angular/src/app/app.component.spec.ts b/barcode-scanner-api-samples/scan-single-barcode/angular/src/app/app.component.spec.ts deleted file mode 100644 index 9a8153d9..00000000 --- a/barcode-scanner-api-samples/scan-single-barcode/angular/src/app/app.component.spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [AppComponent], - }).compileComponents(); - }); - - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - }); - - it(`should have the 'angular' title`, () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('angular'); - }); - - it('should render title', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.nativeElement as HTMLElement; - expect(compiled.querySelector('h1')?.textContent).toContain('Hello, angular'); - }); -}); diff --git a/barcode-scanner-api-samples/scan-single-barcode/angular/src/app/app.component.ts b/barcode-scanner-api-samples/scan-single-barcode/angular/src/app/app.component.ts index 381b1621..994f07ae 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/angular/src/app/app.component.ts +++ b/barcode-scanner-api-samples/scan-single-barcode/angular/src/app/app.component.ts @@ -9,17 +9,21 @@ import { BarcodeScanner, BarcodeScannerConfig } from 'dynamsoft-barcode-reader-b export class AppComponent { title = 'angular'; + barcodeScanner: BarcodeScanner | null = null; - @ViewChild('scannerView') scannerView!: ElementRef; + @ViewChild('barcodeScannerViewRef') barcodeScannerViewRef!: ElementRef; async ngAfterViewInit(): Promise { // Configuration object for initializing the BarcodeScanner instance const config: BarcodeScannerConfig = { license: "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", // Replace with your Dynamsoft license key - container: this.scannerView.nativeElement, // Specify where to render the scanner UI + + // Specify where to render the scanner UI + // If container is not specified, the UI will take up the full screen + container: this.barcodeScannerViewRef.nativeElement, // Specify the path for the definition file "barcode-scanner.ui.xml" for the scanner view. - uiPath: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.0.6000/dist/", + uiPath: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.0.6000/dist/ui/barcode-scanner.ui.xml", // showUploadImageButton: true, // scannerViewConfig: { @@ -34,13 +38,16 @@ export class AppComponent { } // Create an instance of the BarcodeScanner with the provided configuration - const barcodeScanner = new BarcodeScanner(config); + this.barcodeScanner = new BarcodeScanner(config); // Launch the scanner; once a barcode is detected, display its text in an alert - barcodeScanner.launch().then((result) => { - if (result.barcodeResults.length) { - alert(result.barcodeResults[0].text); - } - }); + let result = await this.barcodeScanner.launch(); + if (result.barcodeResults.length) { + alert(result.barcodeResults[0].text); + } + } + async ngOnDestroy(): Promise { + // Dispose of the barcode scanner when the component unmounts + this.barcodeScanner?.dispose(); } } diff --git a/barcode-scanner-api-samples/scan-single-barcode/angular/src/index.html b/barcode-scanner-api-samples/scan-single-barcode/angular/src/index.html index 36c25def..bae20c6b 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/angular/src/index.html +++ b/barcode-scanner-api-samples/scan-single-barcode/angular/src/index.html @@ -5,7 +5,6 @@ Dynamsoft Barcode Reader Sample - Hello World (Decode via Camera) - diff --git a/barcode-scanner-api-samples/scan-single-barcode/blazor/.gitignore b/barcode-scanner-api-samples/scan-single-barcode/blazor/.gitignore new file mode 100644 index 00000000..e6c4e46a --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/blazor/.gitignore @@ -0,0 +1,486 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from `dotnet new gitignore` + +# dotenv files +.env + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Vim temporary swap files +*.swp + +PublishProfiles diff --git a/barcode-scanner-api-samples/scan-single-barcode/blazor/App.razor b/barcode-scanner-api-samples/scan-single-barcode/blazor/App.razor new file mode 100644 index 00000000..6fd3ed1b --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/blazor/App.razor @@ -0,0 +1,12 @@ + + + + + + + Not found + +

Sorry, there's nothing at this address.

+
+
+
diff --git a/barcode-scanner-api-samples/scan-single-barcode/blazor/BlazorApp.csproj b/barcode-scanner-api-samples/scan-single-barcode/blazor/BlazorApp.csproj new file mode 100644 index 00000000..8e50d8dc --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/blazor/BlazorApp.csproj @@ -0,0 +1,18 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/blazor/Layout/MainLayout.razor b/barcode-scanner-api-samples/scan-single-barcode/blazor/Layout/MainLayout.razor new file mode 100644 index 00000000..5a584b18 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/blazor/Layout/MainLayout.razor @@ -0,0 +1,4 @@ +@inherits LayoutComponentBase +
+ @Body +
diff --git a/barcode-scanner-api-samples/scan-single-barcode/blazor/Pages/Home.razor b/barcode-scanner-api-samples/scan-single-barcode/blazor/Pages/Home.razor new file mode 100644 index 00000000..c94ddbd7 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/blazor/Pages/Home.razor @@ -0,0 +1,25 @@ +@page "/" +@inject IJSRuntime JS + +Dynamsoft Barcode Reader Sample - Hello World (Decode via Camera) + +

Barcode Scanner for Svelte

+
+
+ +@code { + // reference: https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/call-javascript-from-dotnet?view=aspnetcore-8.0#invoke-js-functions + + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + // This code will only run once after the component has rendered. + // It's the ideal place to call JavaScript functions that + // need access to the rendered HTML. + var resultTxt = await JS.InvokeAsync("decodeBarcodeViaCamera"); + await JS.InvokeVoidAsync("alert", resultTxt); + } + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/blazor/Program.cs b/barcode-scanner-api-samples/scan-single-barcode/blazor/Program.cs new file mode 100644 index 00000000..e6ef32a3 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/blazor/Program.cs @@ -0,0 +1,11 @@ +using BlazorApp; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; + +var builder = WebAssemblyHostBuilder.CreateDefault(args); +builder.RootComponents.Add("#app"); +builder.RootComponents.Add("head::after"); + +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); + +await builder.Build().RunAsync(); diff --git a/barcode-scanner-api-samples/scan-single-barcode/blazor/Properties/launchSettings.json b/barcode-scanner-api-samples/scan-single-barcode/blazor/Properties/launchSettings.json new file mode 100644 index 00000000..e25d8f48 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/blazor/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:17951", + "sslPort": 44366 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "http://localhost:5244", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "https://localhost:7074;http://localhost:5244", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/blazor/README.md b/barcode-scanner-api-samples/scan-single-barcode/blazor/README.md new file mode 100644 index 00000000..c25f2ed6 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/blazor/README.md @@ -0,0 +1,17 @@ +# 📦 Scan Single Barcode - Blazor + +This sample demonstrates how to use the `BarcodeScanner` API from the [Dynamsoft Barcode Reader JavaScript SDK](https://www.dynamsoft.com/barcode-reader/overview/javascript/) in a **Blazor** app to scan a single barcode using the camera. + +## ✨ Features + +- Easy integration with pre-built UI +- Renders barcodeScanner inside a container +- Scans one barcode at a time from video + +## 📌 Customization + +Please refer to sample [`scan-multiple-barcodes`](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-multiple-barcodes) or check the official [documentation](https://dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner-customization.html). + +## 📄 Support + +If you have any questions, feel free to [contact Dynamsoft Support](https://www.dynamsoft.com/company/contact?utm_source=sampleReadme). diff --git a/barcode-scanner-api-samples/scan-single-barcode/blazor/_Imports.razor b/barcode-scanner-api-samples/scan-single-barcode/blazor/_Imports.razor new file mode 100644 index 00000000..2c3956ad --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/blazor/_Imports.razor @@ -0,0 +1,10 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.AspNetCore.Components.WebAssembly.Http +@using Microsoft.JSInterop +@using BlazorApp +@using BlazorApp.Layout diff --git a/barcode-scanner-api-samples/scan-single-barcode/blazor/wwwroot/index.html b/barcode-scanner-api-samples/scan-single-barcode/blazor/wwwroot/index.html new file mode 100644 index 00000000..a5e91ce2 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/blazor/wwwroot/index.html @@ -0,0 +1,63 @@ + + + + + + + BlazorApp + + + + +
+
+ + + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/README.md b/barcode-scanner-api-samples/scan-single-barcode/capacitor/README.md new file mode 100644 index 00000000..24b2f172 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/README.md @@ -0,0 +1,43 @@ +# 📦 Scan Single Barcode - Capacitor + +This sample demonstrates how to use the `BarcodeScanner` API from the [Dynamsoft Barcode Reader JavaScript SDK](https://www.dynamsoft.com/barcode-reader/overview/javascript/) in a **Capacitor** app to scan a single barcode using the camera. + +We use typescript and rollup inside capacitor for demonstration. You can use any framework you like, or even vanilla javascript. + +## ✨ Features + +- Easy integration with pre-built UI +- Renders barcodeScanner inside a Capacitor container +- Scans one barcode at a time from video + +## 🚀 Quick Start + +```bash +npm install +npm run build +npx cap sync +``` + +Then build your app in Android Studio and Xcode. + +## 👓 Camera Permission + +Notice we add camera permission in `AndroidManifest.xml` and `Info.plist`. + +[android/app/src/main/AndroidManifest.xml](android/app/src/main/AndroidManifest.xml): +```xml + +``` +[ios/App/App/Info.plist](ios/App/App/Info.plist): +```xml +NSCameraUsageDescription +Decoding barcodes from video needs to access your camera. +``` + +## 📌 Customization + +Please refer to sample [`scan-multiple-barcodes`](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-multiple-barcodes) or check the official [documentation](https://dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner-customization.html). + +## 📄 Support + +If you have any questions, feel free to [contact Dynamsoft Support](https://www.dynamsoft.com/company/contact?utm_source=sampleReadme). diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/.gitignore b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/.gitignore new file mode 100644 index 00000000..48354a3d --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/.gitignore @@ -0,0 +1,101 @@ +# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore + +# Built application files +*.apk +*.aar +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +# Uncomment the following line in case you need and you don't have the release build type files in your app +# release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild +.cxx/ + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +# Android Profiling +*.hprof + +# Cordova plugins for Capacitor +capacitor-cordova-android-plugins + +# Copied web assets +app/src/main/assets/public + +# Generated Config files +app/src/main/assets/capacitor.config.json +app/src/main/assets/capacitor.plugins.json +app/src/main/res/xml/config.xml diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/.gitignore b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/.gitignore new file mode 100644 index 00000000..043df802 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/.gitignore @@ -0,0 +1,2 @@ +/build/* +!/build/.npmkeep diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/build.gradle b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/build.gradle new file mode 100644 index 00000000..a2585f06 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/build.gradle @@ -0,0 +1,54 @@ +apply plugin: 'com.android.application' + +android { + namespace "com.dynamsoft.dbrjs" + compileSdk rootProject.ext.compileSdkVersion + defaultConfig { + applicationId "com.dynamsoft.dbrjs" + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + aaptOptions { + // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. + // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61 + ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~' + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +repositories { + flatDir{ + dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs' + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" + implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion" + implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion" + implementation project(':capacitor-android') + testImplementation "junit:junit:$junitVersion" + androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" + androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" + implementation project(':capacitor-cordova-android-plugins') +} + +apply from: 'capacitor.build.gradle' + +try { + def servicesJSON = file('google-services.json') + if (servicesJSON.text) { + apply plugin: 'com.google.gms.google-services' + } +} catch(Exception e) { + logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work") +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/capacitor.build.gradle b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/capacitor.build.gradle new file mode 100644 index 00000000..bbfb44fa --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/capacitor.build.gradle @@ -0,0 +1,19 @@ +// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN + +android { + compileOptions { + sourceCompatibility JavaVersion.VERSION_21 + targetCompatibility JavaVersion.VERSION_21 + } +} + +apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" +dependencies { + + +} + + +if (hasProperty('postBuildExtras')) { + postBuildExtras() +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/proguard-rules.pro b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/proguard-rules.pro new file mode 100644 index 00000000..f1b42451 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java new file mode 100644 index 00000000..f2c2217e --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.getcapacitor.myapp; + +import static org.junit.Assert.*; + +import android.content.Context; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + + assertEquals("com.getcapacitor.app", appContext.getPackageName()); + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/AndroidManifest.xml b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..4cc824b9 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/java/com/dynamsoft/dbrjs/MainActivity.java b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/java/com/dynamsoft/dbrjs/MainActivity.java new file mode 100644 index 00000000..f3250895 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/java/com/dynamsoft/dbrjs/MainActivity.java @@ -0,0 +1,5 @@ +package com.dynamsoft.dbrjs; + +import com.getcapacitor.BridgeActivity; + +public class MainActivity extends BridgeActivity {} diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-hdpi/splash.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-hdpi/splash.png new file mode 100644 index 00000000..e31573b4 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-hdpi/splash.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-mdpi/splash.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-mdpi/splash.png new file mode 100644 index 00000000..f7a64923 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-mdpi/splash.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-xhdpi/splash.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-xhdpi/splash.png new file mode 100644 index 00000000..80772550 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-xhdpi/splash.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-xxhdpi/splash.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-xxhdpi/splash.png new file mode 100644 index 00000000..14c6c8fe Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-xxhdpi/splash.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-xxxhdpi/splash.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-xxxhdpi/splash.png new file mode 100644 index 00000000..244ca250 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-land-xxxhdpi/splash.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-hdpi/splash.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-hdpi/splash.png new file mode 100644 index 00000000..74faaa58 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-hdpi/splash.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-mdpi/splash.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-mdpi/splash.png new file mode 100644 index 00000000..e944f4ad Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-mdpi/splash.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-xhdpi/splash.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-xhdpi/splash.png new file mode 100644 index 00000000..564a82ff Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-xhdpi/splash.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-xxhdpi/splash.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-xxhdpi/splash.png new file mode 100644 index 00000000..bfabe687 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-xxhdpi/splash.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-xxxhdpi/splash.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-xxxhdpi/splash.png new file mode 100644 index 00000000..69290712 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-port-xxxhdpi/splash.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000..c7bd21db --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable/ic_launcher_background.xml b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..d5fccc53 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable/splash.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable/splash.png new file mode 100644 index 00000000..f7a64923 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/drawable/splash.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/layout/activity_main.xml b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..b5ad1387 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 00000000..036d09bc --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 00000000..036d09bc --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 00000000..c023e505 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 00000000..2127973b Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 00000000..b441f37d Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 00000000..72905b85 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 00000000..8ed0605c Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 00000000..9502e47a Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 00000000..4d1e0771 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 00000000..df0f1588 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 00000000..853db043 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..6cdf97c1 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 00000000..2960cbb6 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 00000000..8e3093a8 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 00000000..46de6e25 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 00000000..d2ea9abe Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 00000000..a40d73e9 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/values/ic_launcher_background.xml b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 00000000..c5d5899f --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/values/strings.xml b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/values/strings.xml new file mode 100644 index 00000000..ced650f8 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/values/strings.xml @@ -0,0 +1,7 @@ + + + dbrjs capacitor + dbrjs capacitor + com.dynamsoft.dbrjs + com.dynamsoft.dbrjs + diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/values/styles.xml b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..be874e54 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/values/styles.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/xml/file_paths.xml b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/xml/file_paths.xml new file mode 100644 index 00000000..bd0c4d80 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/main/res/xml/file_paths.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java new file mode 100644 index 00000000..02973278 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java @@ -0,0 +1,18 @@ +package com.getcapacitor.myapp; + +import static org.junit.Assert.*; + +import org.junit.Test; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/build.gradle b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/build.gradle new file mode 100644 index 00000000..f1b3b0e5 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/build.gradle @@ -0,0 +1,29 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + google() + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:8.7.2' + classpath 'com.google.gms:google-services:4.4.2' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +apply from: "variables.gradle" + +allprojects { + repositories { + google() + mavenCentral() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/capacitor.settings.gradle b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/capacitor.settings.gradle new file mode 100644 index 00000000..9a5fa872 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/capacitor.settings.gradle @@ -0,0 +1,3 @@ +// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN +include ':capacitor-android' +project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradle.properties b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradle.properties new file mode 100644 index 00000000..2e87c52f --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradle.properties @@ -0,0 +1,22 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradle/wrapper/gradle-wrapper.jar b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..a4b76b95 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradle/wrapper/gradle-wrapper.properties b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..c1d5e018 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradlew b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradlew new file mode 100644 index 00000000..f5feea6d --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradlew @@ -0,0 +1,252 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradlew.bat b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradlew.bat new file mode 100644 index 00000000..9d21a218 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/settings.gradle b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/settings.gradle new file mode 100644 index 00000000..3b4431d7 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/settings.gradle @@ -0,0 +1,5 @@ +include ':app' +include ':capacitor-cordova-android-plugins' +project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/') + +apply from: 'capacitor.settings.gradle' \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/variables.gradle b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/variables.gradle new file mode 100644 index 00000000..2c8e4083 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/android/variables.gradle @@ -0,0 +1,16 @@ +ext { + minSdkVersion = 23 + compileSdkVersion = 35 + targetSdkVersion = 35 + androidxActivityVersion = '1.9.2' + androidxAppCompatVersion = '1.7.0' + androidxCoordinatorLayoutVersion = '1.2.0' + androidxCoreVersion = '1.15.0' + androidxFragmentVersion = '1.8.4' + coreSplashScreenVersion = '1.0.1' + androidxWebkitVersion = '1.12.1' + junitVersion = '4.13.2' + androidxJunitVersion = '1.2.1' + androidxEspressoCoreVersion = '3.6.1' + cordovaAndroidVersion = '10.1.1' +} \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/capacitor.config.json b/barcode-scanner-api-samples/scan-single-barcode/capacitor/capacitor.config.json new file mode 100644 index 00000000..72cfd925 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/capacitor.config.json @@ -0,0 +1,6 @@ +{ + "appId": "com.dynamsoft.dbrjs", + "appName": "dbrjs capacitor", + "webDir": "dist", + "bundledWebRuntime": true +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/index.ts b/barcode-scanner-api-samples/scan-single-barcode/capacitor/index.ts new file mode 100644 index 00000000..c1ea6c93 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/index.ts @@ -0,0 +1,35 @@ +import { BarcodeScanner, BarcodeScannerConfig } from "dynamsoft-barcode-reader-bundle"; + +// Configuration object for initializing the BarcodeScanner instance +const config: BarcodeScannerConfig = { + license: "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", // Replace with your Dynamsoft license key + + // Specify where to render the scanner UI + // If container is not specified, the UI will take up the full screen + container: document.querySelector(".barcode-scanner-view") as HTMLElement, // Specify where to render the scanner UI + + // Specify the path for the definition file "barcode-scanner.ui.xml" for the scanner view. + uiPath: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.0.6000/dist/ui/barcode-scanner.ui.xml", + + // showUploadImageButton: true, + // scannerViewConfig: { + // showFlashButton: true, + // cameraSwitchControl: "toggleFrontBack", + // }, + + // Specify custom paths for the engine resources + engineResourcePaths: { + rootDirectory: "https://cdn.jsdelivr.net/npm/", + }, +}; + +// Create a new instance of the Dynamsoft Barcode Scanner +const barcodeScanner = new BarcodeScanner(config); + +(async()=>{ + // Launch the scanner; once a barcode is detected, display its text in an alert + let result = await barcodeScanner.launch(); + if (result.barcodeResults.length) { + alert(result.barcodeResults[0].text); + } +})(); diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/.gitignore b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/.gitignore new file mode 100644 index 00000000..f4702997 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/.gitignore @@ -0,0 +1,13 @@ +App/build +App/Pods +App/output +App/App/public +DerivedData +xcuserdata + +# Cordova plugins for Capacitor +capacitor-cordova-ios-plugins + +# Generated Config files +App/App/capacitor.config.json +App/App/config.xml diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App.xcodeproj/project.pbxproj b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App.xcodeproj/project.pbxproj new file mode 100644 index 00000000..bf705a81 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App.xcodeproj/project.pbxproj @@ -0,0 +1,408 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + 2FAD9763203C412B000D30F8 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = 2FAD9762203C412B000D30F8 /* config.xml */; }; + 50379B232058CBB4000EE86E /* capacitor.config.json in Resources */ = {isa = PBXBuildFile; fileRef = 50379B222058CBB4000EE86E /* capacitor.config.json */; }; + 504EC3081FED79650016851F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504EC3071FED79650016851F /* AppDelegate.swift */; }; + 504EC30D1FED79650016851F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30B1FED79650016851F /* Main.storyboard */; }; + 504EC30F1FED79650016851F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30E1FED79650016851F /* Assets.xcassets */; }; + 504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC3101FED79650016851F /* LaunchScreen.storyboard */; }; + 50B271D11FEDC1A000F3C39B /* public in Resources */ = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B /* public */; }; + A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 2FAD9762203C412B000D30F8 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = config.xml; sourceTree = ""; }; + 50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = ""; }; + 504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 504EC3071FED79650016851F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 504EC30C1FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 504EC30E1FED79650016851F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = ""; }; + AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = ""; }; + FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.debug.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 504EC3011FED79650016851F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 27E2DDA53C4D2A4D1A88CE4A /* Frameworks */ = { + isa = PBXGroup; + children = ( + AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 504EC2FB1FED79650016851F = { + isa = PBXGroup; + children = ( + 504EC3061FED79650016851F /* App */, + 504EC3051FED79650016851F /* Products */, + 7F8756D8B27F46E3366F6CEA /* Pods */, + 27E2DDA53C4D2A4D1A88CE4A /* Frameworks */, + ); + sourceTree = ""; + }; + 504EC3051FED79650016851F /* Products */ = { + isa = PBXGroup; + children = ( + 504EC3041FED79650016851F /* App.app */, + ); + name = Products; + sourceTree = ""; + }; + 504EC3061FED79650016851F /* App */ = { + isa = PBXGroup; + children = ( + 50379B222058CBB4000EE86E /* capacitor.config.json */, + 504EC3071FED79650016851F /* AppDelegate.swift */, + 504EC30B1FED79650016851F /* Main.storyboard */, + 504EC30E1FED79650016851F /* Assets.xcassets */, + 504EC3101FED79650016851F /* LaunchScreen.storyboard */, + 504EC3131FED79650016851F /* Info.plist */, + 2FAD9762203C412B000D30F8 /* config.xml */, + 50B271D01FEDC1A000F3C39B /* public */, + ); + path = App; + sourceTree = ""; + }; + 7F8756D8B27F46E3366F6CEA /* Pods */ = { + isa = PBXGroup; + children = ( + FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */, + AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 504EC3031FED79650016851F /* App */ = { + isa = PBXNativeTarget; + buildConfigurationList = 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */; + buildPhases = ( + 6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */, + 504EC3001FED79650016851F /* Sources */, + 504EC3011FED79650016851F /* Frameworks */, + 504EC3021FED79650016851F /* Resources */, + 9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = App; + productName = App; + productReference = 504EC3041FED79650016851F /* App.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 504EC2FC1FED79650016851F /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 0920; + TargetAttributes = { + 504EC3031FED79650016851F = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 504EC2FF1FED79650016851F /* Build configuration list for PBXProject "App" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 504EC2FB1FED79650016851F; + packageReferences = ( + ); + productRefGroup = 504EC3051FED79650016851F /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 504EC3031FED79650016851F /* App */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 504EC3021FED79650016851F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */, + 50B271D11FEDC1A000F3C39B /* public in Resources */, + 504EC30F1FED79650016851F /* Assets.xcassets in Resources */, + 50379B232058CBB4000EE86E /* capacitor.config.json in Resources */, + 504EC30D1FED79650016851F /* Main.storyboard in Resources */, + 2FAD9763203C412B000D30F8 /* config.xml in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-App-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App/Pods-App-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 504EC3001FED79650016851F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 504EC3081FED79650016851F /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 504EC30B1FED79650016851F /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 504EC30C1FED79650016851F /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 504EC3101FED79650016851F /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 504EC3111FED79650016851F /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 504EC3141FED79650016851F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 504EC3151FED79650016851F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 504EC3171FED79650016851F /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + INFOPLIST_FILE = App/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + MARKETING_VERSION = 1.0; + OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; + PRODUCT_BUNDLE_IDENTIFIER = com.dynamsoft.dbrjs; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 504EC3181FED79650016851F /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + INFOPLIST_FILE = App/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.dynamsoft.dbrjs; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 504EC2FF1FED79650016851F /* Build configuration list for PBXProject "App" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 504EC3141FED79650016851F /* Debug */, + 504EC3151FED79650016851F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 504EC3171FED79650016851F /* Debug */, + 504EC3181FED79650016851F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 504EC2FC1FED79650016851F /* Project object */; +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/AppDelegate.swift b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/AppDelegate.swift new file mode 100644 index 00000000..c3cd83b5 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/AppDelegate.swift @@ -0,0 +1,49 @@ +import UIKit +import Capacitor + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { + // Called when the app was launched with a url. Feel free to add additional processing here, + // but if you want the App API to support tracking app url opens, make sure to keep this call + return ApplicationDelegateProxy.shared.application(app, open: url, options: options) + } + + func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { + // Called when the app was launched with an activity, including Universal Links. + // Feel free to add additional processing here, but if you want the App API to support + // tracking app url opens, make sure to keep this call + return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler) + } + +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png new file mode 100644 index 00000000..adf6ba01 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..9b7d382d --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,14 @@ +{ + "images" : [ + { + "filename" : "AppIcon-512@2x.png", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Contents.json b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Contents.json new file mode 100644 index 00000000..da4a164c --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json new file mode 100644 index 00000000..d7d96a67 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "splash-2732x2732-2.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "splash-2732x2732-1.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "splash-2732x2732.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png new file mode 100644 index 00000000..33ea6c97 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png new file mode 100644 index 00000000..33ea6c97 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png new file mode 100644 index 00000000..33ea6c97 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Base.lproj/LaunchScreen.storyboard b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..e7ae5d78 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Base.lproj/Main.storyboard b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Base.lproj/Main.storyboard new file mode 100644 index 00000000..b44df7be --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Base.lproj/Main.storyboard @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Info.plist b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Info.plist new file mode 100644 index 00000000..18184968 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/App/Info.plist @@ -0,0 +1,51 @@ + + + + + NSCameraUsageDescription + Decoding barcodes from video needs to access your camera. + CFBundleDevelopmentRegion + en + CFBundleDisplayName + dbrjs capacitor + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(MARKETING_VERSION) + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/Podfile b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/Podfile new file mode 100644 index 00000000..bb7762ae --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/ios/App/Podfile @@ -0,0 +1,24 @@ +require_relative '../../node_modules/@capacitor/ios/scripts/pods_helpers' + +platform :ios, '14.0' +use_frameworks! + +# workaround to avoid Xcode caching of Pods that requires +# Product -> Clean Build Folder after new Cordova plugins installed +# Requires CocoaPods 1.6 or newer +install! 'cocoapods', :disable_input_output_paths => true + +def capacitor_pods + pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' + pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' + +end + +target 'App' do + capacitor_pods + # Add your Pods here +end + +post_install do |installer| + assertDeploymentTarget(installer) +end diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/package.json b/barcode-scanner-api-samples/scan-single-barcode/capacitor/package.json new file mode 100644 index 00000000..24dd4df7 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/package.json @@ -0,0 +1,24 @@ +{ + "name": "dbrjs-capacitor", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "build": "tsc && rollup -c", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "@capacitor/android": "^7.4.2", + "@capacitor/cli": "^7.4.2", + "@capacitor/core": "^7.4.2", + "@capacitor/ios": "^7.4.2", + "@rollup/plugin-node-resolve": "^15.3.0", + "@rollup/plugin-typescript": "^12.1.1", + "dynamsoft-barcode-reader-bundle": "11.0.6000", + "rollup": "^4.24.0", + "tslib": "^2.8.0", + "typescript": "^5.6.3" + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/public/index.html b/barcode-scanner-api-samples/scan-single-barcode/capacitor/public/index.html new file mode 100644 index 00000000..22685d65 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/public/index.html @@ -0,0 +1,21 @@ + + + + + + + Dynamsoft Barcode Reader Sample - Hello World (Decode via Camera) + + + +

Hello World (Scan One Single Barcode via Camera)

+
+ + + + + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/rollup.config.mjs b/barcode-scanner-api-samples/scan-single-barcode/capacitor/rollup.config.mjs new file mode 100644 index 00000000..dab19334 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/rollup.config.mjs @@ -0,0 +1,28 @@ +import fs from 'fs/promises'; +import typescript from "@rollup/plugin-typescript"; +import { nodeResolve } from "@rollup/plugin-node-resolve"; + +// https://rollupjs.org/guide/en/#configuration-files +export default async() => { + await fs.mkdir("./dist", { recursive: true, force: true }); + fs.cp("./public/", "./dist/", { recursive: true, force: true }) + return [ + { + input: "./index.ts", + plugins: [ + typescript({ + tsconfig: "./tsconfig.json" + }), + nodeResolve({ + exportConditions: ["browser", "default", "module", "import"], + }), + ], + output: [ + { + file: "./dist/index.js", + format: "umd", + }, + ], + }, + ]; +}; diff --git a/barcode-scanner-api-samples/scan-single-barcode/capacitor/tsconfig.json b/barcode-scanner-api-samples/scan-single-barcode/capacitor/tsconfig.json new file mode 100644 index 00000000..35e8318a --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/capacitor/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "es2017", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true, + "module": "ESNext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/electron/README.md b/barcode-scanner-api-samples/scan-single-barcode/electron/README.md new file mode 100644 index 00000000..5db7f2f3 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/electron/README.md @@ -0,0 +1,31 @@ +# 📦 Scan Single Barcode - Electron + +This sample demonstrates how to use the `BarcodeScanner` API from the [Dynamsoft Barcode Reader JavaScript SDK](https://www.dynamsoft.com/barcode-reader/overview/javascript/) in a **Electron** app to scan a single barcode using the camera. + +## ✨ Features + +- Easy integration with pre-built UI +- Renders barcodeScanner inside a container +- Scans one barcode at a time from video + +## 🚀 Quick Start + +### 1. Install Dependencies + +```bash +npm install +``` + +### 2. Start the App + +```bash +npm run start +``` + +## 📌 Customization + +Please refer to sample [`scan-multiple-barcodes`](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-multiple-barcodes) or check the official [documentation](https://dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner-customization.html). + +## 📄 Support + +If you have any questions, feel free to [contact Dynamsoft Support](https://www.dynamsoft.com/company/contact?utm_source=sampleReadme). diff --git a/barcode-scanner-api-samples/scan-single-barcode/electron/action.js b/barcode-scanner-api-samples/scan-single-barcode/electron/action.js new file mode 100644 index 00000000..5b6f0295 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/electron/action.js @@ -0,0 +1,22 @@ +// Configuration object for initializing the BarcodeScanner instance. Refer to https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/barcode-scanner.html#barcodescannerconfig +let config = { + license: "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", // Replace with your Dynamsoft license key + container: document.querySelector(".barcode-scanner-view"), // Specify where to render the scanner UI + + // showUploadImageButton: true, + // scannerViewConfig: { + // showFlashButton: true, + // cameraSwitchControl: "toggleFrontBack", + // }, +}; + +// Create a new instance of the Dynamsoft Barcode Scanner +const barcodeScanner = new Dynamsoft.BarcodeScanner(config); + +// Launch the scanner and handle the scanned result +barcodeScanner.launch().then((result) => { + // Display the first detected barcode's text in an alert + if (result.barcodeResults.length) { + alert(result.barcodeResults[0].text); + } +}); diff --git a/barcode-scanner-api-samples/scan-single-barcode/electron/index.html b/barcode-scanner-api-samples/scan-single-barcode/electron/index.html new file mode 100644 index 00000000..5e734485 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/electron/index.html @@ -0,0 +1,61 @@ + + + + + + + + Dynamsoft Barcode Scanner Sample - Hello World (Decode via Camera) + + + + +

+ Hello World (Scan One Single Barcode via Camera) +

+ +
+ + + + + + + + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/electron/main.js b/barcode-scanner-api-samples/scan-single-barcode/electron/main.js new file mode 100644 index 00000000..452d42f9 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/electron/main.js @@ -0,0 +1,29 @@ +const { app, BrowserWindow } = require("electron"); + +function createWindow() { + const win = new BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + nativeWindowOpen: true, + }, + }); + + win.loadFile("index.html"); +} + +app.whenReady().then(() => { + createWindow(); + + app.on("activate", () => { + if (BrowserWindow.getAllWindows().length === 0) { + createWindow(); + } + }); +}); + +app.on("window-all-closed", () => { + if (process.platform !== "darwin") { + app.quit(); + } +}); diff --git a/barcode-scanner-api-samples/scan-single-barcode/electron/package.json b/barcode-scanner-api-samples/scan-single-barcode/electron/package.json new file mode 100644 index 00000000..afc17b89 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/electron/package.json @@ -0,0 +1,26 @@ +{ + "name": "dbrjs-electron-sample", + "version": "1.2.0", + "description": "How to read barcodes from a video input in an Electron App", + "main": "main.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "electron ." + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Dynamsoft/barcode-reader-javascript-samples.git" + }, + "author": "Dynamsoft", + "license": "ISC", + "bugs": { + "url": "https://github.com/Dynamsoft/barcode-reader-javascript-samples/issues" + }, + "homepage": "https://github.com/Dynamsoft/barcode-reader-javascript-samples#readme", + "devDependencies": { + "electron": "^26.4.1" + }, + "dependencies": { + "dynamsoft-barcode-reader-bundle": "11.0.6000" + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/electron/style.css b/barcode-scanner-api-samples/scan-single-barcode/electron/style.css new file mode 100644 index 00000000..917e0cc1 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/electron/style.css @@ -0,0 +1,6 @@ +#results { + width: 100%; + height: 10vh; + overflow: auto; + white-space: pre-wrap; +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/es6.html b/barcode-scanner-api-samples/scan-single-barcode/es6.html new file mode 100644 index 00000000..741ad42e --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/es6.html @@ -0,0 +1,88 @@ + + + + + + + + Dynamsoft Barcode Scanner Sample - Hello World (Decode via Camera) + + + + +

+ Hello World (Scan One Single Barcode via Camera) +

+ +
+ + + + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/hello-world.html b/barcode-scanner-api-samples/scan-single-barcode/hello-world.html index fc0ade20..019ad007 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/hello-world.html +++ b/barcode-scanner-api-samples/scan-single-barcode/hello-world.html @@ -7,13 +7,49 @@ Dynamsoft Barcode Scanner Sample - Hello World (Decode via Camera) + + + +

+ Hello World (Scan One Single Barcode via Camera) +

+ +
+ + + - - - -

- Hello World (Scan One Single Barcode via Camera) -

- -
- - \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/native-ts/README.md b/barcode-scanner-api-samples/scan-single-barcode/native-ts/README.md new file mode 100644 index 00000000..eb7d5663 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/native-ts/README.md @@ -0,0 +1,26 @@ +# 📦 Scan Single Barcode - Typescript + +This sample demonstrates how to use the `BarcodeScanner` API from the [Dynamsoft Barcode Reader JavaScript SDK](https://www.dynamsoft.com/barcode-reader/overview/javascript/) in a **Typescript** app to scan a single barcode using the camera. + +## ✨ Features + +- Easy integration with pre-built UI +- Renders barcodeScanner inside a container +- Scans one barcode at a time from video + +## 🚀 Quick Start + +```bash +npm install +npm run build +``` + +Open `dist/index.html` in your browser. + +## 📌 Customization + +Please refer to sample [`scan-multiple-barcodes`](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-multiple-barcodes) or check the official [documentation](https://dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner-customization.html). + +## 📄 Support + +If you have any questions, feel free to [contact Dynamsoft Support](https://www.dynamsoft.com/company/contact?utm_source=sampleReadme). diff --git a/barcode-scanner-api-samples/scan-single-barcode/native-ts/index.ts b/barcode-scanner-api-samples/scan-single-barcode/native-ts/index.ts new file mode 100644 index 00000000..c1ea6c93 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/native-ts/index.ts @@ -0,0 +1,35 @@ +import { BarcodeScanner, BarcodeScannerConfig } from "dynamsoft-barcode-reader-bundle"; + +// Configuration object for initializing the BarcodeScanner instance +const config: BarcodeScannerConfig = { + license: "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", // Replace with your Dynamsoft license key + + // Specify where to render the scanner UI + // If container is not specified, the UI will take up the full screen + container: document.querySelector(".barcode-scanner-view") as HTMLElement, // Specify where to render the scanner UI + + // Specify the path for the definition file "barcode-scanner.ui.xml" for the scanner view. + uiPath: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.0.6000/dist/ui/barcode-scanner.ui.xml", + + // showUploadImageButton: true, + // scannerViewConfig: { + // showFlashButton: true, + // cameraSwitchControl: "toggleFrontBack", + // }, + + // Specify custom paths for the engine resources + engineResourcePaths: { + rootDirectory: "https://cdn.jsdelivr.net/npm/", + }, +}; + +// Create a new instance of the Dynamsoft Barcode Scanner +const barcodeScanner = new BarcodeScanner(config); + +(async()=>{ + // Launch the scanner; once a barcode is detected, display its text in an alert + let result = await barcodeScanner.launch(); + if (result.barcodeResults.length) { + alert(result.barcodeResults[0].text); + } +})(); diff --git a/barcode-scanner-api-samples/scan-single-barcode/native-ts/package.json b/barcode-scanner-api-samples/scan-single-barcode/native-ts/package.json new file mode 100644 index 00000000..05ca7796 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/native-ts/package.json @@ -0,0 +1,20 @@ +{ + "name": "dbrjs-capacitor", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "build": "tsc && rollup -c", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "@rollup/plugin-node-resolve": "^15.3.0", + "@rollup/plugin-typescript": "^12.1.1", + "dynamsoft-barcode-reader-bundle": "11.0.6000", + "rollup": "^4.24.0", + "tslib": "^2.8.0", + "typescript": "^5.6.3" + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/native-ts/public/index.html b/barcode-scanner-api-samples/scan-single-barcode/native-ts/public/index.html new file mode 100644 index 00000000..292324a8 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/native-ts/public/index.html @@ -0,0 +1,17 @@ + + + + + + + Dynamsoft Barcode Reader Sample - Hello World (Decode via Camera) + + + +

Hello World (Scan One Single Barcode via Camera)

+
+ + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/native-ts/rollup.config.mjs b/barcode-scanner-api-samples/scan-single-barcode/native-ts/rollup.config.mjs new file mode 100644 index 00000000..dab19334 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/native-ts/rollup.config.mjs @@ -0,0 +1,28 @@ +import fs from 'fs/promises'; +import typescript from "@rollup/plugin-typescript"; +import { nodeResolve } from "@rollup/plugin-node-resolve"; + +// https://rollupjs.org/guide/en/#configuration-files +export default async() => { + await fs.mkdir("./dist", { recursive: true, force: true }); + fs.cp("./public/", "./dist/", { recursive: true, force: true }) + return [ + { + input: "./index.ts", + plugins: [ + typescript({ + tsconfig: "./tsconfig.json" + }), + nodeResolve({ + exportConditions: ["browser", "default", "module", "import"], + }), + ], + output: [ + { + file: "./dist/index.js", + format: "umd", + }, + ], + }, + ]; +}; diff --git a/barcode-scanner-api-samples/scan-single-barcode/native-ts/tsconfig.json b/barcode-scanner-api-samples/scan-single-barcode/native-ts/tsconfig.json new file mode 100644 index 00000000..35e8318a --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/native-ts/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "es2017", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true, + "module": "ESNext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/pwa/README.md b/barcode-scanner-api-samples/scan-single-barcode/pwa/README.md new file mode 100644 index 00000000..c55a68fd --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/pwa/README.md @@ -0,0 +1,17 @@ +# 📦 Scan Single Barcode - PWA + +This sample shows how to integrate the `BarcodeScanner` API from the [Dynamsoft Barcode Reader JavaScript SDK](https://www.dynamsoft.com/barcode-reader/overview/javascript/) into a **PWA** application to scan a single barcode from video. + +## ✨ Features + +- Easy integration with pre-built UI +- BarcodeScanner instance created in a component +- Scans one barcode at a time from video + +## 📌 Customization + +Please refer to sample [`scan-multiple-barcodes`](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-multiple-barcodes) or check the official [documentation](https://dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner-customization.html). + +## 📄 Support + +If you have any questions, feel free to [contact Dynamsoft Support](https://www.dynamsoft.com/company/contact?utm_source=sampleReadme). diff --git a/barcode-scanner-api-samples/scan-single-barcode/pwa/dynamsoft-192x192.png b/barcode-scanner-api-samples/scan-single-barcode/pwa/dynamsoft-192x192.png new file mode 100644 index 00000000..e02348be Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/pwa/dynamsoft-192x192.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/pwa/dynamsoft-512x512.png b/barcode-scanner-api-samples/scan-single-barcode/pwa/dynamsoft-512x512.png new file mode 100644 index 00000000..1e0ec7dc Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/pwa/dynamsoft-512x512.png differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/pwa/helloworld-pwa.html b/barcode-scanner-api-samples/scan-single-barcode/pwa/helloworld-pwa.html new file mode 100644 index 00000000..a4e47410 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/pwa/helloworld-pwa.html @@ -0,0 +1,98 @@ + + + + + + + + Dynamsoft Barcode Reader PWA Sample - Hello World (Decode via Camera) + + + + + + + + + + + + +

+ Hello World (Scan One Single Barcode via Camera) +

+ +
+ + + + + + + + + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/pwa/helloworld-pwa.json b/barcode-scanner-api-samples/scan-single-barcode/pwa/helloworld-pwa.json new file mode 100644 index 00000000..1c6c8e42 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/pwa/helloworld-pwa.json @@ -0,0 +1,22 @@ +{ + "name": "Dynamsoft Barcode Reader Progressive Web App", + "short_name": "DBR-PWA", + "description": "Progressive Web App that reads barcodes from a video input with Dynamsoft Barcode Reader.", + "start_url": "./helloworld-pwa.html", + "scope": ".", + "display": "standalone", + "theme_color": "#B12A34", + "background_color": "#B12A34", + "icons": [ + { + "src": "./dynamsoft-512x512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "./dynamsoft-192x192.png", + "sizes": "192x192", + "type": "image/png" + } + ] +} \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/pwa/service-worker.js b/barcode-scanner-api-samples/scan-single-barcode/pwa/service-worker.js new file mode 100644 index 00000000..3af6a731 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/pwa/service-worker.js @@ -0,0 +1,83 @@ +const engineResourcePaths = { + dbrBundle: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.0.6000/dist/", +}; + +// Files to cache +const cacheName = "helloworld-pwa"; +// Here we choose some files into appShellFiles to cache. +// To keep it simple, you can put all the files +// in "node_modules/dynamsoft-barcode-reader-bundle/dist" into the list. +const appShellFiles = [ + "./helloworld-pwa.html", + "./dynamsoft-192x192.png", + "./dynamsoft-512x512.png", + "./helloworld-pwa.json", + `${engineResourcePaths.dbrBundle}dbr.bundle.worker.js`, + `${engineResourcePaths.dbrBundle}dynamsoft-barcode-reader-bundle.js` + `${engineResourcePaths.dbrBundle}dynamsoft-barcode-reader-bundle.wasm`, + `${engineResourcePaths.dbrBundle}models/OneDDeblur.data`, + `${engineResourcePaths.dbrBundle}parser-resources/AADHAAR_Map.txt`, + `${engineResourcePaths.dbrBundle}parser-resources/AADHAAR.dcpres`, + `${engineResourcePaths.dbrBundle}parser-resources/AAMVA_DL_ID_WITH_MAG_STRIPE.dcpres`, + `${engineResourcePaths.dbrBundle}parser-resources/AAMVA_DL_ID.dcpres`, + `${engineResourcePaths.dbrBundle}parser-resources/AAMVA_Map.txt`, + `${engineResourcePaths.dbrBundle}parser-resources/GS1_AI_Map.txt`, + `${engineResourcePaths.dbrBundle}parser-resources/GS1_AI.txt`, + `${engineResourcePaths.dbrBundle}parser-resources/MRTD_Map.txt`, + `${engineResourcePaths.dbrBundle}parser-resources/MRTD_TD1_ID.dcpres`, + `${engineResourcePaths.dbrBundle}parser-resources/MRTD_TD2_FRENCH_ID.dcpres`, + `${engineResourcePaths.dbrBundle}parser-resources/MRTD_TD2_ID.dcpres`, + `${engineResourcePaths.dbrBundle}parser-resources/MRTD_TD2_VISA.dcpres`, + `${engineResourcePaths.dbrBundle}parser-resources/MRTD_TD3_PASSPORT.dcpres`, + `${engineResourcePaths.dbrBundle}parser-resources/MRTD_TD3_VISA.dcpres`, + `${engineResourcePaths.dbrBundle}parser-resources/SOUTH_AFRICA_DL_Map.txt`, + `${engineResourcePaths.dbrBundle}parser-resources/SOUTH_AFRICA_DL.dcpres`, + `${engineResourcePaths.dbrBundle}parser-resources/VIN_Map.txt`, + `${engineResourcePaths.dbrBundle}parser-resources/VIN.dcpres`, + `${engineResourcePaths.dbrBundle}templates/DBR-PresetTemplates.json`, + `${engineResourcePaths.dbrBundle}ui/barcode-scanner.ui.xml`, + `${engineResourcePaths.dbrBundle}ui/dce.ui.xml`, + `${engineResourcePaths.dbrBundle}ui/dls.license.dialog.html`, +]; + +// Installing Service Worker +self.addEventListener("install", (e) => { + console.log("[Service Worker] Install"); + e.waitUntil( + (async () => { + const cache = await caches.open(cacheName); + console.log(cache); + console.log("[Service Worker] Caching all: app shell and content"); + await cache.addAll(appShellFiles); + })() + ); +}); + +self.addEventListener("fetch", (e) => { + e.respondWith( + (async () => { + // Fetch cached response if exists + const cachedResponse = await caches.match(e.request); + console.log(`[Service Worker] Fetching resource: ${e.request.url}`); + if (cachedResponse) { + return cachedResponse; + } + + // Otherwise, fetch from network + const response = await fetch(e.request); + + if ( + e.request.method !== "POST" && + // Authorization requests should not be cached + !/https:\/\/.*?\.dynamsoft.com\/auth/.test(e.request.url) + // You can add other filter conditions + ) { + const cache = await caches.open(cacheName); + console.log(`[Service Worker] Caching new resource: ${e.request.url}`); + cache.put(e.request, response.clone()); + } + + return response; + })() + ); +}); diff --git a/barcode-scanner-api-samples/scan-single-barcode/react/.gitignore b/barcode-scanner-api-samples/scan-single-barcode/react/.gitignore index a547bf36..b398d222 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/react/.gitignore +++ b/barcode-scanner-api-samples/scan-single-barcode/react/.gitignore @@ -22,3 +22,5 @@ dist-ssr *.njsproj *.sln *.sw? + +package-lock.json diff --git a/barcode-scanner-api-samples/scan-single-barcode/react/README.md b/barcode-scanner-api-samples/scan-single-barcode/react/README.md index 14c86058..10f597f1 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/react/README.md +++ b/barcode-scanner-api-samples/scan-single-barcode/react/README.md @@ -19,7 +19,7 @@ npm install ### 2. Start the App ```bash -npm start +npm run dev ``` Then open http://localhost:3000/ to view the sample app. diff --git a/barcode-scanner-api-samples/scan-single-barcode/react/eslint.config.js b/barcode-scanner-api-samples/scan-single-barcode/react/eslint.config.js deleted file mode 100644 index 092408a9..00000000 --- a/barcode-scanner-api-samples/scan-single-barcode/react/eslint.config.js +++ /dev/null @@ -1,28 +0,0 @@ -import js from '@eslint/js' -import globals from 'globals' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' -import tseslint from 'typescript-eslint' - -export default tseslint.config( - { ignores: ['dist'] }, - { - extends: [js.configs.recommended, ...tseslint.configs.recommended], - files: ['**/*.{ts,tsx}'], - languageOptions: { - ecmaVersion: 2020, - globals: globals.browser, - }, - plugins: { - 'react-hooks': reactHooks, - 'react-refresh': reactRefresh, - }, - rules: { - ...reactHooks.configs.recommended.rules, - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, - ], - }, - }, -) diff --git a/barcode-scanner-api-samples/scan-single-barcode/react/package.json b/barcode-scanner-api-samples/scan-single-barcode/react/package.json index c89b82d1..aa2b87c1 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/react/package.json +++ b/barcode-scanner-api-samples/scan-single-barcode/react/package.json @@ -1,30 +1,29 @@ { - "name": "react", + "name": "dbr-react", "private": true, "version": "0.0.0", "type": "module", "scripts": { "dev": "vite", "build": "tsc -b && vite build", - "lint": "eslint .", "preview": "vite preview" }, "dependencies": { "dynamsoft-barcode-reader-bundle": "11.0.6000", - "react": "^19.0.0", - "react-dom": "^19.0.0" + "react": "^19.1.1", + "react-dom": "^19.1.1" }, "devDependencies": { - "@eslint/js": "^9.22.0", - "@types/react": "^19.0.10", - "@types/react-dom": "^19.0.4", - "@vitejs/plugin-react": "^4.3.4", - "eslint": "^9.22.0", + "@eslint/js": "^9.33.0", + "@types/react": "^19.1.10", + "@types/react-dom": "^19.1.7", + "@vitejs/plugin-react": "^5.0.0", + "eslint": "^9.33.0", "eslint-plugin-react-hooks": "^5.2.0", - "eslint-plugin-react-refresh": "^0.4.19", - "globals": "^16.0.0", - "typescript": "~5.7.2", - "typescript-eslint": "^8.26.1", - "vite": "^6.3.1" + "eslint-plugin-react-refresh": "^0.4.20", + "globals": "^16.3.0", + "typescript": "~5.8.3", + "typescript-eslint": "^8.39.1", + "vite": "^7.1.2" } -} \ No newline at end of file +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/react/src/App.css b/barcode-scanner-api-samples/scan-single-barcode/react/src/App.css deleted file mode 100644 index 96b0bca8..00000000 --- a/barcode-scanner-api-samples/scan-single-barcode/react/src/App.css +++ /dev/null @@ -1,34 +0,0 @@ -.barcode-scanner-hello-world-page { - width: 100%; - height: 100%; - text-align: center; -} - -.barcode-scanner-title { - height: 90px; - display: flex; - justify-content: center; - align-items: center; - padding: 20px 0; -} - -.barcode-scanner-title .barcode-scanner-title-logo { - width: 60px; - height: 60px; - animation: retate 5s infinite linear; -} - -.barcode-scanner-view { - width: 100%; - height: calc(100% - 90px); -} - -@keyframes retate { - from { - transform: rotate(0deg); - } - - to { - transform: rotate(360deg); - } -} \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/react/src/App.tsx b/barcode-scanner-api-samples/scan-single-barcode/react/src/App.tsx index bb4d2088..4dd4fb84 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/react/src/App.tsx +++ b/barcode-scanner-api-samples/scan-single-barcode/react/src/App.tsx @@ -1,60 +1,65 @@ -import { useEffect, useRef } from "react"; -import reactLogo from "./assets/logo.svg"; -import { BarcodeScanner } from "dynamsoft-barcode-reader-bundle"; -import "./App.css"; +import { useEffect, useRef } from 'react'; +import { BarcodeScanner, type BarcodeScannerConfig } from "dynamsoft-barcode-reader-bundle"; + function App() { - const scannerViewRef = useRef(null); - const hasRun = useRef(false); - - useEffect(() => { - if (!hasRun.current) { - // Configuration object for initializing the BarcodeScanner instance - const config = { - license: "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", // Replace with your Dynamsoft license key - container: scannerViewRef.current!, // Specify where to render the scanner UI - - // Specify the path for the definition file "barcode-scanner.ui.xml" for the scanner view. - uiPath: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.0.6000/dist/", - - // showUploadImageButton: true, - // scannerViewConfig: { - // showFlashButton: true, - // cameraSwitchControl: "toggleFrontBack", - // }, - - // Specify custom paths for the engine resources - engineResourcePaths: { - rootDirectory: "https://cdn.jsdelivr.net/npm/", - }, - } + const barcodeScannerViewRef = useRef(null); + const hasRun = useRef(false); // walkaround react strict mode + + useEffect(() => { + if(hasRun.current){ return; } // walkaround react strict mode - // Create an instance of the BarcodeScanner with the provided configuration - const barcodeScanner = new BarcodeScanner(config); + // Configuration object for initializing the BarcodeScanner instance + const config: BarcodeScannerConfig = { + license: "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", // Replace with your Dynamsoft license key - // Launch the scanner; once a barcode is detected, display its text in an alert - barcodeScanner.launch().then((result) => { - if (result.barcodeResults.length) { - alert(result.barcodeResults[0].text); - } - }); - hasRun.current = true; + // Specify where to render the scanner UI + // If container is not specified, the UI will take up the full screen + container: barcodeScannerViewRef.current!, + + // Specify the path for the definition file "barcode-scanner.ui.xml" for the scanner view. + uiPath: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.0.6000/dist/ui/barcode-scanner.ui.xml", + + // showUploadImageButton: true, + // scannerViewConfig: { + // showFlashButton: true, + // cameraSwitchControl: "toggleFrontBack", + // }, + + // Specify custom paths for the engine resources + engineResourcePaths: { + rootDirectory: "https://cdn.jsdelivr.net/npm/", + }, } + + // Create an instance of the BarcodeScanner with the provided configuration + const barcodeScanner = new BarcodeScanner(config); + + (async ()=>{ + // Launch the scanner; once a barcode is detected, display its text in an alert + let result = await barcodeScanner.launch(); + if (result.barcodeResults.length) { + alert(result.barcodeResults[0].text); + } + })(); + + hasRun.current = true; + + //// We have bug in react strict mode. + //// It will be fixed in next version. + // return ()=>{ + // // Dispose of the barcode scanner when the component unmounts + // barcodeScanner?.dispose(); + // }; }, []); + return ( -
-
-

Hello World for React

- logo + <> +

Barcode Scanner for React

+
- {/* This div will host the barcode scanner's camera view */} -
-
- ); + + ) } -export default App; +export default App diff --git a/barcode-scanner-api-samples/scan-single-barcode/react/src/assets/logo.svg b/barcode-scanner-api-samples/scan-single-barcode/react/src/assets/logo.svg deleted file mode 100644 index 9dfc1c05..00000000 --- a/barcode-scanner-api-samples/scan-single-barcode/react/src/assets/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/react/src/index.css b/barcode-scanner-api-samples/scan-single-barcode/react/src/index.css deleted file mode 100644 index 8cff3329..00000000 --- a/barcode-scanner-api-samples/scan-single-barcode/react/src/index.css +++ /dev/null @@ -1,16 +0,0 @@ -* { - margin: 0; - padding: 0; - box-sizing: border-box; -} - -html, -body { - width: 100%; - height: 100%; -} - -#root { - width: 100%; - height: 100%; -} \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/react/src/main.tsx b/barcode-scanner-api-samples/scan-single-barcode/react/src/main.tsx index aa331f78..4aff0256 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/react/src/main.tsx +++ b/barcode-scanner-api-samples/scan-single-barcode/react/src/main.tsx @@ -1,5 +1,9 @@ +import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' -import './index.css' import App from './App.tsx' -createRoot(document.getElementById('root')!).render() +createRoot(document.getElementById('root')!).render( + + + , +) diff --git a/barcode-scanner-api-samples/scan-single-barcode/react/tsconfig.app.json b/barcode-scanner-api-samples/scan-single-barcode/react/tsconfig.app.json index 358ca9ba..227a6c67 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/react/tsconfig.app.json +++ b/barcode-scanner-api-samples/scan-single-barcode/react/tsconfig.app.json @@ -1,16 +1,16 @@ { "compilerOptions": { "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", - "target": "ES2020", + "target": "ES2022", "useDefineForClassFields": true, - "lib": ["ES2020", "DOM", "DOM.Iterable"], + "lib": ["ES2022", "DOM", "DOM.Iterable"], "module": "ESNext", "skipLibCheck": true, /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, - "isolatedModules": true, + "verbatimModuleSyntax": true, "moduleDetection": "force", "noEmit": true, "jsx": "react-jsx", @@ -19,6 +19,7 @@ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, + "erasableSyntaxOnly": true, "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, diff --git a/barcode-scanner-api-samples/scan-single-barcode/react/tsconfig.node.json b/barcode-scanner-api-samples/scan-single-barcode/react/tsconfig.node.json index db0becc8..f85a3990 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/react/tsconfig.node.json +++ b/barcode-scanner-api-samples/scan-single-barcode/react/tsconfig.node.json @@ -1,7 +1,7 @@ { "compilerOptions": { "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", - "target": "ES2022", + "target": "ES2023", "lib": ["ES2023"], "module": "ESNext", "skipLibCheck": true, @@ -9,7 +9,7 @@ /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, - "isolatedModules": true, + "verbatimModuleSyntax": true, "moduleDetection": "force", "noEmit": true, @@ -17,6 +17,7 @@ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, + "erasableSyntaxOnly": true, "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, diff --git a/barcode-scanner-api-samples/scan-single-barcode/react/vite.config.ts b/barcode-scanner-api-samples/scan-single-barcode/react/vite.config.ts index a14bb4d5..8b0f57b9 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/react/vite.config.ts +++ b/barcode-scanner-api-samples/scan-single-barcode/react/vite.config.ts @@ -4,5 +4,4 @@ import react from '@vitejs/plugin-react' // https://vite.dev/config/ export default defineConfig({ plugins: [react()], - base: "./" }) diff --git a/barcode-scanner-api-samples/scan-single-barcode/requirejs.html b/barcode-scanner-api-samples/scan-single-barcode/requirejs.html new file mode 100644 index 00000000..f5004617 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/requirejs.html @@ -0,0 +1,94 @@ + + + + + + + + Dynamsoft Barcode Scanner Sample - Hello World (Decode via Camera) + + + + +

+ Hello World (Scan One Single Barcode via Camera) +

+ +
+ + + + + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/svelte/.gitignore b/barcode-scanner-api-samples/scan-single-barcode/svelte/.gitignore new file mode 100644 index 00000000..b398d222 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/svelte/.gitignore @@ -0,0 +1,26 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +package-lock.json diff --git a/barcode-scanner-api-samples/scan-single-barcode/svelte/README.md b/barcode-scanner-api-samples/scan-single-barcode/svelte/README.md new file mode 100644 index 00000000..ccb3dcaf --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/svelte/README.md @@ -0,0 +1,33 @@ +# 📦 Scan Single Barcode - Svelte + +This sample shows how to integrate the `BarcodeScanner` API from the [Dynamsoft Barcode Reader JavaScript SDK](https://www.dynamsoft.com/barcode-reader/overview/javascript/) into a **Svelte** application to scan a single barcode from video. + +## ✨ Features + +- Easy integration with pre-built UI +- BarcodeScanner instance created in a Svelte component +- Scans one barcode at a time from video + +## 🚀 Quick Start + +### 1. Install Dependencies + +```bash +npm install +``` + +### 2. Run the App + +```bash +npm run dev +``` + +Then open http://localhost:5173/ to view the sample app. + +## 📌 Customization + +Please refer to sample [`scan-multiple-barcodes`](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-multiple-barcodes) or check the official [documentation](https://dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner-customization.html). + +## 📄 Support + +If you have any questions, feel free to [contact Dynamsoft Support](https://www.dynamsoft.com/company/contact?utm_source=sampleReadme). diff --git a/barcode-scanner-api-samples/scan-single-barcode/svelte/index.html b/barcode-scanner-api-samples/scan-single-barcode/svelte/index.html new file mode 100644 index 00000000..dce29517 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/svelte/index.html @@ -0,0 +1,12 @@ + + + + + + Dynamsoft Barcode Reader Sample - Hello World (Decode via Camera) + + +
+ + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/svelte/package.json b/barcode-scanner-api-samples/scan-single-barcode/svelte/package.json new file mode 100644 index 00000000..5534a71c --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/svelte/package.json @@ -0,0 +1,24 @@ +{ + "name": "dbrjs-svelte-sample", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "check": "svelte-check --tsconfig ./tsconfig.json" + }, + "dependencies": { + "dynamsoft-barcode-reader-bundle": "11.0.6000" + }, + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.0.2", + "@tsconfig/svelte": "^5.0.2", + "svelte": "^4.2.12", + "svelte-check": "^3.6.6", + "tslib": "^2.6.2", + "typescript": "^5.2.2", + "vite": "^5.1.6" + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/svelte/src/App.svelte b/barcode-scanner-api-samples/scan-single-barcode/svelte/src/App.svelte new file mode 100644 index 00000000..5dd6d8bf --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/svelte/src/App.svelte @@ -0,0 +1,55 @@ + + +
+

Barcode Scanner for Svelte

+
+
+
diff --git a/barcode-scanner-api-samples/scan-single-barcode/svelte/src/main.ts b/barcode-scanner-api-samples/scan-single-barcode/svelte/src/main.ts new file mode 100644 index 00000000..8c4eaed9 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/svelte/src/main.ts @@ -0,0 +1,7 @@ +import App from "./App.svelte"; + +const app = new App({ + target: document.getElementById("app")!, +}); + +export default app; diff --git a/barcode-scanner-api-samples/scan-single-barcode/react/src/vite-env.d.ts b/barcode-scanner-api-samples/scan-single-barcode/svelte/src/vite-env.d.ts similarity index 53% rename from barcode-scanner-api-samples/scan-single-barcode/react/src/vite-env.d.ts rename to barcode-scanner-api-samples/scan-single-barcode/svelte/src/vite-env.d.ts index 11f02fe2..4078e747 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/react/src/vite-env.d.ts +++ b/barcode-scanner-api-samples/scan-single-barcode/svelte/src/vite-env.d.ts @@ -1 +1,2 @@ +/// /// diff --git a/barcode-scanner-api-samples/scan-single-barcode/svelte/svelte.config.js b/barcode-scanner-api-samples/scan-single-barcode/svelte/svelte.config.js new file mode 100644 index 00000000..b0683fd2 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/svelte/svelte.config.js @@ -0,0 +1,7 @@ +import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' + +export default { + // Consult https://svelte.dev/docs#compile-time-svelte-preprocess + // for more information about preprocessors + preprocess: vitePreprocess(), +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/svelte/tsconfig.json b/barcode-scanner-api-samples/scan-single-barcode/svelte/tsconfig.json new file mode 100644 index 00000000..5fb548f2 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/svelte/tsconfig.json @@ -0,0 +1,20 @@ +{ + "extends": "@tsconfig/svelte/tsconfig.json", + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "resolveJsonModule": true, + /** + * Typecheck JS in `.svelte` and `.js` files by default. + * Disable checkJs if you'd like to use dynamic types in JS. + * Note that setting allowJs false does not prevent the use + * of JS in `.svelte` files. + */ + "allowJs": true, + "checkJs": true, + "isolatedModules": true + }, + "include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/svelte/tsconfig.node.json b/barcode-scanner-api-samples/scan-single-barcode/svelte/tsconfig.node.json new file mode 100644 index 00000000..d02c37df --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/svelte/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "strict": true + }, + "include": ["vite.config.ts"] +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/svelte/vite.config.ts b/barcode-scanner-api-samples/scan-single-barcode/svelte/vite.config.ts new file mode 100644 index 00000000..2aeffabd --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/svelte/vite.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'vite' +import { svelte } from '@sveltejs/vite-plugin-svelte' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [svelte()], + base: "./" +}) diff --git a/barcode-scanner-api-samples/scan-single-barcode/vue/.gitignore b/barcode-scanner-api-samples/scan-single-barcode/vue/.gitignore index a547bf36..b398d222 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/vue/.gitignore +++ b/barcode-scanner-api-samples/scan-single-barcode/vue/.gitignore @@ -22,3 +22,5 @@ dist-ssr *.njsproj *.sln *.sw? + +package-lock.json diff --git a/barcode-scanner-api-samples/scan-single-barcode/vue/index.html b/barcode-scanner-api-samples/scan-single-barcode/vue/index.html index f91cce4c..6f337734 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/vue/index.html +++ b/barcode-scanner-api-samples/scan-single-barcode/vue/index.html @@ -2,7 +2,6 @@ - Dynamsoft Barcode Reader Sample - Hello World (Decode via Camera) diff --git a/barcode-scanner-api-samples/scan-single-barcode/vue/package.json b/barcode-scanner-api-samples/scan-single-barcode/vue/package.json index fc511e0b..e9ff9f84 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/vue/package.json +++ b/barcode-scanner-api-samples/scan-single-barcode/vue/package.json @@ -1,5 +1,5 @@ { - "name": "vue", + "name": "dbr-vue", "private": true, "version": "0.0.0", "type": "module", @@ -10,13 +10,13 @@ }, "dependencies": { "dynamsoft-barcode-reader-bundle": "11.0.6000", - "vue": "^3.5.13" + "vue": "^3.5.18" }, "devDependencies": { - "@vitejs/plugin-vue": "^5.2.2", + "@vitejs/plugin-vue": "^6.0.1", "@vue/tsconfig": "^0.7.0", - "typescript": "~5.7.2", - "vite": "^6.3.1", - "vue-tsc": "^2.2.8" + "typescript": "~5.8.3", + "vite": "^7.1.2", + "vue-tsc": "^3.0.5" } -} \ No newline at end of file +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/vue/public/vite.svg b/barcode-scanner-api-samples/scan-single-barcode/vue/public/vite.svg deleted file mode 100644 index e7b8dfb1..00000000 --- a/barcode-scanner-api-samples/scan-single-barcode/vue/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/vue/src/App.vue b/barcode-scanner-api-samples/scan-single-barcode/vue/src/App.vue index e11700c0..3a7f3dc5 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/vue/src/App.vue +++ b/barcode-scanner-api-samples/scan-single-barcode/vue/src/App.vue @@ -1,18 +1,21 @@ - - diff --git a/barcode-scanner-api-samples/scan-single-barcode/vue/src/assets/vue.svg b/barcode-scanner-api-samples/scan-single-barcode/vue/src/assets/vue.svg deleted file mode 100644 index 770e9d33..00000000 --- a/barcode-scanner-api-samples/scan-single-barcode/vue/src/assets/vue.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/vue/src/main.ts b/barcode-scanner-api-samples/scan-single-barcode/vue/src/main.ts index 2425c0f7..01433bca 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/vue/src/main.ts +++ b/barcode-scanner-api-samples/scan-single-barcode/vue/src/main.ts @@ -1,5 +1,4 @@ import { createApp } from 'vue' -import './style.css' import App from './App.vue' createApp(App).mount('#app') diff --git a/barcode-scanner-api-samples/scan-single-barcode/vue/src/style.css b/barcode-scanner-api-samples/scan-single-barcode/vue/src/style.css deleted file mode 100644 index 051f6089..00000000 --- a/barcode-scanner-api-samples/scan-single-barcode/vue/src/style.css +++ /dev/null @@ -1,16 +0,0 @@ -* { - margin: 0; - padding: 0; - box-sizing: border-box; -} - -html, -body { - width: 100%; - height: 100%; -} - -#app { - width: 100%; - height: 100%; -} \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/vue/tsconfig.app.json b/barcode-scanner-api-samples/scan-single-barcode/vue/tsconfig.app.json index 7fb078ce..3dbbc453 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/vue/tsconfig.app.json +++ b/barcode-scanner-api-samples/scan-single-barcode/vue/tsconfig.app.json @@ -7,6 +7,7 @@ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, + "erasableSyntaxOnly": true, "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, diff --git a/barcode-scanner-api-samples/scan-single-barcode/vue/tsconfig.node.json b/barcode-scanner-api-samples/scan-single-barcode/vue/tsconfig.node.json index db0becc8..f85a3990 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/vue/tsconfig.node.json +++ b/barcode-scanner-api-samples/scan-single-barcode/vue/tsconfig.node.json @@ -1,7 +1,7 @@ { "compilerOptions": { "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", - "target": "ES2022", + "target": "ES2023", "lib": ["ES2023"], "module": "ESNext", "skipLibCheck": true, @@ -9,7 +9,7 @@ /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, - "isolatedModules": true, + "verbatimModuleSyntax": true, "moduleDetection": "force", "noEmit": true, @@ -17,6 +17,7 @@ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, + "erasableSyntaxOnly": true, "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, diff --git a/barcode-scanner-api-samples/scan-single-barcode/vue/vite.config.ts b/barcode-scanner-api-samples/scan-single-barcode/vue/vite.config.ts index 4796231d..bbcf80cc 100644 --- a/barcode-scanner-api-samples/scan-single-barcode/vue/vite.config.ts +++ b/barcode-scanner-api-samples/scan-single-barcode/vue/vite.config.ts @@ -4,5 +4,4 @@ import vue from '@vitejs/plugin-vue' // https://vite.dev/config/ export default defineConfig({ plugins: [vue()], - base: "./" }) diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/.gitignore b/barcode-scanner-api-samples/scan-single-barcode/webview/android/.gitignore new file mode 100644 index 00000000..aa724b77 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/README.md b/barcode-scanner-api-samples/scan-single-barcode/webview/android/README.md new file mode 100644 index 00000000..5af39a6a --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/README.md @@ -0,0 +1,24 @@ +# Hello-world for Android WebView - Dynamsoft Barcode Reader Sample + +This sample demonstrates how to use the [Dynamsoft Barcode Reader](https://www.dynamsoft.com/barcode-reader/overview/) JS Edition in Android. + +If you want to learn how to use the Android Edition SDK in javascript, you can check [Android WebView Barcode Scanning](https://github.com/Dynamsoft/barcode-reader-mobile-samples/tree/v9.x/android/JavaScript/WebViewBarcodeScanning). + +The Android Webview sample uses native APIs to handle some of the details of webview. If you want a framework, you can refer to the [capacitor sample](../../capacitor/). + +## 👓 Camera Permission + +Notice we add camera permission in `AndroidManifest.xml`. + +[app/src/main/AndroidManifest.xml](app/src/main/AndroidManifest.xml): +```xml + +``` + +## 📌 Customization + +Please refer to sample [`scan-multiple-barcodes`](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-multiple-barcodes) or check the official [documentation](https://dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner-customization.html). + +## 📄 Support + +If you have any questions, feel free to [contact Dynamsoft Support](https://www.dynamsoft.com/company/contact?utm_source=sampleReadme). \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/.gitignore b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/build.gradle b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/build.gradle new file mode 100644 index 00000000..33d838de --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/build.gradle @@ -0,0 +1,45 @@ +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' +} + +android { + namespace 'com.dynamsoft.dbrjswebview' + compileSdk 33 + + defaultConfig { + applicationId "com.dynamsoft.dbrjswebview" + minSdk 19 + targetSdk 33 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +dependencies { + + implementation 'androidx.core:core-ktx:1.7.0' + implementation 'androidx.appcompat:appcompat:1.4.1' + implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + implementation 'androidx.webkit:webkit:1.4.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +} \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/proguard-rules.pro b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/AndroidManifest.xml b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..f557697e --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/assets/decodeBarcodeInVideo.html b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/assets/decodeBarcodeInVideo.html new file mode 100644 index 00000000..019ad007 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/assets/decodeBarcodeInVideo.html @@ -0,0 +1,85 @@ + + + + + + + + Dynamsoft Barcode Scanner Sample - Hello World (Decode via Camera) + + + + +

+ Hello World (Scan One Single Barcode via Camera) +

+ +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/java/com/dynamsoft/dbrjswebview/MainActivity.kt b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/java/com/dynamsoft/dbrjswebview/MainActivity.kt new file mode 100644 index 00000000..8ecaf703 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/java/com/dynamsoft/dbrjswebview/MainActivity.kt @@ -0,0 +1,105 @@ +package com.dynamsoft.dbrjswebview + +import android.Manifest +import android.annotation.SuppressLint +import android.content.pm.PackageManager +import android.net.Uri +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.webkit.* +import androidx.activity.result.contract.ActivityResultContracts +import androidx.annotation.RequiresApi +import androidx.core.content.ContextCompat +import androidx.webkit.WebViewAssetLoader +import androidx.webkit.WebViewClientCompat + +class MainActivity : AppCompatActivity() { + @SuppressLint("SetJavaScriptEnabled") + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + val myWebView: WebView = findViewById(R.id.webview) + myWebView.settings.javaScriptEnabled = true + myWebView.settings.mediaPlaybackRequiresUserGesture = false + myWebView.settings.domStorageEnabled = true + + myWebView.webViewClient = MyWebViewClient() + myWebView.webChromeClient = MyWebChromeClient() + + myWebView.loadUrl("https://appassets.androidplatform.net/assets/decodeBarcodeInVideo.html") + } + + // Warning: If you use online url, you don't need `LocalContentWebViewClient` + // Refer: https://developer.android.com/develop/ui/views/layout/webapps/load-local-content?hl=en + private inner class MyWebViewClient : WebViewClientCompat() { + + private val assetLoader = WebViewAssetLoader.Builder() + .addPathHandler("/assets/", WebViewAssetLoader.AssetsPathHandler(this@MainActivity)) + .build() + + @RequiresApi(21) + override fun shouldInterceptRequest( + view: WebView, + request: WebResourceRequest + ): WebResourceResponse? { + return assetLoader.shouldInterceptRequest(request.url) + } + + // to support API < 21 + @Deprecated("Deprecated in Java") + override fun shouldInterceptRequest( + view: WebView, + url: String + ): WebResourceResponse? { + return assetLoader.shouldInterceptRequest(Uri.parse(url)) + } + } + + var cameraPermissionReq: PermissionRequest? = null + private inner class MyWebChromeClient : WebChromeClient() { + @RequiresApi(21) + override fun onPermissionRequest(request: PermissionRequest) { + if(request.resources.contains(PermissionRequest.RESOURCE_VIDEO_CAPTURE)){ + // Refer: https://developer.android.com/training/permissions/requesting + if(ContextCompat.checkSelfPermission( + this@MainActivity, + Manifest.permission.CAMERA + ) == PackageManager.PERMISSION_GRANTED){ + // You can use the API that requires the permission. + request.grant(arrayOf(PermissionRequest.RESOURCE_VIDEO_CAPTURE)) + }else{ + // You can directly ask for the permission. + // The registered ActivityResultCallback gets the result of this request. + this@MainActivity.cameraPermissionReq = request + requestCameraPermissionLauncher.launch(Manifest.permission.CAMERA) + } + }else{ + request.deny() + } + } + } + + // Refer: https://developer.android.com/training/permissions/requesting + @RequiresApi(21) + val requestCameraPermissionLauncher = registerForActivityResult( + ActivityResultContracts.RequestPermission() + ) { isGranted: Boolean -> + // Refer: https://www.dynamsoft.com/codepool/use-barcode-scanner-in-android-webview.html#set-up-webview + this@MainActivity.runOnUiThread { + if (isGranted) { + // Permission is granted. Continue the action or workflow in your + // app. + cameraPermissionReq?.grant(arrayOf(PermissionRequest.RESOURCE_VIDEO_CAPTURE)) + } else { + // Explain to the user that the feature is unavailable because the + // feature requires a permission that the user has denied. At the + // same time, respect the user's decision. Don't link to system + // settings in an effort to convince the user to change their + // decision. + cameraPermissionReq?.deny() + } + cameraPermissionReq = null + } + } +} \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 00000000..2b068d11 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/drawable/ic_launcher_background.xml b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..07d5da9c --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/layout/activity_main.xml b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..7b58479b --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 00000000..eca70cfe --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 00000000..eca70cfe --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml new file mode 100644 index 00000000..6f3b755b --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 00000000..c209e78e Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 00000000..b2dfe3d1 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 00000000..4f0f1d64 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 00000000..62b611da Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 00000000..948a3070 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..1b9a6956 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 00000000..28d4b77f Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..9287f508 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 00000000..aa7d6427 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..9126ae37 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/values-night/themes.xml b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/values-night/themes.xml new file mode 100644 index 00000000..77300351 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/values-night/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/values/colors.xml b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/values/colors.xml new file mode 100644 index 00000000..f8c6127d --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/values/strings.xml b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/values/strings.xml new file mode 100644 index 00000000..5d77158e --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Dynamsoft Barcode + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/values/themes.xml b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/values/themes.xml new file mode 100644 index 00000000..e2ed77aa --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/xml/backup_rules.xml b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/xml/backup_rules.xml new file mode 100644 index 00000000..fa0f996d --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/xml/backup_rules.xml @@ -0,0 +1,13 @@ + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/xml/data_extraction_rules.xml b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/xml/data_extraction_rules.xml new file mode 100644 index 00000000..9ee9997b --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/app/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/build.gradle b/barcode-scanner-api-samples/scan-single-barcode/webview/android/build.gradle new file mode 100644 index 00000000..ab2b874f --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/build.gradle @@ -0,0 +1,6 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + id 'com.android.application' version '7.4.2' apply false + id 'com.android.library' version '7.4.2' apply false + id 'org.jetbrains.kotlin.android' version '1.8.0' apply false +} \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradle.properties b/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradle.properties new file mode 100644 index 00000000..3c5031eb --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradle.properties @@ -0,0 +1,23 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradle/wrapper/gradle-wrapper.jar b/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..e708b1c0 Binary files /dev/null and b/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradle/wrapper/gradle-wrapper.properties b/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..dea1f353 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Thu Apr 13 17:46:19 CST 2023 +distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradlew b/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradlew new file mode 100644 index 00000000..4f906e0c --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradlew.bat b/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradlew.bat new file mode 100644 index 00000000..107acd32 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/android/settings.gradle b/barcode-scanner-api-samples/scan-single-barcode/webview/android/settings.gradle new file mode 100644 index 00000000..e5f9d85d --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/android/settings.gradle @@ -0,0 +1,16 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} +rootProject.name = "Dynamsoft Barcode" +include ':app' diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/.gitignore b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/.gitignore new file mode 100644 index 00000000..ba1ff083 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/.gitignore @@ -0,0 +1,90 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +build/ +DerivedData/ +*.moved-aside +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +## Obj-C/Swift specific +*.hmap + +## App packaging +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +# *.xcodeproj +# +# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata +# hence it is not needed unless you have added a package configuration file to your project +# .swiftpm + +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ +# +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build/ + +# Accio dependency management +Dependencies/ +.accio/ + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. +# Instead, use fastlane to re-generate the screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output + +# Code Injection +# +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/README.md b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/README.md new file mode 100644 index 00000000..a498670c --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/README.md @@ -0,0 +1,25 @@ +# Hello-world for iOS WKWebView - Dynamsoft Barcode Reader Sample + +This sample demonstrates how to use the [Dynamsoft Barcode Reader](https://www.dynamsoft.com/barcode-reader/overview/) JS Edition in iOS(Swift). + +If you want to learn how to use the iOS Edition SDK in javascript, you can check [iOS WebView Barcode Scanning](https://github.com/Dynamsoft/barcode-reader-mobile-samples/tree/v9.x/ios/JavaScript/WebViewBarcodeScanning) + +The iOS Webview sample uses native APIs to handle some of the details of webview. If you want a framework, you can refer to the [capacitor sample](../../capacitor/). + +## 👓 Camera Permission + +Notice we add camera permission in `Info.plist`. + +[dbrjswebview/Info.plist](dbrjswebview/Info.plist): +```xml +NSCameraUsageDescription +Decoding barcodes from video needs to access your camera. +``` + +## 📌 Customization + +Please refer to sample [`scan-multiple-barcodes`](https://github.com/Dynamsoft/barcode-reader-javascript-samples/tree/main/barcode-scanner-api-samples/scan-multiple-barcodes) or check the official [documentation](https://dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner-customization.html). + +## 📄 Support + +If you have any questions, feel free to [contact Dynamsoft Support](https://www.dynamsoft.com/company/contact?utm_source=sampleReadme). \ No newline at end of file diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview.xcodeproj/project.pbxproj b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview.xcodeproj/project.pbxproj new file mode 100644 index 00000000..7f7ce301 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview.xcodeproj/project.pbxproj @@ -0,0 +1,373 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 68309E9F29F28D950016A358 /* html in Resources */ = {isa = PBXBuildFile; fileRef = 68309E9E29F28D950016A358 /* html */; }; + 68A0A94529EE855E00DC7D57 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68A0A94429EE855E00DC7D57 /* AppDelegate.swift */; }; + 68A0A94729EE855E00DC7D57 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68A0A94629EE855E00DC7D57 /* SceneDelegate.swift */; }; + 68A0A94929EE855E00DC7D57 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68A0A94829EE855E00DC7D57 /* ViewController.swift */; }; + 68A0A94C29EE855E00DC7D57 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 68A0A94A29EE855E00DC7D57 /* Main.storyboard */; }; + 68A0A94E29EE856100DC7D57 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 68A0A94D29EE856100DC7D57 /* Assets.xcassets */; }; + 68A0A95129EE856100DC7D57 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 68A0A94F29EE856100DC7D57 /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 68309E9E29F28D950016A358 /* html */ = {isa = PBXFileReference; lastKnownFileType = folder; path = html; sourceTree = ""; }; + 68A0A94129EE855E00DC7D57 /* dbrjswebview.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = dbrjswebview.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 68A0A94429EE855E00DC7D57 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 68A0A94629EE855E00DC7D57 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 68A0A94829EE855E00DC7D57 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 68A0A94B29EE855E00DC7D57 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 68A0A94D29EE856100DC7D57 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 68A0A95029EE856100DC7D57 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 68A0A95229EE856100DC7D57 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 68A0A93E29EE855E00DC7D57 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 68A0A93829EE855E00DC7D57 = { + isa = PBXGroup; + children = ( + 68A0A94329EE855E00DC7D57 /* dbrjswebview */, + 68A0A94229EE855E00DC7D57 /* Products */, + ); + sourceTree = ""; + }; + 68A0A94229EE855E00DC7D57 /* Products */ = { + isa = PBXGroup; + children = ( + 68A0A94129EE855E00DC7D57 /* dbrjswebview.app */, + ); + name = Products; + sourceTree = ""; + }; + 68A0A94329EE855E00DC7D57 /* dbrjswebview */ = { + isa = PBXGroup; + children = ( + 68309E9E29F28D950016A358 /* html */, + 68A0A94429EE855E00DC7D57 /* AppDelegate.swift */, + 68A0A94629EE855E00DC7D57 /* SceneDelegate.swift */, + 68A0A94829EE855E00DC7D57 /* ViewController.swift */, + 68A0A94A29EE855E00DC7D57 /* Main.storyboard */, + 68A0A94D29EE856100DC7D57 /* Assets.xcassets */, + 68A0A94F29EE856100DC7D57 /* LaunchScreen.storyboard */, + 68A0A95229EE856100DC7D57 /* Info.plist */, + ); + path = dbrjswebview; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 68A0A94029EE855E00DC7D57 /* dbrjswebview */ = { + isa = PBXNativeTarget; + buildConfigurationList = 68A0A95529EE856100DC7D57 /* Build configuration list for PBXNativeTarget "dbrjswebview" */; + buildPhases = ( + 68A0A93D29EE855E00DC7D57 /* Sources */, + 68A0A93E29EE855E00DC7D57 /* Frameworks */, + 68A0A93F29EE855E00DC7D57 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = dbrjswebview; + productName = dbrjswebview; + productReference = 68A0A94129EE855E00DC7D57 /* dbrjswebview.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 68A0A93929EE855E00DC7D57 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1400; + LastUpgradeCheck = 1400; + TargetAttributes = { + 68A0A94029EE855E00DC7D57 = { + CreatedOnToolsVersion = 14.0.1; + }; + }; + }; + buildConfigurationList = 68A0A93C29EE855E00DC7D57 /* Build configuration list for PBXProject "dbrjswebview" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 68A0A93829EE855E00DC7D57; + productRefGroup = 68A0A94229EE855E00DC7D57 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 68A0A94029EE855E00DC7D57 /* dbrjswebview */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 68A0A93F29EE855E00DC7D57 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 68A0A95129EE856100DC7D57 /* LaunchScreen.storyboard in Resources */, + 68309E9F29F28D950016A358 /* html in Resources */, + 68A0A94E29EE856100DC7D57 /* Assets.xcassets in Resources */, + 68A0A94C29EE855E00DC7D57 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 68A0A93D29EE855E00DC7D57 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 68A0A94929EE855E00DC7D57 /* ViewController.swift in Sources */, + 68A0A94529EE855E00DC7D57 /* AppDelegate.swift in Sources */, + 68A0A94729EE855E00DC7D57 /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 68A0A94A29EE855E00DC7D57 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 68A0A94B29EE855E00DC7D57 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 68A0A94F29EE856100DC7D57 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 68A0A95029EE856100DC7D57 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 68A0A95329EE856100DC7D57 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 68A0A95429EE856100DC7D57 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 68A0A95629EE856100DC7D57 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = KK22Q4GV82; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = dbrjswebview/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = DyBarcode; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UIStatusBarStyle = ""; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 14.3; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.dynamsoft.dbrjswebview; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 68A0A95729EE856100DC7D57 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = KK22Q4GV82; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = dbrjswebview/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = DyBarcode; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UIStatusBarStyle = ""; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 14.3; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.dynamsoft.dbrjswebview; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 68A0A93C29EE855E00DC7D57 /* Build configuration list for PBXProject "dbrjswebview" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 68A0A95329EE856100DC7D57 /* Debug */, + 68A0A95429EE856100DC7D57 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 68A0A95529EE856100DC7D57 /* Build configuration list for PBXNativeTarget "dbrjswebview" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 68A0A95629EE856100DC7D57 /* Debug */, + 68A0A95729EE856100DC7D57 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 68A0A93929EE855E00DC7D57 /* Project object */; +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/AppDelegate.swift b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/AppDelegate.swift new file mode 100644 index 00000000..ad05d455 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// dbrjswebview +// +// Created by Dynamsoft on 2023/4/18. +// + +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Assets.xcassets/AccentColor.colorset/Contents.json b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Assets.xcassets/AppIcon.appiconset/Contents.json b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..13613e3e --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Assets.xcassets/Contents.json b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Base.lproj/LaunchScreen.storyboard b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..865e9329 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Base.lproj/Main.storyboard b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Base.lproj/Main.storyboard new file mode 100644 index 00000000..85dc8abf --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Base.lproj/Main.storyboard @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Info.plist b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Info.plist new file mode 100644 index 00000000..93bb4788 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/Info.plist @@ -0,0 +1,27 @@ + + + + + NSCameraUsageDescription + Decoding barcodes from video needs to access your camera. + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + + diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/SceneDelegate.swift b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/SceneDelegate.swift new file mode 100644 index 00000000..0860c7e6 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/SceneDelegate.swift @@ -0,0 +1,52 @@ +// +// SceneDelegate.swift +// dbrjswebview +// +// Created by Dynamsoft on 2023/4/18. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/ViewController.swift b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/ViewController.swift new file mode 100644 index 00000000..4e787292 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/ViewController.swift @@ -0,0 +1,116 @@ +// +// ViewController.swift +// dbrjswebview +// +// Created by Dynamsoft on 2023/4/18. +// + +import UIKit +import WebKit + +// Refer: https://developer.apple.com/documentation/webkit/viewing_desktop_or_mobile_web_content_using_a_web_view +class ViewController: UIViewController, WKUIDelegate { + + let webView: WKWebView + + required init?(coder: NSCoder) { + print("entered init") + let configuration = WKWebViewConfiguration() + configuration.allowsInlineMediaPlayback = true + configuration.mediaTypesRequiringUserActionForPlayback = [] + // Refer: https://stackoverflow.com/a/51736967 + configuration.websiteDataStore = WKWebsiteDataStore.default() + webView = WKWebView(frame: .init(), configuration: configuration) + + super.init(coder: coder) + } + + // Refer: https://www.hackingwithswift.com/articles/112/the-ultimate-guide-to-wkwebview + override func loadView() { + self.view = webView + } + + override func viewDidLoad() { + super.viewDidLoad() + print("entered viewDidLoad") + // Do any additional setup after loading the view. + + // Refer: https://stackoverflow.com/a/40316507 + webView.uiDelegate = self + + //let url = URL(string: "https://your.online.website/target/page.html")! + //webView.load(URLRequest(url: url)) + + // load local html + let fileUrl = Bundle.main.url(forResource: "html/decodeFileInVideo", withExtension: "html")! + webView.loadFileURL(fileUrl, allowingReadAccessTo: fileUrl) + print("finish viewDidLoad") + } + + // Refer: https://stackoverflow.com/a/40316507 + + func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, + completionHandler: @escaping () -> Void) { + + let alertController = UIAlertController(title: nil, message: message, preferredStyle: .actionSheet) + alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in + completionHandler() + })) + + present(alertController, animated: true, completion: nil) + } + + + func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, + completionHandler: @escaping (Bool) -> Void) { + + let alertController = UIAlertController(title: nil, message: message, preferredStyle: .actionSheet) + + alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in + completionHandler(true) + })) + + alertController.addAction(UIAlertAction(title: "Cancel", style: .default, handler: { (action) in + completionHandler(false) + })) + + present(alertController, animated: true, completion: nil) + } + + + func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText: String?, initiatedByFrame frame: WKFrameInfo, + completionHandler: @escaping (String?) -> Void) { + + let alertController = UIAlertController(title: nil, message: prompt, preferredStyle: .actionSheet) + + alertController.addTextField { (textField) in + textField.text = defaultText + } + + alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action) in + if let text = alertController.textFields?.first?.text { + completionHandler(text) + } else { + completionHandler(defaultText) + } + })) + + alertController.addAction(UIAlertAction(title: "Cancel", style: .default, handler: { (action) in + completionHandler(nil) + })) + + present(alertController, animated: true, completion: nil) + } + + // Auto grant camera access + // Refer: https://stackoverflow.com/a/72729381/6414094 + func webView(_ webView: WKWebView, + requestMediaCapturePermissionFor + origin: WKSecurityOrigin,initiatedByFrame + frame: WKFrameInfo,type: WKMediaCaptureType, + decisionHandler: @escaping (WKPermissionDecision) -> Void){ + decisionHandler(.grant) + } + +} + diff --git a/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/html/decodeFileInVideo.html b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/html/decodeFileInVideo.html new file mode 100644 index 00000000..019ad007 --- /dev/null +++ b/barcode-scanner-api-samples/scan-single-barcode/webview/ios/dbrjswebview/html/decodeFileInVideo.html @@ -0,0 +1,85 @@ + + + + + + + + Dynamsoft Barcode Scanner Sample - Hello World (Decode via Camera) + + + + +

+ Hello World (Scan One Single Barcode via Camera) +

+ +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/foundational-api-samples/hello-world/pwa/service-worker.js b/foundational-api-samples/hello-world/pwa/service-worker.js index 62afc1bf..3af6a731 100644 --- a/foundational-api-samples/hello-world/pwa/service-worker.js +++ b/foundational-api-samples/hello-world/pwa/service-worker.js @@ -4,6 +4,9 @@ const engineResourcePaths = { // Files to cache const cacheName = "helloworld-pwa"; +// Here we choose some files into appShellFiles to cache. +// To keep it simple, you can put all the files +// in "node_modules/dynamsoft-barcode-reader-bundle/dist" into the list. const appShellFiles = [ "./helloworld-pwa.html", "./dynamsoft-192x192.png", diff --git a/foundational-api-samples/use-case/fill-a-form-with-barcode-reading.html b/foundational-api-samples/use-case/fill-a-form-with-barcode-reading.html index 341658b7..90a214a6 100644 --- a/foundational-api-samples/use-case/fill-a-form-with-barcode-reading.html +++ b/foundational-api-samples/use-case/fill-a-form-with-barcode-reading.html @@ -6,7 +6,7 @@ - + Dynamsoft Barcode Reader Sample - Fill Forms with Dynamsoft Barcode Reader