diff --git a/cocos2d/core/asset-manager/CCAssetManager.js b/cocos2d/core/asset-manager/CCAssetManager.js index f90649374c2..bd1e3a5639f 100644 --- a/cocos2d/core/asset-manager/CCAssetManager.js +++ b/cocos2d/core/asset-manager/CCAssetManager.js @@ -42,7 +42,7 @@ const Bundle = require('./bundle'); const builtins = require('./builtins') const { parse, combine } = require('./urlTransformer'); const { parseParameters, urlAppendTimestamp, asyncify } = require('./utilities'); -const { assets, files, parsed, pipeline, transformPipeline, fetchPipeline, initializePipeline, LoadStrategy, RequestType, bundles, BuiltinBundle } = require('./shared'); +const { assets, files, parsed, pipeline, transformPipeline, fetchPipeline, initializePipeline, LoadStrategy, RequestType, bundles, BuiltinBundleName } = require('./shared'); /** * @module cc */ @@ -280,7 +280,7 @@ AssetManager.Config = Config; AssetManager.LoadStrategy = LoadStrategy; AssetManager.RequestType = RequestType; AssetManager.Bundle = Bundle; -AssetManager.BuiltinBundle = BuiltinBundle; +AssetManager.BuiltinBundleName = BuiltinBundleName; AssetManager.prototype = { @@ -298,7 +298,7 @@ AssetManager.prototype = { * @type {Bundle} */ get main () { - return bundles.get(BuiltinBundle.MAIN); + return bundles.get(BuiltinBundleName.MAIN); }, /** @@ -313,7 +313,7 @@ AssetManager.prototype = { * @type {Bundle} */ get resources () { - return bundles.get(BuiltinBundle.RESOURCES); + return bundles.get(BuiltinBundleName.RESOURCES); }, /** @@ -328,7 +328,7 @@ AssetManager.prototype = { * @type {Bundle} */ get internal () { - return bundles.get(BuiltinBundle.INTERNAL); + return bundles.get(BuiltinBundleName.INTERNAL); }, /** diff --git a/cocos2d/core/asset-manager/builtins.js b/cocos2d/core/asset-manager/builtins.js index 3a784329b02..7664d264fbc 100644 --- a/cocos2d/core/asset-manager/builtins.js +++ b/cocos2d/core/asset-manager/builtins.js @@ -24,7 +24,7 @@ ****************************************************************************/ const Cache = require('./cache'); const finalizer = require('./finalizer'); -const { BuiltinBundle } = require('./shared'); +const { BuiltinBundleName } = require('./shared'); /** * @module cc.AssetManager @@ -76,7 +76,7 @@ var builtins = { */ init (cb) { this.clear(); - if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS || !cc.assetManager.bundles.has(BuiltinBundle.INTERNAL)) { + if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS || !cc.assetManager.bundles.has(BuiltinBundleName.INTERNAL)) { return cb && cb(); } diff --git a/cocos2d/core/asset-manager/deprecated.js b/cocos2d/core/asset-manager/deprecated.js index 1931e3a7f24..940bccdca90 100644 --- a/cocos2d/core/asset-manager/deprecated.js +++ b/cocos2d/core/asset-manager/deprecated.js @@ -569,7 +569,7 @@ var AssetLibrary = { cc.assetManager.init(options); if (options.rawAssets) { var resources = new cc.AssetManager.Bundle(); - resources.init({name: cc.AssetManager.BuiltinBundle.RESOURCES, importBase: options.importBase, nativeBase: options.nativeBase, paths: options.rawAssets.assets, uuids: Object.keys(options.rawAssets.assets)}); + resources.init({name: cc.AssetManager.BuiltinBundleName.RESOURCES, importBase: options.importBase, nativeBase: options.nativeBase, paths: options.rawAssets.assets, uuids: Object.keys(options.rawAssets.assets)}); } }, @@ -614,7 +614,7 @@ cc.url = { */ raw (url) { if (url.startsWith('resources/')) { - return cc.assetManager.transform({'path': cc.path.changeExtname(url.substr(10)), bundle: cc.AssetManager.BuiltinBundle.RESOURCES, isNative: true, ext: cc.path.extname(url)}); + return cc.assetManager.transform({'path': cc.path.changeExtname(url.substr(10)), bundle: cc.AssetManager.BuiltinBundleName.RESOURCES, isNative: true, ext: cc.path.extname(url)}); } return ''; } diff --git a/cocos2d/core/asset-manager/shared.js b/cocos2d/core/asset-manager/shared.js index ba3a1af91b1..fb1569dc1e6 100644 --- a/cocos2d/core/asset-manager/shared.js +++ b/cocos2d/core/asset-manager/shared.js @@ -158,9 +158,9 @@ var RequestType = { * !#zh * 内置 bundle * - * @enum BuiltinBundle + * @enum BuiltinBundleName */ -var BuiltinBundle = { +var BuiltinBundleName = { /** * !#en * The builtin bundle corresponds to 'assets/resources'. @@ -201,4 +201,4 @@ var BuiltinBundle = { MAIN: 'main' }; -module.exports = { assets, files, parsed, pipeline, fetchPipeline, initializePipeline, transformPipeline, LoadStrategy, RequestType, bundles, BuiltinBundle }; \ No newline at end of file +module.exports = { assets, files, parsed, pipeline, fetchPipeline, initializePipeline, transformPipeline, LoadStrategy, RequestType, bundles, BuiltinBundleName }; \ No newline at end of file diff --git a/cocos2d/core/assets/CCTexture2D.js b/cocos2d/core/assets/CCTexture2D.js index 48786437547..fa43eab5c40 100644 --- a/cocos2d/core/assets/CCTexture2D.js +++ b/cocos2d/core/assets/CCTexture2D.js @@ -597,7 +597,7 @@ var Texture2D = cc.Class({ if (!element) return; this._image = element; - if (element.complete || element instanceof HTMLCanvasElement || element instanceof ImageBitmap) { + if (element.complete || element instanceof HTMLCanvasElement || (cc.sys.capabilities.createImageBitmap && element instanceof ImageBitmap)) { this.handleLoadedTexture(); } else { @@ -680,7 +680,7 @@ var Texture2D = cc.Class({ * @return {Boolean} inherit from the CCObject */ destroy () { - if (this._image instanceof ImageBitmap) { + if (cc.sys.capabilities.createImageBitmap && this._image instanceof ImageBitmap) { this._image.close(); } this._packable && cc.dynamicAtlasManager && cc.dynamicAtlasManager.deleteAtlasTexture(this); @@ -759,7 +759,7 @@ var Texture2D = cc.Class({ if (this._image instanceof HTMLImageElement) { this._clearImage(); } - else if (this._image instanceof ImageBitmap) { + else if (cc.sys.capabilities.createImageBitmap && this._image instanceof ImageBitmap) { this._image.close(); } } diff --git a/cocos2d/deprecated.js b/cocos2d/deprecated.js index 0dc9369cb29..e90ce34c057 100644 --- a/cocos2d/deprecated.js +++ b/cocos2d/deprecated.js @@ -512,10 +512,12 @@ if (CC_DEBUG) { 'minFrameSize' ], 'cc.dynamicAtlasManager') - // light component - markAsRemovedInObject(cc.Light.prototype, [ - 'shadowDepthScale', - ], 'cc.Light.prototype'); + if (cc.Light) { + // light component + markAsRemovedInObject(cc.Light.prototype, [ + 'shadowDepthScale', + ], 'cc.Light.prototype'); + } // Value types provideClearError(cc, { diff --git a/index.js b/index.js index 36156c02e44..3696bd3de10 100644 --- a/index.js +++ b/index.js @@ -51,7 +51,6 @@ require('./polyfill/array'); require('./polyfill/object'); require('./polyfill/array-buffer'); require('./polyfill/number'); -require('./polyfill/image-bitmap'); if (!(CC_EDITOR && Editor.isMainProcess)) { require('./polyfill/typescript'); } diff --git a/polyfill/image-bitmap.ts b/polyfill/image-bitmap.ts deleted file mode 100644 index 0186b7e254d..00000000000 --- a/polyfill/image-bitmap.ts +++ /dev/null @@ -1,19 +0,0 @@ -if (typeof ImageBitmap === 'undefined') { - class ImageBitmap { - - public height: Number = 0; - - public width: Number = 0; - - constructor () { - throw new Error('not implement'); - } - - public close () { - throw new Error('not implement'); - } - } - - let _global = typeof window === 'undefined' ? global : window; - Object.defineProperty(_global, 'ImageBitmap', { value: ImageBitmap }); -} \ No newline at end of file diff --git a/test/qunit/unit-es5/test-asset-manager.js b/test/qunit/unit-es5/test-asset-manager.js index c6cc9d654ab..1dcd9b8f350 100644 --- a/test/qunit/unit-es5/test-asset-manager.js +++ b/test/qunit/unit-es5/test-asset-manager.js @@ -8,7 +8,7 @@ }); var resources = new cc.AssetManager.Bundle(); resources.init({ - name: cc.AssetManager.BuiltinBundle.RESOURCES, + name: cc.AssetManager.BuiltinBundleName.RESOURCES, importBase: libPath, nativeBase: libPath, paths: { diff --git a/test/qunit/unit-es5/test-urlTransform.js b/test/qunit/unit-es5/test-urlTransform.js index 7b216952860..d58acfb50d9 100644 --- a/test/qunit/unit-es5/test-urlTransform.js +++ b/test/qunit/unit-es5/test-urlTransform.js @@ -31,7 +31,7 @@ test('raw', function () { cc.assetManager.init({importBase: 'import', nativeBase: 'native'}); var bundle = new cc.AssetManager.Bundle(); bundle.init({ - name: cc.AssetManager.BuiltinBundle.RESOURCES, + name: cc.AssetManager.BuiltinBundleName.RESOURCES, base: 'test/', importBase: 'import', nativeBase: 'native', @@ -50,7 +50,7 @@ test('md5', function () { cc.assetManager.init({importBase: 'import', nativeBase: 'native'}); var bundle = new cc.AssetManager.Bundle(); bundle.init({ - name: cc.AssetManager.BuiltinBundle.RESOURCES, + name: cc.AssetManager.BuiltinBundleName.RESOURCES, base: 'test/', importBase: 'import', nativeBase: 'native',