├── .gitignore ├── README.md ├── bin └── createjs-def ├── jsfl ├── Generate Haxe Definitions.jsfl ├── Generate Typescript Definitions.jsfl ├── build.bat ├── build.sh ├── haxe-gen.js └── typescript-gen.js ├── lib ├── flashpro-export.js ├── formatter.js ├── index.js ├── model.js └── parse-js.js ├── package.json └── test ├── bilbo ├── BilboWalkcycle.hx ├── bilbo-typescript.html ├── bilbo-typescript.js ├── bilbo-typescript.ts ├── bilbo-walkcycle-side.d.ts ├── bilbo-walkcycle-side.html ├── bilbo-walkcycle-side.js ├── easeljs │ └── easeljs.d.ts └── tweenjs │ └── TweenJS.d.ts ├── browser.js ├── index.html ├── index.js ├── node-test.sh ├── sea ├── Sea-typescript.html ├── Sea-typescript.js ├── Sea-typescript.ts ├── Sea.d.ts ├── Sea.html ├── Sea.hx ├── Sea.js ├── easeljs │ └── easeljs.d.ts ├── images │ └── bg.png ├── preloadjs │ └── preloadjs.d.ts ├── soundjs │ └── SoundJS.d.ts ├── sounds │ └── bubbles.mp3 └── tweenjs │ └── TweenJS.d.ts └── web-test.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.DB 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CreateJS Toolkit definitions generator 2 | ====================================== 3 | 4 | Generate definition files for various languages from Adobe Flash CC's HTML5 output. 5 | 6 | _Adobe Flash CC (or CS6 with the CreateJS Toolkit) allows 7 | you to publish animated assets for use with the CreateJS suite of open source JS libraries to create rich, 8 | interactive experiences for HTML5._ 9 | 10 | JSFL version 11 | ------- 12 | 13 | **Download the scripts:** 14 | 15 | * [Generate Typescript Definitions.jsfl](https://raw.github.com/elsassph/createjs-def/master/jsfl/Generate%20Typescript%20Definitions.jsfl) 16 | * [Generate Haxe Definitions.jsfl](https://raw.github.com/elsassph/createjs-def/master/jsfl/Generate%20Haxe%20Definitions.jsfl) 17 | 18 | You can copy them in your Flash Professional commands: 19 | * C:\Users\username\AppData\Local\Adobe\Flash CC\language\Configuration\ 20 | * /Users/username/Library/Application Support/Adobe/Flash CC/language/Configuration/ 21 | 22 | **No configuration needed,** it automatically reads the HTML5 Publish Settings or CreateJS Toolkit's metadatas to find where the JS file is located! 23 | 24 | Hint: you can add a shortcut to the command in Flash Pro Keyboard Shortcuts settings. 25 | 26 | 27 | Node.js version 28 | ------- 29 | 30 | **Installation:** 31 | 32 | npm install -g createjs-def 33 | 34 | **Usage:** 35 | 36 | createjs-def typescript animation-lib.js > animation-lib.d.ts 37 | createjs-def haxe animation-lib.js > AnimationLib.hx 38 | 39 | Node.js code 40 | ------ 41 | 42 | Can be used in your own grunt task or in a custom javascript file you created. 43 | 44 | **Usage** 45 | 46 | var fs = require("fs"); 47 | var createjs = require('createjs-def'); 48 | 49 | var animation_data = fs.readFileSync('animation-lib.js'); 50 | var data = createjs.createDef(animation_data, 'typescript'); 51 | fs.writeFile('animation-lib.d.ts', data); 52 | -------------------------------------------------------------------------------- /bin/createjs-def: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | if (process.argv.length < 4) { 3 | console.log("createjs-format []"); 4 | process.exit(); 5 | } 6 | var format = process.argv[2]; 7 | var fileName = process.argv[3]; 8 | var easeljsPath = process.argv[4]; 9 | 10 | if (easeljsPath == null) { 11 | easeljsPath = "easeljs/easeljs.d.ts"; 12 | } 13 | 14 | var fs = require("fs"); 15 | 16 | fs.readFile(fileName, "utf8", function(err, data) { 17 | 18 | if (err) { 19 | console.log(err); 20 | return; 21 | } 22 | 23 | var jsp = require("../lib/parse-js"); 24 | var ast = jsp.parse(data); 25 | 26 | var builder = require("../lib/model"); 27 | var model = builder.parse(ast[1]); 28 | 29 | var formatter = require("../lib/formatter"); 30 | var out = formatter[format](model, easeljsPath); 31 | console.log(out); 32 | }); 33 | -------------------------------------------------------------------------------- /jsfl/build.bat: -------------------------------------------------------------------------------- 1 | call browserify typescript-gen.js -o "Generate Typescript Definitions.jsfl" 2 | call browserify haxe-gen.js -o "Generate Haxe Definitions.jsfl" 3 | -------------------------------------------------------------------------------- /jsfl/build.sh: -------------------------------------------------------------------------------- 1 | browserify typescript-gen.js -o 'Generate Typescript Definitions.jsfl' 2 | browserify haxe-gen.js -o 'Generate Haxe Definitions.jsfl' 3 | -------------------------------------------------------------------------------- /jsfl/haxe-gen.js: -------------------------------------------------------------------------------- 1 | var fpex = require("../lib/flashpro-export"); 2 | fpex.run("haxe", ".hx", true); -------------------------------------------------------------------------------- /jsfl/typescript-gen.js: -------------------------------------------------------------------------------- 1 | var fpex = require("../lib/flashpro-export"); 2 | fpex.run("typescript", ".d.ts"); -------------------------------------------------------------------------------- /lib/flashpro-export.js: -------------------------------------------------------------------------------- 1 | 2 | var DOC_DATA_NAME = "CreateJSToolkit_data"; 3 | var doc; 4 | var props; 5 | var jsFile; 6 | var defFile; 7 | 8 | exports.run = function(format, ext, safeClassName) { 9 | if (!getDocument()) fl.trace("No document open"); 10 | else if (!getProps()) fl.trace("No CreateJS export data"); 11 | else if (!getOutput(ext, safeClassName)) fl.trace("You must first publish the animation using the CreateJS Toolkit"); 12 | else generateDefinitions(format); 13 | } 14 | 15 | function getDocument() { 16 | doc = fl.getDocumentDOM(); 17 | return doc != null; 18 | } 19 | 20 | function getProps() { 21 | props = null; 22 | 23 | // HTML5 FLAs 24 | var profiles = XML(doc.exportPublishProfileString()).PublishProperties; 25 | for(var i=0; i\n\n" 55 | + "declare module " + model.namespaces[0] + " {\n\n" 56 | + out 57 | + "}\n"; 58 | return out; 59 | } 60 | 61 | exports.typescript = formatTypescript; 62 | exports.ts = formatTypescript; 63 | 64 | 65 | function formatHaxe(model) { 66 | 67 | var out = ""; 68 | var known = {}; 69 | var imports = []; 70 | 71 | function importType(bname) { 72 | if (easeljs[bname]) bname = "createjs.easeljs." + bname; 73 | if (!known[bname]) { 74 | known[bname] = true; 75 | if (bname.indexOf(".") > 0) 76 | imports.push("import " + bname + ";"); 77 | } 78 | } 79 | 80 | function safeType(cname) { 81 | cname = cname.split(".").pop(); 82 | return cname.charAt(0).toUpperCase() + cname.substr(1); 83 | } 84 | 85 | out += "@:native(\"lib.properties\")\n" 86 | + "extern class Properties {\n" 87 | + "\tpublic static var width:Int;\n" 88 | + "\tpublic static var height:Int;\n" 89 | + "\tpublic static var fps:Int;\n" 90 | + "\tpublic static var color:Int;\n" 91 | + "\tpublic static var manifest:Dynamic;\n" 92 | + "}\n\n"; 93 | 94 | for(var i in model.classes) { 95 | var classDef = model.classes[i]; 96 | var cname = safeType(classDef.name); 97 | known[cname] = true; 98 | } 99 | 100 | for(var i in model.classes) { 101 | var classDef = model.classes[i]; 102 | 103 | var cname = safeType(classDef.name); 104 | var bname = classDef.base; 105 | importType(bname); 106 | 107 | out += "@:native(\"" + classDef.name + "\")\n"; 108 | out += "extern class " + cname + " extends " + bname + " {\n"; 109 | 110 | if (classDef.bounds) { 111 | out += "\tstatic public var nominalBounds:Rectangle;\n"; 112 | importType("Rectangle"); 113 | } 114 | 115 | for(var j in classDef.children) { 116 | var child = classDef.children[j]; 117 | var ctype = safeType(child.type); 118 | importType(ctype); 119 | out += "\tpublic var " + child.name + ":" + ctype + ";\n"; 120 | } 121 | out += "}\n\n"; 122 | } 123 | 124 | 125 | out = "package " + model.namespaces[0] + ";\n\n" 126 | + imports.join("\n") + "\n\n" 127 | + out; 128 | return out; 129 | } 130 | 131 | exports.haxe = formatHaxe; 132 | exports.hx = formatHaxe; 133 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | module.exports = {}; 2 | module.exports.formatter = require('./formatter'); 3 | module.exports.model = require('./model'); 4 | module.exports.parseJs = require('./parse-js'); 5 | module.exports.createDef = function(data, format) 6 | { 7 | // @todo check if file is of correct format 8 | var jsp = createjs_def.parseJs; 9 | var ast = jsp.parse(data); 10 | 11 | var builder = createjs_def.model; 12 | var model = builder.parse(ast[1]); 13 | 14 | var formatter = createjs_def.formatter; 15 | return formatter[format](model); 16 | } -------------------------------------------------------------------------------- /lib/model.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Parse a generated (by CreateJS Toolkit) JavaScript library 3 | * and create a simplified model of the classes 4 | */ 5 | 6 | 7 | function isArray(v) { 8 | return v && (typeof v == "object") && (typeof v.push != "undefined"); 9 | } 10 | 11 | function dump(a, tab) { 12 | var out = ""; 13 | if (!tab) tab = ""; 14 | for(var i in a) { 15 | var v = a[i]; 16 | if (isArray(v)) 17 | out += dump(v, tab+" "); 18 | else 19 | out += tab + v + "\n"; 20 | } 21 | return out; 22 | } 23 | 24 | function flatten(a, maxDepth) { 25 | if (!isArray(a)) return [a]; 26 | var out = []; 27 | for(var i in a) { 28 | var v = a[i]; 29 | if (isArray(v)) { 30 | if (maxDepth != 0) 31 | out = out.concat(flatten(v, maxDepth-1)); 32 | else 33 | out.push(v); 34 | } 35 | else 36 | out.push(v); 37 | } 38 | return out; 39 | } 40 | 41 | function extract(a, pattern) { 42 | var out = []; 43 | for(var i=0; i") out.push(a[i]); 45 | else if (a[i] != pattern[i]) return null; 46 | } 47 | return out; 48 | } 49 | 50 | function extractNum(a) { 51 | var sign = 1; 52 | if (a[0] == "unary-prefix" && a[1] == "-") { 53 | sign = -1; 54 | a = a[2]; 55 | } 56 | if (a[0] == "num") return sign * a[1]; 57 | return 0; 58 | } 59 | 60 | function extractType(typeDef) { 61 | var typeSig = flatten(typeDef, 1); 62 | // other symbol 63 | var res = extract(typeSig, ["dot", "name", "", ""]); 64 | if (res) return res.join("."); 65 | // base type 66 | res = extract(typeSig, ["name", ""]); 67 | return ""+res; 68 | } 69 | 70 | function extractChildren(bodyDef) { 71 | var children = []; 72 | // is the body valid? 73 | var bodySig = flatten(bodyDef, 0); 74 | var res = extract(bodySig, ["function", null, "", ""]); 75 | if (!res) return children; 76 | // extract child definitions 77 | var defs = res[1]; 78 | for(var i=0; i", "", "new", "", ""]); 81 | if (res) { 82 | var typeName = extractType(res[2]); 83 | children.push({ name:res[1], type:typeName }); 84 | } 85 | } 86 | return children; 87 | } 88 | 89 | function extractClass(classSig, extendsSig) { 90 | if (classSig[0] != "assign") return null; 91 | 92 | // check class declaration 93 | var classDef = flatten(classSig[2]); 94 | var extendsDef = flatten(extendsSig); 95 | //console.log("class?", classDef, extendsDef); 96 | var res = extract(classDef, ["dot", "name", "", ""]); // class name 97 | var res2 = extract(extendsDef, ["new", "dot", "name", "cjs", ""]); // base class 98 | if (!res || !res2) return null; 99 | // it's a valid class 100 | var sig = { 101 | name: res.join("."), 102 | base: res2[0], 103 | children: extractChildren(classSig[3]) 104 | }; 105 | //console.info("new class", sig.name, "extends", sig.base); 106 | return sig; 107 | } 108 | 109 | function extractBounds(a) { 110 | return [ extractNum(a[0]), extractNum(a[1]), extractNum(a[2]), extractNum(a[3])]; 111 | } 112 | 113 | function parseTopLevel(ast) { 114 | 115 | var struct = flatten(ast, 1); 116 | var res = extract(struct, ["stat", "", "var", ""]); 117 | if (!res) return null; 118 | 119 | var ns = flatten(res[1]); 120 | var defs = flatten(res[0], 2); 121 | 122 | var classes = []; 123 | var curClass = null; 124 | for(var i=0; i", "prototype", "assign", true, "", ""]); 130 | if (res) { 131 | var newClass = extractClass(res[0], res[2]); 132 | if (newClass != null) { 133 | curClass = newClass; 134 | classes.push(newClass); 135 | } 136 | } 137 | else if (curClass) { 138 | // is it the previously defined class' nominalBounds? 139 | res = extract(sig, ["stat", "assign", true, "dot", "", "nominalBounds", "new", "", ""]); 140 | if (res && isArray(res[2])) { 141 | curClass.bounds = extractBounds(res[2]); 142 | //console.info("with bounds", curClass.bounds); 143 | } 144 | // unknown 145 | //else console.info("???", sig); 146 | } 147 | } 148 | 149 | return { 150 | namespaces: ns, 151 | classes: classes 152 | } 153 | } 154 | 155 | exports.parse = parseTopLevel; 156 | -------------------------------------------------------------------------------- /lib/parse-js.js: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | 3 | A JavaScript tokenizer / parser / beautifier / compressor. 4 | 5 | This version is suitable for Node.js. With minimal changes (the 6 | exports stuff) it should work on any JS platform. 7 | 8 | This file contains the tokenizer/parser. It is a port to JavaScript 9 | of parse-js [1], a JavaScript parser library written in Common Lisp 10 | by Marijn Haverbeke. Thank you Marijn! 11 | 12 | [1] http://marijn.haverbeke.nl/parse-js/ 13 | 14 | Exported functions: 15 | 16 | - tokenizer(code) -- returns a function. Call the returned 17 | function to fetch the next token. 18 | 19 | - parse(code) -- returns an AST of the given JavaScript code. 20 | 21 | -------------------------------- (C) --------------------------------- 22 | 23 | Author: Mihai Bazon 24 | 25 | http://mihai.bazon.net/blog 26 | 27 | Distributed under the BSD license: 28 | 29 | Copyright 2010 (c) Mihai Bazon 30 | Based on parse-js (http://marijn.haverbeke.nl/parse-js/). 31 | 32 | Redistribution and use in source and binary forms, with or without 33 | modification, are permitted provided that the following conditions 34 | are met: 35 | 36 | * Redistributions of source code must retain the above 37 | copyright notice, this list of conditions and the following 38 | disclaimer. 39 | 40 | * Redistributions in binary form must reproduce the above 41 | copyright notice, this list of conditions and the following 42 | disclaimer in the documentation and/or other materials 43 | provided with the distribution. 44 | 45 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY 46 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 47 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 48 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE 49 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 50 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 51 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 52 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 53 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 54 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 55 | THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 56 | SUCH DAMAGE. 57 | 58 | ***********************************************************************/ 59 | 60 | /* -----[ Tokenizer (constants) ]----- */ 61 | 62 | var KEYWORDS = array_to_hash([ 63 | "break", 64 | "case", 65 | "catch", 66 | "const", 67 | "continue", 68 | "debugger", 69 | "default", 70 | "delete", 71 | "do", 72 | "else", 73 | "finally", 74 | "for", 75 | "function", 76 | "if", 77 | "in", 78 | "instanceof", 79 | "new", 80 | "return", 81 | "switch", 82 | "throw", 83 | "try", 84 | "typeof", 85 | "var", 86 | "void", 87 | "while", 88 | "with" 89 | ]); 90 | 91 | var RESERVED_WORDS = array_to_hash([ 92 | "abstract", 93 | "boolean", 94 | "byte", 95 | "char", 96 | "class", 97 | "double", 98 | "enum", 99 | "export", 100 | "extends", 101 | "final", 102 | "float", 103 | "goto", 104 | "implements", 105 | "import", 106 | "int", 107 | "interface", 108 | "long", 109 | "native", 110 | "package", 111 | "private", 112 | "protected", 113 | "public", 114 | "short", 115 | "static", 116 | "super", 117 | "synchronized", 118 | "throws", 119 | "transient", 120 | "volatile" 121 | ]); 122 | 123 | var KEYWORDS_BEFORE_EXPRESSION = array_to_hash([ 124 | "return", 125 | "new", 126 | "delete", 127 | "throw", 128 | "else", 129 | "case" 130 | ]); 131 | 132 | var KEYWORDS_ATOM = array_to_hash([ 133 | "false", 134 | "null", 135 | "true", 136 | "undefined" 137 | ]); 138 | 139 | var OPERATOR_CHARS = array_to_hash(characters("+-*&%=<>!?|~^")); 140 | 141 | var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i; 142 | var RE_OCT_NUMBER = /^0[0-7]+$/; 143 | var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i; 144 | 145 | var OPERATORS = array_to_hash([ 146 | "in", 147 | "instanceof", 148 | "typeof", 149 | "new", 150 | "void", 151 | "delete", 152 | "++", 153 | "--", 154 | "+", 155 | "-", 156 | "!", 157 | "~", 158 | "&", 159 | "|", 160 | "^", 161 | "*", 162 | "/", 163 | "%", 164 | ">>", 165 | "<<", 166 | ">>>", 167 | "<", 168 | ">", 169 | "<=", 170 | ">=", 171 | "==", 172 | "===", 173 | "!=", 174 | "!==", 175 | "?", 176 | "=", 177 | "+=", 178 | "-=", 179 | "/=", 180 | "*=", 181 | "%=", 182 | ">>=", 183 | "<<=", 184 | ">>>=", 185 | "|=", 186 | "^=", 187 | "&=", 188 | "&&", 189 | "||" 190 | ]); 191 | 192 | var WHITESPACE_CHARS = array_to_hash(characters(" \u00a0\n\r\t\f\u000b\u200b\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\uFEFF")); 193 | 194 | var PUNC_BEFORE_EXPRESSION = array_to_hash(characters("[{(,.;:")); 195 | 196 | var PUNC_CHARS = array_to_hash(characters("[]{}(),;:")); 197 | 198 | var REGEXP_MODIFIERS = array_to_hash(characters("gmsiy")); 199 | 200 | /* -----[ Tokenizer ]----- */ 201 | 202 | var UNICODE = { // Unicode 6.1 203 | letter: new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0\\u08A2-\\u08AC\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F0\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA697\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA793\\uA7A0-\\uA7AA\\uA7F8-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA80-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"), 204 | combining_mark: new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065F\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0859-\\u085B\\u08E4-\\u08FE\\u0900-\\u0903\\u093A-\\u093C\\u093E-\\u094F\\u0951-\\u0957\\u0962\\u0963\\u0981-\\u0983\\u09BC\\u09BE-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CD\\u09D7\\u09E2\\u09E3\\u0A01-\\u0A03\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81-\\u0A83\\u0ABC\\u0ABE-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AE2\\u0AE3\\u0B01-\\u0B03\\u0B3C\\u0B3E-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B62\\u0B63\\u0B82\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD7\\u0C01-\\u0C03\\u0C3E-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0C82\\u0C83\\u0CBC\\u0CBE-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CE2\\u0CE3\\u0D02\\u0D03\\u0D3E-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4D\\u0D57\\u0D62\\u0D63\\u0D82\\u0D83\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F3E\\u0F3F\\u0F71-\\u0F84\\u0F86\\u0F87\\u0F8D-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102B-\\u103E\\u1056-\\u1059\\u105E-\\u1060\\u1062-\\u1064\\u1067-\\u106D\\u1071-\\u1074\\u1082-\\u108D\\u108F\\u109A-\\u109D\\u135D-\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B4-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u192B\\u1930-\\u193B\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A17-\\u1A1B\\u1A55-\\u1A5E\\u1A60-\\u1A7C\\u1A7F\\u1B00-\\u1B04\\u1B34-\\u1B44\\u1B6B-\\u1B73\\u1B80-\\u1B82\\u1BA1-\\u1BAD\\u1BE6-\\u1BF3\\u1C24-\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE8\\u1CED\\u1CF2-\\u1CF4\\u1DC0-\\u1DE6\\u1DFC-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2D7F\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA674-\\uA67D\\uA69F\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA823-\\uA827\\uA880\\uA881\\uA8B4-\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA953\\uA980-\\uA983\\uA9B3-\\uA9C0\\uAA29-\\uAA36\\uAA43\\uAA4C\\uAA4D\\uAA7B\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uAAEB-\\uAAEF\\uAAF5\\uAAF6\\uABE3-\\uABEA\\uABEC\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"), 205 | connector_punctuation: new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]"), 206 | digit: new RegExp("[\\u0030-\\u0039\\u0660-\\u0669\\u06F0-\\u06F9\\u07C0-\\u07C9\\u0966-\\u096F\\u09E6-\\u09EF\\u0A66-\\u0A6F\\u0AE6-\\u0AEF\\u0B66-\\u0B6F\\u0BE6-\\u0BEF\\u0C66-\\u0C6F\\u0CE6-\\u0CEF\\u0D66-\\u0D6F\\u0E50-\\u0E59\\u0ED0-\\u0ED9\\u0F20-\\u0F29\\u1040-\\u1049\\u1090-\\u1099\\u17E0-\\u17E9\\u1810-\\u1819\\u1946-\\u194F\\u19D0-\\u19D9\\u1A80-\\u1A89\\u1A90-\\u1A99\\u1B50-\\u1B59\\u1BB0-\\u1BB9\\u1C40-\\u1C49\\u1C50-\\u1C59\\uA620-\\uA629\\uA8D0-\\uA8D9\\uA900-\\uA909\\uA9D0-\\uA9D9\\uAA50-\\uAA59\\uABF0-\\uABF9\\uFF10-\\uFF19]") 207 | }; 208 | 209 | function is_letter(ch) { 210 | return UNICODE.letter.test(ch); 211 | }; 212 | 213 | function is_digit(ch) { 214 | ch = ch.charCodeAt(0); 215 | return ch >= 48 && ch <= 57; 216 | }; 217 | 218 | function is_unicode_digit(ch) { 219 | return UNICODE.digit.test(ch); 220 | } 221 | 222 | function is_alphanumeric_char(ch) { 223 | return is_digit(ch) || is_letter(ch); 224 | }; 225 | 226 | function is_unicode_combining_mark(ch) { 227 | return UNICODE.combining_mark.test(ch); 228 | }; 229 | 230 | function is_unicode_connector_punctuation(ch) { 231 | return UNICODE.connector_punctuation.test(ch); 232 | }; 233 | 234 | function is_identifier_start(ch) { 235 | return ch == "$" || ch == "_" || is_letter(ch); 236 | }; 237 | 238 | function is_identifier_char(ch) { 239 | return is_identifier_start(ch) 240 | || is_unicode_combining_mark(ch) 241 | || is_unicode_digit(ch) 242 | || is_unicode_connector_punctuation(ch) 243 | || ch == "\u200c" // zero-width non-joiner 244 | || ch == "\u200d" // zero-width joiner (in my ECMA-262 PDF, this is also 200c) 245 | ; 246 | }; 247 | 248 | function parse_js_number(num) { 249 | if (RE_HEX_NUMBER.test(num)) { 250 | return parseInt(num.substr(2), 16); 251 | } else if (RE_OCT_NUMBER.test(num)) { 252 | return parseInt(num.substr(1), 8); 253 | } else if (RE_DEC_NUMBER.test(num)) { 254 | return parseFloat(num); 255 | } 256 | }; 257 | 258 | function JS_Parse_Error(message, line, col, pos) { 259 | this.message = message; 260 | this.line = line + 1; 261 | this.col = col + 1; 262 | this.pos = pos + 1; 263 | this.stack = new Error().stack; 264 | }; 265 | 266 | JS_Parse_Error.prototype.toString = function() { 267 | return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack; 268 | }; 269 | 270 | function js_error(message, line, col, pos) { 271 | throw new JS_Parse_Error(message, line, col, pos); 272 | }; 273 | 274 | function is_token(token, type, val) { 275 | return token.type == type && (val == null || token.value == val); 276 | }; 277 | 278 | var EX_EOF = {}; 279 | 280 | function tokenizer($TEXT) { 281 | 282 | var S = { 283 | text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''), 284 | pos : 0, 285 | tokpos : 0, 286 | line : 0, 287 | tokline : 0, 288 | col : 0, 289 | tokcol : 0, 290 | newline_before : false, 291 | regex_allowed : false, 292 | comments_before : [] 293 | }; 294 | 295 | function peek() { return S.text.charAt(S.pos); }; 296 | 297 | function next(signal_eof, in_string) { 298 | var ch = S.text.charAt(S.pos++); 299 | if (signal_eof && !ch) 300 | throw EX_EOF; 301 | if (ch == "\n") { 302 | S.newline_before = S.newline_before || !in_string; 303 | ++S.line; 304 | S.col = 0; 305 | } else { 306 | ++S.col; 307 | } 308 | return ch; 309 | }; 310 | 311 | function eof() { 312 | return !S.peek(); 313 | }; 314 | 315 | function find(what, signal_eof) { 316 | var pos = S.text.indexOf(what, S.pos); 317 | if (signal_eof && pos == -1) throw EX_EOF; 318 | return pos; 319 | }; 320 | 321 | function start_token() { 322 | S.tokline = S.line; 323 | S.tokcol = S.col; 324 | S.tokpos = S.pos; 325 | }; 326 | 327 | function token(type, value, is_comment) { 328 | S.regex_allowed = ((type == "operator" && !HOP(UNARY_POSTFIX, value)) || 329 | (type == "keyword" && HOP(KEYWORDS_BEFORE_EXPRESSION, value)) || 330 | (type == "punc" && HOP(PUNC_BEFORE_EXPRESSION, value))); 331 | var ret = { 332 | type : type, 333 | value : value, 334 | line : S.tokline, 335 | col : S.tokcol, 336 | pos : S.tokpos, 337 | endpos : S.pos, 338 | nlb : S.newline_before 339 | }; 340 | if (!is_comment) { 341 | ret.comments_before = S.comments_before; 342 | S.comments_before = []; 343 | // make note of any newlines in the comments that came before 344 | for (var i = 0, len = ret.comments_before.length; i < len; i++) { 345 | ret.nlb = ret.nlb || ret.comments_before[i].nlb; 346 | } 347 | } 348 | S.newline_before = false; 349 | return ret; 350 | }; 351 | 352 | function skip_whitespace() { 353 | while (HOP(WHITESPACE_CHARS, peek())) 354 | next(); 355 | }; 356 | 357 | function read_while(pred) { 358 | var ret = "", ch = peek(), i = 0; 359 | while (ch && pred(ch, i++)) { 360 | ret += next(); 361 | ch = peek(); 362 | } 363 | return ret; 364 | }; 365 | 366 | function parse_error(err) { 367 | js_error(err, S.tokline, S.tokcol, S.tokpos); 368 | }; 369 | 370 | function read_num(prefix) { 371 | var has_e = false, after_e = false, has_x = false, has_dot = prefix == "."; 372 | var num = read_while(function(ch, i){ 373 | if (ch == "x" || ch == "X") { 374 | if (has_x) return false; 375 | return has_x = true; 376 | } 377 | if (!has_x && (ch == "E" || ch == "e")) { 378 | if (has_e) return false; 379 | return has_e = after_e = true; 380 | } 381 | if (ch == "-") { 382 | if (after_e || (i == 0 && !prefix)) return true; 383 | return false; 384 | } 385 | if (ch == "+") return after_e; 386 | after_e = false; 387 | if (ch == ".") { 388 | if (!has_dot && !has_x && !has_e) 389 | return has_dot = true; 390 | return false; 391 | } 392 | return is_alphanumeric_char(ch); 393 | }); 394 | if (prefix) 395 | num = prefix + num; 396 | var valid = parse_js_number(num); 397 | if (!isNaN(valid)) { 398 | return token("num", valid); 399 | } else { 400 | parse_error("Invalid syntax: " + num); 401 | } 402 | }; 403 | 404 | function read_escaped_char(in_string) { 405 | var ch = next(true, in_string); 406 | switch (ch) { 407 | case "n" : return "\n"; 408 | case "r" : return "\r"; 409 | case "t" : return "\t"; 410 | case "b" : return "\b"; 411 | case "v" : return "\u000b"; 412 | case "f" : return "\f"; 413 | case "0" : return "\0"; 414 | case "x" : return String.fromCharCode(hex_bytes(2)); 415 | case "u" : return String.fromCharCode(hex_bytes(4)); 416 | case "\n": return ""; 417 | default : return ch; 418 | } 419 | }; 420 | 421 | function hex_bytes(n) { 422 | var num = 0; 423 | for (; n > 0; --n) { 424 | var digit = parseInt(next(true), 16); 425 | if (isNaN(digit)) 426 | parse_error("Invalid hex-character pattern in string"); 427 | num = (num << 4) | digit; 428 | } 429 | return num; 430 | }; 431 | 432 | function read_string() { 433 | return with_eof_error("Unterminated string constant", function(){ 434 | var quote = next(), ret = ""; 435 | for (;;) { 436 | var ch = next(true); 437 | if (ch == "\\") { 438 | // read OctalEscapeSequence (XXX: deprecated if "strict mode") 439 | // https://github.com/mishoo/UglifyJS/issues/178 440 | var octal_len = 0, first = null; 441 | ch = read_while(function(ch){ 442 | if (ch >= "0" && ch <= "7") { 443 | if (!first) { 444 | first = ch; 445 | return ++octal_len; 446 | } 447 | else if (first <= "3" && octal_len <= 2) return ++octal_len; 448 | else if (first >= "4" && octal_len <= 1) return ++octal_len; 449 | } 450 | return false; 451 | }); 452 | if (octal_len > 0) ch = String.fromCharCode(parseInt(ch, 8)); 453 | else ch = read_escaped_char(true); 454 | } 455 | else if (ch == quote) break; 456 | else if (ch == "\n") throw EX_EOF; 457 | ret += ch; 458 | } 459 | return token("string", ret); 460 | }); 461 | }; 462 | 463 | function read_line_comment() { 464 | next(); 465 | var i = find("\n"), ret; 466 | if (i == -1) { 467 | ret = S.text.substr(S.pos); 468 | S.pos = S.text.length; 469 | } else { 470 | ret = S.text.substring(S.pos, i); 471 | S.pos = i; 472 | } 473 | return token("comment1", ret, true); 474 | }; 475 | 476 | function read_multiline_comment() { 477 | next(); 478 | return with_eof_error("Unterminated multiline comment", function(){ 479 | var i = find("*/", true), 480 | text = S.text.substring(S.pos, i); 481 | S.pos = i + 2; 482 | S.line += text.split("\n").length - 1; 483 | S.newline_before = S.newline_before || text.indexOf("\n") >= 0; 484 | 485 | // https://github.com/mishoo/UglifyJS/issues/#issue/100 486 | if (/^@cc_on/i.test(text)) { 487 | warn("WARNING: at line " + S.line); 488 | warn("*** Found \"conditional comment\": " + text); 489 | warn("*** UglifyJS DISCARDS ALL COMMENTS. This means your code might no longer work properly in Internet Explorer."); 490 | } 491 | 492 | return token("comment2", text, true); 493 | }); 494 | }; 495 | 496 | function read_name() { 497 | var backslash = false, name = "", ch, escaped = false, hex; 498 | while ((ch = peek()) != null) { 499 | if (!backslash) { 500 | if (ch == "\\") escaped = backslash = true, next(); 501 | else if (is_identifier_char(ch)) name += next(); 502 | else break; 503 | } 504 | else { 505 | if (ch != "u") parse_error("Expecting UnicodeEscapeSequence -- uXXXX"); 506 | ch = read_escaped_char(); 507 | if (!is_identifier_char(ch)) parse_error("Unicode char: " + ch.charCodeAt(0) + " is not valid in identifier"); 508 | name += ch; 509 | backslash = false; 510 | } 511 | } 512 | if (HOP(KEYWORDS, name) && escaped) { 513 | hex = name.charCodeAt(0).toString(16).toUpperCase(); 514 | name = "\\u" + "0000".substr(hex.length) + hex + name.slice(1); 515 | } 516 | return name; 517 | }; 518 | 519 | function read_regexp(regexp) { 520 | return with_eof_error("Unterminated regular expression", function(){ 521 | var prev_backslash = false, ch, in_class = false; 522 | while ((ch = next(true))) if (prev_backslash) { 523 | regexp += "\\" + ch; 524 | prev_backslash = false; 525 | } else if (ch == "[") { 526 | in_class = true; 527 | regexp += ch; 528 | } else if (ch == "]" && in_class) { 529 | in_class = false; 530 | regexp += ch; 531 | } else if (ch == "/" && !in_class) { 532 | break; 533 | } else if (ch == "\\") { 534 | prev_backslash = true; 535 | } else { 536 | regexp += ch; 537 | } 538 | var mods = read_name(); 539 | return token("regexp", [ regexp, mods ]); 540 | }); 541 | }; 542 | 543 | function read_operator(prefix) { 544 | function grow(op) { 545 | if (!peek()) return op; 546 | var bigger = op + peek(); 547 | if (HOP(OPERATORS, bigger)) { 548 | next(); 549 | return grow(bigger); 550 | } else { 551 | return op; 552 | } 553 | }; 554 | return token("operator", grow(prefix || next())); 555 | }; 556 | 557 | function handle_slash() { 558 | next(); 559 | var regex_allowed = S.regex_allowed; 560 | switch (peek()) { 561 | case "/": 562 | S.comments_before.push(read_line_comment()); 563 | S.regex_allowed = regex_allowed; 564 | return next_token(); 565 | case "*": 566 | S.comments_before.push(read_multiline_comment()); 567 | S.regex_allowed = regex_allowed; 568 | return next_token(); 569 | } 570 | return S.regex_allowed ? read_regexp("") : read_operator("/"); 571 | }; 572 | 573 | function handle_dot() { 574 | next(); 575 | return is_digit(peek()) 576 | ? read_num(".") 577 | : token("punc", "."); 578 | }; 579 | 580 | function read_word() { 581 | var word = read_name(); 582 | return !HOP(KEYWORDS, word) 583 | ? token("name", word) 584 | : HOP(OPERATORS, word) 585 | ? token("operator", word) 586 | : HOP(KEYWORDS_ATOM, word) 587 | ? token("atom", word) 588 | : token("keyword", word); 589 | }; 590 | 591 | function with_eof_error(eof_error, cont) { 592 | try { 593 | return cont(); 594 | } catch(ex) { 595 | if (ex === EX_EOF) parse_error(eof_error); 596 | else throw ex; 597 | } 598 | }; 599 | 600 | function next_token(force_regexp) { 601 | if (force_regexp != null) 602 | return read_regexp(force_regexp); 603 | skip_whitespace(); 604 | start_token(); 605 | var ch = peek(); 606 | if (!ch) return token("eof"); 607 | if (is_digit(ch)) return read_num(); 608 | if (ch == '"' || ch == "'") return read_string(); 609 | if (HOP(PUNC_CHARS, ch)) return token("punc", next()); 610 | if (ch == ".") return handle_dot(); 611 | if (ch == "/") return handle_slash(); 612 | if (HOP(OPERATOR_CHARS, ch)) return read_operator(); 613 | if (ch == "\\" || is_identifier_start(ch)) return read_word(); 614 | parse_error("Unexpected character '" + ch + "'"); 615 | }; 616 | 617 | next_token.context = function(nc) { 618 | if (nc) S = nc; 619 | return S; 620 | }; 621 | 622 | return next_token; 623 | 624 | }; 625 | 626 | /* -----[ Parser (constants) ]----- */ 627 | 628 | var UNARY_PREFIX = array_to_hash([ 629 | "typeof", 630 | "void", 631 | "delete", 632 | "--", 633 | "++", 634 | "!", 635 | "~", 636 | "-", 637 | "+" 638 | ]); 639 | 640 | var UNARY_POSTFIX = array_to_hash([ "--", "++" ]); 641 | 642 | var ASSIGNMENT = (function(a, ret, i){ 643 | while (i < a.length) { 644 | ret[a[i]] = a[i].substr(0, a[i].length - 1); 645 | i++; 646 | } 647 | return ret; 648 | })( 649 | ["+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&="], 650 | { "=": true }, 651 | 0 652 | ); 653 | 654 | var PRECEDENCE = (function(a, ret){ 655 | for (var i = 0, n = 1; i < a.length; ++i, ++n) { 656 | var b = a[i]; 657 | for (var j = 0; j < b.length; ++j) { 658 | ret[b[j]] = n; 659 | } 660 | } 661 | return ret; 662 | })( 663 | [ 664 | ["||"], 665 | ["&&"], 666 | ["|"], 667 | ["^"], 668 | ["&"], 669 | ["==", "===", "!=", "!=="], 670 | ["<", ">", "<=", ">=", "in", "instanceof"], 671 | [">>", "<<", ">>>"], 672 | ["+", "-"], 673 | ["*", "/", "%"] 674 | ], 675 | {} 676 | ); 677 | 678 | var STATEMENTS_WITH_LABELS = array_to_hash([ "for", "do", "while", "switch" ]); 679 | 680 | var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "name" ]); 681 | 682 | /* -----[ Parser ]----- */ 683 | 684 | function NodeWithToken(str, start, end) { 685 | this.name = str; 686 | this.start = start; 687 | this.end = end; 688 | }; 689 | 690 | NodeWithToken.prototype.toString = function() { return this.name; }; 691 | 692 | function parse($TEXT, exigent_mode, embed_tokens) { 693 | 694 | var S = { 695 | input : typeof $TEXT == "string" ? tokenizer($TEXT, true) : $TEXT, 696 | token : null, 697 | prev : null, 698 | peeked : null, 699 | in_function : 0, 700 | in_directives : true, 701 | in_loop : 0, 702 | labels : [] 703 | }; 704 | 705 | S.token = next(); 706 | 707 | function is(type, value) { 708 | return is_token(S.token, type, value); 709 | }; 710 | 711 | function peek() { return S.peeked || (S.peeked = S.input()); }; 712 | 713 | function next() { 714 | S.prev = S.token; 715 | if (S.peeked) { 716 | S.token = S.peeked; 717 | S.peeked = null; 718 | } else { 719 | S.token = S.input(); 720 | } 721 | S.in_directives = S.in_directives && ( 722 | S.token.type == "string" || is("punc", ";") 723 | ); 724 | return S.token; 725 | }; 726 | 727 | function prev() { 728 | return S.prev; 729 | }; 730 | 731 | function croak(msg, line, col, pos) { 732 | var ctx = S.input.context(); 733 | js_error(msg, 734 | line != null ? line : ctx.tokline, 735 | col != null ? col : ctx.tokcol, 736 | pos != null ? pos : ctx.tokpos); 737 | }; 738 | 739 | function token_error(token, msg) { 740 | croak(msg, token.line, token.col); 741 | }; 742 | 743 | function unexpected(token) { 744 | if (token == null) 745 | token = S.token; 746 | token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")"); 747 | }; 748 | 749 | function expect_token(type, val) { 750 | if (is(type, val)) { 751 | return next(); 752 | } 753 | token_error(S.token, "Unexpected token " + S.token.type + ", expected " + type); 754 | }; 755 | 756 | function expect(punc) { return expect_token("punc", punc); }; 757 | 758 | function can_insert_semicolon() { 759 | return !exigent_mode && ( 760 | S.token.nlb || is("eof") || is("punc", "}") 761 | ); 762 | }; 763 | 764 | function semicolon() { 765 | if (is("punc", ";")) next(); 766 | else if (!can_insert_semicolon()) unexpected(); 767 | }; 768 | 769 | function as() { 770 | return slice(arguments); 771 | }; 772 | 773 | function parenthesised() { 774 | expect("("); 775 | var ex = expression(); 776 | expect(")"); 777 | return ex; 778 | }; 779 | 780 | function add_tokens(str, start, end) { 781 | return str instanceof NodeWithToken ? str : new NodeWithToken(str, start, end); 782 | }; 783 | 784 | function maybe_embed_tokens(parser) { 785 | if (embed_tokens) return function() { 786 | var start = S.token; 787 | var ast = parser.apply(this, arguments); 788 | ast[0] = add_tokens(ast[0], start, prev()); 789 | return ast; 790 | }; 791 | else return parser; 792 | }; 793 | 794 | var statement = maybe_embed_tokens(function() { 795 | if (is("operator", "/") || is("operator", "/=")) { 796 | S.peeked = null; 797 | S.token = S.input(S.token.value.substr(1)); // force regexp 798 | } 799 | switch (S.token.type) { 800 | case "string": 801 | var dir = S.in_directives, stat = simple_statement(); 802 | if (dir && stat[1][0] == "string" && !is("punc", ",")) 803 | return as("directive", stat[1][1]); 804 | return stat; 805 | case "num": 806 | case "regexp": 807 | case "operator": 808 | case "atom": 809 | return simple_statement(); 810 | 811 | case "name": 812 | return is_token(peek(), "punc", ":") 813 | ? labeled_statement(prog1(S.token.value, next, next)) 814 | : simple_statement(); 815 | 816 | case "punc": 817 | switch (S.token.value) { 818 | case "{": 819 | return as("block", block_()); 820 | case "[": 821 | case "(": 822 | return simple_statement(); 823 | case ";": 824 | next(); 825 | return as("block"); 826 | default: 827 | unexpected(); 828 | } 829 | 830 | case "keyword": 831 | switch (prog1(S.token.value, next)) { 832 | case "break": 833 | return break_cont("break"); 834 | 835 | case "continue": 836 | return break_cont("continue"); 837 | 838 | case "debugger": 839 | semicolon(); 840 | return as("debugger"); 841 | 842 | case "do": 843 | return (function(body){ 844 | expect_token("keyword", "while"); 845 | return as("do", prog1(parenthesised, semicolon), body); 846 | })(in_loop(statement)); 847 | 848 | case "for": 849 | return for_(); 850 | 851 | case "function": 852 | return function_(true); 853 | 854 | case "if": 855 | return if_(); 856 | 857 | case "return": 858 | if (S.in_function == 0) 859 | croak("'return' outside of function"); 860 | return as("return", 861 | is("punc", ";") 862 | ? (next(), null) 863 | : can_insert_semicolon() 864 | ? null 865 | : prog1(expression, semicolon)); 866 | 867 | case "switch": 868 | return as("switch", parenthesised(), switch_block_()); 869 | 870 | case "throw": 871 | if (S.token.nlb) 872 | croak("Illegal newline after 'throw'"); 873 | return as("throw", prog1(expression, semicolon)); 874 | 875 | case "try": 876 | return try_(); 877 | 878 | case "var": 879 | return prog1(var_, semicolon); 880 | 881 | case "const": 882 | return prog1(const_, semicolon); 883 | 884 | case "while": 885 | return as("while", parenthesised(), in_loop(statement)); 886 | 887 | case "with": 888 | return as("with", parenthesised(), statement()); 889 | 890 | default: 891 | unexpected(); 892 | } 893 | } 894 | }); 895 | 896 | function labeled_statement(label) { 897 | S.labels.push(label); 898 | var start = S.token, stat = statement(); 899 | if (exigent_mode && !HOP(STATEMENTS_WITH_LABELS, stat[0])) 900 | unexpected(start); 901 | S.labels.pop(); 902 | return as("label", label, stat); 903 | }; 904 | 905 | function simple_statement() { 906 | return as("stat", prog1(expression, semicolon)); 907 | }; 908 | 909 | function break_cont(type) { 910 | var name; 911 | if (!can_insert_semicolon()) { 912 | name = is("name") ? S.token.value : null; 913 | } 914 | if (name != null) { 915 | next(); 916 | if (!member(name, S.labels)) 917 | croak("Label " + name + " without matching loop or statement"); 918 | } 919 | else if (S.in_loop == 0) 920 | croak(type + " not inside a loop or switch"); 921 | semicolon(); 922 | return as(type, name); 923 | }; 924 | 925 | function for_() { 926 | expect("("); 927 | var init = null; 928 | if (!is("punc", ";")) { 929 | init = is("keyword", "var") 930 | ? (next(), var_(true)) 931 | : expression(true, true); 932 | if (is("operator", "in")) { 933 | if (init[0] == "var" && init[1].length > 1) 934 | croak("Only one variable declaration allowed in for..in loop"); 935 | return for_in(init); 936 | } 937 | } 938 | return regular_for(init); 939 | }; 940 | 941 | function regular_for(init) { 942 | expect(";"); 943 | var test = is("punc", ";") ? null : expression(); 944 | expect(";"); 945 | var step = is("punc", ")") ? null : expression(); 946 | expect(")"); 947 | return as("for", init, test, step, in_loop(statement)); 948 | }; 949 | 950 | function for_in(init) { 951 | var lhs = init[0] == "var" ? as("name", init[1][0]) : init; 952 | next(); 953 | var obj = expression(); 954 | expect(")"); 955 | return as("for-in", init, lhs, obj, in_loop(statement)); 956 | }; 957 | 958 | var function_ = function(in_statement) { 959 | var name = is("name") ? prog1(S.token.value, next) : null; 960 | if (in_statement && !name) 961 | unexpected(); 962 | expect("("); 963 | return as(in_statement ? "defun" : "function", 964 | name, 965 | // arguments 966 | (function(first, a){ 967 | while (!is("punc", ")")) { 968 | if (first) first = false; else expect(","); 969 | if (!is("name")) unexpected(); 970 | a.push(S.token.value); 971 | next(); 972 | } 973 | next(); 974 | return a; 975 | })(true, []), 976 | // body 977 | (function(){ 978 | ++S.in_function; 979 | var loop = S.in_loop; 980 | S.in_directives = true; 981 | S.in_loop = 0; 982 | var a = block_(); 983 | --S.in_function; 984 | S.in_loop = loop; 985 | return a; 986 | })()); 987 | }; 988 | 989 | function if_() { 990 | var cond = parenthesised(), body = statement(), belse; 991 | if (is("keyword", "else")) { 992 | next(); 993 | belse = statement(); 994 | } 995 | return as("if", cond, body, belse); 996 | }; 997 | 998 | function block_() { 999 | expect("{"); 1000 | var a = []; 1001 | while (!is("punc", "}")) { 1002 | if (is("eof")) unexpected(); 1003 | a.push(statement()); 1004 | } 1005 | next(); 1006 | return a; 1007 | }; 1008 | 1009 | var switch_block_ = curry(in_loop, function(){ 1010 | expect("{"); 1011 | var a = [], cur = null; 1012 | while (!is("punc", "}")) { 1013 | if (is("eof")) unexpected(); 1014 | if (is("keyword", "case")) { 1015 | next(); 1016 | cur = []; 1017 | a.push([ expression(), cur ]); 1018 | expect(":"); 1019 | } 1020 | else if (is("keyword", "default")) { 1021 | next(); 1022 | expect(":"); 1023 | cur = []; 1024 | a.push([ null, cur ]); 1025 | } 1026 | else { 1027 | if (!cur) unexpected(); 1028 | cur.push(statement()); 1029 | } 1030 | } 1031 | next(); 1032 | return a; 1033 | }); 1034 | 1035 | function try_() { 1036 | var body = block_(), bcatch, bfinally; 1037 | if (is("keyword", "catch")) { 1038 | next(); 1039 | expect("("); 1040 | if (!is("name")) 1041 | croak("Name expected"); 1042 | var name = S.token.value; 1043 | next(); 1044 | expect(")"); 1045 | bcatch = [ name, block_() ]; 1046 | } 1047 | if (is("keyword", "finally")) { 1048 | next(); 1049 | bfinally = block_(); 1050 | } 1051 | if (!bcatch && !bfinally) 1052 | croak("Missing catch/finally blocks"); 1053 | return as("try", body, bcatch, bfinally); 1054 | }; 1055 | 1056 | function vardefs(no_in) { 1057 | var a = []; 1058 | for (;;) { 1059 | if (!is("name")) 1060 | unexpected(); 1061 | var name = S.token.value; 1062 | next(); 1063 | if (is("operator", "=")) { 1064 | next(); 1065 | a.push([ name, expression(false, no_in) ]); 1066 | } else { 1067 | a.push([ name ]); 1068 | } 1069 | if (!is("punc", ",")) 1070 | break; 1071 | next(); 1072 | } 1073 | return a; 1074 | }; 1075 | 1076 | function var_(no_in) { 1077 | return as("var", vardefs(no_in)); 1078 | }; 1079 | 1080 | function const_() { 1081 | return as("const", vardefs()); 1082 | }; 1083 | 1084 | function new_() { 1085 | var newexp = expr_atom(false), args; 1086 | if (is("punc", "(")) { 1087 | next(); 1088 | args = expr_list(")"); 1089 | } else { 1090 | args = []; 1091 | } 1092 | return subscripts(as("new", newexp, args), true); 1093 | }; 1094 | 1095 | var expr_atom = maybe_embed_tokens(function(allow_calls) { 1096 | if (is("operator", "new")) { 1097 | next(); 1098 | return new_(); 1099 | } 1100 | if (is("punc")) { 1101 | switch (S.token.value) { 1102 | case "(": 1103 | next(); 1104 | return subscripts(prog1(expression, curry(expect, ")")), allow_calls); 1105 | case "[": 1106 | next(); 1107 | return subscripts(array_(), allow_calls); 1108 | case "{": 1109 | next(); 1110 | return subscripts(object_(), allow_calls); 1111 | } 1112 | unexpected(); 1113 | } 1114 | if (is("keyword", "function")) { 1115 | next(); 1116 | return subscripts(function_(false), allow_calls); 1117 | } 1118 | if (HOP(ATOMIC_START_TOKEN, S.token.type)) { 1119 | var atom = S.token.type == "regexp" 1120 | ? as("regexp", S.token.value[0], S.token.value[1]) 1121 | : as(S.token.type, S.token.value); 1122 | return subscripts(prog1(atom, next), allow_calls); 1123 | } 1124 | unexpected(); 1125 | }); 1126 | 1127 | function expr_list(closing, allow_trailing_comma, allow_empty) { 1128 | var first = true, a = []; 1129 | while (!is("punc", closing)) { 1130 | if (first) first = false; else expect(","); 1131 | if (allow_trailing_comma && is("punc", closing)) break; 1132 | if (is("punc", ",") && allow_empty) { 1133 | a.push([ "atom", "undefined" ]); 1134 | } else { 1135 | a.push(expression(false)); 1136 | } 1137 | } 1138 | next(); 1139 | return a; 1140 | }; 1141 | 1142 | function array_() { 1143 | return as("array", expr_list("]", !exigent_mode, true)); 1144 | }; 1145 | 1146 | function object_() { 1147 | var first = true, a = []; 1148 | while (!is("punc", "}")) { 1149 | if (first) first = false; else expect(","); 1150 | if (!exigent_mode && is("punc", "}")) 1151 | // allow trailing comma 1152 | break; 1153 | var type = S.token.type; 1154 | var name = as_property_name(); 1155 | if (type == "name" && (name == "get" || name == "set") && !is("punc", ":")) { 1156 | a.push([ as_name(), function_(false), name ]); 1157 | } else { 1158 | expect(":"); 1159 | a.push([ name, expression(false) ]); 1160 | } 1161 | } 1162 | next(); 1163 | return as("object", a); 1164 | }; 1165 | 1166 | function as_property_name() { 1167 | switch (S.token.type) { 1168 | case "num": 1169 | case "string": 1170 | return prog1(S.token.value, next); 1171 | } 1172 | return as_name(); 1173 | }; 1174 | 1175 | function as_name() { 1176 | switch (S.token.type) { 1177 | case "name": 1178 | case "operator": 1179 | case "keyword": 1180 | case "atom": 1181 | return prog1(S.token.value, next); 1182 | default: 1183 | unexpected(); 1184 | } 1185 | }; 1186 | 1187 | function subscripts(expr, allow_calls) { 1188 | if (is("punc", ".")) { 1189 | next(); 1190 | return subscripts(as("dot", expr, as_name()), allow_calls); 1191 | } 1192 | if (is("punc", "[")) { 1193 | next(); 1194 | return subscripts(as("sub", expr, prog1(expression, curry(expect, "]"))), allow_calls); 1195 | } 1196 | if (allow_calls && is("punc", "(")) { 1197 | next(); 1198 | return subscripts(as("call", expr, expr_list(")")), true); 1199 | } 1200 | return expr; 1201 | }; 1202 | 1203 | function maybe_unary(allow_calls) { 1204 | if (is("operator") && HOP(UNARY_PREFIX, S.token.value)) { 1205 | return make_unary("unary-prefix", 1206 | prog1(S.token.value, next), 1207 | maybe_unary(allow_calls)); 1208 | } 1209 | var val = expr_atom(allow_calls); 1210 | while (is("operator") && HOP(UNARY_POSTFIX, S.token.value) && !S.token.nlb) { 1211 | val = make_unary("unary-postfix", S.token.value, val); 1212 | next(); 1213 | } 1214 | return val; 1215 | }; 1216 | 1217 | function make_unary(tag, op, expr) { 1218 | if ((op == "++" || op == "--") && !is_assignable(expr)) 1219 | croak("Invalid use of " + op + " operator"); 1220 | return as(tag, op, expr); 1221 | }; 1222 | 1223 | function expr_op(left, min_prec, no_in) { 1224 | var op = is("operator") ? S.token.value : null; 1225 | if (op && op == "in" && no_in) op = null; 1226 | var prec = op != null ? PRECEDENCE[op] : null; 1227 | if (prec != null && prec > min_prec) { 1228 | next(); 1229 | var right = expr_op(maybe_unary(true), prec, no_in); 1230 | return expr_op(as("binary", op, left, right), min_prec, no_in); 1231 | } 1232 | return left; 1233 | }; 1234 | 1235 | function expr_ops(no_in) { 1236 | return expr_op(maybe_unary(true), 0, no_in); 1237 | }; 1238 | 1239 | function maybe_conditional(no_in) { 1240 | var expr = expr_ops(no_in); 1241 | if (is("operator", "?")) { 1242 | next(); 1243 | var yes = expression(false); 1244 | expect(":"); 1245 | return as("conditional", expr, yes, expression(false, no_in)); 1246 | } 1247 | return expr; 1248 | }; 1249 | 1250 | function is_assignable(expr) { 1251 | if (!exigent_mode) return true; 1252 | switch (expr[0]+"") { 1253 | case "dot": 1254 | case "sub": 1255 | case "new": 1256 | case "call": 1257 | return true; 1258 | case "name": 1259 | return expr[1] != "this"; 1260 | } 1261 | }; 1262 | 1263 | function maybe_assign(no_in) { 1264 | var left = maybe_conditional(no_in), val = S.token.value; 1265 | if (is("operator") && HOP(ASSIGNMENT, val)) { 1266 | if (is_assignable(left)) { 1267 | next(); 1268 | return as("assign", ASSIGNMENT[val], left, maybe_assign(no_in)); 1269 | } 1270 | croak("Invalid assignment"); 1271 | } 1272 | return left; 1273 | }; 1274 | 1275 | var expression = maybe_embed_tokens(function(commas, no_in) { 1276 | if (arguments.length == 0) 1277 | commas = true; 1278 | var expr = maybe_assign(no_in); 1279 | if (commas && is("punc", ",")) { 1280 | next(); 1281 | return as("seq", expr, expression(true, no_in)); 1282 | } 1283 | return expr; 1284 | }); 1285 | 1286 | function in_loop(cont) { 1287 | try { 1288 | ++S.in_loop; 1289 | return cont(); 1290 | } finally { 1291 | --S.in_loop; 1292 | } 1293 | }; 1294 | 1295 | return as("toplevel", (function(a){ 1296 | while (!is("eof")) 1297 | a.push(statement()); 1298 | return a; 1299 | })([])); 1300 | 1301 | }; 1302 | 1303 | /* -----[ Utilities ]----- */ 1304 | 1305 | function curry(f) { 1306 | var args = slice(arguments, 1); 1307 | return function() { return f.apply(this, args.concat(slice(arguments))); }; 1308 | }; 1309 | 1310 | function prog1(ret) { 1311 | if (ret instanceof Function) 1312 | ret = ret(); 1313 | for (var i = 1, n = arguments.length; --n > 0; ++i) 1314 | arguments[i](); 1315 | return ret; 1316 | }; 1317 | 1318 | function array_to_hash(a) { 1319 | var ret = {}; 1320 | for (var i = 0; i < a.length; ++i) 1321 | ret[a[i]] = true; 1322 | return ret; 1323 | }; 1324 | 1325 | function slice(a, start) { 1326 | return Array.prototype.slice.call(a, start || 0); 1327 | }; 1328 | 1329 | function characters(str) { 1330 | return str.split(""); 1331 | }; 1332 | 1333 | function member(name, array) { 1334 | for (var i = array.length; --i >= 0;) 1335 | if (array[i] == name) 1336 | return true; 1337 | return false; 1338 | }; 1339 | 1340 | function HOP(obj, prop) { 1341 | return Object.prototype.hasOwnProperty.call(obj, prop); 1342 | }; 1343 | 1344 | var warn = function() {}; 1345 | 1346 | /* -----[ Exports ]----- */ 1347 | 1348 | exports.tokenizer = tokenizer; 1349 | exports.parse = parse; 1350 | exports.slice = slice; 1351 | exports.curry = curry; 1352 | exports.member = member; 1353 | exports.array_to_hash = array_to_hash; 1354 | exports.PRECEDENCE = PRECEDENCE; 1355 | exports.KEYWORDS_ATOM = KEYWORDS_ATOM; 1356 | exports.RESERVED_WORDS = RESERVED_WORDS; 1357 | exports.KEYWORDS = KEYWORDS; 1358 | exports.ATOMIC_START_TOKEN = ATOMIC_START_TOKEN; 1359 | exports.OPERATORS = OPERATORS; 1360 | exports.is_alphanumeric_char = is_alphanumeric_char; 1361 | exports.is_identifier_start = is_identifier_start; 1362 | exports.is_identifier_char = is_identifier_char; 1363 | exports.set_logger = function(logger) { 1364 | warn = logger; 1365 | }; 1366 | 1367 | // Local variables: 1368 | // js-indent-level: 4 1369 | // End: 1370 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "createjs-def", 3 | "version": "0.3.0", 4 | "description": "CreateJS Toolkit definitions generator", 5 | "bin": { 6 | "createjs-def": "bin/createjs-def" 7 | }, 8 | "main": "./lib/index", 9 | "repository": { 10 | "type": "git", 11 | "url": "http://github.com/elsassph/createjs-def.git" 12 | }, 13 | "keywords": [ 14 | "createjs", 15 | "typescript", 16 | "haxe" 17 | ], 18 | "author": { 19 | "name": "Philippe Elsass" 20 | }, 21 | "license": "MIT", 22 | "readme": "Generate definition files for various languages from Flash Professional's CreateJS Toolkit's generated JavaScript library.", 23 | "readmeFilename": "README.md" 24 | } 25 | -------------------------------------------------------------------------------- /test/bilbo/BilboWalkcycle.hx: -------------------------------------------------------------------------------- 1 | package lib; 2 | 3 | import createjs.easeljs.MovieClip; 4 | import createjs.easeljs.Rectangle; 5 | import createjs.easeljs.Shadow; 6 | import createjs.easeljs.Container; 7 | import createjs.easeljs.Shape; 8 | 9 | @:native("lib.properties") 10 | extern class Properties { 11 | public static var width:Int; 12 | public static var height:Int; 13 | public static var fps:Int; 14 | public static var color:Int; 15 | public static var manifest:Dynamic; 16 | } 17 | 18 | @:native("lib.bilbowalkcycleside") 19 | extern class Bilbowalkcycleside extends MovieClip { 20 | static public var nominalBounds:Rectangle; 21 | public var instance:Bilbofootwalkcycle; 22 | public var instance_1:Bilbofootwalkcycle; 23 | public var instance_2:Biblobodywalkcycle; 24 | public var instance_3:Bilbofootwalkcycle; 25 | public var instance_4:Bilbofootwalkcycle; 26 | public var instance_5:Shadow; 27 | } 28 | 29 | @:native("lib.shadow2") 30 | extern class Shadow2 extends Container { 31 | static public var nominalBounds:Rectangle; 32 | public var shape:Shape; 33 | } 34 | 35 | @:native("lib.bilbotail") 36 | extern class Bilbotail extends MovieClip { 37 | static public var nominalBounds:Rectangle; 38 | public var shape:Shape; 39 | public var shape_1:Shape; 40 | public var shape_2:Shape; 41 | public var shape_3:Shape; 42 | public var shape_4:Shape; 43 | public var shape_5:Shape; 44 | public var shape_6:Shape; 45 | public var shape_7:Shape; 46 | public var shape_8:Shape; 47 | public var shape_9:Shape; 48 | public var shape_10:Shape; 49 | public var shape_11:Shape; 50 | public var shape_12:Shape; 51 | public var shape_13:Shape; 52 | public var shape_14:Shape; 53 | public var shape_15:Shape; 54 | public var shape_16:Shape; 55 | public var shape_17:Shape; 56 | public var shape_18:Shape; 57 | public var shape_19:Shape; 58 | public var shape_20:Shape; 59 | public var shape_21:Shape; 60 | public var shape_22:Shape; 61 | public var shape_23:Shape; 62 | public var shape_24:Shape; 63 | public var shape_25:Shape; 64 | public var shape_26:Shape; 65 | public var shape_27:Shape; 66 | public var shape_28:Shape; 67 | public var shape_29:Shape; 68 | public var shape_30:Shape; 69 | public var shape_31:Shape; 70 | public var shape_32:Shape; 71 | public var shape_33:Shape; 72 | public var shape_34:Shape; 73 | } 74 | 75 | @:native("lib.bilbopupil") 76 | extern class Bilbopupil extends Container { 77 | static public var nominalBounds:Rectangle; 78 | public var shape:Shape; 79 | public var shape_1:Shape; 80 | } 81 | 82 | @:native("lib.bilbomouthint") 83 | extern class Bilbomouthint extends Container { 84 | static public var nominalBounds:Rectangle; 85 | public var shape:Shape; 86 | } 87 | 88 | @:native("lib.bilbohat") 89 | extern class Bilbohat extends Container { 90 | static public var nominalBounds:Rectangle; 91 | public var shape:Shape; 92 | public var shape_1:Shape; 93 | } 94 | 95 | @:native("lib.bilbofoot") 96 | extern class Bilbofoot extends MovieClip { 97 | static public var nominalBounds:Rectangle; 98 | public var shape:Shape; 99 | public var shape_1:Shape; 100 | public var shape_2:Shape; 101 | public var shape_3:Shape; 102 | } 103 | 104 | @:native("lib.bilboeyeball") 105 | extern class Bilboeyeball extends Container { 106 | static public var nominalBounds:Rectangle; 107 | public var shape:Shape; 108 | } 109 | 110 | @:native("lib.bilboear") 111 | extern class Bilboear extends Container { 112 | static public var nominalBounds:Rectangle; 113 | public var shape:Shape; 114 | } 115 | 116 | @:native("lib.bilbobrow") 117 | extern class Bilbobrow extends Container { 118 | static public var nominalBounds:Rectangle; 119 | public var shape:Shape; 120 | } 121 | 122 | @:native("lib.shadow") 123 | extern class Shadow extends MovieClip { 124 | static public var nominalBounds:Rectangle; 125 | public var instance:Shadow2; 126 | } 127 | 128 | @:native("lib.bilbofootwalkcycle") 129 | extern class Bilbofootwalkcycle extends MovieClip { 130 | static public var nominalBounds:Rectangle; 131 | public var instance:Bilbofoot; 132 | } 133 | 134 | @:native("lib.bilboeyebuild") 135 | extern class Bilboeyebuild extends Container { 136 | static public var nominalBounds:Rectangle; 137 | public var instance:Bilbopupil; 138 | public var instance_1:Bilboeyeball; 139 | public var shape:Shape; 140 | } 141 | 142 | @:native("lib.bilbobody") 143 | extern class Bilbobody extends MovieClip { 144 | static public var nominalBounds:Rectangle; 145 | public var instance:Bilboeyebuild; 146 | public var instance_1:Bilbobrow; 147 | public var shape:Shape; 148 | public var shape_1:Shape; 149 | public var shape_2:Shape; 150 | public var shape_3:Shape; 151 | public var shape_4:Shape; 152 | public var shape_5:Shape; 153 | public var shape_6:Shape; 154 | public var shape_7:Shape; 155 | public var shape_8:Shape; 156 | public var shape_9:Shape; 157 | public var shape_10:Shape; 158 | public var shape_11:Shape; 159 | public var shape_12:Shape; 160 | public var shape_13:Shape; 161 | public var shape_14:Shape; 162 | public var shape_15:Shape; 163 | public var shape_16:Shape; 164 | public var shape_17:Shape; 165 | public var shape_18:Shape; 166 | public var shape_19:Shape; 167 | public var shape_20:Shape; 168 | public var shape_21:Shape; 169 | public var shape_22:Shape; 170 | public var shape_23:Shape; 171 | public var shape_24:Shape; 172 | public var shape_25:Shape; 173 | public var shape_26:Shape; 174 | public var shape_27:Shape; 175 | public var shape_28:Shape; 176 | public var shape_29:Shape; 177 | public var shape_30:Shape; 178 | public var shape_31:Shape; 179 | public var shape_32:Shape; 180 | public var shape_33:Shape; 181 | public var shape_34:Shape; 182 | public var shape_35:Shape; 183 | public var shape_36:Shape; 184 | public var instance_2:Bilbomouthint; 185 | } 186 | 187 | @:native("lib.biblobodywalkcycle") 188 | extern class Biblobodywalkcycle extends MovieClip { 189 | static public var nominalBounds:Rectangle; 190 | public var instance:Bilboear; 191 | public var instance_1:Bilbohat; 192 | public var instance_2:Bilbobody; 193 | public var instance_3:Bilbotail; 194 | } 195 | 196 | 197 | -------------------------------------------------------------------------------- /test/bilbo/bilbo-typescript.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Typescript bilbo-walkcycle-side 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/bilbo/bilbo-typescript.js: -------------------------------------------------------------------------------- 1 | var canvas, stage, exportRoot; 2 | function init() { 3 | canvas = document.getElementById("canvas"); 4 | exportRoot = new lib.bilbowalkcycleside(); 5 | stage = new createjs.Stage(canvas); 6 | stage.addChild(exportRoot); 7 | stage.update(); 8 | stage; 9 | createjs.Ticker.setFPS(24); 10 | createjs.Ticker.addEventListener("tick", stage); 11 | } 12 | -------------------------------------------------------------------------------- /test/bilbo/bilbo-typescript.ts: -------------------------------------------------------------------------------- 1 | 2 | /// 3 | /// 4 | 5 | var canvas, stage:createjs.Stage, exportRoot; 6 | 7 | function init() { 8 | canvas = document.getElementById("canvas"); 9 | exportRoot = new lib.bilbowalkcycleside(); 10 | 11 | stage = new createjs.Stage(canvas); 12 | stage.addChild(exportRoot); 13 | stage.update(); 14 | 15 | createjs.Ticker.setFPS(24); 16 | createjs.Ticker.addEventListener("tick", stage); 17 | } -------------------------------------------------------------------------------- /test/bilbo/bilbo-walkcycle-side.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module lib { 4 | 5 | export class properties implements Object { 6 | static width: number; 7 | static height: number; 8 | static fps: number; 9 | static color: string; 10 | static manifest: Object[]; 11 | } 12 | 13 | export class bilbowalkcycleside extends createjs.MovieClip { 14 | static nominalBounds: createjs.Rectangle; 15 | instance: bilbofootwalkcycle; 16 | instance_1: bilbofootwalkcycle; 17 | instance_2: biblobodywalkcycle; 18 | instance_3: bilbofootwalkcycle; 19 | instance_4: bilbofootwalkcycle; 20 | instance_5: shadow; 21 | } 22 | 23 | export class shadow2 extends createjs.Container { 24 | static nominalBounds: createjs.Rectangle; 25 | shape: createjs.Shape; 26 | } 27 | 28 | export class bilbotail extends createjs.MovieClip { 29 | static nominalBounds: createjs.Rectangle; 30 | shape: createjs.Shape; 31 | shape_1: createjs.Shape; 32 | shape_2: createjs.Shape; 33 | shape_3: createjs.Shape; 34 | shape_4: createjs.Shape; 35 | shape_5: createjs.Shape; 36 | shape_6: createjs.Shape; 37 | shape_7: createjs.Shape; 38 | shape_8: createjs.Shape; 39 | shape_9: createjs.Shape; 40 | shape_10: createjs.Shape; 41 | shape_11: createjs.Shape; 42 | shape_12: createjs.Shape; 43 | shape_13: createjs.Shape; 44 | shape_14: createjs.Shape; 45 | shape_15: createjs.Shape; 46 | shape_16: createjs.Shape; 47 | shape_17: createjs.Shape; 48 | shape_18: createjs.Shape; 49 | shape_19: createjs.Shape; 50 | shape_20: createjs.Shape; 51 | shape_21: createjs.Shape; 52 | shape_22: createjs.Shape; 53 | shape_23: createjs.Shape; 54 | shape_24: createjs.Shape; 55 | shape_25: createjs.Shape; 56 | shape_26: createjs.Shape; 57 | shape_27: createjs.Shape; 58 | shape_28: createjs.Shape; 59 | shape_29: createjs.Shape; 60 | shape_30: createjs.Shape; 61 | shape_31: createjs.Shape; 62 | shape_32: createjs.Shape; 63 | shape_33: createjs.Shape; 64 | shape_34: createjs.Shape; 65 | } 66 | 67 | export class bilbopupil extends createjs.Container { 68 | static nominalBounds: createjs.Rectangle; 69 | shape: createjs.Shape; 70 | shape_1: createjs.Shape; 71 | } 72 | 73 | export class bilbomouthint extends createjs.Container { 74 | static nominalBounds: createjs.Rectangle; 75 | shape: createjs.Shape; 76 | } 77 | 78 | export class bilbohat extends createjs.Container { 79 | static nominalBounds: createjs.Rectangle; 80 | shape: createjs.Shape; 81 | shape_1: createjs.Shape; 82 | } 83 | 84 | export class bilbofoot extends createjs.MovieClip { 85 | static nominalBounds: createjs.Rectangle; 86 | shape: createjs.Shape; 87 | shape_1: createjs.Shape; 88 | shape_2: createjs.Shape; 89 | shape_3: createjs.Shape; 90 | } 91 | 92 | export class bilboeyeball extends createjs.Container { 93 | static nominalBounds: createjs.Rectangle; 94 | shape: createjs.Shape; 95 | } 96 | 97 | export class bilboear extends createjs.Container { 98 | static nominalBounds: createjs.Rectangle; 99 | shape: createjs.Shape; 100 | } 101 | 102 | export class bilbobrow extends createjs.Container { 103 | static nominalBounds: createjs.Rectangle; 104 | shape: createjs.Shape; 105 | } 106 | 107 | export class shadow extends createjs.MovieClip { 108 | static nominalBounds: createjs.Rectangle; 109 | instance: shadow2; 110 | } 111 | 112 | export class bilbofootwalkcycle extends createjs.MovieClip { 113 | static nominalBounds: createjs.Rectangle; 114 | instance: bilbofoot; 115 | } 116 | 117 | export class bilboeyebuild extends createjs.Container { 118 | static nominalBounds: createjs.Rectangle; 119 | instance: bilbopupil; 120 | instance_1: bilboeyeball; 121 | shape: createjs.Shape; 122 | } 123 | 124 | export class bilbobody extends createjs.MovieClip { 125 | static nominalBounds: createjs.Rectangle; 126 | instance: bilboeyebuild; 127 | instance_1: bilbobrow; 128 | shape: createjs.Shape; 129 | shape_1: createjs.Shape; 130 | shape_2: createjs.Shape; 131 | shape_3: createjs.Shape; 132 | shape_4: createjs.Shape; 133 | shape_5: createjs.Shape; 134 | shape_6: createjs.Shape; 135 | shape_7: createjs.Shape; 136 | shape_8: createjs.Shape; 137 | shape_9: createjs.Shape; 138 | shape_10: createjs.Shape; 139 | shape_11: createjs.Shape; 140 | shape_12: createjs.Shape; 141 | shape_13: createjs.Shape; 142 | shape_14: createjs.Shape; 143 | shape_15: createjs.Shape; 144 | shape_16: createjs.Shape; 145 | shape_17: createjs.Shape; 146 | shape_18: createjs.Shape; 147 | shape_19: createjs.Shape; 148 | shape_20: createjs.Shape; 149 | shape_21: createjs.Shape; 150 | shape_22: createjs.Shape; 151 | shape_23: createjs.Shape; 152 | shape_24: createjs.Shape; 153 | shape_25: createjs.Shape; 154 | shape_26: createjs.Shape; 155 | shape_27: createjs.Shape; 156 | shape_28: createjs.Shape; 157 | shape_29: createjs.Shape; 158 | shape_30: createjs.Shape; 159 | shape_31: createjs.Shape; 160 | shape_32: createjs.Shape; 161 | shape_33: createjs.Shape; 162 | shape_34: createjs.Shape; 163 | shape_35: createjs.Shape; 164 | shape_36: createjs.Shape; 165 | instance_2: bilbomouthint; 166 | } 167 | 168 | export class biblobodywalkcycle extends createjs.MovieClip { 169 | static nominalBounds: createjs.Rectangle; 170 | instance: bilboear; 171 | instance_1: bilbohat; 172 | instance_2: bilbobody; 173 | instance_3: bilbotail; 174 | } 175 | 176 | } 177 | 178 | -------------------------------------------------------------------------------- /test/bilbo/bilbo-walkcycle-side.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CreateJS export from bilbo-walkcycle-side 6 | 7 | 8 | 9 | 10 | 11 | 12 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /test/bilbo/easeljs/easeljs.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for EaselJS 0.6 2 | // Project: http://www.createjs.com/#!/EaselJS 3 | // Definitions by: Pedro Ferreira 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /* 7 | Copyright (c) 2012 Pedro Ferreira 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | 13 | 14 | /// 15 | 16 | // rename the native MouseEvent, to avoid conflit with createjs's MouseEvent 17 | interface NativeMouseEvent extends MouseEvent { 18 | 19 | } 20 | 21 | module createjs { 22 | // :: base classes :: // 23 | 24 | export class DisplayObject { 25 | // properties 26 | alpha: number; 27 | cacheCanvas: HTMLCanvasElement; 28 | cacheID: number; 29 | compositeOperation: string; 30 | cursor: string; 31 | filters: Filter[]; 32 | hitArea: DisplayObject; 33 | id: number; 34 | mask: Shape; 35 | mouseEnabled: bool; 36 | name: string; 37 | parent: DisplayObject; 38 | regX: number; 39 | regY: number; 40 | rotation: number; 41 | scaleX: number; 42 | scaleY: number; 43 | shadow: Shadow; 44 | skewX: number; 45 | skewY: number; 46 | snapToPixel: bool; 47 | static suppressCrossDomainErrors: bool; 48 | visible: bool; 49 | x: number; 50 | y: number; 51 | 52 | // methods 53 | cache(x: number, y: number, width: number, height: number, scale?: number): void; 54 | clone(): DisplayObject; 55 | draw(ctx: CanvasRenderingContext2D, ignoreCache?: bool): void; 56 | getCacheDataURL(): string; 57 | getChildByName(name: string): DisplayObject; 58 | getConcatenatedMatrix(mtx: Matrix2D): Matrix2D; 59 | getMatrix(matrix: Matrix2D): Matrix2D; 60 | getStage(): Stage; 61 | globalToLocal(x: number, y: number): Point; 62 | hitTest(x: number, y: number): bool; 63 | isVisible(): bool; 64 | localToGlobal(x: number, y: number): Point; 65 | localToLocal(x: number, y: number, target: DisplayObject): Point; 66 | set(props: Object): DisplayObject; 67 | setTransform(x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX: number, regY: number): DisplayObject; 68 | setupContext(ctx: CanvasRenderingContext2D): void; 69 | toString(): string; 70 | uncache(): void; 71 | updateCache(compositeOperation: string): void; 72 | 73 | // events 74 | click: (event: MouseEvent) => any; 75 | dblClick: (event: MouseEvent) => any; 76 | mouseout: (event: MouseEvent) => any; 77 | mouseover: (event: MouseEvent) => any; 78 | mousedown: (event: MouseEvent) => any; 79 | tick: () => any; 80 | 81 | // EventDispatcher mixins 82 | addEventListener(type: string, listener: (eventObj: Object) => bool): Function; 83 | addEventListener(type: string, listener: (eventObj: Object) => void): Function; 84 | addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): Object; 85 | addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): Object; 86 | removeEventListener(type: string, listener: (eventObj: Object) => bool): void; 87 | removeEventListener(type: string, listener: (eventObj: Object) => void): void; 88 | removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): void; 89 | removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): void; 90 | removeAllEventListeners(type: string): void; 91 | dispatchEvent(eventObj: string, target: Object): bool; 92 | dispatchEvent(eventObj: Object, target: Object): bool; 93 | hasEventListener(type: string): bool; 94 | } 95 | 96 | 97 | export class Filter { 98 | constructor (); 99 | applyFilter(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, targetCtx?: CanvasRenderingContext2D, targetX?: number, targetY?: number): bool; 100 | clone(): Filter; 101 | getBounds(): Rectangle; 102 | toString(): string; 103 | } 104 | 105 | 106 | // :: The rest :: // 107 | 108 | export class AlphaMapFilter extends Filter { 109 | // properties 110 | alphaMap: any; //Image or HTMLCanvasElement 111 | 112 | // methods 113 | constructor (alphaMap: HTMLImageElement); 114 | constructor (alphaMap: HTMLCanvasElement); 115 | clone(): AlphaMapFilter; 116 | } 117 | 118 | 119 | export class AlphaMaskFilter extends Filter { 120 | // properties 121 | mask: any; // HTMLImageElement or HTMLCanvasElement 122 | 123 | // methods 124 | constructor (mask: HTMLImageElement); 125 | constructor (mask: HTMLCanvasElement); 126 | clone(): AlphaMaskFilter; 127 | } 128 | 129 | 130 | export class Bitmap extends DisplayObject { 131 | // properties 132 | image: any; // HTMLImageElement or HTMLCanvasElement or HTMLVideoElement 133 | snapToPixel: bool; 134 | sourceRect: Rectangle; 135 | 136 | // methods 137 | constructor (imageOrUrl: HTMLImageElement); 138 | constructor (imageOrUrl: HTMLCanvasElement); 139 | constructor (imageOrUrl: HTMLVideoElement); 140 | constructor (imageOrUrl: string); 141 | 142 | clone(): Bitmap; 143 | updateCache(): void; 144 | } 145 | 146 | 147 | export class BitmapAnimation extends DisplayObject { 148 | // properties 149 | currentAnimation: string; 150 | currentAnimationFrame: number; 151 | currentFrame: number; 152 | offset: number; 153 | paused: bool; 154 | snapToPixel: bool; 155 | spriteSheet: SpriteSheet; 156 | 157 | // methods 158 | constructor (spriteSheet: SpriteSheet); 159 | advance(): void; 160 | cache(): void; 161 | clone(): BitmapAnimation; 162 | getBounds(): Rectangle; 163 | gotoAndPlay(frameOrAnimation: string): void; 164 | gotoAndPlay(frameOrAnimation: number): void; 165 | play(): void; 166 | stop(): void; 167 | updateCache(): void; 168 | 169 | // events 170 | onAnimationEnd: (event: Object) => any; 171 | } 172 | 173 | export class ButtonHelper { 174 | // properties 175 | target: Object; 176 | overLabel: string; 177 | outLabel: string; 178 | downLabel: string; 179 | play: bool; 180 | 181 | // methods 182 | constructor(target: MovieClip, outLabel: string, overLabel: string, downLabel: string, play: bool, hitArea: DisplayObject, hitLabel: string); 183 | constructor(target: BitmapAnimation, outLabel: string, overLabel: string, downLabel: string, play: bool, hitArea: DisplayObject, hitLabel: string); 184 | setEnabled(value: bool); 185 | toString(): string; 186 | } 187 | 188 | export class BoxBlurFilter extends Filter { 189 | // properties 190 | blurX: number; 191 | blurY: number; 192 | quality: number; 193 | 194 | // methods 195 | constructor (blurX: number, blurY: number, quality: number); 196 | clone(): BoxBlurFilter; 197 | } 198 | 199 | 200 | export class ColorFilter extends Filter { 201 | // properties 202 | alphaOffset: number; 203 | blueMultiplier: number; 204 | blueOffset: number; 205 | greenMultiplier: number; 206 | greenOffset: number; 207 | redMultiplier: number; 208 | redOffset: number; 209 | 210 | // methods 211 | constructor (redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaMultiplier?: number, redOffset?: number, greenOffset?: number, blueOffset?: number, alphaOffset?: number); 212 | clone(): ColorFilter; 213 | } 214 | 215 | 216 | export class ColorMatrix { 217 | // properties 218 | DELTA_INDEX: number[]; 219 | IDENTITY_MATRIX: number[]; 220 | LENGTH: number; 221 | 222 | // methods 223 | constructor (brightness: number, contrast: number, saturation: number, hue: number); 224 | adjustBrightness(value: number): ColorMatrix; 225 | adjustColor(brightness: number, contrast: number, saturation: number, hue: number): ColorMatrix; 226 | adjustContrast(value: number): ColorMatrix; 227 | adjustHue(value: number): ColorMatrix; 228 | adjustSaturation(value: number): ColorMatrix; 229 | clone(): ColorMatrix; 230 | concat(matrix: ColorMatrix[]): ColorMatrix; 231 | copyMatrix(matrix: ColorMatrix[]): ColorMatrix; 232 | reset(): ColorMatrix; 233 | toArray(): number[]; 234 | } 235 | 236 | 237 | export class ColorMatrixFilter extends Filter { 238 | // methods 239 | constructor (matrix: number[]); 240 | clone(): ColorMatrixFilter; 241 | } 242 | 243 | 244 | export class Command { 245 | // methods 246 | constructor (f, params, path); 247 | exec(scope: any): void; 248 | } 249 | 250 | 251 | export class Container extends DisplayObject { 252 | // properties 253 | children: DisplayObject[]; 254 | 255 | // methods 256 | addChild(...child: DisplayObject[]): DisplayObject; 257 | addChildAt(...childOrIndex: any[]): DisplayObject; // actually (...child: DisplayObject[], index: number) 258 | clone(recursive?: bool): Container; 259 | contains(child: DisplayObject): bool; 260 | getChildAt(index: number): DisplayObject; 261 | getChildIndex(child: DisplayObject): number; 262 | getNumChildren(): number; 263 | getObjectsUnderPoint(x, number, y: number): DisplayObject[]; 264 | getObjectUnderPoint(x: number, y: number): DisplayObject; 265 | hitTest(x: number, y: number): bool; 266 | removeAllChildren(): void; 267 | removeChild(...child: DisplayObject[]): bool; 268 | removeChildAt(...index: number[]): bool; 269 | setChildIndex(child: DisplayObject, index: number): void; 270 | sortChildren(sortFunction: (a: DisplayObject, b: DisplayObject) => number): void; 271 | swapChildren(child1: DisplayObject, child2: DisplayObject): void; 272 | swapChildrenAt(index1: number, index2: number): void; 273 | } 274 | 275 | 276 | export class DOMElement extends DisplayObject { 277 | // properties 278 | htmlElement: HTMLElement; 279 | 280 | // methods 281 | constructor (htmlElement: HTMLElement); 282 | clone(): DOMElement; 283 | } 284 | 285 | 286 | export class EaselJS { 287 | // properties 288 | version: string; 289 | buildDate: string; 290 | } 291 | 292 | 293 | export class EventDispatcher { 294 | // properties 295 | 296 | // methods 297 | static initialize(target: Object): void; 298 | 299 | addEventListener(type: string, listener: (eventObj: Object) => bool): Function; 300 | addEventListener(type: string, listener: (eventObj: Object) => void): Function; 301 | addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): Object; 302 | addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): Object; 303 | removeEventListener(type: string, listener: (eventObj: Object) => bool): void; 304 | removeEventListener(type: string, listener: (eventObj: Object) => void): void; 305 | removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): void; 306 | removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): void; 307 | removeAllEventListeners(type: string): void; 308 | dispatchEvent(eventObj: string, target: Object): bool; 309 | dispatchEvent(eventObj: Object, target: Object): bool; 310 | hasEventListener(type: string): bool; 311 | toString(): string; 312 | } 313 | 314 | 315 | export class Graphics { 316 | // properties 317 | BASE_64: Object; 318 | curveTo(cpx: number, cpy: number, x: number, y: number): Graphics; // same as quadraticCurveTo() 319 | drawRect(x: number, y: number, width: number, height: number): Graphics; // same as rect() 320 | STROKE_CAPS_MAP: string[]; 321 | STROKE_JOINTS_MAP: string[]; 322 | 323 | // methods 324 | arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: bool): Graphics; 325 | arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): Graphics; 326 | beginBitmapFill(image: Object, repetition?: string, matrix?: Matrix2D): Graphics; 327 | beginBitmapStroke(image: Object, repetition?: string): Graphics; 328 | beginFill(color: string): Graphics; 329 | beginLinearGradientFill(colors: string[], ratios: number[], x0: number, y0: number, x1: number, y1: number): Graphics; 330 | beginLinearGradientStroke(colors: string[], ratios: number[], x0: number, y0: number, x1: number, y1: number): Graphics; 331 | beginRadialGradientFill(colors: string[], ratios: number[], x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): Graphics; 332 | beginRadialGradientStroke(colors: string[], ratios: number[], x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): Graphics; 333 | beginStroke(color: string): Graphics; 334 | bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): Graphics; 335 | clear(): Graphics; 336 | clone(): Graphics; 337 | closePath(): Graphics; 338 | decodePath(str: string): Graphics; 339 | draw(ctx: CanvasRenderingContext2D): void; 340 | drawAsPath(ctx: CanvasRenderingContext2D): void; 341 | drawCircle(x: number, y: number, radius: number): Graphics; 342 | drawEllipse(x: number, y: number, width: number, height: number): Graphics; 343 | drawPolyStar(x: number, y: number, radius: number, sides: number, pointSize: number, angle: number): Graphics; 344 | drawRoundRect(x: number, y: number, width: number, height: number, radius: number): Graphics; 345 | drawRoundRectComplex(x: number, y: number, width: number, height: number, radiusTL: number, radiusTR: number, radiusBR: number, radisBL: number): Graphics; 346 | endFill(): Graphics; 347 | endStroke(): Graphics; 348 | isEmpty(): bool; 349 | static getHSL(hue: number, saturation: number, lightness: number, alpha?: number): string; 350 | static getRGB(red: number, green: number, blue: number, alpha?: number): string; 351 | lineTo(x: number, y: number): Graphics; 352 | moveTo(x: number, y: number): Graphics; 353 | quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): Graphics; 354 | rect(x: number, y: number, width: number, height: number): Graphics; 355 | setStrokeStyle(thickness: number, caps?: string, joints?: string, miter?: number, ignoreScale?: bool): Graphics; // caps and joints can be a string or number 356 | setStrokeStyle(thickness: number, caps?: number, joints?: string, miter?: number, ignoreScale?: bool): Graphics; 357 | setStrokeStyle(thickness: number, caps?: string, joints?: number, miter?: number, ignoreScale?: bool): Graphics; 358 | setStrokeStyle(thickness: number, caps?: number, joints?: number, miter?: number, ignoreScale?: bool): Graphics; 359 | toString(): string; 360 | } 361 | 362 | 363 | export class Log { 364 | // properties 365 | static NONE: number; 366 | static ERROR: number; 367 | static WARNING: number; 368 | static TRACE: number; 369 | static ALL: number; 370 | static level: number; 371 | 372 | // methods 373 | static out(message: string, details: string, level: number); 374 | static addKeys(keys: Object); 375 | static log(message: string, details: string, level: number); 376 | } 377 | 378 | export class Matrix2D { 379 | // properties 380 | a: number; 381 | alpha: number; 382 | atx: number; 383 | b: number; 384 | c: number; 385 | compositeOperation: string; 386 | d: number; 387 | static DEG_TO_RAD: number; 388 | static identity: Matrix2D; 389 | shadow: Shadow; 390 | ty: number; 391 | 392 | // methods 393 | constructor (a: number, b: number, c: number, d: number, tx: number, ty: number); 394 | append(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix2D; 395 | appendMatrix(matrix: Matrix2D): Matrix2D; 396 | appendProperties(a: number, b: number, c: number, d: number, tx: number, ty: number, alpha: number, shadow: Shadow, compositeOperation: string): Matrix2D; 397 | appendTransform(x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX?: number, regY?: number): Matrix2D; 398 | clone(): Matrix2D; 399 | decompose(target: Object): Matrix2D; 400 | identity(): Matrix2D; 401 | invert(): Matrix2D; 402 | isIdentity(): bool; 403 | prepend(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix2D; 404 | prependMatrix(matrix: Matrix2D): Matrix2D; 405 | prependProperties(alpha: number, shadow: Shadow, compositeOperation: string): Matrix2D; 406 | prependTransform(x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX?: number, regY?: number): Matrix2D; 407 | rotate(angle: number): Matrix2D; 408 | scale(x: number, y: number): Matrix2D; 409 | skew(skewX: number, skewY: number): Matrix2D; 410 | toString(): string; 411 | translate(x: number, y: number): Matrix2D; 412 | } 413 | 414 | 415 | export class MouseEvent { 416 | 417 | // properties 418 | nativeEvent: NativeMouseEvent; 419 | pointerID: number; 420 | primaryPointer: bool; 421 | rawX: number; 422 | rawY: number; 423 | stageX: number; 424 | stageY: number; 425 | target: DisplayObject; 426 | type: string; 427 | 428 | // methods 429 | constructor (type: string, stageX: number, stageY: number, target: DisplayObject, nativeEvent: NativeMouseEvent, pointerID: number, primary: bool, rawX: number, rawY: number); 430 | clone(): MouseEvent; 431 | toString(): string; 432 | 433 | // EventDispatcher mixins 434 | addEventListener(type: string, listener: (eventObj: Object) => bool): Function; 435 | addEventListener(type: string, listener: (eventObj: Object) => void ): Function; 436 | addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): Object; 437 | addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): Object; 438 | removeEventListener(type: string, listener: (eventObj: Object) => bool): void; 439 | removeEventListener(type: string, listener: (eventObj: Object) => void ): void; 440 | removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): void; 441 | removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): void; 442 | removeAllEventListeners(type: string): void; 443 | dispatchEvent(eventObj: string, target: Object): bool; 444 | dispatchEvent(eventObj: Object, target: Object): bool; 445 | hasEventListener(type: string): bool; 446 | 447 | // events 448 | onMouseMove: (event: MouseEvent) => any; 449 | onMouseUp: (event: MouseEvent) => any; 450 | } 451 | 452 | 453 | export class MovieClip extends Container { 454 | // properties 455 | actionsEnabled: bool; 456 | autoReset: bool; 457 | currentFrame: number; 458 | static INDEPENDENT: string; 459 | loop: bool; 460 | mode: string; 461 | paused: bool; 462 | static SINGLE_FRAME: string; 463 | startPosition: number; 464 | static SYNCHED: string; 465 | timeline: Timeline; //HERE requires tweenJS 466 | 467 | // methods 468 | constructor (mode: string, startPosition: number, loop: bool, labels: Object); 469 | clone(recursive?: bool): MovieClip; 470 | gotoAndPlay(positionOrLabel: string): void; 471 | gotoAndPlay(positionOrLabel: number): void; 472 | gotoAndStop(positionOrLabel: string): void; 473 | gotoAndStop(positionOrLabel: number): void; 474 | play(): void; 475 | stop(): void; 476 | } 477 | 478 | 479 | export class Point { 480 | // properties 481 | x: number; 482 | y: number; 483 | 484 | // methods 485 | constructor (x: number, y: number); 486 | clone(): Point; 487 | toString(): string; 488 | } 489 | 490 | 491 | export class Rectangle { 492 | // properties 493 | x: number; 494 | y: number; 495 | width: number; 496 | height: number; 497 | 498 | // methods 499 | constructor (x: number, y: number, width: number, height: number); 500 | clone(): Rectangle; 501 | toString(): string; 502 | } 503 | 504 | 505 | export class Shadow { 506 | // properties 507 | blur: number; 508 | color: string; 509 | static identity: Shadow; 510 | offsetX: number; 511 | offsetY: number; 512 | 513 | // methods 514 | constructor (color: string, offsetX: number, offsetY: number, blur: number); 515 | clone(): Shadow; 516 | toString(): string; 517 | } 518 | 519 | 520 | export class Shape extends DisplayObject { 521 | // properties 522 | graphics: Graphics; 523 | 524 | // methods 525 | constructor (graphics?: Graphics); 526 | clone(recursive?: bool): Shape; 527 | } 528 | 529 | 530 | // what is returned from .getAnimation() 531 | interface SpriteSheetAnimation { 532 | frames: number[]; 533 | frequency: number; 534 | name: string; 535 | next: string; 536 | } 537 | 538 | export class SpriteSheet { 539 | // properties 540 | complete: bool; 541 | 542 | // methods 543 | constructor (data: Object); 544 | clone(): SpriteSheet; 545 | getAnimation(name: string): SpriteSheetAnimation; 546 | getAnimations(): string[]; 547 | getFrame(frameIndex: number): Object; 548 | getFrameBounds(frameIndex: number); 549 | getNumFrames(animation: string): number; 550 | toString(): string; 551 | 552 | // events 553 | onComplete: () => any; 554 | } 555 | 556 | 557 | export class SpriteSheetBuilder { 558 | // properties 559 | defaultScale: number; 560 | maxWidth: number; 561 | maxHeight: number; 562 | padding: number; 563 | progress: number; 564 | spriteSheet: SpriteSheet; 565 | timeSlice: number; 566 | 567 | // methods 568 | addFrame(source: DisplayObject, sourceRect?: Rectangle, scale?: number, setupFunction?: () => any, setupParams?: any[], setupScope?: Object): any; //HERE returns number or null 569 | addMovieClip(source: MovieClip, sourceRect?: Rectangle, scale?: number): void; 570 | build(): void; 571 | buildAsync(timeSlice?: number): void; 572 | clone(): SpriteSheetBuilder; 573 | stopAsync(): void; 574 | toString(): string; 575 | 576 | // events 577 | complete: (event: Object) => any; 578 | onProgress: (event: Object) => any; 579 | } 580 | 581 | 582 | export class SpriteSheetUtils { 583 | static addFlippedFrames(spriteSheet: SpriteSheet, horizontal?: bool, vertical?: bool, both?: bool): void; 584 | static extractFrame(spriteSheet: SpriteSheet, frame: number): HTMLImageElement; 585 | static extractFrame(spriteSheet: SpriteSheet, animationName: string): HTMLImageElement; 586 | static flip(spriteSheet: HTMLImageElement, flipData: Object): void; 587 | static mergeAlpha(rgbImage: HTMLImageElement, alphaImage: HTMLImageElement, canvas?: HTMLCanvasElement): HTMLCanvasElement; 588 | } 589 | 590 | 591 | export class Stage extends Container { 592 | // properties 593 | autoClear: bool; 594 | canvas: HTMLCanvasElement; 595 | mouseInBounds: bool; 596 | mouseX: number; 597 | mouseY: number; 598 | snapToPixelEnabled: bool; 599 | tickOnUpdate: bool; 600 | 601 | new (): Stage; 602 | new (canvas: HTMLElement): Stage; 603 | 604 | // methods 605 | constructor (canvas: HTMLCanvasElement); 606 | clone(): Stage; 607 | enableMouseOver(frequency: number): void; 608 | enableDOMEvents(enable: bool): void; 609 | toDataURL(backgroundColor: string, mimeType: string): string; 610 | update(): void; 611 | clear(): void; 612 | handleEvent(evt: Object): void; 613 | 614 | // events 615 | stagemousemove: (event: MouseEvent) => any; 616 | stagemouseup: (event: MouseEvent) => any; 617 | } 618 | 619 | 620 | export class Text extends DisplayObject { 621 | // properties 622 | color: string; 623 | font: string; 624 | lineHeight: number; 625 | lineWidth: number; 626 | maxWidth: number; 627 | outline: bool; 628 | text: string; 629 | textAlign: string; 630 | textBaseline: string; 631 | 632 | // methods 633 | constructor (text?: string, font?: string, color?: string); 634 | clone(): Text; 635 | getMeasuredHeight(): number; 636 | getMeasuredLineHeight(): number; 637 | getMeasuredWidth(): number; 638 | } 639 | 640 | 641 | export class Ticker { 642 | // properties 643 | static useRAF: bool; 644 | 645 | // methods 646 | static addListener(o: Object, pauseable?: bool): void; 647 | static getFPS(): number; 648 | static getInterval(): number; 649 | static getMeasuredFPS(ticks?: number): number; 650 | static getPaused(): bool; 651 | static getTicks(pauseable?: bool): number; 652 | static getTime(pauseable: bool): number; 653 | static init(): void; 654 | static removeAllListeners(): void; 655 | static removeListener(o: Object): void; 656 | static setFPS(value: number): void; 657 | static setInterval(interval: number): void; 658 | static setPaused(value: bool): void; 659 | 660 | // EventDispatcher mixins 661 | static addEventListener(type: string, listener: (eventObj: Object) => bool): Function; 662 | static addEventListener(type: string, listener: (eventObj: Object) => void): Function; 663 | static addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): Object; 664 | static addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): Object; 665 | static removeEventListener(type: string, listener: (eventObj: Object) => bool): void; 666 | static removeEventListener(type: string, listener: (eventObj: Object) => void): void; 667 | static removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): void; 668 | static removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): void; 669 | 670 | // events 671 | tick: (timeElapsed: number) => any; 672 | } 673 | 674 | 675 | export class Touch { 676 | // methods 677 | static disable(stage: Stage): void; 678 | static enable(stage: Stage, singleTouch?: bool, allowDefault?: bool): bool; 679 | static isSupported(): bool; 680 | } 681 | 682 | 683 | export class UID { 684 | // methods 685 | static get(): number; 686 | } 687 | } -------------------------------------------------------------------------------- /test/bilbo/tweenjs/TweenJS.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for TweenJS 0.4 2 | // Project: http://www.createjs.com/#!/TweenJS 3 | // Definitions by: Pedro Ferreira 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /* 7 | Copyright (c) 2012 Pedro Ferreira 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | 13 | module createjs { 14 | 15 | export class TweenJS { 16 | // properties 17 | version: string; 18 | buildDate: string; 19 | } 20 | 21 | 22 | export class CSSPlugin { 23 | // properties 24 | static cssSuffixMap: Object; 25 | 26 | // methods 27 | static install(): void; 28 | } 29 | 30 | 31 | export class Ease { 32 | // methods 33 | static backIn(): number; 34 | static backInOut(): number; 35 | static backOut(): number; 36 | static bounceIn(amount: number): number; 37 | static bounceInOut(amount: number): number; 38 | static bounceOut(amount: number): number; 39 | static circIn(amount: number): number; 40 | static circInOut(amount: number): number; 41 | static circOut(amount: number): number; 42 | static cubicIn(): number; 43 | static cubicInOut(): number; 44 | static cubicOut(): number; 45 | static elasticIn(): number; 46 | static elasticInOut(): number; 47 | static elasticOut(): number; 48 | static get(amount: number): (amount: number) => number; 49 | static getBackIn(amount: number): (amount: number) => number; 50 | static getBackInOut(amount: number): (amount: number) => number; 51 | static getBackOut(amount: number): (amount: number) => number; 52 | static getElasticIn(amplitude: number, period: number): (amount: number) => number; 53 | static getElasticInOut(amplitude: number, period: number): (amount: number) => number; 54 | static getElasticOut(amplitude: number, period: number): (amount: number) => number; 55 | static getPowIn(pow: number): (amount: number) => number; 56 | static getPowInOut(pow: number): (amount: number) => number; 57 | static getPowOut(pow: number): (amount: number) => number; 58 | static linear(amount: number): number; 59 | static none(amount: number): number; // same as linear 60 | static quadIn(): (amount: number) => number; 61 | static quadInOut(): (amount: number) => number; 62 | static quadOut(): (amount: number) => number; 63 | static quartIn(): (amount: number) => number; 64 | static quartInOut(): (amount: number) => number; 65 | static quartOut(): (amount: number) => number; 66 | static quintIn(): (amount: number) => number; 67 | static quintInOut(): (amount: number) => number; 68 | static quintOut(): (amount: number) => number; 69 | static sineIn(amount: number): number; 70 | static sineInOut(amount: number): number; 71 | static sineOut(amount: number): number; 72 | } 73 | 74 | 75 | export class Timeline { 76 | constructor (tweens: Tween[], labels: Object, props: Object); 77 | 78 | // properties 79 | duration: number; 80 | ignoreGlobalPause: bool; 81 | loop: bool; 82 | position: number; 83 | 84 | // methods 85 | addLabel(label: string, position: number): void; 86 | addTween(...tween: Tween[]): void; 87 | gotoAndPlay(positionOrLabel: string): void; 88 | gotoAndPlay(positionOrLabel: number): void; 89 | gotoAndStop(positionOrLabel: string): void; 90 | gotoAndStop(positionOrLabel: number): void; 91 | removeTween(...tween: Tween[]): void; 92 | resolve(positionOrLabel: string): number; 93 | resolve(positionOrLabel: number): number; 94 | setPaused(value: bool): void; 95 | setPosition(value: number, actionsMode?: number): void; 96 | tick(delta: number): void; 97 | toString(): string; 98 | updateDuration(): void; 99 | 100 | // events 101 | onChange: (instance: Timeline) => any; 102 | } 103 | 104 | 105 | export class Tween { 106 | constructor (target: Object, props: Object); 107 | 108 | // properties 109 | duration: number; 110 | static IGNORE: Object; 111 | ignoreGlobalPause: bool; 112 | loop: bool; 113 | static LOOP: number; 114 | static NONE: number; 115 | pluginData: Object; 116 | position: number; 117 | static REVERSE: number; 118 | target: Object; 119 | 120 | // methods 121 | call(callback: (tweenObject: Tween) => any, params?: any[], scope?: Object); // when 'params' isn't given, the callback receives a tweenObject 122 | call(callback: (...params: any[]) => any, params?: any[], scope?: Object); // otherwise, it receives the params only 123 | static get(target, props?: Object, pluginData?: Object, override?: bool): Tween; 124 | static hasActiveTweens(target? ): void; 125 | static installPlugin(plugin: Object, properties: Object): void; 126 | pause(tween: Tween): void; 127 | play(tween: Tween): void; 128 | static removeTweens(target): void; 129 | set(props: Object, target? ): void; 130 | setPaused(value: bool): void; 131 | setPosition(value: number, actionsMode: number): void; 132 | static tick(delta: number, paused: bool): void; 133 | to(props: Object, duration?: number, ease?: (amount: number) => number): Tween; 134 | toString(): string; 135 | wait(duration: number): void; 136 | 137 | // events 138 | change: (event) => any; 139 | 140 | // EventDispatcher mixins 141 | addEventListener(type: string, listener: (eventObj: Object) => bool): Function; 142 | addEventListener(type: string, listener: (eventObj: Object) => bool): Object; 143 | removeEventListener(type: string, listener: (eventObj: Function) => bool): void; 144 | removeEventListener(type: string, listener: (eventObj: Object) => bool): void; 145 | removeAllEventListeners(type: string): void; 146 | dispatchEvent(eventObj: string, target: Object): bool; 147 | dispatchEvent(eventObj: Object, target: Object): bool; 148 | hasEventListener(type: string): bool; 149 | } 150 | 151 | 152 | export class MotionGuidePlugin { 153 | // properties 154 | static priority: number; 155 | 156 | //methods 157 | static install(): Object; 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /test/browser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * For testing in browser the library AST and generated model 3 | */ 4 | 5 | var req = new XMLHttpRequest(); 6 | req.onreadystatechange = function(result, b) { 7 | if (req.readyState != 4) return; 8 | 9 | var jsp = require("../lib/parse-js"); 10 | var ast = jsp.parse(req.responseText); 11 | 12 | var builder = require("../lib/model"); 13 | var model = builder.parse(ast[1]); 14 | console.info(model); 15 | } 16 | req.open("GET", "sea/Sea.js", false); 17 | req.send(); 18 | -------------------------------------------------------------------------------- /test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /test/node-test.sh: -------------------------------------------------------------------------------- 1 | ../bin/createjs-def haxe bilbo/bilbo-walkcycle-side.js > bilbo/BilboWalkcycle.hx 2 | ../bin/createjs-def typescript bilbo/bilbo-walkcycle-side.js > bilbo/bilbo-walkcycle-side.d.ts 3 | 4 | ../bin/createjs-def haxe sea/Sea.js > sea/Sea.hx 5 | ../bin/createjs-def typescript sea/Sea.js > sea/Sea.d.ts 6 | -------------------------------------------------------------------------------- /test/sea/Sea-typescript.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Typescript Sea 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/sea/Sea-typescript.js: -------------------------------------------------------------------------------- 1 | var canvas, stage, exportRoot, images; 2 | function init() { 3 | canvas = document.getElementById("canvas"); 4 | images = images || { 5 | }; 6 | var manifest = [ 7 | { 8 | src: "images/bg.png", 9 | id: "bg" 10 | }, 11 | { 12 | src: "sounds/bubbles.mp3", 13 | id: "bubbles" 14 | } 15 | ]; 16 | var loader = new createjs.LoadQueue(false); 17 | loader.installPlugin(createjs.Sound); 18 | loader.addEventListener("fileload", handleFileLoad); 19 | loader.addEventListener("complete", handleComplete); 20 | loader.loadManifest(manifest); 21 | } 22 | function handleFileLoad(evt) { 23 | if(evt.item.type == "image") { 24 | images[evt.item.id] = evt.result; 25 | } 26 | } 27 | function handleComplete() { 28 | exportRoot = new lib.Sea(); 29 | stage = new createjs.Stage(canvas); 30 | stage.addChild(exportRoot); 31 | stage.update(); 32 | createjs.Ticker.setFPS(24); 33 | createjs.Ticker.addEventListener("tick", stage); 34 | } 35 | function playSound(id, loop) { 36 | createjs.Sound.play(id, createjs.Sound.INTERRUPT_EARLY, 0, 0, loop); 37 | } 38 | -------------------------------------------------------------------------------- /test/sea/Sea-typescript.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | 6 | var canvas, stage:createjs.Stage, exportRoot, images; 7 | 8 | function init() { 9 | canvas = document.getElementById("canvas"); 10 | images = images||{}; 11 | 12 | var manifest = [ 13 | {src:"images/bg.png", id:"bg"}, 14 | {src:"sounds/bubbles.mp3", id:"bubbles"} 15 | ]; 16 | 17 | var loader = new createjs.LoadQueue(false); 18 | loader.installPlugin(createjs.Sound); 19 | loader.addEventListener("fileload", handleFileLoad); 20 | loader.addEventListener("complete", handleComplete); 21 | loader.loadManifest(manifest); 22 | } 23 | 24 | function handleFileLoad(evt) { 25 | if (evt.item.type == "image") { images[evt.item.id] = evt.result; } 26 | } 27 | 28 | function handleComplete() { 29 | exportRoot = new lib.Sea(); 30 | 31 | var stage = new createjs.Stage(canvas); 32 | stage.addChild(exportRoot); 33 | stage.update(); 34 | 35 | createjs.Ticker.setFPS(24); 36 | createjs.Ticker.addEventListener("tick", stage); 37 | } 38 | 39 | function playSound(id, loop) { 40 | createjs.Sound.play(id, createjs.Sound.INTERRUPT_EARLY, 0, 0, loop); 41 | } -------------------------------------------------------------------------------- /test/sea/Sea.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module lib { 4 | 5 | export class properties implements Object { 6 | static width: number; 7 | static height: number; 8 | static fps: number; 9 | static color: string; 10 | static manifest: Object[]; 11 | } 12 | 13 | export class Sea extends createjs.MovieClip { 14 | static nominalBounds: createjs.Rectangle; 15 | text: createjs.Text; 16 | shadow: createjs.Shadow; 17 | seaweed: Seaweed; 18 | instance: Star; 19 | instance_1: Star; 20 | instance_2: Star; 21 | instance_3: Star; 22 | octopus: Octopus; 23 | octopus_1: Octopus; 24 | octopus_2: Octopus; 25 | seaweed_1: Seaweed; 26 | seaweed_2: Seaweed; 27 | seaweed_3: Seaweed; 28 | seaweed_4: Seaweed; 29 | seaweed_5: Seaweed; 30 | seaweed_6: Seaweed; 31 | octopus_3: Octopus; 32 | shadow: createjs.Shadow; 33 | seaweed_7: Seaweed; 34 | octopus_4: Octopus; 35 | instance_4: Background; 36 | } 37 | 38 | export class bg extends createjs.Bitmap { 39 | static nominalBounds: createjs.Rectangle; 40 | } 41 | 42 | export class Star extends createjs.Container { 43 | static nominalBounds: createjs.Rectangle; 44 | shape: createjs.Shape; 45 | } 46 | 47 | export class Seaweed extends createjs.Container { 48 | static nominalBounds: createjs.Rectangle; 49 | shape: createjs.Shape; 50 | shape_1: createjs.Shape; 51 | shape_2: createjs.Shape; 52 | } 53 | 54 | export class Octopus extends createjs.Container { 55 | static nominalBounds: createjs.Rectangle; 56 | shape: createjs.Shape; 57 | shape_1: createjs.Shape; 58 | shape_2: createjs.Shape; 59 | shape_3: createjs.Shape; 60 | shape_4: createjs.Shape; 61 | shape_5: createjs.Shape; 62 | shape_6: createjs.Shape; 63 | shape_7: createjs.Shape; 64 | shape_8: createjs.Shape; 65 | shape_9: createjs.Shape; 66 | shape_10: createjs.Shape; 67 | shape_11: createjs.Shape; 68 | shape_12: createjs.Shape; 69 | shape_13: createjs.Shape; 70 | shape_14: createjs.Shape; 71 | shape_15: createjs.Shape; 72 | shape_16: createjs.Shape; 73 | shape_17: createjs.Shape; 74 | shape_18: createjs.Shape; 75 | shape_19: createjs.Shape; 76 | shape_20: createjs.Shape; 77 | shape_21: createjs.Shape; 78 | shape_22: createjs.Shape; 79 | shape_23: createjs.Shape; 80 | shape_24: createjs.Shape; 81 | shape_25: createjs.Shape; 82 | shape_26: createjs.Shape; 83 | shape_27: createjs.Shape; 84 | shape_28: createjs.Shape; 85 | shape_29: createjs.Shape; 86 | shape_30: createjs.Shape; 87 | shape_31: createjs.Shape; 88 | shape_32: createjs.Shape; 89 | shape_33: createjs.Shape; 90 | shape_34: createjs.Shape; 91 | shape_35: createjs.Shape; 92 | shape_36: createjs.Shape; 93 | shape_37: createjs.Shape; 94 | shape_38: createjs.Shape; 95 | shape_39: createjs.Shape; 96 | shape_40: createjs.Shape; 97 | shape_41: createjs.Shape; 98 | } 99 | 100 | export class Background extends createjs.Container { 101 | static nominalBounds: createjs.Rectangle; 102 | instance: bg; 103 | shape: createjs.Shape; 104 | } 105 | 106 | } 107 | 108 | -------------------------------------------------------------------------------- /test/sea/Sea.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CreateJS export from Sea 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /test/sea/Sea.hx: -------------------------------------------------------------------------------- 1 | package lib; 2 | 3 | import createjs.easeljs.MovieClip; 4 | import createjs.easeljs.Rectangle; 5 | import createjs.easeljs.Text; 6 | import createjs.easeljs.Shadow; 7 | import createjs.easeljs.Bitmap; 8 | import createjs.easeljs.Container; 9 | import createjs.easeljs.Shape; 10 | 11 | @:native("lib.properties") 12 | extern class Properties { 13 | public static var width:Int; 14 | public static var height:Int; 15 | public static var fps:Int; 16 | public static var color:Int; 17 | public static var manifest:Dynamic; 18 | } 19 | 20 | @:native("lib.Sea") 21 | extern class Sea extends MovieClip { 22 | static public var nominalBounds:Rectangle; 23 | public var text:Text; 24 | public var shadow:Shadow; 25 | public var seaweed:Seaweed; 26 | public var instance:Star; 27 | public var instance_1:Star; 28 | public var instance_2:Star; 29 | public var instance_3:Star; 30 | public var octopus:Octopus; 31 | public var octopus_1:Octopus; 32 | public var octopus_2:Octopus; 33 | public var seaweed_1:Seaweed; 34 | public var seaweed_2:Seaweed; 35 | public var seaweed_3:Seaweed; 36 | public var seaweed_4:Seaweed; 37 | public var seaweed_5:Seaweed; 38 | public var seaweed_6:Seaweed; 39 | public var octopus_3:Octopus; 40 | public var shadow:Shadow; 41 | public var seaweed_7:Seaweed; 42 | public var octopus_4:Octopus; 43 | public var instance_4:Background; 44 | } 45 | 46 | @:native("lib.bg") 47 | extern class Bg extends Bitmap { 48 | static public var nominalBounds:Rectangle; 49 | } 50 | 51 | @:native("lib.Star") 52 | extern class Star extends Container { 53 | static public var nominalBounds:Rectangle; 54 | public var shape:Shape; 55 | } 56 | 57 | @:native("lib.Seaweed") 58 | extern class Seaweed extends Container { 59 | static public var nominalBounds:Rectangle; 60 | public var shape:Shape; 61 | public var shape_1:Shape; 62 | public var shape_2:Shape; 63 | } 64 | 65 | @:native("lib.Octopus") 66 | extern class Octopus extends Container { 67 | static public var nominalBounds:Rectangle; 68 | public var shape:Shape; 69 | public var shape_1:Shape; 70 | public var shape_2:Shape; 71 | public var shape_3:Shape; 72 | public var shape_4:Shape; 73 | public var shape_5:Shape; 74 | public var shape_6:Shape; 75 | public var shape_7:Shape; 76 | public var shape_8:Shape; 77 | public var shape_9:Shape; 78 | public var shape_10:Shape; 79 | public var shape_11:Shape; 80 | public var shape_12:Shape; 81 | public var shape_13:Shape; 82 | public var shape_14:Shape; 83 | public var shape_15:Shape; 84 | public var shape_16:Shape; 85 | public var shape_17:Shape; 86 | public var shape_18:Shape; 87 | public var shape_19:Shape; 88 | public var shape_20:Shape; 89 | public var shape_21:Shape; 90 | public var shape_22:Shape; 91 | public var shape_23:Shape; 92 | public var shape_24:Shape; 93 | public var shape_25:Shape; 94 | public var shape_26:Shape; 95 | public var shape_27:Shape; 96 | public var shape_28:Shape; 97 | public var shape_29:Shape; 98 | public var shape_30:Shape; 99 | public var shape_31:Shape; 100 | public var shape_32:Shape; 101 | public var shape_33:Shape; 102 | public var shape_34:Shape; 103 | public var shape_35:Shape; 104 | public var shape_36:Shape; 105 | public var shape_37:Shape; 106 | public var shape_38:Shape; 107 | public var shape_39:Shape; 108 | public var shape_40:Shape; 109 | public var shape_41:Shape; 110 | } 111 | 112 | @:native("lib.Background") 113 | extern class Background extends Container { 114 | static public var nominalBounds:Rectangle; 115 | public var instance:Bg; 116 | public var shape:Shape; 117 | } 118 | 119 | 120 | -------------------------------------------------------------------------------- /test/sea/Sea.js: -------------------------------------------------------------------------------- 1 | (function (lib, img, cjs) { 2 | 3 | var p; // shortcut to reference prototypes 4 | 5 | // stage content: 6 | (lib.Sea = function(mode,startPosition,loop) { 7 | this.initialize(mode,startPosition,loop,{}); 8 | 9 | // timeline functions: 10 | this.frame_0 = function() { 11 | playSound("bubbles",-1); 12 | } 13 | 14 | // actions tween: 15 | this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0)); 16 | 17 | // text 18 | this.text = new cjs.Text("Under The Sea!", "bold 48px Arial", "#FFFFFF"); 19 | this.text.textAlign = "center"; 20 | this.text.lineHeight = 50; 21 | this.text.lineWidth = 412; 22 | this.text.setTransform(285.4,18.8,1,1,0,30,0); 23 | this.text.shadow = new cjs.Shadow("rgba(18,69,98,1)",3,3,8); 24 | 25 | this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.text}]}).wait(1)); 26 | 27 | // foreground 28 | this.seaweed = new lib.Seaweed(); 29 | this.seaweed.setTransform(361.8,358.8,0.7,0.7,-19.9); 30 | 31 | this.instance = new lib.Star(); 32 | this.instance.setTransform(438.4,278,0.75,0.75,-19.9); 33 | this.instance.alpha = 0.602; 34 | this.instance.compositeOperation = "lighter"; 35 | 36 | this.instance_1 = new lib.Star(); 37 | this.instance_1.setTransform(438.4,277,0.378,0.378,45); 38 | this.instance_1.alpha = 0.391; 39 | this.instance_1.compositeOperation = "lighter"; 40 | 41 | this.instance_2 = new lib.Star(); 42 | this.instance_2.setTransform(439.4,279,0.54,0.54,30); 43 | this.instance_2.alpha = 0.391; 44 | this.instance_2.compositeOperation = "lighter"; 45 | 46 | this.instance_3 = new lib.Star(); 47 | this.instance_3.setTransform(438.4,278,0.6,0.6); 48 | this.instance_3.alpha = 0.602; 49 | this.instance_3.compositeOperation = "lighter"; 50 | 51 | this.octopus = new lib.Octopus(); 52 | this.octopus.setTransform(385.8,170.5,0.253,0.253,70); 53 | this.octopus.alpha = 0.449; 54 | 55 | this.octopus_1 = new lib.Octopus(); 56 | this.octopus_1.setTransform(432.8,103,0.178,0.178,70); 57 | this.octopus_1.alpha = 0.289; 58 | 59 | this.octopus_2 = new lib.Octopus(); 60 | this.octopus_2.setTransform(481.8,104,0.22,0.22,60); 61 | this.octopus_2.alpha = 0.359; 62 | 63 | this.seaweed_1 = new lib.Seaweed(); 64 | this.seaweed_1.setTransform(451.8,366.8); 65 | 66 | this.seaweed_2 = new lib.Seaweed(); 67 | this.seaweed_2.setTransform(507.8,385.8,1.25,1.25,-11.9); 68 | 69 | this.seaweed_3 = new lib.Seaweed(); 70 | this.seaweed_3.setTransform(274.7,389.8,1.322,1.322,7); 71 | 72 | this.seaweed_4 = new lib.Seaweed(); 73 | this.seaweed_4.setTransform(72.7,360.8,1.013,1.013,-14.9); 74 | 75 | this.seaweed_5 = new lib.Seaweed(); 76 | this.seaweed_5.setTransform(171.7,382.8); 77 | 78 | this.seaweed_6 = new lib.Seaweed(); 79 | this.seaweed_6.setTransform(217.8,353.8,0.7,0.7,-19.9); 80 | 81 | this.octopus_3 = new lib.Octopus(); 82 | this.octopus_3.setTransform(134.8,193.9,1,1,-4.9); 83 | this.octopus_3.shadow = new cjs.Shadow("rgba(0,204,255,1)",0,0,32); 84 | 85 | this.seaweed_7 = new lib.Seaweed(); 86 | this.seaweed_7.setTransform(263.7,351.8,0.9,0.9,-7.9); 87 | 88 | this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.seaweed_7},{t:this.octopus_3},{t:this.seaweed_6},{t:this.seaweed_5},{t:this.seaweed_4},{t:this.seaweed_3},{t:this.seaweed_2},{t:this.seaweed_1},{t:this.octopus_2},{t:this.octopus_1},{t:this.octopus},{t:this.instance_3},{t:this.instance_2},{t:this.instance_1},{t:this.instance},{t:this.seaweed}]}).wait(1)); 89 | 90 | // background 91 | this.octopus_4 = new lib.Octopus(); 92 | this.octopus_4.setTransform(499.5,282.8,0.54,0.54,10); 93 | this.octopus_4.alpha = 0.898; 94 | 95 | this.instance_4 = new lib.Background(); 96 | this.instance_4.setTransform(275.2,200,1,1,0,0,0,275.2,200); 97 | this.instance_4.cache(-1,-1,554,404); 98 | 99 | this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.instance_4},{t:this.octopus_4}]}).wait(1)); 100 | 101 | }).prototype = p = new cjs.MovieClip(); 102 | p.nominalBounds = new cjs.Rectangle(0,0,569.9,400); 103 | 104 | 105 | // symbols: 106 | (lib.bg = function() { 107 | this.initialize(img.bg); 108 | }).prototype = p = new cjs.Bitmap(); 109 | p.nominalBounds = new cjs.Rectangle(0,0,550,160); 110 | 111 | 112 | (lib.Star = function() { 113 | this.initialize(); 114 | 115 | // Layer 1 116 | this.shape = new cjs.Shape(); 117 | this.shape.graphics.lf(["#0B3579","#04A18A"],[0,1],-69.7,0,69.9,0).s().p("AhvB2IpKFPIH0nFIn0nEIJKFPIEUpoIiKKWIKfBHIqfBJICKKUg"); 118 | this.shape.setTransform(6.9,3.4); 119 | 120 | this.addChild(this.shape); 121 | }).prototype = p = new cjs.Container(); 122 | p.nominalBounds = new cjs.Rectangle(-62.9,-69.9,139.7,146.8); 123 | 124 | 125 | (lib.Seaweed = function() { 126 | this.initialize(); 127 | 128 | // leaf1 129 | this.shape = new cjs.Shape(); 130 | this.shape.graphics.f("#000000").s().p("AiWHMQgHgPAAgfQAAiCAzhpQAZgwAJgXQAQglAAghIgJiMQAAgVAWgmQAGgLAqhAQBIhqAAg/QAAgSgNgRQgOgQAAgCQAAgIAEgDQAFgDAPAAQAeAAAXAaQAfAiAAA/QAAAbgQAdQgRAegnAnQhEBEgJBRQgFAtAJBEQAAArgOAlQgFALghA5Qg9BqgUCbQgCgBgDgMQgCgLAAgIQAAh8BBheIAthBQASgkAAgmQgIh1AAgKQAAhPBIhKQApgoAKgQQAYggAAglQAAgugSgcQgQgbgdgGIgOgCQAeAYAAAhQAAAzhKBrQhHBrAAAlQAAAKAJBvQAAApgQAtQgFAOgfBFQg0B1AABxQAAAKADAQQACARAEAHQgIgGgEgHg"); 131 | this.shape.setTransform(11.9,-37,0.696,0.696); 132 | 133 | this.shape_1 = new cjs.Shape(); 134 | this.shape_1.graphics.f("#000000").s().p("AkuISQgDgUAAgLQAAhNA5g2QAhgfBdgyQBZgwAigmQA5g7AAhXQgIhnAEhCQAJh5BFgpICOhTQA0gkAAgyQgBgPgSghQgXgngZgPIADAKQANAcgkAwQggAshRBGQgnAhgMAPQgZAdgKAnQgbBkgIA9QgFAhAAAkQgHA6g2A+QgXAahbBSQhNBFghAxQgyBIAABQIAGATQAEAUADAFIgCgCIgLgbIgGgUQAAhfAyhOQAkg1BMhAQBfhPAQgSQAzg3AAg3QAAkACChrQAigbA5goQApgkAAgzIgQgnIAEgEQADgBAGAAQAkAAAdAcQAjAjAAA/QAAA2grAfQgMAJhTAlQhAAdgeAnQgrA3AABgQAAAIAGAVQAEAkAABSQABBag7A8QgeAihgA4QhcA1gmAsQg6BFAABoQgFgMgCgZg"); 135 | this.shape_1.setTransform(26.7,-37.8,0.696,0.696); 136 | 137 | this.shape_2 = new cjs.Shape(); 138 | this.shape_2.graphics.f("#21B573").s().p("Ak/H+QgYgrAAgSQAAilA1hdQAbgqAKgWQAQgkAAgtQABgrgKghQgJgcAAgGQAAgtBLh1QBKh1AAgsQgagqgCgRIABgEQAAgCAHAAQAeAAAYAgQAbAkAAA1QAAAigXAiQgLAPgpArQhKBQAABOQgBAKALBbQgBAagbA5QgaA3geApQgMARgSBYQgOBCgFAqIAAAGQAZhLAjgvQAiguBdhTQAZgWAfgWQAcgRAIgKQAagdAYh7QAMhlAJgrQAPhIA3hJQAQgXBhhYQA8g3AAg1QAAgOAJgHQAlAkAIANQAOAVAAAlQAAA2gmAdQg2AegfAUIguAZQgLAGgeAiQg+BHAGB9QAFBYgBAMQgBA6gUAtQgjBThbAqIhGAcQgmAPgSARQhCA/gTA9QgNAmAGAvIAAADQAAACgHAAQgGAAgXgqg"); 139 | this.shape_2.setTransform(25.4,-38,0.696,0.696); 140 | 141 | this.addChild(this.shape_2,this.shape_1,this.shape); 142 | }).prototype = p = new cjs.Container(); 143 | p.nominalBounds = new cjs.Rectangle(0.9,-77.4,49.7,79); 144 | 145 | 146 | (lib.Octopus = function() { 147 | this.initialize(); 148 | 149 | // octoAnim 150 | this.shape = new cjs.Shape(); 151 | this.shape.graphics.f("#000000").s().p("AgKA4QgIgYAIgiQAHggAOgYQAAAAABgBQAAAAAAAAQABAAAAAAQABAAAAAAQABABAAAAQAAAAAAABQAAAAAAABQAAAAAAABQgMAbgCAjIABAZQAAAPgCAJQgBAEgEAAQgEAAgBgEg"); 152 | this.shape.setTransform(-7.7,34.1,0.701,0.701); 153 | 154 | this.shape_1 = new cjs.Shape(); 155 | this.shape_1.graphics.f("#000000").s().p("AgRFRQgUAIgogUQgqgWgMgyQgDgKACgcQACghALAGQgDgBAHAnQAGAoAFAHQAMAUAXAMQAVAMAYABQgPhDA6huQAohJAoheQASgtAAg6QAAg0gPg0QgKghgVgjQgCgDgSgPIgRgOQgBgKATAGQAQAEAFAFQARAPAQAiQAaA8ACBFIAAAAQACA8gRA8QgOAuggBBQgPAfghA+QgZA3gEAsIgBAqQgCAZgGAAQgCAAgCgDg"); 156 | this.shape_1.setTransform(32.4,37.1,0.701,0.701); 157 | 158 | this.shape_2 = new cjs.Shape(); 159 | this.shape_2.graphics.f("#000000").s().p("AgvErQgbgKgXgiQgNgTgVgpQgZgygCgnQAAgHAGgVQAGgXAEAOQAaB0AGAOQAfBXA1AGQgSg+BIh3IAuhIQAZgnAPgjQAihPgLhVQgGgrgQgfIgOgQQgNgNAAABQACgGAUASQATARADAGQAQAXAFAZIADAPQAGAhgIgnQANBNgbBPQgUA4g3BXQgcArgPAeQgUAogGAnQgEARgBAgQgDANgOAAQgIAAgNgFg"); 160 | this.shape_2.setTransform(19.1,44.4,0.701,0.701); 161 | 162 | this.shape_3 = new cjs.Shape(); 163 | this.shape_3.graphics.f("#000000").s().p("AhSD0QgYglgOggQgLgYgFgeQgGgkAIgTQADgGAFAUIADATQAIAoAMAfQANAgAJAPQAPAcASAKQAHgcAbgnQAegrAMgVIAnhCQAVgmAMgdQAahFgJhZQgBgMgZg0Qgag1gDADQAKgLAgBAQAdA6ADARQAKA+gUBDQgRAygnBCQgYApgxBQIgPAkQgLAagHACQgDAGgFAAQgMAAgagng"); 164 | this.shape_3.setTransform(2,47.5,0.701,0.701); 165 | 166 | this.shape_4 = new cjs.Shape(); 167 | this.shape_4.graphics.f("#000000").s().p("AA1GGQAKg3AAgNQABgkgdg3QgOBIhBAlQgxAbgzAAQgMAAgFgFQgEgEAAgEQAAgIAJgkQAJgjAAgGQAAgagUgxIgrhlQg/iTAAh1QAAhfAihHQAmg7AGgPIAGAAQAEACAAAGIgkBfQgjBdAAA2QAABzA/B9QAjBGAIAXQAUA0AAAzQAAArgOAdQBNgFAsgsQAigkAAgvQAAgOgfhGQgihHAAhGQAEgcAGgeQALg9ANgJIADACIgUA7QAABYA7CNQA9COAAAsQAAALgCARQgDAVgDAAIAXACQAxAAAug0QA+hGAAh+QAAg8gUg2QgUgzg0hTIABgBQAeAMAhA3QAvBMAABpQAACMhPBNQg5A3g1AAQggAAAAgWg"); 168 | this.shape_4.setTransform(-25.1,37.6,0.701,0.701); 169 | 170 | this.shape_5 = new cjs.Shape(); 171 | this.shape_5.graphics.f("#000000").s().p("AggA/IAageQAUgaADgJQAGgYADgVIADgRIAAgBIAEAWQgCAcgXAlQgVAlgPAHQgBAAAAgBQgBAAAAAAQgBgBAAAAQAAgBgBAAg"); 172 | this.shape_5.setTransform(31.4,23.4,0.701,0.701); 173 | 174 | this.shape_6 = new cjs.Shape(); 175 | this.shape_6.graphics.f("#000000").s().p("AgGBEQgXgYAAgtQAAggABgMQAEgfAPgPQAHAKgDAtQgCAWgDAUQAAAWASAaQAVAbABAKQgdgPgHgIg"); 176 | this.shape_6.setTransform(-36.5,18.2,0.701,0.701); 177 | 178 | this.shape_7 = new cjs.Shape(); 179 | this.shape_7.graphics.f("#000000").s().p("AmWJjQhpgfg9isQgziOAAiiQAAkpC/jPQDBjSEZAAQCbAACABsQCFBwBYDbQAYA8AaBdQAcBiAAAmQAADciTCUQhJBMhPAfIgHAAIAAgBIgDgGQBTgUBjiUQBpidAAiEQAAhOghhwQgliDhBhuQitkkkQAAQkDAAi4DNQi3DNAAEhQAADNBPCWQAyBeBGA5g"); 180 | this.shape_7.setTransform(1.2,-19.4,0.701,0.701); 181 | 182 | this.shape_8 = new cjs.Shape(); 183 | this.shape_8.graphics.f("#000000").s().p("AgMAZQgGgLAAgOQAAgNAGgLQAFgKAHAAQAIAAAFAKQAGALAAANQAAAOgGALQgFALgIAAQgHAAgFgLg"); 184 | this.shape_8.setTransform(25.5,-22.2,0.701,0.701); 185 | 186 | this.shape_9 = new cjs.Shape(); 187 | this.shape_9.graphics.f("#000000").s().p("AgMAZQgGgLAAgOQAAgOAGgKQAFgKAHAAQAHAAAGAKQAGAKAAAOQAAAOgGALQgGALgHAAQgHAAgFgLg"); 188 | this.shape_9.setTransform(-17.1,-20.1,0.701,0.701); 189 | 190 | this.shape_10 = new cjs.Shape(); 191 | this.shape_10.graphics.f("#000000").s().p("AgtAMQgUgKgJgKQAJAHAQAGQAZALAYAAQAVgBAbgQIAYgWQADABAAAKQgBARgbALQgXAHgdABQgUAAgUgMg"); 192 | this.shape_10.setTransform(8.2,8.9,0.701,0.701); 193 | 194 | this.shape_11 = new cjs.Shape(); 195 | this.shape_11.graphics.f("#000000").s().p("AipBJQgUgQABghQAAgPAQgeQAPghANgKIADACQgJAZgZA4QAAAZANAOQAMANATAAQAZAAA5gSIA3gTQAUAAAmAJQAmAKAJgBQAhABARgWQAOgSAAgYQAAgUgHgPIAHAJQAOAQAAAVQABAcgWAUQgVATgeAAQgKAAhcgQQgYAAg/ASIg6ASQgYAAgPgOgACFhSIABgEIAPATIgQgPg"); 196 | this.shape_11.setTransform(8.1,1.4,0.701,0.701); 197 | 198 | this.shape_12 = new cjs.Shape(); 199 | this.shape_12.graphics.f("#000000").s().p("AgfARIgWgIQAHgEAugDQArgEALgTIgHANQgbAdglAAIgOgEg"); 200 | this.shape_12.setTransform(26.7,-17.7,0.701,0.701); 201 | 202 | this.shape_13 = new cjs.Shape(); 203 | this.shape_13.graphics.f("#000000").s().p("AglAyQgQgUABgeQgBgdAQgUQAQgWAVAAQAWAAAQAWQAQAUAAAdQAAAegQAUQgQAWgWgBQgVABgQgWgAgZgqQgLARAAAYQAAAWALARQALARAPAAQARAAALgRQAMgRgBgWQABgYgMgRQgLgRgRAAQgPAAgLARg"); 204 | this.shape_13.setTransform(25.1,-21.7,0.701,0.701); 205 | 206 | this.shape_14 = new cjs.Shape(); 207 | this.shape_14.graphics.f("#000000").s().p("AgKACQgegKgIgEQAOADBSAJQgFAFgDAFQgCADgRAAQgDAAgcgLg"); 208 | this.shape_14.setTransform(-20.7,-15,0.701,0.701); 209 | 210 | this.shape_15 = new cjs.Shape(); 211 | this.shape_15.graphics.f("#000000").s().p("AglA1QgQgWAAgfQAAgeAQgWQAQgWAVAAQAWAAAQAWQAQAWAAAeQAAAfgQAWQgQAWgWAAQgVAAgQgWgAgcgqQgNATAAAYQAAAaANASQAMASAQABQARgBAMgSQAMgSABgaQgBgYgMgTQgMgSgRAAQgQAAgMASg"); 212 | this.shape_15.setTransform(-17.6,-19.7,0.701,0.701); 213 | 214 | this.shape_16 = new cjs.Shape(); 215 | this.shape_16.graphics.f("#00C1AE").s().p("AhSENIgBgBQgDgXAAgKQAAgpAWgtQAKgTAng/QBGhvAAhiQAAg7gOgdQgRgYgHgQQAaAFAOARQAeAoAABrQAAAyggA1QhFB5gQAiQgDAGgRA+QgMAugMAAQgGAAgCgCg"); 216 | this.shape_16.setTransform(35,37.5,0.701,0.701); 217 | 218 | this.shape_17 = new cjs.Shape(); 219 | this.shape_17.graphics.f("#00C1AE").s().p("AhYD0IgCgdQAAgpBOiNQBKiKAAhAQAAgVgIgZIgMgiQAYAZALAVQANAdAAAqQAABOgvBOQhZCagfBIQgJgHgCABg"); 220 | this.shape_17.setTransform(21.9,42.8,0.701,0.701); 221 | 222 | this.shape_18 = new cjs.Shape(); 223 | this.shape_18.graphics.f("#00C1AE").s().p("AgGAGIAAgLIANAAIAAALg"); 224 | this.shape_18.setTransform(-3.1,42.4,0.701,0.701); 225 | 226 | this.shape_19 = new cjs.Shape(); 227 | this.shape_19.graphics.f("#00C1AE").s().p("AAGBpQgKgJgJgeIgHgcQAAghAQgzQAOgyALgIQABASgIAzIgIA2IAKBSIgBAEg"); 228 | this.shape_19.setTransform(-4.3,52.3,0.701,0.701); 229 | 230 | this.shape_20 = new cjs.Shape(); 231 | this.shape_20.graphics.f("#00C1AE").s().p("AA9D6QgzhigbhDQg1h7AAhNQAAhLATggQAKgRAYgKQgTBeAAALQAAB1A0BjIAmBIQARAoAAAnQAAAKgDARg"); 232 | this.shape_20.setTransform(-22.3,43.5,0.701,0.701); 233 | 234 | this.shape_21 = new cjs.Shape(); 235 | this.shape_21.graphics.f("#00C1AE").s().p("AAxDQQgLgfgmhJQhKiUAAh7QAAhWAohCQAEAGACAAQADARgBAMQAAAKgCARIgHAbQgEANABAFQAACEA3CWIAoBoQASA0AAAiQAAAJgFAUQgEAVgFAKQAHg2gTg6g"); 236 | this.shape_21.setTransform(-37.4,35.5,0.701,0.701); 237 | 238 | this.shape_22 = new cjs.Shape(); 239 | this.shape_22.graphics.f("#00C1AE").s().p("AgBBRQhAhIg6iRIADgGQAZABAjA6IAyBSQAUAWBCA3QAwAoAAAQQAAAGgCACIgBACIgOABQg3AAg1g+g"); 240 | this.shape_22.setTransform(-28.3,11.9,0.701,0.701); 241 | 242 | this.shape_23 = new cjs.Shape(); 243 | this.shape_23.graphics.f("#00C1AE").s().p("AAsAXQgjgMgRAAQgPAAgaAMIgYALQgKAAgCgDIgCgIQAHgPAdgTQAfgZAUAAQAiABAdAYQAZAUAAAVQAAACAAACQAAACAAAAQAAABAAgBQAAAAAAgCIgBABQgCABgGAAg"); 244 | this.shape_23.setTransform(-16.8,-25.2,0.701,0.701); 245 | 246 | this.shape_24 = new cjs.Shape(); 247 | this.shape_24.graphics.f("#00C1AE").s().p("AhHAUQAAg+BHAKQAaAEAYAMQAWAMAAAJQAAAKgDAAIgQABIgdgEIgcgEIgRANQgUANgSAAQgMAAAAgOg"); 248 | this.shape_24.setTransform(24,-26.5,0.701,0.701); 249 | 250 | this.shape_25 = new cjs.Shape(); 251 | this.shape_25.graphics.f("#00C1AE").s().p("AgKAQQgEgHAAgJQAAgIAEgHQAFgHAFAAQAGAAAFAHQAEAHAAAIQAAAJgEAHQgFAHgGAAQgFAAgFgHg"); 252 | this.shape_25.setTransform(36.9,-24.8,0.701,0.701); 253 | 254 | this.shape_26 = new cjs.Shape(); 255 | this.shape_26.graphics.f("#00C1AE").s().p("ACGDEIgqg9IhUh9QgagphGhOQg2g8AAgQIALgKQARAHAqAkQAxAqAqAxQB8CJAABqQAAAHgCADQgBACgFACg"); 256 | this.shape_26.setTransform(25.9,-42.1,0.701,0.701); 257 | 258 | this.shape_27 = new cjs.Shape(); 259 | this.shape_27.graphics.f("#00C1AE").s().p("AgNBIQgJgGABgFQAAgUAKgMQAKgJAAgBQAAgRgWglQgYgmAAgFQBegCABBgQgBAagFANQgLAYgdAAQgHAAgIgHg"); 260 | this.shape_27.setTransform(17.3,0,0.701,0.701); 261 | 262 | this.shape_28 = new cjs.Shape(); 263 | this.shape_28.graphics.f("#009183").s().p("AgcAgIgCgHQAKgJAZggQALgOAPgDQgCAegwAlQgHAAgCgCg"); 264 | this.shape_28.setTransform(29.2,-19.4,0.701,0.701); 265 | 266 | this.shape_29 = new cjs.Shape(); 267 | this.shape_29.graphics.f("#009183").s().p("AgSAJQgYgYgCgRQAnAWAbANQAPAIAIAGIgEAOQgHACgIAAQgYAAgUgYg"); 268 | this.shape_29.setTransform(-22.1,-15.8,0.701,0.701); 269 | 270 | this.shape_30 = new cjs.Shape(); 271 | this.shape_30.graphics.f("#009183").s().p("AhDDgIgFgdIAohtQAmhtAAhHQAAgFgFgXIgDgWQAAgTAHgGIATgHQAcgIAAg1IgBgOIgBgKQAPADAEAKQAEAIAAAUQAAAEgIAZQgKAfgMARIAKBIQgBA9gPAoQgMAegYAfQgeApgHAuQgCAPAABFQgTgIgKgeg"); 272 | this.shape_30.setTransform(29.8,39.4,0.701,0.701); 273 | 274 | this.shape_31 = new cjs.Shape(); 275 | this.shape_31.graphics.f("#009183").s().p("AAdD+QgxhDAAgwQAAgUAOhGQAMhDAAgcQAAg4gdhJQgghAAAgIIAAgHIAAABQAGAGAWASQAYATAMAQQAvA4AABeQAAAdgPBTQgPBVAAAHQABAQAFAfQAGAfAAAKQAAAHgFAAIgEgBg"); 276 | this.shape_31.setTransform(10.6,44,0.701,0.701); 277 | 278 | this.shape_32 = new cjs.Shape(); 279 | this.shape_32.graphics.f("#009183").s().p("AhEEBIgGAAQgFgEAAgQQAAgiAVgrIAuhSQBBh1AAh2QAAgGgIghQgJgfAAgXQAAgFACgBIADABIABACQAMALALAjQAPAxAAA+QAABHgzBpIheCxIADAAg"); 280 | this.shape_32.setTransform(2.3,45.6,0.701,0.701); 281 | 282 | this.shape_33 = new cjs.Shape(); 283 | this.shape_33.graphics.f("#009183").s().p("AAhAuIhohjIAEgGQApAVA7AdQAoAVgBAYQAAAYgMAAQgKAAgRgOg"); 284 | this.shape_33.setTransform(-12.3,30.6,0.701,0.701); 285 | 286 | this.shape_34 = new cjs.Shape(); 287 | this.shape_34.graphics.f("#009183").s().p("AiBBGQA/gLBWg9QBlhKAFgCQASAdhEA8QhHBChEAAIggACQgcAAgGgJg"); 288 | this.shape_34.setTransform(27.2,18.7,0.701,0.701); 289 | 290 | this.shape_35 = new cjs.Shape(); 291 | this.shape_35.graphics.f("#009183").s().p("AguAdQgqgUgNgiIABgIQAPgGAUAPQAaAUApAAQAKAAApgTIApgTQAKAAgCAEQgDAYgXAZQgdAggjAAQgaAAgggOg"); 292 | this.shape_35.setTransform(7.9,10.1,0.701,0.701); 293 | 294 | this.shape_36 = new cjs.Shape(); 295 | this.shape_36.graphics.f("#009183").s().p("AgrD5QAkhVAPhHQALgxAAgaQAAhigvhRIgigzQgQgYAAgOQAAgGADAAIADABQBRBBAVAdQAxBFAAB8QAABIgiA5QgaArg6A1QgDgBgBgHg"); 296 | this.shape_36.setTransform(-11.6,45,0.701,0.701); 297 | 298 | this.shape_37 = new cjs.Shape(); 299 | this.shape_37.graphics.f("#009183").s().p("AgKEsIgBgHIAhg5QAagsAAgRIgWhBQgXhDAAguIAPhZQgvgLgmg8Qgjg1AAgsQAKggAHgKQACA3AuA2QAlAsAnANIAjgsQAHABABAHQgCAGgPAfQgPAlAAAwQAAAfAOA0QAFAUAOAuIANAqQAHASgBALQABAngZApQgfA1gwAAQgGAAgDgDg"); 300 | this.shape_37.setTransform(-32,39.4,0.701,0.701); 301 | 302 | this.shape_38 = new cjs.Shape(); 303 | this.shape_38.graphics.f("#009183").s().p("Ag3ARQgwhCATgjIAJgCIAGgDQADgCAAAGQAAAlA2AzQAxAwA1AZIgGAHQgOAIgKAAQhBAAgyhKg"); 304 | this.shape_38.setTransform(-31.3,18.7,0.701,0.701); 305 | 306 | this.shape_39 = new cjs.Shape(); 307 | this.shape_39.graphics.f("#F2F2F2").s().p("AgdAwQgNgVAAgbQAAgbANgUQAMgTARgBQASABAMATQANAUAAAbQAAAbgNAVQgMATgSAAQgRAAgMgTg"); 308 | this.shape_39.setTransform(25.1,-21.6,0.701,0.701); 309 | 310 | this.shape_40 = new cjs.Shape(); 311 | this.shape_40.graphics.f("#F2F2F2").s().p("AgdAwQgNgUAAgcQAAgbANgUQANgUAQAAQARAAANAUQANAUAAAbQAAAcgNAUQgNAUgRAAQgQAAgNgUg"); 312 | this.shape_40.setTransform(-17.6,-19.5,0.701,0.701); 313 | 314 | this.shape_41 = new cjs.Shape(); 315 | this.shape_41.graphics.f("#00A99D").s().p("Ag1N7QgWg7gdg1QgSAWgmA8QgpAxg/AAQggAAAAgVQAAgJAHgRQAHgQAAgFQAAgagxhYIgIgNQgPBSguAoQgmAhgzAAQgXAAAAgVQAAgHAJgcQAIgcAAgLQAAgbgTgwIgrhhQg/iQAAh0QAAhTAihTQAhhTAAgOQAAgdgYhJQgYhLAAhsQAAlADtjXQBbhRBrgwQBegrBDAAQEAAACdCsQCqC4AoFzIAAgNIADAdQAABDgkBbQgXA4g9B3QAEABAKAKQAPAQANAWQApBIAAByQAAACgiBYQglBggRAmQgqBcgNBNQgEAZgDAFQgEAHgPAAQgqAAgYguQgQgeAAgUQAAgNAGgYIADgMQgQAbgrBvQghBRgQAAQgTAAgagpQgkg2gZhnQgkAyhMBzQgaArgSAAQgRAAgIgWg"); 316 | this.shape_41.setTransform(0.1,1.8,0.701,0.701); 317 | 318 | this.addChild(this.shape_41,this.shape_40,this.shape_39,this.shape_38,this.shape_37,this.shape_36,this.shape_35,this.shape_34,this.shape_33,this.shape_32,this.shape_31,this.shape_30,this.shape_29,this.shape_28,this.shape_27,this.shape_26,this.shape_25,this.shape_24,this.shape_23,this.shape_22,this.shape_21,this.shape_20,this.shape_19,this.shape_18,this.shape_17,this.shape_16,this.shape_15,this.shape_14,this.shape_13,this.shape_12,this.shape_11,this.shape_10,this.shape_9,this.shape_8,this.shape_7,this.shape_6,this.shape_5,this.shape_4,this.shape_3,this.shape_2,this.shape_1,this.shape); 319 | }).prototype = p = new cjs.Container(); 320 | p.nominalBounds = new cjs.Rectangle(-44.4,-62.3,89.5,129.8); 321 | 322 | 323 | (lib.Background = function() { 324 | this.initialize(); 325 | 326 | // Layer 1 327 | this.instance = new lib.bg(); 328 | this.instance.setTransform(0.5,240); 329 | 330 | this.shape = new cjs.Shape(); 331 | this.shape.graphics.lf(["#0B3579","#04A18A"],[0,1],-256.3,199.3,-289.4,-159.2).s().dr(-275,-200,550,400); 332 | this.shape.setTransform(275,200); 333 | 334 | this.addChild(this.shape,this.instance); 335 | }).prototype = p = new cjs.Container(); 336 | p.nominalBounds = new cjs.Rectangle(0,0,550.5,400); 337 | 338 | })(lib = lib||{}, images = images||{}, createjs = createjs||{}); 339 | var lib, images, createjs; -------------------------------------------------------------------------------- /test/sea/easeljs/easeljs.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for EaselJS 0.6 2 | // Project: http://www.createjs.com/#!/EaselJS 3 | // Definitions by: Pedro Ferreira 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /* 7 | Copyright (c) 2012 Pedro Ferreira 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | 13 | 14 | /// 15 | 16 | // rename the native MouseEvent, to avoid conflit with createjs's MouseEvent 17 | interface NativeMouseEvent extends MouseEvent { 18 | 19 | } 20 | 21 | module createjs { 22 | // :: base classes :: // 23 | 24 | export class DisplayObject { 25 | // properties 26 | alpha: number; 27 | cacheCanvas: HTMLCanvasElement; 28 | cacheID: number; 29 | compositeOperation: string; 30 | cursor: string; 31 | filters: Filter[]; 32 | hitArea: DisplayObject; 33 | id: number; 34 | mask: Shape; 35 | mouseEnabled: bool; 36 | name: string; 37 | parent: DisplayObject; 38 | regX: number; 39 | regY: number; 40 | rotation: number; 41 | scaleX: number; 42 | scaleY: number; 43 | shadow: Shadow; 44 | skewX: number; 45 | skewY: number; 46 | snapToPixel: bool; 47 | static suppressCrossDomainErrors: bool; 48 | visible: bool; 49 | x: number; 50 | y: number; 51 | 52 | // methods 53 | cache(x: number, y: number, width: number, height: number, scale?: number): void; 54 | clone(): DisplayObject; 55 | draw(ctx: CanvasRenderingContext2D, ignoreCache?: bool): void; 56 | getCacheDataURL(): string; 57 | getChildByName(name: string): DisplayObject; 58 | getConcatenatedMatrix(mtx: Matrix2D): Matrix2D; 59 | getMatrix(matrix: Matrix2D): Matrix2D; 60 | getStage(): Stage; 61 | globalToLocal(x: number, y: number): Point; 62 | hitTest(x: number, y: number): bool; 63 | isVisible(): bool; 64 | localToGlobal(x: number, y: number): Point; 65 | localToLocal(x: number, y: number, target: DisplayObject): Point; 66 | set(props: Object): DisplayObject; 67 | setTransform(x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX: number, regY: number): DisplayObject; 68 | setupContext(ctx: CanvasRenderingContext2D): void; 69 | toString(): string; 70 | uncache(): void; 71 | updateCache(compositeOperation: string): void; 72 | 73 | // events 74 | click: (event: MouseEvent) => any; 75 | dblClick: (event: MouseEvent) => any; 76 | mouseout: (event: MouseEvent) => any; 77 | mouseover: (event: MouseEvent) => any; 78 | mousedown: (event: MouseEvent) => any; 79 | tick: () => any; 80 | 81 | // EventDispatcher mixins 82 | addEventListener(type: string, listener: (eventObj: Object) => bool): Function; 83 | addEventListener(type: string, listener: (eventObj: Object) => void): Function; 84 | addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): Object; 85 | addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): Object; 86 | removeEventListener(type: string, listener: (eventObj: Object) => bool): void; 87 | removeEventListener(type: string, listener: (eventObj: Object) => void): void; 88 | removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): void; 89 | removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): void; 90 | removeAllEventListeners(type: string): void; 91 | dispatchEvent(eventObj: string, target: Object): bool; 92 | dispatchEvent(eventObj: Object, target: Object): bool; 93 | hasEventListener(type: string): bool; 94 | } 95 | 96 | 97 | export class Filter { 98 | constructor (); 99 | applyFilter(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, targetCtx?: CanvasRenderingContext2D, targetX?: number, targetY?: number): bool; 100 | clone(): Filter; 101 | getBounds(): Rectangle; 102 | toString(): string; 103 | } 104 | 105 | 106 | // :: The rest :: // 107 | 108 | export class AlphaMapFilter extends Filter { 109 | // properties 110 | alphaMap: any; //Image or HTMLCanvasElement 111 | 112 | // methods 113 | constructor (alphaMap: HTMLImageElement); 114 | constructor (alphaMap: HTMLCanvasElement); 115 | clone(): AlphaMapFilter; 116 | } 117 | 118 | 119 | export class AlphaMaskFilter extends Filter { 120 | // properties 121 | mask: any; // HTMLImageElement or HTMLCanvasElement 122 | 123 | // methods 124 | constructor (mask: HTMLImageElement); 125 | constructor (mask: HTMLCanvasElement); 126 | clone(): AlphaMaskFilter; 127 | } 128 | 129 | 130 | export class Bitmap extends DisplayObject { 131 | // properties 132 | image: any; // HTMLImageElement or HTMLCanvasElement or HTMLVideoElement 133 | snapToPixel: bool; 134 | sourceRect: Rectangle; 135 | 136 | // methods 137 | constructor (imageOrUrl: HTMLImageElement); 138 | constructor (imageOrUrl: HTMLCanvasElement); 139 | constructor (imageOrUrl: HTMLVideoElement); 140 | constructor (imageOrUrl: string); 141 | 142 | clone(): Bitmap; 143 | updateCache(): void; 144 | } 145 | 146 | 147 | export class BitmapAnimation extends DisplayObject { 148 | // properties 149 | currentAnimation: string; 150 | currentAnimationFrame: number; 151 | currentFrame: number; 152 | offset: number; 153 | paused: bool; 154 | snapToPixel: bool; 155 | spriteSheet: SpriteSheet; 156 | 157 | // methods 158 | constructor (spriteSheet: SpriteSheet); 159 | advance(): void; 160 | cache(): void; 161 | clone(): BitmapAnimation; 162 | getBounds(): Rectangle; 163 | gotoAndPlay(frameOrAnimation: string): void; 164 | gotoAndPlay(frameOrAnimation: number): void; 165 | play(): void; 166 | stop(): void; 167 | updateCache(): void; 168 | 169 | // events 170 | onAnimationEnd: (event: Object) => any; 171 | } 172 | 173 | export class ButtonHelper { 174 | // properties 175 | target: Object; 176 | overLabel: string; 177 | outLabel: string; 178 | downLabel: string; 179 | play: bool; 180 | 181 | // methods 182 | constructor(target: MovieClip, outLabel: string, overLabel: string, downLabel: string, play: bool, hitArea: DisplayObject, hitLabel: string); 183 | constructor(target: BitmapAnimation, outLabel: string, overLabel: string, downLabel: string, play: bool, hitArea: DisplayObject, hitLabel: string); 184 | setEnabled(value: bool); 185 | toString(): string; 186 | } 187 | 188 | export class BoxBlurFilter extends Filter { 189 | // properties 190 | blurX: number; 191 | blurY: number; 192 | quality: number; 193 | 194 | // methods 195 | constructor (blurX: number, blurY: number, quality: number); 196 | clone(): BoxBlurFilter; 197 | } 198 | 199 | 200 | export class ColorFilter extends Filter { 201 | // properties 202 | alphaOffset: number; 203 | blueMultiplier: number; 204 | blueOffset: number; 205 | greenMultiplier: number; 206 | greenOffset: number; 207 | redMultiplier: number; 208 | redOffset: number; 209 | 210 | // methods 211 | constructor (redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaMultiplier?: number, redOffset?: number, greenOffset?: number, blueOffset?: number, alphaOffset?: number); 212 | clone(): ColorFilter; 213 | } 214 | 215 | 216 | export class ColorMatrix { 217 | // properties 218 | DELTA_INDEX: number[]; 219 | IDENTITY_MATRIX: number[]; 220 | LENGTH: number; 221 | 222 | // methods 223 | constructor (brightness: number, contrast: number, saturation: number, hue: number); 224 | adjustBrightness(value: number): ColorMatrix; 225 | adjustColor(brightness: number, contrast: number, saturation: number, hue: number): ColorMatrix; 226 | adjustContrast(value: number): ColorMatrix; 227 | adjustHue(value: number): ColorMatrix; 228 | adjustSaturation(value: number): ColorMatrix; 229 | clone(): ColorMatrix; 230 | concat(matrix: ColorMatrix[]): ColorMatrix; 231 | copyMatrix(matrix: ColorMatrix[]): ColorMatrix; 232 | reset(): ColorMatrix; 233 | toArray(): number[]; 234 | } 235 | 236 | 237 | export class ColorMatrixFilter extends Filter { 238 | // methods 239 | constructor (matrix: number[]); 240 | clone(): ColorMatrixFilter; 241 | } 242 | 243 | 244 | export class Command { 245 | // methods 246 | constructor (f, params, path); 247 | exec(scope: any): void; 248 | } 249 | 250 | 251 | export class Container extends DisplayObject { 252 | // properties 253 | children: DisplayObject[]; 254 | 255 | // methods 256 | addChild(...child: DisplayObject[]): DisplayObject; 257 | addChildAt(...childOrIndex: any[]): DisplayObject; // actually (...child: DisplayObject[], index: number) 258 | clone(recursive?: bool): Container; 259 | contains(child: DisplayObject): bool; 260 | getChildAt(index: number): DisplayObject; 261 | getChildIndex(child: DisplayObject): number; 262 | getNumChildren(): number; 263 | getObjectsUnderPoint(x, number, y: number): DisplayObject[]; 264 | getObjectUnderPoint(x: number, y: number): DisplayObject; 265 | hitTest(x: number, y: number): bool; 266 | removeAllChildren(): void; 267 | removeChild(...child: DisplayObject[]): bool; 268 | removeChildAt(...index: number[]): bool; 269 | setChildIndex(child: DisplayObject, index: number): void; 270 | sortChildren(sortFunction: (a: DisplayObject, b: DisplayObject) => number): void; 271 | swapChildren(child1: DisplayObject, child2: DisplayObject): void; 272 | swapChildrenAt(index1: number, index2: number): void; 273 | } 274 | 275 | 276 | export class DOMElement extends DisplayObject { 277 | // properties 278 | htmlElement: HTMLElement; 279 | 280 | // methods 281 | constructor (htmlElement: HTMLElement); 282 | clone(): DOMElement; 283 | } 284 | 285 | 286 | export class EaselJS { 287 | // properties 288 | version: string; 289 | buildDate: string; 290 | } 291 | 292 | 293 | export class EventDispatcher { 294 | // properties 295 | 296 | // methods 297 | static initialize(target: Object): void; 298 | 299 | addEventListener(type: string, listener: (eventObj: Object) => bool): Function; 300 | addEventListener(type: string, listener: (eventObj: Object) => void): Function; 301 | addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): Object; 302 | addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): Object; 303 | removeEventListener(type: string, listener: (eventObj: Object) => bool): void; 304 | removeEventListener(type: string, listener: (eventObj: Object) => void): void; 305 | removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): void; 306 | removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): void; 307 | removeAllEventListeners(type: string): void; 308 | dispatchEvent(eventObj: string, target: Object): bool; 309 | dispatchEvent(eventObj: Object, target: Object): bool; 310 | hasEventListener(type: string): bool; 311 | toString(): string; 312 | } 313 | 314 | 315 | export class Graphics { 316 | // properties 317 | BASE_64: Object; 318 | curveTo(cpx: number, cpy: number, x: number, y: number): Graphics; // same as quadraticCurveTo() 319 | drawRect(x: number, y: number, width: number, height: number): Graphics; // same as rect() 320 | STROKE_CAPS_MAP: string[]; 321 | STROKE_JOINTS_MAP: string[]; 322 | 323 | // methods 324 | arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: bool): Graphics; 325 | arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): Graphics; 326 | beginBitmapFill(image: Object, repetition?: string, matrix?: Matrix2D): Graphics; 327 | beginBitmapStroke(image: Object, repetition?: string): Graphics; 328 | beginFill(color: string): Graphics; 329 | beginLinearGradientFill(colors: string[], ratios: number[], x0: number, y0: number, x1: number, y1: number): Graphics; 330 | beginLinearGradientStroke(colors: string[], ratios: number[], x0: number, y0: number, x1: number, y1: number): Graphics; 331 | beginRadialGradientFill(colors: string[], ratios: number[], x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): Graphics; 332 | beginRadialGradientStroke(colors: string[], ratios: number[], x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): Graphics; 333 | beginStroke(color: string): Graphics; 334 | bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): Graphics; 335 | clear(): Graphics; 336 | clone(): Graphics; 337 | closePath(): Graphics; 338 | decodePath(str: string): Graphics; 339 | draw(ctx: CanvasRenderingContext2D): void; 340 | drawAsPath(ctx: CanvasRenderingContext2D): void; 341 | drawCircle(x: number, y: number, radius: number): Graphics; 342 | drawEllipse(x: number, y: number, width: number, height: number): Graphics; 343 | drawPolyStar(x: number, y: number, radius: number, sides: number, pointSize: number, angle: number): Graphics; 344 | drawRoundRect(x: number, y: number, width: number, height: number, radius: number): Graphics; 345 | drawRoundRectComplex(x: number, y: number, width: number, height: number, radiusTL: number, radiusTR: number, radiusBR: number, radisBL: number): Graphics; 346 | endFill(): Graphics; 347 | endStroke(): Graphics; 348 | isEmpty(): bool; 349 | static getHSL(hue: number, saturation: number, lightness: number, alpha?: number): string; 350 | static getRGB(red: number, green: number, blue: number, alpha?: number): string; 351 | lineTo(x: number, y: number): Graphics; 352 | moveTo(x: number, y: number): Graphics; 353 | quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): Graphics; 354 | rect(x: number, y: number, width: number, height: number): Graphics; 355 | setStrokeStyle(thickness: number, caps?: string, joints?: string, miter?: number, ignoreScale?: bool): Graphics; // caps and joints can be a string or number 356 | setStrokeStyle(thickness: number, caps?: number, joints?: string, miter?: number, ignoreScale?: bool): Graphics; 357 | setStrokeStyle(thickness: number, caps?: string, joints?: number, miter?: number, ignoreScale?: bool): Graphics; 358 | setStrokeStyle(thickness: number, caps?: number, joints?: number, miter?: number, ignoreScale?: bool): Graphics; 359 | toString(): string; 360 | } 361 | 362 | 363 | export class Log { 364 | // properties 365 | static NONE: number; 366 | static ERROR: number; 367 | static WARNING: number; 368 | static TRACE: number; 369 | static ALL: number; 370 | static level: number; 371 | 372 | // methods 373 | static out(message: string, details: string, level: number); 374 | static addKeys(keys: Object); 375 | static log(message: string, details: string, level: number); 376 | } 377 | 378 | export class Matrix2D { 379 | // properties 380 | a: number; 381 | alpha: number; 382 | atx: number; 383 | b: number; 384 | c: number; 385 | compositeOperation: string; 386 | d: number; 387 | static DEG_TO_RAD: number; 388 | static identity: Matrix2D; 389 | shadow: Shadow; 390 | ty: number; 391 | 392 | // methods 393 | constructor (a: number, b: number, c: number, d: number, tx: number, ty: number); 394 | append(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix2D; 395 | appendMatrix(matrix: Matrix2D): Matrix2D; 396 | appendProperties(a: number, b: number, c: number, d: number, tx: number, ty: number, alpha: number, shadow: Shadow, compositeOperation: string): Matrix2D; 397 | appendTransform(x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX?: number, regY?: number): Matrix2D; 398 | clone(): Matrix2D; 399 | decompose(target: Object): Matrix2D; 400 | identity(): Matrix2D; 401 | invert(): Matrix2D; 402 | isIdentity(): bool; 403 | prepend(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix2D; 404 | prependMatrix(matrix: Matrix2D): Matrix2D; 405 | prependProperties(alpha: number, shadow: Shadow, compositeOperation: string): Matrix2D; 406 | prependTransform(x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX?: number, regY?: number): Matrix2D; 407 | rotate(angle: number): Matrix2D; 408 | scale(x: number, y: number): Matrix2D; 409 | skew(skewX: number, skewY: number): Matrix2D; 410 | toString(): string; 411 | translate(x: number, y: number): Matrix2D; 412 | } 413 | 414 | 415 | export class MouseEvent { 416 | 417 | // properties 418 | nativeEvent: NativeMouseEvent; 419 | pointerID: number; 420 | primaryPointer: bool; 421 | rawX: number; 422 | rawY: number; 423 | stageX: number; 424 | stageY: number; 425 | target: DisplayObject; 426 | type: string; 427 | 428 | // methods 429 | constructor (type: string, stageX: number, stageY: number, target: DisplayObject, nativeEvent: NativeMouseEvent, pointerID: number, primary: bool, rawX: number, rawY: number); 430 | clone(): MouseEvent; 431 | toString(): string; 432 | 433 | // EventDispatcher mixins 434 | addEventListener(type: string, listener: (eventObj: Object) => bool): Function; 435 | addEventListener(type: string, listener: (eventObj: Object) => void ): Function; 436 | addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): Object; 437 | addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): Object; 438 | removeEventListener(type: string, listener: (eventObj: Object) => bool): void; 439 | removeEventListener(type: string, listener: (eventObj: Object) => void ): void; 440 | removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): void; 441 | removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): void; 442 | removeAllEventListeners(type: string): void; 443 | dispatchEvent(eventObj: string, target: Object): bool; 444 | dispatchEvent(eventObj: Object, target: Object): bool; 445 | hasEventListener(type: string): bool; 446 | 447 | // events 448 | onMouseMove: (event: MouseEvent) => any; 449 | onMouseUp: (event: MouseEvent) => any; 450 | } 451 | 452 | 453 | export class MovieClip extends Container { 454 | // properties 455 | actionsEnabled: bool; 456 | autoReset: bool; 457 | currentFrame: number; 458 | static INDEPENDENT: string; 459 | loop: bool; 460 | mode: string; 461 | paused: bool; 462 | static SINGLE_FRAME: string; 463 | startPosition: number; 464 | static SYNCHED: string; 465 | timeline: Timeline; //HERE requires tweenJS 466 | 467 | // methods 468 | constructor (mode: string, startPosition: number, loop: bool, labels: Object); 469 | clone(recursive?: bool): MovieClip; 470 | gotoAndPlay(positionOrLabel: string): void; 471 | gotoAndPlay(positionOrLabel: number): void; 472 | gotoAndStop(positionOrLabel: string): void; 473 | gotoAndStop(positionOrLabel: number): void; 474 | play(): void; 475 | stop(): void; 476 | } 477 | 478 | 479 | export class Point { 480 | // properties 481 | x: number; 482 | y: number; 483 | 484 | // methods 485 | constructor (x: number, y: number); 486 | clone(): Point; 487 | toString(): string; 488 | } 489 | 490 | 491 | export class Rectangle { 492 | // properties 493 | x: number; 494 | y: number; 495 | width: number; 496 | height: number; 497 | 498 | // methods 499 | constructor (x: number, y: number, width: number, height: number); 500 | clone(): Rectangle; 501 | toString(): string; 502 | } 503 | 504 | 505 | export class Shadow { 506 | // properties 507 | blur: number; 508 | color: string; 509 | static identity: Shadow; 510 | offsetX: number; 511 | offsetY: number; 512 | 513 | // methods 514 | constructor (color: string, offsetX: number, offsetY: number, blur: number); 515 | clone(): Shadow; 516 | toString(): string; 517 | } 518 | 519 | 520 | export class Shape extends DisplayObject { 521 | // properties 522 | graphics: Graphics; 523 | 524 | // methods 525 | constructor (graphics?: Graphics); 526 | clone(recursive?: bool): Shape; 527 | } 528 | 529 | 530 | // what is returned from .getAnimation() 531 | interface SpriteSheetAnimation { 532 | frames: number[]; 533 | frequency: number; 534 | name: string; 535 | next: string; 536 | } 537 | 538 | export class SpriteSheet { 539 | // properties 540 | complete: bool; 541 | 542 | // methods 543 | constructor (data: Object); 544 | clone(): SpriteSheet; 545 | getAnimation(name: string): SpriteSheetAnimation; 546 | getAnimations(): string[]; 547 | getFrame(frameIndex: number): Object; 548 | getFrameBounds(frameIndex: number); 549 | getNumFrames(animation: string): number; 550 | toString(): string; 551 | 552 | // events 553 | onComplete: () => any; 554 | } 555 | 556 | 557 | export class SpriteSheetBuilder { 558 | // properties 559 | defaultScale: number; 560 | maxWidth: number; 561 | maxHeight: number; 562 | padding: number; 563 | progress: number; 564 | spriteSheet: SpriteSheet; 565 | timeSlice: number; 566 | 567 | // methods 568 | addFrame(source: DisplayObject, sourceRect?: Rectangle, scale?: number, setupFunction?: () => any, setupParams?: any[], setupScope?: Object): any; //HERE returns number or null 569 | addMovieClip(source: MovieClip, sourceRect?: Rectangle, scale?: number): void; 570 | build(): void; 571 | buildAsync(timeSlice?: number): void; 572 | clone(): SpriteSheetBuilder; 573 | stopAsync(): void; 574 | toString(): string; 575 | 576 | // events 577 | complete: (event: Object) => any; 578 | onProgress: (event: Object) => any; 579 | } 580 | 581 | 582 | export class SpriteSheetUtils { 583 | static addFlippedFrames(spriteSheet: SpriteSheet, horizontal?: bool, vertical?: bool, both?: bool): void; 584 | static extractFrame(spriteSheet: SpriteSheet, frame: number): HTMLImageElement; 585 | static extractFrame(spriteSheet: SpriteSheet, animationName: string): HTMLImageElement; 586 | static flip(spriteSheet: HTMLImageElement, flipData: Object): void; 587 | static mergeAlpha(rgbImage: HTMLImageElement, alphaImage: HTMLImageElement, canvas?: HTMLCanvasElement): HTMLCanvasElement; 588 | } 589 | 590 | 591 | export class Stage extends Container { 592 | // properties 593 | autoClear: bool; 594 | canvas: HTMLCanvasElement; 595 | mouseInBounds: bool; 596 | mouseX: number; 597 | mouseY: number; 598 | snapToPixelEnabled: bool; 599 | tickOnUpdate: bool; 600 | 601 | new (): Stage; 602 | new (canvas: HTMLElement): Stage; 603 | 604 | // methods 605 | constructor (canvas: HTMLCanvasElement); 606 | clone(): Stage; 607 | enableMouseOver(frequency: number): void; 608 | enableDOMEvents(enable: bool): void; 609 | toDataURL(backgroundColor: string, mimeType: string): string; 610 | update(): void; 611 | clear(): void; 612 | handleEvent(evt: Object): void; 613 | 614 | // events 615 | stagemousemove: (event: MouseEvent) => any; 616 | stagemouseup: (event: MouseEvent) => any; 617 | } 618 | 619 | 620 | export class Text extends DisplayObject { 621 | // properties 622 | color: string; 623 | font: string; 624 | lineHeight: number; 625 | lineWidth: number; 626 | maxWidth: number; 627 | outline: bool; 628 | text: string; 629 | textAlign: string; 630 | textBaseline: string; 631 | 632 | // methods 633 | constructor (text?: string, font?: string, color?: string); 634 | clone(): Text; 635 | getMeasuredHeight(): number; 636 | getMeasuredLineHeight(): number; 637 | getMeasuredWidth(): number; 638 | } 639 | 640 | 641 | export class Ticker { 642 | // properties 643 | static useRAF: bool; 644 | 645 | // methods 646 | static addListener(o: Object, pauseable?: bool): void; 647 | static getFPS(): number; 648 | static getInterval(): number; 649 | static getMeasuredFPS(ticks?: number): number; 650 | static getPaused(): bool; 651 | static getTicks(pauseable?: bool): number; 652 | static getTime(pauseable: bool): number; 653 | static init(): void; 654 | static removeAllListeners(): void; 655 | static removeListener(o: Object): void; 656 | static setFPS(value: number): void; 657 | static setInterval(interval: number): void; 658 | static setPaused(value: bool): void; 659 | 660 | // EventDispatcher mixins 661 | static addEventListener(type: string, listener: (eventObj: Object) => bool): Function; 662 | static addEventListener(type: string, listener: (eventObj: Object) => void): Function; 663 | static addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): Object; 664 | static addEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): Object; 665 | static removeEventListener(type: string, listener: (eventObj: Object) => bool): void; 666 | static removeEventListener(type: string, listener: (eventObj: Object) => void): void; 667 | static removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => bool; }): void; 668 | static removeEventListener(type: string, listener: { handleEvent: (eventObj: Object) => void; }): void; 669 | 670 | // events 671 | tick: (timeElapsed: number) => any; 672 | } 673 | 674 | 675 | export class Touch { 676 | // methods 677 | static disable(stage: Stage): void; 678 | static enable(stage: Stage, singleTouch?: bool, allowDefault?: bool): bool; 679 | static isSupported(): bool; 680 | } 681 | 682 | 683 | export class UID { 684 | // methods 685 | static get(): number; 686 | } 687 | } -------------------------------------------------------------------------------- /test/sea/images/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elsassph/createjs-def/b75303de2b9613a2afd3253acabca2719ec10c25/test/sea/images/bg.png -------------------------------------------------------------------------------- /test/sea/preloadjs/preloadjs.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for PreloadJS 0.3 2 | // Project: http://www.createjs.com/#!/PreloadJS 3 | // Definitions by: Pedro Ferreira 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /* 7 | Copyright (c) 2012 Pedro Ferreira 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | 13 | module createjs { 14 | export class AbstractLoader { 15 | // properties 16 | canceled: bool; 17 | loaded: bool; 18 | progress: number; 19 | 20 | // methods 21 | close(): void; 22 | getItem(value: string): Object; 23 | load(): void; 24 | toString(): string; 25 | 26 | // events 27 | complete: (event: Object) => any; 28 | error: (event: Object) => any; 29 | fileload: (event: Object) => any; 30 | fileprogress: (event: Object) => any; 31 | loadStart: (event: Object) => any; 32 | 33 | // EventDispatcher mixins 34 | addEventListener(type: string, listener: (eventObj: Object) => bool): Function; 35 | addEventListener(type: string, listener: (eventObj: Object) => bool): Object; 36 | removeEventListener(type: string, listener: (eventObj: Function) => bool): void; 37 | removeEventListener(type: string, listener: (eventObj: Object) => bool): void; 38 | removeAllEventListeners(type: string): void; 39 | dispatchEvent(eventObj: string, target: Object): bool; 40 | dispatchEvent(eventObj: Object, target: Object): bool; 41 | hasEventListener(type: string): bool; 42 | } 43 | 44 | export class PreloadJS { 45 | version: string; 46 | buildDate: string; 47 | } 48 | 49 | export class LoadQueue extends AbstractLoader { 50 | constructor (useXHR?: bool); 51 | 52 | // properties 53 | static BINARY: string; 54 | static CSS: string; 55 | static IMAGE: string; 56 | static JAVASCRIPT: string; 57 | static JSON: string; 58 | static SOUND: string; 59 | static SVG: string; 60 | static TEXT: string; 61 | static LOAD_TIMEOUT: number; 62 | static XML: string; 63 | 64 | maintainScriptOrder: bool; 65 | next: LoadQueue; 66 | stopOnError: bool; 67 | useXHR: bool; 68 | 69 | // methods 70 | BrowserDetect(): Object; 71 | init(useXHR?: bool): void; 72 | close(): void; 73 | initialize(useXHR: bool): void; 74 | installPlugin(plugin: any): void; 75 | load(): void; 76 | loadFile(file: Object, loadNow?: bool): void; 77 | loadFile(file: string, loadNow?: bool): void; 78 | loadManifest(manifest: Object[], loadNow?: bool): void; 79 | loadManifest(manifest: string[], loadNow?: bool): void; 80 | getItem(value: string): Object; 81 | getResult(value: string, rawResult?: bool): Object; 82 | removeAll(): void; 83 | remove(idsOrUrls: string): void; 84 | remove(idsOrUrls: Array): void; 85 | reset(): void; 86 | setMaxConnections(value: number): void; 87 | setUseXHR(value: bool): void; 88 | setPaused(value: bool): void; 89 | } 90 | 91 | 92 | export class TagLoader extends AbstractLoader { 93 | constructor (item: Object, srcAttr: string, useXHR: bool); 94 | constructor (item: string, srcAttr: string, useXHR: bool); 95 | getResult(): HTMLImageElement; 96 | getResult(): HTMLAudioElement; 97 | } 98 | 99 | 100 | export class XHRLoader extends AbstractLoader { 101 | constructor (file: Object); 102 | getResult(rawResult?: bool); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /test/sea/soundjs/SoundJS.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for SoundJS 0.4 2 | // Project: http://www.createjs.com/#!/SoundJS 3 | // Definitions by: Pedro Ferreira 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /* 7 | Copyright (c) 2012 Pedro Ferreira 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | 13 | module createjs { 14 | export class FlashPlugin { 15 | // properties 16 | static BASE_PATH: string; 17 | static capabilities: Object; 18 | showOutput: bool; 19 | 20 | // methods 21 | create(src: string): SoundInstance; 22 | preload(src: string, instance: Object): void; 23 | static generateCapabilities(): void; 24 | static isSupported(): bool; 25 | isPreloadStarted(src: string): bool; 26 | register(src: string, instances: Number): Object; 27 | setVolume(value: Number): bool; 28 | getVolume(): Number; 29 | setMute(isMuted: bool): Boolean; 30 | toString(): string; 31 | 32 | // Flash API 33 | unregisterPreloadInstance(flashId: string): void; 34 | unregisterSoundInstance(flashId: string): void; 35 | flashLog(data: string): void; 36 | handleSoundEvent(flashId: string, method: string): void; 37 | handlePreloadEvent(flashId: string, method: string): void; 38 | handleEvent(method: string): void; 39 | handleErrorEvent(error: string): void; 40 | } 41 | 42 | export class HTMLAudioPlugin { 43 | // properties 44 | static capabilities: Object; 45 | static MAX_INSTANCES: number; 46 | static AUDIO_READY: string; 47 | static AUDIO_ENDED: string; 48 | static AUDIO_ERROR: string; 49 | static AUDIO_STALLED: string; 50 | capabilities:Object; 51 | defaultNumChannels: number; 52 | 53 | // methods 54 | create(src: string): SoundInstance; 55 | static generateCapabilities(): void; 56 | static isSupported(): bool; 57 | register(src: string, instances: number): Object; 58 | isPreloadStarted(src: string): bool; 59 | preload(src: string, instance: Object): void; 60 | toString(): string; 61 | } 62 | 63 | export class WebAudioPlugin { 64 | // properties 65 | static capabilities: Object; 66 | static MAX_INSTANCES: number; 67 | static AUDIO_READY: string; 68 | static AUDIO_ENDED: string; 69 | static AUDIO_ERROR: string; 70 | static AUDIO_STALLED: string; 71 | arrayBuffers: ArrayBuffer[]; 72 | capabilities:Object; 73 | defaultNumChannels: number; 74 | dynamicsCompressorNode: Object; 75 | gainNode: Object; 76 | volume: number; 77 | context: any; 78 | WebAudioLoader(src: string, owner: Object): Function; 79 | 80 | // methods 81 | create(src: string): SoundInstance; 82 | static generateCapabilities(): void; 83 | static isSupported(): bool; 84 | setVolume(value: Number): bool; 85 | getVolume(): number; 86 | register(src: string, instances: number): Object; 87 | isPreloadStarted(src: string): bool; 88 | preload(src: string, instance: Object): void; 89 | isPreloadComplete(src : string): bool; 90 | removeFromPreload(src: string); 91 | setMute(value: number): bool; 92 | toString(): string; 93 | } 94 | 95 | export class SoundInstance { 96 | constructor (src: string, owner: string, flash: string); 97 | 98 | // properties 99 | muted: bool; 100 | owner: HTMLAudioPlugin; 101 | offset: number; 102 | paused: bool; 103 | delay: number; 104 | pan: number; 105 | duration: number; 106 | playState: string; 107 | delayTimeoutId: number; 108 | src: string; 109 | uniqueId: any; //HERE string or number 110 | volume: number; 111 | 112 | // methods 113 | getDuration(): number; 114 | getPan(): number; 115 | getPosition(): number; 116 | getVolume(): number; 117 | mute(isMuted: bool): bool; 118 | pause(): bool; 119 | play(interrupt: string, delay: number, offset: number, loop: number, volume: number, pan: number): void; 120 | resume(): bool; 121 | setPan(value: number): number; 122 | setPosition(value: number): void; 123 | setVolume(value: number): bool; 124 | stop(): bool; 125 | 126 | // events 127 | complete: () => any; 128 | loop: () => any; 129 | failed: () => any; 130 | interrupted: () => any; 131 | succeeded: () => any; 132 | ready: () => any; 133 | 134 | // EventDispatcher mixins 135 | addEventListener(type: string, listener: (eventObj: Object) => bool): Function; 136 | addEventListener(type: string, listener: (eventObj: Object) => bool): Object; 137 | removeEventListener(type: string, listener: (eventObj: Function) => bool): void; 138 | removeEventListener(type: string, listener: (eventObj: Object) => bool): void; 139 | removeAllEventListeners(type: string): void; 140 | dispatchEvent(eventObj: string, target: Object): bool; 141 | dispatchEvent(eventObj: Object, target: Object): bool; 142 | hasEventListener(type: string): bool; 143 | } 144 | 145 | 146 | export class Sound { 147 | // properties 148 | static activePlugin: Object; 149 | static AUDIO_TIMEOUT: number; 150 | static DELIMITER: string; 151 | static INTERRUPT_ANY: string; 152 | static INTERRUPT_EARLY: string; 153 | static INTERRUPT_LATE: string; 154 | static INTERRUPT_NONE: string; 155 | static muted: bool; 156 | static PLAY_FAILED: string; 157 | static PLAY_FINISHED: string; 158 | static PLAY_INITED: string; 159 | static PLAY_INTERRUPTED: string; 160 | static PLAY_SUCCEEDED: string; 161 | static SUPPORTED_EXTENSIONS: Array; 162 | static EXTENSION_MAP: Object; 163 | static defaultInterruptBehavior: string; 164 | 165 | // methods 166 | static checkPlugin(initializeDefault: bool): bool; 167 | static createInstance(src: string): SoundInstance; 168 | static getCapabilities(): Object; 169 | static getCapability(key: string): any; //HERE can return string | number | bool 170 | static getInstanceById(uniqueId: string): SoundInstance; 171 | static getMute(): number; 172 | static getMasterVolume(): number; 173 | static getSrcFromId(value: string): string; 174 | static getVolume(): number; 175 | static isReady(): bool; 176 | static pause(id: string): void; 177 | static play(src: string, interrupt?: string, delay?: number, offset?: number, loop?: number, volume?: number, pan?: number): SoundInstance; 178 | static registerPlugin(plugin: Object): bool; 179 | static registerPlugins(plugins: Object[]): bool; 180 | static registerSound(src: Object, id: string, data: Object, preload?: bool): Object; 181 | static registerManifest(manifest: Array); 182 | static resume(id: string): void; 183 | static setMasterVolume(value: number): bool; 184 | static setMute(isMuted: bool, id: string): bool; 185 | static setVolume(value: number, id?: string): bool; 186 | static stop(): bool; 187 | 188 | // events 189 | loadComplete: () => any; 190 | 191 | // EventDispatcher mixins 192 | addEventListener(type: string, listener: (eventObj: Object) => bool): Function; 193 | addEventListener(type: string, listener: (eventObj: Object) => bool): Object; 194 | removeEventListener(type: string, listener: (eventObj: Function) => bool): void; 195 | removeEventListener(type: string, listener: (eventObj: Object) => bool): void; 196 | removeAllEventListeners(type: string): void; 197 | dispatchEvent(eventObj: string, target: Object): bool; 198 | dispatchEvent(eventObj: Object, target: Object): bool; 199 | hasEventListener(type: string): bool; 200 | } 201 | 202 | export class BrowserDetect { 203 | // properties 204 | static isFirefox: bool; 205 | static isOpera: bool; 206 | static isChrome: bool; 207 | static isIOS: bool; 208 | static isAndroid: bool; 209 | static isBlackberry: bool; 210 | 211 | // methods 212 | static init(); 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /test/sea/sounds/bubbles.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elsassph/createjs-def/b75303de2b9613a2afd3253acabca2719ec10c25/test/sea/sounds/bubbles.mp3 -------------------------------------------------------------------------------- /test/sea/tweenjs/TweenJS.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for TweenJS 0.4 2 | // Project: http://www.createjs.com/#!/TweenJS 3 | // Definitions by: Pedro Ferreira 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /* 7 | Copyright (c) 2012 Pedro Ferreira 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | 13 | module createjs { 14 | 15 | export class TweenJS { 16 | // properties 17 | version: string; 18 | buildDate: string; 19 | } 20 | 21 | 22 | export class CSSPlugin { 23 | // properties 24 | static cssSuffixMap: Object; 25 | 26 | // methods 27 | static install(): void; 28 | } 29 | 30 | 31 | export class Ease { 32 | // methods 33 | static backIn(): number; 34 | static backInOut(): number; 35 | static backOut(): number; 36 | static bounceIn(amount: number): number; 37 | static bounceInOut(amount: number): number; 38 | static bounceOut(amount: number): number; 39 | static circIn(amount: number): number; 40 | static circInOut(amount: number): number; 41 | static circOut(amount: number): number; 42 | static cubicIn(): number; 43 | static cubicInOut(): number; 44 | static cubicOut(): number; 45 | static elasticIn(): number; 46 | static elasticInOut(): number; 47 | static elasticOut(): number; 48 | static get(amount: number): (amount: number) => number; 49 | static getBackIn(amount: number): (amount: number) => number; 50 | static getBackInOut(amount: number): (amount: number) => number; 51 | static getBackOut(amount: number): (amount: number) => number; 52 | static getElasticIn(amplitude: number, period: number): (amount: number) => number; 53 | static getElasticInOut(amplitude: number, period: number): (amount: number) => number; 54 | static getElasticOut(amplitude: number, period: number): (amount: number) => number; 55 | static getPowIn(pow: number): (amount: number) => number; 56 | static getPowInOut(pow: number): (amount: number) => number; 57 | static getPowOut(pow: number): (amount: number) => number; 58 | static linear(amount: number): number; 59 | static none(amount: number): number; // same as linear 60 | static quadIn(): (amount: number) => number; 61 | static quadInOut(): (amount: number) => number; 62 | static quadOut(): (amount: number) => number; 63 | static quartIn(): (amount: number) => number; 64 | static quartInOut(): (amount: number) => number; 65 | static quartOut(): (amount: number) => number; 66 | static quintIn(): (amount: number) => number; 67 | static quintInOut(): (amount: number) => number; 68 | static quintOut(): (amount: number) => number; 69 | static sineIn(amount: number): number; 70 | static sineInOut(amount: number): number; 71 | static sineOut(amount: number): number; 72 | } 73 | 74 | 75 | export class Timeline { 76 | constructor (tweens: Tween[], labels: Object, props: Object); 77 | 78 | // properties 79 | duration: number; 80 | ignoreGlobalPause: bool; 81 | loop: bool; 82 | position: number; 83 | 84 | // methods 85 | addLabel(label: string, position: number): void; 86 | addTween(...tween: Tween[]): void; 87 | gotoAndPlay(positionOrLabel: string): void; 88 | gotoAndPlay(positionOrLabel: number): void; 89 | gotoAndStop(positionOrLabel: string): void; 90 | gotoAndStop(positionOrLabel: number): void; 91 | removeTween(...tween: Tween[]): void; 92 | resolve(positionOrLabel: string): number; 93 | resolve(positionOrLabel: number): number; 94 | setPaused(value: bool): void; 95 | setPosition(value: number, actionsMode?: number): void; 96 | tick(delta: number): void; 97 | toString(): string; 98 | updateDuration(): void; 99 | 100 | // events 101 | onChange: (instance: Timeline) => any; 102 | } 103 | 104 | 105 | export class Tween { 106 | constructor (target: Object, props: Object); 107 | 108 | // properties 109 | duration: number; 110 | static IGNORE: Object; 111 | ignoreGlobalPause: bool; 112 | loop: bool; 113 | static LOOP: number; 114 | static NONE: number; 115 | pluginData: Object; 116 | position: number; 117 | static REVERSE: number; 118 | target: Object; 119 | 120 | // methods 121 | call(callback: (tweenObject: Tween) => any, params?: any[], scope?: Object); // when 'params' isn't given, the callback receives a tweenObject 122 | call(callback: (...params: any[]) => any, params?: any[], scope?: Object); // otherwise, it receives the params only 123 | static get(target, props?: Object, pluginData?: Object, override?: bool): Tween; 124 | static hasActiveTweens(target? ): void; 125 | static installPlugin(plugin: Object, properties: Object): void; 126 | pause(tween: Tween): void; 127 | play(tween: Tween): void; 128 | static removeTweens(target): void; 129 | set(props: Object, target? ): void; 130 | setPaused(value: bool): void; 131 | setPosition(value: number, actionsMode: number): void; 132 | static tick(delta: number, paused: bool): void; 133 | to(props: Object, duration?: number, ease?: (amount: number) => number): Tween; 134 | toString(): string; 135 | wait(duration: number): void; 136 | 137 | // events 138 | change: (event) => any; 139 | 140 | // EventDispatcher mixins 141 | addEventListener(type: string, listener: (eventObj: Object) => bool): Function; 142 | addEventListener(type: string, listener: (eventObj: Object) => bool): Object; 143 | removeEventListener(type: string, listener: (eventObj: Function) => bool): void; 144 | removeEventListener(type: string, listener: (eventObj: Object) => bool): void; 145 | removeAllEventListeners(type: string): void; 146 | dispatchEvent(eventObj: string, target: Object): bool; 147 | dispatchEvent(eventObj: Object, target: Object): bool; 148 | hasEventListener(type: string): bool; 149 | } 150 | 151 | 152 | export class MotionGuidePlugin { 153 | // properties 154 | static priority: number; 155 | 156 | //methods 157 | static install(): Object; 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /test/web-test.sh: -------------------------------------------------------------------------------- 1 | browserify browser.js -o index.js 2 | 3 | --------------------------------------------------------------------------------