Commit ba414655 authored by rockyl's avatar rockyl

兼容数组的配置

parent e293595f
/**
* Created by rockyl on 2020-01-27.
*/
var genericRegexp = /(\w+)(<(\w+)>)?/;
function compute(props, options) {
var result = props || {};
var _loop_1 = function (key) {
var sourceValue = getValue(result, options, key);
var value = sourceValue;
if (options) {
if (Array.isArray(options)) {
for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
var option = options_1[_i];
var key = option.name;
var value = getValue(result, option, key);
result[key] = transform(key, value, option);
}
}
else {
for (var key in options) {
var option = options[key];
if (option && option.type) {
var _a = parseType(option.type), type = _a.type, generic_1 = _a.generic;
switch (type) {
case 'vector2':
value = parseVector2(sourceValue);
break;
case 'array':
var seps = sourceValue.split(',');
seps = seps.map(function (sep) {
var item;
if (generic_1) {
switch (generic_1) {
case 'number':
item = parseFloat(sep);
break;
case 'boolean':
item = sep === 'true';
break;
default:
item = sep;
break;
}
}
else {
item = sep;
var value = getValue(result, option, key);
result[key] = transform(key, value, option);
}
}
return result;
function transform(key, value, option) {
var sourceValue = value;
if (option && option.type) {
var _a = parseType(option.type), type = _a.type, generic_1 = _a.generic;
switch (type) {
case 'vector2':
value = parseVector2(sourceValue);
break;
case 'array':
var seps = sourceValue.split(',');
seps = seps.map(function (sep) {
var item;
if (generic_1) {
switch (generic_1) {
case 'number':
item = parseFloat(sep);
break;
case 'boolean':
item = sep === 'true';
break;
default:
item = sep;
break;
}
return item;
});
value = seps;
break;
}
}
else {
item = sep;
}
return item;
});
value = seps;
break;
}
}
result[key] = value;
};
for (var key in options) {
_loop_1(key);
return value;
}
return result;
}
function parseType(typeStr) {
var type = typeStr, generic;
......@@ -80,13 +85,13 @@ function parseVector2(sourceValue) {
}
return value;
}
function getValue(props, options, key) {
function getValue(props, option, key) {
var value;
if (props.hasOwnProperty(key)) {
value = props[key];
}
else if (options && options[key].hasOwnProperty('default')) {
value = options[key].default;
else if (option && option.hasOwnProperty('default')) {
value = option.default;
}
return value;
}
......
{"version":3,"file":"index.es.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-27.\n */\n\nconst genericRegexp = /(\\w+)(<(\\w+)>)?/;\n\nexport function compute(props, options) {\n\tlet result = props || {};\n\tfor (let key in options) {\n\t\tlet sourceValue = getValue(result, options, key);\n\t\tlet value = sourceValue;\n\t\tif (options) {\n\t\t\tlet option = options[key];\n\t\t\tif (option && option.type) {\n\t\t\t\tlet {type, generic} = parseType(option.type);\n\t\t\t\tswitch (type) {\n\t\t\t\t\tcase 'vector2':\n\t\t\t\t\t\tvalue = parseVector2(sourceValue);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'array':\n\t\t\t\t\t\tlet seps = sourceValue.split(',');\n\t\t\t\t\t\tseps = seps.map(sep => {\n\t\t\t\t\t\t\tlet item;\n\t\t\t\t\t\t\tif (generic) {\n\t\t\t\t\t\t\t\tswitch (generic) {\n\t\t\t\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\t\t\t\t\titem = parseFloat(sep);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\t\t\t\titem = sep === 'true';\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t\titem = sep;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\titem = sep;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn item;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tvalue = seps;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tresult[key] = value;\n\t}\n\treturn result;\n}\n\nexport function parseType(typeStr) {\n\tlet type = typeStr, generic;\n\tlet regResult = typeStr.match(genericRegexp);\n\tif (regResult) {\n\t\ttype = regResult[1];\n\t\tgeneric = regResult[3];\n\t}\n\n\treturn {\n\t\ttype, generic,\n\t}\n}\n\nexport function parseVector2(sourceValue) {\n\tlet value = sourceValue;\n\tif (!sourceValue) {\n\t\tvalue = {x: undefined, y: undefined};\n\t}\n\tif (typeof sourceValue === 'string') {\n\t\tlet arr = sourceValue.split(',');\n\t\tvalue = {\n\t\t\tx: arr[0] === '' ? undefined : parseFloat(arr[0]),\n\t\t\ty: arr[1] === '' ? undefined : parseFloat(arr[1]),\n\t\t};\n\t} else if (Array.isArray(sourceValue)) {\n\t\tvalue = {\n\t\t\tx: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),\n\t\t\ty: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),\n\t\t};\n\t}\n\treturn value;\n}\n\nfunction getValue(props, options, key) {\n\tlet value;\n\tif (props.hasOwnProperty(key)) {\n\t\tvalue = props[key];\n\t} else if (options && options[key].hasOwnProperty('default')) {\n\t\tvalue = options[key].default;\n\t}\n\n\treturn value;\n}\n"],"names":[],"mappings":"AAAA;;;AAIA,IAAM,aAAa,GAAG,iBAAiB,CAAC;AAExC,SAAgB,OAAO,CAAC,KAAK,EAAE,OAAO;IACrC,IAAI,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC;4BAChB,GAAG;QACX,IAAI,WAAW,GAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QACjD,IAAI,KAAK,GAAG,WAAW,CAAC;QACxB,IAAI,OAAO,EAAE;YACZ,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YAC1B,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE;gBACtB,IAAA,2BAAwC,EAAvC,cAAI,EAAE,sBAAiC,CAAC;gBAC7C,QAAQ,IAAI;oBACX,KAAK,SAAS;wBACb,KAAK,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;wBAClC,MAAM;oBACP,KAAK,OAAO;wBACX,IAAI,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC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AG,CAAC,CAAC;QACjC,KAAK,GAAG;YACP,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACjD,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACjD,CAAC;KACF;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QACtC,KAAK,GAAG;YACP,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACjE,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;SACjE,CAAC;KACF;IACD,OAAO,KAAK,CAAC;CACb;AAED,SAAS,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG;IACpC,IAAI,KAAK,CAAC;IACV,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;QAC9B,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;SAAM,IAAI,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;QAC7D,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;KAC7B;IAED,OAAO,KAAK,CAAC;CACb;;;;"}
\ No newline at end of file
{"version":3,"file":"index.es.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-27.\n */\n\nconst genericRegexp = /(\\w+)(<(\\w+)>)?/;\n\nexport function compute(props, options: Object | Array<any>) {\n\tlet result = props || {};\n\tif (Array.isArray(options)) {\n\t\tfor (let option of options) {\n\t\t\tlet key = option.name;\n\t\t\tlet value = getValue(result, option, key);\n\n\t\t\tresult[key] = transform(key, value, option);\n\t\t}\n\t} else {\n\t\tfor (let key in options) {\n\t\t\tlet option = options[key];\n\t\t\tlet value = getValue(result, option, key);\n\n\t\t\tresult[key] = transform(key, value, option);\n\t\t}\n\t}\n\treturn result;\n\n\tfunction transform(key, value, option) {\n\t\tlet sourceValue = value;\n\t\tif (option && option.type) {\n\t\t\tlet {type, generic} = parseType(option.type);\n\t\t\tswitch (type) {\n\t\t\t\tcase 'vector2':\n\t\t\t\t\tvalue = parseVector2(sourceValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'array':\n\t\t\t\t\tlet seps = sourceValue.split(',');\n\t\t\t\t\tseps = seps.map(sep => {\n\t\t\t\t\t\tlet item;\n\t\t\t\t\t\tif (generic) {\n\t\t\t\t\t\t\tswitch (generic) {\n\t\t\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\t\t\t\titem = parseFloat(sep);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\t\t\titem = sep === 'true';\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\titem = sep;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\titem = sep;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn item;\n\t\t\t\t\t});\n\t\t\t\t\tvalue = seps;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn value;\n\t}\n}\n\nexport function parseType(typeStr) {\n\tlet type = typeStr, generic;\n\tlet regResult = typeStr.match(genericRegexp);\n\tif (regResult) {\n\t\ttype = regResult[1];\n\t\tgeneric = regResult[3];\n\t}\n\n\treturn {\n\t\ttype, generic,\n\t}\n}\n\nexport function parseVector2(sourceValue) {\n\tlet value = sourceValue;\n\tif (!sourceValue) {\n\t\tvalue = {x: undefined, y: undefined};\n\t}\n\tif (typeof sourceValue === 'string') {\n\t\tlet arr = sourceValue.split(',');\n\t\tvalue = {\n\t\t\tx: arr[0] === '' ? undefined : parseFloat(arr[0]),\n\t\t\ty: arr[1] === '' ? undefined : parseFloat(arr[1]),\n\t\t};\n\t} else if (Array.isArray(sourceValue)) {\n\t\tvalue = {\n\t\t\tx: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),\n\t\t\ty: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),\n\t\t};\n\t}\n\treturn value;\n}\n\nfunction getValue(props, option, key) {\n\tlet value;\n\tif (props.hasOwnProperty(key)) {\n\t\tvalue = props[key];\n\t} else if (option && option.hasOwnProperty('default')) {\n\t\tvalue = option.default;\n\t}\n\n\treturn value;\n}\n"],"names":[],"mappings":"AAIA,IAAM,aAAa,GAAG,iBAAiB,CAAC;SAExB,OAAO,CAAC,KAAK,EAAE,OAA4B;IAC1D,IAAI,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC;IACzB,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,KAAmB,UAAO,EAAP,mBAAO,EAAP,qBAAO,EAAP,IAAO,EAAE;YAAvB,IAAI,MAAM,gBAAA;YACd,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC;YACtB,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;YAE1C,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;SAC5C;KACD;SAAM;QACN,KAAK,IAAI,GAAG,IAAI,OAAO,EAAE;YACxB,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YAC1B,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;YAE1C,MAAM,CAAC,GAAG,CAAC,GAAG,SAA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MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;QACtD,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC;KACvB;IAED,OAAO,KAAK,CAAC;AACd;;;;"}
\ No newline at end of file
......@@ -2,56 +2,61 @@
Object.defineProperty(exports, '__esModule', { value: true });
/**
* Created by rockyl on 2020-01-27.
*/
var genericRegexp = /(\w+)(<(\w+)>)?/;
function compute(props, options) {
var result = props || {};
var _loop_1 = function (key) {
var sourceValue = getValue(result, options, key);
var value = sourceValue;
if (options) {
if (Array.isArray(options)) {
for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
var option = options_1[_i];
var key = option.name;
var value = getValue(result, option, key);
result[key] = transform(key, value, option);
}
}
else {
for (var key in options) {
var option = options[key];
if (option && option.type) {
var _a = parseType(option.type), type = _a.type, generic_1 = _a.generic;
switch (type) {
case 'vector2':
value = parseVector2(sourceValue);
break;
case 'array':
var seps = sourceValue.split(',');
seps = seps.map(function (sep) {
var item;
if (generic_1) {
switch (generic_1) {
case 'number':
item = parseFloat(sep);
break;
case 'boolean':
item = sep === 'true';
break;
default:
item = sep;
break;
}
}
else {
item = sep;
var value = getValue(result, option, key);
result[key] = transform(key, value, option);
}
}
return result;
function transform(key, value, option) {
var sourceValue = value;
if (option && option.type) {
var _a = parseType(option.type), type = _a.type, generic_1 = _a.generic;
switch (type) {
case 'vector2':
value = parseVector2(sourceValue);
break;
case 'array':
var seps = sourceValue.split(',');
seps = seps.map(function (sep) {
var item;
if (generic_1) {
switch (generic_1) {
case 'number':
item = parseFloat(sep);
break;
case 'boolean':
item = sep === 'true';
break;
default:
item = sep;
break;
}
return item;
});
value = seps;
break;
}
}
else {
item = sep;
}
return item;
});
value = seps;
break;
}
}
result[key] = value;
};
for (var key in options) {
_loop_1(key);
return value;
}
return result;
}
function parseType(typeStr) {
var type = typeStr, generic;
......@@ -84,13 +89,13 @@ function parseVector2(sourceValue) {
}
return value;
}
function getValue(props, options, key) {
function getValue(props, option, key) {
var value;
if (props.hasOwnProperty(key)) {
value = props[key];
}
else if (options && options[key].hasOwnProperty('default')) {
value = options[key].default;
else if (option && option.hasOwnProperty('default')) {
value = option.default;
}
return value;
}
......
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-27.\n */\n\nconst genericRegexp = /(\\w+)(<(\\w+)>)?/;\n\nexport function compute(props, options) {\n\tlet result = props || {};\n\tfor (let key in options) {\n\t\tlet sourceValue = getValue(result, options, key);\n\t\tlet value = sourceValue;\n\t\tif (options) {\n\t\t\tlet option = options[key];\n\t\t\tif (option && option.type) {\n\t\t\t\tlet {type, generic} = parseType(option.type);\n\t\t\t\tswitch (type) {\n\t\t\t\t\tcase 'vector2':\n\t\t\t\t\t\tvalue = parseVector2(sourceValue);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'array':\n\t\t\t\t\t\tlet seps = sourceValue.split(',');\n\t\t\t\t\t\tseps = seps.map(sep => {\n\t\t\t\t\t\t\tlet item;\n\t\t\t\t\t\t\tif (generic) {\n\t\t\t\t\t\t\t\tswitch (generic) {\n\t\t\t\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\t\t\t\t\titem = parseFloat(sep);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\t\t\t\titem = sep === 'true';\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t\titem = sep;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\titem = sep;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn item;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tvalue = seps;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tresult[key] = value;\n\t}\n\treturn result;\n}\n\nexport function parseType(typeStr) {\n\tlet type = typeStr, generic;\n\tlet regResult = typeStr.match(genericRegexp);\n\tif (regResult) {\n\t\ttype = regResult[1];\n\t\tgeneric = regResult[3];\n\t}\n\n\treturn {\n\t\ttype, generic,\n\t}\n}\n\nexport function parseVector2(sourceValue) {\n\tlet value = sourceValue;\n\tif (!sourceValue) {\n\t\tvalue = {x: undefined, y: undefined};\n\t}\n\tif (typeof sourceValue === 'string') {\n\t\tlet arr = sourceValue.split(',');\n\t\tvalue = {\n\t\t\tx: arr[0] === '' ? undefined : parseFloat(arr[0]),\n\t\t\ty: arr[1] === '' ? undefined : parseFloat(arr[1]),\n\t\t};\n\t} else if (Array.isArray(sourceValue)) {\n\t\tvalue = {\n\t\t\tx: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),\n\t\t\ty: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),\n\t\t};\n\t}\n\treturn value;\n}\n\nfunction getValue(props, options, key) {\n\tlet value;\n\tif (props.hasOwnProperty(key)) {\n\t\tvalue = props[key];\n\t} else if (options && options[key].hasOwnProperty('default')) {\n\t\tvalue = options[key].default;\n\t}\n\n\treturn value;\n}\n"],"names":[],"mappings":";;;;AAAA;;;AAIA,IAAM,aAAa,GAAG,iBAAiB,CAAC;AAExC,SAAgB,OAAO,CAAC,KAAK,EAAE,OAAO;IACrC,IAAI,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC;4BAChB,GAAG;QACX,IAAI,WAAW,GAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QACjD,IAAI,KAAK,GAAG,WAAW,CAAC;QACxB,IAAI,OAAO,EAAE;YACZ,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YAC1B,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE;gBACtB,IAAA,2BAAwC,EAAvC,cAAI,EAAE,sBAAiC,CAAC;gBAC7C,QAAQ,IAAI;oBACX,KAAK,SAAS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AAS,EAAE,CAAC,EAAE,SAAS,EAAC,CAAC;KACrC;IACD,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACpC,IAAI,GAAG,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjC,KAAK,GAAG;YACP,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACjD,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACjD,CAAC;KACF;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QACtC,KAAK,GAAG;YACP,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACjE,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;SACjE,CAAC;KACF;IACD,OAAO,KAAK,CAAC;CACb;AAED,SAAS,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG;IACpC,IAAI,KAAK,CAAC;IACV,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;QAC9B,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;SAAM,IAAI,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;QAC7D,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;KAC7B;IAED,OAAO,KAAK,CAAC;CACb;;;;;;"}
\ No newline at end of file
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-27.\n */\n\nconst genericRegexp = /(\\w+)(<(\\w+)>)?/;\n\nexport function compute(props, options: Object | Array<any>) {\n\tlet result = props || {};\n\tif (Array.isArray(options)) {\n\t\tfor (let option of options) {\n\t\t\tlet key = option.name;\n\t\t\tlet value = getValue(result, option, key);\n\n\t\t\tresult[key] = transform(key, value, option);\n\t\t}\n\t} else {\n\t\tfor (let key in options) {\n\t\t\tlet option = options[key];\n\t\t\tlet value = getValue(result, option, key);\n\n\t\t\tresult[key] = transform(key, value, option);\n\t\t}\n\t}\n\treturn result;\n\n\tfunction transform(key, value, option) {\n\t\tlet sourceValue = value;\n\t\tif (option && option.type) {\n\t\t\tlet {type, generic} = parseType(option.type);\n\t\t\tswitch (type) {\n\t\t\t\tcase 'vector2':\n\t\t\t\t\tvalue = parseVector2(sourceValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'array':\n\t\t\t\t\tlet seps = sourceValue.split(',');\n\t\t\t\t\tseps = seps.map(sep => {\n\t\t\t\t\t\tlet item;\n\t\t\t\t\t\tif (generic) {\n\t\t\t\t\t\t\tswitch (generic) {\n\t\t\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\t\t\t\titem = parseFloat(sep);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\t\t\titem = sep === 'true';\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\titem = sep;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\titem = sep;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn item;\n\t\t\t\t\t});\n\t\t\t\t\tvalue = seps;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn value;\n\t}\n}\n\nexport function parseType(typeStr) {\n\tlet type = typeStr, generic;\n\tlet regResult = typeStr.match(genericRegexp);\n\tif (regResult) {\n\t\ttype = regResult[1];\n\t\tgeneric = regResult[3];\n\t}\n\n\treturn {\n\t\ttype, generic,\n\t}\n}\n\nexport function parseVector2(sourceValue) {\n\tlet value = sourceValue;\n\tif (!sourceValue) {\n\t\tvalue = {x: undefined, y: undefined};\n\t}\n\tif (typeof sourceValue === 'string') {\n\t\tlet arr = sourceValue.split(',');\n\t\tvalue = {\n\t\t\tx: arr[0] === '' ? undefined : parseFloat(arr[0]),\n\t\t\ty: arr[1] === '' ? undefined : parseFloat(arr[1]),\n\t\t};\n\t} else if (Array.isArray(sourceValue)) {\n\t\tvalue = {\n\t\t\tx: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),\n\t\t\ty: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),\n\t\t};\n\t}\n\treturn value;\n}\n\nfunction getValue(props, option, key) {\n\tlet value;\n\tif (props.hasOwnProperty(key)) {\n\t\tvalue = props[key];\n\t} else if (option && option.hasOwnProperty('default')) {\n\t\tvalue = option.default;\n\t}\n\n\treturn value;\n}\n"],"names":[],"mappings":";;;;AAIA,IAAM,aAAa,GAAG,iBAAiB,CAAC;SAExB,OAAO,CAAC,KAAK,EAAE,OAA4B;IAC1D,IAAI,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC;IACzB,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,KAAmB,UAAO,EAAP,mBAAO,EAAP,qBAAO,EAAP,IAAO,EAAE;YAAvB,IAAI,MAAM,gBAAA;YACd,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC;YACtB,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;YAE1C,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;SAC5C;KACD;SAAM;QACN,KAAK,IAAI,GAAG,IAAI,OAAO,EAAE;YACxB,IAAI,MAAM,GAAG,OAAO,CA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AAK,CAAC;IACV,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;QAC9B,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;KACnB;SAAM,IAAI,MAAM,IAAI,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;QACtD,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC;KACvB;IAED,OAAO,KAAK,CAAC;AACd;;;;;;"}
\ No newline at end of file
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global['props-compute'] = {}));
}(this, function (exports) { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['props-compute'] = {}));
}(this, (function (exports) { 'use strict';
/**
* Created by rockyl on 2020-01-27.
*/
var genericRegexp = /(\w+)(<(\w+)>)?/;
function compute(props, options) {
var result = props || {};
var _loop_1 = function (key) {
var sourceValue = getValue(result, options, key);
var value = sourceValue;
if (options) {
if (Array.isArray(options)) {
for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
var option = options_1[_i];
var key = option.name;
var value = getValue(result, option, key);
result[key] = transform(key, value, option);
}
}
else {
for (var key in options) {
var option = options[key];
if (option && option.type) {
var _a = parseType(option.type), type = _a.type, generic_1 = _a.generic;
switch (type) {
case 'vector2':
value = parseVector2(sourceValue);
break;
case 'array':
var seps = sourceValue.split(',');
seps = seps.map(function (sep) {
var item;
if (generic_1) {
switch (generic_1) {
case 'number':
item = parseFloat(sep);
break;
case 'boolean':
item = sep === 'true';
break;
default:
item = sep;
break;
}
}
else {
item = sep;
var value = getValue(result, option, key);
result[key] = transform(key, value, option);
}
}
return result;
function transform(key, value, option) {
var sourceValue = value;
if (option && option.type) {
var _a = parseType(option.type), type = _a.type, generic_1 = _a.generic;
switch (type) {
case 'vector2':
value = parseVector2(sourceValue);
break;
case 'array':
var seps = sourceValue.split(',');
seps = seps.map(function (sep) {
var item;
if (generic_1) {
switch (generic_1) {
case 'number':
item = parseFloat(sep);
break;
case 'boolean':
item = sep === 'true';
break;
default:
item = sep;
break;
}
return item;
});
value = seps;
break;
}
}
else {
item = sep;
}
return item;
});
value = seps;
break;
}
}
result[key] = value;
};
for (var key in options) {
_loop_1(key);
return value;
}
return result;
}
function parseType(typeStr) {
var type = typeStr, generic;
......@@ -86,13 +91,13 @@
}
return value;
}
function getValue(props, options, key) {
function getValue(props, option, key) {
var value;
if (props.hasOwnProperty(key)) {
value = props[key];
}
else if (options && options[key].hasOwnProperty('default')) {
value = options[key].default;
else if (option && option.hasOwnProperty('default')) {
value = option.default;
}
return value;
}
......@@ -103,5 +108,5 @@
Object.defineProperty(exports, '__esModule', { value: true });
}));
})));
//# sourceMappingURL=index.umd.js.map
{"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-27.\n */\n\nconst genericRegexp = /(\\w+)(<(\\w+)>)?/;\n\nexport function compute(props, options) {\n\tlet result = props || {};\n\tfor (let key in options) {\n\t\tlet sourceValue = getValue(result, options, key);\n\t\tlet value = sourceValue;\n\t\tif (options) {\n\t\t\tlet option = options[key];\n\t\t\tif (option && option.type) {\n\t\t\t\tlet {type, generic} = parseType(option.type);\n\t\t\t\tswitch (type) {\n\t\t\t\t\tcase 'vector2':\n\t\t\t\t\t\tvalue = parseVector2(sourceValue);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'array':\n\t\t\t\t\t\tlet seps = sourceValue.split(',');\n\t\t\t\t\t\tseps = seps.map(sep => {\n\t\t\t\t\t\t\tlet item;\n\t\t\t\t\t\t\tif (generic) {\n\t\t\t\t\t\t\t\tswitch (generic) {\n\t\t\t\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\t\t\t\t\titem = parseFloat(sep);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\t\t\t\titem = sep === 'true';\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t\titem = sep;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\titem = sep;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn item;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tvalue = seps;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tresult[key] = value;\n\t}\n\treturn result;\n}\n\nexport function parseType(typeStr) {\n\tlet type = typeStr, generic;\n\tlet regResult = typeStr.match(genericRegexp);\n\tif (regResult) {\n\t\ttype = regResult[1];\n\t\tgeneric = regResult[3];\n\t}\n\n\treturn {\n\t\ttype, generic,\n\t}\n}\n\nexport function parseVector2(sourceValue) {\n\tlet value = sourceValue;\n\tif (!sourceValue) {\n\t\tvalue = {x: undefined, y: undefined};\n\t}\n\tif (typeof sourceValue === 'string') {\n\t\tlet arr = sourceValue.split(',');\n\t\tvalue = {\n\t\t\tx: arr[0] === '' ? undefined : parseFloat(arr[0]),\n\t\t\ty: arr[1] === '' ? undefined : parseFloat(arr[1]),\n\t\t};\n\t} else if (Array.isArray(sourceValue)) {\n\t\tvalue = {\n\t\t\tx: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),\n\t\t\ty: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),\n\t\t};\n\t}\n\treturn value;\n}\n\nfunction getValue(props, options, key) {\n\tlet value;\n\tif (props.hasOwnProperty(key)) {\n\t\tvalue = props[key];\n\t} else if (options && options[key].hasOwnProperty('default')) {\n\t\tvalue = options[key].default;\n\t}\n\n\treturn value;\n}\n"],"names":[],"mappings":";;;;;;CAAA;;;CAIA,IAAM,aAAa,GAAG,iBAAiB,CAAC;AAExC,UAAgB,OAAO,CAAC,KAAK,EAAE,OAAO;KACrC,IAAI,MAAM,GAAG,K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V,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;SAC9B,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;MACnB;UAAM,IAAI,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;SAC7D,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;MAC7B;KAED,OAAO,KAAK,CAAC;CACd,CAAC;;;;;;;;;;;;;;"}
\ No newline at end of file
{"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-27.\n */\n\nconst genericRegexp = /(\\w+)(<(\\w+)>)?/;\n\nexport function compute(props, options: Object | Array<any>) {\n\tlet result = props || {};\n\tif (Array.isArray(options)) {\n\t\tfor (let option of options) {\n\t\t\tlet key = option.name;\n\t\t\tlet value = getValue(result, option, key);\n\n\t\t\tresult[key] = transform(key, value, option);\n\t\t}\n\t} else {\n\t\tfor (let key in options) {\n\t\t\tlet option = options[key];\n\t\t\tlet value = getValue(result, option, key);\n\n\t\t\tresult[key] = transform(key, value, option);\n\t\t}\n\t}\n\treturn result;\n\n\tfunction transform(key, value, option) {\n\t\tlet sourceValue = value;\n\t\tif (option && option.type) {\n\t\t\tlet {type, generic} = parseType(option.type);\n\t\t\tswitch (type) {\n\t\t\t\tcase 'vector2':\n\t\t\t\t\tvalue = parseVector2(sourceValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'array':\n\t\t\t\t\tlet seps = sourceValue.split(',');\n\t\t\t\t\tseps = seps.map(sep => {\n\t\t\t\t\t\tlet item;\n\t\t\t\t\t\tif (generic) {\n\t\t\t\t\t\t\tswitch (generic) {\n\t\t\t\t\t\t\t\tcase 'number':\n\t\t\t\t\t\t\t\t\titem = parseFloat(sep);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase 'boolean':\n\t\t\t\t\t\t\t\t\titem = sep === 'true';\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\titem = sep;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\titem = sep;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn item;\n\t\t\t\t\t});\n\t\t\t\t\tvalue = seps;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn value;\n\t}\n}\n\nexport function parseType(typeStr) {\n\tlet type = typeStr, generic;\n\tlet regResult = typeStr.match(genericRegexp);\n\tif (regResult) {\n\t\ttype = regResult[1];\n\t\tgeneric = regResult[3];\n\t}\n\n\treturn {\n\t\ttype, generic,\n\t}\n}\n\nexport function parseVector2(sourceValue) {\n\tlet value = sourceValue;\n\tif (!sourceValue) {\n\t\tvalue = {x: undefined, y: undefined};\n\t}\n\tif (typeof sourceValue === 'string') {\n\t\tlet arr = sourceValue.split(',');\n\t\tvalue = {\n\t\t\tx: arr[0] === '' ? undefined : parseFloat(arr[0]),\n\t\t\ty: arr[1] === '' ? undefined : parseFloat(arr[1]),\n\t\t};\n\t} else if (Array.isArray(sourceValue)) {\n\t\tvalue = {\n\t\t\tx: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),\n\t\t\ty: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),\n\t\t};\n\t}\n\treturn value;\n}\n\nfunction getValue(props, option, key) {\n\tlet value;\n\tif (props.hasOwnProperty(key)) {\n\t\tvalue = props[key];\n\t} else if (option && option.hasOwnProperty('default')) {\n\t\tvalue = option.default;\n\t}\n\n\treturn value;\n}\n"],"names":[],"mappings":";;;;;;CAIA,IAAM,aAAa,GAAG,iBAAiB,CAAC;UAExB,OAAO,CAAC,KAAK,EAAE,OAA4B;KAC1D,IAAI,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC;KACzB,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,C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IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;SACtC,KAAK,GAAG;aACP,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;aACjE,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;UACjE,CAAC;MACF;KACD,OAAO,KAAK,CAAC;CACd,CAAC;CAED,SAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG;KACnC,IAAI,KAAK,CAAC;KACV,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;SAC9B,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;MACnB;UAAM,IAAI,MAAM,IAAI,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;SACtD,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC;MACvB;KAED,OAAO,KAAK,CAAC;CACd;;;;;;;;;;;;;;"}
\ No newline at end of file
......@@ -3,14 +3,17 @@
"version": "1.0.0",
"main": "dist/index.js",
"module": "dist/index.es.js",
"types": "types.d.ts",
"license": "MIT",
"scripts": {
"dev": "rollup -c -w",
"build": "rollup -c"
"build": "rollup -c",
"dts": "dts-bundle-generator -o types.d.ts src/index.ts"
},
"devDependencies": {
"dts-bundle-generator": "^5.4.0",
"rollup-plugin-typescript": "^1.0.1",
"tslib": "^1.11.1",
"typescript": "^3.8.3"
"tslib": "^2.0.1",
"typescript": "^4.0.3"
}
}
......@@ -2,9 +2,8 @@
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/dist" />
</content>
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
"use strict";
/**
* Created by rockyl on 2020-01-27.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var genericRegexp = /(\w+)(<(\w+)>)?/;
function compute(props, options) {
var result = props || {};
var _loop_1 = function (key) {
var sourceValue = getValue(result, options, key);
var value = sourceValue;
if (options) {
var option = options[key];
if (option && option.type) {
var _a = parseType(option.type), type = _a.type, generic_1 = _a.generic;
switch (type) {
case 'vector2':
value = parseVector2(sourceValue);
break;
case 'array':
var seps = sourceValue.split(',');
seps = seps.map(function (sep) {
var item;
if (generic_1) {
switch (generic_1) {
case 'number':
item = parseFloat(sep);
break;
case 'boolean':
item = sep === 'true';
break;
default:
item = sep;
break;
}
}
else {
item = sep;
}
return item;
});
value = seps;
break;
}
}
}
result[key] = value;
};
for (var key in options) {
_loop_1(key);
}
return result;
}
exports.compute = compute;
function parseType(typeStr) {
var type = typeStr, generic;
var regResult = typeStr.match(genericRegexp);
if (regResult) {
type = regResult[1];
generic = regResult[3];
}
return {
type: type, generic: generic,
};
}
exports.parseType = parseType;
function parseVector2(sourceValue) {
var value = sourceValue;
if (!sourceValue) {
value = { x: undefined, y: undefined };
}
if (typeof sourceValue === 'string') {
var arr = sourceValue.split(',');
value = {
x: arr[0] === '' ? undefined : parseFloat(arr[0]),
y: arr[1] === '' ? undefined : parseFloat(arr[1]),
};
}
else if (Array.isArray(sourceValue)) {
value = {
x: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),
y: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),
};
}
return value;
}
exports.parseVector2 = parseVector2;
function getValue(props, options, key) {
var value;
if (props.hasOwnProperty(key)) {
value = props[key];
}
else if (options && options[key].hasOwnProperty('default')) {
value = options[key].default;
}
return value;
}
......@@ -4,48 +4,60 @@
const genericRegexp = /(\w+)(<(\w+)>)?/;
export function compute(props, options) {
export function compute(props, options: Object | Array<any>) {
let result = props || {};
for (let key in options) {
let sourceValue = getValue(result, options, key);
let value = sourceValue;
if (options) {
if (Array.isArray(options)) {
for (let option of options) {
let key = option.name;
let value = getValue(result, option, key);
result[key] = transform(key, value, option);
}
} else {
for (let key in options) {
let option = options[key];
if (option && option.type) {
let {type, generic} = parseType(option.type);
switch (type) {
case 'vector2':
value = parseVector2(sourceValue);
break;
case 'array':
let seps = sourceValue.split(',');
seps = seps.map(sep => {
let item;
if (generic) {
switch (generic) {
case 'number':
item = parseFloat(sep);
break;
case 'boolean':
item = sep === 'true';
break;
default:
item = sep;
break;
}
} else {
item = sep;
let value = getValue(result, option, key);
result[key] = transform(key, value, option);
}
}
return result;
function transform(key, value, option) {
let sourceValue = value;
if (option && option.type) {
let {type, generic} = parseType(option.type);
switch (type) {
case 'vector2':
value = parseVector2(sourceValue);
break;
case 'array':
let seps = sourceValue.split(',');
seps = seps.map(sep => {
let item;
if (generic) {
switch (generic) {
case 'number':
item = parseFloat(sep);
break;
case 'boolean':
item = sep === 'true';
break;
default:
item = sep;
break;
}
return item;
});
value = seps;
break;
}
} else {
item = sep;
}
return item;
});
value = seps;
break;
}
}
result[key] = value;
return value;
}
return result;
}
export function parseType(typeStr) {
......@@ -81,12 +93,12 @@ export function parseVector2(sourceValue) {
return value;
}
function getValue(props, options, key) {
function getValue(props, option, key) {
let value;
if (props.hasOwnProperty(key)) {
value = props[key];
} else if (options && options[key].hasOwnProperty('default')) {
value = options[key].default;
} else if (option && option.hasOwnProperty('default')) {
value = option.default;
}
return value;
......
{
"compilerOptions": {
"module": "ES2015",
"target": "es5",
"noImplicitAny": false,
"sourceMap": true,
"removeComments": true,
"noEmitOnError": true,
"noEmitHelpers": true,
"experimentalDecorators": true,
"outDir": "dist-m",
"lib": [
"es5",
"dom",
"es2015.promise"
]
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
}
\ No newline at end of file
// Generated by dts-bundle-generator v5.4.0
export declare function compute(props: any, options: Object | Array<any>): any;
export declare function parseType(typeStr: any): {
type: any;
generic: any;
};
export declare function parseVector2(sourceValue: any): any;
export {};
......@@ -2,16 +2,137 @@
# yarn lockfile v1
"@types/color-name@^1.1.1":
version "1.1.1"
resolved "https://registry.npm.taobao.org/@types/color-name/download/@types/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
integrity sha1-HBJhu+qhCoBVu8XYq4S3sq/IRqA=
ansi-regex@^5.0.0:
version "5.0.0"
resolved "https://registry.npm.taobao.org/ansi-regex/download/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
integrity sha1-OIU59VF5vzkznIGvMKZU1p+Hy3U=
ansi-styles@^4.0.0:
version "4.2.1"
resolved "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359"
integrity sha1-kK51xCTQCNJiTFvynq0xd+v881k=
dependencies:
"@types/color-name" "^1.1.1"
color-convert "^2.0.1"
camelcase@^5.0.0:
version "5.3.1"
resolved "https://registry.npm.taobao.org/camelcase/download/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
integrity sha1-48mzFWnhBoEd8kL3FXJaH0xJQyA=
cliui@^6.0.0:
version "6.0.0"
resolved "https://registry.npm.taobao.org/cliui/download/cliui-6.0.0.tgz?cache=0&sync_timestamp=1597607904134&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcliui%2Fdownload%2Fcliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1"
integrity sha1-UR1wLAxOQcoVbX0OlgIfI+EyJbE=
dependencies:
string-width "^4.2.0"
strip-ansi "^6.0.0"
wrap-ansi "^6.2.0"
color-convert@^2.0.1:
version "2.0.1"
resolved "https://registry.npm.taobao.org/color-convert/download/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
integrity sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=
dependencies:
color-name "~1.1.4"
color-name@~1.1.4:
version "1.1.4"
resolved "https://registry.npm.taobao.org/color-name/download/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha1-wqCah6y95pVD3m9j+jmVyCbFNqI=
decamelize@^1.2.0:
version "1.2.0"
resolved "https://registry.npm.taobao.org/decamelize/download/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
dts-bundle-generator@^5.4.0:
version "5.4.0"
resolved "https://registry.npm.taobao.org/dts-bundle-generator/download/dts-bundle-generator-5.4.0.tgz#97e592c4304287e5916196e60a8b70d7c1408455"
integrity sha1-l+WSxDBCh+WRYZbmCotw18FAhFU=
dependencies:
typescript ">=3.0.1"
yargs "^15.3.1"
emoji-regex@^8.0.0:
version "8.0.0"
resolved "https://registry.npm.taobao.org/emoji-regex/download/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
integrity sha1-6Bj9ac5cz8tARZT4QpY79TFkzDc=
estree-walker@^0.6.1:
version "0.6.1"
resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362"
integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==
find-up@^4.1.0:
version "4.1.0"
resolved "https://registry.npm.taobao.org/find-up/download/find-up-4.1.0.tgz?cache=0&sync_timestamp=1597169884679&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffind-up%2Fdownload%2Ffind-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19"
integrity sha1-l6/n1s3AvFkoWEt8jXsW6KmqXRk=
dependencies:
locate-path "^5.0.0"
path-exists "^4.0.0"
get-caller-file@^2.0.1:
version "2.0.5"
resolved "https://registry.npm.taobao.org/get-caller-file/download/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
integrity sha1-T5RBKoLbMvNuOwuXQfipf+sDH34=
is-fullwidth-code-point@^3.0.0:
version "3.0.0"
resolved "https://registry.npm.taobao.org/is-fullwidth-code-point/download/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
integrity sha1-8Rb4Bk/pCz94RKOJl8C3UFEmnx0=
locate-path@^5.0.0:
version "5.0.0"
resolved "https://registry.npm.taobao.org/locate-path/download/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0"
integrity sha1-Gvujlq/WdqbUJQTQpno6frn2KqA=
dependencies:
p-locate "^4.1.0"
p-limit@^2.2.0:
version "2.3.0"
resolved "https://registry.npm.taobao.org/p-limit/download/p-limit-2.3.0.tgz?cache=0&sync_timestamp=1594559668746&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fp-limit%2Fdownload%2Fp-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
integrity sha1-PdM8ZHohT9//2DWTPrCG2g3CHbE=
dependencies:
p-try "^2.0.0"
p-locate@^4.1.0:
version "4.1.0"
resolved "https://registry.npm.taobao.org/p-locate/download/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07"
integrity sha1-o0KLtwiLOmApL2aRkni3wpetTwc=
dependencies:
p-limit "^2.2.0"
p-try@^2.0.0:
version "2.2.0"
resolved "https://registry.npm.taobao.org/p-try/download/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
integrity sha1-yyhoVA4xPWHeWPr741zpAE1VQOY=
path-exists@^4.0.0:
version "4.0.0"
resolved "https://registry.npm.taobao.org/path-exists/download/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
integrity sha1-UTvb4tO5XXdi6METfvoZXGxhtbM=
path-parse@^1.0.6:
version "1.0.6"
resolved "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==
require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.npm.taobao.org/require-directory/download/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I=
require-main-filename@^2.0.0:
version "2.0.0"
resolved "https://registry.npm.taobao.org/require-main-filename/download/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
integrity sha1-0LMp7MfMD2Fkn2IhW+aa9UqomJs=
resolve@^1.10.0:
version "1.15.1"
resolved "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8"
......@@ -21,8 +142,8 @@ resolve@^1.10.0:
rollup-plugin-typescript@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/rollup-plugin-typescript/-/rollup-plugin-typescript-1.0.1.tgz#86565033b714c3d1f3aba510aad3dc519f7091e9"
integrity sha512-rwJDNn9jv/NsKZuyBb/h0jsclP4CJ58qbvZt2Q9zDIGILF2LtdtvCqMOL+Gq9IVq5MTrTlHZNrn8h7VjQgd8tw==
resolved "https://registry.npm.taobao.org/rollup-plugin-typescript/download/rollup-plugin-typescript-1.0.1.tgz#86565033b714c3d1f3aba510aad3dc519f7091e9"
integrity sha1-hlZQM7cUw9Hzq6UQqtPcUZ9wkek=
dependencies:
resolve "^1.10.0"
rollup-pluginutils "^2.5.0"
......@@ -34,12 +155,77 @@ rollup-pluginutils@^2.5.0:
dependencies:
estree-walker "^0.6.1"
tslib@^1.11.1:
version "1.11.1"
resolved "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35"
integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==
set-blocking@^2.0.0:
version "2.0.0"
resolved "https://registry.npm.taobao.org/set-blocking/download/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc=
string-width@^4.1.0, string-width@^4.2.0:
version "4.2.0"
resolved "https://registry.npm.taobao.org/string-width/download/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5"
integrity sha1-lSGCxGzHssMT0VluYjmSvRY7crU=
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.0"
strip-ansi@^6.0.0:
version "6.0.0"
resolved "https://registry.npm.taobao.org/strip-ansi/download/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
integrity sha1-CxVx3XZpzNTz4G4U7x7tJiJa5TI=
dependencies:
ansi-regex "^5.0.0"
tslib@^2.0.1:
version "2.0.1"
resolved "https://registry.npm.taobao.org/tslib/download/tslib-2.0.1.tgz?cache=0&sync_timestamp=1596751917452&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftslib%2Fdownload%2Ftslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e"
integrity sha1-QQ6w0RPltjVkkO7HSWA3JbAhtD4=
typescript@>=3.0.1, typescript@^4.0.3:
version "4.0.3"
resolved "https://registry.npm.taobao.org/typescript/download/typescript-4.0.3.tgz?cache=0&sync_timestamp=1600687348536&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftypescript%2Fdownload%2Ftypescript-4.0.3.tgz#153bbd468ef07725c1df9c77e8b453f8d36abba5"
integrity sha1-FTu9Ro7wdyXB35x36LRT+NNqu6U=
which-module@^2.0.0:
version "2.0.0"
resolved "https://registry.npm.taobao.org/which-module/download/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=
wrap-ansi@^6.2.0:
version "6.2.0"
resolved "https://registry.npm.taobao.org/wrap-ansi/download/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53"
integrity sha1-6Tk7oHEC5skaOyIUePAlfNKFblM=
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"
y18n@^4.0.0:
version "4.0.0"
resolved "https://registry.npm.taobao.org/y18n/download/y18n-4.0.0.tgz?cache=0&sync_timestamp=1599868278022&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fy18n%2Fdownload%2Fy18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
integrity sha1-le+U+F7MgdAHwmThkKEg8KPIVms=
typescript@^3.8.3:
version "3.8.3"
resolved "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==
yargs-parser@^18.1.2:
version "18.1.3"
resolved "https://registry.npm.taobao.org/yargs-parser/download/yargs-parser-18.1.3.tgz?cache=0&sync_timestamp=1600655125311&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fyargs-parser%2Fdownload%2Fyargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"
integrity sha1-vmjEl1xrKr9GkjawyHA2L6sJp7A=
dependencies:
camelcase "^5.0.0"
decamelize "^1.2.0"
yargs@^15.3.1:
version "15.4.1"
resolved "https://registry.npm.taobao.org/yargs/download/yargs-15.4.1.tgz?cache=0&sync_timestamp=1600660043201&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fyargs%2Fdownload%2Fyargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
integrity sha1-DYehbeAa7p2L7Cv7909nhRcw9Pg=
dependencies:
cliui "^6.0.0"
decamelize "^1.2.0"
find-up "^4.1.0"
get-caller-file "^2.0.1"
require-directory "^2.1.1"
require-main-filename "^2.0.0"
set-blocking "^2.0.0"
string-width "^4.2.0"
which-module "^2.0.0"
y18n "^4.0.0"
yargs-parser "^18.1.2"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment