From 6967071816a259ac54f561afc705eb1158f4f5cb Mon Sep 17 00:00:00 2001 From: Kazi Manzur Rashid Date: Fri, 5 Apr 2013 09:22:58 +0600 Subject: [PATCH 1/5] Included Mocha definition. --- mocha/mocha.d.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 mocha/mocha.d.ts diff --git a/mocha/mocha.d.ts b/mocha/mocha.d.ts new file mode 100644 index 0000000000..55b20cecc8 --- /dev/null +++ b/mocha/mocha.d.ts @@ -0,0 +1,24 @@ +declare var describe : { + (description: string, spec: () => void): void; + only(description: string, spec: () => void): void; + skip(description: string, spec: () => void): void; + timeout(ms: number); +} + +declare var it: { + (expectation: string, assertion?: () => void): void; + (expectation: string, assertion?: (done: () => void) => void): void; + only(expectation: string, assertion?: () => void): void; + only(expectation: string, assertion?: (done: () => void) => void): void; + skip(expectation: string, assertion?: () => void): void; + skip(expectation: string, assertion?: (done: () => void) => void): void; + timeout(ms: number); +}; + +declare function beforeEach(action: () => void): void; + +declare function beforeEach(action: (done: () => void) => void): void; + +declare function afterEach(action: () => void): void; + +declare function afterEach(action: (done: () => void) => void): void; \ No newline at end of file From 886e87bc14dfb94ba3f519366adb5f36f24d1696 Mon Sep 17 00:00:00 2001 From: Roman Nikitin Date: Fri, 5 Apr 2013 15:13:28 +0700 Subject: [PATCH 2/5] added definitions for durandal/widget module. --- durandal/durandal.d.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts index 0a07086f73..a99c2f226c 100644 --- a/durandal/durandal.d.ts +++ b/durandal/durandal.d.ts @@ -441,6 +441,32 @@ declare module "durandal/plugins/router" { export var activate: (defaultRoute: string) => JQueryPromise; } +declare module "durandal/widget" { + /** + * Use this function to create a widget through code. The element should reference a dom element that the widget will be created on. The settings can be either a string or an object. If it's a string, it should specify the widget kind. If it's an object, it represents settings that will be passed along to the widget. This object should have a kind property used to identify the widget kind to create. Optionally, you can specify a bindingContext of which you want the widget's binding context to be created as a child. + */ + export function create(element: any, settings: any, bindingContext?: any); + /** + * By default, you can create widgets in html by using the widget binding extension. Calling registerKind allows you to easily create a custom binding handler for your widget kind. Without calling registerKind you might declare a widget binding for an expander control with + */ + export function registerKind(kind: string); + /** + * Use this to re-map a widget kind identifier to a new viewId or moduleId representing the 'skin' and 'behavior' respectively. + */ + export function mapKind(kind: string, viewId?: string, moduleId?: string); + /** + * Developers implementing widgets may wish to use this function to acquire the resolved template parts for a widget. Pass a single dom element or an array of elements and get back an object keyed by part name whose values are the dom elements corresponding to each part in that scope. + */ + export function getParts(elements: any): any; + /** + * (overrridable) Replace this to re-interpret the kind id as a module path. By default it does a lookup for any custom maps added through mapKind and then falls back to the path "durandal/widgets/{kind}/controller". + */ + export function convertKindToModuleId(kind): string; + /** + * (overridable) Replace this to re-interpret the kind id as a view id. The default does a lookup for any custom maps added through mapKind and then falls back to the path "durandal/widgets/{kind}/view". + */ + export function convertKindToViewId(kind): string; +} interface IEventSubscription { From c365fcd0357679ade2d7403f13631fcd1e78a09c Mon Sep 17 00:00:00 2001 From: Mathis Zeiher Date: Fri, 5 Apr 2013 11:02:02 +0200 Subject: [PATCH 3/5] Added definitions for JSZip library --- jszip/jszip-test.ts | 132 ++++++++++++++++++++++++++++++++ jszip/jszip.d.ts | 183 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 315 insertions(+) create mode 100644 jszip/jszip-test.ts create mode 100644 jszip/jszip.d.ts diff --git a/jszip/jszip-test.ts b/jszip/jszip-test.ts new file mode 100644 index 0000000000..9222cbb5bc --- /dev/null +++ b/jszip/jszip-test.ts @@ -0,0 +1,132 @@ +/// +/// + +var SEVERITY = { + DEBUG: 0, + INFO: 1, + WARN: 2, + ERROR: 3, + FATAL: 4 +} + +function testJSZip() { + + var newJszip = new JSZip(); + + newJszip.file("test.txt", "test string"); + newJszip.file("test/test.txt", "test string"); + + var serializedZip = newJszip.generate({compression: "DEFLATE", type:"base64"}); + + newJszip = new JSZip(); + newJszip.load(serializedZip, {base64: true, checkCRC32: true}); + + if(newJszip.file("test.txt").data === "test string") { + log(SEVERITY.INFO, "all ok"); + } else { + log(SEVERITY.ERROR, "no matching file found"); + } + if(newJszip.file("test/test.txt").data === "test string") { + log(SEVERITY.INFO, "all ok"); + } else { + log(SEVERITY.ERROR, "no matching file found"); + } + + var folder = newJszip.folder("test"); + if(folder.file("test.txt").data == "test string") { + log(SEVERITY.INFO, "all ok"); + } + else { + log(SEVERITY.ERROR, "wrong file"); + } + + var folders = newJszip.folder(new RegExp("^test")); + + if(folders.length == 1) { + log(SEVERITY.INFO, "all ok"); + if(folders[0].options.dir == true) { + log(SEVERITY.INFO, "all ok"); + } + else { + log(SEVERITY.ERROR, "wrong file"); + } + } else { + log(SEVERITY.ERROR, "wrong number of folder"); + } + + var files = newJszip.file(new RegExp("^test")); + if(files.length == 2) { + log(SEVERITY.INFO, "all ok"); + if(files[0].data == "test string" && files[1].data == "test string") { + log(SEVERITY.INFO, "all ok"); + } + else { + log(SEVERITY.ERROR, "wrong data in files"); + } + } + else { + log(SEVERITY.ERROR, "wrong number of files"); + } + + var filterFiles = newJszip.filter((relativePath: string, file: jszip.JSZipFile) => { + if(file.data == "test string") { + return true; + } + return false; + }); + + if(filterFiles.length == 2) { + log(SEVERITY.INFO, "all ok"); + } + else { + log(SEVERITY.ERROR, "wrong number of files"); + } + + newJszip.remove("test/test.txt"); + + filterFiles = newJszip.filter((relativePath: string, file: jszip.JSZipFile) => { + if(file.data == "test string") { + return true; + } + return false; + }); + + if(filterFiles.length == 1) { + log(SEVERITY.INFO, "all ok"); + } + else { + log(SEVERITY.ERROR, "wrong number of files"); + } + + log(SEVERITY.INFO, newJszip.crc32("Test")); + log(SEVERITY.INFO, newJszip.utf8encode("Test")); + log(SEVERITY.INFO, newJszip.utf8decode("Test")); + newJszip.clone(); +} + +function log(severity:number, message: any) { + var log = ""; + switch(severity) { + case 0: + log += "[DEBUG] "; + break; + case 1: + log += "[INFO] "; + break; + case 2: + log += "[WARN] "; + break; + case 3: + log += "[ERROR] "; + break; + case 4: + log += "[FATAL] "; + break; + default: + log += "[INFO]" + break; + } + console.log(log += message); +} + +testJSZip(); \ No newline at end of file diff --git a/jszip/jszip.d.ts b/jszip/jszip.d.ts new file mode 100644 index 0000000000..af6c58329c --- /dev/null +++ b/jszip/jszip.d.ts @@ -0,0 +1,183 @@ +// Type definitions for JSZip +// Project: http://stuk.github.com/jszip/ +// Definitions by: mzeiher +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +module jszip { + export interface JSZip { + /** + * Get a file from the archive + * + * @param path {string} relative path to file + * + * @return {JSZipFile} file matching path, null if no file found + */ + file(path: string): JSZipFile; + + /** + * Get files matching a RegExp from archive + * + * @param path {RegExp} RegExp to match + * + * @return {JSZipFile[]} return all matching files or an empty array + */ + file(path: RegExp): JSZipFile[]; + + /** + * Add a file to the archive + * + * @param path {string} relative path to file + * @param content {any} content of the file + * @param options {JSZipOptions} optional information about the file + * + * @return {JSZip} JSZip object + */ + file(path: string, content: any, options?: JSZipOptions): JSZip; + + /** + * Return an new JSZip instance with the given folder as root + * + * @param name {string} name of the folder + * + * @return {JSZip} new JSZip object with the given folder as root or null + */ + folder(name: string): JSZip; + + /** + * Returns new JSZip instances with the matching folders as root + * + * @param name {RegExp} RegExp to match + * + * @return {JSZipFile[]} new array of JSZipFile objects which match the RegExp + */ + folder(name: RegExp): JSZipFile[]; + + /** + * Removes the file or folder from the archive + * + * @param path {string} relative path of file or folder + * + * @return {JSZip} returns the JSZip instance + */ + remove(path: string): JSZip; + + /** + * Generates a new archive + * + * @param options {JSZipGeneratorOptions} optional options for the generator + * + * @return {any} the serialized archive + */ + generate(options?: JSZipGeneratorOptions): any; + + /** + * Deserialize zip file + * + * @param data {any} serialized zip file + * @param options {JSZipOptions} options for deserializing + * + * @return {JSZip} returns the JSZip instance + */ + load(data: any, options: JSZipOptions): JSZip; + + /** + * Get all files wchich match the given filter function + * + * @param {function} filter function + * + * @return {JSZipFile[]} array of matched elements + */ + filter(predicate: (relativePath: string, file: JSZipFile) => bool): JSZipFile[]; + + /** + * Calculate crc32 of given string + * + * @param data {string} string to calculate crc32 from + * @param crc {number} optional: initializer for crc calc + * + * @return {number} calculated crc32 number + */ + crc32(data: string, crc?: number): number; + + /** + * Clone JSSZip instance + * + * return {JSZip} cloned instsance + */ + clone(): JSZip; + + /** + * UTF8 encode a string + * + * @param data {string} string to encode + */ + utf8encode(data: string): string; + + /** + * UTF8 decode a string + * + * @param data {string} string to decode + */ + utf8decode(data: string): string; + + } + + export interface JSZipSupport { + arraybuffer: bool; + uint8array: bool; + blob: bool; + } + + export interface JSZipGeneratorOptions { + base64?: bool; //deprecated + compression: string; //DEFLATE or STORE + type: string; //base64 (default), string, uint8array, blob + } + + export interface JSZipOptions { + base64: bool; + checkCRC32: bool; + } + + export interface JSZipFile { + name: string; + data: any; + options: JSZipFileOptions; + + asText(): string; + asBinary(): any; + asArrayBuffer(): ArrayBuffer; + asUint8Array(): Uint8Array; + } + + export interface JSZipFileOptions { + base64: bool; + binary: bool; + dir: bool; + date: Date; + } + + export interface JSZipBase64 { + } +} + +declare var JSZip: { + /** + * Create JSZip instance + * If no parameters given an empty zip archive will be created + * + * @param data {any} serialized zip archive + * @param options {JSZipOptions} description of the serialized zip archive + */ + new(data?: any, options?: jszip.JSZipOptions): jszip.JSZip; + + prototype: jszip.JSZip; + support : jszip.JSZipSupport; +} + +declare var JSZipBase64: { + encode(input: string, utf8?: any): string; + decode(input: string, utf8?: any): string; + + prototype: jszip.JSZipBase64; +} \ No newline at end of file From 3309e1aa4b8c4cb11b33e9e4facfc8a49a635521 Mon Sep 17 00:00:00 2001 From: Diullei Gomes Date: Fri, 5 Apr 2013 08:59:10 -0300 Subject: [PATCH 4/5] durandal: Fixed introduced bug at pull/451 --- durandal/durandal.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts index a99c2f226c..f2dcdc3298 100644 --- a/durandal/durandal.d.ts +++ b/durandal/durandal.d.ts @@ -423,7 +423,7 @@ declare module "durandal/plugins/router" { /** * Works the same as mapRoute except that routes are automatically added to the visibleRoutes array. */ - export var mapNav: (url: string, moduleId: string, name: string) => routeInfo; + export var mapNav: (url: string, moduleId?: string, name?: string) => routeInfo; /** * You can pass a single routeInfo to this function, or you can pass the basic configuration parameters. url is your url pattern, moduleId is the module path this pattern will map to, name is used as the document title and visible determines whether or not to include it in the router's visibleRoutes array for easy navigation UI binding. */ From 970725912a361ecbee36edd0a8dec7d11eef1e22 Mon Sep 17 00:00:00 2001 From: Mathis Zeiher Date: Fri, 5 Apr 2013 14:24:42 +0200 Subject: [PATCH 5/5] renamed tests --- jszip/{jszip-test.ts => jszip-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jszip/{jszip-test.ts => jszip-tests.ts} (100%) diff --git a/jszip/jszip-test.ts b/jszip/jszip-tests.ts similarity index 100% rename from jszip/jszip-test.ts rename to jszip/jszip-tests.ts