Add rollup config and tested commonjs module import (#3220)

* Add basic rollup environment configs

* Fix issues for rollup build

* Import commonjs module, test with assets
This commit is contained in:
pandamicro
2018-09-09 11:32:11 +08:00
committed by GitHub
parent fcf92b32a9
commit 11f876f72e
31 changed files with 226 additions and 545 deletions
+10 -286
View File
@@ -1,297 +1,21 @@
Cocos2d-html5 authors
Cocos2d Creator 3D authors
(Ordered by join time)
Core Developers:
Shun Lin (Sean Lin)
Huabing Xu (@dabingnn)
Ricardo Quesada
Yaqiong Liu
Yunxiao Wu
Xuguang Zhu
Nan Li
Huabin LING (@pandamicro)
Sijie Wang (@VisualSJ)
Huabing Xu (@dabingnn)
Guanghui Qu (@zilongshanren)
Jiawei Guo (@jareguo)
Kaile Yin (@2youyouo2)
Yanbin Huang (@knoxHuang)
Contributors:
Name GithubID Main contribution
Dali Kilani @dadilcool added instruction to read me
Chris @hannon235 added node.js api for box2d
added SocketIO and SocketIO tests
Jason Aeschliman @jaeschliman fixed cc.Node setposition
Zhuoshi Sun(Intel) @sunzhuoshi engine loader fixed
Alejandro Reyero @KaTXi fixed error message
Long Xiang @seanlong resource loader count
Timm Drevensek(Zynga) @timmjd cc.Class fixed
add CCScale9Sprite test
Lzzy Chen @czizzy audio engine fixed
cleanup comments
Mcscooter @mcscooter tilempapxml fixed
Roed @roed Mouse rightclick api
Mouse scroll fix for firefox
cc.Screen bug fix
Surith Thekkiam(Zynga) @folecr match Cocos2dx api
Robert Boyd @rboyd fixed stackable actions
Ivo Wetzel(Zynga Germany) @BonsaiDen Fixes for Audio Support Detection,
Texture Support in Particle System,
and Performance improvements
Mario Adrian @many20 Code review, multi touch improvements,
ccbi bugs fixed
keisuke hata(Square) @Seasons7 Code review, bug fix
Marat Yakupov @moadib Various bug fixes
Liang Wu @akira-cn Touch location fix for designResolution
ScrollView on paused bugs fix
Jimmy Sambuo @jsambuo AudioEngine improvements
Jose Antonio Andujar Clavell Scale9Sprite improvements
TadeuszWlodarkiewic @TadeuszWlodarkiewic Tizen Compatibility
smshuja @smshuja Parallax node bug fix
rickms @rickms EGLView Optimizations
Szymon Piłkowski @ardcore CCTexture Bug fix
Tomasz Tunik @tomasztunik CCNode Memory leak fix
Xuankang Lin(Intel) @AndriyLin cc.WebAudioEngine implements
Kang-Hao Lu(Opera/Oupeng) @kennyluck Optimize John Resig's inheritance pattern
cc.clone improvements
Mark Henderson @MarkEHenderson Code review, LabelTTF and Scale9Sprite bug fix
Jing Wang @06wj CCScheduler improvements
Js file loading image add
cc.RectApplyAffineTransform improvements
Fixed a bug of cc.Node.setPosition that parameter check is incorrect
Ze Wang @WanderWang Fix crash when BrowserTypes match nothing from navigator.userAgent
LabelTTF improvements
cc.TextureCache.dumpCachedTextureInfo 's bug fix
CCTween bug fix
CCScale9Sprite bug fix
sys.localStorage bug fix
CCArmature refactoring
cc.SpriteFrame and cc.SpriteFrameCache refactoring
Christian Schwartz @cschwartz SpriteFrame.initWithTextureFilename converted fix
XiaoJun Zheng @SmallAiTT _getResType error fix
cc.ScrollView bug fix
cc.LabelTTF bug fix
rewrite functions in CCNS.js with regex
refactor CCScheduler.js and CCCommon.js
cc.BMFontConfiguration bug fix
refactor cc.Application to cc.game
refactor cc.loader
refactor cc.Textur2D
refactor some functions about array operation
move sys.xxx to cc.sys.xxx
refactor some public functions in cc to private
add node.js scripts for publishing game
refactor cc.CCBReader
cc.view bug fix
multiple property object supports in extend function
Guozhu Cheng @bengol cc.SimpleAudioEngine bug fix
Jing Xiao @xbruce cc.SAXParser bug fix
cc.ActionManager refactoring
cc.Scheduler refactoring
cc.LabelTTF refactoring
JiaHui He @garfield_ho cc.FileUtils bug fix
cc.Builder and SpriteLoader bugs fix
CCBAnimation bug fix
Luis Parravicini @luisparravicini cc.Director refactoring
cc.LabelTTF documentation
typo fix
Jose Antonio @jandujar cc.ParticleSystem bug fix for CocoStudio animations
SceneReader bug fix
BoHao Tang @btspoony cc.TableView bug fix
Claudiu @csaftoiu cc.LabelTTF bug fix
cc.DrawNode bugs fix
cc.NodeRGBA bug fix
cc.Texture2D bug fix
Pei Wu @rablwupei cc.ProgressTimer bug fix
cc.ParticleBatchNode bug fix
kuaipao @kuaipao CocoStudio GUIReader bug fix
CocoStudio UIScrollView bug fix
CocoStudio UIWidget bug fix
XieDaijin @NijiadeIX CCControl bug fix
samael @samael65535 CCPhysicsSprite bug fix
NatWeiss @NatWeiss Add analytics plugin protocol ,Flurry plugin and ProtocolAds.js plugin protocol
cc.FileUtils refactoring
cc.Audio bugs fix
cc.Texture2D bug fix
Andor Salga @asalga typo fix
erykwalder @erykwalder Function.prototype.bind bug fix
ZippoLag @ZippoLag cc.Application.getCurrentLanguage bug fix
typo fix
Fixed `cc.TMXObjectGroup#objectNamed` not returning the result bug
Asano @LaercioAsano cc.Node bug fix
Bruno Assarisse @bassarisse cc.LabelBMFont bug fix
Mykyta Usikov @musikov cc.ClippingNode bugs fix
cc.fontLoader bug fix
Inverted ClippingNode with DrawNode as stencil bug fix under canvas render mode
JumpTo bug with wrong _delta position bug fix
cc.ProgressTimer bugs fix
cc.Scale9Sprite bugs fix
cc.RenderTexture bug fix
cc.ParticleSystem bug fix
Made CCProgressTimerCanvasRenderCmd to properly show colorized sprites
cc.ScrollView and cc.TableView: added check for parent visibility in onTouchBegan method
Han XiaoLong @kpkhxlgy0 cc.ParticleSytem bug fix
AaronRZH @AaronRZH Creation of a sequence objcet or a spawn object by using new method bug fix
Xiaodong Liu @tianxing113 cc.Spawn.create bug fix
ccui.LoadingBar.setPercent crash bug fix
Park Hyun Chen @sincntx Touch anywhere of screen to finish input when using cc.EditBox
ccui.TextBMFont bug fix
cc.game bug fix
Fixed an issue of cc.ArmatureAnimation's setMovementEventCallFunc
Ninja Lau @mutoo A typo bug in UILayout fix
One-loop CCArmatureAnimation can't finish when setSpeedScale is less than 1.0 bug fix
A transform error in CCTransformHelp.js fix
ccs.DisplayManager bug fix
Fix child armature lost _parentBone issue
cc.eventManager bug fix
ccs.Bone bug fix
ccs.ActionFrame bug fix
ccui.Widget bug fix
ccui.LoadingBar bug fix
Taras Tovchenko @tovchenko cc.Skin bounding box calculation bug fix under canvas render mode
Minh Quy @MQuy cc.MenuItemSprite bug fix
Check empty string for textureData
Adds type check functions
Michael Yin @layerssss cc.game refactored
Yang Yuchen @yycdef cc.sys bug fix
K @kiwigrc cc.ParticleSystem bug fix
Claudio Freitas @claudiofreitas ccui.TextField typo fix.
nopakos @nopakos cc.Texture2D bug fix
Robert Rouhani @Robmaister cc.TMXMapInfo bug fix
cc.TMXLayer bug fix
Igor Mats @IgorMats cc.Scale9Sprite bug fix
Spine runtime update
Add getStroke and setStroke method to cc.MotionStreak
Tim @duhaibo0404 ccs.csLoader bug fix
Hermanto @man2 cc.loader bug fix
Long Jiang @jianglong0156 cc.LabelBMFont bug fix
KeyCode bug fix
ccui.ListView bug fix
Joe Lafiosca @lafiosca Added Javascript file loader
galapagosit @galapagosit ccs.actionManager bug fix
Dany Ellement @DEllement cc.FontDefinition & ccui.RichText improvements
cc.LayerGradient improvements
IShm @IShm cc.Screen bug fix
cc.ParticleSystem bug fix
ccui.PageView bug fix
Fixed crash when character not found into BMP font
Fixed restoring of sprite's color issue
Thomas Jablonski @thomas-jablonski cc.audioEngine bug fix
Cocostudio typo fix
WingGao @WingGao cc.TMXLayer bug fix
Skliar Ihor @igogo5yo Add Bower support
feijing566 @feijing566 cc.Audio bug fix
RackovychV @RackovychV Fixed a bug of `cc.Scheduler`'s `pauseAllTargetsWithMinPriority`
giuseppelt @giuseppelt Fixed TransitionSlideX callback sequence issue
YShumov @pixmaster Fixed issue in music end event
SPACELAN @spacelan Fixed `inverse` function bug of `cc.math.Matrix4`
patriciog @patriciog Allowed timeline animations with only one frame
Ningxin Hu @huningxin SIMD.js optimization for kazmath functions
Zachary Lester @ZLester Fix typo in AUTHORS.txt
Juan Carlos @Ruluk Fixed a bug where not resetting cc.Audio._ignoreEnded when replaying a sound caused it to stay in a "playing" state
Maxim Litvinov @metalim Throw new Error object instead of error message string
Retired Core Developers:
Shengxiang Chen (Nero Chan)
Xingsen Ma
Xiaojun Zheng
Jialong Zhai (@JoshuaAstray)
Hao Wu (WuHao)
Dingping Lv (David Lv)
Long Jiang (@jianglong0156)
Menghe Zhang (@ZhangMenghe)
Cocos2d-x and cocos2d-html5 can not grow so fast without the active community.
Thanks to all developers who report & trace bugs, discuss the engine usage in forum & QQ groups!
Special thanks to Ricardo Quesada for giving us lots of guidances & suggestions.
Thanks to all developers who report & trace bugs, discuss the engine usage in forum!
+14 -14
View File
@@ -24,14 +24,14 @@
THE SOFTWARE.
****************************************************************************/
var Asset = require('../assets/CCAsset');
var callInNextTick = require('./utils').callInNextTick;
var Loader = require('../load-pipeline/CCLoader');
var PackDownloader = require('../load-pipeline/pack-downloader');
var AutoReleaseUtils = require('../load-pipeline/auto-release-utils');
var decodeUuid = require('../utils/decode-uuid');
var MD5Pipe = require('../load-pipeline/md5-pipe');
var js = require('./js');
const js = require('../core/utils/js');
const Asset = require('./CCAsset');
const callInNextTick = require('../core/utils/misc').callInNextTick;
const decodeUuid = require('../core/utils/decode-uuid');
// var Loader = require('./load-pipeline/CCLoader');
// var PackDownloader = require('../load-pipeline/pack-downloader');
// var AutoReleaseUtils = require('../load-pipeline/auto-release-utils');
// var MD5Pipe = require('../load-pipeline/md5-pipe');
/**
* The asset library which managing loading/unloading assets in project.
@@ -89,7 +89,7 @@ var AssetLibrary = {
if (options && options.existingAsset) {
item.existingAsset = options.existingAsset;
}
Loader.load(item, function (error, asset) {
cc.loader.load(item, function (error, asset) {
if (error || !asset) {
error = new Error('[AssetLibrary] loading JSON or dependencies failed: ' + (error ? error.message : 'Unknown error'));
}
@@ -105,7 +105,7 @@ var AssetLibrary = {
}
if (CC_EDITOR || isScene(asset)) {
var id = cc.loader._getReferenceKey(uuid);
Loader.removeItem(id);
cc.loader.removeItem(id);
}
}
if (callback) {
@@ -223,9 +223,9 @@ var AssetLibrary = {
uuid: randomUuid,
type: 'uuid',
content: json,
skips: [ Loader.assetLoader.id, Loader.downloader.id ]
skips: [ cc.loader.assetLoader.id, cc.loader.downloader.id ]
};
Loader.load(item, function (error, asset) {
cc.loader.load(item, function (error, asset) {
if (error) {
error = new Error('[AssetLibrary] loading JSON or dependencies failed: ' + error.message);
}
@@ -236,7 +236,7 @@ var AssetLibrary = {
}
if (CC_EDITOR || isScene(asset)) {
var id = cc.loader._getReferenceKey(randomUuid);
Loader.removeItem(id);
cc.loader.removeItem(id);
}
}
asset._uuid = '';
@@ -309,7 +309,7 @@ var AssetLibrary = {
// init raw assets
var resources = Loader._resources;
var resources = cc.loader._resources;
resources.reset();
var rawAssets = options.rawAssets;
if (rawAssets) {
+2 -1
View File
@@ -24,6 +24,8 @@
THE SOFTWARE.
****************************************************************************/
const jit = require('../core/data/instantiate-jit');
/**
* !#zh
* Prefab 创建实例所用的优化策略,配合 {{#crossLink "Prefab.optimizationPolicy"}}cc.Prefab#optimizationPolicy{{/crossLink}} 使用。
@@ -137,7 +139,6 @@ var Prefab = cc.Class({
* @method compileCreateFunction
*/
compileCreateFunction: function () {
var jit = require('../platform/instantiate-jit');
this._createFunction = jit.compile(this.data);
},
+2 -2
View File
@@ -24,8 +24,8 @@
THE SOFTWARE.
****************************************************************************/
var CCObject = require('../platform/CCObject');
var js = require('../platform/js');
var CCObject = require('../core/data/object');
var js = require('../core/utils/js');
/**
* !#en
+4 -3
View File
@@ -25,8 +25,9 @@
THE SOFTWARE.
****************************************************************************/
const EventTarget = require("../event/event-target");
const textureUtil = require('../utils/texture-util');
const EventTarget = require("../core/event/event-target");
const textureUtil = require('./texture-util');
const Asset = require('./CCAsset');
let temp_uvs = [{u: 0, v: 0}, {u: 0, v: 0}, {u: 0, v: 0}, {u: 0, v: 0}];
@@ -57,7 +58,7 @@ let temp_uvs = [{u: 0, v: 0}, {u: 0, v: 0}, {u: 0, v: 0}, {u: 0, v: 0}];
*/
let SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
name: 'cc.SpriteFrame',
extends: require('../assets/CCAsset'),
extends: Asset,
mixins: [EventTarget],
properties: {
+24 -23
View File
@@ -24,11 +24,12 @@
THE SOFTWARE.
****************************************************************************/
const EventTarget = require('../event/event-target');
const renderEngine = require('../renderer/render-engine');
const renderer = require('../renderer');
require('../platform/CCClass');
const gfx = renderEngine.gfx;
const EventTarget = require('../core/event/event-target');
const Tex_GFX = require('../renderer/gfx/texture-2d');
const CCClass = require('../core/data/class');
const IDGenerator = require('../core/utils/id-generater');
const Enums_GFX = require('../renderer/gfx/enums');
const enums = Enums_GFX.enums;
const GL_NEAREST = 9728; // gl.NEAREST
const GL_LINEAR = 9729; // gl.LINEAR
@@ -39,7 +40,7 @@ const GL_MIRRORED_REPEAT = 33648; // gl.MIRRORED_REPEAT
const CHAR_CODE_0 = 48; // '0'
const CHAR_CODE_1 = 49; // '1'
var idGenerater = new (require('../platform/id-generater'))('Tex');
var idGenerator = new IDGenerator('Tex');
/**
* <p>
@@ -67,63 +68,63 @@ const PixelFormat = cc.Enum({
* @readonly
* @type {Number}
*/
RGB565: gfx.TEXTURE_FMT_R5_G6_B5,
RGB565: enums.TEXTURE_FMT_R5_G6_B5,
/**
* 16-bit textures: RGB5A1
* @property RGB5A1
* @readonly
* @type {Number}
*/
RGB5A1: gfx.TEXTURE_FMT_R5_G5_B5_A1,
RGB5A1: enums.TEXTURE_FMT_R5_G5_B5_A1,
/**
* 16-bit textures: RGBA4444
* @property RGBA4444
* @readonly
* @type {Number}
*/
RGBA4444: gfx.TEXTURE_FMT_R4_G4_B4_A4,
RGBA4444: enums.TEXTURE_FMT_R4_G4_B4_A4,
/**
* 24-bit texture: RGB888
* @property RGB888
* @readonly
* @type {Number}
*/
RGB888: gfx.TEXTURE_FMT_RGB8,
RGB888: enums.TEXTURE_FMT_RGB8,
/**
* 32-bit texture: RGBA8888
* @property RGBA8888
* @readonly
* @type {Number}
*/
RGBA8888: gfx.TEXTURE_FMT_RGBA8,
RGBA8888: enums.TEXTURE_FMT_RGBA8,
/**
* 32-bit float texture: RGBA32F
* @property RGBA32F
* @readonly
* @type {Number}
*/
RGBA32F: gfx.TEXTURE_FMT_RGBA32F,
RGBA32F: enums.TEXTURE_FMT_RGBA32F,
/**
* 8-bit textures used as masks
* @property A8
* @readonly
* @type {Number}
*/
A8: gfx.TEXTURE_FMT_A8,
A8: enums.TEXTURE_FMT_A8,
/**
* 8-bit intensity texture
* @property I8
* @readonly
* @type {Number}
*/
I8: gfx.TEXTURE_FMT_L8,
I8: enums.TEXTURE_FMT_L8,
/**
* 16-bit textures used as masks
* @property AI88
* @readonly
* @type {Number}
*/
AI8: gfx.TEXTURE_FMT_L8_A8,
AI8: enums.TEXTURE_FMT_L8_A8,
/**
* rgb 2 bpp pvrtc
@@ -131,28 +132,28 @@ const PixelFormat = cc.Enum({
* @readonly
* @type {Number}
*/
RGB_PVRTC_2BPPV1: gfx.TEXTURE_FMT_RGB_PVRTC_2BPPV1,
RGB_PVRTC_2BPPV1: enums.TEXTURE_FMT_RGB_PVRTC_2BPPV1,
/**
* rgba 2 bpp pvrtc
* @property RGBA_PVRTC_2BPPV1
* @readonly
* @type {Number}
*/
RGBA_PVRTC_2BPPV1: gfx.TEXTURE_FMT_RGBA_PVRTC_2BPPV1,
RGBA_PVRTC_2BPPV1: enums.TEXTURE_FMT_RGBA_PVRTC_2BPPV1,
/**
* rgb 4 bpp pvrtc
* @property RGB_PVRTC_4BPPV1
* @readonly
* @type {Number}
*/
RGB_PVRTC_4BPPV1: gfx.TEXTURE_FMT_RGB_PVRTC_4BPPV1,
RGB_PVRTC_4BPPV1: enums.TEXTURE_FMT_RGB_PVRTC_4BPPV1,
/**
* rgba 4 bpp pvrtc
* @property RGBA_PVRTC_4BPPV1
* @readonly
* @type {Number}
*/
RGBA_PVRTC_4BPPV1: gfx.TEXTURE_FMT_RGBA_PVRTC_4BPPV1,
RGBA_PVRTC_4BPPV1: enums.TEXTURE_FMT_RGBA_PVRTC_4BPPV1,
});
/**
@@ -243,7 +244,7 @@ function _getSharedOptions () {
* @uses EventTarget
* @extends Asset
*/
var Texture2D = cc.Class({
var Texture2D = CCClass({
name: 'cc.Texture2D',
extends: require('../assets/CCAsset'),
mixins: [EventTarget],
@@ -290,7 +291,7 @@ var Texture2D = cc.Class({
ctor () {
// Id for generate hash in material
this._id = idGenerater.getNewId();
this._id = idGenerator.getNewId();
/**
* !#en
@@ -500,7 +501,7 @@ var Texture2D = cc.Class({
opts.width = pixelsWidth;
opts.height = pixelsHeight;
if (!this._texture) {
this._texture = new renderer.Texture2D(renderer.device, opts);
this._texture = new Tex_GFX(cc.renderer.device, opts);
}
else {
this._texture.update(opts);
@@ -618,7 +619,7 @@ var Texture2D = cc.Class({
opts.wrapT = this._wrapT;
if (!this._texture) {
this._texture = new renderer.Texture2D(renderer.device, opts);
this._texture = new Tex_GFX(cc.renderer.device, opts);
}
else {
this._texture.update(opts);
+2 -4
View File
@@ -28,16 +28,14 @@ require('./CCRawAsset');
require('./CCAsset');
require('./CCFont');
require('./CCPrefab');
require('./CCAudioClip');
require('./CCScripts');
require('./CCSceneAsset');
require('./CCSpriteFrame');
require('./CCTexture2D');
require('./CCRenderTexture');
require('./CCTTFFont');
require('./CCSpriteAtlas');
require('./CCBitmapFont');
require('./CCLabelAtlas');
require('./CCTextAsset');
require('./CCJsonAsset');
require('./CCMesh');
require('./texture-util');
require('./CCAssetLibrary')
+1 -1
View File
@@ -24,7 +24,7 @@
THE SOFTWARE.
****************************************************************************/
const Texture2D = require('../assets/CCTexture2D');
const Texture2D = require('./CCTexture2D');
/**
* cc.textureUtil is a singleton object, it can load cc.Texture2D asynchronously
+1
View File
@@ -1055,4 +1055,5 @@ Director.EVENT_AFTER_DRAW = "director_after_draw";
*/
let director = cc.director = new Director();
cc.Director = Director;
cc.director = director;
export default director;
+9 -8
View File
@@ -38,10 +38,9 @@
// inspired by toddlxt (https://github.com/toddlxt/Creator-TypeScript-Boilerplate)
require('./class');
const Preprocess = require('./preprocess-class');
const js = require('./js');
const isPlainEmptyObj_DEV = CC_DEV && require('./utils').isPlainEmptyObj_DEV;
import './class';
import {getFullFormOfProperty, doValidateMethodWithProps_DEV} from './utils/preprocess-class';
import * as js from'../utils/js';
// caches for class construction
const CACHE_KEY = '__ccclassCache__';
@@ -149,8 +148,8 @@ function extractActualDefaultValues (ctor) {
function genProperty (ctor, properties, propName, options, desc, cache) {
var fullOptions;
if (options) {
fullOptions = CC_DEV ? Preprocess.getFullFormOfProperty(options, propName, js.getClassName(ctor)) :
Preprocess.getFullFormOfProperty(options);
fullOptions = CC_DEV ? getFullFormOfProperty(options, propName, js.getClassName(ctor)) :
getFullFormOfProperty(options);
fullOptions = fullOptions || options;
}
var existsProperty = properties[propName];
@@ -300,7 +299,7 @@ var ccclass = checkCtorArgument(function (ctor, name) {
var desc = Object.getOwnPropertyDescriptor(ctor.prototype, prop);
var func = desc && desc.value;
if (typeof func === 'function') {
Preprocess.doValidateMethodWithProps_DEV(func, prop, js.getClassName(ctor), ctor, base);
doValidateMethodWithProps_DEV(func, prop, js.getClassName(ctor), ctor, base);
}
}
}
@@ -708,7 +707,7 @@ function mixins () {
}
}
cc._decorator = {
let _decorator = cc._decorator = {
ccclass,
property,
executeInEditMode,
@@ -722,3 +721,5 @@ cc._decorator = {
help,
mixins,
};
export default _decorator;
+1 -1
View File
@@ -26,7 +26,7 @@
import * as js from '../utils/js';
import * as misc from '../utils/misc';
import {CCClass} from './class';
import CCClass from './class';
import * as Attr from './utils/attribute';
// HELPERS
+1 -3
View File
@@ -23,9 +23,7 @@
THE SOFTWARE.
****************************************************************************/
import * as decorator from './class-decorator';
cc._decorator = decorator;
export { default as _decorator} from './class-decorator';
export { default as CCClass } from './class';
export { default as CCObject } from './object';
export { default as deserialize } from './deserialize';
+1 -1
View File
@@ -24,7 +24,7 @@
****************************************************************************/
import * as js from '../utils/js';
import {CCClass} from './class';
import CCClass from './class';
// definitions for CCObject.Flags
+15 -17
View File
@@ -351,23 +351,21 @@ export function preprocessAttrs (properties, className, cls, es6) {
}
};
if (CC_DEV) {
const CALL_SUPER_DESTROY_REG_DEV = /\b\._super\b|destroy\s*\.\s*call\s*\(\s*\w+\s*[,|)]/;
export function doValidateMethodWithProps_DEV (func, funcName, className, cls, base) {
if (cls.__props__ && cls.__props__.indexOf(funcName) >= 0) {
// find class that defines this method as a property
var baseClassName = js.getClassName(getBaseClassWherePropertyDefined_DEV(funcName, cls));
cc.errorID(3648, className, funcName, baseClassName);
return false;
}
if (funcName === 'destroy' &&
js.isChildClassOf(base, cc.Component) &&
!CALL_SUPER_DESTROY_REG_DEV.test(func)
) {
cc.error(`Overwriting '${funcName}' function in '${className}' class without calling super is not allowed. Call the super function in '${funcName}' please.`);
}
};
}
const CALL_SUPER_DESTROY_REG_DEV = /\b\._super\b|destroy\s*\.\s*call\s*\(\s*\w+\s*[,|)]/;
export function doValidateMethodWithProps_DEV (func, funcName, className, cls, base) {
if (cls.__props__ && cls.__props__.indexOf(funcName) >= 0) {
// find class that defines this method as a property
var baseClassName = js.getClassName(getBaseClassWherePropertyDefined_DEV(funcName, cls));
cc.errorID(3648, className, funcName, baseClassName);
return false;
}
if (funcName === 'destroy' &&
js.isChildClassOf(base, cc.Component) &&
!CALL_SUPER_DESTROY_REG_DEV.test(func)
) {
cc.error(`Overwriting '${funcName}' function in '${className}' class without calling super is not allowed. Call the super function in '${funcName}' please.`);
}
};
export function validateMethodWithProps (func, funcName, className, cls, base) {
if (CC_DEV && funcName === 'constructor') {
@@ -26,7 +26,7 @@
import macro from '../CCMacro';
import sys from '../CCSys';
import eventManager from './event-manager';
import eventManager from './CCEventManager';
const TOUCH_TIMEOUT = macro.TOUCH_TIMEOUT;
+15
View File
@@ -28,6 +28,8 @@
* @static
*/
export {default as MutableForwardIterator} from './mutable-forward-iterator';
/**
* Removes the array item at the specified index.
* @method removeAt
@@ -165,4 +167,17 @@ export function copy (array) {
for (i = 0; i < len; i += 1)
arr_clone[i] = array[i];
return arr_clone;
}
export default {
MutableForwardIterator,
removeAt,
fastRemoveAt,
remove,
fastRemove,
verifyType,
removeArray,
appendObjectsAt,
contains,
copy
}
+1 -1
View File
@@ -24,7 +24,7 @@
THE SOFTWARE.
****************************************************************************/
import {BASE64_VALUES} from 'misc';
import {BASE64_VALUES} from './misc';
var HexChars = '0123456789abcdef'.split('');
+7 -9
View File
@@ -25,14 +25,7 @@
****************************************************************************/
// ========= cc.js ==========
import * as array from './array';
import * as js from './js';
import Pool from './pool';
import MutableForwardIterator from './mutable-forward-iterator';
js.Pool = Pool;
js.array = array;
js.array.MutableForwardIterator = MutableForwardIterator;
if (CC_DEV) {
js.getset(js, '_registeredClassIds',
@@ -69,9 +62,14 @@ if (CC_DEV) {
cc.js = js;
// ========= cc.path ==========
import * as path from 'path';
import * as path from './path';
get(path, 'sep', () => {
return (cc.sys.os === cc.sys.OS_WINDOWS ? '\\' : '/');
})
cc.path = path;
cc.path = path;
export default {
js,
path
}
+4 -2
View File
@@ -25,8 +25,6 @@
THE SOFTWARE.
****************************************************************************/
import IDGenerater from './id-generater';
let tempCIDGenerater = new IDGenerater('TmpCId.');
const REGEXP_NUM_OR_STR = /(%d)|(%s)/;
@@ -58,6 +56,10 @@ var _tmpSetDesc = {
* @module js
*/
export {default as IDGenerater} from './id-generater';
export {default as Pool} from './pool';
export {default as array} from './array';
/**
* Check the obj whether is number or not
* If a number is created by using 'new Number(10086)', the typeof it will be "object"...
+33 -36
View File
@@ -242,45 +242,42 @@ export function callInNextTick (callback, p1, p2) {
}
}
if (CC_EDITOR) {
// use anonymous function here to ensure it will not being hoisted without CC_EDITOR
export function tryCatchFunctor_EDITOR (funcName, forwardArgs, afterCall, bindArg) {
function call_FUNC_InTryCatch (_R_ARGS_) {
try {
target._FUNC_(_U_ARGS_);
}
catch (e) {
cc._throw(e);
}
_AFTER_CALL_
// use anonymous function here to ensure it will not being hoisted without CC_EDITOR
export function tryCatchFunctor_EDITOR (funcName, forwardArgs, afterCall, bindArg) {
function call_FUNC_InTryCatch (_R_ARGS_) {
try {
target._FUNC_(_U_ARGS_);
}
// use evaled code to generate named function
return Function('arg', 'return ' + call_FUNC_InTryCatch
.toString()
.replace(/_FUNC_/g, funcName)
.replace('_R_ARGS_', 'target' + (forwardArgs ? ', ' + forwardArgs : ''))
.replace('_U_ARGS_', forwardArgs || '')
.replace('_AFTER_CALL_', afterCall || ''))(bindArg);
};
export function isPlainEmptyObj_DEV (obj) {
if (!obj || obj.constructor !== Object) {
return false;
catch (e) {
cc._throw(e);
}
// jshint ignore: start
for (var k in obj) {
return false;
}
// jshint ignore: end
return true;
};
_AFTER_CALL_
}
// use evaled code to generate named function
return Function('arg', 'return ' + call_FUNC_InTryCatch
.toString()
.replace(/_FUNC_/g, funcName)
.replace('_R_ARGS_', 'target' + (forwardArgs ? ', ' + forwardArgs : ''))
.replace('_U_ARGS_', forwardArgs || '')
.replace('_AFTER_CALL_', afterCall || ''))(bindArg);
}
export function cloneable_DEV (obj) {
return obj &&
typeof obj.clone === 'function' &&
( (obj.constructor && obj.constructor.prototype.hasOwnProperty('clone')) || obj.hasOwnProperty('clone') );
};
export function isPlainEmptyObj_DEV (obj) {
if (!obj || obj.constructor !== Object) {
return false;
}
// jshint ignore: start
for (var k in obj) {
return false;
}
// jshint ignore: end
return true;
}
export function cloneable_DEV (obj) {
return obj &&
typeof obj.clone === 'function' &&
( (obj.constructor && obj.constructor.prototype.hasOwnProperty('clone')) || obj.hasOwnProperty('clone') );
}
if (CC_TEST) {
@@ -25,6 +25,7 @@
****************************************************************************/
/**
* @class js.array.MutableForwardIterator
* @example
* var array = [0, 1, 2, 3, 4];
* var iterator = new cc.js.array.MutableForwardIterator(array);
-29
View File
@@ -1,29 +0,0 @@
/****************************************************************************
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
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.
****************************************************************************/
require('./core/CCGame');
// ensure modular-cocos2d can determine whether action module is included
require('./actions');
-49
View File
@@ -1,49 +0,0 @@
/****************************************************************************
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
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.
****************************************************************************/
require('./cocos2d/core');
require('./cocos2d/animation');
if (CC_EDITOR && Editor.isMainProcess) {
require('./cocos2d/particle/CCParticleAsset');
require('./cocos2d/tilemap/CCTiledMapAsset');
}
else {
require('./cocos2d/particle');
require('./cocos2d/tilemap');
require('./cocos2d/videoplayer/CCVideoPlayer');
require('./cocos2d/webview/CCWebView');
require('./cocos2d/core/components/CCStudioComponent');
require('./extensions/ccpool/CCNodePool');
require('./cocos2d/actions');
}
require('./extensions/spine');
require('./extensions/dragonbones');
if (!CC_EDITOR || !Editor.isMainProcess) {
require('./cocos2d/deprecated');
}
+5 -46
View File
@@ -26,52 +26,11 @@
// PREDEFINE
// window may be undefined when first load engine from editor
var _global = typeof window === 'undefined' ? global : window;
import cc from './predefine';
/**
* !#en
* The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace.
* !#zh
* Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。
* @module cc
* @main cc
*/
cc = _global.cc || {};
// LOAD ENGINE CORE
import './cocos/core';
// For internal usage
_cc = _global._cc || {};
import './cocos/assets';
// For internal usage
_cc = {};
require('./predefine');
// polyfills
require('./polyfill/string');
require('./polyfill/misc');
require('./polyfill/array');
require('./polyfill/object');
if (!(CC_EDITOR && Editor.isMainProcess)) {
require('./polyfill/typescript');
}
require('./cocos2d/core/predefine');
// LOAD COCOS2D ENGINE CODE
if (!(CC_EDITOR && Editor.isMainProcess)) {
require('./cocos2d');
}
// LOAD EXTENDS
require('./extends');
if (CC_EDITOR) {
if (Editor.isMainProcess) {
Editor.versions['cocos2d'] = require('./package').version;
}
}
module.exports = cc;
export default cc;
+20 -8
View File
@@ -1,16 +1,24 @@
{
"name": "cocos-creator-js",
"version": "1.7.0",
"description": "Cocos2d-html5 is a cross-platform 2D game engine written in Javascript, based on Cocos2d-X and licensed under MIT. It incorporates the same high level api as “Cocos2d JS-binding engine” and compatible with Cocos2d-X. It currently supports canvas and WebGL renderering.",
"homepage": "http://www.cocos2d-x.org",
"name": "cocos-creator-3d",
"version": "0.1.0",
"description": "Cocos Creator 3D is a cross-platform 3D game engine written in Javascript, licensed under MIT.",
"homepage": "http://www.cocos.com",
"license": "MIT",
"authors": [
"AUTHORS.txt"
],
"license": "MIT",
"module": "index.js",
"scripts": {
"test": "gulp test-in-ci"
"build": "npm run build:dev && npm run build:min",
"build:dev": "rollup -c ./rollup/config.js",
"build:min": "uglifyjs ./bin/cocos-3d.dev.js --mangle --source-map url=cocos-3d.min.js.map -o ./bin/cocos-3d.min.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/cocos-creator/engine.git"
},
"devDependencies": {
"aliasify": "^2.1.0",
"async": "1.5.2",
"babel-plugin-parser-opts": "1.0.1",
"babel-plugin-transform-class-properties": "6.22.0",
@@ -20,11 +28,11 @@
"babel-plugin-transform-es2015-template-literals": "6.22.0",
"babel-preset-env": "^1.2.2",
"babelify": "7.3.0",
"browserify": "13.0.0",
"chalk": "1.1.0",
"del": "1.2.0",
"event-stream": "3.3.2",
"fire-fs": "0.2.1",
"fs-jetpack": "^1.1.0",
"gulp": "^3.9.1",
"gulp-babel": "6.1.2",
"gulp-cached": "1.1.0",
@@ -44,8 +52,12 @@
"jshint-stylish": "2.1.0",
"multipipe": "0.3.0",
"persistify": "^1.1.1",
"aliasify": "^2.1.0",
"require-dir": "0.3.0",
"rollup": "^0.65.2",
"rollup-plugin-commonjs": "^9.1.6",
"rollup-plugin-buble": "^0.18.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-watch": "^4.3.1",
"uglify-es": "3.3.7",
"vinyl": "1.1.0",
"vinyl-buffer": "1.0.0",
+19
View File
@@ -115,8 +115,25 @@
* @property {Boolean} CC_RUNTIME - Running in runtime environments.
*/
// PREDEFINE
// window may be undefined when first load engine from editor
var _global = typeof window === 'undefined' ? global : window;
/**
* !#en
* The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace.
* !#zh
* Cocos 引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。
* @module cc
* @main cc
*/
cc = _global.cc || {};
// For internal usage
_cc = _global._cc || {};
function defineMacro (name, defaultValue) {
// if "global_defs" not preprocessed by uglify, just declare them globally,
// this may happened in release version's preview page.
@@ -183,3 +200,5 @@ if (CC_DEV) {
*/
const engineVersion = '2.0.0 alpha';
_global['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
export default cc;
+33
View File
@@ -0,0 +1,33 @@
'use strict';
const fsJetpack = require('fs-jetpack');
const commonjs = require('rollup-plugin-commonjs');
const resolve = require('rollup-plugin-node-resolve');
const buble = require('rollup-plugin-buble');
let dest = './bin';
let file = 'cocos-3d.dev';
let moduleName = 'cocos3d';
// clear directory
fsJetpack.dir(dest, { empty: true });
module.exports = {
input: './index.js',
output: [
{
file: `${dest}/${file}.js`,
format: 'cjs',
name: moduleName,
sourcemap: false,
},
],
plugins: [
resolve({
jsnext: true,
main: true,
}),
commonjs(),
buble()
],
};