From d71aeb3dd8d30b7b415212846246da9a1479173b Mon Sep 17 00:00:00 2001 From: Jed Hunsaker Date: Sat, 16 Feb 2013 00:21:48 -0800 Subject: [PATCH 1/5] Add PhantomJS --- README.md | 9 +++++---- phantomjs/phantomjs.d.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 phantomjs/phantomjs.d.ts diff --git a/README.md b/README.md index 235369690d..85aaa1d1d7 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ List of Definitions * [node_redis](https://github.com/mranney/node_redis) (by [Boris Yankov](https://github.com/borisyankov)) * [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov)) * [Numeral.js](https://github.com/adamwdraper/Numeral-js) (by [Vincent Bortone](https://github.com/vbortone/)) +* [PhantomJS](http://phantomjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker)) * [PhoneGap](http://phonegap.com) (by [Boris Yankov](https://github.com/borisyankov)) * [Platform](https://github.com/bestiejs/platform.js) (by [Jake Hickman](https://github.com/JakeH)) * [PouchDB](http://pouchdb.com) (by [Bill Sears](https://github.com/MrBigDog2U/)) @@ -138,17 +139,17 @@ List of Definitions * [WebRTC](http://dev.w3.org/2011/webrtc/editor/webrtc.html) (by [Ken Smith](https://github.com/smithkl42)) * [YouTube](https://developers.google.com/youtube/) (by [Daz Wilkin](https://github.com/DazWilkin/)) * [Zynga Scroller](https://github.com/zynga/scroller) (by [Boris Yankov](https://github.com/borisyankov)) -* [ZeroClipboard] (https://github.com/jonrohan/ZeroClipboard) (by [Eric J. Smith] (https://github.com/ejsmith)) +* [ZeroClipboard](https://github.com/jonrohan/ZeroClipboard) (by [Eric J. Smith](https://github.com/ejsmith)) Requested Definitions --------------------- * [Rickshaw](https://github.com/shutterstock/rickshaw) -* [Livestamp.js] (https://github.com/mattbradley/livestampjs) -* [jQuery ScrollTo] (https://github.com/balupton/jquery-scrollto) +* [Livestamp.js](https://github.com/mattbradley/livestampjs) +* [jQuery ScrollTo](https://github.com/balupton/jquery-scrollto) * [Crossfilter](https://github.com/square/crossfilter) * [dc.js](https://github.com/NickQiZhu/dc.js) * [google.visualizations](https://developers.google.com/chart/) * [Tags Manager](http://welldonethings.com/tags/manager) * [Prelude.ls](http://gkz.github.com/prelude-ls/) * [MooTools](http://mootools.net/) -* [Lo-Dash](http://lodash.com/) +* [Lo-Dash](http://lodash.com/) diff --git a/phantomjs/phantomjs.d.ts b/phantomjs/phantomjs.d.ts new file mode 100644 index 0000000000..7ebfe91cf1 --- /dev/null +++ b/phantomjs/phantomjs.d.ts @@ -0,0 +1,26 @@ +/************************************************ +* * +* PlantomJS v1.8.0 API * +* * +************************************************/ + +interface PhantomJSStatic { + + // Properties + args: string[]; // DEPRECATED + cookies: any; + cookiesEnabled: bool; + libraryPath: string; + scriptName: string; // DEPRECATED + version: any; + + // Functions + addCookie(cookie: any): bool; + clearCookies(); + deleteCookie(cookieName: string): bool; + exit(returnValue: any): bool; + injectJs(filename: string): bool; + + // Callbacks + onError: Function; +} From ca0565d727b1055ba1844ec8386a8af3196b725e Mon Sep 17 00:00:00 2001 From: Jed Hunsaker Date: Sat, 16 Feb 2013 01:46:18 -0800 Subject: [PATCH 2/5] Add CasperJS, Refactor PhantomJS --- README.md | 1 + casperjs/casperjs.d.ts | 220 +++++++++++++++++++++++++++++++++++++++ phantomjs/phantomjs.d.ts | 17 +-- 3 files changed, 232 insertions(+), 6 deletions(-) create mode 100644 casperjs/casperjs.d.ts diff --git a/README.md b/README.md index 85aaa1d1d7..6ed05f3bc5 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ List of Definitions * [bootstrap.datepicker](https://github.com/eternicode/bootstrap-datepicker) (by [Boris Yankov](https://github.com/borisyankov)) * [Box2DWeb](http://code.google.com/p/box2dweb/) (by [Josh Baldwin](https://github.com/jbaldwin/)) * [Breeze](http://www.breezejs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [CasperJS](http://casperjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker)) * [Cheerio](https://github.com/MatthewMueller/cheerio) (by [Bret Little](https://github.com/blittle)) * [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov)) * [Chrome](http://developer.chrome.com/extensions/) (by [Matthew Kimber](https://github.com/matthewkimber)) diff --git a/casperjs/casperjs.d.ts b/casperjs/casperjs.d.ts new file mode 100644 index 0000000000..3acf054644 --- /dev/null +++ b/casperjs/casperjs.d.ts @@ -0,0 +1,220 @@ +/************************************************ +* * +* CasperJS v1.0.0 API * +* http://casperjs.org/api.html * +* * +************************************************/ + +/// + +interface Casper { + + constructor (options: CasperOptions); + + // Properties + __utils__: ClientUtils; + + // Methods + back(); + base64encode(url: string, method?: string, data?: any); + click(selector: string); + clickLabel(label: string, tag?: string); + capture(targetFilePath: string, clipRect: ClipRect); + captureBase64(format: string); + captureBase64(format: string, area: string); + captureBase64(format: string, area: ClipRect); + captureBase64(format: string, area: any); + captureSelector(targetFile: string, selector: string); + clear(); + debugHTML(selector?: string, outer?: bool); + debugPage(); + die(message: string, status?: number); + download(url: string, target?: string, method?: string, data?: any); + each(array: Array, fn: Function); + echo(message: string, style?: string); + evaluate(fn: Function, ...args: any[]); + evaluateOrDie(fn: Function, message?: string); + exit(status?: number); + exists(selector: string); + fetchText(selector: string); + forward(); + log(message: string, level?: string, space?: string); + fill(selector: string, values: any, submit?: bool); + getCurrentUrl(); + getElementAttribute(selector: string, attribute: string); + getElementBounds(selector: string); + getElementsBounds(selector: string); + getElementInfo(selector: string); + getFormValues(selector: string); + getGlobal(name: string); + getHTML(selector?: string, outer?: bool); + getPageContent(); + getTitle(); + mouseEvent(type: string, selector: string); + open(location: string, settings: any); + reload(then?: Function); + repeat(times: number, then: Function); + resourceExists(test: Function); + resourceExists(test: string); + run(onComplete: Function, time?: number); + sendKeys(selector: string, keys: string, options?: any); + setHttpAuth(username: string, password: string); + start(url: string, then?: Function); + status(asString: bool); + then(fn: Function); + thenClick(selector: string); + thenEvaluate(fn: Function, ...args: any[]); + thenOpen(location: string, then?: Function); + thenOpen(location: string, options?: any, then?: Function); + thenOpenAndEvaluate(location: string, then?: Function, ...args: any[]); + toString(); + userAgent(agent: string); + viewport(width: number, height: number); + visible(selector: string); + wait(timeout: number, then?: Function); + waitFor(testFx: Function, then?: Function, onTimeout?: Function, timeout?: number); + waitForPopup(urlPattern: string, then?: Function, onTimeout?: Function, timeout?: number); + waitForPopup(urlPattern: RegExp, then?: Function, onTimeout?: Function, timeout?: number); + waitForSelector(selector: string, then?: Function, onTimeout?: Function, timeout?: number); + waitWhileSelector(selector: string, then?: Function, onTimeout?: Function, timeout?: number); + waitForResource(testFx: Function, then?: Function, onTimeout?: Function, timeout?: number); + waitForText(pattern: string, then?: Function, onTimeout?: Function, timeout?: number); + waitForText(pattern: RegExp, then?: Function, onTimeout?: Function, timeout?: number); + waitUntilVisible(selector: string, then?: Function, onTimeout?: Function, timeout?: number); + waitWhileVisible(selector: string, then?: Function, onTimeout?: Function, timeout?: number); + warn(message: string); + withFrame(frameInfo: string, then: Function); + withFrame(frameInfo: number, then: Function); + withPopup(popupInfo: string, step: Function); + withPopup(popupInfo: RegExp, step: Function); + zoom(factor: number); +} + +interface CasperOptions { + clientScripts: Array; + exitOnError: bool; + httpStatusHandlers: any; + logLevel: string; + onAlert: Function; + onDie: Function; + onError: Function; + onLoadError: Function; + onPageInitialized: Function; + onResourceReceived: Function; + onResourceRequested: Function; + onStepComplete: Function; + onStepTimeout: Function; + onTimeout: Function; + onWaitTimeout: Function; + page: WebPage; + pageSettings: any; + remoteScripts: Array; + safeLogs: bool; + stepTimeout: number; + timeout: number; + verbose: bool; + viewportSize: any; + waitTimeout: number; +} + +interface ClientUtils { + echo(message: string); + encode(contents: string); + exists(selector: string); + findAll(selector: string); + findOne(selector: string); + getBase64(url: string, method?: string, data?: any); + getBinary(url: string, method?: string, data?: any); + getDocumentHeight(); + getElementBounds(selector: string); + getElementsBounds(selector: string); + getElementByXPath(expression: string, scope?: HTMLElement); + getElementsByXPath(expression: string, scope?: HTMLElement); + getFieldValue(inputName: string); + getFormValues(selector: string); + mouseEvent(type: string, selector: string); + removeElementsByXPath(expression: string); + sendAJAX(url: string, method?: string, data?: any, async?: bool); + visible(selector: string); +} + +interface ClipRect { + top: number; + left: number; + width: number; + height: number; +} + +interface Colorizer { + colorize(text: string, styleName: string); + format(text: string, style: any); +} + +interface Tester { + assert(condition: bool, message?: string); + assertDoesntExist(selector: string, message?: string); + assertEquals(testValue: any, expected: any, message?: string); + assertEval(fn: Function, message: string, arguments: any); + assertEvalEquals(fn: Function, expected: any, message?: string, arguments?: any); + assertExists(selector: string, message?: string); + assertFalsy(subject: any, message?: string); + assertField(inputName: string, expected: string, message?: string); + assertHttpStatus(status: number, message?: string); + assertMatch(subject: any, pattern: RegExp, message?: string); + assertNot(subject: any, message?: string); + assertNotEquals(testValue: any, expected: any, message?: string); + assertNotVisible(selector: string, message?: string); + assertRaises(fn: Function, args: Array, message?: string); + assertSelectorDoesntHaveText(selector: string, text: string, message?: string); + assertSelectorExists(selector: string, message?: string); + assertSelectorHasText(selector: string, text: string, message?: string); + assertResourceExists(testFx: Function, message?: string); + assertTextExists(expected: string, message?: string); + assertTextDoesntExist(unexpected: string, message: string); + assertTitle(expected: string, message?: string); + assertTitleMatch(pattern: RegExp, message?: string); + assertTruthy(subject: any, message?: string); + assertType(input: any, type: string, message?: string); + assertUrlMatch(pattern: RegExp, message?: string); + assertVisible(selector: string, message?: string); + colorize(message: string, style: string); + comment(message: string); + done(expected?: number); + error(message: string); + fail(message: string); + formatMessage(message: string, style: string); + getFailures(); + getPasses(); + info(message: string); + pass(message: string); + renderResults(exit: bool, status: number, save: string); +} + +interface Utils { + betterTypeOf(input: any); + dump(value: any); + fileExt(file: string); + fillBlanks(text: string, pad: number); + format(f: string, ...args: any[]); + getPropertyPath(obj: any, path: string); + inherits(ctor: any, superCtor: any); + isArray(value: any); + isCasperObject(value: any); + isClipRect(value: any); + isFalsy(subject: any); + isFunction(value: any); + isJsFile(file: string); + isNull(value: any); + isNumber(value: any); + isObject(value: any); + isRegExp(value: any); + isString(value: any); + isTruthy(subject: any); + isType(what: any, type: string); + isUndefined(value: any); + isWebPage(what: any); + mergeObjects(origin: any, add: any); + node(name: string, attributes: any); + serialize(value: any); + unique(array: Array); +} diff --git a/phantomjs/phantomjs.d.ts b/phantomjs/phantomjs.d.ts index 7ebfe91cf1..c31ad40eb6 100644 --- a/phantomjs/phantomjs.d.ts +++ b/phantomjs/phantomjs.d.ts @@ -1,10 +1,11 @@ -/************************************************ -* * -* PlantomJS v1.8.0 API * -* * -************************************************/ +/********************************************************** +* * +* PlantomJS v1.8.0 API * +* https://github.com/ariya/phantomjs/wiki/API-Reference * +* * +**********************************************************/ -interface PhantomJSStatic { +interface Phantom { // Properties args: string[]; // DEPRECATED @@ -24,3 +25,7 @@ interface PhantomJSStatic { // Callbacks onError: Function; } + +interface WebPage { + +} From ad54ebff92123b7ae04f1b262401bb1aac895e6c Mon Sep 17 00:00:00 2001 From: Jed Hunsaker Date: Sat, 16 Feb 2013 02:17:15 -0800 Subject: [PATCH 3/5] Add WebPage, Etc --- casperjs/casperjs.d.ts | 7 -- phantomjs/phantomjs.d.ts | 153 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 150 insertions(+), 10 deletions(-) diff --git a/casperjs/casperjs.d.ts b/casperjs/casperjs.d.ts index 3acf054644..644a58bb6b 100644 --- a/casperjs/casperjs.d.ts +++ b/casperjs/casperjs.d.ts @@ -138,13 +138,6 @@ interface ClientUtils { visible(selector: string); } -interface ClipRect { - top: number; - left: number; - width: number; - height: number; -} - interface Colorizer { colorize(text: string, styleName: string); format(text: string, style: any); diff --git a/phantomjs/phantomjs.d.ts b/phantomjs/phantomjs.d.ts index c31ad40eb6..6342284789 100644 --- a/phantomjs/phantomjs.d.ts +++ b/phantomjs/phantomjs.d.ts @@ -9,14 +9,14 @@ interface Phantom { // Properties args: string[]; // DEPRECATED - cookies: any; + cookies: Cookie[]; cookiesEnabled: bool; libraryPath: string; scriptName: string; // DEPRECATED version: any; - // Functions - addCookie(cookie: any): bool; + // Methods + addCookie(cookie: Cookie): bool; clearCookies(); deleteCookie(cookieName: string): bool; exit(returnValue: any): bool; @@ -26,6 +26,153 @@ interface Phantom { onError: Function; } +interface System { + pid: number; + platform: string; + os: OS; + env: any; + args: string[]; +} + +interface OS { + architecture: string; + name: string; + version: string; +} + interface WebPage { + // Properties + canGoBack: bool; + canGoForward: bool; + clipRect: ClipRect; + content: string; + cookies: Cookie[]; + customHeaders: any; + event; + focusedFrameName: string; + frameContent: string; + frameName: string; + framePlainText: string; + frameTitle: string; + frameUrl: string; + framesCount: number; + framesName; + libraryPath: string; + navigationLocked: bool; + offlineStoragePath: string; + offlineStorageQuota: number; + ownsPages: bool; + pages; + pagesWindowName: string; + paperSize: any; + plainText: string; + scrollPosition: TopLeft; + settings: WebPageSettings; + title: string; + url: string; + viewportSize: Size; + windowName: string; + zoomFactor: number; + + // Methods + addCookie(cookie: Cookie): bool; + childFramesCount(): number; // DEPRECATED + childFramesName(): string; // DEPRECATED + clearCookies(); + close(); + currentFrameName(): string; // DEPRECATED + deleteCookie(cookieName: string): bool; + evaluate(fn: Function, ...args: any[]): any; + evaluateAsync(fn: Function); + evaluateJavascript(str: string); + getPage(windowName: string); + go(index: number); + goBack(); + goForward(); + includeJs(url: string, callback: Function); + injectJs(filename: string): bool; + open(url: string, callback: Function); + openUrl(url: string, httpConf: any, settings: any); + release(); // DEPRECATED + reload(); + render(filename: string); + renderBase64(format: any): string; + sendEvent(mouseEventType: string, mouseX?: number, mouseY?: number, button?: string); + sendEvent(keyboardEventType: string, keyOrKeys, aNull?, bNull?, modifier?); + setContent(content: string, url: string); + stop(); + switchToFocusedFrame(); + switchToFrame(frameName: string); + switchToFrame(framePosition); + switchToChildFrame(frameName: string); + switchToChildFrame(framePosition); + switchToMainFrame(); // DEPRECATED + switchToParentFrame(); // DEPRECATED + uploadFile(selector: string, filename: string); + + // Callbacks + onAlert: Function; + onCallback: Function; // EXPERIMENTAL + onClosing: Function; + onConfirm: Function; + onConsoleMessage: Function; + onError: Function; + onFilePicker: Function; + onInitialized: Function; + onLoadFinished: Function; + onLoadStarted: Function; + onNavigationRequested: Function; + onPageCreated: Function; + onPrompt: Function; + onResourceRequested: Function; + onResourceReceived: Function; + onUrlChanged: Function; + + // Callback triggers + closing(page); + initialized(); + javaScriptAlertSent(message: string); + javaScriptConsoleMessageSent(message: string); + loadFinished(status); + loadStarted(); + navigationRequested(url: string, navigationType, navigationLocked, isMainFrame: bool); + rawPageCreated(page); + resourceReceived(request); + resourceRequested(resource); + urlChanged(url: string); +} + +interface WebPageSettings { + javascriptEnabled: bool; + loadImages: bool; + localToRemoteUrlAccessEnabled: bool; + userAgent: string; + password: string; + XSSAuditingEnabled: bool; + webSecurityEnabled: bool; +} + +interface TopLeft { + top: number; + left: number; +} + +interface Size { + width: number; + height: number; +} + +interface ClipRect extends TopLeft, Size { + width: number; + height: number; +} + +interface NameValuePair { + name: string; + value: any; +} + +interface Cookie extends NameValuePair { + value: string; } From 33e627ba3179c2afdb513555cf94e946b3de6a5a Mon Sep 17 00:00:00 2001 From: Jed Hunsaker Date: Sat, 16 Feb 2013 10:57:30 -0800 Subject: [PATCH 4/5] Handle Callbacks, Return Values --- casperjs/casperjs.d.ts | 96 ++++++++++++++++++++++++++++++-------- phantomjs/phantomjs.d.ts | 99 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 166 insertions(+), 29 deletions(-) diff --git a/casperjs/casperjs.d.ts b/casperjs/casperjs.d.ts index 644a58bb6b..e097a681ea 100644 --- a/casperjs/casperjs.d.ts +++ b/casperjs/casperjs.d.ts @@ -30,7 +30,7 @@ interface Casper { debugPage(); die(message: string, status?: number); download(url: string, target?: string, method?: string, data?: any); - each(array: Array, fn: Function); + each(array: Array, fn: (self, link) => void); echo(message: string, style?: string); evaluate(fn: Function, ...args: any[]); evaluateOrDie(fn: Function, message?: string); @@ -40,32 +40,32 @@ interface Casper { forward(); log(message: string, level?: string, space?: string); fill(selector: string, values: any, submit?: bool); - getCurrentUrl(); - getElementAttribute(selector: string, attribute: string); - getElementBounds(selector: string); - getElementsBounds(selector: string); - getElementInfo(selector: string); - getFormValues(selector: string); - getGlobal(name: string); - getHTML(selector?: string, outer?: bool); - getPageContent(); - getTitle(); + getCurrentUrl(): string; + getElementAttribute(selector: string, attribute: string): string; + getElementBounds(selector: string): ElementBounds; + getElementsBounds(selector: string): ElementBounds[]; + getElementInfo(selector: string): ElementInfo; + getFormValues(selector: string): any; + getGlobal(name: string): any; + getHTML(selector?: string, outer?: bool): string; + getPageContent(): string; + getTitle(): string; mouseEvent(type: string, selector: string); - open(location: string, settings: any); - reload(then?: Function); + open(location: string, settings: OpenSettings): Casper; + reload(then?: (response: HttpResponse) => void); repeat(times: number, then: Function); resourceExists(test: Function); resourceExists(test: string); run(onComplete: Function, time?: number); sendKeys(selector: string, keys: string, options?: any); setHttpAuth(username: string, password: string); - start(url: string, then?: Function); - status(asString: bool); - then(fn: Function); + start(url: string, then?: (response: HttpResponse) => void): Casper; + status(asString: bool): any; + then(fn: (self?: Casper) => void); thenClick(selector: string); thenEvaluate(fn: Function, ...args: any[]); - thenOpen(location: string, then?: Function); - thenOpen(location: string, options?: any, then?: Function); + thenOpen(location: string, then?: (response: HttpResponse) => void); + thenOpen(location: string, options?: OpenSettings, then?: (response: HttpResponse) => void); thenOpenAndEvaluate(location: string, then?: Function, ...args: any[]); toString(); userAgent(agent: string); @@ -90,6 +90,44 @@ interface Casper { zoom(factor: number); } +interface HttpResponse { + contentType: string; + headers: any[]; + id: number; + redirectURL: string; + stage: string; + status: number; + statusText: string; + time: string; + url: string; +} + +interface OpenSettings { + method: string; + data: any; + headers: any; +} + +interface ElementBounds { + top: number; + left: number; + width: number; + height: number; +} + +interface ElementInfo { + nodeName: string; + attributes: any; + tag: string; + html: string; + text: string; + x: number; + y: number; + width: number; + height: number; + visible: bool; +} + interface CasperOptions { clientScripts: Array; exitOnError: bool; @@ -176,13 +214,31 @@ interface Tester { error(message: string); fail(message: string); formatMessage(message: string, style: string); - getFailures(); - getPasses(); + getFailures(): Cases; + getPasses(): Cases; info(message: string); pass(message: string); renderResults(exit: bool, status: number, save: string); } +interface Cases { + length: number; + cases: Case[]; +} + +interface Case { + success: bool; + type: string; + standard: string; + file: string; + values: CaseValues; +} + +interface CaseValues { + subject: bool; + expected: bool; +} + interface Utils { betterTypeOf(input: any); dump(value: any); diff --git a/phantomjs/phantomjs.d.ts b/phantomjs/phantomjs.d.ts index 6342284789..3d851d422c 100644 --- a/phantomjs/phantomjs.d.ts +++ b/phantomjs/phantomjs.d.ts @@ -15,7 +15,7 @@ interface Phantom { scriptName: string; // DEPRECATED version: any; - // Methods + // Functions addCookie(cookie: Cookie): bool; clearCookies(); deleteCookie(cookieName: string): bool; @@ -65,7 +65,7 @@ interface WebPage { ownsPages: bool; pages; pagesWindowName: string; - paperSize: any; + paperSize: PaperSize; plainText: string; scrollPosition: TopLeft; settings: WebPageSettings; @@ -75,7 +75,7 @@ interface WebPage { windowName: string; zoomFactor: number; - // Methods + // Functions addCookie(cookie: Cookie): bool; childFramesCount(): number; // DEPRECATED childFramesName(): string; // DEPRECATED @@ -92,7 +92,7 @@ interface WebPage { goForward(); includeJs(url: string, callback: Function); injectJs(filename: string): bool; - open(url: string, callback: Function); + open(url: string, callback: (status: string) => void); openUrl(url: string, httpConf: any, settings: any); release(); // DEPRECATED reload(); @@ -143,6 +143,14 @@ interface WebPage { urlChanged(url: string); } +interface PaperSize { + width: string; + height: string; + border: string; + format: string; + orientation: string; +} + interface WebPageSettings { javascriptEnabled: bool; loadImages: bool; @@ -153,6 +161,83 @@ interface WebPageSettings { webSecurityEnabled: bool; } +interface FileSystem { + + // Properties + separator: string; + workingDirectory: string; + + // Functions + + // Query Functions + list(path: string): string[]; + absolute(path: string): string; + exists(path: string): bool; + isDirectory(path: string): bool; + isFile(path: string): bool; + isAbsolute(path: string): bool; + isExecutable(path: string): bool; + isReadable(path: string): bool; + isWritable(path: string): bool; + isLink(path: string): bool; + readLink(path: string): string; + + // Directory Functions + changeWorkingDirectory(path: string); + makeDirectory(path: string); + makeTree(path: string); + removeDirectory(path: string); + removeTree(path: string); + copyTree(source: string, destination: string); + + // File Functions + open(path: string, mode: string): Stream; + read(path: string): string; + write(path: string, content: string, mode: string); + size(path: string): number; + remove(path: string); + copy(source: string, destination: string); + move(source: string, destination: string); + touch(path: string); +} + +interface Stream { + read(): string; + readLine(): string; + write(data: string); + writeLine(data: string); + flush(); + close(); +} + +interface WebServer { + port: number; + listen(port: number, cb?:(request, response) => void): bool; + listen(ipAddressPort: string, cb?:(request, response) => void): bool; + close(); +} + +interface Request { + method: string; + url: string; + httpVersion: number; + headers: any; + post: string; + postRaw: string; +} + +interface Response { + headers: any; + setHeader(name: string, value: string); + header(name: string): string; + statusCode: number; + setEncoding(encoding: string); + write(data: string); + writeHead(statusCode: number, headers?: any); + close(); + closeGracefully(); +} + interface TopLeft { top: number; left: number; @@ -168,11 +253,7 @@ interface ClipRect extends TopLeft, Size { height: number; } -interface NameValuePair { +interface Cookie { name: string; - value: any; -} - -interface Cookie extends NameValuePair { value: string; } From ec69c8517926028741fe27990ebe81ec8c8695e3 Mon Sep 17 00:00:00 2001 From: Jed Hunsaker Date: Sat, 16 Feb 2013 11:44:22 -0800 Subject: [PATCH 5/5] start url is optional, despite documentation --- casperjs/casperjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/casperjs/casperjs.d.ts b/casperjs/casperjs.d.ts index e097a681ea..9bf4485a5f 100644 --- a/casperjs/casperjs.d.ts +++ b/casperjs/casperjs.d.ts @@ -59,7 +59,7 @@ interface Casper { run(onComplete: Function, time?: number); sendKeys(selector: string, keys: string, options?: any); setHttpAuth(username: string, password: string); - start(url: string, then?: (response: HttpResponse) => void): Casper; + start(url?: string, then?: (response: HttpResponse) => void): Casper; status(asString: bool): any; then(fn: (self?: Casper) => void); thenClick(selector: string);