Commit 9c6abccc authored by rockyl's avatar rockyl

改用ts

parent 8ef14521
/** /**
* Created by rockyl on 2020-01-27. * Created by rockyl on 2020-01-27.
*/ */
var genericRegexp = /(\w+)(<(\w+)>)?/;
const genericRegexp = /(\w+)(<(\w+)>)?/;
function compute(props, options) { function compute(props, options) {
let result = props || {}; var result = props || {};
for (let key in options) { var _loop_1 = function (key) {
let sourceValue = getValue(result, options, key); var sourceValue = getValue(result, options, key);
let value = sourceValue; var value = sourceValue;
if (options) { if (options) {
let option = options[key]; var option = options[key];
if (option && option.type) { if (option && option.type) {
let {type, generic} = parseType(option.type); var _a = parseType(option.type), type = _a.type, generic_1 = _a.generic;
switch (type) { switch (type) {
case 'vector2': case 'vector2':
value = parseVector2(sourceValue); value = parseVector2(sourceValue);
break; break;
case 'array': case 'array':
let seps = sourceValue.split(','); var seps = sourceValue.split(',');
seps = seps.map(sep => { seps = seps.map(function (sep) {
let item; var item;
if (generic) { if (generic_1) {
switch (generic) { switch (generic_1) {
case 'number': case 'number':
item = parseFloat(sep); item = parseFloat(sep);
break; break;
case 'boolean': case 'boolean':
item = sep === 'true'; item = sep === 'true';
break; break;
default: default:
item = sep; item = sep;
break; break;
} }
} else { }
item = sep; else {
} item = sep;
return item; }
}); return item;
value = seps; });
break; value = seps;
} break;
} }
} }
result[key] = value; }
} result[key] = value;
return result; };
for (var key in options) {
_loop_1(key);
}
return result;
} }
function parseType(typeStr) { function parseType(typeStr) {
let type = typeStr, generic; var type = typeStr, generic;
let regResult = typeStr.match(genericRegexp); var regResult = typeStr.match(genericRegexp);
if (regResult) { if (regResult) {
type = regResult[1]; type = regResult[1];
generic = regResult[3]; generic = regResult[3];
} }
return {
return { type: type, generic: generic,
type, generic, };
}
} }
function parseVector2(sourceValue) { function parseVector2(sourceValue) {
let value = sourceValue; var value = sourceValue;
if (!sourceValue) { if (!sourceValue) {
value = {x: undefined, y: undefined}; value = { x: undefined, y: undefined };
} }
if (typeof sourceValue === 'string') { if (typeof sourceValue === 'string') {
let arr = sourceValue.split(','); var arr = sourceValue.split(',');
value = { value = {
x: arr[0] === '' ? undefined : parseFloat(arr[0]), x: arr[0] === '' ? undefined : parseFloat(arr[0]),
y: arr[1] === '' ? undefined : parseFloat(arr[1]), y: arr[1] === '' ? undefined : parseFloat(arr[1]),
}; };
} else if (Array.isArray(sourceValue)) { }
value = { else if (Array.isArray(sourceValue)) {
x: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]), value = {
y: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]), x: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),
}; y: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),
} };
return value; }
return value;
} }
function getValue(props, options, key) { function getValue(props, options, key) {
let value; var value;
if (props.hasOwnProperty(key)) { if (props.hasOwnProperty(key)) {
value = props[key]; value = props[key];
} else if (options && options[key].hasOwnProperty('default')) { }
value = options[key].default; else if (options && options[key].hasOwnProperty('default')) {
} value = options[key].default;
}
return value; return value;
} }
export { compute, parseType, parseVector2 }; export { compute, parseType, parseVector2 };
......
{"version":3,"file":"index.es.js","sources":["../src/index.js"],"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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AC,WAAW,CAAC,CAAC,CAAC,CAAC;GACjE,CAAC;EACF;CACD,OAAO,KAAK,CAAC;CACb;;AAED,SAAS,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE;CACtC,IAAI,KAAK,CAAC;CACV,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;EAC9B,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;EACnB,MAAM,IAAI,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;EAC7D,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;EAC7B;;CAED,OAAO,KAAK,CAAC;CACb;;;;"} {"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;4BACh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AAE;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 \ No newline at end of file
...@@ -5,95 +5,94 @@ Object.defineProperty(exports, '__esModule', { value: true }); ...@@ -5,95 +5,94 @@ Object.defineProperty(exports, '__esModule', { value: true });
/** /**
* Created by rockyl on 2020-01-27. * Created by rockyl on 2020-01-27.
*/ */
var genericRegexp = /(\w+)(<(\w+)>)?/;
const genericRegexp = /(\w+)(<(\w+)>)?/;
function compute(props, options) { function compute(props, options) {
let result = props || {}; var result = props || {};
for (let key in options) { var _loop_1 = function (key) {
let sourceValue = getValue(result, options, key); var sourceValue = getValue(result, options, key);
let value = sourceValue; var value = sourceValue;
if (options) { if (options) {
let option = options[key]; var option = options[key];
if (option && option.type) { if (option && option.type) {
let {type, generic} = parseType(option.type); var _a = parseType(option.type), type = _a.type, generic_1 = _a.generic;
switch (type) { switch (type) {
case 'vector2': case 'vector2':
value = parseVector2(sourceValue); value = parseVector2(sourceValue);
break; break;
case 'array': case 'array':
let seps = sourceValue.split(','); var seps = sourceValue.split(',');
seps = seps.map(sep => { seps = seps.map(function (sep) {
let item; var item;
if (generic) { if (generic_1) {
switch (generic) { switch (generic_1) {
case 'number': case 'number':
item = parseFloat(sep); item = parseFloat(sep);
break; break;
case 'boolean': case 'boolean':
item = sep === 'true'; item = sep === 'true';
break; break;
default: default:
item = sep; item = sep;
break; break;
} }
} else { }
item = sep; else {
} item = sep;
return item; }
}); return item;
value = seps; });
break; value = seps;
} break;
} }
} }
result[key] = value; }
} result[key] = value;
return result; };
for (var key in options) {
_loop_1(key);
}
return result;
} }
function parseType(typeStr) { function parseType(typeStr) {
let type = typeStr, generic; var type = typeStr, generic;
let regResult = typeStr.match(genericRegexp); var regResult = typeStr.match(genericRegexp);
if (regResult) { if (regResult) {
type = regResult[1]; type = regResult[1];
generic = regResult[3]; generic = regResult[3];
} }
return {
return { type: type, generic: generic,
type, generic, };
}
} }
function parseVector2(sourceValue) { function parseVector2(sourceValue) {
let value = sourceValue; var value = sourceValue;
if (!sourceValue) { if (!sourceValue) {
value = {x: undefined, y: undefined}; value = { x: undefined, y: undefined };
} }
if (typeof sourceValue === 'string') { if (typeof sourceValue === 'string') {
let arr = sourceValue.split(','); var arr = sourceValue.split(',');
value = { value = {
x: arr[0] === '' ? undefined : parseFloat(arr[0]), x: arr[0] === '' ? undefined : parseFloat(arr[0]),
y: arr[1] === '' ? undefined : parseFloat(arr[1]), y: arr[1] === '' ? undefined : parseFloat(arr[1]),
}; };
} else if (Array.isArray(sourceValue)) { }
value = { else if (Array.isArray(sourceValue)) {
x: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]), value = {
y: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]), x: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),
}; y: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),
} };
return value; }
return value;
} }
function getValue(props, options, key) { function getValue(props, options, key) {
let value; var value;
if (props.hasOwnProperty(key)) { if (props.hasOwnProperty(key)) {
value = props[key]; value = props[key];
} else if (options && options[key].hasOwnProperty('default')) { }
value = options[key].default; else if (options && options[key].hasOwnProperty('default')) {
} value = options[key].default;
}
return value; return value;
} }
exports.compute = compute; exports.compute = compute;
......
{"version":3,"file":"index.js","sources":["../src/index.js"],"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,MAAM,aAAa,GAAG,iBAAiB,CAAC;;AAExC,AAAO,SAAS,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE;CACvC,IAAI,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC;CACzB,KAAK,IAAI,GAAG,IAAI,OAAO,EAAE;EACxB,IAAI,WAAW,GAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;EACjD,IAAI,KAAK,GAAG,WAAW,CAAC;EACxB,IAAI,OAAO,EAAE;GACZ,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;GAC1B,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE;IAC1B,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,QAAQ,IAAI;KACX,KAAK,SAAS;MACb,KAAK,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;MAClC,MAAM;KACP,KAAK,OAAO;MACX,IAAI,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;MAClC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI;OACtB,IAAI,IAAI,CAAC;OACT,IAAI,OAAO,EAAE;QACZ,QAAQ,OAAO;SACd,KAAK,QAAQ;UACZ,IAAI,GAAG,U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AAC,CAAC,CAAC,CAAC;GACjD,CAAC;EACF,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;EACtC,KAAK,GAAG;GACP,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;GACjE,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;GACjE,CAAC;EACF;CACD,OAAO,KAAK,CAAC;CACb;;AAED,SAAS,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE;CACtC,IAAI,KAAK,CAAC;CACV,IAAI,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;EAC9B,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;EACnB,MAAM,IAAI,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;EAC7D,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;EAC7B;;CAED,OAAO,KAAK,CAAC;CACb;;;;;;"} {"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;wBACb,KAAK,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;wBAClC,MAAM;oBACP,KAAK,OAAO;wBACX,IAAI,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;wBAClC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,UAAA,GAAG;4BAClB,IAAI,IAAI,CAAC;4BACT,IAAI,SAAO,EAAE;gCACZ,QAAQ,SAAO;oCACd,KAAK,QAAQ;wCACZ,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;wCACvB,MAAM;oCACP,KAAK,SAAS;wCACb,IAAI,GAAG,GAAG,KAAK,MAAM,CAAC;wCACtB,MAAM;oCACP;wCACC,IAAI,GAAG,GAAG,CAAC;wCACX,MAAM;iCACP;6BACD;iCAAM;gCACN,IAAI,GAAG,GAAG,CAAC;6BACX;4BACD,OAAO,IAAI,CAAC;yBACZ,CAAC,CAAC;wBACH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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 \ No newline at end of file
...@@ -7,95 +7,94 @@ ...@@ -7,95 +7,94 @@
/** /**
* Created by rockyl on 2020-01-27. * Created by rockyl on 2020-01-27.
*/ */
var genericRegexp = /(\w+)(<(\w+)>)?/;
const genericRegexp = /(\w+)(<(\w+)>)?/;
function compute(props, options) { function compute(props, options) {
let result = props || {}; var result = props || {};
for (let key in options) { var _loop_1 = function (key) {
let sourceValue = getValue(result, options, key); var sourceValue = getValue(result, options, key);
let value = sourceValue; var value = sourceValue;
if (options) { if (options) {
let option = options[key]; var option = options[key];
if (option && option.type) { if (option && option.type) {
let {type, generic} = parseType(option.type); var _a = parseType(option.type), type = _a.type, generic_1 = _a.generic;
switch (type) { switch (type) {
case 'vector2': case 'vector2':
value = parseVector2(sourceValue); value = parseVector2(sourceValue);
break; break;
case 'array': case 'array':
let seps = sourceValue.split(','); var seps = sourceValue.split(',');
seps = seps.map(sep => { seps = seps.map(function (sep) {
let item; var item;
if (generic) { if (generic_1) {
switch (generic) { switch (generic_1) {
case 'number': case 'number':
item = parseFloat(sep); item = parseFloat(sep);
break; break;
case 'boolean': case 'boolean':
item = sep === 'true'; item = sep === 'true';
break; break;
default: default:
item = sep; item = sep;
break; break;
} }
} else { }
item = sep; else {
} item = sep;
return item; }
}); return item;
value = seps; });
break; value = seps;
} break;
} }
} }
result[key] = value; }
} result[key] = value;
return result; };
for (var key in options) {
_loop_1(key);
}
return result;
} }
function parseType(typeStr) { function parseType(typeStr) {
let type = typeStr, generic; var type = typeStr, generic;
let regResult = typeStr.match(genericRegexp); var regResult = typeStr.match(genericRegexp);
if (regResult) { if (regResult) {
type = regResult[1]; type = regResult[1];
generic = regResult[3]; generic = regResult[3];
} }
return {
return { type: type, generic: generic,
type, generic, };
}
} }
function parseVector2(sourceValue) { function parseVector2(sourceValue) {
let value = sourceValue; var value = sourceValue;
if (!sourceValue) { if (!sourceValue) {
value = {x: undefined, y: undefined}; value = { x: undefined, y: undefined };
} }
if (typeof sourceValue === 'string') { if (typeof sourceValue === 'string') {
let arr = sourceValue.split(','); var arr = sourceValue.split(',');
value = { value = {
x: arr[0] === '' ? undefined : parseFloat(arr[0]), x: arr[0] === '' ? undefined : parseFloat(arr[0]),
y: arr[1] === '' ? undefined : parseFloat(arr[1]), y: arr[1] === '' ? undefined : parseFloat(arr[1]),
}; };
} else if (Array.isArray(sourceValue)) { }
value = { else if (Array.isArray(sourceValue)) {
x: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]), value = {
y: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]), x: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),
}; y: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),
} };
return value; }
return value;
} }
function getValue(props, options, key) { function getValue(props, options, key) {
let value; var value;
if (props.hasOwnProperty(key)) { if (props.hasOwnProperty(key)) {
value = props[key]; value = props[key];
} else if (options && options[key].hasOwnProperty('default')) { }
value = options[key].default; else if (options && options[key].hasOwnProperty('default')) {
} value = options[key].default;
}
return value; return value;
} }
exports.compute = compute; exports.compute = compute;
......
This diff is collapsed.
...@@ -5,6 +5,12 @@ ...@@ -5,6 +5,12 @@
"module": "dist/index.es.js", "module": "dist/index.es.js",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"dev": "rollup -c -w",
"build": "rollup -c" "build": "rollup -c"
},
"devDependencies": {
"rollup-plugin-typescript": "^1.0.1",
"tslib": "^1.11.1",
"typescript": "^3.8.3"
} }
} }
...@@ -3,28 +3,39 @@ ...@@ -3,28 +3,39 @@
*/ */
const name = 'props-compute'; const name = 'props-compute';
const typescript = require('rollup-plugin-typescript');
export default { export default {
input: 'src/index.js', input: 'src/index.ts',
output: [ output: [
{ {
file: `dist/index.js`, file: `dist/index.js`,
format: 'cjs', format: 'cjs',
sourcemap: true, sourcemap: true,
globals: {
tslib: 'tslib'
},
}, },
{ {
file: `dist/index.es.js`, file: `dist/index.es.js`,
format: 'es', format: 'es',
sourcemap: true, sourcemap: true,
globals: {
tslib: 'tslib'
},
}, },
{ {
file: `dist/index.umd.js`, file: `dist/index.umd.js`,
format: 'umd', format: 'umd',
sourcemap: true, sourcemap: true,
name, name,
globals: {
tslib: 'tslib'
},
} }
], ],
plugins: [ plugins: [
typescript(),
] ],
external: ['tslib'],
}; };
...@@ -2,3 +2,44 @@ ...@@ -2,3 +2,44 @@
# yarn lockfile v1 # yarn lockfile v1
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==
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==
resolve@^1.10.0:
version "1.15.1"
resolved "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8"
integrity sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==
dependencies:
path-parse "^1.0.6"
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==
dependencies:
resolve "^1.10.0"
rollup-pluginutils "^2.5.0"
rollup-pluginutils@^2.5.0:
version "2.8.2"
resolved "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==
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==
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==
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