Fixed conversions that depend on pure JS modules

That is:
- quoted printable
- punycode
- (utf8), dependency of quoted printable
This commit is contained in:
Manuel Friedli 2017-03-14 23:36:39 +01:00
parent 710b703a8f
commit 1386babee5
11 changed files with 50 additions and 50 deletions

View File

@ -19,14 +19,14 @@
"url": "https://gittr.ch/manuel/dencode.org.git" "url": "https://gittr.ch/manuel/dencode.org.git"
}, },
"dependencies": { "dependencies": {
"@angular/common": "~2.4.0", "@angular/common": "^2.4.0",
"@angular/compiler": "~2.4.0", "@angular/compiler": "^2.4.0",
"@angular/core": "~2.4.0", "@angular/core": "^2.4.0",
"@angular/forms": "~2.4.0", "@angular/forms": "^2.4.0",
"@angular/platform-browser": "~2.4.0", "@angular/platform-browser": "^2.4.0",
"@angular/platform-browser-dynamic": "~2.4.0", "@angular/platform-browser-dynamic": "^2.4.0",
"core-js": "^2.4.1", "core-js": "^2.4.1",
"rxjs": "5.0.1", "rxjs": "^5.0.1",
"zone.js": "^0.7.4", "zone.js": "^0.7.4",
"bootstrap": "^3.3.0", "bootstrap": "^3.3.0",
"quoted-printable": "^1.0.0", "quoted-printable": "^1.0.0",
@ -53,9 +53,9 @@
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
"rimraf": "^2.5.2", "rimraf": "^2.5.2",
"style-loader": "^0.13.1", "style-loader": "^0.13.1",
"typescript": "~2.0.10", "typescript": "^2.0.10",
"webpack": "2.2.1", "webpack": "^2.2.1",
"webpack-dev-server": "2.4.1", "webpack-dev-server": "^2.4.1",
"webpack-merge": "^3.0.0" "webpack-merge": "^3.0.0"
}, },
"scripts": { "scripts": {

View File

@ -15,7 +15,6 @@ export class PunycodeDecoder implements Converter {
} }
convert(input: string): string { convert(input: string): string {
// return this.nativeLibraryWrapperService.punycode.decode(input); return this.nativeLibraryWrapperService.punycode.decode(input);
return "";
} }
} }

View File

@ -15,7 +15,6 @@ export class PunycodeEncoder implements Converter {
} }
convert(input: string): string { convert(input: string): string {
// return this.nativeLibraryWrapperService.punycode.encode(input); return this.nativeLibraryWrapperService.punycode.encode(input);
return "";
} }
} }

View File

@ -14,10 +14,10 @@ export class QuotedPrintableDecoder implements Converter {
} }
convert(input:string):string { convert(input:string):string {
// try { try {
// return this.nativeLibraryWrapperService.utf8.decode(this.nativeLibraryWrapperService.quotedPrintable.decode(input)); return this.nativeLibraryWrapperService.utf8.decode(this.nativeLibraryWrapperService.quotedPrintable.decode(input));
// } catch (error) { } catch (error) {
throw new Error("The input can not be interpreted as quoted-printable. May be corrupt?"); throw new Error("The input can not be interpreted as quoted-printable. May be corrupt?");
// } }
} }
} }

View File

@ -14,7 +14,6 @@ export class QuotedPrintableEncoder implements Converter {
} }
convert(input:string):string { convert(input:string):string {
// return this.nativeLibraryWrapperService.quotedPrintable.encode(this.nativeLibraryWrapperService.utf8.encode(input)); return this.nativeLibraryWrapperService.quotedPrintable.encode(this.nativeLibraryWrapperService.utf8.encode(input));
return "";
} }
} }

View File

@ -12,11 +12,11 @@ import {DecToHexConverter} from "./converter/dectohexconverter";
import {HexToDecConverter} from "./converter/hextodecconverter"; import {HexToDecConverter} from "./converter/hextodecconverter";
import {DecToBinConverter} from "./converter/dectobinconverter"; import {DecToBinConverter} from "./converter/dectobinconverter";
import {BinToDecConverter} from "./converter/bintodecconverter"; import {BinToDecConverter} from "./converter/bintodecconverter";
// import {QuotedPrintableDecoder} from "./converter/quotedprintabledecoder"; import {QuotedPrintableDecoder} from "./converter/quotedprintabledecoder";
// import {QuotedPrintableEncoder} from "./converter/quotedprintableencoder"; import {QuotedPrintableEncoder} from "./converter/quotedprintableencoder";
import {NativeLibraryWrapperService} from "./nativelibrarywrapper.service"; import {NativeLibraryWrapperService} from "./nativelibrarywrapper.service";
// import {PunycodeEncoder} from "./converter/punycodeencoder"; import {PunycodeEncoder} from "./converter/punycodeencoder";
// import {PunycodeDecoder} from "./converter/punycodedecoder"; import {PunycodeDecoder} from "./converter/punycodedecoder";
@Injectable() @Injectable()
export class ConverterRegistryService { export class ConverterRegistryService {
@ -48,14 +48,14 @@ export class ConverterRegistryService {
this.registerConverter(new URIComponentDecoder()); this.registerConverter(new URIComponentDecoder());
this.registerConverter(new HTMLEntitiesEncoder()); this.registerConverter(new HTMLEntitiesEncoder());
this.registerConverter(new HTMLEntitiesDecoder()); this.registerConverter(new HTMLEntitiesDecoder());
// this.registerConverter(new QuotedPrintableEncoder(this.wrapper)); this.registerConverter(new QuotedPrintableEncoder(this.wrapper));
// this.registerConverter(new QuotedPrintableDecoder(this.wrapper)); this.registerConverter(new QuotedPrintableDecoder(this.wrapper));
this.registerConverter(new DecToHexConverter()); this.registerConverter(new DecToHexConverter());
this.registerConverter(new HexToDecConverter()); this.registerConverter(new HexToDecConverter());
this.registerConverter(new DecToBinConverter()); this.registerConverter(new DecToBinConverter());
this.registerConverter(new BinToDecConverter()); this.registerConverter(new BinToDecConverter());
// this.registerConverter(new PunycodeEncoder(this.wrapper)); this.registerConverter(new PunycodeEncoder(this.wrapper));
// this.registerConverter(new PunycodeDecoder(this.wrapper)); this.registerConverter(new PunycodeDecoder(this.wrapper));
} }
private registerConverter(converter:Converter):void { private registerConverter(converter:Converter):void {

View File

@ -1,18 +1,17 @@
import {Injectable} from "@angular/core"; import {Injectable} from "@angular/core";
import {Punycode} from "./punycode";
declare var utf8:any; import {Utf8} from "./utf8";
declare var quotedPrintable:any; import {QuotedPrintable} from "./quotedprintable";
declare var punycode:any;
@Injectable() @Injectable()
export class NativeLibraryWrapperService { export class NativeLibraryWrapperService {
// public utf8:any; public utf8:Utf8;
// public quotedPrintable:any; public quotedPrintable:QuotedPrintable;
// public punycode:any; public punycode:Punycode;
constructor() { constructor() {
// this.utf8 = utf8; this.utf8 = require("utf8");
// this.quotedPrintable = quotedPrintable; this.quotedPrintable = require("quoted-printable");
// this.punycode = punycode; this.punycode = require("punycode");
} }
} }

4
src/app/punycode.ts Normal file
View File

@ -0,0 +1,4 @@
export interface Punycode {
encode(input:string):string;
decode(input:string):string;
}

View File

@ -0,0 +1,4 @@
export interface QuotedPrintable {
encode(input:string):string;
decode(input:string):string;
}

4
src/app/utf8.ts Normal file
View File

@ -0,0 +1,4 @@
export interface Utf8 {
encode(input:any):string;
decode(input:string):any;
}

View File

@ -1,13 +1,5 @@
import {Component, Injectable, NgModule, OnInit} from "@angular/core"; import "@angular/core";
import {BrowserModule} from "@angular/platform-browser"; import "@angular/platform-browser";
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic"; import "@angular/platform-browser-dynamic";
import {FormsModule} from "@angular/forms"; import "@angular/forms";
import "rxjs"; import "rxjs";
import "utf8";
import "quoted-printable";
import "punycode";
require("utf8");
require("quoted-printable");
require("punycode");