Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Nov 23, 2024
1 parent 57d1fbd commit cf3e066
Show file tree
Hide file tree
Showing 7 changed files with 3,397 additions and 3,556 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}
22 changes: 13 additions & 9 deletions lib/spec/filesaver.directive.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { ApplicationRef, Component, DebugElement, Injector } from '@angular/core';
import { By } from '@angular/platform-browser';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpHeaders } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { HttpHeaders, provideHttpClient } from '@angular/common/http';
import * as fs from 'file-saver';

import { FileSaverModule } from '../src/filesaver.module';
import { FileSaverDirective } from '../src/filesaver.directive';
import { FileSaverService } from '../src/filesaver.service';

function genFile(ext: string, isRealFile = true): Blob {
function genFile(_: string, isRealFile = true): Blob {
const blob = new Blob([
isRealFile ? `iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==` : '',
]);
Expand All @@ -25,8 +24,8 @@ describe('ngx-filesaver:', () => {

beforeEach(() => {
injector = TestBed.configureTestingModule({
imports: [HttpClientTestingModule, FileSaverModule],
declarations: [TestComponent],
providers: [provideHttpClient(), provideHttpClientTesting()],
imports: [TestComponent],
});

fixture = TestBed.createComponent(TestComponent);
Expand Down Expand Up @@ -143,8 +142,8 @@ describe('change detection', () => {

beforeEach(() => {
injector = TestBed.configureTestingModule({
imports: [HttpClientTestingModule, FileSaverModule],
declarations: [TestNoListenersComponent],
providers: [provideHttpClient(), provideHttpClientTesting()],
imports: [TestNoListenersComponent],
});

fixture = TestBed.createComponent(TestNoListenersComponent);
Expand All @@ -166,8 +165,8 @@ describe('change detection', () => {

@Component({
template: `
@for (i of fileTypes; track $index) {
<button
*ngFor="let i of fileTypes"
id="down-{{ i }}"
class="mr-sm"
fileSaver
Expand All @@ -180,7 +179,10 @@ describe('change detection', () => {
>
{{ i }}
</button>
}
`,
standalone: true,
imports: [FileSaverDirective],
})
class TestComponent {
fileTypes = ['xlsx', 'docx', 'pptx', 'pdf'];
Expand All @@ -199,6 +201,8 @@ class TestComponent {

@Component({
template: '<button id="down-xlsx" fileSaver query="data" method="get" url="/demo.xlsx" [fileName]="fileName">xlsx</button>',
standalone: true,
imports: [FileSaverDirective],
})
class TestNoListenersComponent {
fileName = 'demo中文';
Expand Down
1 change: 0 additions & 1 deletion lib/src/filesaver.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { FileSaverService } from './filesaver.service';
@Directive({
selector: '[fileSaver]',
exportAs: 'fileSaver',
standalone: true,
})
export class FileSaverDirective implements OnInit, OnDestroy {
@Input() method = 'GET';
Expand Down
46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,41 @@
"release:next": "npm run build && cd publish && npm publish --access public --tag next"
},
"dependencies": {
"@angular/animations": "^18.0.0",
"@angular/common": "^18.0.0",
"@angular/compiler": "^18.0.0",
"@angular/core": "^18.0.0",
"@angular/forms": "^18.0.0",
"@angular/platform-browser": "^18.0.0",
"@angular/platform-browser-dynamic": "^18.0.0",
"@angular/router": "^18.0.0",
"@angular/animations": "^19.0.0",
"@angular/common": "^19.0.0",
"@angular/compiler": "^19.0.0",
"@angular/core": "^19.0.0",
"@angular/forms": "^19.0.0",
"@angular/platform-browser": "^19.0.0",
"@angular/platform-browser-dynamic": "^19.0.0",
"@angular/router": "^19.0.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.3"
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^18.0.4",
"@angular-eslint/builder": "^18.0.0",
"@angular-eslint/eslint-plugin": "^18.0.0",
"@angular-eslint/eslint-plugin-template": "^18.0.0",
"@angular-eslint/schematics": "^18.0.0",
"@angular-eslint/template-parser": "^18.0.0",
"@angular/cli": "^18.0.4",
"@angular/compiler-cli": "^18.0.0",
"@types/file-saver": "^2.0.5",
"@angular-devkit/build-angular": "^19.0.1",
"@angular-eslint/builder": "^18.4.1",
"@angular-eslint/eslint-plugin": "^18.4.1",
"@angular-eslint/eslint-plugin-template": "^18.4.1",
"@angular-eslint/schematics": "^18.4.1",
"@angular-eslint/template-parser": "^18.4.1",
"@angular/cli": "^19.0.1",
"@angular/compiler-cli": "^19.0.0",
"@types/file-saver": "^2.0.7",
"@types/jasmine": "~5.1.0",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.13.0",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"eslint": "^8.53.0",
"file-saver": "^2.0.5",
"jasmine-core": "~5.1.0",
"jasmine-core": "~5.4.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"ng-packagr": "^18.0.0",
"typescript": "~5.4.2"
"ng-packagr": "^19.0.1",
"typescript": "~5.6.2"
},
"packageManager": "[email protected]"
}
3 changes: 1 addition & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ import { FileSaverDirective, FileSaverService } from 'ngx-filesaver';
<button type="button" fileSaver url="assets/files/demo.docx">Save Word</button>
`,
encapsulation: ViewEncapsulation.None,
standalone: true,
imports: [CommonModule, FormsModule, FileSaverDirective],
imports: [CommonModule, FormsModule, FileSaverDirective],
})
export class AppComponent {
text = `{ "text": "This is text file!中文" }`;
Expand Down
32 changes: 16 additions & 16 deletions src/index.html

Large diffs are not rendered by default.

Loading

0 comments on commit cf3e066

Please sign in to comment.