├── src
├── .gitignore
├── .npmignore
├── references.d.ts
├── platforms
│ └── android
│ │ └── include.gradle
├── index.d.ts
├── pdf-view.ios.d.ts
├── pdf-view.android.d.ts
├── pdf-view.common.d.ts
├── tsconfig.json
├── pdf-view.common.ts
├── package.json
├── pdf-view.ios.ts
├── pdf-view.android.ts
├── tslint.json
└── AndroidPdfViewer.d.ts
├── demo
├── nsconfig.json
├── tsfmt.json
├── app
│ ├── app.css
│ ├── App_Resources
│ │ ├── iOS
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── Contents.json
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ ├── icon-29.png
│ │ │ │ │ ├── icon-40.png
│ │ │ │ │ ├── icon-50.png
│ │ │ │ │ ├── icon-57.png
│ │ │ │ │ ├── icon-72.png
│ │ │ │ │ ├── icon-76.png
│ │ │ │ │ ├── icon-29@2x.png
│ │ │ │ │ ├── icon-29@3x.png
│ │ │ │ │ ├── icon-40@2x.png
│ │ │ │ │ ├── icon-40@3x.png
│ │ │ │ │ ├── icon-50@2x.png
│ │ │ │ │ ├── icon-57@2x.png
│ │ │ │ │ ├── icon-60@2x.png
│ │ │ │ │ ├── icon-60@3x.png
│ │ │ │ │ ├── icon-72@2x.png
│ │ │ │ │ ├── icon-76@2x.png
│ │ │ │ │ ├── icon-83.5@2x.png
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── LaunchImage.launchimage
│ │ │ │ │ ├── Default.png
│ │ │ │ │ ├── Default@2x.png
│ │ │ │ │ ├── Default-568h@2x.png
│ │ │ │ │ ├── Default-667h@2x.png
│ │ │ │ │ ├── Default-736h@3x.png
│ │ │ │ │ ├── Default-Portrait.png
│ │ │ │ │ ├── Default-Landscape.png
│ │ │ │ │ ├── Default-Landscape@2x.png
│ │ │ │ │ ├── Default-Landscape@3x.png
│ │ │ │ │ ├── Default-Portrait@2x.png
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── LaunchScreen.Center.imageset
│ │ │ │ │ ├── LaunchScreen-Center.png
│ │ │ │ │ ├── LaunchScreen-Center@2x.png
│ │ │ │ │ └── Contents.json
│ │ │ │ └── LaunchScreen.AspectFill.imageset
│ │ │ │ │ ├── LaunchScreen-AspectFill.png
│ │ │ │ │ ├── LaunchScreen-AspectFill@2x.png
│ │ │ │ │ └── Contents.json
│ │ │ ├── build.xcconfig
│ │ │ ├── Info.plist
│ │ │ └── LaunchScreen.storyboard
│ │ └── Android
│ │ │ ├── src
│ │ │ └── main
│ │ │ │ ├── res
│ │ │ │ ├── values-v21
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── styles.xml
│ │ │ │ ├── drawable-hdpi
│ │ │ │ │ ├── icon.png
│ │ │ │ │ ├── logo.png
│ │ │ │ │ └── background.png
│ │ │ │ ├── drawable-ldpi
│ │ │ │ │ ├── icon.png
│ │ │ │ │ ├── logo.png
│ │ │ │ │ └── background.png
│ │ │ │ ├── drawable-mdpi
│ │ │ │ │ ├── icon.png
│ │ │ │ │ ├── logo.png
│ │ │ │ │ └── background.png
│ │ │ │ ├── drawable-xhdpi
│ │ │ │ │ ├── icon.png
│ │ │ │ │ ├── logo.png
│ │ │ │ │ └── background.png
│ │ │ │ ├── drawable-xxhdpi
│ │ │ │ │ ├── icon.png
│ │ │ │ │ ├── logo.png
│ │ │ │ │ └── background.png
│ │ │ │ ├── drawable-xxxhdpi
│ │ │ │ │ ├── icon.png
│ │ │ │ │ ├── logo.png
│ │ │ │ │ └── background.png
│ │ │ │ ├── values
│ │ │ │ │ ├── strings.xml
│ │ │ │ │ ├── colors.xml
│ │ │ │ │ └── styles.xml
│ │ │ │ └── drawable-nodpi
│ │ │ │ │ └── splash_screen.xml
│ │ │ │ └── AndroidManifest.xml
│ │ │ └── app.gradle
│ ├── tests
│ │ └── tests.js
│ ├── package.json
│ ├── main-page.ts
│ ├── main-page.xml
│ └── app.ts
├── tsconfig.tns.json
├── .editorconfig
├── .gitignore
├── tsconfig.json
├── package.json
├── karma.conf.js
└── webpack.config.js
├── .gitignore
├── .npmignore
├── .vscode
└── settings.json
├── .travis.yml
├── .github
└── FUNDING.yml
├── CONTRIBUTING.md
├── LICENSE
├── package.json
├── README.md
└── .cz-config.js
/src/.gitignore:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/demo/nsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "useLegacyWorkflow": false
3 | }
4 |
--------------------------------------------------------------------------------
/demo/tsfmt.json:
--------------------------------------------------------------------------------
1 | {
2 | "indentSize": 4,
3 | "tabSize": 4
4 | }
5 |
--------------------------------------------------------------------------------
/src/.npmignore:
--------------------------------------------------------------------------------
1 | pdf-view.android.ts
2 | pdf-view.ios.ts
3 | pdf-view.common.ts
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .npmrc
2 | *.js
3 | *.js.map
4 | *.log
5 | !.cz-config.js
6 |
7 | node_modules
--------------------------------------------------------------------------------
/demo/app/app.css:
--------------------------------------------------------------------------------
1 | @import '~@nativescript/theme/css/core.css';
2 | @import '~@nativescript/theme/css/default.css';
3 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .vscode
2 | demo/
3 | screenshots/
4 | *.gif
5 | *.png
6 | *.log
7 | *.map
8 | *.ts
9 | !*.d.ts
10 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/demo/tsconfig.tns.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig",
3 | "compilerOptions": {
4 | "module": "esNext",
5 | "moduleResolution": "node"
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/values-v21/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3d5afe
4 |
--------------------------------------------------------------------------------
/src/references.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/logo.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/logo.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/logo.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.exclude": {
3 | "**/*.js": {
4 | "when": "$(basename).ts"
5 | },
6 | "**/*.js.map": {
7 | "when": "$(basename)"
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/background.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/background.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/background.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/background.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/background.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png
--------------------------------------------------------------------------------
/src/platforms/android/include.gradle:
--------------------------------------------------------------------------------
1 | repositories {
2 | maven { url 'https://jitpack.io' }
3 | }
4 |
5 | dependencies {
6 | implementation 'com.github.TalbotGooday:AndroidPdfViewer:3.1.0-beta.3'
7 | }
8 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png
--------------------------------------------------------------------------------
/demo/app/tests/tests.js:
--------------------------------------------------------------------------------
1 | var PDFView = require("nativescript-pdf-view").PDFView;
2 | var pdfView = new PDFView();
3 |
4 | describe("PDFView", function() {
5 | it("exists", function() {
6 | expect(pdfView).toBeDefined();
7 | });
8 | });
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | PdfView Demo
4 | PdfView Demo
5 |
6 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/app.gradle:
--------------------------------------------------------------------------------
1 | android {
2 | defaultConfig {
3 | generatedDensities = []
4 | applicationId = "de.mynethome.nativescriptpdfviewdemo"
5 | }
6 | aaptOptions {
7 | additionalParameters "--no-version-vectors"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madmas/nativescript-pdf-view/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png
--------------------------------------------------------------------------------
/demo/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | end_of_line = lf
5 | insert_final_newline = true
6 | trim_trailing_whitespace = true
7 | charset = utf-8
8 |
9 | [*.json]
10 | indent_style = space
11 | indent_size = 2
12 |
13 | [*.ts]
14 | indent_style = space
15 | indent_size = 4
16 |
--------------------------------------------------------------------------------
/demo/app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "app.js",
3 | "android": {
4 | "v8Flags": "--expose_gc",
5 | "markingMode": "none",
6 | "codeCache" : "true"
7 | },
8 | "main": "app.js",
9 | "name": "nativescript-pdf-view-demo",
10 | "version": "3.0.0",
11 | "private": true
12 | }
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #F5F5F5
4 | #757575
5 | #33B5E5
6 | #272734
7 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/build.xcconfig:
--------------------------------------------------------------------------------
1 | // You can add custom settings here
2 | // for example you can uncomment the following line to force distribution code signing
3 | // CODE_SIGN_IDENTITY = iPhone Distribution
4 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
5 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
6 |
--------------------------------------------------------------------------------
/src/index.d.ts:
--------------------------------------------------------------------------------
1 | import { PDFViewCommon } from './pdf-view.common';
2 |
3 | export declare class PDFView extends PDFViewCommon {
4 | public loadPDF(src: string): void;
5 |
6 | public static loadEvent: string;
7 | public static notifyOfEvent(
8 | eventName: string,
9 | pdfViewRef: WeakRef,
10 | ): void;
11 | }
12 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/drawable-nodpi/splash_screen.xml:
--------------------------------------------------------------------------------
1 |
2 | -
3 |
4 |
5 | -
6 |
7 |
8 |
--------------------------------------------------------------------------------
/demo/app/main-page.ts:
--------------------------------------------------------------------------------
1 | import { EventData, Page } from '@nativescript/core/ui/page';
2 |
3 | import { MainViewModel } from './main-view-model';
4 |
5 | // Event handler for Page 'loaded' event attached in main-page.xml
6 | export function pageLoaded(args: EventData) {
7 | // Get the event sender
8 | const page = args.object;
9 | page.bindingContext = new MainViewModel();
10 | }
11 |
--------------------------------------------------------------------------------
/src/pdf-view.ios.d.ts:
--------------------------------------------------------------------------------
1 | import { PDFViewCommon } from './pdf-view.common';
2 | export declare class PDFView extends PDFViewCommon {
3 | private delegate;
4 | constructor();
5 | get ios(): WKWebView;
6 | set ios(value: WKWebView);
7 | onLoaded(): void;
8 | onUnloaded(): void;
9 | loadPDF(src: string): void;
10 | private init;
11 | private get mainScreen();
12 | }
13 |
--------------------------------------------------------------------------------
/demo/app/main-page.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/pdf-view.android.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | import pdfviewer = com.github.barteksc.pdfviewer;
3 | import { PDFViewCommon } from './pdf-view.common';
4 | export declare class PDFView extends PDFViewCommon {
5 | private promise;
6 | private onLoadHandler;
7 | get android(): pdfviewer.PDFView;
8 | set android(value: pdfviewer.PDFView);
9 | createNativeView(): pdfviewer.PDFView;
10 | loadPDF(src: string): void;
11 | private cacheThenLoad;
12 | }
13 |
--------------------------------------------------------------------------------
/demo/app/app.ts:
--------------------------------------------------------------------------------
1 | /*
2 | In NativeScript, the app.ts file is the entry point to your application.
3 | You can use this file to perform app-level initialization, but the primary
4 | purpose of the file is to pass control to the app’s first module.
5 | */
6 |
7 | import * as application from "@nativescript/core/application";
8 |
9 | application.run({ moduleName: "main-page" });
10 |
11 | /*
12 | Do not place any code after the application has been started as it will not
13 | be executed on iOS.
14 | */
15 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchScreen-Center.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchScreen-Center@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchScreen-AspectFill.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchScreen-AspectFill@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/src/pdf-view.common.d.ts:
--------------------------------------------------------------------------------
1 | import * as fs from '@nativescript/core/file-system';
2 | import { Property, View } from '@nativescript/core/ui/core/view';
3 | export declare abstract class PDFViewCommon extends View {
4 | static loadEvent: string;
5 | enableAnnotationRendering: boolean;
6 | src: string;
7 | protected tempFolder: fs.Folder;
8 | static notifyOfEvent(eventName: string, pdfViewRef: WeakRef): void;
9 | abstract loadPDF(src: string): any;
10 | protected createTempFile(base64data: any): void;
11 | }
12 | export declare const enableAnnotationRenderingProperty: Property;
13 | export declare const srcProperty: Property;
14 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | cache:
3 | directories:
4 | - ~/.npm
5 | notifications:
6 | email: true
7 | node_js:
8 | - 10
9 |
10 | jobs:
11 | include:
12 | - stage: test
13 | script:
14 | - cd src
15 | - npm ci && npm run lint
16 | - stage: build
17 | script:
18 | - cd src
19 | - npm ci && npm run build
20 | - stage: release
21 | # Advanced: optionally overwrite your default `script` step to skip the tests
22 | # script: skip
23 | deploy:
24 | provider: script
25 | skip_cleanup: true
26 | script: cp README.md src/ && cd src && npm ci && npx semantic-release
27 | on:
28 | all_branches: true
29 | branches:
30 | except:
31 | - /^v\d+\.\d+\.\d+$/
32 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: madmas # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: madmas # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/demo/.gitignore:
--------------------------------------------------------------------------------
1 | # NativeScript
2 | hooks/
3 | node_modules/
4 | platforms/
5 |
6 | # NativeScript Template
7 | *.js.map
8 | *.js
9 | !webpack.config.js
10 |
11 | # Logs
12 | logs
13 | *.log
14 | npm-debug.log*
15 | yarn-debug.log*
16 | yarn-error.log*
17 |
18 | # General
19 | .DS_Store
20 | .AppleDouble
21 | .LSOverride
22 | .idea
23 | .cloud
24 | .project
25 | tmp/
26 | typings/
27 |
28 | # Visual Studio Code
29 | .vscode/*
30 | !.vscode/settings.json
31 | !.vscode/tasks.json
32 | !.vscode/launch.json
33 | !.vscode/extensions.json
34 |
35 | lib
36 | platforms
37 | node_modules
38 | .migration_backup
39 | node_modules
40 |
41 | app/*.js
42 | !karma.conf.js
43 | !app/tests/*.js
44 |
45 | *.d.ts
46 | !references.d.ts
47 | app/main-page.d.ts
48 | app/main-view-model.d.ts
49 | app/app.d.ts
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | First of all, thank you!
4 |
5 | ## Commit Messages
6 |
7 | This project uses [`semantic-release`](https://github.com/semantic-release/semantic-release) to manage its releases, and therefore your commit messages must follow a [strict commit message format](https://github.com/semantic-release/semantic-release#default-commit-message-format).
8 |
9 | You may choose to use `npm run commit` instead of `git commit`, and you'll be presented with an interactive session that will generate your commit message for you.
10 |
11 | ## Linting TypeScript Code
12 |
13 | Make sure that your code changes pass the project TSLint rules. You can find out by running `npm run lint`. The task also runs on the Continuous Integration environment and will fail the build if it does not pass.
14 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
11 |
14 |
15 |
16 |
19 |
20 |
23 |
--------------------------------------------------------------------------------
/demo/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es5",
5 | "experimentalDecorators": true,
6 | "declaration": false,
7 | "removeComments": true,
8 | "emitDecoratorMetadata": true,
9 | "noEmitHelpers": true,
10 | "noEmitOnError": true,
11 | "skipLibCheck": true,
12 | "lib": [
13 | "es6",
14 | "dom"
15 | ],
16 | "pretty": true,
17 | "allowUnreachableCode": false,
18 | "allowUnusedLabels": false,
19 | "noImplicitAny": false,
20 | "noImplicitReturns": true,
21 | "noImplicitUseStrict": false,
22 | "noFallthroughCasesInSwitch": true,
23 | "baseUrl": ".",
24 | "paths": {
25 | "~/*": [
26 | "app/*"
27 | ],
28 | "*": [
29 | "./node_modules/*"
30 | ]
31 | }
32 | },
33 | "exclude": [
34 | "node_modules",
35 | "platforms",
36 | "../src/node_modules"
37 | ],
38 | "include": [
39 | "../src",
40 | "**/*"
41 | ]
42 | }
--------------------------------------------------------------------------------
/demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nativescript-pdf-view-demo",
3 | "description": "Demo application for nativescript-pdf-view",
4 | "private": true,
5 | "license": "MIT",
6 | "repository": {
7 | "type": "git",
8 | "url": "https://github.com/madmas/nativescript-pdf-view.git"
9 | },
10 | "nativescript": {
11 | "id": "de.mynethome.nativescriptpdfviewdemo",
12 | "tns-android": {
13 | "version": "6.5.3"
14 | },
15 | "tns-ios": {
16 | "version": "6.5.2"
17 | }
18 | },
19 | "dependencies": {
20 | "@nativescript/core": "6.5.12",
21 | "@nativescript/theme": "^2.3.3",
22 | "nativescript-pdf-view": "file:../src"
23 | },
24 | "devDependencies": {
25 | "babel-traverse": "6.24.1",
26 | "babel-types": "6.24.1",
27 | "babylon": "6.17.1",
28 | "filewalker": "0.1.3",
29 | "jasmine-core": "^2.6.1",
30 | "karma": "4.1.0",
31 | "karma-jasmine": "2.0.1",
32 | "karma-nativescript-launcher": "^0.4.0",
33 | "lazy": "1.0.11",
34 | "typescript": "~3.5.3",
35 | "nativescript-dev-webpack": "~1.5.1",
36 | "karma-webpack": "3.0.5"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | nativescript-pdf-view
4 |
5 | Copyright (c) 2019, Markus Schlichting
6 | Copyright (c) 2017, Merott Movahedi
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining a copy of
9 | this software and associated documentation files (the "Software"), to deal in
10 | the Software without restriction, including without limitation the rights to
11 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12 | the Software, and to permit persons to whom the Software is furnished to do so,
13 | subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice shall be included in all
16 | copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/src/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "declaration": true,
6 | "removeComments": true,
7 | "noLib": false,
8 | "emitDecoratorMetadata": true,
9 | "experimentalDecorators": true,
10 | "lib": [
11 | "es6",
12 | "dom"
13 | ],
14 | "baseUrl": ".",
15 | "paths": {
16 | "*": [
17 | "./node_modules/@nativescript/core/*",
18 | "./node_modules/*"
19 | ]
20 | },
21 | "sourceMap": true,
22 | "pretty": true,
23 | "allowUnreachableCode": false,
24 | "allowUnusedLabels": false,
25 | "noEmitHelpers": true,
26 | "noEmitOnError": false,
27 | "noImplicitAny": false,
28 | "noImplicitReturns": true,
29 | "noImplicitUseStrict": false,
30 | "noFallthroughCasesInSwitch": true,
31 | "typeRoots": [
32 | "./node_modules/@types",
33 | "./node_modules"
34 | ],
35 | "types": [
36 | ]
37 | },
38 | "exclude": [
39 | "demo",
40 | "node_modules",
41 | "out"
42 | ],
43 | "compileOnSave": false
44 | }
45 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
28 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiresFullScreen
28 |
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/src/pdf-view.common.ts:
--------------------------------------------------------------------------------
1 | import * as fs from '@nativescript/core/file-system';
2 | import { Property, View } from '@nativescript/core/ui/core/view';
3 |
4 | export abstract class PDFViewCommon extends View {
5 | public static loadEvent = 'load';
6 |
7 | /**
8 | * Render annotations (such as comments, colors or forms) on Android
9 | */
10 | public enableAnnotationRendering: boolean;
11 |
12 | /**
13 | * the source url of the PDF to show
14 | */
15 | public src: string;
16 |
17 | protected tempFolder = fs.knownFolders.temp().getFolder('PDFViewer.temp/');
18 |
19 | public static notifyOfEvent(
20 | eventName: string,
21 | // tslint:disable-next-line: no-any
22 | pdfViewRef: WeakRef,
23 | ) {
24 | const viewer = pdfViewRef.get();
25 |
26 | if (viewer) {
27 | // tslint:disable-next-line: no-unsafe-any
28 | viewer.notify({ eventName, object: viewer });
29 | }
30 | }
31 |
32 | public abstract loadPDF(src: string);
33 |
34 | // tslint:disable-next-line: no-any
35 | protected createTempFile(base64data: any) {
36 | this.tempFolder.clear().then(() => {
37 | const file = fs.Folder.fromPath(this.tempFolder.path)
38 | .getFile(`_${Date.now()}.pdf`);
39 | file.writeSync(base64data);
40 | this.loadPDF(file.path);
41 | });
42 | }
43 | }
44 |
45 | export const enableAnnotationRenderingProperty = new Property({
46 | defaultValue: false,
47 | name: 'enableAnnotationRendering',
48 | });
49 | enableAnnotationRenderingProperty.register(PDFViewCommon);
50 |
51 | export const srcProperty = new Property({
52 | name: 'src',
53 | });
54 | srcProperty.register(PDFViewCommon);
55 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nativescript-pdf-view",
3 | "version": "0.0.0-development",
4 | "description": "A NativeScript plugin to display PDF files on iOS and Android",
5 | "main": "index.js",
6 | "scripts": {
7 | "commit": "git-cz",
8 | "commitmsg": "cz-customizable-ghooks",
9 | "setup": "cd src && npm ci && cd demo && npm ci && cd .. && npm run build && cd demo && tns plugin add .. && cd .."
10 | },
11 | "release": {
12 | "generateNotes": "./node_modules/@semantic-release/release-notes-generator"
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "https://github.com/madmas/nativescript-pdf-view.git"
17 | },
18 | "author": "Markus Schlichting",
19 | "keywords": [
20 | "Android",
21 | "JavaScript",
22 | "NativeScript",
23 | "PDF",
24 | "View",
25 | "iOS"
26 | ],
27 | "contributors": [
28 | {
29 | "name": "Merott Movahedi",
30 | "email": "merott@merott.com"
31 | },
32 | {
33 | "name": "Markus Schlichting",
34 | "email": "m.schlichting@mynethome.de"
35 | }
36 | ],
37 | "bugs": {
38 | "url": "https://github.com/madmas/nativescript-pdf-view/issues"
39 | },
40 | "license": "MIT",
41 | "homepage": "https://github.com/madmas/nativescript-pdf-view#readme",
42 | "readmeFilename": "README.md",
43 | "devDependencies": {
44 | "commitizen": "^4.1.2",
45 | "cz-customizable": "^6.3.0",
46 | "cz-customizable-ghooks": "^1.5.0",
47 | "husky": "^0.13.4",
48 | "prompt": "~1.0.0",
49 | "rimraf": "3.0.0",
50 | "tslint": "^5.2.0",
51 | "typescript": "~2.3.2"
52 | },
53 | "config": {
54 | "commitizen": {
55 | "path": "./node_modules/cz-customizable"
56 | },
57 | "cz-customizable": {
58 | "config": ".cz-config.js"
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
18 |
19 |
21 |
22 |
23 |
31 |
32 |
34 |
35 |
36 |
42 |
43 |
45 |
46 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # *IMPORTANT*
2 |
3 | This plugin has moved into the NativeScript plugin repository: https://github.com/NativeScript/plugins/blob/main/packages/pdf/
4 |
5 | Please use `npm install @nativescript/pdf`from now on.
6 |
7 | There will be no more releases from this repository.
8 |
9 |
10 |
11 | # NativeScript PDFView
12 |
13 | > *Remark* [This repository](https://github.com/madmas/nativescript-pdf-view) is a fork of [the original by Merott](https://github.com/Merott/nativescript-pdf-view) that will be used with his consent to provide further maintenance of this NativeScript plugin.
14 |
15 | A minimal PDF view implementation that does only one thing, and that is to display PDF files in the simplest way possible. It conveniently uses the iOS `WKWebView`, and for Android it uses [`AndroidPdfViewer`](https://github.com/barteksc/AndroidPdfViewer).
16 |
17 | This plugin does the bare minimum required to render the PDF, no configuration options, and no error handling have been built yet. I welcome all Pull Requests!
18 |
19 | My aim is to keep the features consistent across iOS and Android.
20 |
21 | ## Installation
22 |
23 | ```
24 | tns plugin add nativescript-pdf-view
25 | ```
26 |
27 | ## Usage
28 |
29 | ### Vanilla NativeScript
30 |
31 | ```xml
32 |
36 |
37 |
38 | ```
39 |
40 | ### Angular NativeScript
41 |
42 | ```ts
43 | import { PDFView } from 'nativescript-pdf-view';
44 | import { registerElement } from 'nativescript-angular';
45 | registerElement('PDFView', () => PDFView);
46 | ```
47 |
48 | ```html
49 |
50 | ```
51 |
52 | ## Demo
53 |
54 | Check out the [demo](./demo) folder for a demo application using this plugin. You can run the demo by executing `npm run demo.ios` and `npm run demo.android` from the root directory of the project.
55 |
56 |
57 | ## Samples
58 |
59 | There are sample applications avalable:
60 |
61 | * *Plain TypeScript*: see [demo/](https://github.com/madmas/nativescript-pdf-view/tree/master/demo) folder in this repository
62 | * *NativeScript+Angular*: [nativescript-pdf-view-angular-sample](https://github.com/madmas/nativescript-pdf-view-angular-sample) repository
63 | * *NativeScript+VueJs*: [nativescript-pdf-view-vue-sample](https://github.com/madmas/nativescript-pdf-view-vue-sample) repository
64 |
--------------------------------------------------------------------------------
/src/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nativescript-pdf-view",
3 | "version": "0.0.0-development",
4 | "description": "A NativeScript plugin to display PDF files on iOS and Android",
5 | "main": "pdf-view",
6 | "typings": "index.d.ts",
7 | "nativescript": {
8 | "platforms": {
9 | "android": "3.0.0",
10 | "ios": "3.0.0"
11 | }
12 | },
13 | "scripts": {
14 | "build": "tsc",
15 | "commit": "git-cz",
16 | "commitmsg": "cz-customizable-ghooks",
17 | "demo.ios": "npm run preparedemo && cd ../demo && tns run ios --emulator",
18 | "demo.ios.device": "npm run preparedemo && cd ../demo && tns run ios",
19 | "demo.android": "npm run preparedemo && cd ../demo && tns run android --emulator",
20 | "lint": "tslint --project tsconfig.json -t stylish",
21 | "test.ios": "cd ../demo && tns test ios --emulator",
22 | "test.ios.device": "cd ../demo && tns test ios",
23 | "test.android": "cd ../demo && tns test android",
24 | "preparedemo": "npm run build && cd ../demo && tns plugin remove nativescript-pdf-view && tns plugin add ../src && tns install",
25 | "prepare": "npm run build",
26 | "semantic-release": "semantic-release",
27 | "setup": "npm ci && cd demo && npm ci && cd .. && npm run build && cd demo && tns plugin add .. && cd .."
28 | },
29 | "release": {
30 | "generateNotes": "./node_modules/@semantic-release/release-notes-generator"
31 | },
32 | "repository": {
33 | "type": "git",
34 | "url": "https://github.com/madmas/nativescript-pdf-view.git"
35 | },
36 | "keywords": [
37 | "Android",
38 | "JavaScript",
39 | "NativeScript",
40 | "PDF",
41 | "View",
42 | "iOS"
43 | ],
44 | "contributors": [
45 | {
46 | "name": "Merott Movahedi",
47 | "email": "merott@merott.com"
48 | },
49 | {
50 | "name": "Markus Schlichting",
51 | "email": "m.schlichting@mynethome.de"
52 | }
53 | ],
54 | "bugs": {
55 | "url": "https://github.com/madmas/nativescript-pdf-view/issues"
56 | },
57 | "license": "MIT",
58 | "homepage": "https://github.com/madmas/nativescript-pdf-view",
59 | "readmeFilename": "README.md",
60 | "devDependencies": {
61 | "@nativescript/core": "~6.5.15",
62 | "@semantic-release/release-notes-generator": "^9.0.1",
63 | "semantic-release": "^17.1.1",
64 | "prompt": "~1.0.0",
65 | "rimraf": "3.0.0",
66 | "tns-platform-declarations": "^6.5.15",
67 | "tslint": "^6.1.0",
68 | "typescript": "~3.9.7"
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/.cz-config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | types: [
3 | { value: 'feat', name: 'feat: A new feature' },
4 | { value: 'fix', name: 'fix: A bug fix' },
5 | { value: 'docs', name: 'docs: Documentation only changes' },
6 | {
7 | value: 'style',
8 | name:
9 | 'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc)',
10 | },
11 | {
12 | value: 'refactor',
13 | name: 'refactor: A code change that neither fixes a bug nor adds a feature',
14 | },
15 | {
16 | value: 'perf',
17 | name: 'perf: A code change that improves performance',
18 | },
19 | { value: 'test', name: 'test: Adding missing tests' },
20 | {
21 | value: 'chore',
22 | name:
23 | 'chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation',
24 | },
25 | { value: 'revert', name: 'revert: Revert to a commit' },
26 | { value: 'WIP', name: 'WIP: Work in progress' },
27 | ],
28 |
29 | scopes: [{ name: 'accounts' }, { name: 'admin' }, { name: 'exampleScope' }, { name: 'changeMe' }],
30 |
31 | allowTicketNumber: false,
32 | isTicketNumberRequired: false,
33 | ticketNumberPrefix: 'TICKET-',
34 | ticketNumberRegExp: '\\d{1,5}',
35 |
36 | // it needs to match the value for field type. Eg.: 'fix'
37 | /*
38 | scopeOverrides: {
39 | fix: [
40 |
41 | {name: 'merge'},
42 | {name: 'style'},
43 | {name: 'e2eTest'},
44 | {name: 'unitTest'}
45 | ]
46 | },
47 | */
48 | // override the messages, defaults are as follows
49 | messages: {
50 | type: "Select the type of change that you're committing:",
51 | scope: '\nDenote the SCOPE of this change (optional):',
52 | // used if allowCustomScopes is true
53 | customScope: 'Denote the SCOPE of this change:',
54 | subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
55 | body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
56 | breaking: 'List any BREAKING CHANGES (optional):\n',
57 | footer: 'List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:\n',
58 | confirmCommit: 'Are you sure you want to proceed with the commit above?',
59 | },
60 |
61 | allowCustomScopes: true,
62 | allowBreakingChanges: ['feat', 'fix'],
63 | // skip any questions you want
64 | skipQuestions: ['body', 'footer'],
65 |
66 | // limit subject length
67 | subjectLimit: 100,
68 | // breaklineChar: '|', // It is supported for fields body and footer.
69 | // footerPrefix : 'ISSUES CLOSED:', // default value
70 |
71 | appendBranchNameToCommitMessage: false,
72 | };
73 |
--------------------------------------------------------------------------------
/src/pdf-view.ios.ts:
--------------------------------------------------------------------------------
1 | import { screen } from '@nativescript/core/platform';
2 |
3 | import { PDFViewCommon, srcProperty } from './pdf-view.common';
4 |
5 | class PDFViewDelegate extends NSObject implements WKNavigationDelegate {
6 | public static ObjCProtocols = [WKNavigationDelegate];
7 |
8 | private owner: WeakRef;
9 |
10 | public static initWithOwner(owner: WeakRef): PDFViewDelegate {
11 | const delegate = PDFViewDelegate.new() as PDFViewDelegate;
12 | delegate.owner = owner;
13 | return delegate;
14 | }
15 |
16 | public webViewDidFinishNavigation(webView: WKWebView) {
17 | PDFViewCommon.notifyOfEvent(PDFViewCommon.loadEvent, this.owner);
18 | }
19 | }
20 |
21 | export class PDFView extends PDFViewCommon {
22 | private delegate: PDFViewDelegate;
23 |
24 | public constructor() {
25 | super();
26 | this.init();
27 | }
28 |
29 | public get ios() {
30 | return this.nativeView as WKWebView;
31 | }
32 |
33 | public set ios(value: WKWebView) {
34 | this.nativeView = value;
35 | }
36 |
37 | public [srcProperty.setNative](value: string) {
38 | this.loadPDF(value);
39 | }
40 |
41 | public onLoaded() {
42 | super.onLoaded();
43 | this.ios.navigationDelegate = this.delegate;
44 | }
45 |
46 | public onUnloaded() {
47 | this.ios.navigationDelegate = void 0;
48 | super.onUnloaded();
49 | }
50 |
51 | public loadPDF(src: string) {
52 | if (!src) {
53 | return;
54 | }
55 |
56 | let url: NSURL;
57 |
58 | // detect base64 stream
59 | const base64prefix = 'data:application/pdf;base64,';
60 | if (src.indexOf(base64prefix) === 0) {
61 | const base64data = NSData.alloc().initWithBase64EncodedStringOptions(src.substr(base64prefix.length), 0);
62 | this.createTempFile(base64data);
63 | return;
64 | }
65 |
66 | if (src.indexOf('://') === -1) {
67 | url = NSURL.fileURLWithPath(src);
68 | this.ios.loadFileURLAllowingReadAccessToURL(url, url);
69 | } else {
70 | url = NSURL.URLWithString(src);
71 | const urlRequest = NSURLRequest.requestWithURL(url);
72 | this.ios.loadRequest(urlRequest);
73 | }
74 | }
75 |
76 | private init() {
77 | this.delegate = PDFViewDelegate.initWithOwner(new WeakRef(this));
78 |
79 | this.ios = new WKWebView({
80 | configuration: WKWebViewConfiguration.new(),
81 | frame: this.mainScreen.bounds,
82 | });
83 |
84 | this.ios.opaque = false;
85 | this.ios.autoresizingMask =
86 | // tslint:disable-next-line:no-bitwise
87 | UIViewAutoresizing.FlexibleWidth |
88 | UIViewAutoresizing.FlexibleHeight;
89 | }
90 |
91 | private get mainScreen(): UIScreen {
92 | return UIScreen.mainScreen;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/pdf-view.android.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | import pdfviewer = com.github.barteksc.pdfviewer;
4 | import * as http from '@nativescript/core/http';
5 |
6 | import { PDFViewCommon, srcProperty } from './pdf-view.common';
7 |
8 | export class PDFView extends PDFViewCommon {
9 | private promise: Promise;
10 |
11 | private onLoadHandler = (() => {
12 | const pdfViewRef = new WeakRef(this);
13 |
14 | return new pdfviewer.listener.OnLoadCompleteListener({
15 | loadComplete: numPages => {
16 | PDFViewCommon.notifyOfEvent(PDFViewCommon.loadEvent, pdfViewRef);
17 | },
18 | });
19 | })();
20 |
21 | public get android() {
22 | return this.nativeView as pdfviewer.PDFView;
23 | }
24 |
25 | public set android(value) {
26 | this.nativeView = value;
27 | }
28 |
29 | public createNativeView() {
30 | // tslint:disable-next-line:no-unsafe-any
31 | return new pdfviewer.PDFView(this._context, void 0);
32 | }
33 |
34 | public [srcProperty.setNative](value: string) {
35 | this.loadPDF(value);
36 | }
37 |
38 | public loadPDF(src: string) {
39 | if (!src || !this.android) {
40 | return;
41 | }
42 |
43 | // reset any previous promise since we've called loadPDF again
44 | this.promise = void 0;
45 |
46 | // detect base64 stream
47 | const base64prefix = 'data:application/pdf;base64,';
48 | if (src.indexOf(base64prefix) === 0) {
49 | const base64data = android.util.Base64.decode(
50 | src.substr(base64prefix.length),
51 | android.util.Base64.DEFAULT);
52 | this.createTempFile(base64data);
53 | return;
54 | }
55 |
56 | if (src.indexOf('://') === -1) {
57 | src = 'file://' + src;
58 | } else if (src.indexOf('file://') !== 0) {
59 | // AndroidPdfViewer cannot load from remote URLs, download to cache
60 | this.cacheThenLoad(src);
61 | return;
62 | }
63 |
64 | const uri = android.net.Uri.parse(src);
65 |
66 | const defaultSpacingDP = 8;
67 | this.android
68 | .fromUri(uri)
69 | .onLoad(this.onLoadHandler)
70 | .spacing(defaultSpacingDP)
71 | .enableAnnotationRendering(this.enableAnnotationRendering)
72 | .fitEachPage(true)
73 | .load();
74 | }
75 |
76 | private cacheThenLoad(url: string) {
77 | // clear everything in cache
78 | this.tempFolder.clear().then(() => {
79 |
80 | // download to cache
81 | const promise = this.promise = http
82 | .getFile(url, `${this.tempFolder.path}/${Date.now()}.pdf`)
83 | .then(file => {
84 | if (this.promise === promise) { // make sure we haven't switched
85 | this.loadPDF(file.path);
86 | }
87 | }).catch(error => {
88 | console.error(error);
89 | });
90 | });
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "29x29",
5 | "idiom" : "iphone",
6 | "filename" : "icon-29.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "29x29",
11 | "idiom" : "iphone",
12 | "filename" : "icon-29@2x.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "icon-29@3x.png",
19 | "scale" : "3x"
20 | },
21 | {
22 | "size" : "40x40",
23 | "idiom" : "iphone",
24 | "filename" : "icon-40@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "40x40",
29 | "idiom" : "iphone",
30 | "filename" : "icon-40@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "57x57",
35 | "idiom" : "iphone",
36 | "filename" : "icon-57.png",
37 | "scale" : "1x"
38 | },
39 | {
40 | "size" : "57x57",
41 | "idiom" : "iphone",
42 | "filename" : "icon-57@2x.png",
43 | "scale" : "2x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "icon-60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "icon-60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "29x29",
59 | "idiom" : "ipad",
60 | "filename" : "icon-29.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "29x29",
65 | "idiom" : "ipad",
66 | "filename" : "icon-29@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "40x40",
71 | "idiom" : "ipad",
72 | "filename" : "icon-40.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "40x40",
77 | "idiom" : "ipad",
78 | "filename" : "icon-40@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "50x50",
83 | "idiom" : "ipad",
84 | "filename" : "icon-50.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "50x50",
89 | "idiom" : "ipad",
90 | "filename" : "icon-50@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "72x72",
95 | "idiom" : "ipad",
96 | "filename" : "icon-72.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "72x72",
101 | "idiom" : "ipad",
102 | "filename" : "icon-72@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "76x76",
107 | "idiom" : "ipad",
108 | "filename" : "icon-76.png",
109 | "scale" : "1x"
110 | },
111 | {
112 | "size" : "76x76",
113 | "idiom" : "ipad",
114 | "filename" : "icon-76@2x.png",
115 | "scale" : "2x"
116 | },
117 | {
118 | "size" : "83.5x83.5",
119 | "idiom" : "ipad",
120 | "filename" : "icon-83.5@2x.png",
121 | "scale" : "2x"
122 | }
123 | ],
124 | "info" : {
125 | "version" : 1,
126 | "author" : "xcode"
127 | }
128 | }
--------------------------------------------------------------------------------
/demo/karma.conf.js:
--------------------------------------------------------------------------------
1 | module.exports = function (config) {
2 | const options = {
3 |
4 | // base path that will be used to resolve all patterns (eg. files, exclude)
5 | basePath: '',
6 |
7 |
8 | // frameworks to use
9 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
10 | frameworks: ['jasmine'],
11 |
12 |
13 | // list of files / patterns to load in the browser
14 | files: ['app/tests/**/*.*'],
15 |
16 |
17 | // list of files to exclude
18 | exclude: [
19 | ],
20 |
21 |
22 | // preprocess matching files before serving them to the browser
23 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
24 | preprocessors: {
25 | },
26 |
27 |
28 | // test results reporter to use
29 | // possible values: 'dots', 'progress'
30 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter
31 | reporters: ['progress'],
32 |
33 |
34 | // web server port
35 | port: 9876,
36 |
37 |
38 | // enable / disable colors in the output (reporters and logs)
39 | colors: true,
40 |
41 |
42 | // level of logging
43 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
44 | logLevel: config.LOG_INFO,
45 |
46 |
47 | // enable / disable watching file and executing tests whenever any file changes
48 | autoWatch: true,
49 |
50 |
51 | // start these browsers
52 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
53 | browsers: [],
54 |
55 | customLaunchers: {
56 | android: {
57 | base: 'NS',
58 | platform: 'android'
59 | },
60 | ios: {
61 | base: 'NS',
62 | platform: 'ios'
63 | },
64 | ios_simulator: {
65 | base: 'NS',
66 | platform: 'ios',
67 | arguments: ['--emulator']
68 | }
69 | },
70 |
71 | // Continuous Integration mode
72 | // if true, Karma captures browsers, runs the tests and exits
73 | singleRun: false
74 | };
75 |
76 | setWebpackPreprocessor(config, options);
77 | setWebpack(config, options);
78 |
79 | config.set(options);
80 | }
81 |
82 | function setWebpackPreprocessor(config, options) {
83 | if (config && config.bundle) {
84 | if (!options.preprocessors) {
85 | options.preprocessors = {};
86 | }
87 |
88 | options.files.forEach(file => {
89 | if (!options.preprocessors[file]) {
90 | options.preprocessors[file] = [];
91 | }
92 | options.preprocessors[file].push('webpack');
93 | });
94 | }
95 | }
96 |
97 | function setWebpack(config, options) {
98 | if (config && config.bundle) {
99 | const env = {};
100 | env[config.platform] = true;
101 | env.sourceMap = config.debugBrk;
102 | options.webpack = require('./webpack.config')(env);
103 | delete options.webpack.entry;
104 | delete options.webpack.output.libraryTarget;
105 | const invalidPluginsForUnitTesting = ["GenerateBundleStarterPlugin", "GenerateNativeScriptEntryPointsPlugin"];
106 | options.webpack.plugins = options.webpack.plugins.filter(p => !invalidPluginsForUnitTesting.includes(p.constructor.name));
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "extent" : "full-screen",
5 | "idiom" : "iphone",
6 | "subtype" : "736h",
7 | "filename" : "Default-736h@3x.png",
8 | "minimum-system-version" : "8.0",
9 | "orientation" : "portrait",
10 | "scale" : "3x"
11 | },
12 | {
13 | "extent" : "full-screen",
14 | "idiom" : "iphone",
15 | "subtype" : "736h",
16 | "filename" : "Default-Landscape@3x.png",
17 | "minimum-system-version" : "8.0",
18 | "orientation" : "landscape",
19 | "scale" : "3x"
20 | },
21 | {
22 | "extent" : "full-screen",
23 | "idiom" : "iphone",
24 | "subtype" : "667h",
25 | "filename" : "Default-667h@2x.png",
26 | "minimum-system-version" : "8.0",
27 | "orientation" : "portrait",
28 | "scale" : "2x"
29 | },
30 | {
31 | "orientation" : "portrait",
32 | "idiom" : "iphone",
33 | "filename" : "Default@2x.png",
34 | "extent" : "full-screen",
35 | "minimum-system-version" : "7.0",
36 | "scale" : "2x"
37 | },
38 | {
39 | "extent" : "full-screen",
40 | "idiom" : "iphone",
41 | "subtype" : "retina4",
42 | "filename" : "Default-568h@2x.png",
43 | "minimum-system-version" : "7.0",
44 | "orientation" : "portrait",
45 | "scale" : "2x"
46 | },
47 | {
48 | "orientation" : "portrait",
49 | "idiom" : "ipad",
50 | "filename" : "Default-Portrait.png",
51 | "extent" : "full-screen",
52 | "minimum-system-version" : "7.0",
53 | "scale" : "1x"
54 | },
55 | {
56 | "orientation" : "landscape",
57 | "idiom" : "ipad",
58 | "filename" : "Default-Landscape.png",
59 | "extent" : "full-screen",
60 | "minimum-system-version" : "7.0",
61 | "scale" : "1x"
62 | },
63 | {
64 | "orientation" : "portrait",
65 | "idiom" : "ipad",
66 | "filename" : "Default-Portrait@2x.png",
67 | "extent" : "full-screen",
68 | "minimum-system-version" : "7.0",
69 | "scale" : "2x"
70 | },
71 | {
72 | "orientation" : "landscape",
73 | "idiom" : "ipad",
74 | "filename" : "Default-Landscape@2x.png",
75 | "extent" : "full-screen",
76 | "minimum-system-version" : "7.0",
77 | "scale" : "2x"
78 | },
79 | {
80 | "orientation" : "portrait",
81 | "idiom" : "iphone",
82 | "filename" : "Default.png",
83 | "extent" : "full-screen",
84 | "scale" : "1x"
85 | },
86 | {
87 | "orientation" : "portrait",
88 | "idiom" : "iphone",
89 | "filename" : "Default@2x.png",
90 | "extent" : "full-screen",
91 | "scale" : "2x"
92 | },
93 | {
94 | "orientation" : "portrait",
95 | "idiom" : "iphone",
96 | "filename" : "Default-568h@2x.png",
97 | "extent" : "full-screen",
98 | "subtype" : "retina4",
99 | "scale" : "2x"
100 | },
101 | {
102 | "orientation" : "portrait",
103 | "idiom" : "ipad",
104 | "extent" : "to-status-bar",
105 | "scale" : "1x"
106 | },
107 | {
108 | "orientation" : "portrait",
109 | "idiom" : "ipad",
110 | "filename" : "Default-Portrait.png",
111 | "extent" : "full-screen",
112 | "scale" : "1x"
113 | },
114 | {
115 | "orientation" : "landscape",
116 | "idiom" : "ipad",
117 | "extent" : "to-status-bar",
118 | "scale" : "1x"
119 | },
120 | {
121 | "orientation" : "landscape",
122 | "idiom" : "ipad",
123 | "filename" : "Default-Landscape.png",
124 | "extent" : "full-screen",
125 | "scale" : "1x"
126 | },
127 | {
128 | "orientation" : "portrait",
129 | "idiom" : "ipad",
130 | "extent" : "to-status-bar",
131 | "scale" : "2x"
132 | },
133 | {
134 | "orientation" : "portrait",
135 | "idiom" : "ipad",
136 | "filename" : "Default-Portrait@2x.png",
137 | "extent" : "full-screen",
138 | "scale" : "2x"
139 | },
140 | {
141 | "orientation" : "landscape",
142 | "idiom" : "ipad",
143 | "extent" : "to-status-bar",
144 | "scale" : "2x"
145 | },
146 | {
147 | "orientation" : "landscape",
148 | "idiom" : "ipad",
149 | "filename" : "Default-Landscape@2x.png",
150 | "extent" : "full-screen",
151 | "scale" : "2x"
152 | }
153 | ],
154 | "info" : {
155 | "version" : 1,
156 | "author" : "xcode"
157 | }
158 | }
--------------------------------------------------------------------------------
/src/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "defaultSeverity": "error",
3 | "rules": {
4 | "adjacent-overload-signatures": true,
5 | "align": [
6 | true,
7 | "parameters",
8 | "statements"
9 | ],
10 | "array-type": [
11 | true,
12 | "array-simple"
13 | ],
14 | "arrow-parens": [
15 | true,
16 | "ban-single-arg-parens"
17 | ],
18 | "arrow-return-shorthand": true,
19 | "await-promise": true,
20 | "ban": false,
21 | "ban-types": [
22 | true,
23 | [
24 | "Object",
25 | "Avoid using the `Object` type. Did you mean `object`?"
26 | ],
27 | [
28 | "Function",
29 | "Avoid using the `Function` type. Prefer a specific function type, like `() => void`."
30 | ],
31 | [
32 | "Boolean",
33 | "Avoid using the `Boolean` type. Did you mean `boolean`?"
34 | ],
35 | [
36 | "Number",
37 | "Avoid using the `Number` type. Did you mean `number`?"
38 | ],
39 | [
40 | "String",
41 | "Avoid using the `String` type. Did you mean `string`?"
42 | ],
43 | [
44 | "Symbol",
45 | "Avoid using the `Symbol` type. Did you mean `symbol`?"
46 | ]
47 | ],
48 | "callable-types": true,
49 | "class-name": true,
50 | "comment-format": [
51 | true,
52 | "check-space"
53 | ],
54 | "curly": true,
55 | "cyclomatic-complexity": [
56 | true
57 | ],
58 | "eofline": true,
59 | "file-header": [
60 | false
61 | ],
62 | "forin": true,
63 | "import-blacklist": [
64 | true,
65 | "rxjs"
66 | ],
67 | "import-spacing": true,
68 | "indent": [
69 | true,
70 | "spaces"
71 | ],
72 | "interface-name": [
73 | true,
74 | "never-prefix"
75 | ],
76 | "interface-over-type-literal": true,
77 | "jsdoc-format": true,
78 | "label-position": true,
79 | "linebreak-style": [
80 | false,
81 | "LF"
82 | ],
83 | "match-default-export-name": [
84 | true
85 | ],
86 | "max-classes-per-file": [
87 | true,
88 | 2
89 | ],
90 | "max-file-line-count": [
91 | true,
92 | 499
93 | ],
94 | "max-line-length": [
95 | false
96 | ], // using ter-max-len because it has more options
97 | "member-access": [
98 | true,
99 | "check-accessor",
100 | "check-constructor"
101 | ],
102 | "member-ordering": [
103 | true,
104 | "static-before-instance",
105 | "variables-before-functions"
106 | ],
107 | "new-parens": true,
108 | "newline-before-return": false,
109 | "no-angle-bracket-type-assertion": true,
110 | "no-any": true,
111 | "no-arg": true,
112 | "no-bitwise": true,
113 | "no-boolean-literal-compare": false,
114 | "no-conditional-assignment": true,
115 | "no-consecutive-blank-lines": [
116 | true
117 | ],
118 | "no-console": [
119 | true,
120 | "debug",
121 | "info",
122 | "log",
123 | "time",
124 | "timeEnd",
125 | "trace"
126 | ],
127 | "no-construct": true,
128 | "no-debugger": true,
129 | "no-default-export": true,
130 | "no-duplicate-super": true,
131 | "no-duplicate-variable": true,
132 | "no-empty": true,
133 | "no-empty-interface": true,
134 | "no-eval": true,
135 | "no-floating-promises": [
136 | false
137 | ],
138 | "no-for-in-array": true,
139 | "no-import-side-effect": [
140 | false
141 | ],
142 | "no-inferrable-types": [
143 | true,
144 | "ignore-params"
145 | ],
146 | "no-inferred-empty-object-type": true,
147 | "no-internal-module": true,
148 | "no-invalid-template-strings": true,
149 | "no-invalid-this": false,
150 | "no-magic-numbers": true,
151 | "no-mergeable-namespace": true,
152 | "no-misused-new": true,
153 | "no-namespace": true,
154 | "no-non-null-assertion": true,
155 | "no-null-keyword": true,
156 | "no-parameter-properties": false,
157 | "no-reference": false,
158 | "no-reference-import": false,
159 | "no-require-imports": true,
160 | "no-shadowed-variable": true,
161 | "no-sparse-arrays": true,
162 | "no-string-literal": true,
163 | "no-string-throw": true,
164 | "no-switch-case-fall-through": true,
165 | "no-trailing-whitespace": true,
166 | "no-unbound-method": true,
167 | "no-unnecessary-callback-wrapper": false,
168 | "no-unnecessary-initializer": true,
169 | "no-unnecessary-qualifier": true,
170 | "no-unsafe-any": true,
171 | "no-unsafe-finally": true,
172 | "no-unused-expression": true,
173 | "no-use-before-declare": true,
174 | "no-var-keyword": true,
175 | "no-var-requires": true,
176 | "no-void-expression": [
177 | true,
178 | "ignore-arrow-function-shorthand"
179 | ],
180 | "object-literal-key-quotes": [
181 | true,
182 | "consistent-as-needed"
183 | ],
184 | "object-literal-shorthand": true,
185 | "object-literal-sort-keys": true,
186 | "one-line": [
187 | true,
188 | "check-catch",
189 | "check-else",
190 | "check-finally",
191 | "check-open-brace",
192 | "check-whitespace"
193 | ],
194 | "one-variable-per-declaration": [
195 | true,
196 | "ignore-for-loop"
197 | ],
198 | "only-arrow-functions": [
199 | true,
200 | "allow-declarations",
201 | "allow-named-functions"
202 | ],
203 | "ordered-imports": [
204 | true,
205 | {
206 | "import-sources-order": "case-insensitive",
207 | "named-imports-order": "case-insensitive"
208 | }
209 | ],
210 | "prefer-const": true,
211 | "prefer-for-of": true,
212 | "prefer-function-over-method": [
213 | false
214 | ],
215 | "prefer-method-signature": true,
216 | "prefer-template": [
217 | true,
218 | "allow-single-concat"
219 | ],
220 | "promise-function-async": true,
221 | "quotemark": [
222 | true,
223 | "single",
224 | "avoid-escape"
225 | ],
226 | "radix": true,
227 | "restrict-plus-operands": true,
228 | "return-undefined": false,
229 | "semicolon": [
230 | true,
231 | "always"
232 | ],
233 | "space-before-function-paren": [
234 | true,
235 | {
236 | "anonymous": "never",
237 | "asyncArrow": "always",
238 | "constructor": "never",
239 | "method": "never",
240 | "named": "never"
241 | }
242 | ],
243 | "strict-boolean-expressions": false,
244 | "strict-type-predicates": true,
245 | "switch-default": false,
246 | "trailing-comma": [
247 | true,
248 | {
249 | "multiline": "always",
250 | "singleline": "never"
251 | }
252 | ],
253 | "triple-equals": [
254 | true,
255 | "allow-null-check"
256 | ],
257 | "typedef": [
258 | false
259 | ],
260 | "typedef-whitespace": [
261 | true,
262 | {
263 | "call-signature": "nospace",
264 | "index-signature": "nospace",
265 | "parameter": "nospace",
266 | "property-declaration": "nospace",
267 | "variable-declaration": "nospace"
268 | },
269 | {
270 | "call-signature": "onespace",
271 | "index-signature": "onespace",
272 | "parameter": "onespace",
273 | "property-declaration": "onespace",
274 | "variable-declaration": "onespace"
275 | }
276 | ],
277 | "unified-signatures": true,
278 | "use-isnan": true,
279 | "variable-name": [
280 | true,
281 | "allow-leading-underscore",
282 | "allow-pascal-case",
283 | "ban-keywords",
284 | "check-format"
285 | ],
286 | "whitespace": [
287 | true,
288 | "check-branch",
289 | "check-decl",
290 | "check-operator",
291 | "check-module",
292 | "check-separator",
293 | "check-type",
294 | "check-preblock"
295 | ]
296 | }
297 | }
--------------------------------------------------------------------------------
/src/AndroidPdfViewer.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module com {
4 | export module github {
5 | export module barteksc {
6 | export module pdfviewer {
7 | export class PDFView {
8 | public static class: java.lang.Class;
9 | public static DEFAULT_MAX_SCALE: number;
10 | public static DEFAULT_MID_SCALE: number;
11 | public static DEFAULT_MIN_SCALE: number;
12 | public toRealScale(param0: number): number;
13 | public isFitEachPage(): boolean;
14 | public recycle(): void;
15 | public isZooming(): boolean;
16 | public moveRelativeTo(param0: number, param1: number): void;
17 | public fromUri(param0: globalAndroid.net.Uri): com.github.barteksc.pdfviewer.PDFView.Configurator;
18 | public zoomWithAnimation(param0: number): void;
19 | public getMaxZoom(): number;
20 | public doRenderDuringScale(): boolean;
21 | public constructor(param0: globalAndroid.content.Context, param1: globalAndroid.util.AttributeSet);
22 | public jumpTo(param0: number): void;
23 | public isAnnotationRendering(): boolean;
24 | public zoomWithAnimation(param0: number, param1: number, param2: number): void;
25 | public zoomCenteredRelativeTo(param0: number, param1: globalAndroid.graphics.PointF): void;
26 | public enableRenderDuringScale(param0: boolean): void;
27 | public isBestQuality(): boolean;
28 | public setPageSnap(param0: boolean): void;
29 | public jumpTo(param0: number, param1: boolean): void;
30 | public performPageSnap(): void;
31 | public onDraw(param0: globalAndroid.graphics.Canvas): void;
32 | public enableAnnotationRendering(param0: boolean): void;
33 | public fromAsset(param0: string): com.github.barteksc.pdfviewer.PDFView.Configurator;
34 | public setNightMode(param0: boolean): void;
35 | public computeScroll(): void;
36 | public getCurrentPage(): number;
37 | public setSwipeEnabled(param0: boolean): void;
38 | public canScrollVertically(param0: number): boolean;
39 | public isPageFlingEnabled(): boolean;
40 | public getCurrentYOffset(): number;
41 | public getMinZoom(): number;
42 | public fromFile(param0: java.io.File): com.github.barteksc.pdfviewer.PDFView.Configurator;
43 | public documentFitsView(): boolean;
44 | public isSwipeVertical(): boolean;
45 | public getMidZoom(): number;
46 | public setPositionOffset(param0: number, param1: boolean): void;
47 | public isSwipeEnabled(): boolean;
48 | public setMinZoom(param0: number): void;
49 | public useBestQuality(param0: boolean): void;
50 | public isAutoSpacingEnabled(): boolean;
51 | public getCurrentXOffset(): number;
52 | public zoomCenteredTo(param0: number, param1: globalAndroid.graphics.PointF): void;
53 | public setMaxZoom(param0: number): void;
54 | public fitToWidth(param0: number): void;
55 | public setPositionOffset(param0: number): void;
56 | public setPageFling(param0: boolean): void;
57 | public fromBytes(param0: native.Array): com.github.barteksc.pdfviewer.PDFView.Configurator;
58 | public getZoom(): number;
59 | public pageFillsScreen(): boolean;
60 | public isPageSnap(): boolean;
61 | public onDetachedFromWindow(): void;
62 | public moveTo(param0: number, param1: number): void;
63 | public moveTo(param0: number, param1: number, param2: boolean): void;
64 | public getPageAtPositionOffset(param0: number): number;
65 | public fromStream(param0: java.io.InputStream): com.github.barteksc.pdfviewer.PDFView.Configurator;
66 | public setMidZoom(param0: number): void;
67 | public resetZoom(): void;
68 | public canScrollHorizontally(param0: number): boolean;
69 | public zoomTo(param0: number): void;
70 | public onSizeChanged(param0: number, param1: number, param2: number, param3: number): void;
71 | public getPositionOffset(): number;
72 | public getPageCount(): number;
73 | public loadPages(): void;
74 | public stopFling(): void;
75 | public enableAntialiasing(param0: boolean): void;
76 | public isRecycled(): boolean;
77 | public toCurrentScale(param0: number): number;
78 | public isAntialiasing(): boolean;
79 | public resetZoomWithAnimation(): void;
80 | public getSpacingPx(): number;
81 | }
82 | export module PDFView {
83 | export class Configurator {
84 | public static class: java.lang.Class;
85 | public enableAnnotationRendering(param0: boolean): com.github.barteksc.pdfviewer.PDFView.Configurator;
86 | public nightMode(param0: boolean): com.github.barteksc.pdfviewer.PDFView.Configurator;
87 | public spacing(param0: number): com.github.barteksc.pdfviewer.PDFView.Configurator;
88 | public fitEachPage(param0: boolean): com.github.barteksc.pdfviewer.PDFView.Configurator;
89 | public pageSnap(param0: boolean): com.github.barteksc.pdfviewer.PDFView.Configurator;
90 | public enableAntialiasing(param0: boolean): com.github.barteksc.pdfviewer.PDFView.Configurator;
91 | public load(): void;
92 | public disableLongpress(): com.github.barteksc.pdfviewer.PDFView.Configurator;
93 | public enableSwipe(param0: boolean): com.github.barteksc.pdfviewer.PDFView.Configurator;
94 | public defaultPage(param0: number): com.github.barteksc.pdfviewer.PDFView.Configurator;
95 | public swipeHorizontal(param0: boolean): com.github.barteksc.pdfviewer.PDFView.Configurator;
96 | public enableDoubletap(param0: boolean): com.github.barteksc.pdfviewer.PDFView.Configurator;
97 | public password(param0: string): com.github.barteksc.pdfviewer.PDFView.Configurator;
98 | public onLoad(param0: com.github.barteksc.pdfviewer.listener.OnLoadCompleteListener): com.github.barteksc.pdfviewer.PDFView.Configurator;
99 | public autoSpacing(param0: boolean): com.github.barteksc.pdfviewer.PDFView.Configurator;
100 | public pageFling(param0: boolean): com.github.barteksc.pdfviewer.PDFView.Configurator;
101 | public pages(param0: native.Array): com.github.barteksc.pdfviewer.PDFView.Configurator;
102 | }
103 | export class ScrollDir {
104 | public static class: java.lang.Class;
105 | public static NONE: com.github.barteksc.pdfviewer.PDFView.ScrollDir;
106 | public static START: com.github.barteksc.pdfviewer.PDFView.ScrollDir;
107 | public static END: com.github.barteksc.pdfviewer.PDFView.ScrollDir;
108 | public static values(): native.Array;
109 | public static valueOf(param0: string): com.github.barteksc.pdfviewer.PDFView.ScrollDir;
110 | }
111 | export class State {
112 | public static class: java.lang.Class;
113 | public static DEFAULT: com.github.barteksc.pdfviewer.PDFView.State;
114 | public static LOADED: com.github.barteksc.pdfviewer.PDFView.State;
115 | public static SHOWN: com.github.barteksc.pdfviewer.PDFView.State;
116 | public static ERROR: com.github.barteksc.pdfviewer.PDFView.State;
117 | public static valueOf(param0: string): com.github.barteksc.pdfviewer.PDFView.State;
118 | public static values(): native.Array;
119 | }
120 | }
121 |
122 | export module listener {
123 | export interface OnErrorListener {
124 | onError(throwable: java.lang.Throwable): void;
125 | }
126 |
127 | interface IOnLoadCompleteListener {
128 | /**
129 | * Called when the PDF is loaded
130 | * @param numPages the number of pages in this PDF file
131 | */
132 | loadComplete(numPages: number): void;
133 | }
134 |
135 | export class OnLoadCompleteListener implements IOnLoadCompleteListener {
136 | constructor(implementation: IOnLoadCompleteListener);
137 |
138 | /**
139 | * Called when the PDF is loaded
140 | * @param numPages the number of pages in this PDF file
141 | */
142 | loadComplete(numPages: number): void;
143 | }
144 | }
145 | }
146 | }
147 | }
148 | }
149 |
150 | import pdfviewer = com.github.barteksc.pdfviewer;
151 |
152 | declare class Configurator {
153 | load(): void;
154 | defaultPage(pageNumber: number): this;
155 | pages(...pageNumbers: number[]): this;
156 | enableAnnotationRendering(enable: boolean): this;
157 | enableDoubletap(enable: boolean): this;
158 | enableSwipe(enable: boolean): this;
159 | fitEachPage(enable: boolean): this;
160 | spacing(spacing: number): this;
161 | onLoad(
162 | onLoadCompleteListener: pdfviewer.listener.OnLoadCompleteListener
163 | ): this;
164 | autoSpacing(enable: boolean): this;
165 | swipeHorizontal(horizontal: boolean): this;
166 | }
167 |
--------------------------------------------------------------------------------
/demo/webpack.config.js:
--------------------------------------------------------------------------------
1 | const { join, relative, resolve, sep } = require("path");
2 |
3 | const webpack = require("webpack");
4 | const nsWebpack = require("nativescript-dev-webpack");
5 | const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
6 | const { getNoEmitOnErrorFromTSConfig } = require("nativescript-dev-webpack/utils/tsconfig-utils");
7 | const CleanWebpackPlugin = require("clean-webpack-plugin");
8 | const CopyWebpackPlugin = require("copy-webpack-plugin");
9 | const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
10 | const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
11 | const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
12 | const TerserPlugin = require("terser-webpack-plugin");
13 | const hashSalt = Date.now().toString();
14 |
15 | module.exports = env => {
16 | // Add your custom Activities, Services and other Android app components here.
17 | const appComponents = env.appComponents || [];
18 | appComponents.push(...[
19 | "tns-core-modules/ui/frame",
20 | "tns-core-modules/ui/frame/activity",
21 | ]);
22 |
23 | const platform = env && (env.android && "android" || env.ios && "ios" || env.platform);
24 | if (!platform) {
25 | throw new Error("You need to provide a target platform!");
26 | }
27 |
28 | const platforms = ["ios", "android"];
29 | const projectRoot = __dirname;
30 |
31 | if (env.platform) {
32 | platforms.push(env.platform);
33 | }
34 |
35 | // Default destination inside platforms//...
36 | const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
37 |
38 | const {
39 | // The 'appPath' and 'appResourcesPath' values are fetched from
40 | // the nsconfig.json configuration file.
41 | appPath = "app",
42 | appResourcesPath = "app/App_Resources",
43 |
44 | // You can provide the following flags when running 'tns run android|ios'
45 | snapshot, // --env.snapshot
46 | production, // --env.production
47 | uglify, // --env.uglify
48 | report, // --env.report
49 | sourceMap, // --env.sourceMap
50 | hiddenSourceMap, // --env.hiddenSourceMap
51 | hmr, // --env.hmr,
52 | unitTesting, // --env.unitTesting,
53 | verbose, // --env.verbose
54 | snapshotInDocker, // --env.snapshotInDocker
55 | skipSnapshotTools, // --env.skipSnapshotTools
56 | compileSnapshot // --env.compileSnapshot
57 | } = env;
58 |
59 | const useLibs = compileSnapshot;
60 | const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
61 | const externals = nsWebpack.getConvertedExternals(env.externals);
62 |
63 | const appFullPath = resolve(projectRoot, appPath);
64 | const hasRootLevelScopedModules = nsWebpack.hasRootLevelScopedModules({ projectDir: projectRoot });
65 | let coreModulesPackageName = "tns-core-modules";
66 | const alias = env.alias || {};
67 | alias['~'] = appFullPath;
68 |
69 | if (hasRootLevelScopedModules) {
70 | coreModulesPackageName = "@nativescript/core";
71 | alias["tns-core-modules"] = coreModulesPackageName;
72 | }
73 | const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
74 |
75 | const entryModule = nsWebpack.getEntryModule(appFullPath, platform);
76 | const entryPath = `.${sep}${entryModule}.ts`;
77 | const entries = env.entries || {};
78 | entries.bundle = entryPath;
79 |
80 | const tsConfigPath = resolve(projectRoot, "tsconfig.tns.json");
81 |
82 | const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("tns-core-modules") > -1);
83 | if (platform === "ios" && !areCoreModulesExternal) {
84 | entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules";
85 | };
86 |
87 | let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);
88 |
89 | const itemsToClean = [`${dist}/**/*`];
90 | if (platform === "android") {
91 | itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "src", "main", "assets", "snapshots")}`);
92 | itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`);
93 | }
94 |
95 | const noEmitOnErrorFromTSConfig = getNoEmitOnErrorFromTSConfig(tsConfigPath);
96 |
97 | nsWebpack.processAppComponents(appComponents, platform);
98 | const config = {
99 | mode: production ? "production" : "development",
100 | context: appFullPath,
101 | externals,
102 | watchOptions: {
103 | ignored: [
104 | appResourcesFullPath,
105 | // Don't watch hidden files
106 | "**/.*",
107 | ]
108 | },
109 | target: nativescriptTarget,
110 | entry: entries,
111 | output: {
112 | pathinfo: false,
113 | path: dist,
114 | sourceMapFilename,
115 | libraryTarget: "commonjs2",
116 | filename: "[name].js",
117 | globalObject: "global",
118 | hashSalt
119 | },
120 | resolve: {
121 | extensions: [".ts", ".js", ".scss", ".css"],
122 | // Resolve {N} system modules from tns-core-modules
123 | modules: [
124 | resolve(__dirname, `node_modules/${coreModulesPackageName}`),
125 | resolve(__dirname, "node_modules"),
126 | `node_modules/${coreModulesPackageName}`,
127 | "node_modules",
128 | ],
129 | alias,
130 | // resolve symlinks to symlinked modules
131 | symlinks: true
132 | },
133 | resolveLoader: {
134 | // don't resolve symlinks to symlinked loaders
135 | symlinks: false
136 | },
137 | node: {
138 | // Disable node shims that conflict with NativeScript
139 | "http": false,
140 | "timers": false,
141 | "setImmediate": false,
142 | "fs": "empty",
143 | "__dirname": false,
144 | },
145 | devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"),
146 | optimization: {
147 | runtimeChunk: "single",
148 | noEmitOnErrors: noEmitOnErrorFromTSConfig,
149 | splitChunks: {
150 | cacheGroups: {
151 | vendor: {
152 | name: "vendor",
153 | chunks: "all",
154 | test: (module, chunks) => {
155 | const moduleName = module.nameForCondition ? module.nameForCondition() : '';
156 | return /[\\/]node_modules[\\/]/.test(moduleName) ||
157 | appComponents.some(comp => comp === moduleName);
158 |
159 | },
160 | enforce: true,
161 | },
162 | }
163 | },
164 | minimize: !!uglify,
165 | minimizer: [
166 | new TerserPlugin({
167 | parallel: true,
168 | cache: true,
169 | sourceMap: isAnySourceMapEnabled,
170 | terserOptions: {
171 | output: {
172 | comments: false,
173 | semicolons: !isAnySourceMapEnabled
174 | },
175 | compress: {
176 | // The Android SBG has problems parsing the output
177 | // when these options are enabled
178 | 'collapse_vars': platform !== "android",
179 | sequences: platform !== "android",
180 | }
181 | }
182 | })
183 | ],
184 | },
185 | module: {
186 | rules: [
187 | {
188 | include: join(appFullPath, entryPath),
189 | use: [
190 | // Require all Android app components
191 | platform === "android" && {
192 | loader: "nativescript-dev-webpack/android-app-components-loader",
193 | options: { modules: appComponents }
194 | },
195 |
196 | {
197 | loader: "nativescript-dev-webpack/bundle-config-loader",
198 | options: {
199 | loadCss: !snapshot, // load the application css if in debug mode
200 | unitTesting,
201 | appFullPath,
202 | projectRoot,
203 | ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform)
204 | }
205 | },
206 | ].filter(loader => !!loader)
207 | },
208 |
209 | {
210 | test: /\.(ts|css|scss|html|xml)$/,
211 | use: "nativescript-dev-webpack/hmr/hot-loader"
212 | },
213 |
214 | { test: /\.(html|xml)$/, use: "nativescript-dev-webpack/xml-namespace-loader" },
215 |
216 | {
217 | test: /\.css$/,
218 | use: "nativescript-dev-webpack/css2json-loader"
219 | },
220 |
221 | {
222 | test: /\.scss$/,
223 | use: [
224 | "nativescript-dev-webpack/css2json-loader",
225 | "sass-loader"
226 | ]
227 | },
228 |
229 | {
230 | test: /\.ts$/,
231 | use: {
232 | loader: "ts-loader",
233 | options: {
234 | configFile: tsConfigPath,
235 | // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds
236 | // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#hot-module-replacement
237 | transpileOnly: true,
238 | allowTsInNodeModules: true,
239 | compilerOptions: {
240 | sourceMap: isAnySourceMapEnabled,
241 | declaration: false
242 | }
243 | },
244 | }
245 | },
246 | ]
247 | },
248 | plugins: [
249 | // Define useful constants like TNS_WEBPACK
250 | new webpack.DefinePlugin({
251 | "global.TNS_WEBPACK": "true",
252 | "process": "global.process",
253 | }),
254 | // Remove all files from the out dir.
255 | new CleanWebpackPlugin(itemsToClean, { verbose: !!verbose }),
256 | // Copy assets to out dir. Add your own globs as needed.
257 | new CopyWebpackPlugin([
258 | { from: { glob: "fonts/**" } },
259 | { from: { glob: "**/*.jpg" } },
260 | { from: { glob: "**/*.png" } },
261 | ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
262 | new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"),
263 | // For instructions on how to set up workers with webpack
264 | // check out https://github.com/nativescript/worker-loader
265 | new NativeScriptWorkerPlugin(),
266 | new nsWebpack.PlatformFSPlugin({
267 | platform,
268 | platforms,
269 | }),
270 | // Does IPC communication with the {N} CLI to notify events when running in watch mode.
271 | new nsWebpack.WatchStateLoggerPlugin(),
272 | // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds
273 | // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#hot-module-replacement
274 | new ForkTsCheckerWebpackPlugin({
275 | tsconfig: tsConfigPath,
276 | async: false,
277 | useTypescriptIncrementalApi: true,
278 | checkSyntacticErrors: true,
279 | memoryLimit: 4096
280 | })
281 | ],
282 | };
283 |
284 | if (report) {
285 | // Generate report files for bundles content
286 | config.plugins.push(new BundleAnalyzerPlugin({
287 | analyzerMode: "static",
288 | openAnalyzer: false,
289 | generateStatsFile: true,
290 | reportFilename: resolve(projectRoot, "report", `report.html`),
291 | statsFilename: resolve(projectRoot, "report", `stats.json`),
292 | }));
293 | }
294 |
295 | if (snapshot) {
296 | config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({
297 | chunk: "vendor",
298 | requireModules: [
299 | "tns-core-modules/bundle-entry-points",
300 | ],
301 | projectRoot,
302 | webpackConfig: config,
303 | snapshotInDocker,
304 | skipSnapshotTools,
305 | useLibs
306 | }));
307 | }
308 |
309 | if (hmr) {
310 | config.plugins.push(new webpack.HotModuleReplacementPlugin());
311 | }
312 |
313 |
314 | return config;
315 | };
316 |
--------------------------------------------------------------------------------