mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
Fix npm run build:dev (#3275)
This commit is contained in:
@@ -24,8 +24,8 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
// ========= cc.js ==========
|
||||
export {default as js} from './js';
|
||||
import './js';
|
||||
import './path';
|
||||
|
||||
// ========= cc.path ==========
|
||||
export {default as path} from './path';
|
||||
export const js = cc.js;
|
||||
export const path = cc.path;
|
||||
+34
-34
@@ -25,9 +25,7 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
import * as array from './array';
|
||||
import IDGenerater from './id-generater';
|
||||
import Pool from './pool';
|
||||
import * as jsarray from './array';
|
||||
|
||||
let tempCIDGenerater = new IDGenerater('TmpCId.');
|
||||
|
||||
@@ -66,6 +64,10 @@ var _tmpSetDesc = {
|
||||
* @module js
|
||||
*/
|
||||
|
||||
export {default as IDGenerater} from './id-generater';
|
||||
export {default as Pool} from './pool';
|
||||
export const array = jsarray;
|
||||
|
||||
/**
|
||||
* Check the obj whether is number or not
|
||||
* If a number is created by using 'new Number(10086)', the typeof it will be "object"...
|
||||
@@ -74,7 +76,7 @@ var _tmpSetDesc = {
|
||||
* @param {*} obj
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
function isNumber (obj) {
|
||||
export function isNumber (obj) {
|
||||
return typeof obj === 'number' || obj instanceof Number;
|
||||
};
|
||||
|
||||
@@ -86,7 +88,7 @@ function isNumber (obj) {
|
||||
* @param {*} obj
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
function isString (obj) {
|
||||
export function isString (obj) {
|
||||
return typeof obj === 'string' || obj instanceof String;
|
||||
};
|
||||
|
||||
@@ -97,7 +99,7 @@ function isString (obj) {
|
||||
* @param {String} name
|
||||
* @return {Object}
|
||||
*/
|
||||
function getPropertyDescriptor (obj, name) {
|
||||
export function getPropertyDescriptor (obj, name) {
|
||||
while (obj) {
|
||||
var pd = Object.getOwnPropertyDescriptor(obj, name);
|
||||
if (pd) {
|
||||
@@ -120,7 +122,7 @@ function _copyprop(name, source, target) {
|
||||
* @param {Object} ...sourceObj source object to copy properties from
|
||||
* @return {Object} the result obj
|
||||
*/
|
||||
function addon (obj) {
|
||||
export function addon (obj) {
|
||||
'use strict';
|
||||
obj = obj || {};
|
||||
for (var i = 1, length = arguments.length; i < length; i++) {
|
||||
@@ -147,7 +149,7 @@ function addon (obj) {
|
||||
* @param {Object} ...sourceObj
|
||||
* @return {Object} the result obj
|
||||
*/
|
||||
function mixin (obj) {
|
||||
export function mixin (obj) {
|
||||
'use strict';
|
||||
obj = obj || {};
|
||||
for (var i = 1, length = arguments.length; i < length; i++) {
|
||||
@@ -174,7 +176,7 @@ function mixin (obj) {
|
||||
* @param {Function} base - the baseclass to inherit
|
||||
* @return {Function} the result class
|
||||
*/
|
||||
function extend (cls, base) {
|
||||
export function extend (cls, base) {
|
||||
if (CC_DEV) {
|
||||
if (!base) {
|
||||
cc.errorID(5404);
|
||||
@@ -205,7 +207,7 @@ function extend (cls, base) {
|
||||
* @param {Function} ctor - the constructor of subclass
|
||||
* @return {Function}
|
||||
*/
|
||||
function getSuper (ctor) {
|
||||
export function getSuper (ctor) {
|
||||
var proto = ctor.prototype; // binded function do not have prototype
|
||||
var dunderProto = proto && Object.getPrototypeOf(proto);
|
||||
return dunderProto && dunderProto.constructor;
|
||||
@@ -219,7 +221,7 @@ function getSuper (ctor) {
|
||||
* @param {Function} superclass
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function isChildClassOf (subclass, superclass) {
|
||||
export function isChildClassOf (subclass, superclass) {
|
||||
if (subclass && superclass) {
|
||||
if (typeof subclass !== 'function') {
|
||||
return false;
|
||||
@@ -251,7 +253,7 @@ function isChildClassOf (subclass, superclass) {
|
||||
* @method clear
|
||||
* @param {any} obj
|
||||
*/
|
||||
function clear (obj) {
|
||||
export function clear (obj) {
|
||||
var keys = Object.keys(obj);
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
delete obj[keys[i]];
|
||||
@@ -268,7 +270,7 @@ function clear (obj) {
|
||||
* @param {Boolean} [writable=false]
|
||||
* @param {Boolean} [enumerable=false]
|
||||
*/
|
||||
function value (obj, prop, value, writable, enumerable) {
|
||||
export function value (obj, prop, value, writable, enumerable) {
|
||||
_tmpValueDesc.value = value;
|
||||
_tmpValueDesc.writable = writable;
|
||||
_tmpValueDesc.enumerable = enumerable;
|
||||
@@ -286,7 +288,7 @@ function value (obj, prop, value, writable, enumerable) {
|
||||
* @param {Boolean} [enumerable=false]
|
||||
* @param {Boolean} [configurable=false]
|
||||
*/
|
||||
function getset (obj, prop, getter, setter, enumerable, configurable) {
|
||||
export function getset (obj, prop, getter, setter, enumerable, configurable) {
|
||||
if (typeof setter !== 'function') {
|
||||
enumerable = setter;
|
||||
setter = undefined;
|
||||
@@ -310,7 +312,7 @@ function getset (obj, prop, getter, setter, enumerable, configurable) {
|
||||
* @param {Boolean} [enumerable=false]
|
||||
* @param {Boolean} [configurable=false]
|
||||
*/
|
||||
function get (obj, prop, getter, enumerable, configurable) {
|
||||
export function get (obj, prop, getter, enumerable, configurable) {
|
||||
_tmpGetDesc.get = getter;
|
||||
_tmpGetDesc.enumerable = enumerable;
|
||||
_tmpGetDesc.configurable = configurable;
|
||||
@@ -328,7 +330,7 @@ function get (obj, prop, getter, enumerable, configurable) {
|
||||
* @param {Boolean} [enumerable=false]
|
||||
* @param {Boolean} [configurable=false]
|
||||
*/
|
||||
function set (obj, prop, setter, enumerable, configurable) {
|
||||
export function set (obj, prop, setter, enumerable, configurable) {
|
||||
_tmpSetDesc.set = setter;
|
||||
_tmpSetDesc.enumerable = enumerable;
|
||||
_tmpSetDesc.configurable = configurable;
|
||||
@@ -343,7 +345,7 @@ function set (obj, prop, setter, enumerable, configurable) {
|
||||
* @param {Object|Function} objOrCtor - instance or constructor
|
||||
* @return {String}
|
||||
*/
|
||||
function getClassName (objOrCtor) {
|
||||
export function getClassName (objOrCtor) {
|
||||
if (typeof objOrCtor === 'function') {
|
||||
var prototype = objOrCtor.prototype;
|
||||
if (prototype && prototype.hasOwnProperty('__classname__') && prototype.__classname__) {
|
||||
@@ -391,7 +393,7 @@ let _nameToClass = {};
|
||||
* @param {Function} constructor
|
||||
* @private
|
||||
*/
|
||||
function _setClassId (id, constructor) {
|
||||
export function _setClassId (id, constructor) {
|
||||
let key = '__cid__';
|
||||
let table = _idToClass;
|
||||
// deregister old
|
||||
@@ -455,7 +457,7 @@ cc.js.unregisterClass to remove the id of unused class';
|
||||
* @param {String} className
|
||||
* @param {Function} constructor
|
||||
*/
|
||||
function setClassName (className, constructor) {
|
||||
export function setClassName (className, constructor) {
|
||||
doSetClassName(className, constructor);
|
||||
// auto set class id
|
||||
if (!constructor.prototype.hasOwnProperty('__cid__')) {
|
||||
@@ -475,7 +477,7 @@ function setClassName (className, constructor) {
|
||||
* @method unregisterClass
|
||||
* @param {Function} ...constructor - the class you will want to unregister, any number of classes can be added
|
||||
*/
|
||||
function unregisterClass () {
|
||||
export function unregisterClass () {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var p = arguments[i].prototype;
|
||||
var classId = p.__cid__;
|
||||
@@ -496,7 +498,7 @@ function unregisterClass () {
|
||||
* @return {Function} constructor
|
||||
* @private
|
||||
*/
|
||||
function _getClassById (classId) {
|
||||
export function _getClassById (classId) {
|
||||
return _idToClass[classId];
|
||||
};
|
||||
|
||||
@@ -506,7 +508,7 @@ function _getClassById (classId) {
|
||||
* @param {String} classname
|
||||
* @return {Function} constructor
|
||||
*/
|
||||
function getClassByName (classname) {
|
||||
export function getClassByName (classname) {
|
||||
return _nameToClass[classname];
|
||||
};
|
||||
|
||||
@@ -518,7 +520,7 @@ function getClassByName (classname) {
|
||||
* @return {String}
|
||||
* @private
|
||||
*/
|
||||
function _getClassId (obj, allowTempId) {
|
||||
export function _getClassId (obj, allowTempId) {
|
||||
allowTempId = (typeof allowTempId !== 'undefined' ? allowTempId: true);
|
||||
|
||||
var res;
|
||||
@@ -550,7 +552,7 @@ function _getClassId (obj, allowTempId) {
|
||||
* @param {String} newExpr - "NewParam" or "YourClass.NewParam"
|
||||
* @param {Boolean} [writable=false]
|
||||
*/
|
||||
function obsolete (obj, obsoleted, newExpr, writable) {
|
||||
export function obsolete (obj, obsoleted, newExpr, writable) {
|
||||
var extractPropName = /([^.]+)$/;
|
||||
var oldProp = extractPropName.exec(obsoleted)[0];
|
||||
var newProp = extractPropName.exec(newExpr)[0];
|
||||
@@ -584,7 +586,7 @@ function obsolete (obj, obsoleted, newExpr, writable) {
|
||||
* @param {Object} props
|
||||
* @param {Boolean} [writable=false]
|
||||
*/
|
||||
function obsoletes (obj, objName, props, writable) {
|
||||
export function obsoletes (obj, objName, props, writable) {
|
||||
for (var obsoleted in props) {
|
||||
var newName = props[obsoleted];
|
||||
obsolete(obj, objName + '.' + obsoleted, newName, writable);
|
||||
@@ -601,7 +603,7 @@ function obsoletes (obj, objName, props, writable) {
|
||||
* cc.js.formatStr("a: %s, b: %s", a, b);
|
||||
* cc.js.formatStr(a, b, c);
|
||||
*/
|
||||
function formatStr () {
|
||||
export function formatStr () {
|
||||
var argLen = arguments.length;
|
||||
if (argLen === 0) {
|
||||
return '';
|
||||
@@ -631,7 +633,7 @@ function formatStr () {
|
||||
};
|
||||
|
||||
// see https://github.com/petkaantonov/bluebird/issues/1389
|
||||
function shiftArguments () {
|
||||
export function shiftArguments () {
|
||||
var len = arguments.length - 1;
|
||||
var args = new Array(len);
|
||||
for(var i = 0; i < len; ++i) {
|
||||
@@ -650,7 +652,7 @@ function shiftArguments () {
|
||||
* @param {Boolean} [forceDictMode=false] - Apply the delete operator to newly created map object. This causes V8 to put the object in "dictionary mode" and disables creation of hidden classes which are very expensive for objects that are constantly changing shape.
|
||||
* @return {Object}
|
||||
*/
|
||||
function createMap (forceDictMode) {
|
||||
export function createMap (forceDictMode) {
|
||||
var map = Object.create(null);
|
||||
if (forceDictMode) {
|
||||
const INVALID_IDENTIFIER_1 = '.';
|
||||
@@ -668,7 +670,7 @@ function createMap (forceDictMode) {
|
||||
* @submodule cc
|
||||
*/
|
||||
|
||||
var js = cc.js = {
|
||||
cc.js = {
|
||||
IDGenerater,
|
||||
Pool,
|
||||
array,
|
||||
@@ -700,7 +702,7 @@ var js = cc.js = {
|
||||
};
|
||||
|
||||
if (CC_DEV) {
|
||||
js.getset(js, '_registeredClassIds',
|
||||
cc.js.getset(js, '_registeredClassIds',
|
||||
function () {
|
||||
var dump = {};
|
||||
for (var id in _idToClass) {
|
||||
@@ -715,7 +717,7 @@ if (CC_DEV) {
|
||||
}
|
||||
}
|
||||
);
|
||||
js.getset(js, '_registeredClassNames',
|
||||
cc.js.getset(js, '_registeredClassNames',
|
||||
function () {
|
||||
var dump = {};
|
||||
for (var id in _nameToClass) {
|
||||
@@ -730,6 +732,4 @@ if (CC_DEV) {
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default js;
|
||||
}
|
||||
+11
-13
@@ -42,7 +42,7 @@ const NORMALIZE_RE = /[^\.\/]+\/\.\.\//;
|
||||
* @example {@link cocos2d/core/utils/CCPath/join.js}
|
||||
* @returns {String}
|
||||
*/
|
||||
function join () {
|
||||
export function join () {
|
||||
let l = arguments.length;
|
||||
let result = "";
|
||||
for (let i = 0; i < l; i++) {
|
||||
@@ -59,7 +59,7 @@ function join () {
|
||||
* @param {String} pathStr
|
||||
* @returns {*}
|
||||
*/
|
||||
function extname (pathStr) {
|
||||
export function extname (pathStr) {
|
||||
let temp = EXTNAME_RE.exec(pathStr);
|
||||
return temp ? temp[1] : '';
|
||||
}
|
||||
@@ -72,7 +72,7 @@ function extname (pathStr) {
|
||||
* @returns {String}
|
||||
* @deprecated
|
||||
*/
|
||||
function mainFileName (fileName) {
|
||||
export function mainFileName (fileName) {
|
||||
if (fileName) {
|
||||
let idx = fileName.lastIndexOf(".");
|
||||
if (idx !== -1)
|
||||
@@ -90,7 +90,7 @@ function mainFileName (fileName) {
|
||||
* @param {String} [extname]
|
||||
* @returns {*}
|
||||
*/
|
||||
function basename (pathStr, extname) {
|
||||
export function basename (pathStr, extname) {
|
||||
let index = pathStr.indexOf("?");
|
||||
if (index > 0) pathStr = pathStr.substring(0, index);
|
||||
let reg = /(\/|\\)([^\/\\]+)$/g;
|
||||
@@ -110,7 +110,7 @@ function basename (pathStr, extname) {
|
||||
* @param {String} pathStr
|
||||
* @returns {*}
|
||||
*/
|
||||
function dirname (pathStr) {
|
||||
export function dirname (pathStr) {
|
||||
let temp = DIRNAME_RE.exec(pathStr);
|
||||
return temp ? temp[2] : '';
|
||||
}
|
||||
@@ -124,7 +124,7 @@ function dirname (pathStr) {
|
||||
* @param {String} [extname]
|
||||
* @returns {String}
|
||||
*/
|
||||
function changeExtname (pathStr, extname) {
|
||||
export function changeExtname (pathStr, extname) {
|
||||
extname = extname || "";
|
||||
let index = pathStr.indexOf("?");
|
||||
let tempStr = "";
|
||||
@@ -146,7 +146,7 @@ function changeExtname (pathStr, extname) {
|
||||
* @param {Boolean} [isSameExt]
|
||||
* @returns {String}
|
||||
*/
|
||||
function changeBasename (pathStr, basename, isSameExt) {
|
||||
export function changeBasename (pathStr, basename, isSameExt) {
|
||||
if (basename.indexOf(".") === 0) return this.changeExtname(pathStr, basename);
|
||||
let index = pathStr.indexOf("?");
|
||||
let tempStr = "";
|
||||
@@ -161,7 +161,7 @@ function changeBasename (pathStr, basename, isSameExt) {
|
||||
}
|
||||
|
||||
//todo make public after verification
|
||||
function _normalize (url) {
|
||||
export function _normalize (url) {
|
||||
let oldUrl = url = String(url);
|
||||
|
||||
//removing all ../
|
||||
@@ -173,11 +173,11 @@ function _normalize (url) {
|
||||
}
|
||||
|
||||
// @param {string} path
|
||||
function stripSep (path) {
|
||||
export function stripSep (path) {
|
||||
return path.replace(/[\/\\]$/, '');
|
||||
}
|
||||
|
||||
var path = cc.path = {
|
||||
cc.path = {
|
||||
join,
|
||||
extname,
|
||||
mainFileName,
|
||||
@@ -190,6 +190,4 @@ var path = cc.path = {
|
||||
get sep () {
|
||||
return (cc.sys.os === cc.sys.OS_WINDOWS ? '\\' : '/');
|
||||
}
|
||||
};
|
||||
|
||||
export default path;
|
||||
};
|
||||
Reference in New Issue
Block a user