From 127b4308fd6e0efcb7ec70d78e7a425ccb794011 Mon Sep 17 00:00:00 2001 From: wdamien Date: Mon, 25 Feb 2013 12:03:22 -0700 Subject: [PATCH 1/5] Updates to match the latest version of CreateJS (EaseJS v0.6, PreloadJS v0.3, SoundJS v0.4, and TweenJS v0.4). Also fixed the easeljs-tests.ts so it compiles correctly. --- easeljs/easeljs-tests.ts | 32 ++++++---- easeljs/easeljs.d.ts | 116 +++++++++++++++++++++++++++++------ preloadjs/preloadjs.d.ts | 62 +++++++++++++------ soundjs/soundjs.d.ts | 129 +++++++++++++++++++++++++++++++++++---- tweenjs/tweenjs.d.ts | 33 +++++++++- 5 files changed, 309 insertions(+), 63 deletions(-) diff --git a/easeljs/easeljs-tests.ts b/easeljs/easeljs-tests.ts index 956908434..678e335a1 100644 --- a/easeljs/easeljs-tests.ts +++ b/easeljs/easeljs-tests.ts @@ -1,16 +1,19 @@ /// function test_simple() { - var canvas = document.getElementById('canvas'); - var stage = new Stage(canvas); - var shape = new Shape(); + var canvas = document.getElementById('canvas'); + var stage = new createjs.Stage(canvas); + var shape = new createjs.Shape(); shape.graphics.beginFill('rgba(255,0,0,1)').drawRoundRect(0, 0, 120, 120, 10); stage.addChild(shape); stage.update(); } function test_animation() { - var ss = new SpriteSheet({ + var canvas = document.getElementById('canvas'); + var stage = new createjs.Stage(canvas); + + var ss = new createjs.SpriteSheet({ "frames": { "width": 200, "numFrames": 64, @@ -26,28 +29,31 @@ function test_animation() { ss.getAnimation("run").next = "jump"; ss.getAnimation("jump").next = "run"; - var bitmapAnimation = new BitmapAnimation(ss); + var bitmapAnimation = new createjs.BitmapAnimation(ss); bitmapAnimation.scaleY = bitmapAnimation.scaleX = .4; bitmapAnimation.gotoAndPlay("run"); - Ticker.setFPS(60); - Ticker.addListener(stage); + createjs.Ticker.setFPS(60); + createjs.Ticker.addListener(stage); stage.addChild(bitmapAnimation); } function test_graphics() { - var g = new Graphics(); + var canvas = document.getElementById('canvas'); + var stage = new createjs.Stage(canvas); + + var g = new createjs.Graphics(); g.setStrokeStyle(1); - g.beginStroke(Graphics.getRGB(0, 0, 0)); - g.beginFill(Graphics.getRGB(255, 0, 0)); + g.beginStroke(createjs.Graphics.getRGB(0, 0, 0)); + g.beginFill(createjs.Graphics.getRGB(255, 0, 0)); g.drawCircle(0, 0, 3); - var s = new Shape(g); + var s = new createjs.Shape(g); s.x = 100; s.y = 100; stage.addChild(s); stage.update(); - var myGraphics: Graphics; - myGraphics.beginStroke("#F00").beginFill("#00F").drawRect(20, 20, 100, 50).draw(myContext2D); + var myGraphics: createjs.Graphics; + myGraphics.beginStroke("#F00").beginFill("#00F").drawRect(20, 20, 100, 50).draw(canvas.getContext('2d')); } \ No newline at end of file diff --git a/easeljs/easeljs.d.ts b/easeljs/easeljs.d.ts index a19c285b9..e26026772 100644 --- a/easeljs/easeljs.d.ts +++ b/easeljs/easeljs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for EaselJS 0.5 +// Type definitions for EaselJS 0.6 // Project: http://www.createjs.com/#!/EaselJS // Definitions by: Pedro Ferreira // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -27,6 +27,7 @@ module createjs { cacheCanvas: HTMLCanvasElement; cacheID: number; compositeOperation: string; + cursor: string; filters: Filter[]; hitArea: DisplayObject; id: number; @@ -53,6 +54,7 @@ module createjs { clone(): DisplayObject; draw(ctx: CanvasRenderingContext2D, ignoreCache?: bool): void; getCacheDataURL(): string; + getChildByName(name: string): DisplayObject; getConcatenatedMatrix(mtx: Matrix2D): Matrix2D; getMatrix(matrix: Matrix2D): Matrix2D; getStage(): Stage; @@ -61,6 +63,7 @@ module createjs { isVisible(): bool; localToGlobal(x: number, y: number): Point; localToLocal(x: number, y: number, target: DisplayObject): Point; + set(props: Object): DisplayObject; setTransform(x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX: number, regY: number): DisplayObject; setupContext(ctx: CanvasRenderingContext2D): void; toString(): string; @@ -68,12 +71,22 @@ module createjs { updateCache(compositeOperation: string): void; // events - onClick: (event: MouseEvent) => any; - onDoubleClick: (event: MouseEvent) => any; - onMouseOut: (event: MouseEvent) => any; - onMouseOver: (event: MouseEvent) => any; - onPress: (event: MouseEvent) => any; - onTick: () => any; + click: (event: MouseEvent) => any; + dblClick: (event: MouseEvent) => any; + mouseout: (event: MouseEvent) => any; + mouseover: (event: MouseEvent) => any; + mousedown: (event: MouseEvent) => any; + tick: () => any; + + // EventDispatcher mixins + addEventListener(type: string, listener: (eventObj: Object) => bool): Function; + addEventListener(type: string, listener: (eventObj: Object) => bool): Object; + removeEventListener(type: string, listener: (eventObj: Function) => bool): void; + removeEventListener(type: string, listener: (eventObj: Object) => bool): void; + removeAllEventListeners(type: string): void; + dispatchEvent(eventObj: string, target: Object): bool; + dispatchEvent(eventObj: Object, target: Object): bool; + hasEventListener(type: string): bool; } @@ -142,6 +155,7 @@ module createjs { advance(): void; cache(): void; clone(): BitmapAnimation; + getBounds(): Rectangle; gotoAndPlay(frameOrAnimation: string): void; gotoAndPlay(frameOrAnimation: number): void; play(): void; @@ -149,9 +163,23 @@ module createjs { updateCache(): void; // events - onAnimationEnd: (reference: BitmapAnimation, animationEnded: string) => any; + onAnimationEnd: (event: Object) => any; } + export class ButtonHelper { + // properties + target: Object; + overLabel: string; + outLabel: string; + downLabel: string; + play: bool; + + // methods + constructor(target: MovieClip, outLabel: string, overLabel: string, downLabel: string, play: bool, hitArea: DisplayObject, hitLabel: string); + constructor(target: BitmapAnimation, outLabel: string, overLabel: string, downLabel: string, play: bool, hitArea: DisplayObject, hitLabel: string); + setEnabled(value: bool); + toString(): string; + } export class BoxBlurFilter extends Filter { // properties @@ -209,8 +237,7 @@ module createjs { } - export class Command - { + export class Command { // methods constructor (f, params, path); exec(scope: any): void; @@ -252,6 +279,31 @@ module createjs { } + export class EaselJS { + // properties + version: string; + buildDate: string; + } + + + export class EventDispatcher { + // properties + + // methods + static initialize(target: Object): void; + + addEventListener(type: string, listener: (eventObj: Object) => bool): Function; + addEventListener(type: string, listener: (eventObj: Object) => bool): Object; + removeEventListener(type: string, listener: (eventObj: Function) => bool): void; + removeEventListener(type: string, listener: (eventObj: Object) => bool): void; + removeAllEventListeners(type: string): void; + dispatchEvent(eventObj: string, target: Object): bool; + dispatchEvent(eventObj: Object, target: Object): bool; + hasEventListener(type: string): bool; + toString(): string; + } + + export class Graphics { // properties BASE_64: Object; @@ -263,7 +315,7 @@ module createjs { // methods arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: bool): Graphics; arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): Graphics; - beginBitmapFill(image: Object, repetition?: string): Graphics; + beginBitmapFill(image: Object, repetition?: string, matrix?: Matrix2D): Graphics; beginBitmapStroke(image: Object, repetition?: string): Graphics; beginFill(color: string): Graphics; beginLinearGradientFill(colors: string[], ratios: number[], x0: number, y0: number, x1: number, y1: number): Graphics; @@ -285,20 +337,36 @@ module createjs { drawRoundRectComplex(x: number, y: number, width: number, height: number, radiusTL: number, radiusTR: number, radiusBR: number, radisBL: number): Graphics; endFill(): Graphics; endStroke(): Graphics; + isEmpty(): bool; static getHSL(hue: number, saturation: number, lightness: number, alpha?: number): string; static getRGB(red: number, green: number, blue: number, alpha?: number): string; lineTo(x: number, y: number): Graphics; moveTo(x: number, y: number): Graphics; quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): Graphics; rect(x: number, y: number, width: number, height: number): Graphics; - setStrokeStyle(thickness: number, caps?: string, joints?: string, miter?: number): Graphics; // caps and joints can be a string or number - setStrokeStyle(thickness: number, caps?: number, joints?: string, miter?: number): Graphics; - setStrokeStyle(thickness: number, caps?: string, joints?: number, miter?: number): Graphics; - setStrokeStyle(thickness: number, caps?: number, joints?: number, miter?: number): Graphics; + setStrokeStyle(thickness: number, caps?: string, joints?: string, miter?: number, ignoreScale?: bool): Graphics; // caps and joints can be a string or number + setStrokeStyle(thickness: number, caps?: number, joints?: string, miter?: number, ignoreScale?: bool): Graphics; + setStrokeStyle(thickness: number, caps?: string, joints?: number, miter?: number, ignoreScale?: bool): Graphics; + setStrokeStyle(thickness: number, caps?: number, joints?: number, miter?: number, ignoreScale?: bool): Graphics; toString(): string; } + export class Log { + // properties + static NONE: number; + static ERROR: number; + static WARNING: number; + static TRACE: number; + static ALL: number; + static level: number; + + // methods + static out(message: string, details: string, level: number); + static addKeys(keys: Object); + static log(message: string, details: string, level: number); + } + export class Matrix2D { // properties a: number; @@ -363,6 +431,8 @@ module createjs { export class MovieClip extends Container { // properties actionsEnabled: bool; + autoReset: bool; + currentFrame: number; static INDEPENDENT: string; loop: bool; mode: string; @@ -453,6 +523,7 @@ module createjs { getAnimation(name: string): SpriteSheetAnimation; getAnimations(): string[]; getFrame(frameIndex: number): Object; + getFrameBounds(frameIndex: number); getNumFrames(animation: string): number; toString(): string; @@ -467,16 +538,22 @@ module createjs { maxWidth: number; maxHeight: number; padding: number; + progress: number; spriteSheet: SpriteSheet; + timeSlice: number; // methods addFrame(source: DisplayObject, sourceRect?: Rectangle, scale?: number, setupFunction?: () => any, setupParams?: any[], setupScope?: Object): any; //HERE returns number or null addMovieClip(source: MovieClip, sourceRect?: Rectangle, scale?: number): void; build(): void; - buildAsync(callback?: (reference: SpriteSheetBuilder) => any, timeSlice?: number): void; + buildAsync(timeSlice?: number): void; clone(): SpriteSheetBuilder; stopAsync(): void; toString(): string; + + // events + complete: (event: Object) => any; + onProgress: (event: Object) => any; } @@ -502,14 +579,15 @@ module createjs { constructor (canvas: HTMLCanvasElement); clone(): Stage; enableMouseOver(frequency: number): void; + enableDOMEvents(enable: bool): void; toDataURL(backgroundColor: string, mimeType: string): string; update(): void; clear(): void; + handleEvent(evt: Object): void; // events - onMouseDown: (event: MouseEvent) => any; - onMouseMove: (event: MouseEvent) => any; - onMouseUp: (event: MouseEvent) => any; + stagemousemove: (event: MouseEvent) => any; + stagemouseup: (event: MouseEvent) => any; } diff --git a/preloadjs/preloadjs.d.ts b/preloadjs/preloadjs.d.ts index fd044e968..4edbe81ae 100644 --- a/preloadjs/preloadjs.d.ts +++ b/preloadjs/preloadjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for PreloadJS 0.2 +// Type definitions for PreloadJS 0.3 // Project: http://www.createjs.com/#!/PreloadJS // Definitions by: Pedro Ferreira // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -18,39 +18,57 @@ module createjs { progress: number; // methods - cancel(): void; - getItem(): Object; + close(): void; + getItem(value: string): Object; load(): void; + toString(): string; // events - onComplete: () => any; - onError: () => any; - onFileLoad: () => any; - onFileProgress: () => any; - onLoadStart: () => any; - onProgress: () => any; + complete: (event: Object) => any; + error: (event: Object) => any; + fileload: (event: Object) => any; + fileprogress: (event: Object) => any; + loadStart: (event: Object) => any; + + // EventDispatcher mixins + addEventListener(type: string, listener: (eventObj: Object) => bool): Function; + addEventListener(type: string, listener: (eventObj: Object) => bool): Object; + removeEventListener(type: string, listener: (eventObj: Function) => bool): void; + removeEventListener(type: string, listener: (eventObj: Object) => bool): void; + removeAllEventListeners(type: string): void; + dispatchEvent(eventObj: string, target: Object): bool; + dispatchEvent(eventObj: Object, target: Object): bool; + hasEventListener(type: string): bool; } + export class PreloadJS { + version: string; + buildDate: string; + } - export class PreloadJS extends AbstractLoader { - constructor (useXHR2?: bool); + export class LoadQueue extends AbstractLoader { + constructor (useXHR?: bool); // properties + static BINARY: string; static CSS: string; static IMAGE: string; static JAVASCRIPT: string; static JSON: string; - maintainScriptOrder: bool; - next: PreloadJS; static SOUND: string; - stopOnError: bool; + static SVG: string; static TEXT: string; - static TIMEOUT_TIME: number; - useXHR: bool; + static LOAD_TIMEOUT: number; static XML: string; + maintainScriptOrder: bool; + next: LoadQueue; + stopOnError: bool; + useXHR: bool; + // methods BrowserDetect(): Object; + init(useXHR?: bool): void; close(): void; getResult(value: string): Object; initialize(useXHR: bool): void; @@ -60,7 +78,14 @@ module createjs { loadFile(file: string, loadNow: bool): void; loadManifest(manifest: Object[], loadNow: bool): void; loadManifest(manifest: string[], loadNow: bool): void; + getItem(value: string): Object; + getResult(value: string, rawResult?: bool): Object; + removeAll(): void; + remove(idsOrUrls: string): void; + remove(idsOrUrls: Array): void; + reset(): void; setMaxConnections(value: number): void; + setUseXHR(value: bool): void; setPaused(value: bool): void; } @@ -68,10 +93,13 @@ module createjs { export class TagLoader extends AbstractLoader { constructor (item: Object, srcAttr: string, useXHR: bool); constructor (item: string, srcAttr: string, useXHR: bool); + getResult(): HTMLImageElement; + getResult(): HTMLAudioElement; } export class XHRLoader extends AbstractLoader { constructor (file: Object); + getResult(rawResult?: bool); } -} \ No newline at end of file +} diff --git a/soundjs/soundjs.d.ts b/soundjs/soundjs.d.ts index 7355b34b7..a00d33775 100644 --- a/soundjs/soundjs.d.ts +++ b/soundjs/soundjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for SoundJS 0.3 +// Type definitions for SoundJS 0.4 // Project: http://www.createjs.com/#!/SoundJS // Definitions by: Pedro Ferreira // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -19,33 +19,95 @@ module createjs { // methods create(src: string): SoundInstance; + preload(src: string, instance: Object): void; static generateCapabilities(): void; static isSupported(): bool; - register(src: string, instances: number): Object; + isPreloadStarted(src: string): bool; + register(src: string, instances: Number): Object; + setVolume(value: Number): bool; + getVolume(): Number; + setMute(isMuted: bool): Boolean; + toString(): string; + + // Flash API + unregisterPreloadInstance(flashId: string): void; + unregisterSoundInstance(flashId: string): void; + flashLog(data: string): void; + handleSoundEvent(flashId: string, method: string): void; + handlePreloadEvent(flashId: string, method: string): void; + handleEvent(method: string): void; + handleErrorEvent(error: string): void; } export class HTMLAudioPlugin { // properties static capabilities: Object; static MAX_INSTANCES: number; + static AUDIO_READY: string; + static AUDIO_ENDED: string; + static AUDIO_ERROR: string; + static AUDIO_STALLED: string; + capabilities:Object; + defaultNumChannels: number; // methods create(src: string): SoundInstance; static generateCapabilities(): void; static isSupported(): bool; register(src: string, instances: number): Object; + isPreloadStarted(src: string): bool; + preload(src: string, instance: Object): void; + toString(): string; + } + + export class WebAudioPlugin { + // properties + static capabilities: Object; + static MAX_INSTANCES: number; + static AUDIO_READY: string; + static AUDIO_ENDED: string; + static AUDIO_ERROR: string; + static AUDIO_STALLED: string; + arrayBuffers: ArrayBuffer[]; + capabilities:Object; + defaultNumChannels: number; + dynamicsCompressorNode: Object; + gainNode: Object; + volume: number; + context: any; + WebAudioLoader(src: string, owner: Object): Function; + + // methods + create(src: string): SoundInstance; + static generateCapabilities(): void; + static isSupported(): bool; + setVolume(value: Number): bool; + getVolume(): number; + register(src: string, instances: number): Object; + isPreloadStarted(src: string): bool; + preload(src: string, instance: Object): void; + isPreloadComplete(src : string): bool; + removeFromPreload(src: string); + setMute(value: number): bool; + toString(): string; } export class SoundInstance { - constructor (src: string); + constructor (src: string, owner: string, flash: string); // properties muted: bool; owner: HTMLAudioPlugin; + offset: number; paused: bool; + delay: number; + pan: number; + duration: number; playState: string; + delayTimeoutId: number; src: string; uniqueId: any; //HERE string or number + volume: number; // methods getDuration(): number; @@ -62,15 +124,26 @@ module createjs { stop(): bool; // events - onComplete: () => any; - onLoop: () => any; - onPlayFailed: () => any; - onPlayInterrupted: () => any; - onReady: () => any; + complete: () => any; + loop: () => any; + failed: () => any; + interrupted: () => any; + succeeded: () => any; + ready: () => any; + + // EventDispatcher mixins + addEventListener(type: string, listener: (eventObj: Object) => bool): Function; + addEventListener(type: string, listener: (eventObj: Object) => bool): Object; + removeEventListener(type: string, listener: (eventObj: Function) => bool): void; + removeEventListener(type: string, listener: (eventObj: Object) => bool): void; + removeAllEventListeners(type: string): void; + dispatchEvent(eventObj: string, target: Object): bool; + dispatchEvent(eventObj: Object, target: Object): bool; + hasEventListener(type: string): bool; } - export class SoundJS { + export class Sound { // properties static activePlugin: Object; static AUDIO_TIMEOUT: number; @@ -85,23 +158,57 @@ module createjs { static PLAY_INITED: string; static PLAY_INTERRUPTED: string; static PLAY_SUCCEEDED: string; + static SUPPORTED_EXTENSIONS: Array; + static EXTENSION_MAP: Object; + static defaultInterruptBehavior: string; // methods static checkPlugin(initializeDefault: bool): bool; + static createInstance(src: string): SoundInstance; static getCapabilities(): Object; static getCapability(key: string): any; //HERE can return string | number | bool static getInstanceById(uniqueId: string): SoundInstance; + static getMute(): number; static getMasterVolume(): number; static getSrcFromId(value: string): string; + static getVolume(): number; static isReady(): bool; static pause(id: string): void; - static play(value: string, interrupt?: string, delay?: number, offset?: number, loop?: number, volume?: number, pan?: number): SoundInstance; + static play(src: string, interrupt?: string, delay?: number, offset?: number, loop?: number, volume?: number, pan?: number): SoundInstance; static registerPlugin(plugin: Object): bool; static registerPlugins(plugins: Object[]): bool; + static registerSound(src: Object, id: string, data: Object, preload?: bool): Object; + static registerManifest(manifest: Array); static resume(id: string): void; static setMasterVolume(value: number): bool; static setMute(isMuted: bool, id: string): bool; static setVolume(value: number, id?: string): bool; - static stop(id?: string): bool; + static stop(): bool; + + // events + loadComplete: () => any; + + // EventDispatcher mixins + addEventListener(type: string, listener: (eventObj: Object) => bool): Function; + addEventListener(type: string, listener: (eventObj: Object) => bool): Object; + removeEventListener(type: string, listener: (eventObj: Function) => bool): void; + removeEventListener(type: string, listener: (eventObj: Object) => bool): void; + removeAllEventListeners(type: string): void; + dispatchEvent(eventObj: string, target: Object): bool; + dispatchEvent(eventObj: Object, target: Object): bool; + hasEventListener(type: string): bool; } + + export class BrowserDetect { + // properties + static isFirefox: bool; + static isOpera: bool; + static isChrome: bool; + static isIOS: bool; + static isAndroid: bool; + static isBlackberry: bool; + + // methods + static init(); + } } diff --git a/tweenjs/tweenjs.d.ts b/tweenjs/tweenjs.d.ts index 31499c910..82e9fd25c 100644 --- a/tweenjs/tweenjs.d.ts +++ b/tweenjs/tweenjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for TweenJS 0.3 +// Type definitions for TweenJS 0.4 // Project: http://www.createjs.com/#!/TweenJS // Definitions by: Pedro Ferreira // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -12,6 +12,13 @@ module createjs { + export class TweenJS { + // properties + version: string; + buildDate: string; + } + + export class CSSPlugin { // properties static cssSuffixMap: Object; @@ -128,6 +135,26 @@ module createjs { wait(duration: number): void; // events - onChange: (instance: Tween) => any; + change: (event) => any; + + // EventDispatcher mixins + addEventListener(type: string, listener: (eventObj: Object) => bool): Function; + addEventListener(type: string, listener: (eventObj: Object) => bool): Object; + removeEventListener(type: string, listener: (eventObj: Function) => bool): void; + removeEventListener(type: string, listener: (eventObj: Object) => bool): void; + removeAllEventListeners(type: string): void; + dispatchEvent(eventObj: string, target: Object): bool; + dispatchEvent(eventObj: Object, target: Object): bool; + hasEventListener(type: string): bool; } -} \ No newline at end of file + + + export class MotionGuidePlugin { + // properties + static priority: number; + + //methods + static install(): Object; + + } +} From 266df0f4a05ad13180d3161efb7a4e60b46845bf Mon Sep 17 00:00:00 2001 From: Diullei Gomes Date: Mon, 25 Feb 2013 21:25:42 -0300 Subject: [PATCH 2/5] jqrangeslider-tests.ts bug fix --- jqrangeslider/jqrangeslider-tests.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jqrangeslider/jqrangeslider-tests.ts b/jqrangeslider/jqrangeslider-tests.ts index 37ffeb8ef..b4e3875f8 100644 --- a/jqrangeslider/jqrangeslider-tests.ts +++ b/jqrangeslider/jqrangeslider-tests.ts @@ -94,7 +94,10 @@ $("#formatterExample").dateRangeSlider({ formatter: (val: Date) => { var days = val.getDay(), month = val.getMonth() + 1, - year = val.getYear(); + // https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getYear#Description + // getYear is no longer used and has been replaced by the getFullYear method. + // year = val.getYear(); + year = val.getFullYear(); return days + "/" + month + "/" + year; } }); From 3908267c99841d543e2f57fa530097254a80852e Mon Sep 17 00:00:00 2001 From: Kon Date: Tue, 26 Feb 2013 09:43:33 +0900 Subject: [PATCH 3/5] Added new definitions for jake --- README.md | 1 + jake/jake-tests.ts | 267 +++++++++++++++++++++++++++++++ jake/jake.d.ts | 388 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 656 insertions(+) create mode 100644 jake/jake-tests.ts create mode 100644 jake/jake.d.ts diff --git a/README.md b/README.md index ca58803a5..20f7a0a5e 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ List of Definitions * [i18next](http://i18next.com/) (by [Maarten Docter](https://github.com/mdocter)) * [Impress.js](https://github.com/bartaz/impress.js) (by [Boris Yankov](https://github.com/borisyankov)) * [iScroll](http://cubiq.org/iscroll-4) (by [Boris Yankov](https://github.com/borisyankov)) +* [jake](https://github.com/mde/jake) (by [Kon](http://phyzkit.net/)) * [Jasmine](http://pivotal.github.com/jasmine/) (by [Boris Yankov](https://github.com/borisyankov)) * [jQRangeSlider](http://ghusse.github.com/jQRangeSlider) (by [D�niel Tar](https://github.com/qcz)) * [jQuery](http://jquery.com/) (from TypeScript samples) diff --git a/jake/jake-tests.ts b/jake/jake-tests.ts new file mode 100644 index 000000000..410764d28 --- /dev/null +++ b/jake/jake-tests.ts @@ -0,0 +1,267 @@ +// https://github.com/mde/jake +/// + +import path = module("path"); + +desc('This is the default task.'); +task('default', function (params) { + console.log('This is the default task.'); +}); + +desc('This task has prerequisites.'); +task('hasPrereqs', ['foo', 'bar', 'baz'], function (params) { + console.log('Ran some prereqs first.'); +}); + +desc('This is an asynchronous task.'); +task('asyncTask', {async: true}, function () { + setTimeout(complete, 1000); +}); + +desc('This builds a minified JS file for production.'); +file('foo-minified.js', ['bar', 'foo-bar.js', 'foo-baz.js'], function () { + // Code to concat and minify goes here +}); + +desc('This creates the bar directory for use with the foo-minified.js file-task.'); +directory('bar'); + +desc('This is the default task.'); +task('default', function () { + console.log('This is the default task.'); +}); + +namespace('foo', function () { + desc('This the foo:bar task'); + task('bar', function () { + console.log('doing foo:bar task'); + }); + + desc('This the foo:baz task'); + task('baz', ['default', 'foo:bar'], function () { + console.log('doing foo:baz task'); + }); + +}); + +desc('This is an awesome task.'); +task('awesome', function (a, b, c) { + console.log(a, b, c); +}); + + +desc('This is an awesome task.'); +task('awesome', function (a, b, c) { + console.log(a, b, c); + console.log(process.env.qux, process.env.frang); +}); + + +jake.addListener('complete', function () { + process.exit(); +}); + +desc('Calls the foo:bar task and its prerequisites.'); +task('invokeFooBar', function () { + // Calls foo:bar and its prereqs + jake.Task['foo:bar'].invoke(); +}); + +desc('Calls the foo:bar task and its prerequisites.'); +task('invokeFooBar', function () { + // Calls foo:bar and its prereqs + jake.Task['foo:bar'].invoke(); + // Does nothing + jake.Task['foo:bar'].invoke(); +}); + +desc('Calls the foo:bar task without its prerequisites.'); +task('executeFooBar', function () { + // Calls foo:bar without its prereqs + jake.Task['foo:baz'].execute(); +}); + +desc('Calls the foo:bar task without its prerequisites.'); +task('executeFooBar', function () { + // Calls foo:bar without its prereqs + jake.Task['foo:baz'].execute(); + // Can keep running this over and over + jake.Task['foo:baz'].execute(); + jake.Task['foo:baz'].execute(); +}); + +desc('Calls the foo:bar task and its prerequisites.'); +task('invokeFooBar', function () { + // Calls foo:bar and its prereqs + jake.Task['foo:bar'].invoke(); + // Does nothing + jake.Task['foo:bar'].invoke(); + // Only re-runs foo:bar, but not its prerequisites + jake.Task['foo:bar'].reenable(); + jake.Task['foo:bar'].invoke(); +}); + +desc('Calls the foo:bar task and its prerequisites.'); +task('invokeFooBar', function () { + // Calls foo:bar and its prereqs + jake.Task['foo:bar'].invoke(); + // Does nothing + jake.Task['foo:bar'].invoke(); + // Re-runs foo:bar and all of its prerequisites + jake.Task['foo:bar'].reenable(true); + jake.Task['foo:bar'].invoke(); +}); + +desc('Passes params on to other tasks.'); +task('passParams', function () { + var t = jake.Task['foo:bar']; + // Calls foo:bar, passing along current args + t.invoke.apply(t, arguments); +}); + +desc('Calls the async foo:baz task and its prerequisites.'); +task('invokeFooBaz', {async: true}, function () { + var t = jake.Task['foo:baz']; + t.addListener('complete', function () { + console.log('Finished executing foo:baz'); + // Maybe run some other code + // ... + // Complete the containing task + complete(); + }); + // Kick off foo:baz + t.invoke(); +}); + + +namespace('vronk', function () { + task('groo', function () { + var t = jake.Task['vronk:zong']; + t.addListener('error', function (e) { + console.log(e.message); + }); + t.invoke(); + }); + + task('zong', function () { + throw new Error('OMFGZONG'); + }); +}); + +desc('This task fails.'); +task('failTask', function () { + fail('Yikes. Something back happened.'); +}); + + +desc('This task fails with an exit-status of 42.'); +task('failTaskQuestionCustomStatus', function () { + fail('What is the answer?', 42); +}); + + +declare var sourceDir:string; +declare var currentDir:string; +jake.mkdirP('app/views/layouts'); +jake.cpR(path.join(sourceDir, '/templates'), currentDir); +jake.readdirR('pkg'); +jake.rmRf('pkg'); + +desc('Runs the Jake tests.'); +task('test', {async: true}, function () { + var cmds = [ + 'node ./tests/parseargs.js' + , 'node ./tests/task_base.js' + , 'node ./tests/file_task.js' + ]; + jake.exec(cmds, function () { + console.log('All tests passed.'); + complete(); + }, {printStdout: true}); +}); + +var ex = jake.createExec(['do_thing.sh'], {printStdout: true}); +ex.addListener('error', function (msg, code) { + if (code == 127) { + console.log("Couldn't find do_thing script, trying do_other_thing"); + ex.append('do_other_thing.sh'); + } + else { + fail('Fatal error: ' + msg, code); + } +}); +ex.run(); + +task('echo', {async: true}, function () { + jake.exec(['echo "hello"'], function () { + jake.logger.log('Done.'); + complete(); + }, {printStdout: !jake.program.opts.quiet}); +}); + +function hoge(){ + var t = new jake.PackageTask('fonebone', 'v0.1.2112', function () { + var fileList = [ + 'Jakefile' + , 'README.md' + , 'package.json' + , 'lib/*' + , 'bin/*' + , 'tests/*' + ]; + this.packageFiles.include(fileList); + this.needTarGz = true; + this.needTarBz2 = true; + }); +} + +var list = new jake.FileList(); +list.include('foo/*.txt'); +list.include(['bar/*.txt', 'README.md']); +list.include('Makefile', 'package.json'); +list.exclude('foo/zoobie.txt'); +list.exclude(/foo\/src.*.txt/); +console.log(list.toArray()); + + +var t = new jake.TestTask('fonebone', function () { + var fileList = [ + 'tests/*' + , 'lib/adapters/**/test.js' + ]; + this.testFiles.include(fileList); + this.testFiles.exclude('tests/helper.js'); + this.testName = 'testMainAndAdapters'; +}); + +var assert = require('assert') + , tests; + +tests = { + 'sync test': function () { + // Assert something + assert.ok(true); + } +, 'async test': function (next) { + // Assert something else + assert.ok(true); + // Won't go next until this is called + next(); + } +, 'another sync test': function () { + // Assert something else + assert.ok(true); + } +}; + +//module.exports = tests; + +var p = new jake.NpmPublishTask('jake', [ + 'Makefile' +, 'Jakefile' +, 'README.md' +, 'package.json' +, 'lib/*' +, 'bin/*' +, 'tests/*' +]); \ No newline at end of file diff --git a/jake/jake.d.ts b/jake/jake.d.ts new file mode 100644 index 000000000..ec6f20d2b --- /dev/null +++ b/jake/jake.d.ts @@ -0,0 +1,388 @@ +// Type definitions for jake +// Project: https://github.com/mde/jake +// Definitions by: Kon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/** + * Complets an asynchronous task, allowing Jake's execution to proceed to the next task + */ +function complete(): void; + +/** + * Creates a description for a Jake Task (or FileTask, DirectoryTask). When invoked, the description that iscreated will be associated with whatever Task is created next. + * @param description The description for the Task + */ +function desc(description:string): void; + +/** + * Creates a Jake DirectoryTask. Can be used as a prerequisite for FileTasks, or for simply ensuring a directory exists for use with a Task's action. + * @param name The name of the DiretoryTask + */ +function directory(name:string): jake.DirectoryTask; + + +/** + * Causes Jake execution to abort with an error. Allows passing an optional error code, which will be used to set the exit-code of exiting process. + * @param err The error to thow when aborting execution. If this argument is an Error object, it will simply be thrown. If a String, it will be used as the error-message. (If it is a multi-line String, the first line will be used as the Error message, and the remaining lines will be used as the error-stack.) + */ +function fail(...err:string[]): void; +function fail(...err:Error[]): void; +function fail(...err:any[]): void; + +/** + * Creates a Jake FileTask. + * @name name The name of the Task + * @param prereqs Prerequisites to be run before this task + * @param action The action to perform for this task + * @param opts Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task. + */ +function file(name:string, prereqs?:string[], action?:()=>void, opts?:jake.FileTaskOptions): jake.FileTask; + +/** + * Creates a namespace which allows logical grouping of tasks, and prevents name-collisions with task-names. Namespaces can be nested inside of other namespaces. + * @param name The name of the namespace + * @param scope The enclosing scope for the namespaced tasks + */ +function namespace(name:string, scope:()=>void): void; + +/** + * @param name The name of the Task + * @param prereqs Prerequisites to be run before this task + * @param action The action to perform for this task + * @param opts + */ +function task(name:string, prereqs?:string[], action?:(...params:any[])=>any, opts?:jake.TaskOptions): jake.Task; +function task(name:string, action?:(...params:any[])=>any, opts?:jake.TaskOptions): jake.Task; +function task(name:string, opts?:jake.TaskOptions, action?:(...params:any[])=>any): jake.Task; + +module jake{ + + //////////////////////////////////////////////////////////////////////////////////// + // File-utils ////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + + interface UtilOptions{ + silent?: bool; + } + + /** + * The jake.mkdirP utility recursively creates a set of nested directories. It will not throw an error if any of the directories already exists. + * https://github.com/substack/node-mkdirp + */ + export function mkdirP(name:string, mode?:string, f?:(er:Error, made:any)=>void): void; + export function mkdirP(name:string, f?:(er:Error, made:any)=>void): void; + + /** + * The jake.cpR utility does a recursive copy of a file or directory. + * Note that this command can only copy files and directories; it does not perform globbing (so arguments like '*.txt' are not possible). + * @param path the file/directory to copy, + * @param destination the destination. + */ + export function cpR(path:string, destination:string, opts?:UtilOptions, callback?:()=>void): void; + export function cpR(path:string, destination:string, callback?:(err:Error)=>void): void; + + /** + * The jake.readdirR utility gives you a recursive directory listing, giving you output somewhat similar to the Unix find command. It only works with a directory name, and does not perform filtering or globbing. + * @return an array of filepaths for all files in the 'pkg' directory, and all its subdirectories. + */ + export function readdirR(name:string, opts?:UtilOptions): string[]; + + /** + * The jake.rmRf utility recursively removes a directory and all its contents. + */ + export function rmRf(name:string, opts?:UtilOptions): void; + + ////////////////////////////////////////////////////////////////////////////////////////////// + // Running shell-commands //////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////////// + + interface ExecOptions{ + /** + * print to stdout, default false + */ + + printStdout?:bool; + /** + * print to stderr, default false + */ + printStderr?:bool; + + /** + * stop execution on error, default true + */ + breakOnError?:bool; + } + export function exec(cmds:string[], callback?:()=>void, opts?:ExecOptions); + + + /** + * @event cmdStart When a new command begins to run. Passes one arg, the command being run. + * @event cmdEnd When a command finishes. Passes one arg, the command being run. + * @event stdout When the stdout for the child-process recieves data. This streams the stdout data. Passes one arg, the chunk of data. + * @event stderr When the stderr for the child-process recieves data. This streams the stderr data. Passes one arg, the chunk of data. + * @event error When a shell-command + */ + export interface Exec extends EventEmitter{ + constructor(cmds:string[], callback?:()=>void, opts?:ExecOptions); + constructor(cmds:string[], opts?:ExecOptions, callback?:()=>void); + constructor(cmds:string, callback?:()=>void, opts?:ExecOptions); + constructor(cmds:string, opts?:ExecOptions, callback?:()=>void); + append(cmd:string): void; + run(): void; + } + + export function createExec(cmds:string[], callback?:()=>void, opts?:ExecOptions ):Exec; + export function createExec(cmds:string[], opts?:ExecOptions, callback?:()=>void):Exec; + export function createExec(cmds:string, callback?:()=>void, opts?:ExecOptions ):Exec; + export function createExec(cmds:string, opts?:ExecOptions, callback?:()=>void):Exec; + + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Logging and output //////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////// + + interface Logger{ + log(value:any): void; + error(value:any): void; + } + + export var logger: Logger; + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // program //////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + export var program: { + opts: { + [name:string]: any; + quiet: bool; + }; + taskNames: string[]; + taskArgs: string[]; + envVars: { [key:string]: string; }; + }; + + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Tasks ///////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + + export interface TaskOptions{ + /** + * Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task. + * @default false + */ + asyc?: bool; + } + + /** + * A Jake Task + * + * @event complete + */ + export class Task implements EventEmitter{ + /** + * @name name The name of the Task + * @param prereqs Prerequisites to be run before this task + * @param action The action to perform for this task + * @param opts Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task. + */ + constructor(name:string, prereqs?:string[], action?:()=>void, opts?:TaskOptions); + + /** + * Runs prerequisites, then this task. If the task has already been run, will not run the task again. + */ + invoke(): void; + + /** + * Runs this task, without running any prerequisites. If the task has already been run, it will still run it again. + */ + reenable(): void; + + addListener(event: string, listener: Function); + on(event: string, listener: Function); + once(event: string, listener: Function): void; + removeListener(event: string, listener: Function): void; + removeAllListener(event: string): void; + setMaxListeners(n: number): void; + listeners(event: string): { Function; }[]; + emit(event: string, arg1?: any, arg2?: any): void; + } + + + + export class DirectoryTask{ + /** + * @param name The name of the directory to create. + */ + constructor(name:string); + } + + export interface FileTaskOptions{ + /** + * Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task. + * @default false + */ + asyc?: bool; + } + + export class FileTask{ + /** + * @param name The name of the Task + * @param prereqs Prerequisites to be run before this task + * @param action The action to perform to create this file + * @param opts Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task. + */ + constructor(name:string, prereqs?:string[], action?:()=>void, opts?:FileTaskOptions); + } + + interface FileFilter{ + (filename:string): bool; + } + + export class FileList{ + constructor(); + + /** + * Includes file-patterns in the FileList. Should be called with one or more + * pattern for finding file to include in the list. Arguments should be strings + * for either a glob-pattern or a specific file-name, or an array of them + */ + include(files:string[]): void; + include(...files:string[]): void; + + /** + * Indicates whether a particular file would be filtered out by the current + * exclusion rules for this FileList. + * @param name The filename to check + * @return Whether or not the file should be excluded + */ + shouldExclude(name:string): bool; + + /** + * Excludes file-patterns from the FileList. Should be called with one or more + * pattern for finding file to include in the list. Arguments can be: + * 1. Strings for either a glob-pattern or a specific file-name + * 2. Regular expression literals + * 3. Functions to be run on the filename that return a true/false + */ + exclude(file:string[]): void; + exclude(...file:string[]): void; + exclude(file:RegExp[]): void; + exclude(...file:RegExp[]): void; + exclude(file:FileFilter[]): void; + exclude(...file:FileFilter[]): void; + + + /** + * Populates the FileList from the include/exclude rules with a list of + * actual files + */ + resolve(): void; + + /** + * Convert to a plain-jane array + */ + toArray(): string[]; + + /** + * Get rid of any current exclusion rules + */ + clearExclude(): void; + } + + export class PackageTask{ + /** + * Instantiating a PackageTask creates a number of Jake Tasks that make packaging and distributing your software easy. + * @param name The name of the project + * @param version The current project version (will be appended to the project-name in the package-archive + * @param definition Defines the contents of the package, and format of the package-archive. Will be executed on the instantiated PackageTask (i.e., 'this', will be the PackageTask instance), to set the various instance-propertiess. + */ + constructor(name:string, version:string, definition:()=>void); + + /** + * Equivalent to the '-C' command for the `tar` and `jar` commands. ("Change to this directory before adding files.") + */ + archiveChangeDir: string; + + /** + * Specifies the files and directories to include in the package-archive. If unset, this will default to the main package directory -- i.e., name + version. + */ + archiveContentDir: string; + + /** + * The shell-command to use for creating jar archives. + */ + jarCommand: string; + + /** + * Can be set to point the `jar` utility at a manifest file to use in a .jar archive. If unset, one will be automatically created by the `jar` utility. This path should be relative to the root of the package directory (this.packageDir above, likely 'pkg') + */ + manifestFile: string; + + /** + * The name of the project + */ + name: string; + + /** + * If set to true, uses the `jar` utility to create a .jar archive of the pagckage + */ + needJar: bool; + + /** + * If set to true, uses the `tar` utility to create a gzip .tgz archive of the pagckage + */ + needTar: bool; + + /** + * If set to true, uses the `tar` utility to create a bzip2 .bz2 archive of the pagckage + */ + needTarBz2: bool; + + /** + * If set to true, uses the `zip` utility to create a .zip archive of the pagckage + */ + needZip: bool; + + /** + * The list of files and directories to include in the package-archive + */ + packageFiles: FileList; + + /** + * The shell-command to use for creating tar archives. + */ + tarCommand: string; + + /** + * The project version-string + */ + version: string; + + /** + * The shell-command to use for creating zip archives. + */ + zipCommand: string; + + } + + export class TestTask{ + constructor(name:string, definition?:()=>void); + } + + export class NpmPublishTask{ + constructor(name:string, packageFiles:string[]); + } + + export function addListener(event: string, listener: Function); + export function on(event: string, listener: Function); + export function once(event: string, listener: Function): void; + export function removeListener(event: string, listener: Function): void; + export function removeAllListener(event: string): void; + export function setMaxListeners(n: number): void; + export function listeners(event: string): { Function; }[]; + export function emit(event: string, arg1?: any, arg2?: any): void; +} \ No newline at end of file From aee0afb0b885749dbf135dd9a01942d882c6a506 Mon Sep 17 00:00:00 2001 From: Diullei Gomes Date: Mon, 25 Feb 2013 22:53:37 -0300 Subject: [PATCH 4/5] node_redis-tests.ts fixed --- node_redis/node_redis-tests.ts | 18 +++++++++--------- node_redis/node_redis.d.ts | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/node_redis/node_redis-tests.ts b/node_redis/node_redis-tests.ts index d506bdd2a..f8dfe1728 100644 --- a/node_redis/node_redis-tests.ts +++ b/node_redis/node_redis-tests.ts @@ -142,7 +142,7 @@ function test7() { var client = redis.createClient(), multi; client.multi([ - ["mget", "multifoo", "multibar", redis.print], + ["mget", "multifoo", "multibar", redis.print], ["incr", "multifoo"], ["incr", "multibar"] ]).exec(function (err, replies) { @@ -180,7 +180,7 @@ function test9() { }); var max = 3, min = 1, offset = 1, count = 2; - var args2 = ['myzset', max, min, 'WITHSCORES', 'LIMIT', offset, count]; + var args2 = ['myzset', max, min, 'WITHSCORES', 'LIMIT', offset, count]; client.zrevrangebyscore(args2, function (err, response) { if (err) throw err; console.log('example2', response); @@ -322,14 +322,14 @@ tests.MULTI_2 = function () { // test nested multi-bulk replies client.multi([ - ["mget", "multifoo", "multibar", function (err, res) { + ["mget", "multifoo", "multibar", function (err, res) { assert.strictEqual(2, res.length, name); assert.strictEqual("12", res[0].toString(), name); assert.strictEqual("22", res[1].toString(), name); }], - ["set", "foo2", require_error(name)], - ["incr", "multifoo", require_number(13, name)], - ["incr", "multibar", require_number(23, name)] + ["set", "foo2", require_error(name)], + ["incr", "multifoo", require_number(13, name)], + ["incr", "multibar", require_number(23, name)] ]).exec(function (err, replies) { assert.strictEqual(2, replies[0].length, name); assert.strictEqual("12", replies[0][0].toString(), name); @@ -393,7 +393,7 @@ tests.MULTI_5 = function () { // test nested multi-bulk replies with nulls. client.multi([ - ["mget", ["multifoo", "some", "random value", "keys"]], + ["mget", ["multifoo", "some", "random value", "keys"]], ["incr", "multifoo"] ]) .exec(function (err, replies) { @@ -947,7 +947,7 @@ tests.TYPE = function () { client.rpush(["list key", "should be a list"], require_number_pos(name)); client.sadd(["set key", "should be a set"], require_number_any(name)); client.zadd(["zset key", "10.0", "should be a zset"], require_number_any(name)); - client.hset(["hash key", "hashtest", "should be a hash"], require_number_any(0, name)); + client.hset(["hash key", "hashtest", "should be a hash"], require_number_any(name)); client.TYPE(["string key"], require_string("string", name)); client.TYPE(["list key"], require_string("list", name)); @@ -1685,7 +1685,7 @@ tests.TTL = function () { client.set(["ttl key", "ttl val"], require_string("OK", name)); client.expire(["ttl key", "100"], require_number_pos(name)); setTimeout(function () { - client.TTL(["ttl key"], last(name, require_number_pos(0, name))); + client.TTL(["ttl key"], last(name, require_number_pos(name))); }, 500); }; diff --git a/node_redis/node_redis.d.ts b/node_redis/node_redis.d.ts index 16fadff95..74652ab33 100644 --- a/node_redis/node_redis.d.ts +++ b/node_redis/node_redis.d.ts @@ -342,7 +342,7 @@ declare module 'redis' { once(eventName: string, callback: Function): void; removeListener(eventName: string, callback: Function): void; - multi(): Multi; + multi(commands?: any[]): Multi; MULTI(): Multi; } } \ No newline at end of file From 5b83ce4c10a09a60d360dbc8a5f2b15ee27342ce Mon Sep 17 00:00:00 2001 From: Diullei Gomes Date: Mon, 25 Feb 2013 23:06:10 -0300 Subject: [PATCH 5/5] viewporter-tests.ts fixed --- viewporter/viewporter-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/viewporter/viewporter-tests.ts b/viewporter/viewporter-tests.ts index 5c6c32cae..35c8c2ae4 100644 --- a/viewporter/viewporter-tests.ts +++ b/viewporter/viewporter-tests.ts @@ -91,7 +91,7 @@ function test_swipey() { } context.strokeStyle = "rgba(" + color[0] + "," + color[1] + "," + color[2] + "," + opacity + ")"; context.lineJoin = "round"; - context.lineWidth = (window.devicePixelRatio || 1) * 5; + context.lineWidth = ((window).devicePixelRatio || 1) * 5; for (var i = 0; i < clickX.length; i++) { context.beginPath(); if (clickDrag[i] && i) { @@ -161,7 +161,7 @@ function test_swipey() { window.setInterval(function () { context.clearRect(0, 0, width, height); - var counter = 0, ratio = window.devicePixelRatio || 1; + var counter = 0, ratio = (window).devicePixelRatio || 1; for (var identifier in pointers) { pointers[identifier].redraw(); counter++;