Skip to content

Commit

Permalink
fix(abc:pdf): fix ignore dependency pdfjs-dist (#1641)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Aug 28, 2023
1 parent 26023ca commit b987bab
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 13 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
"xlsx": "^0.18.5",
"jszip": "^3.10.1",
"plyr": "^3.7.8",
"pdfjs-dist": "~3.6.172",
"screenfull": "^6.0.2",
"less-bundle-promise": "^1.0.11",
"ng-alain-codelyzer": "^0.0.1",
Expand Down
1 change: 0 additions & 1 deletion packages/abc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"jszip": "@LIB-PLACEHOLDER",
"xlsx": "@LIB-PLACEHOLDER",
"plyr": "@LIB-PLACEHOLDER",
"pdfjs-dist": "@LIB-PLACEHOLDER",
"@github/hotkey": "@LIB-PLACEHOLDER",
"ngx-countdown": "@LIB-PLACEHOLDER",
"@delon/theme": "PEER-0.0.0-PLACEHOLDER",
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/pdf/demo/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class DemoComponent implements OnInit {
};

loadOutline(): void {
this.comp.pdf?.getOutline().then(outline => {
this.comp.pdf?.getOutline().then((outline: NzSafeAny) => {
this.outlineList = outline;
});
}
Expand Down
4 changes: 4 additions & 0 deletions packages/abc/pdf/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ pdf.js libary is lazy loading by default,you can change the default root CDN p
**Use local path**

```bash
yarn add pdfjs-dist
```

```json
// angular.json
{
Expand Down
4 changes: 4 additions & 0 deletions packages/abc/pdf/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ module: import { PdfModule } from '@delon/abc/pdf';
**使用本地路径**

```bash
yarn add pdfjs-dist
```

```json
// angular.json
{
Expand Down
22 changes: 16 additions & 6 deletions packages/abc/pdf/pdf.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import {
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { fromEvent, timer, debounceTime, filter } from 'rxjs';

import type { PDFDocumentLoadingTask, PDFDocumentProxy } from 'pdfjs-dist';
import type { EventBus } from 'pdfjs-dist/types/web/event_utils';
import type { PDFFindController } from 'pdfjs-dist/types/web/pdf_find_controller';
import type { PDFLinkService } from 'pdfjs-dist/types/web/pdf_link_service';
import type { PDFViewer } from 'pdfjs-dist/types/web/pdf_viewer';
// import type { PDFDocumentLoadingTask, PDFDocumentProxy } from 'pdfjs-dist';
// import type { EventBus } from 'pdfjs-dist/types/web/event_utils';
// import type { PDFFindController } from 'pdfjs-dist/types/web/pdf_find_controller';
// import type { PDFLinkService } from 'pdfjs-dist/types/web/pdf_link_service';
// import type { PDFViewer } from 'pdfjs-dist/types/web/pdf_viewer';

import { AlainConfigService } from '@delon/util/config';
import { BooleanInput, InputBoolean, InputNumber, NumberInput, ZoneOutside } from '@delon/util/decorator';
Expand All @@ -36,6 +36,16 @@ import type { NzSafeAny } from 'ng-zorro-antd/core/types';
import { PDF_DEFULAT_CONFIG } from './pdf.config';
import { PdfChangeEvent, PdfChangeEventType, PdfExternalLinkTarget, PdfTextLayerMode, PdfZoomScale } from './pdf.types';

// TODO: Although pdfjs-dist is an optional dependency on canvas
// will be installed automatically when the dependency is installed by default;
// This requires a higher environment and often fails to install
type PDFDocumentLoadingTask = NzSafeAny;
type PDFDocumentProxy = NzSafeAny;
type EventBus = NzSafeAny;
type PDFFindController = NzSafeAny;
type PDFLinkService = NzSafeAny;
type PDFViewer = NzSafeAny;

const CSS_UNITS: number = 96.0 / 72.0;
const BORDER_WIDTH = 9;

Expand Down Expand Up @@ -325,7 +335,7 @@ export class PdfComponent implements OnChanges, AfterViewInit, OnDestroy {
const currentViewer = this.pageViewer;
if (!currentViewer) return;

this._pdf!.getPage(currentViewer.currentPageNumber).then(page => {
this._pdf!.getPage(currentViewer.currentPageNumber).then((page: NzSafeAny) => {
const { _rotation, _zoom } = this;
const rotation = _rotation || page.rotate;
const viewportWidth =
Expand Down
4 changes: 3 additions & 1 deletion packages/abc/pdf/pdf.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { PDFDocumentProxy } from 'pdfjs-dist';
// import type { PDFDocumentProxy } from 'pdfjs-dist';

import type { NzSafeAny } from 'ng-zorro-antd/core/types';

type PDFDocumentProxy = NzSafeAny;

export type PdfChangeEventType =
| 'loaded'
| 'load-progress'
Expand Down
2 changes: 2 additions & 0 deletions scripts/site/route-paths.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
/components/auto-focus/zh
/components/avatar-list/en
/components/avatar-list/zh
/components/cell/en
/components/cell/zh
/components/count-down/en
/components/count-down/zh
/components/date-picker/en
Expand Down
6 changes: 3 additions & 3 deletions src/app/global-config.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const alainConfig: AlainConfig = {
qr: {
lib: '/assets/qrious/qrious.min.js'
},
pdf: {
lib: '/assets/pdfjs/'
},
// pdf: {
// lib: '/assets/pdfjs/'
// },
media: {
urls: ['assets/plyr/plyr.min.js', 'assets/plyr/plyr.css'],
options: {
Expand Down

0 comments on commit b987bab

Please sign in to comment.