diff --git a/lib/flash/display/ShaderData.as b/lib/flash/display/ShaderData.as new file mode 100644 index 0000000..0e2bdab --- /dev/null +++ b/lib/flash/display/ShaderData.as @@ -0,0 +1,19 @@ +package flash.display { + + + import flash.utils.ByteArray; + + + /** + * @externs + */ + final public dynamic class ShaderData { + + + public function ShaderData (byteArray:ByteArray) {} + + + } + + +} \ No newline at end of file diff --git a/lib/flash/net/URLVariables.as b/lib/flash/net/URLVariables.as new file mode 100644 index 0000000..91a4852 --- /dev/null +++ b/lib/flash/net/URLVariables.as @@ -0,0 +1,53 @@ +package flash.net { + + + /** + * @externs + * The URLVariables class allows you to transfer variables between an + * application and a server. Use URLVariables objects with methods of the + * URLLoader class, with the `data` property of the URLRequest + * class, and with flash.net package functions. + */ + public dynamic class URLVariables { + + + /** + * Creates a new URLVariables object. You pass URLVariables objects to the + * `data` property of URLRequest objects. + * + * If you call the URLVariables constructor with a string, the + * `decode()` method is automatically called to convert the string + * to properties of the URLVariables object. + * + * @param source A URL-encoded string containing name/value pairs. + */ + public function URLVariables (source:String = null) {} + + + /** + * Converts the variable string to properties of the specified URLVariables + * object. + * + * This method is used internally by the URLVariables events. Most users + * do not need to call this method directly. + * + * @param source A URL-encoded query string containing name/value pairs. + * @throws Error The source parameter must be a URL-encoded query string + * containing name/value pairs. + */ + public function decode (source:String):void {} + + + /** + * Returns a string containing all enumerable variables, in the MIME content + * encoding _application/x-www-form-urlencoded_. + * + * @return A URL-encoded string containing name/value pairs. + */ + public function toString ():String { return null; } + + + } + + +} \ No newline at end of file diff --git a/lib/flash/net/navigateToURL.as b/lib/flash/net/navigateToURL.as new file mode 100644 index 0000000..93d4d0a --- /dev/null +++ b/lib/flash/net/navigateToURL.as @@ -0,0 +1,10 @@ +package flash.net { + + + /** + * @externs + */ + public function navigateToURL (request:URLRequest, window:String = null):void {} + + +} \ No newline at end of file diff --git a/lib/flash/net/sendToURL.as b/lib/flash/net/sendToURL.as new file mode 100644 index 0000000..645c972 --- /dev/null +++ b/lib/flash/net/sendToURL.as @@ -0,0 +1,10 @@ +package flash.net { + + + /** + * @externs + */ + public function sendToURL (request:URLRequest):void {} + + +} \ No newline at end of file diff --git a/lib/flash/utils/Dictionary.as b/lib/flash/utils/Dictionary.as new file mode 100644 index 0000000..41bcab9 --- /dev/null +++ b/lib/flash/utils/Dictionary.as @@ -0,0 +1,34 @@ +package flash.utils { + + + /** + * @externs + */ + public dynamic class Dictionary { + + + public function Dictionary (weakKeys:Boolean = false) {} + // public function exists (key:*):Boolean { return false; } + // public function get (key:K):V { return null; } + // public function remove (key:*):Boolean { return false; } + // public function set (key:K, value:V):V { return null; } + + + // public inline function iterator ():Iterator { + + // return this.keys (); + + // } + + + // public inline function each ():Iterator { + + // return this.iterator (); + + // } + + + } + + +} \ No newline at end of file diff --git a/lib/flash/utils/clearTimeout.as b/lib/flash/utils/clearTimeout.as new file mode 100644 index 0000000..edb434f --- /dev/null +++ b/lib/flash/utils/clearTimeout.as @@ -0,0 +1,10 @@ +package flash.utils { + + + /** + * @externs + */ + public function clearTimeout (id:uint):void {} + + +} diff --git a/lib/flash/utils/getDefinitionByName.as b/lib/flash/utils/getDefinitionByName.as new file mode 100644 index 0000000..2e5f09b --- /dev/null +++ b/lib/flash/utils/getDefinitionByName.as @@ -0,0 +1,10 @@ +package flash.utils { + + + /** + * @externs + */ + public function getDefinitionByName (name:String):* { return null; } + + +} \ No newline at end of file diff --git a/lib/flash/utils/getQualifiedClassName.as b/lib/flash/utils/getQualifiedClassName.as new file mode 100644 index 0000000..68f1c10 --- /dev/null +++ b/lib/flash/utils/getQualifiedClassName.as @@ -0,0 +1,10 @@ +package flash.utils { + + + /** + * @externs + */ + public function getQualifiedClassName (value:*):String { return null; } + + +} \ No newline at end of file diff --git a/lib/flash/utils/getQualifiedSuperclassName.as b/lib/flash/utils/getQualifiedSuperclassName.as new file mode 100644 index 0000000..4ae68a0 --- /dev/null +++ b/lib/flash/utils/getQualifiedSuperclassName.as @@ -0,0 +1,10 @@ +package flash.utils { + + + /** + * @externs + */ + public function getQualifiedSuperclassName (value:*):String { return null; } + + +} \ No newline at end of file diff --git a/lib/flash/utils/getTimer.as b/lib/flash/utils/getTimer.as new file mode 100644 index 0000000..01fdb57 --- /dev/null +++ b/lib/flash/utils/getTimer.as @@ -0,0 +1,10 @@ +package flash.utils { + + + /** + * @externs + */ + public function getTimer ():Number { return 0; } + + +} \ No newline at end of file diff --git a/lib/flash/utils/setTimeout.as b/lib/flash/utils/setTimeout.as new file mode 100644 index 0000000..5365931 --- /dev/null +++ b/lib/flash/utils/setTimeout.as @@ -0,0 +1,10 @@ +package flash.utils { + + + /** + * @externs + */ + public function setTimeout (closure:Function, delay:Number, ...arguments):uint { return 0; } + + +} \ No newline at end of file diff --git a/lib/openfl/index.js b/lib/openfl/index.js index 780f5c7..df40e6a 100644 --- a/lib/openfl/index.js +++ b/lib/openfl/index.js @@ -1,4 +1,4 @@ -module.exports = { +const openfl = { desktop: require("./desktop"), @@ -323,3 +323,9 @@ module.exports = { Vector: require("./Vector").default, } + +module.exports = openfl; +if(typeof window !== "undefined") +{ + window.flash = openfl; +} \ No newline at end of file diff --git a/scripts/AS3ExternsGenerator.hx b/scripts/AS3ExternsGenerator.hx index 65a88b0..8f5a352 100644 --- a/scripts/AS3ExternsGenerator.hx +++ b/scripts/AS3ExternsGenerator.hx @@ -214,6 +214,13 @@ class AS3ExternsGenerator { return true; } if (options != null) { + if (options.includedSymbols != null) { + for (includedSymbol in options.includedSymbols) { + if (qname == includedSymbol) { + return false; + } + } + } if (options.includedPackages != null) { final qnameLastDotIndex = qname.lastIndexOf("."); final qnamePack = qnameLastDotIndex != -1 ? qname.substr(0, qnameLastDotIndex).split(".") : []; @@ -965,10 +972,39 @@ class AS3ExternsGenerator { return true; } var qname = baseTypeToQname(baseType, []); - if (qname.indexOf(".") == -1) { + if (qname.indexOf(".") == -1 && ALWAYS_ALLOWED_REFERENCE_TYPES.indexOf(baseType.name) != -1) { return true; } - if (isInPackage(currentPackage, baseType.pack, true)) { + var baseTypePack = baseType.pack; + var i = 0; + if (options != null && options.renameSymbols != null) { + var renameSymbols = options.renameSymbols; + while (i < renameSymbols.length) { + var originalName = renameSymbols[i]; + i++; + var newName = renameSymbols[i]; + i++; + if (baseTypePack.indexOf(originalName) != -1) { + baseTypePack[baseTypePack.indexOf(originalName)] = newName; + break; + } + } + } + if (options != null && options.renamePackages != null) { + i = 0; + var renamePackages = options.renamePackages; + while (i < renamePackages.length) { + var originalName = renamePackages[i]; + i++; + var newName = renamePackages[i]; + i++; + if (baseTypePack.indexOf(originalName) != -1) { + baseTypePack[baseTypePack.indexOf(originalName)] = newName; + break; + } + } + } + if (isInPackage(currentPackage, baseTypePack, true)) { return true; } return false; @@ -1273,6 +1309,14 @@ typedef AS3GeneratorOptions = { **/ ?includedPackages:Array, + /** + Externs will be generated for symbols specified. + + Types from other packages may still be referenced by fields or method + signatures. Use `allowedPackageReferences` to restrict those too. + **/ + ?includedSymbols:Array, + /** When `includedPackages` is not empty, `allowedPackageReferences` may be used to allow types from other packages to be used for field types, diff --git a/scripts/TSExternsGenerator.hx b/scripts/TSExternsGenerator.hx index 85509a4..87feb35 100644 --- a/scripts/TSExternsGenerator.hx +++ b/scripts/TSExternsGenerator.hx @@ -198,6 +198,13 @@ class TSExternsGenerator { return true; } if (options != null) { + if (options.includedSymbols != null) { + for (includedSymbol in options.includedSymbols) { + if (qname == includedSymbol) { + return false; + } + } + } if (options.includedPackages != null) { final qnameLastDotIndex = qname.lastIndexOf("."); final qnamePack = qnameLastDotIndex != -1 ? qname.substr(0, qnameLastDotIndex).split(".") : []; @@ -1576,6 +1583,14 @@ typedef TSGeneratorOptions = { **/ ?includedPackages:Array, + /** + Externs will be generated for symbols specified. + + Types from other packages may still be referenced by fields or method + signatures. Use `allowedPackageReferences` to restrict those too. + **/ + ?includedSymbols:Array, + /** When `includedPackages` is not empty, `allowedPackageReferences` may be used to allow types from other packages to be used for field types, diff --git a/scripts/build.hxml b/scripts/build.hxml index 2fe1cd0..d6405dc 100644 --- a/scripts/build.hxml +++ b/scripts/build.hxml @@ -35,4 +35,5 @@ -D webgl1 --macro AS3ExternsGenerator.generate({outputPath: "../lib", includedPackages: ["openfl"], allowedPackageReferences: [], renameSymbols: ["openfl.VectorData", "openfl.Vector", "openfl.utils.ByteArrayData", "openfl.utils.ByteArray", "lime.app.Future", "openfl.utils.Future"]}) --macro TSExternsGenerator.generate({outputPath: "../lib", includedPackages: ["openfl"], allowedPackageReferences: [], renameSymbols: ["openfl.VectorData", "openfl.Vector", "openfl.utils.ByteArrayData", "openfl.utils.ByteArray", "lime.app.Future", "openfl.utils.Future"]}) ---no-inline \ No newline at end of file +--macro AS3ExternsGenerator.generate({outputPath: "../lib", includedPackages: ["flash"], allowedPackageReferences: [], renameSymbols: ["flash.VectorData", "flash.Vector", "flash.utils.ByteArrayData", "flash.utils.ByteArray", "lime.app.Future", "flash.utils.Future"], renamePackages: ["openfl", "flash"]}) +--no-inline