@finanzritter/nativescript-pdf-view
Advanced tools
Comparing version 2.1.3 to 3.0.0
@@ -1,7 +0,8 @@ | ||
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" /> | ||
/// <reference path="./node_modules/@nativescript/types-android/lib/android-29.d.ts" | ||
declare module com.github.barteksc.pdfviewer { | ||
export class PDFView extends android.view.SurfaceView { | ||
export class PDFView { | ||
fromFile(file: java.io.File): Configurator; | ||
fromUri(uri: android.net.Uri): Configurator; | ||
public constructor(param0: globalAndroid.content.Context, param1: globalAndroid.util.AttributeSet); | ||
} | ||
@@ -48,4 +49,4 @@ | ||
): this; | ||
autoSpacing(enable: boolean): this; | ||
autoSpacing(enable: boolean): this; | ||
swipeHorizontal(horizontal: boolean): this; | ||
} |
{ | ||
"name": "@finanzritter/nativescript-pdf-view", | ||
"version": "2.1.3", | ||
"version": "3.0.0", | ||
"description": "A basic PDF viewer plugin for NativeScript, to display PDF documents on iOS and Android.", | ||
@@ -9,4 +9,4 @@ "main": "pdf-view", | ||
"platforms": { | ||
"android": "3.0.0", | ||
"ios": "3.0.0" | ||
"android": "7.0.0", | ||
"ios": "7.0.0" | ||
} | ||
@@ -61,10 +61,12 @@ }, | ||
"devDependencies": { | ||
"husky": "^0.13.3", | ||
"@nativescript/android": "7.0.1", | ||
"@nativescript/core": "^7.0.0", | ||
"@nativescript/types": "^7.0.0", | ||
"husky": "^4.3.0", | ||
"prompt": "~1.0.0", | ||
"rimraf": "3.0.0", | ||
"tns-core-modules": "~3.0.0", | ||
"tns-platform-declarations": "^3.0.1", | ||
"tslint": "^5.2.0", | ||
"typescript": "~2.3.2" | ||
} | ||
"tslint": "^6.1.3", | ||
"typescript": "^3.9.7" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -1,2 +0,2 @@ | ||
/// <reference path="AndroidPdfViewer.d.ts" /> | ||
/// <reference types="AndroidPdfViewer" /> | ||
import pdfviewer = com.github.barteksc.pdfviewer; | ||
@@ -8,6 +8,7 @@ import { PDFViewCommon } from './pdf-view.common'; | ||
private onLoadHandler; | ||
android: pdfviewer.PDFView; | ||
get android(): pdfviewer.PDFView; | ||
set android(value: pdfviewer.PDFView); | ||
createNativeView(): pdfviewer.PDFView; | ||
loadPDF(src: string): void; | ||
private cacheThenLoad(url); | ||
private cacheThenLoad; | ||
} |
@@ -1,39 +0,30 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var pdfviewer = com.github.barteksc.pdfviewer; | ||
var fs = require("tns-core-modules/file-system"); | ||
var http = require("tns-core-modules/http"); | ||
var pdf_view_common_1 = require("./pdf-view.common"); | ||
var PDFView = (function (_super) { | ||
__extends(PDFView, _super); | ||
function PDFView() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.tempFolder = fs.knownFolders.temp().getFolder('PDFViewer.temp/'); | ||
_this.onLoadHandler = (function () { | ||
var pdfViewRef = new WeakRef(_this); | ||
import { Http, knownFolders } from '@nativescript/core'; | ||
import { PDFViewCommon, srcProperty } from './pdf-view.common'; | ||
export class PDFView extends PDFViewCommon { | ||
constructor() { | ||
super(...arguments); | ||
this.tempFolder = knownFolders.temp().getFolder('PDFViewer.temp/'); | ||
this.onLoadHandler = (() => { | ||
const pdfViewRef = new WeakRef(this); | ||
return new pdfviewer.listener.OnLoadCompleteListener({ | ||
loadComplete: function (numPages) { | ||
pdf_view_common_1.PDFViewCommon.notifyOfEvent(pdf_view_common_1.PDFViewCommon.loadEvent, pdfViewRef); | ||
loadComplete: numPages => { | ||
PDFViewCommon.notifyOfEvent(PDFViewCommon.loadEvent, pdfViewRef); | ||
}, | ||
}); | ||
})(); | ||
return _this; | ||
} | ||
Object.defineProperty(PDFView.prototype, "android", { | ||
get: function () { | ||
return this.nativeView; | ||
}, | ||
set: function (value) { | ||
this.nativeView = value; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
PDFView.prototype.createNativeView = function () { | ||
get android() { | ||
return this.nativeView; | ||
} | ||
set android(value) { | ||
this.nativeView = value; | ||
} | ||
createNativeView() { | ||
return new pdfviewer.PDFView(this._context, void 0); | ||
}; | ||
PDFView.prototype[pdf_view_common_1.srcProperty.setNative] = function (value) { | ||
} | ||
[srcProperty.setNative](value) { | ||
this.loadPDF(value); | ||
}; | ||
PDFView.prototype.loadPDF = function (src) { | ||
} | ||
loadPDF(src) { | ||
if (!src || !this.android) { | ||
@@ -50,4 +41,4 @@ return; | ||
} | ||
var uri = android.net.Uri.parse(src); | ||
var defaultSpacingDP = 8; | ||
const uri = android.net.Uri.parse(src); | ||
const defaultSpacingDP = 8; | ||
this.android | ||
@@ -60,20 +51,17 @@ .fromUri(uri) | ||
.load(); | ||
}; | ||
PDFView.prototype.cacheThenLoad = function (url) { | ||
var _this = this; | ||
this.tempFolder.clear().then(function () { | ||
var promise = _this.promise = http | ||
.getFile(url, _this.tempFolder.path + "/" + Date.now() + ".pdf") | ||
.then(function (file) { | ||
if (_this.promise === promise) { | ||
_this.loadPDF(file.path); | ||
} | ||
cacheThenLoad(url) { | ||
this.tempFolder.clear().then(() => { | ||
const promise = this.promise = Http | ||
.getFile(url, `${this.tempFolder.path}/${Date.now()}.pdf`) | ||
.then(file => { | ||
if (this.promise === promise) { | ||
this.loadPDF(file.path); | ||
} | ||
}).catch(function (error) { | ||
}).catch(error => { | ||
console.error(error); | ||
}); | ||
}); | ||
}; | ||
return PDFView; | ||
}(pdf_view_common_1.PDFViewCommon)); | ||
exports.PDFView = PDFView; | ||
} | ||
} | ||
//# sourceMappingURL=pdf-view.android.js.map |
@@ -1,2 +0,2 @@ | ||
import { Property, View } from 'tns-core-modules/ui/core/view'; | ||
import { Property, View } from '@nativescript/core'; | ||
export declare abstract class PDFViewCommon extends View { | ||
@@ -3,0 +3,0 @@ static loadEvent: string; |
@@ -1,28 +0,20 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var view_1 = require("tns-core-modules/ui/core/view"); | ||
var PDFViewCommon = (function (_super) { | ||
__extends(PDFViewCommon, _super); | ||
function PDFViewCommon() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
PDFViewCommon.notifyOfEvent = function (eventName, pdfViewRef) { | ||
var viewer = pdfViewRef.get(); | ||
import { Property, View } from '@nativescript/core'; | ||
export class PDFViewCommon extends View { | ||
static notifyOfEvent(eventName, pdfViewRef) { | ||
const viewer = pdfViewRef.get(); | ||
if (viewer) { | ||
viewer.notify({ eventName: eventName, object: viewer }); | ||
viewer.notify({ eventName, object: viewer }); | ||
} | ||
}; | ||
return PDFViewCommon; | ||
}(view_1.View)); | ||
} | ||
} | ||
PDFViewCommon.loadEvent = 'load'; | ||
exports.PDFViewCommon = PDFViewCommon; | ||
exports.enableAnnotationRenderingProperty = new view_1.Property({ | ||
export const enableAnnotationRenderingProperty = new Property({ | ||
defaultValue: false, | ||
name: 'enableAnnotationRendering', | ||
}); | ||
exports.enableAnnotationRenderingProperty.register(PDFViewCommon); | ||
exports.srcProperty = new view_1.Property({ | ||
enableAnnotationRenderingProperty.register(PDFViewCommon); | ||
export const srcProperty = new Property({ | ||
name: 'src', | ||
}); | ||
exports.srcProperty.register(PDFViewCommon); | ||
srcProperty.register(PDFViewCommon); | ||
//# sourceMappingURL=pdf-view.common.js.map |
@@ -5,8 +5,9 @@ import { PDFViewCommon } from './pdf-view.common'; | ||
constructor(); | ||
ios: WKWebView; | ||
get ios(): WKWebView; | ||
set ios(value: WKWebView); | ||
onLoaded(): void; | ||
onUnloaded(): void; | ||
loadPDF(src: string): void; | ||
private init(); | ||
private readonly mainScreen; | ||
private init; | ||
private get mainScreen(); | ||
} |
@@ -1,53 +0,44 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var pdf_view_common_1 = require("./pdf-view.common"); | ||
var PDFViewDelegate = (function (_super) { | ||
__extends(PDFViewDelegate, _super); | ||
function PDFViewDelegate() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
PDFViewDelegate.initWithOwner = function (owner) { | ||
var delegate = PDFViewDelegate.new(); | ||
var PDFViewDelegate_1; | ||
import { PDFViewCommon, srcProperty } from './pdf-view.common'; | ||
let PDFViewDelegate = PDFViewDelegate_1 = class PDFViewDelegate extends NSObject { | ||
static initWithOwner(owner) { | ||
const delegate = PDFViewDelegate_1.new(); | ||
delegate.owner = owner; | ||
return delegate; | ||
}; | ||
PDFViewDelegate.prototype.webViewDidFinishNavigation = function (webView) { | ||
pdf_view_common_1.PDFViewCommon.notifyOfEvent(pdf_view_common_1.PDFViewCommon.loadEvent, this.owner); | ||
}; | ||
return PDFViewDelegate; | ||
}(NSObject)); | ||
} | ||
webViewDidFinishNavigation(webView) { | ||
PDFViewCommon.notifyOfEvent(PDFViewCommon.loadEvent, this.owner); | ||
} | ||
}; | ||
PDFViewDelegate.ObjCProtocols = [WKNavigationDelegate]; | ||
var PDFView = (function (_super) { | ||
__extends(PDFView, _super); | ||
function PDFView() { | ||
var _this = _super.call(this) || this; | ||
_this.init(); | ||
return _this; | ||
PDFViewDelegate = PDFViewDelegate_1 = __decorate([ | ||
NativeClass() | ||
], PDFViewDelegate); | ||
export class PDFView extends PDFViewCommon { | ||
constructor() { | ||
super(); | ||
this.init(); | ||
} | ||
Object.defineProperty(PDFView.prototype, "ios", { | ||
get: function () { | ||
return this.nativeView; | ||
}, | ||
set: function (value) { | ||
this.nativeView = value; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
PDFView.prototype[pdf_view_common_1.srcProperty.setNative] = function (value) { | ||
get ios() { | ||
return this.nativeView; | ||
} | ||
set ios(value) { | ||
this.nativeView = value; | ||
} | ||
[srcProperty.setNative](value) { | ||
this.loadPDF(value); | ||
}; | ||
PDFView.prototype.onLoaded = function () { | ||
_super.prototype.onLoaded.call(this); | ||
} | ||
onLoaded() { | ||
super.onLoaded(); | ||
this.ios.navigationDelegate = this.delegate; | ||
}; | ||
PDFView.prototype.onUnloaded = function () { | ||
} | ||
onUnloaded() { | ||
this.ios.navigationDelegate = void 0; | ||
_super.prototype.onUnloaded.call(this); | ||
}; | ||
PDFView.prototype.loadPDF = function (src) { | ||
super.onUnloaded(); | ||
} | ||
loadPDF(src) { | ||
if (!src) { | ||
return; | ||
} | ||
var url; | ||
let url; | ||
if (src.indexOf('://') === -1) { | ||
@@ -59,7 +50,7 @@ url = NSURL.fileURLWithPath(src); | ||
url = NSURL.URLWithString(src); | ||
var urlRequest = NSURLRequest.requestWithURL(url); | ||
const urlRequest = NSURLRequest.requestWithURL(url); | ||
this.ios.loadRequest(urlRequest); | ||
} | ||
}; | ||
PDFView.prototype.init = function () { | ||
} | ||
init() { | ||
this.delegate = PDFViewDelegate.initWithOwner(new WeakRef(this)); | ||
@@ -74,15 +65,7 @@ this.ios = new WKWebView({ | ||
16; | ||
}; | ||
Object.defineProperty(PDFView.prototype, "mainScreen", { | ||
get: function () { | ||
return typeof UIScreen.mainScreen === 'function' ? | ||
UIScreen.mainScreen() : | ||
UIScreen.mainScreen; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return PDFView; | ||
}(pdf_view_common_1.PDFViewCommon)); | ||
exports.PDFView = PDFView; | ||
} | ||
get mainScreen() { | ||
return UIScreen.mainScreen; | ||
} | ||
} | ||
//# sourceMappingURL=pdf-view.ios.js.map |
@@ -24,3 +24,3 @@ # NativeScript PDFView | ||
``` | ||
tns plugin add nativescript-pdf-view | ||
tns plugin add @finanzritter/nativescript-pdf-view | ||
``` | ||
@@ -35,3 +35,3 @@ | ||
xmlns="http://schemas.nativescript.org/tns.xsd" | ||
xmlns:pdf="nativescript-pdf-view" | ||
xmlns:pdf="@finanzritter/nativescript-pdf-view" | ||
loaded="pageLoaded"> | ||
@@ -45,3 +45,3 @@ <pdf:PDFView src="{{ pdfUrl }}" load="{{ onLoad }}" /> | ||
```ts | ||
import { PDFView } from 'nativescript-pdf-view'; | ||
import { PDFView } from '@finanzritter/nativescript-pdf-view'; | ||
import { registerElement } from 'nativescript-angular'; | ||
@@ -48,0 +48,0 @@ registerElement('PDFView', () => PDFView); |
@@ -1,2 +0,1 @@ | ||
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" /> | ||
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" /> | ||
/// <reference path="./node_modules/@nativescript/types/index.d.ts" /> |
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs", | ||
"declaration": true, | ||
"removeComments": true, | ||
"noLib": false, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"lib": [ | ||
"es6", | ||
"dom" | ||
], | ||
"baseUrl": ".", | ||
"paths": { | ||
"*": [ | ||
"./node_modules/tns-core-modules/*", | ||
"./node_modules/*" | ||
] | ||
}, | ||
"sourceMap": true, | ||
"pretty": true, | ||
"allowUnreachableCode": false, | ||
"allowUnusedLabels": false, | ||
"noEmitHelpers": true, | ||
"noEmitOnError": false, | ||
"noImplicitAny": false, | ||
"noImplicitReturns": true, | ||
"noImplicitUseStrict": false, | ||
"noFallthroughCasesInSwitch": true, | ||
"typeRoots": [ | ||
"./node_modules/@types", | ||
"./node_modules" | ||
], | ||
"types": [ | ||
] | ||
"compilerOptions": { | ||
"target": "es2017", | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"declaration": true, | ||
"removeComments": true, | ||
"noLib": false, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"skipLibCheck": true, | ||
"lib": ["es2017", "dom", "es6"], | ||
"baseUrl": ".", | ||
"paths": { | ||
"*": [ | ||
"./node_modules/@nativescript/core/*", | ||
"./node_modules/*" | ||
] | ||
}, | ||
"exclude": [ | ||
"demo", | ||
"node_modules" | ||
"sourceMap": true, | ||
"pretty": true, | ||
"allowUnreachableCode": false, | ||
"allowUnusedLabels": false, | ||
"noEmitHelpers": true, | ||
"noEmitOnError": true, | ||
"noImplicitAny": false, | ||
"noImplicitReturns": true, | ||
"noImplicitUseStrict": false, | ||
"noFallthroughCasesInSwitch": true, | ||
"typeRoots": [ | ||
"./node_modules/@types", | ||
"./node_modules" | ||
], | ||
"compileOnSave": false | ||
"types": [ | ||
], | ||
"plugins": [ | ||
{ | ||
"transform": "@nativescript/webpack/transformers/ns-transform-native-classes", | ||
"type": "raw" | ||
} | ||
] | ||
}, | ||
"exclude": [ | ||
"demo", | ||
"node_modules" | ||
], | ||
"exclude": ["node_modules", "platforms", "typings"], | ||
"compileOnSave": false | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15304
8
291
1