Christian Fraß commited on 2017-07-25 08:22:10
Zeige 2 geänderte Dateien mit 6503 Einfügungen und 4384 Löschungen.
... | ... |
@@ -211,7 +211,7 @@ var lib_log; |
211 | 211 |
for (var _i = 0; _i < arguments.length; _i++) { |
212 | 212 |
args[_i] = arguments[_i]; |
213 | 213 |
} |
214 |
- /*window.*/ console.log(args); |
|
214 |
+ /*window.*/ console.log.apply(console, args); |
|
215 | 215 |
} |
216 | 216 |
lib_log.log = log; |
217 | 217 |
/** |
... | ... |
@@ -222,7 +222,7 @@ var lib_log; |
222 | 222 |
for (var _i = 0; _i < arguments.length; _i++) { |
223 | 223 |
args[_i] = arguments[_i]; |
224 | 224 |
} |
225 |
- /*window.*/ console.info(args); |
|
225 |
+ /*window.*/ console.info.apply(console, args); |
|
226 | 226 |
} |
227 | 227 |
lib_log.info = info; |
228 | 228 |
/** |
... | ... |
@@ -233,7 +233,7 @@ var lib_log; |
233 | 233 |
for (var _i = 0; _i < arguments.length; _i++) { |
234 | 234 |
args[_i] = arguments[_i]; |
235 | 235 |
} |
236 |
- /*window.*/ console.warn(args); |
|
236 |
+ /*window.*/ console.warn.apply(console, args); |
|
237 | 237 |
} |
238 | 238 |
lib_log.warn = warn; |
239 | 239 |
/** |
... | ... |
@@ -244,7 +244,7 @@ var lib_log; |
244 | 244 |
for (var _i = 0; _i < arguments.length; _i++) { |
245 | 245 |
args[_i] = arguments[_i]; |
246 | 246 |
} |
247 |
- /*window.*/ console.error(args); |
|
247 |
+ /*window.*/ console.error.apply(console, args); |
|
248 | 248 |
} |
249 | 249 |
lib_log.error = error; |
250 | 250 |
})(lib_log || (lib_log = {})); |
... | ... |
@@ -534,7 +534,6 @@ var class_error = (function (_super) { |
534 | 534 |
}; |
535 | 535 |
return class_error; |
536 | 536 |
}(Error)); |
537 |
-///<reference path="../../base/build/logic-decl.d.ts"/> |
|
538 | 537 |
var lib_call; |
539 | 538 |
(function (lib_call) { |
540 | 539 |
/** |
... | ... |
@@ -560,104 +559,6 @@ var lib_call; |
560 | 559 |
} |
561 | 560 |
lib_call.schedule = schedule; |
562 | 561 |
})(lib_call || (lib_call = {})); |
563 |
-///<reference path="../../base/build/logic-decl.d.ts"/> |
|
564 |
-var lib_call; |
|
565 |
-(function (lib_call) { |
|
566 |
- /** |
|
567 |
- * @author frac |
|
568 |
- * @todo could possibly be replaced by Promise-system |
|
569 |
- */ |
|
570 |
- class class_wait { |
|
571 |
- } |
|
572 |
- lib_call.class_wait = class_wait; |
|
573 |
- /** |
|
574 |
- * @author frac |
|
575 |
- * @todo could possibly be replaced by Promise-system |
|
576 |
- */ |
|
577 |
- class class_wait_sequential extends class_wait { |
|
578 |
- /** |
|
579 |
- * @author frac |
|
580 |
- */ |
|
581 |
- constructor(dependencies, action = function () { lib_log.log("all done"); }) { |
|
582 |
- super(); |
|
583 |
- this.dependencies = dependencies; |
|
584 |
- this.action = action; |
|
585 |
- } |
|
586 |
- /** |
|
587 |
- * @author frac |
|
588 |
- */ |
|
589 |
- run_(dependencies) { |
|
590 |
- if (dependencies.length > 0) { |
|
591 |
- dependencies[0](() => this.run_(dependencies.slice(1))); |
|
592 |
- } |
|
593 |
- else { |
|
594 |
- this.action(); |
|
595 |
- } |
|
596 |
- } |
|
597 |
- /** |
|
598 |
- * @author frac |
|
599 |
- */ |
|
600 |
- run() { |
|
601 |
- this.run_(this.dependencies); |
|
602 |
- } |
|
603 |
- } |
|
604 |
- lib_call.class_wait_sequential = class_wait_sequential; |
|
605 |
- /** |
|
606 |
- * @author frac |
|
607 |
- * @todo could possibly be replaced by Promise-system |
|
608 |
- */ |
|
609 |
- class class_wait_parallel extends class_wait { |
|
610 |
- /** |
|
611 |
- * @author frac |
|
612 |
- */ |
|
613 |
- constructor(dependencies, action = function () { lib_log.log("all done"); }) { |
|
614 |
- super(); |
|
615 |
- this.index = 0; |
|
616 |
- this.dependencies = {}; |
|
617 |
- this.action = action; |
|
618 |
- dependencies.forEach(dependency => this.add_dependency(dependency)); |
|
619 |
- } |
|
620 |
- /** |
|
621 |
- * @author frac |
|
622 |
- */ |
|
623 |
- add_dependency(dependency) { |
|
624 |
- this.dependencies["dependency_" + this.index.toString()] = dependency; |
|
625 |
- this.index += 1; |
|
626 |
- } |
|
627 |
- /** |
|
628 |
- * @author frac |
|
629 |
- */ |
|
630 |
- remove_dependency(id) { |
|
631 |
- if (!(id in this.dependencies)) { |
|
632 |
- throw (new Error("dependency does not exist")); |
|
633 |
- } |
|
634 |
- else { |
|
635 |
- delete this.dependencies[id]; |
|
636 |
- if (Object.keys(this.dependencies).length == 0) { |
|
637 |
- this.action(); |
|
638 |
- } |
|
639 |
- } |
|
640 |
- } |
|
641 |
- /** |
|
642 |
- * @author frac |
|
643 |
- */ |
|
644 |
- run() { |
|
645 |
- let that = this; |
|
646 |
- if (Object.keys(this.dependencies).length == 0) { |
|
647 |
- this.action(); |
|
648 |
- } |
|
649 |
- else { |
|
650 |
- Object.keys(this.dependencies).forEach(function (id) { |
|
651 |
- let dependency = that.dependencies[id]; |
|
652 |
- dependency(function () { |
|
653 |
- that.remove_dependency(id); |
|
654 |
- }); |
|
655 |
- }); |
|
656 |
- } |
|
657 |
- } |
|
658 |
- } |
|
659 |
- lib_call.class_wait_parallel = class_wait_parallel; |
|
660 |
-})(lib_call || (lib_call = {})); |
|
661 | 562 |
var lib_call; |
662 | 563 |
(function (lib_call) { |
663 | 564 |
/** |
... | ... |
@@ -789,15 +690,6 @@ var lib_call; |
789 | 690 |
} |
790 | 691 |
} |
791 | 692 |
lib_call.curryfy = curryfy; |
792 |
- /** |
|
793 |
- * @desc adapter for old syntax |
|
794 |
- * @author fenris |
|
795 |
- */ |
|
796 |
- function wait(dependencies, action = function () { lib_log.log("all done"); }, parallel = true) { |
|
797 |
- let wait = (parallel ? (new lib_call.class_wait_parallel(dependencies, action)) : (new lib_call.class_wait_sequential(dependencies, action))); |
|
798 |
- wait.run(); |
|
799 |
- } |
|
800 |
- lib_call.wait = wait; |
|
801 | 693 |
/** |
802 | 694 |
* returns a function which goes through a process step by step |
803 | 695 |
* a process is an array of objects like { func : {function}, state : {string}} |
... | ... |
@@ -1015,6 +907,135 @@ var lib_call; |
1015 | 907 |
}))); |
1016 | 908 |
} |
1017 | 909 |
lib_call.executor_reduce = executor_reduce; |
910 |
+ /** |
|
911 |
+ * @desc useful for e.g. asynchronous singletons |
|
912 |
+ * @author fenris |
|
913 |
+ */ |
|
914 |
+ class class_executor_initializer { |
|
915 |
+ /** |
|
916 |
+ * @author fenris |
|
917 |
+ */ |
|
918 |
+ constructor(fetcher) { |
|
919 |
+ /** |
|
920 |
+ * @author fenris |
|
921 |
+ * 0 : initial |
|
922 |
+ * 1 : waiting |
|
923 |
+ * 2 : done, successful |
|
924 |
+ * 3 : done, failed |
|
925 |
+ */ |
|
926 |
+ this.state = 0; |
|
927 |
+ this.fetcher = fetcher; |
|
928 |
+ this.state = 0; |
|
929 |
+ this.queue = []; |
|
930 |
+ this.output = null; |
|
931 |
+ this.error = null; |
|
932 |
+ } |
|
933 |
+ /** |
|
934 |
+ * @author fenris |
|
935 |
+ */ |
|
936 |
+ actuate() { |
|
937 |
+ switch (this.state) { |
|
938 |
+ case 2: { |
|
939 |
+ this.queue.forEach(entry => entry.resolve(this.output)); |
|
940 |
+ break; |
|
941 |
+ } |
|
942 |
+ case 3: { |
|
943 |
+ this.queue.forEach(entry => entry.reject(this.error)); |
|
944 |
+ break; |
|
945 |
+ } |
|
946 |
+ default: { |
|
947 |
+ throw (new Error(`unhandled state ${this.state}`)); |
|
948 |
+ break; |
|
949 |
+ } |
|
950 |
+ } |
|
951 |
+ } |
|
952 |
+ /** |
|
953 |
+ * @author fenris |
|
954 |
+ */ |
|
955 |
+ reset() { |
|
956 |
+ this.state = 0; |
|
957 |
+ this.queue = []; |
|
958 |
+ } |
|
959 |
+ /** |
|
960 |
+ * @author fenris |
|
961 |
+ */ |
|
962 |
+ get() { |
|
963 |
+ switch (this.state) { |
|
964 |
+ case 0: { |
|
965 |
+ this.state = 1; |
|
966 |
+ return ((resolve, reject) => { |
|
967 |
+ this.queue.push({ "resolve": resolve, "reject": reject }); |
|
968 |
+ this.fetcher(output => { |
|
969 |
+ this.state = 2; |
|
970 |
+ this.output = output; |
|
971 |
+ this.actuate(); |
|
972 |
+ }, error => { |
|
973 |
+ this.state = 3; |
|
974 |
+ this.error = error; |
|
975 |
+ this.actuate(); |
|
976 |
+ }); |
|
977 |
+ }); |
|
978 |
+ break; |
|
979 |
+ } |
|
980 |
+ case 1: { |
|
981 |
+ return ((resolve, reject) => this.queue.push({ "resolve": resolve, "reject": reject })); |
|
982 |
+ break; |
|
983 |
+ } |
|
984 |
+ case 2: { |
|
985 |
+ return executor_resolve(this.output); |
|
986 |
+ break; |
|
987 |
+ } |
|
988 |
+ case 3: { |
|
989 |
+ return executor_reject(this.error); |
|
990 |
+ break; |
|
991 |
+ } |
|
992 |
+ default: { |
|
993 |
+ throw (new Error(`unhandled state ${this.state}`)); |
|
994 |
+ break; |
|
995 |
+ } |
|
996 |
+ } |
|
997 |
+ } |
|
998 |
+ /** |
|
999 |
+ * @author fenris |
|
1000 |
+ */ |
|
1001 |
+ get_sync() { |
|
1002 |
+ switch (this.state) { |
|
1003 |
+ case 2: { |
|
1004 |
+ return this.output; |
|
1005 |
+ break; |
|
1006 |
+ } |
|
1007 |
+ case 3: { |
|
1008 |
+ throw this.error; |
|
1009 |
+ break; |
|
1010 |
+ } |
|
1011 |
+ default: { |
|
1012 |
+ throw (new Error(`unhandled state ${this.state}`)); |
|
1013 |
+ break; |
|
1014 |
+ } |
|
1015 |
+ } |
|
1016 |
+ } |
|
1017 |
+ /** |
|
1018 |
+ * @author fenris |
|
1019 |
+ */ |
|
1020 |
+ set_sync(output) { |
|
1021 |
+ switch (this.state) { |
|
1022 |
+ case 2: { |
|
1023 |
+ this.output = output; |
|
1024 |
+ break; |
|
1025 |
+ } |
|
1026 |
+ case 3: { |
|
1027 |
+ this.state = 2; |
|
1028 |
+ this.output = output; |
|
1029 |
+ break; |
|
1030 |
+ } |
|
1031 |
+ default: { |
|
1032 |
+ throw (new Error(`unhandled state ${this.state}`)); |
|
1033 |
+ break; |
|
1034 |
+ } |
|
1035 |
+ } |
|
1036 |
+ } |
|
1037 |
+ } |
|
1038 |
+ lib_call.class_executor_initializer = class_executor_initializer; |
|
1018 | 1039 |
})(lib_call || (lib_call = {})); |
1019 | 1040 |
var lib_call; |
1020 | 1041 |
(function (lib_call) { |
... | ... |
@@ -1275,92 +1296,19 @@ var lib_call; |
1275 | 1296 |
* @author fenris |
1276 | 1297 |
*/ |
1277 | 1298 |
constructor(fetcher) { |
1278 |
- /** |
|
1279 |
- * @author fenris |
|
1280 |
- * 0 : initial |
|
1281 |
- * 1 : waiting |
|
1282 |
- * 2 : done, successful |
|
1283 |
- * 3 : done, failed |
|
1284 |
- */ |
|
1285 |
- this.state = 0; |
|
1286 |
- /** |
|
1287 |
- * @author fenris |
|
1288 |
- */ |
|
1289 |
- this.output = null; |
|
1290 |
- /** |
|
1291 |
- * @author fenris |
|
1292 |
- */ |
|
1293 |
- this.error = null; |
|
1294 |
- this.fetcher = fetcher; |
|
1295 |
- this.state = 0; |
|
1296 |
- this.queue = []; |
|
1297 |
- this.output = null; |
|
1298 |
- this.error = null; |
|
1299 |
- } |
|
1300 |
- /** |
|
1301 |
- * @author fenris |
|
1302 |
- */ |
|
1303 |
- actuate() { |
|
1304 |
- switch (this.state) { |
|
1305 |
- case 2: { |
|
1306 |
- this.queue.forEach(entry => entry.resolve(this.output)); |
|
1307 |
- break; |
|
1308 |
- } |
|
1309 |
- case 3: { |
|
1310 |
- this.queue.forEach(entry => entry.reject(this.error)); |
|
1311 |
- break; |
|
1312 |
- } |
|
1313 |
- default: { |
|
1314 |
- throw (new Error(`unhandled state ${this.state}`)); |
|
1315 |
- break; |
|
1316 |
- } |
|
1317 |
- } |
|
1299 |
+ this.core = new lib_call.class_executor_initializer(fetcher(null)); |
|
1318 | 1300 |
} |
1319 | 1301 |
/** |
1320 | 1302 |
* @author fenris |
1321 | 1303 |
*/ |
1322 | 1304 |
reset() { |
1323 |
- this.state = 0; |
|
1324 |
- this.queue = []; |
|
1305 |
+ this.core.reset(); |
|
1325 | 1306 |
} |
1326 | 1307 |
/** |
1327 | 1308 |
* @author fenris |
1328 | 1309 |
*/ |
1329 | 1310 |
get(input) { |
1330 |
- switch (this.state) { |
|
1331 |
- case 0: { |
|
1332 |
- this.state = 1; |
|
1333 |
- return (_ => (resolve, reject) => { |
|
1334 |
- this.queue.push({ "resolve": resolve, "reject": reject }); |
|
1335 |
- this.fetcher(input)(output => { |
|
1336 |
- this.state = 2; |
|
1337 |
- this.output = output; |
|
1338 |
- this.actuate(); |
|
1339 |
- }, error => { |
|
1340 |
- this.state = 3; |
|
1341 |
- this.error = error; |
|
1342 |
- this.actuate(); |
|
1343 |
- }); |
|
1344 |
- }); |
|
1345 |
- break; |
|
1346 |
- } |
|
1347 |
- case 1: { |
|
1348 |
- return (_ => (resolve, reject) => this.queue.push({ "resolve": resolve, "reject": reject })); |
|
1349 |
- break; |
|
1350 |
- } |
|
1351 |
- case 2: { |
|
1352 |
- return knot_resolver(this.output); |
|
1353 |
- break; |
|
1354 |
- } |
|
1355 |
- case 3: { |
|
1356 |
- return knot_rejector(this.error); |
|
1357 |
- break; |
|
1358 |
- } |
|
1359 |
- default: { |
|
1360 |
- throw (new Error(`unhandled state ${this.state}`)); |
|
1361 |
- break; |
|
1362 |
- } |
|
1363 |
- } |
|
1311 |
+ return (_ => this.core.get()); |
|
1364 | 1312 |
} |
1365 | 1313 |
} |
1366 | 1314 |
lib_call.class_knot_initializer = class_knot_initializer; |
... | ... |
@@ -1391,3741 +1339,5587 @@ var lib_call; |
1391 | 1339 |
/** |
1392 | 1340 |
* @author fenris |
1393 | 1341 |
*/ |
1394 |
- function promise_all(promises) { |
|
1395 |
- return Promise.all(promises); |
|
1342 |
+ function promise_then_close(promise, resolver, rejector) { |
|
1343 |
+ return (promise.then(resolver, rejector)); |
|
1396 | 1344 |
} |
1397 |
- lib_call.promise_all = promise_all; |
|
1398 |
-})(lib_call || (lib_call = {})); |
|
1399 |
- |
|
1400 |
-(function (exports) { |
|
1401 |
- |
|
1345 |
+ lib_call.promise_then_close = promise_then_close; |
|
1402 | 1346 |
/** |
1403 | 1347 |
* @author fenris |
1404 | 1348 |
*/ |
1405 |
- function promise_chain( |
|
1406 |
- microprograms |
|
1407 |
- ) { |
|
1408 |
- return ( |
|
1409 |
- input => microprograms.reduce( |
|
1410 |
- (x, y) => x.then(y), |
|
1411 |
- Promise.resolve(input) |
|
1412 |
- ) |
|
1413 |
- ); |
|
1349 |
+ function promise_then_append(promise, resolver, rejector = null) { |
|
1350 |
+ if (rejector == null) { |
|
1351 |
+ rejector = (reason) => promise_reject(reason); |
|
1414 | 1352 |
} |
1415 |
- exports.promise_chain = promise_chain; |
|
1416 |
- |
|
1417 |
- |
|
1353 |
+ return (promise.then(resolver, rejector)); |
|
1354 |
+ } |
|
1355 |
+ lib_call.promise_then_append = promise_then_append; |
|
1418 | 1356 |
/** |
1419 | 1357 |
* @author fenris |
1420 | 1358 |
*/ |
1421 |
- function promise_wrap( |
|
1422 |
- promise, |
|
1423 |
- transformator_result, |
|
1424 |
- transformator_reason = lib_call.id |
|
1425 |
- ) { |
|
1426 |
- return ( |
|
1427 |
- new Promise( |
|
1428 |
- (resolve, reject) => { |
|
1429 |
- promise.then( |
|
1430 |
- result => resolve(transformator_result(result)), |
|
1431 |
- reason => reject(transformator_reason(reason)) |
|
1432 |
- ) |
|
1359 |
+ function promise_all(promises) { |
|
1360 |
+ return Promise.all(promises); |
|
1433 | 1361 |
} |
1434 |
- ) |
|
1435 |
- ); |
|
1362 |
+ lib_call.promise_all = promise_all; |
|
1363 |
+ /** |
|
1364 |
+ * @author fenris |
|
1365 |
+ */ |
|
1366 |
+ function promise_chain(promises, start = undefined) { |
|
1367 |
+ return (promises.reduce((chain, promise) => promise_then_append(chain, promise), promise_resolve(start))); |
|
1436 | 1368 |
} |
1437 |
- exports.promise_wrap = promise_wrap; |
|
1438 |
- |
|
1439 |
- |
|
1369 |
+ lib_call.promise_chain = promise_chain; |
|
1440 | 1370 |
/** |
1441 | 1371 |
* @author fenris |
1442 | 1372 |
*/ |
1443 |
- function promise_log(state) { |
|
1444 |
- return ( |
|
1445 |
- new Promise( |
|
1446 |
- (resolve, reject) => { |
|
1447 |
- lib_log.info(state); |
|
1448 |
- resolve(state); |
|
1373 |
+ function promise_wrap(promise, transformator_result, transformator_reason = lib_call.id) { |
|
1374 |
+ return (promise_make((resolve, reject) => { |
|
1375 |
+ promise_then_close(promise, result => resolve(transformator_result(result)), reason => reject(transformator_reason(reason))); |
|
1376 |
+ })); |
|
1449 | 1377 |
} |
1450 |
- ) |
|
1451 |
- ); |
|
1378 |
+ lib_call.promise_wrap = promise_wrap; |
|
1379 |
+ /** |
|
1380 |
+ * @author fenris |
|
1381 |
+ */ |
|
1382 |
+ function promise_show(label) { |
|
1383 |
+ return (result => promise_make((resolve, reject) => { |
|
1384 |
+ lib_log.info(label + ": " + instance_show(result)); |
|
1385 |
+ resolve(result); |
|
1386 |
+ })); |
|
1452 | 1387 |
} |
1453 |
- exports.promise_log = promise_log; |
|
1454 |
- |
|
1455 |
- |
|
1388 |
+ lib_call.promise_show = promise_show; |
|
1456 | 1389 |
/** |
1457 | 1390 |
* @author fenris |
1458 | 1391 |
*/ |
1459 |
- function promise_attach( |
|
1460 |
- state, |
|
1461 |
- promise, |
|
1462 |
- name |
|
1463 |
- ) { |
|
1464 |
- return ( |
|
1465 |
- promise_wrap( |
|
1466 |
- promise, |
|
1467 |
- result => { |
|
1392 |
+ function promise_log(result) { |
|
1393 |
+ return promise_show("log"); |
|
1394 |
+ } |
|
1395 |
+ lib_call.promise_log = promise_log; |
|
1396 |
+ /** |
|
1397 |
+ * @author fenris |
|
1398 |
+ */ |
|
1399 |
+ function promise_attach(state, promise, name) { |
|
1400 |
+ return (promise_wrap(promise, result => { |
|
1468 | 1401 |
state[name] = result; |
1469 | 1402 |
return state; |
1403 |
+ })); |
|
1470 | 1404 |
} |
1471 |
- ) |
|
1472 |
- ); |
|
1405 |
+ lib_call.promise_attach = promise_attach; |
|
1406 |
+})(lib_call || (lib_call = {})); |
|
1407 |
+/** |
|
1408 |
+ * @author fenris |
|
1409 |
+ */ |
|
1410 |
+var lib_trait; |
|
1411 |
+(function (lib_trait) { |
|
1412 |
+ /** |
|
1413 |
+ * @author fenris |
|
1414 |
+ */ |
|
1415 |
+ lib_trait._verbosity = 1; |
|
1416 |
+ /** |
|
1417 |
+ * @author fenris |
|
1418 |
+ */ |
|
1419 |
+ function type_show(type) { |
|
1420 |
+ return JSON.stringify(type); |
|
1473 | 1421 |
} |
1474 |
- exports.promise_attach = promise_attach; |
|
1475 |
- |
|
1476 |
-}) (lib_call || (lib_call == {})); |
|
1477 |
- |
|
1478 |
-///<reference path="../../base/build/logic-decl.d.ts"/> |
|
1479 |
-var lib_object; |
|
1480 |
-(function (lib_object) { |
|
1481 | 1422 |
/** |
1482 | 1423 |
* @author fenris |
1483 | 1424 |
*/ |
1484 |
- function fetch(object, fieldname, fallback, escalation) { |
|
1485 |
- if (fallback === void 0) { fallback = null; } |
|
1486 |
- if (escalation === void 0) { escalation = 1; } |
|
1487 |
- if ((fieldname in object) && (object[fieldname] !== undefined)) { |
|
1488 |
- return object[fieldname]; |
|
1425 |
+ function type_resolve(raw, bindings) { |
|
1426 |
+ switch (raw.kind) { |
|
1427 |
+ case "variable": { |
|
1428 |
+ var variable_name = raw.parameters["name"]; |
|
1429 |
+ if (variable_name in bindings) { |
|
1430 |
+ return bindings[variable_name]; |
|
1489 | 1431 |
} |
1490 | 1432 |
else { |
1491 |
- switch (escalation) { |
|
1492 |
- case 0: { |
|
1493 |
- return fallback; |
|
1494 |
- break; |
|
1433 |
+ var message = "binding missing for variable '" + variable_name + "'"; |
|
1434 |
+ throw (new Error(message)); |
|
1495 | 1435 |
} |
1496 |
- case 1: { |
|
1497 |
- var message = ("field '" + fieldname + "' not in structure"); |
|
1498 |
- message += ("; using fallback value '" + String(fallback) + "'"); |
|
1499 |
- // console.warn(message); |
|
1500 |
- return fallback; |
|
1501 | 1436 |
break; |
1502 | 1437 |
} |
1503 |
- case 2: { |
|
1504 |
- var message = ("field '" + fieldname + "' not in structure"); |
|
1505 |
- throw (new Error(message)); |
|
1438 |
+ case "object": { |
|
1439 |
+ return { |
|
1440 |
+ "kind": "object", |
|
1441 |
+ "parameters": { |
|
1442 |
+ "fields": raw.parameters["fields"].map(function (field) { |
|
1443 |
+ return { |
|
1444 |
+ "name": field.name, |
|
1445 |
+ "type": type_resolve(field.type, bindings) |
|
1446 |
+ }; |
|
1447 |
+ }) |
|
1448 |
+ } |
|
1449 |
+ }; |
|
1506 | 1450 |
break; |
1507 | 1451 |
} |
1508 | 1452 |
default: { |
1509 |
- throw (new Error("invalid escalation level " + escalation)); |
|
1453 |
+ return raw; |
|
1510 | 1454 |
break; |
1511 | 1455 |
} |
1512 | 1456 |
} |
1513 | 1457 |
} |
1514 |
- } |
|
1515 |
- lib_object.fetch = fetch; |
|
1516 | 1458 |
/** |
1459 |
+ * @desc holds all defined traits |
|
1517 | 1460 |
* @author fenris |
1518 | 1461 |
*/ |
1519 |
- function map(object_from, transformator) { |
|
1520 |
- var object_to = {}; |
|
1521 |
- Object.keys(object_from).forEach(function (key) { return (object_to[key] = transformator(object_from[key], key)); }); |
|
1522 |
- return object_to; |
|
1523 |
- } |
|
1524 |
- lib_object.map = map; |
|
1462 |
+ var _pool = {}; |
|
1525 | 1463 |
/** |
1526 | 1464 |
* @author fenris |
1527 | 1465 |
*/ |
1528 |
- function filter(object_from, predicate) { |
|
1529 |
- var object_to = {}; |
|
1530 |
- Object.keys(object_from).forEach(function (key) { |
|
1531 |
- var value = object_from[key]; |
|
1532 |
- if (predicate(value, key)) { |
|
1533 |
- object_to[key] = value; |
|
1534 |
- } |
|
1535 |
- }); |
|
1536 |
- return object_to; |
|
1537 |
- } |
|
1538 |
- lib_object.filter = filter; |
|
1466 |
+ var _typechecker; |
|
1539 | 1467 |
/** |
1540 | 1468 |
* @author fenris |
1541 | 1469 |
*/ |
1542 |
- function from_array(array) { |
|
1543 |
- var object = {}; |
|
1544 |
- array.forEach(function (entry) { return (object[entry.key] = entry.value); }); |
|
1545 |
- return object; |
|
1470 |
+ function set_typechecker(typechecker) { |
|
1471 |
+ _typechecker = typechecker; |
|
1546 | 1472 |
} |
1547 |
- lib_object.from_array = from_array; |
|
1473 |
+ lib_trait.set_typechecker = set_typechecker; |
|
1548 | 1474 |
/** |
1549 | 1475 |
* @author fenris |
1550 | 1476 |
*/ |
1551 |
- function to_array(object) { |
|
1552 |
- var array = []; |
|
1553 |
- Object.keys(object).forEach(function (key) { return array.push({ "key": key, "value": object[key] }); }); |
|
1554 |
- return array; |
|
1477 |
+ function domain_instance(domain, value) { |
|
1478 |
+ return { "domain": domain, "value": value }; |
|
1555 | 1479 |
} |
1556 |
- lib_object.to_array = to_array; |
|
1480 |
+ lib_trait.domain_instance = domain_instance; |
|
1557 | 1481 |
/** |
1482 |
+ * @desc adds a trait |
|
1558 | 1483 |
* @author fenris |
1559 | 1484 |
*/ |
1560 |
- function keys(object) { |
|
1561 |
- return Object.keys(object); |
|
1485 |
+ function describe(trait_id, variable_conditions, facet_signatures) { |
|
1486 |
+ if (trait_id in _pool) { |
|
1487 |
+ var error = new Error("trait '" + trait_id + "' already registered"); |
|
1488 |
+ throw error; |
|
1562 | 1489 |
} |
1563 |
- lib_object.keys = keys; |
|
1564 |
- /** |
|
1565 |
- * @author fenris |
|
1566 |
- */ |
|
1567 |
- function values(object) { |
|
1568 |
- return to_array(object).map(function (entry) { return entry.value; }); |
|
1490 |
+ else { |
|
1491 |
+ var trait_1 = { |
|
1492 |
+ "variables": {}, |
|
1493 |
+ "facets": {} |
|
1494 |
+ }; |
|
1495 |
+ Object.keys(variable_conditions).forEach(function (variable_name) { |
|
1496 |
+ var variable = { |
|
1497 |
+ "conditions": variable_conditions[variable_name], |
|
1498 |
+ "bindings": {} |
|
1499 |
+ }; |
|
1500 |
+ trait_1.variables[variable_name] = variable; |
|
1501 |
+ }); |
|
1502 |
+ Object.keys(facet_signatures).forEach(function (facet_name) { |
|
1503 |
+ var facet = { |
|
1504 |
+ "signature": facet_signatures[facet_name], |
|
1505 |
+ "handlers": {} |
|
1506 |
+ }; |
|
1507 |
+ trait_1.facets[facet_name] = facet; |
|
1508 |
+ }); |
|
1509 |
+ _pool[trait_id] = trait_1; |
|
1569 | 1510 |
} |
1570 |
- lib_object.values = values; |
|
1511 |
+ } |
|
1512 |
+ lib_trait.describe = describe; |
|
1571 | 1513 |
/** |
1514 |
+ * @desc adhoc binding |
|
1572 | 1515 |
* @author fenris |
1573 | 1516 |
*/ |
1574 |
- function path_read(object, path, fallback, escalation) { |
|
1575 |
- if (fallback === void 0) { fallback = null; } |
|
1576 |
- if (escalation === void 0) { escalation = 1; } |
|
1577 |
- var steps = ((path.length == 0) ? [] : path.split(".")); |
|
1578 |
- if (steps.length == 0) { |
|
1579 |
- throw (new Error("empty path")); |
|
1517 |
+ function assign(domain_kind, trait_id, bindings, handlers, strict_binding, strict_handling) { |
|
1518 |
+ if (strict_binding === void 0) { strict_binding = true; } |
|
1519 |
+ if (strict_handling === void 0) { strict_handling = true; } |
|
1520 |
+ if (trait_id in _pool) { |
|
1521 |
+ var trait_2 = _pool[trait_id]; |
|
1522 |
+ // assignments |
|
1523 |
+ { |
|
1524 |
+ // variables |
|
1525 |
+ { |
|
1526 |
+ Object.keys(bindings).forEach(function (variable_name) { |
|
1527 |
+ if (variable_name in trait_2.variables) { |
|
1528 |
+ var variable = trait_2.variables[variable_name]; |
|
1529 |
+ if (!(domain_kind in variable.bindings)) { |
|
1530 |
+ variable.bindings[domain_kind] = bindings[variable_name]; |
|
1580 | 1531 |
} |
1581 | 1532 |
else { |
1582 |
- var position_1 = object; |
|
1583 |
- var reachable = steps.slice(0, steps.length - 1).every(function (step) { |
|
1584 |
- position_1 = object_fetch(position_1, step, null, 0); |
|
1585 |
- return (position_1 != null); |
|
1586 |
- }); |
|
1587 |
- if (reachable) { |
|
1588 |
- return object_fetch(position_1, steps[steps.length - 1], fallback, escalation); |
|
1533 |
+ var message = "variable '" + variable_name + "' already bound for domain '" + domain_kind + "' in trait '" + trait_id + "'"; |
|
1534 |
+ throw (new Error(message)); |
|
1589 | 1535 |
} |
1590 |
- else { |
|
1591 |
- return object_fetch({}, "_dummy_", fallback, escalation); |
|
1592 | 1536 |
} |
1537 |
+ else { |
|
1538 |
+ var message = "no variable '" + variable_name + "' to bind in trait '" + trait_id + "'"; |
|
1539 |
+ console.warn(message); |
|
1540 |
+ // throw (new Error(message)); |
|
1593 | 1541 |
} |
1542 |
+ }); |
|
1594 | 1543 |
} |
1595 |
- lib_object.path_read = path_read; |
|
1596 |
- /** |
|
1597 |
- * @author fenris |
|
1598 |
- */ |
|
1599 |
- function path_write(object, path, value, construct) { |
|
1600 |
- if (construct === void 0) { construct = true; } |
|
1601 |
- var steps = ((path.length == 0) ? [] : path.split(".")); |
|
1602 |
- if (steps.length == 0) { |
|
1603 |
- throw (new Error("empty path")); |
|
1544 |
+ // facets |
|
1545 |
+ { |
|
1546 |
+ Object.keys(handlers).forEach(function (facet_name) { |
|
1547 |
+ if (facet_name in trait_2.facets) { |
|
1548 |
+ var facet = trait_2.facets[facet_name]; |
|
1549 |
+ if (!(domain_kind in facet.handlers)) { |
|
1550 |
+ facet.handlers[domain_kind] = handlers[facet_name]; |
|
1604 | 1551 |
} |
1605 | 1552 |
else { |
1606 |
- var position_2 = object; |
|
1607 |
- var reachable = steps.slice(0, steps.length - 1).every(function (step) { |
|
1608 |
- var position_ = object_fetch(position_2, step, null, 0); |
|
1609 |
- if (position_ == null) { |
|
1610 |
- if (construct) { |
|
1611 |
- position_2[step] = {}; |
|
1612 |
- position_2 = position_2[step]; |
|
1613 |
- return true; |
|
1553 |
+ var message = "facet '" + facet_name + "' already implemented for domain '" + domain_kind + "' in trait '" + trait_id + "'"; |
|
1554 |
+ throw (new Error(message)); |
|
1555 |
+ } |
|
1614 | 1556 |
} |
1615 | 1557 |
else { |
1616 |
- return false; |
|
1558 |
+ var message = "no facet '" + facet_name + "' to implement in trait '" + trait_id + "'"; |
|
1559 |
+ console.warn(message); |
|
1560 |
+ // throw (new Error(message)); |
|
1617 | 1561 |
} |
1562 |
+ }); |
|
1618 | 1563 |
} |
1619 |
- else { |
|
1620 |
- position_2 = position_; |
|
1621 |
- return true; |
|
1622 | 1564 |
} |
1565 |
+ // checks |
|
1566 |
+ { |
|
1567 |
+ var messages_1 = []; |
|
1568 |
+ if (strict_binding) { |
|
1569 |
+ // variables |
|
1570 |
+ { |
|
1571 |
+ var variable_names_given_1 = Object.keys(bindings); |
|
1572 |
+ var variable_names_present = Object.keys(trait_2.variables); |
|
1573 |
+ var variable_names_missing = variable_names_present.filter(function (variable_name) { return !variable_names_given_1.some(function (variable_name_) { return (variable_name == variable_name_); }); }); |
|
1574 |
+ variable_names_missing.forEach(function (variable_name) { |
|
1575 |
+ var message = "binding missing for variable '" + variable_name + "'"; |
|
1576 |
+ messages_1.push(message); |
|
1623 | 1577 |
}); |
1624 |
- if (reachable) { |
|
1625 |
- position_2[steps[steps.length - 1]] = value; |
|
1626 | 1578 |
} |
1627 |
- else { |
|
1628 |
- throw (new Error("path " + path + " does not exist and may not be constructed")); |
|
1629 | 1579 |
} |
1580 |
+ if (strict_handling) { |
|
1581 |
+ // facets |
|
1582 |
+ { |
|
1583 |
+ var facet_names_given_1 = Object.keys(handlers); |
|
1584 |
+ var facet_names_present = Object.keys(trait_2.facets); |
|
1585 |
+ var facet_names_missing = facet_names_present.filter(function (facet_name) { return !facet_names_given_1.some(function (facet_name_) { return (facet_name == facet_name_); }); }); |
|
1586 |
+ facet_names_missing.forEach(function (facet_name) { |
|
1587 |
+ var message = "implementations missing for the facet '" + facet_name + "'"; |
|
1588 |
+ messages_1.push(message); |
|
1589 |
+ }); |
|
1630 | 1590 |
} |
1591 |
+ if (messages_1.length > 0) { |
|
1592 |
+ var message = "assignment of domain '" + domain_kind + "' to trait '" + trait_id + "' incomplete: " + messages_1.join(", "); |
|
1593 |
+ throw (new Error(message)); |
|
1631 | 1594 |
} |
1632 |
- lib_object.path_write = path_write; |
|
1633 |
- /** |
|
1634 |
- * @author fenris |
|
1635 |
- */ |
|
1636 |
- function matches(object, pattern, collate) { |
|
1637 |
- if (collate === void 0) { collate = instance_collate; } |
|
1638 |
- return Object.keys(pattern).every(function (key) { return collate(pattern[key], object[key]); }); |
|
1639 | 1595 |
} |
1640 |
- lib_object.matches = matches; |
|
1596 |
+ } |
|
1597 |
+ } |
|
1598 |
+ else { |
|
1599 |
+ var message = "no trait '" + trait_id + "'"; |
|
1600 |
+ throw (new Error(message)); |
|
1601 |
+ } |
|
1602 |
+ } |
|
1603 |
+ lib_trait.assign = assign; |
|
1641 | 1604 |
/** |
1642 | 1605 |
* @author fenris |
1643 | 1606 |
*/ |
1644 |
- function flatten(value) { |
|
1645 |
- var integrate = function (result, key_, value_) { |
|
1646 |
- if (value_ == null) { |
|
1647 |
- result[key_] = value_; |
|
1607 |
+ function call(trait_id, facet_name, domain, input) { |
|
1608 |
+ if (trait_id in _pool) { |
|
1609 |
+ var trait_3 = _pool[trait_id]; |
|
1610 |
+ if (facet_name in trait_3.facets) { |
|
1611 |
+ var facet = trait_3.facets[facet_name]; |
|
1612 |
+ if (domain.kind in facet.handlers) { |
|
1613 |
+ var handler = facet.handlers[domain.kind]; |
|
1614 |
+ var bindings_1 = {}; |
|
1615 |
+ Object.keys(trait_3.variables).forEach(function (variable_name) { |
|
1616 |
+ bindings_1[variable_name] = trait_3.variables[variable_name].bindings[domain.kind]; |
|
1617 |
+ }); |
|
1618 |
+ if ((_typechecker != null) && (facet.signature.type_input != undefined)) { |
|
1619 |
+ var type = type_resolve(facet.signature.type_input, bindings_1); |
|
1620 |
+ var valid_input = _typechecker(input, type); |
|
1621 |
+ if (!valid_input) { |
|
1622 |
+ var message = "input '" + String(input) + "' for domain '" + domain.kind + "' implementing facet '" + facet_name + "' in trait '" + trait_id + "' doesn't match the expected type '" + type_show(type) + "'"; |
|
1623 |
+ console.warn(message); |
|
1648 | 1624 |
} |
1649 |
- else { |
|
1650 |
- if (typeof (value_) != "object") { |
|
1651 |
- result[key_] = value_; |
|
1652 | 1625 |
} |
1653 |
- else { |
|
1654 |
- var result_1 = flatten(value_); |
|
1655 |
- Object.keys(result_1).forEach(function (key__) { |
|
1656 |
- var value__ = result_1[key__]; |
|
1657 |
- result[key_ + "." + key__] = value__; |
|
1658 |
- }); |
|
1626 |
+ var output = handler(domain.parameters)(input); |
|
1627 |
+ if ((_typechecker != null) && (facet.signature.type_output != undefined)) { |
|
1628 |
+ var type = type_resolve(facet.signature.type_output, bindings_1); |
|
1629 |
+ var valid_output = _typechecker(output, type); |
|
1630 |
+ if (!valid_output) { |
|
1631 |
+ var message = "output '" + String(output) + "' for domain '" + domain.kind + "' implementing facet '" + facet_name + "' in trait '" + trait_id + "' doesn't match the expected type '" + type_show(type) + "'"; |
|
1632 |
+ console.warn(message); |
|
1659 | 1633 |
} |
1660 | 1634 |
} |
1661 |
- }; |
|
1662 |
- if (value == null) { |
|
1663 |
- return null; |
|
1635 |
+ return output; |
|
1664 | 1636 |
} |
1665 | 1637 |
else { |
1666 |
- var result_2 = {}; |
|
1667 |
- if (typeof (value) != "object") { |
|
1668 |
- result_2["value"] = value; |
|
1638 |
+ var message = "implementation for facet '" + facet_name + "' missing for domain '" + domain.kind + "' belonging to the trait '" + trait_id + "'"; |
|
1639 |
+ throw (new Error(message)); |
|
1669 | 1640 |
} |
1670 |
- else { |
|
1671 |
- if (value instanceof Array) { |
|
1672 |
- var array = (value); |
|
1673 |
- array.forEach(function (element, index) { return integrate(result_2, "element_" + index, element); }); |
|
1674 | 1641 |
} |
1675 | 1642 |
else { |
1676 |
- var object_1 = (value); |
|
1677 |
- Object.keys(object_1).forEach(function (key) { return integrate(result_2, key, object_1[key]); }); |
|
1643 |
+ var message = "no facet '" + facet_name + "' in trait '" + trait_id + "'"; |
|
1644 |
+ throw (new Error(message)); |
|
1678 | 1645 |
} |
1679 | 1646 |
} |
1680 |
- return result_2; |
|
1647 |
+ else { |
|
1648 |
+ var message = "no trait '" + trait_id + "'"; |
|
1649 |
+ throw (new Error(message)); |
|
1681 | 1650 |
} |
1682 | 1651 |
} |
1683 |
- lib_object.flatten = flatten; |
|
1652 |
+ lib_trait.call = call; |
|
1684 | 1653 |
/** |
1685 | 1654 |
* @author fenris |
1686 | 1655 |
*/ |
1687 |
- function clash(x, y, _a) { |
|
1688 |
- var _b = _a === void 0 ? {} : _a, _c = _b["overwrite"], overwrite = _c === void 0 ? true : _c, _d = _b["hooks"]["existing"], hook_existing = _d === void 0 ? null : _d; |
|
1689 |
- if (hook_existing == null) { |
|
1690 |
- (function (key, value_old, value_new) { return console.warn("field " + key + " already defined"); }); |
|
1656 |
+ function show() { |
|
1657 |
+ console.info(JSON.stringify(_pool, undefined, "\t")); |
|
1658 |
+ // console.info(_pool); |
|
1659 |
+ } |
|
1660 |
+ lib_trait.show = show; |
|
1661 |
+})(lib_trait || (lib_trait = {})); |
|
1662 |
+/** |
|
1663 |
+ * @author fenris |
|
1664 |
+ */ |
|
1665 |
+var lib_trait; |
|
1666 |
+(function (lib_trait) { |
|
1667 |
+ /** |
|
1668 |
+ * @desc the ability to check for equality with another element of the same domain |
|
1669 |
+ * @author fenris |
|
1670 |
+ */ |
|
1671 |
+ function define_collatable() { |
|
1672 |
+ lib_trait.describe("collatable", { |
|
1673 |
+ "value": [] |
|
1674 |
+ }, { |
|
1675 |
+ "collate": { |
|
1676 |
+ "type_input": { |
|
1677 |
+ "kind": "object", |
|
1678 |
+ "parameters": { |
|
1679 |
+ "fields": [ |
|
1680 |
+ { |
|
1681 |
+ "name": "left", |
|
1682 |
+ "type": { |
|
1683 |
+ "kind": "variable", |
|
1684 |
+ "parameters": { |
|
1685 |
+ "name": "value" |
|
1686 |
+ } |
|
1687 |
+ } |
|
1688 |
+ }, |
|
1689 |
+ { |
|
1690 |
+ "name": "right", |
|
1691 |
+ "type": { |
|
1692 |
+ "kind": "variable", |
|
1693 |
+ "parameters": { |
|
1694 |
+ "name": "value" |
|
1695 |
+ } |
|
1696 |
+ } |
|
1697 |
+ } |
|
1698 |
+ ] |
|
1699 |
+ } |
|
1700 |
+ }, |
|
1701 |
+ "type_output": { |
|
1702 |
+ "kind": "boolean" |
|
1691 | 1703 |
} |
1692 |
- var z = {}; |
|
1693 |
- Object.keys(x).forEach(function (key) { |
|
1694 |
- z[key] = x[key]; |
|
1695 |
- }); |
|
1696 |
- Object.keys(y).forEach(function (key) { |
|
1697 |
- if (key in z) { |
|
1698 |
- hook_existing(key, z[key], y[key]); |
|
1699 |
- if (overwrite) { |
|
1700 |
- z[key] = y[key]; |
|
1701 | 1704 |
} |
1705 |
+ }); |
|
1706 |
+ lib_trait.assign("auto", "collatable", { |
|
1707 |
+ "value": { |
|
1708 |
+ "kind": "any" |
|
1709 |
+ } |
|
1710 |
+ }, { |
|
1711 |
+ "collate": function (_) { return function (_a) { |
|
1712 |
+ var x = _a["left"], y = _a["right"]; |
|
1713 |
+ if (typeof (x) === "object") { |
|
1714 |
+ if (x == null) { |
|
1715 |
+ return (y == null); |
|
1702 | 1716 |
} |
1703 | 1717 |
else { |
1704 |
- z[key] = y[key]; |
|
1718 |
+ if ("_collate" in x) { |
|
1719 |
+ return x["_collate"](y); |
|
1720 |
+ } |
|
1721 |
+ else { |
|
1722 |
+ throw (new Error("[collate]" + " " + "object has no such method")); |
|
1723 |
+ } |
|
1724 |
+ } |
|
1705 | 1725 |
} |
1726 |
+ else { |
|
1727 |
+ if (lib_trait._verbosity >= 1) { |
|
1728 |
+ console.warn("[collate]" + " " + "primitive value; using default implementation"); |
|
1729 |
+ } |
|
1730 |
+ return (x === y); |
|
1731 |
+ } |
|
1732 |
+ }; } |
|
1706 | 1733 |
}); |
1707 |
- return z; |
|
1708 | 1734 |
} |
1709 |
- lib_object.clash = clash; |
|
1735 |
+ lib_trait.define_collatable = define_collatable; |
|
1736 |
+})(lib_trait || (lib_trait = {})); |
|
1710 | 1737 |
/** |
1711 | 1738 |
* @author fenris |
1712 | 1739 |
*/ |
1713 |
- function patch(core, mantle, deep, path) { |
|
1714 |
- if (deep === void 0) { deep = true; } |
|
1715 |
- if (path === void 0) { path = null; } |
|
1716 |
- if (mantle == null) { |
|
1717 |
- console.warn("mantle is null; core was", core); |
|
1740 |
+var lib_trait; |
|
1741 |
+(function (lib_trait) { |
|
1742 |
+ /** |
|
1743 |
+ * @desc the ability to compare with another element of the same domain for determining if the first is "smaller than or equal to" the latter |
|
1744 |
+ * @author fenris |
|
1745 |
+ */ |
|
1746 |
+ function define_comparable() { |
|
1747 |
+ lib_trait.describe("comparable", { |
|
1748 |
+ "value": [] |
|
1749 |
+ }, { |
|
1750 |
+ "compare": { |
|
1751 |
+ "type_input": { |
|
1752 |
+ "kind": "object", |
|
1753 |
+ "parameters": { |
|
1754 |
+ "fields": [ |
|
1755 |
+ { |
|
1756 |
+ "name": "left", |
|
1757 |
+ "type": { |
|
1758 |
+ "kind": "variable", |
|
1759 |
+ "parameters": { |
|
1760 |
+ "name": "value" |
|
1718 | 1761 |
} |
1719 |
- else { |
|
1720 |
- Object.keys(mantle).forEach(function (key) { |
|
1721 |
- var path_ = ((path == null) ? key : path + "." + key); |
|
1722 |
- var value_mantle = mantle[key]; |
|
1723 |
- if (!(key in core)) { |
|
1724 |
- if ((typeof (value_mantle) == "object") && (value_mantle != null) && deep) { |
|
1725 |
- if (value_mantle instanceof Array) { |
|
1726 |
- core[key] = []; |
|
1727 |
- value_mantle.forEach(function (element) { |
|
1728 |
- if ((typeof (element) == "object") && (element != null)) { |
|
1729 |
- var element_ = {}; |
|
1730 |
- patch(element_, element); |
|
1731 |
- core[key].push(element_); |
|
1732 | 1762 |
} |
1733 |
- else { |
|
1734 |
- core[key].push(element); |
|
1763 |
+ }, |
|
1764 |
+ { |
|
1765 |
+ "name": "right", |
|
1766 |
+ "type": { |
|
1767 |
+ "kind": "variable", |
|
1768 |
+ "parameters": { |
|
1769 |
+ "name": "value" |
|
1735 | 1770 |
} |
1736 |
- }); |
|
1737 | 1771 |
} |
1738 |
- else { |
|
1739 |
- core[key] = {}; |
|
1740 |
- patch(core[key], value_mantle, deep, path_); |
|
1741 | 1772 |
} |
1773 |
+ ] |
|
1742 | 1774 |
} |
1743 |
- else { |
|
1744 |
- core[key] = value_mantle; |
|
1775 |
+ }, |
|
1776 |
+ "type_output": { |
|
1777 |
+ "kind": "boolean" |
|
1745 | 1778 |
} |
1746 | 1779 |
} |
1747 |
- else { |
|
1748 |
- var value_core = core[key]; |
|
1749 |
- if (typeof (value_mantle) == typeof (value_core)) { |
|
1750 |
- if ((typeof (value_mantle) == "object") && (value_mantle != null) && deep) { |
|
1751 |
- patch(core[key], value_mantle, deep, path_); |
|
1780 |
+ }); |
|
1781 |
+ lib_trait.assign("auto", "comparable", { |
|
1782 |
+ "value": { |
|
1783 |
+ "kind": "any" |
|
1784 |
+ } |
|
1785 |
+ }, { |
|
1786 |
+ "compare": function (_) { return function (_a) { |
|
1787 |
+ var x = _a["left"], y = _a["right"]; |
|
1788 |
+ if (typeof (x) === "object") { |
|
1789 |
+ if ("_compare" in x) { |
|
1790 |
+ return x["_compare"](y); |
|
1752 | 1791 |
} |
1753 | 1792 |
else { |
1754 |
- core[key] = value_mantle; |
|
1793 |
+ throw (new Error("[compare]" + " " + "object has no such method")); |
|
1755 | 1794 |
} |
1756 | 1795 |
} |
1757 | 1796 |
else { |
1758 |
- var message = "objects have different shapes at path '" + path_ + "'; core has type '" + typeof (value_core) + "' and mantle has type '" + typeof (value_mantle) + "'"; |
|
1759 |
- console.warn(message); |
|
1760 |
- core[key] = value_mantle; |
|
1761 |
- // throw (new Error(message)); |
|
1797 |
+ if (lib_trait._verbosity >= 1) { |
|
1798 |
+ console.warn("[compare]" + " " + "primitive value; using default implementation"); |
|
1762 | 1799 |
} |
1800 |
+ return (x <= y); |
|
1763 | 1801 |
} |
1802 |
+ }; } |
|
1764 | 1803 |
}); |
1765 | 1804 |
} |
1766 |
- } |
|
1767 |
- lib_object.patch = patch; |
|
1805 |
+ lib_trait.define_comparable = define_comparable; |
|
1806 |
+})(lib_trait || (lib_trait = {})); |
|
1768 | 1807 |
/** |
1769 | 1808 |
* @author fenris |
1770 | 1809 |
*/ |
1771 |
- function patched(core, mantle, deep) { |
|
1772 |
- if (deep === void 0) { deep = undefined; } |
|
1773 |
- var result = {}; |
|
1774 |
- patch(result, core, deep); |
|
1775 |
- patch(result, mantle, deep); |
|
1776 |
- return result; |
|
1777 |
- } |
|
1778 |
- lib_object.patched = patched; |
|
1810 |
+var lib_trait; |
|
1811 |
+(function (lib_trait) { |
|
1779 | 1812 |
/** |
1813 |
+ * @desc the ability to create an exact copy |
|
1780 | 1814 |
* @author fenris |
1781 | 1815 |
*/ |
1782 |
- function attached(object, key, value) { |
|
1783 |
- var mantle = {}; |
|
1784 |
- mantle[key] = value; |
|
1785 |
- return patched(object, mantle, false); |
|
1816 |
+ function define_clonable() { |
|
1817 |
+ lib_trait.describe("clonable", { |
|
1818 |
+ "value": [] |
|
1819 |
+ }, { |
|
1820 |
+ "clone": { |
|
1821 |
+ "type_input": { |
|
1822 |
+ "kind": "variable", |
|
1823 |
+ "parameters": { |
|
1824 |
+ "name": "value" |
|
1786 | 1825 |
} |
1787 |
- lib_object.attached = attached; |
|
1788 |
- /** |
|
1789 |
- * @author fenris |
|
1790 |
- */ |
|
1791 |
- function copy(object) { |
|
1792 |
- return patched({}, object); |
|
1826 |
+ }, |
|
1827 |
+ "type_output": { |
|
1828 |
+ "kind": "variable", |
|
1829 |
+ "parameters": { |
|
1830 |
+ "name": "value" |
|
1793 | 1831 |
} |
1794 |
- lib_object.copy = copy; |
|
1795 |
-})(lib_object || (lib_object = {})); |
|
1832 |
+ } |
|
1833 |
+ } |
|
1834 |
+ }); |
|
1835 |
+ lib_trait.assign("auto", "clonable", { |
|
1836 |
+ "value": { |
|
1837 |
+ "kind": "any" |
|
1838 |
+ } |
|
1839 |
+ }, { |
|
1840 |
+ "clone": function (_) { return function (x) { |
|
1841 |
+ if (typeof (x) === "object") { |
|
1842 |
+ if ("_clone" in x) { |
|
1843 |
+ return x["_clone"](); |
|
1844 |
+ } |
|
1845 |
+ else { |
|
1846 |
+ throw (new Error("[clone]" + " " + "object has no such method")); |
|
1847 |
+ } |
|
1848 |
+ } |
|
1849 |
+ else { |
|
1850 |
+ if (lib_trait._verbosity >= 1) { |
|
1851 |
+ console.warn("[clone]" + " " + "primitive value; using default implementation"); |
|
1852 |
+ } |
|
1853 |
+ return x; |
|
1854 |
+ } |
|
1855 |
+ }; } |
|
1856 |
+ }); |
|
1857 |
+ } |
|
1858 |
+ lib_trait.define_clonable = define_clonable; |
|
1859 |
+})(lib_trait || (lib_trait = {})); |
|
1796 | 1860 |
/** |
1797 |
- * @desc adapters for old syntax |
|
1798 | 1861 |
* @author fenris |
1799 | 1862 |
*/ |
1800 |
-var object_fetch = lib_object.fetch; |
|
1801 |
-var object_map = lib_object.map; |
|
1802 |
-var object_a2o = lib_object.from_array; |
|
1803 |
-var object_o2a = lib_object.to_array; |
|
1804 |
-var object_matches = lib_object.matches; |
|
1805 |
-var object_clash = lib_object.clash; |
|
1806 |
-///<reference path="../../base/build/logic-decl.d.ts"/> |
|
1807 |
-/** |
|
1808 |
- * @param {Object} map |
|
1809 |
- * @return {string} |
|
1810 |
- * @author frac |
|
1811 |
- */ |
|
1812 |
-/*export*/ var object_map2string = function (map) { |
|
1813 |
- return (" " + Object.keys(map) |
|
1814 |
- .filter(function (key) { return (key != "isMapped"); }) |
|
1815 |
- .map(function (key) { return ("" + ((map[key] == null) ? "-" : map[key].toString()) + ""); }) |
|
1816 |
- .join(" ") |
|
1817 |
- + ""); |
|
1818 |
-}; |
|
1863 |
+var lib_trait; |
|
1864 |
+(function (lib_trait) { |
|
1819 | 1865 |
/** |
1820 |
- * @param {Array} array |
|
1821 |
- * @return {string} |
|
1822 |
- * @author frac |
|
1866 |
+ * @desc the ability to generate a string out of the element, which identifies it to a high degree |
|
1867 |
+ * @author fenris |
|
1823 | 1868 |
*/ |
1824 |
-/*export*/ var object_array2string = function (array) { |
|
1825 |
- return ("" + array.map(function (element, index) { |
|
1826 |
- switch (typeof (element)) { |
|
1827 |
- case "object": return object_map2string(element); |
|
1828 |
- default: return String(element); |
|
1869 |
+ function define_hashable() { |
|
1870 |
+ lib_trait.describe("hashable", { |
|
1871 |
+ "value": [] |
|
1872 |
+ }, { |
|
1873 |
+ "hash": { |
|
1874 |
+ "type_input": { |
|
1875 |
+ "kind": "variable", |
|
1876 |
+ "parameters": { |
|
1877 |
+ "name": "value" |
|
1829 | 1878 |
} |
1830 |
- }).join(",") + ""); |
|
1831 |
-}; |
|
1832 |
-/** |
|
1833 |
- * @desc follows a path in an object-tree |
|
1834 |
- * @param {Object} object the object in which the path lies |
|
1835 |
- * @param {string} path the steps |
|
1836 |
- * @param {boolean} [create] whether to create not yet existing branches |
|
1837 |
- * @return {Object} {'successful': successful, 'position': position} where the branch or leaf at the end of the path |
|
1838 |
- * @author frac |
|
1839 |
- */ |
|
1840 |
-var object_path_walk = function (object, path, create, null_on_missing) { |
|
1841 |
- if (create === void 0) { create = true; } |
|
1842 |
- if (null_on_missing === void 0) { null_on_missing = false; } |
|
1843 |
- var steps = ((path == "") ? [] : path.split(".")); |
|
1844 |
- if (steps.length == 0) { |
|
1845 |
- return object; |
|
1879 |
+ }, |
|
1880 |
+ "type_output": { |
|
1881 |
+ "kind": "string" |
|
1846 | 1882 |
} |
1847 |
- else { |
|
1848 |
- var head = steps[0]; |
|
1849 |
- // create |
|
1850 |
- { |
|
1851 |
- if (!(head in object)) { |
|
1852 |
- if (create) { |
|
1853 |
- var value = null; |
|
1854 |
- if (steps.length >= 2) { |
|
1855 |
- var next = steps[1]; |
|
1856 |
- var index = parseInt(next); |
|
1857 |
- if (!isNaN(index)) { |
|
1858 |
- value = []; |
|
1859 | 1883 |
} |
1860 |
- else { |
|
1861 |
- value = {}; |
|
1884 |
+ }); |
|
1885 |
+ lib_trait.assign("auto", "hashable", { |
|
1886 |
+ "value": { |
|
1887 |
+ "kind": "any" |
|
1862 | 1888 |
} |
1889 |
+ }, { |
|
1890 |
+ "hash": function (_) { return function (x) { |
|
1891 |
+ if (typeof (x) === "object") { |
|
1892 |
+ if ("_hash" in x) { |
|
1893 |
+ return x["_hash"](); |
|
1863 | 1894 |
} |
1864 | 1895 |
else { |
1865 |
- value = {}; |
|
1896 |
+ throw (new Error("[hash]" + " " + "object has no such method")); |
|
1866 | 1897 |
} |
1867 |
- object[head] = value; |
|
1868 | 1898 |
} |
1869 | 1899 |
else { |
1870 |
- // console.info("[object_path_walk] object is ", object); |
|
1871 |
- var message = "[object_path_walk] can not walk step \u00BB" + head + "\u00AB in path \u00BB" + path + "\u00AB on object"; |
|
1872 |
- if (null_on_missing) { |
|
1873 |
- console.warn(message); |
|
1874 |
- return null; |
|
1900 |
+ if (lib_trait._verbosity >= 1) { |
|
1901 |
+ console.warn("[hash]" + " " + "primitive value; using default implementation"); |
|
1875 | 1902 |
} |
1876 |
- else { |
|
1877 |
- throw (new Error(message)); |
|
1903 |
+ return String(x); |
|
1878 | 1904 |
} |
1905 |
+ }; } |
|
1906 |
+ }); |
|
1879 | 1907 |
} |
1908 |
+ lib_trait.define_hashable = define_hashable; |
|
1909 |
+})(lib_trait || (lib_trait = {})); |
|
1910 |
+/** |
|
1911 |
+ * @author fenris |
|
1912 |
+ */ |
|
1913 |
+var lib_trait; |
|
1914 |
+(function (lib_trait) { |
|
1915 |
+ /** |
|
1916 |
+ * @desc the ability to map the element to a textual representation (most likely not injective) |
|
1917 |
+ * @author fenris |
|
1918 |
+ */ |
|
1919 |
+ function define_showable() { |
|
1920 |
+ lib_trait.describe("showable", { |
|
1921 |
+ "value": [] |
|
1922 |
+ }, { |
|
1923 |
+ "show": { |
|
1924 |
+ "type_input": { |
|
1925 |
+ "kind": "variable", |
|
1926 |
+ "parameters": { |
|
1927 |
+ "name": "value" |
|
1880 | 1928 |
} |
1929 |
+ }, |
|
1930 |
+ "type_output": { |
|
1931 |
+ "kind": "string" |
|
1881 | 1932 |
} |
1882 |
- // execute rest |
|
1883 |
- { |
|
1884 |
- var object_ = object[head]; |
|
1885 |
- var path_ = steps.slice(1).join("."); |
|
1886 |
- return object_path_walk(object_, path_, create, null_on_missing); |
|
1887 | 1933 |
} |
1934 |
+ }); |
|
1935 |
+ lib_trait.assign("auto", "showable", { |
|
1936 |
+ "value": { |
|
1937 |
+ "kind": "any" |
|
1938 |
+ } |
|
1939 |
+ }, { |
|
1940 |
+ "show": function (_) { return function (x) { |
|
1941 |
+ if (typeof (x) === "object") { |
|
1942 |
+ if (x == null) { |
|
1943 |
+ return "NULL"; |
|
1888 | 1944 |
} |
1889 |
- /* |
|
1890 |
- return ( |
|
1891 |
- string_split(path, ".").reduce( |
|
1892 |
- function (position : any, step : string) : any { |
|
1893 |
- if (! lib_call.is_def(position[step], true)) { |
|
1894 |
- if (create) { |
|
1895 |
- position[step] = {}; |
|
1945 |
+ else { |
|
1946 |
+ if ("_show" in x) { |
|
1947 |
+ return x["_show"](); |
|
1896 | 1948 |
} |
1897 | 1949 |
else { |
1898 |
- // console.info("[object_path_walk] object is ", object); |
|
1899 |
- let message : string = sprintf("[object_path_walk] can not walk step »%s« in path »%s« on object", [step, path]); |
|
1900 |
- if (null_on_missing) { |
|
1901 |
- console.warn(message); |
|
1902 |
- return null; |
|
1950 |
+ // throw (new Error("[show]" + " " + "object has no such method")); |
|
1951 |
+ return JSON.stringify(x); |
|
1952 |
+ } |
|
1953 |
+ } |
|
1903 | 1954 |
} |
1904 | 1955 |
else { |
1905 |
- throw (new Error(message)); |
|
1956 |
+ if (lib_trait._verbosity >= 1) { |
|
1957 |
+ console.warn("[show]" + " " + "primitive value; using default implementation"); |
|
1906 | 1958 |
} |
1959 |
+ return String(x); |
|
1907 | 1960 |
} |
1961 |
+ }; } |
|
1962 |
+ }); |
|
1908 | 1963 |
} |
1909 |
- return position[step]; |
|
1910 |
- }, |
|
1911 |
- object |
|
1912 |
- ) |
|
1913 |
- ); |
|
1914 |
- */ |
|
1915 |
-}; |
|
1964 |
+ lib_trait.define_showable = define_showable; |
|
1965 |
+})(lib_trait || (lib_trait = {})); |
|
1916 | 1966 |
/** |
1917 |
- * @desc reads a branch/leaf from an object-tree |
|
1918 |
- * @author frac |
|
1967 |
+ * @author fenris |
|
1919 | 1968 |
*/ |
1920 |
-/*export*/ var object_path_read = function (object, path, null_on_missing) { |
|
1921 |
- if (null_on_missing === void 0) { null_on_missing = false; } |
|
1922 |
- return object_path_walk(object, path, false, null_on_missing); |
|
1923 |
-}; |
|
1969 |
+var lib_trait; |
|
1970 |
+(function (lib_trait) { |
|
1924 | 1971 |
/** |
1925 |
- * @desc writes a branch/leaf to an object-tree |
|
1926 |
- * @author frac |
|
1972 |
+ * @author fenris |
|
1927 | 1973 |
*/ |
1928 |
-/*export*/ var object_path_write = function (object, path, value) { |
|
1929 |
- // for "initializing" the object (important if the value to write is an entry in a yet not existing array) |
|
1930 |
- /*let old : any = */ object_path_walk(object, path, true, true); |
|
1931 |
- var steps = ((path == "") ? [] : path.split(".")); |
|
1932 |
- var position = object_path_walk(object, steps.slice(0, steps.length - 1).join("."), true); |
|
1933 |
- if (position == undefined) { |
|
1934 |
- console.warn("can't set \u00BB" + steps[steps.length - 1] + "\u00AB in undefined"); |
|
1974 |
+ function define_common() { |
|
1975 |
+ lib_trait.define_collatable(); |
|
1976 |
+ lib_trait.define_comparable(); |
|
1977 |
+ lib_trait.define_clonable(); |
|
1978 |
+ lib_trait.define_hashable(); |
|
1979 |
+ lib_trait.define_showable(); |
|
1980 |
+ } |
|
1981 |
+ lib_trait.define_common = define_common; |
|
1982 |
+})(lib_trait || (lib_trait = {})); |
|
1983 |
+///<reference path="../../base/build/logic-decl.d.ts"/> |
|
1984 |
+var lib_object; |
|
1985 |
+(function (lib_object) { |
|
1986 |
+ /** |
|
1987 |
+ * @author fenris |
|
1988 |
+ */ |
|
1989 |
+ function fetch(object, fieldname, fallback, escalation) { |
|
1990 |
+ if (fallback === void 0) { fallback = null; } |
|
1991 |
+ if (escalation === void 0) { escalation = 1; } |
|
1992 |
+ if ((fieldname in object) && (object[fieldname] !== undefined)) { |
|
1993 |
+ return object[fieldname]; |
|
1935 | 1994 |
} |
1936 | 1995 |
else { |
1937 |
- position[steps[steps.length - 1]] = value; |
|
1996 |
+ switch (escalation) { |
|
1997 |
+ case 0: { |
|
1998 |
+ return fallback; |
|
1999 |
+ break; |
|
1938 | 2000 |
} |
1939 |
-}; |
|
1940 |
-/*export*/ var object_object_path_write_ex = function (obj, path, val) { |
|
1941 |
- var ref = obj; |
|
1942 |
- var paths = path.split("."); |
|
1943 |
- var i; |
|
1944 |
- for (i = 0; i < paths.length - 1; i++) { |
|
1945 |
- if (ref[paths[i]] === void 0) { |
|
1946 |
- if (/^(0|[1-9][0-9]*)$/.test(paths[i + 1])) { |
|
1947 |
- ref[paths[i]] = []; |
|
2001 |
+ case 1: { |
|
2002 |
+ var message = ("field '" + fieldname + "' not in structure"); |
|
2003 |
+ message += ("; using fallback value '" + String(fallback) + "'"); |
|
2004 |
+ // console.warn(message); |
|
2005 |
+ return fallback; |
|
2006 |
+ break; |
|
1948 | 2007 |
} |
1949 |
- else { |
|
1950 |
- ref[paths[i]] = {}; |
|
2008 |
+ case 2: { |
|
2009 |
+ var message = ("field '" + fieldname + "' not in structure"); |
|
2010 |
+ throw (new Error(message)); |
|
2011 |
+ break; |
|
1951 | 2012 |
} |
2013 |
+ default: { |
|
2014 |
+ throw (new Error("invalid escalation level " + escalation)); |
|
2015 |
+ break; |
|
1952 | 2016 |
} |
1953 |
- ref = ref[paths[i]]; |
|
1954 | 2017 |
} |
1955 |
- ref[paths[i]] = val; |
|
1956 |
-}; |
|
1957 |
-/** |
|
1958 |
- * @desc filters branches from an object |
|
1959 |
- * @param {Object} object the object to read from |
|
1960 |
- * @param {Array} paths a list of string-lists, that are the paths to be propagated |
|
1961 |
- * @return {Object} the object with only the selected branches |
|
1962 |
- * @author frac |
|
1963 |
- */ |
|
1964 |
-/*export*/ var object_path_filter = function (object, paths) { |
|
1965 |
- var result = {}; |
|
1966 |
- paths.forEach(function (path) { |
|
1967 |
- var value = null; |
|
1968 |
- try { |
|
1969 |
- value = object_path_read(object, path); |
|
1970 | 2018 |
} |
1971 |
- catch (exception) { |
|
1972 |
- console.warn(exception); |
|
1973 | 2019 |
} |
1974 |
- if (value != null) { |
|
1975 |
- object_path_write(result, path, value); |
|
2020 |
+ lib_object.fetch = fetch; |
|
2021 |
+ /** |
|
2022 |
+ * @author fenris |
|
2023 |
+ */ |
|
2024 |
+ function map(object_from, transformator) { |
|
2025 |
+ var object_to = {}; |
|
2026 |
+ Object.keys(object_from).forEach(function (key) { return (object_to[key] = transformator(object_from[key], key)); }); |
|
2027 |
+ return object_to; |
|
1976 | 2028 |
} |
1977 |
- else { |
|
1978 |
- console.warn("skipped path \"" + path + "\" while filtering"); |
|
2029 |
+ lib_object.map = map; |
|
2030 |
+ /** |
|
2031 |
+ * @author fenris |
|
2032 |
+ */ |
|
2033 |
+ function filter(object_from, predicate) { |
|
2034 |
+ var object_to = {}; |
|
2035 |
+ Object.keys(object_from).forEach(function (key) { |
|
2036 |
+ var value = object_from[key]; |
|
2037 |
+ if (predicate(value, key)) { |
|
2038 |
+ object_to[key] = value; |
|
1979 | 2039 |
} |
1980 | 2040 |
}); |
1981 |
- return result; |
|
1982 |
-}; |
|
2041 |
+ return object_to; |
|
2042 |
+ } |
|
2043 |
+ lib_object.filter = filter; |
|
1983 | 2044 |
/** |
1984 |
- * @desc dunno… returns a list of object-paths? |
|
1985 |
- * @param {Object} object |
|
1986 |
- * @param {string} p |
|
1987 |
- * @todo can probably be merged with getLeafg |
|
2045 |
+ * @author fenris |
|
1988 | 2046 |
*/ |
1989 |
-/*export*/ var object_path_list = function (object, path, visited) { |
|
1990 |
- if (path === void 0) { path = null; } |
|
1991 |
- if (visited === void 0) { visited = []; } |
|
1992 |
- var result = []; |
|
1993 |
- visited.push(object); |
|
1994 |
- for (var key in object) { |
|
1995 |
- var value = object[key]; |
|
1996 |
- if (visited.indexOf(value) === -1) { |
|
1997 |
- var key_ = (path == null) ? key : (path + "." + key); |
|
1998 |
- if (typeof (value) === "object") { |
|
1999 |
- result = result.concat(object_path_list(value, key_, visited)); |
|
2047 |
+ function from_array(array) { |
|
2048 |
+ var object = {}; |
|
2049 |
+ array.forEach(function (entry) { return (object[entry.key] = entry.value); }); |
|
2050 |
+ return object; |
|
2000 | 2051 |
} |
2001 |
- else { |
|
2002 |
- result.push({ "key": key_, "value": value }); |
|
2052 |
+ lib_object.from_array = from_array; |
|
2053 |
+ /** |
|
2054 |
+ * @author fenris |
|
2055 |
+ */ |
|
2056 |
+ function to_array(object) { |
|
2057 |
+ var array = []; |
|
2058 |
+ Object.keys(object).forEach(function (key) { return array.push({ "key": key, "value": object[key] }); }); |
|
2059 |
+ return array; |
|
2003 | 2060 |
} |
2061 |
+ lib_object.to_array = to_array; |
|
2062 |
+ /** |
|
2063 |
+ * @author fenris |
|
2064 |
+ */ |
|
2065 |
+ function keys(object) { |
|
2066 |
+ return Object.keys(object); |
|
2004 | 2067 |
} |
2068 |
+ lib_object.keys = keys; |
|
2069 |
+ /** |
|
2070 |
+ * @author fenris |
|
2071 |
+ */ |
|
2072 |
+ function values(object) { |
|
2073 |
+ return to_array(object).map(function (entry) { return entry.value; }); |
|
2005 | 2074 |
} |
2006 |
- return result; |
|
2007 |
-}; |
|
2075 |
+ lib_object.values = values; |
|
2008 | 2076 |
/** |
2009 |
- * theroreticaly loop prof walk through all elements and subelements of an object |
|
2010 |
- * and call a callback for each entry |
|
2011 |
- * @param {object} obj object to iterate through |
|
2012 |
- * @param {function} callback |
|
2077 |
+ * @author fenris |
|
2013 | 2078 |
*/ |
2014 |
-/*export*/ var object_iterate = function (obj, callback, leafs_only, path, visited) { |
|
2015 |
- if (leafs_only === void 0) { leafs_only = false; } |
|
2016 |
- if (visited === void 0) { visited = []; } |
|
2017 |
- var have_seen = function (ob) { |
|
2018 |
- return visited.some(function (e) { return ((typeof (ob) === "object") && (ob !== null) && (e === ob)); }); |
|
2019 |
- }; |
|
2020 |
- var next = []; |
|
2021 |
- Object.keys(obj).forEach(function (key) { |
|
2022 |
- var elem = obj[key]; |
|
2023 |
- if (!have_seen(elem)) { |
|
2024 |
- visited.push(elem); |
|
2025 |
- var _path = ""; |
|
2026 |
- if (typeof path === "undefined") { |
|
2027 |
- _path = key; |
|
2079 |
+ function path_read(object, path, fallback, escalation) { |
|
2080 |
+ if (fallback === void 0) { fallback = null; } |
|
2081 |
+ if (escalation === void 0) { escalation = 1; } |
|
2082 |
+ var steps = ((path.length == 0) ? [] : path.split(".")); |
|
2083 |
+ if (steps.length == 0) { |
|
2084 |
+ throw (new Error("empty path")); |
|
2028 | 2085 |
} |
2029 | 2086 |
else { |
2030 |
- _path += [path, key].join("."); |
|
2031 |
- } |
|
2032 |
- if (!leafs_only) |
|
2033 |
- callback(_path, elem, key); |
|
2034 |
- if (typeof (elem) === "object") { |
|
2035 |
- (function (elem_, callback_, _path_, visited_) { |
|
2036 |
- next.push(function () { object_iterate(elem_, callback_, leafs_only, _path_, visited_); }); |
|
2037 |
- })(elem, callback, _path, visited); |
|
2087 |
+ var position_1 = object; |
|
2088 |
+ var reachable = (position_1 != null) && steps.slice(0, steps.length - 1).every(function (step) { |
|
2089 |
+ position_1 = object_fetch(position_1, step, null, 0); |
|
2090 |
+ return (position_1 != null); |
|
2091 |
+ }); |
|
2092 |
+ if (reachable) { |
|
2093 |
+ return object_fetch(position_1, steps[steps.length - 1], fallback, escalation); |
|
2038 | 2094 |
} |
2039 | 2095 |
else { |
2040 |
- if (leafs_only) |
|
2041 |
- callback(_path, elem, key); |
|
2096 |
+ return object_fetch({}, "_dummy_", fallback, escalation); |
|
2042 | 2097 |
} |
2043 | 2098 |
} |
2044 |
- }); |
|
2045 |
- var func; |
|
2046 |
- while (func = next.shift()) { |
|
2047 |
- func(); |
|
2048 | 2099 |
} |
2049 |
-}; |
|
2100 |
+ lib_object.path_read = path_read; |
|
2050 | 2101 |
/** |
2051 |
- * @desc get the leaf-nodes of an object |
|
2052 |
- * @param {object} object |
|
2053 |
- * @return {Array<string>} a list containing all leaf-nodes |
|
2054 |
- * @author frac |
|
2102 |
+ * @author fenris |
|
2055 | 2103 |
*/ |
2056 |
-/*export*/ var getLeafs = function (object) { |
|
2057 |
- var skip = { |
|
2058 |
- "className": true, |
|
2059 |
- "timeStamp": true, |
|
2060 |
- "parentId": true, |
|
2061 |
- "transactionID": true, |
|
2062 |
- "guid": true, |
|
2063 |
- "_id": true, |
|
2064 |
- "parents": true, |
|
2065 |
- "children": true |
|
2066 |
- }; |
|
2067 |
- return (Object.keys(object).reduce(function (leafs, key) { |
|
2068 |
- try { |
|
2069 |
- var value = object[key]; |
|
2070 |
- if (key in skip) { |
|
2071 |
- console.warn("skipping field \"" + key + "\""); |
|
2072 |
- return leafs; |
|
2104 |
+ function path_write(object, path, value, construct) { |
|
2105 |
+ if (construct === void 0) { construct = true; } |
|
2106 |
+ var steps = ((path.length == 0) ? [] : path.split(".")); |
|
2107 |
+ if (steps.length == 0) { |
|
2108 |
+ throw (new Error("empty path")); |
|
2073 | 2109 |
} |
2074 | 2110 |
else { |
2075 |
- if ((typeof (value) === "object") && (value != null)) { |
|
2076 |
- return leafs.concat(getLeafs(value).map(function (leaf) { return (key + "." + leaf); })); |
|
2111 |
+ var position_2 = object; |
|
2112 |
+ var reachable = steps.slice(0, steps.length - 1).every(function (step) { |
|
2113 |
+ var position_ = object_fetch(position_2, step, null, 0); |
|
2114 |
+ if (position_ == null) { |
|
2115 |
+ if (construct) { |
|
2116 |
+ position_2[step] = {}; |
|
2117 |
+ position_2 = position_2[step]; |
|
2118 |
+ return true; |
|
2077 | 2119 |
} |
2078 | 2120 |
else { |
2079 |
- return leafs.concat([key]); |
|
2121 |
+ return false; |
|
2122 |
+ } |
|
2123 |
+ } |
|
2124 |
+ else { |
|
2125 |
+ position_2 = position_; |
|
2126 |
+ return true; |
|
2127 |
+ } |
|
2128 |
+ }); |
|
2129 |
+ if (reachable) { |
|
2130 |
+ position_2[steps[steps.length - 1]] = value; |
|
2080 | 2131 |
} |
2132 |
+ else { |
|
2133 |
+ throw (new Error("path " + path + " does not exist and may not be constructed")); |
|
2081 | 2134 |
} |
2082 | 2135 |
} |
2083 |
- catch (exception) { |
|
2084 |
- console.warn(exception); |
|
2085 |
- console.info("key: ", key); |
|
2086 |
- return null; |
|
2087 | 2136 |
} |
2088 |
- }, new Array())); |
|
2089 |
-}; |
|
2137 |
+ lib_object.path_write = path_write; |
|
2090 | 2138 |
/** |
2091 |
- * |
|
2092 |
- * @desc merges two arrays by probing |
|
2093 |
- * @param {Array} core |
|
2094 |
- * @param {Array} mantle |
|
2095 |
- * @param {function} match |
|
2139 |
+ * @author fenris |
|
2096 | 2140 |
*/ |
2097 |
-/*export*/ var merge_array = function (core, mantle, match) { |
|
2098 |
- if (match === void 0) { match = (function (x, y) { return (x === y); }); } |
|
2099 |
- if ((core == undefined) || (mantle == undefined)) { |
|
2100 |
- throw (new Error("Error: " |
|
2101 |
- + ((core == undefined) ? " core must be an array and not '" + typeof (core) + "'" : "") |
|
2102 |
- + ((mantle == undefined) ? " mantle must be an array and not '" + typeof (mantle) + "'" : ""))); |
|
2141 |
+ function matches(object, pattern, collate) { |
|
2142 |
+ if (collate === void 0) { collate = instance_collate; } |
|
2143 |
+ return Object.keys(pattern).every(function (key) { return collate(pattern[key], object[key]); }); |
|
2103 | 2144 |
} |
2104 |
- var ret = core; |
|
2105 |
- for (var i = 0; i < mantle.length; i++) { |
|
2106 |
- var entry = mantle[i]; |
|
2107 |
- try { |
|
2108 |
- var matching_index = core.find(function (element) { return match(element, entry); }); |
|
2109 |
- ret[matching_index] = object_merge_objects(core[matching_index], entry); |
|
2110 |
- } |
|
2111 |
- catch (e) { |
|
2112 |
- ret.push(entry); |
|
2113 |
- } |
|
2114 |
- } |
|
2115 |
- return ret; |
|
2116 |
-}; |
|
2145 |
+ lib_object.matches = matches; |
|
2117 | 2146 |
/** |
2118 |
- * @desc merges two objects recursivly |
|
2119 |
- * @param {Object} object1 core |
|
2120 |
- * @param {Object} object2 mantle |
|
2121 |
- * @param {Array} [ignore_keys] |
|
2122 |
- * @param [do_not_overwrite_existing_values] |
|
2123 |
- * @returns {Object} a clone of object1 will be returned |
|
2147 |
+ * @author fenris |
|
2124 | 2148 |
*/ |
2125 |
-/*export*/ var object_merge_objects = function (object1, object2, ignore_keys, do_not_overwrite_existing_values, ignore_null, path) { |
|
2126 |
- if (object1 === void 0) { object1 = null; } |
|
2127 |
- if (object2 === void 0) { object2 = null; } |
|
2128 |
- if (ignore_keys === void 0) { ignore_keys = ["parents"]; } |
|
2129 |
- if (do_not_overwrite_existing_values === void 0) { do_not_overwrite_existing_values = false; } |
|
2130 |
- if (ignore_null === void 0) { ignore_null = false; } |
|
2131 |
- if (path === void 0) { path = []; } |
|
2132 |
- if (object1 == null) { |
|
2133 |
- if (object2 instanceof Array) { |
|
2134 |
- object1 = []; |
|
2149 |
+ function flatten(value) { |
|
2150 |
+ var integrate = function (result, key_, value_) { |
|
2151 |
+ if (value_ == null) { |
|
2152 |
+ result[key_] = value_; |
|
2135 | 2153 |
} |
2136 | 2154 |
else { |
2137 |
- object1 = {}; |
|
2155 |
+ if (typeof (value_) != "object") { |
|
2156 |
+ result[key_] = value_; |
|
2138 | 2157 |
} |
2158 |
+ else { |
|
2159 |
+ var result_1 = flatten(value_); |
|
2160 |
+ Object.keys(result_1).forEach(function (key__) { |
|
2161 |
+ var value__ = result_1[key__]; |
|
2162 |
+ result[key_ + "." + key__] = value__; |
|
2163 |
+ }); |
|
2139 | 2164 |
} |
2140 |
- var iteration_keys = Object.keys(object2); |
|
2141 |
- if (ignore_keys === []) { |
|
2142 |
- if (path.indexOf(object2) >= 0) |
|
2143 |
- return undefined; |
|
2144 |
- path.push(object2); |
|
2145 | 2165 |
} |
2146 |
- // |
|
2147 |
- for (var i = 0; i < iteration_keys.length; i += 1) { |
|
2148 |
- var key = iteration_keys[i]; |
|
2149 |
- if (ignore_keys.some(function (k) { |
|
2150 |
- return key == k; |
|
2151 |
- })) { |
|
2152 |
- // |
|
2166 |
+ }; |
|
2167 |
+ if (value == null) { |
|
2168 |
+ return null; |
|
2153 | 2169 |
} |
2154 |
- else if (object2[key] === null) { |
|
2155 |
- if (!ignore_null) |
|
2156 |
- object1[key] = null; |
|
2170 |
+ else { |
|
2171 |
+ var result_2 = {}; |
|
2172 |
+ if (typeof (value) != "object") { |
|
2173 |
+ result_2["value"] = value; |
|
2157 | 2174 |
} |
2158 |
- else if ((typeof (object2[key]) === "object") && ((typeof (object1[key]) === "object") || (typeof (object1[key]) === "undefined"))) { |
|
2159 |
- object1[key] = object_merge_objects(object1[key], object2[key], ignore_keys, do_not_overwrite_existing_values, ignore_null, path); |
|
2175 |
+ else { |
|
2176 |
+ if (value instanceof Array) { |
|
2177 |
+ var array = (value); |
|
2178 |
+ array.forEach(function (element, index) { return integrate(result_2, "element_" + index, element); }); |
|
2160 | 2179 |
} |
2161 | 2180 |
else { |
2162 |
- if ((do_not_overwrite_existing_values === false) || (typeof (object1[key]) === "undefined")) { |
|
2163 |
- object1[key] = object2[key]; |
|
2181 |
+ var object_1 = (value); |
|
2182 |
+ Object.keys(object_1).forEach(function (key) { return integrate(result_2, key, object_1[key]); }); |
|
2164 | 2183 |
} |
2165 | 2184 |
} |
2185 |
+ return result_2; |
|
2166 | 2186 |
} |
2167 |
- return object1; |
|
2168 |
-}; |
|
2169 |
-/* |
|
2170 |
- * @param {object} recipie ex: { "name" : { extract : function(o) { return o["name"]; }}} |
|
2171 |
- * */ |
|
2172 |
-var flatten_object = function (obj, recipie, drop_key) { |
|
2173 |
- if (drop_key === void 0) { drop_key = (function (k) { return ["parents", "parent", "children"].indexOf(k) > -1; }); } |
|
2174 |
- var ret = {}; |
|
2175 |
- for (var key in recipie) { |
|
2176 |
- if (!drop_key(key)) { |
|
2177 |
- var prefix = (recipie[key].prefix || ""); |
|
2178 |
- var recursive = (recipie[key].recursive || -1); |
|
2179 |
- var extract = (recipie[key].extract || (function (x) { return x; })); |
|
2180 |
- var _obj = extract(obj[key]); |
|
2181 |
- if ((_obj !== null) && ((typeof _obj == "object") || (obj[key] instanceof Array)) && (!(recursive == 0))) { |
|
2182 |
- var tmp = {}; |
|
2183 |
- var _recipie = {}; |
|
2184 |
- for (var _i = 0, _a = Object.keys(_obj); _i < _a.length; _i++) { |
|
2185 |
- var k = _a[_i]; |
|
2186 |
- _recipie[k] = { |
|
2187 |
- "prefix": (prefix + key + "."), |
|
2188 |
- "recursive": (recursive - 1), |
|
2189 |
- "extract": (function (x) { return x; }) |
|
2190 |
- }; |
|
2191 | 2187 |
} |
2192 |
- tmp = flatten_object(_obj, _recipie, drop_key); |
|
2193 |
- ret = object_merge_objects(ret, tmp); |
|
2188 |
+ lib_object.flatten = flatten; |
|
2189 |
+ /** |
|
2190 |
+ * @author fenris |
|
2191 |
+ */ |
|
2192 |
+ function clash(x, y, _a) { |
|
2193 |
+ var _b = _a === void 0 ? {} : _a, _c = _b["overwrite"], overwrite = _c === void 0 ? true : _c, _d = _b["hooks"]["existing"], hook_existing = _d === void 0 ? null : _d; |
|
2194 |
+ if (hook_existing == null) { |
|
2195 |
+ (function (key, value_old, value_new) { return console.warn("field " + key + " already defined"); }); |
|
2194 | 2196 |
} |
2195 |
- else { |
|
2196 |
- ret[prefix + key] = _obj; |
|
2197 |
+ var z = {}; |
|
2198 |
+ Object.keys(x).forEach(function (key) { |
|
2199 |
+ z[key] = x[key]; |
|
2200 |
+ }); |
|
2201 |
+ Object.keys(y).forEach(function (key) { |
|
2202 |
+ if (key in z) { |
|
2203 |
+ hook_existing(key, z[key], y[key]); |
|
2204 |
+ if (overwrite) { |
|
2205 |
+ z[key] = y[key]; |
|
2197 | 2206 |
} |
2198 | 2207 |
} |
2208 |
+ else { |
|
2209 |
+ z[key] = y[key]; |
|
2199 | 2210 |
} |
2200 |
- return ret; |
|
2201 |
-}; |
|
2211 |
+ }); |
|
2212 |
+ return z; |
|
2213 |
+ } |
|
2214 |
+ lib_object.clash = clash; |
|
2202 | 2215 |
/** |
2203 |
- * use the complete path of an objects entry as key to make an one dimensional object |
|
2204 |
- * @param {object} object the object which should be moade flat |
|
2205 |
- * @param {string} [path] for the recursive call the current path |
|
2216 |
+ * @author fenris |
|
2206 | 2217 |
*/ |
2207 |
-/*export*/ var object_make_flat = function (object, path, filter, split_char, objects) { |
|
2218 |
+ function patch(core, mantle, deep, path) { |
|
2219 |
+ if (deep === void 0) { deep = true; } |
|
2208 | 2220 |
if (path === void 0) { path = null; } |
2209 |
- if (filter === void 0) { filter = ["parent", "children"]; } |
|
2210 |
- if (split_char === void 0) { split_char = "."; } |
|
2211 |
- if (objects === void 0) { objects = []; } |
|
2212 |
- if (object.toFlat != undefined) { |
|
2213 |
- return object.toFlat(); |
|
2221 |
+ if (mantle == null) { |
|
2222 |
+ console.warn("mantle is null; core was", core); |
|
2214 | 2223 |
} |
2215 | 2224 |
else { |
2216 |
- var ret = {}; |
|
2217 |
- var default_visited_key = "___visited_path___"; |
|
2218 |
- var visited_key; |
|
2219 |
- if (object != void 0) { |
|
2220 |
- var iterate = function (key) { |
|
2221 |
- var newkey = key; |
|
2222 |
- if ((path != undefined) && (path !== "")) { |
|
2223 |
- newkey = path + split_char + newkey; |
|
2225 |
+ Object.keys(mantle).forEach(function (key) { |
|
2226 |
+ var path_ = ((path == null) ? key : path + "." + key); |
|
2227 |
+ var value_mantle = mantle[key]; |
|
2228 |
+ if (!(key in core)) { |
|
2229 |
+ if ((typeof (value_mantle) == "object") && (value_mantle != null) && deep) { |
|
2230 |
+ if (value_mantle instanceof Array) { |
|
2231 |
+ core[key] = []; |
|
2232 |
+ value_mantle.forEach(function (element) { |
|
2233 |
+ if ((typeof (element) == "object") && (element != null)) { |
|
2234 |
+ var element_ = {}; |
|
2235 |
+ patch(element_, element); |
|
2236 |
+ core[key].push(element_); |
|
2224 | 2237 |
} |
2225 |
- // do not touch objects we alrdy know |
|
2226 |
- if ((obj_ref[key] != undefined) && (!objects.some(function (e) { return (e === obj_ref); }))) { |
|
2227 |
- //if (lib_call.is_def(obj_ref[key]) && (! obj_ref[key].hasOwnProperty(visited_key)) && (key !== visited_key)) { |
|
2228 |
- if (typeof obj_ref[key] === "object") { |
|
2229 |
- ret = object_merge_objects(ret, object_make_flat(obj_ref[key], newkey, filter, split_char, objects.concat(object))); |
|
2238 |
+ else { |
|
2239 |
+ core[key].push(element); |
|
2230 | 2240 |
} |
2231 |
- else if (typeof obj_ref[key] === "function") { |
|
2232 |
- // o.O a function ... doing nothing might be the best choice |
|
2241 |
+ }); |
|
2233 | 2242 |
} |
2234 | 2243 |
else { |
2235 |
- var value = obj_ref[key]; |
|
2236 |
- ret[newkey] = value; |
|
2244 |
+ core[key] = {}; |
|
2245 |
+ patch(core[key], value_mantle, deep, path_); |
|
2237 | 2246 |
} |
2238 | 2247 |
} |
2239 |
- }; |
|
2240 |
- visited_key = default_visited_key; |
|
2241 |
- //object[visited_key] = true; |
|
2242 |
- var obj_ref = object; |
|
2243 |
- Object.keys(object).filter(function (key) { return (filter.indexOf(key) < 0); }).forEach(iterate); |
|
2244 |
- if (typeof object.getComputedValues == "function") { |
|
2245 |
- visited_key = default_visited_key + "_" + Math.random().toString(); |
|
2246 |
- obj_ref = object.getComputedValues(); |
|
2247 |
- obj_ref[visited_key] = true; |
|
2248 |
- Object.keys(obj_ref).filter(function (key) { return (filter.indexOf(key) < 0); }).forEach(iterate); |
|
2248 |
+ else { |
|
2249 |
+ core[key] = value_mantle; |
|
2249 | 2250 |
} |
2250 | 2251 |
} |
2251 | 2252 |
else { |
2252 |
- //console.warn("something went wrong with that object: ", object, "on this path:", path); |
|
2253 |
- } |
|
2254 |
- return ret; |
|
2253 |
+ var value_core = core[key]; |
|
2254 |
+ if (typeof (value_core) == typeof (value_mantle)) { |
|
2255 |
+ if ((typeof (value_mantle) == "object") && (value_mantle != null) && deep) { |
|
2256 |
+ patch(core[key], value_mantle, deep, path_); |
|
2255 | 2257 |
} |
2256 |
-}; |
|
2257 |
-/** |
|
2258 |
- * splits a flat oject into an array of objects if there are paths containing numbers, which indicates |
|
2259 |
- * that there might be an array |
|
2260 |
- * used for normalisation of imports |
|
2261 |
- * @param entry |
|
2262 |
- * @param number_replace_string |
|
2263 |
- * @param {function} [match_function] how to test key if it causes a split |
|
2264 |
- * @returns {Array} |
|
2265 |
- */ |
|
2266 |
-var object_split_flat_object = function (entry, number_replace_string, fab_function, match_function) { |
|
2267 |
- if (typeof (match_function) === "undefined") { |
|
2268 |
- match_function = function (key) { |
|
2269 |
- return (!key.match(/^custom/)) && key.match(/\.[0-9]+\./); |
|
2270 |
- }; |
|
2258 |
+ else { |
|
2259 |
+ core[key] = value_mantle; |
|
2271 | 2260 |
} |
2272 |
- if (typeof (fab_function) === "undefined") { |
|
2273 |
- fab_function = function (obj, e) { |
|
2274 |
- return obj; |
|
2275 |
- }; |
|
2276 | 2261 |
} |
2277 |
- if (typeof (number_replace_string) === "undefined") { |
|
2278 |
- number_replace_string = "%d"; |
|
2262 |
+ else { |
|
2263 |
+ if ((value_core != null) && (value_mantle != null)) { |
|
2264 |
+ var message = "objects have different shapes at path '" + path_ + "'; core has type '" + typeof (value_core) + "' and mantle has type '" + typeof (value_mantle) + "'"; |
|
2265 |
+ console.warn(message); |
|
2279 | 2266 |
} |
2280 |
- var ret = {}; |
|
2281 |
- var _ret = []; |
|
2282 |
- var keys = Object.keys(entry); |
|
2283 |
- var group_keys = keys.filter(match_function); |
|
2284 |
- keys.forEach(function (key) { |
|
2285 |
- var index = 0; |
|
2286 |
- var nkey = key; |
|
2287 |
- if (match_function(key)) { |
|
2288 |
- index = Number(key.match(/[0-9]+/)[0]).valueOf(); |
|
2289 |
- nkey = key.replace(/\.[0-9]+\./, "." + number_replace_string + "."); |
|
2267 |
+ core[key] = value_mantle; |
|
2268 |
+ // throw (new Error(message)); |
|
2290 | 2269 |
} |
2291 |
- if (!ret[index]) { |
|
2292 |
- ret[index] = {}; |
|
2293 | 2270 |
} |
2294 |
- ret[index][nkey] = entry[key]; |
|
2295 | 2271 |
}); |
2296 |
- keys = Object.keys(ret).sort(); |
|
2297 |
- _ret.push(ret[0]); |
|
2298 |
- for (var index = 1; index < keys.length; index++) { |
|
2299 |
- _ret.push(fab_function(ret[keys[index]], entry)); |
|
2300 | 2272 |
} |
2301 |
- _ret[0] = object_merge_objects(_ret[0], ret[0]); |
|
2302 |
- return _ret; |
|
2303 |
-}; |
|
2304 |
-// TODO: move to exporter, it's to specific |
|
2305 |
-// to normalize the objects convert paths of a tree-like structure to a |
|
2306 |
-// key-value list with complete paths as key |
|
2307 |
-// the info object is passed to the next function as it is |
|
2308 |
-// and a flat_object (key : value) |
|
2309 |
-/*export*/ var object_make_flat_async = function (data, callback, on_progress) { |
|
2310 |
- setTimeout((function (_obj, _cb, _info) { |
|
2311 |
- return (function () { |
|
2312 |
- var ret = _obj.map(function (o) { return object_make_flat(o); }); |
|
2313 |
- _cb({ "flat_object": ret, "objects": ret, "info": _info }); |
|
2314 |
- }); |
|
2315 |
- })((typeof (data.processed.objects) === "undefined") ? data.processed.source_object : data.processed.objects, callback, data.processed.info), 0); |
|
2316 |
-}; |
|
2317 |
-var object_flatten = function (object, paths, prefix) { |
|
2318 |
- if (prefix === void 0) { prefix = ""; } |
|
2319 |
- var ret = {}; |
|
2320 |
- var paths_ = paths.reduce(function (prev, current) { |
|
2321 |
- if (current.split(".").some(function (x) { return (x === "%d"); })) { |
|
2322 |
- var path = current.split(".%d").shift(); |
|
2323 |
- var len = object_path_read(object, path).length; |
|
2324 |
- for (var i = 0; i < len; i++) { |
|
2325 |
- // prev.push(sprintf(current, [i])); |
|
2326 |
- prev.push(current.replace(new RegExp("%d"), i.toFixed(0))); |
|
2327 |
- } |
|
2328 |
- } |
|
2329 |
- else { |
|
2330 |
- prev.push(current); |
|
2331 |
- } |
|
2332 |
- return prev; |
|
2333 |
- }, []); |
|
2334 |
- for (var _i = 0, paths_1 = paths_; _i < paths_1.length; _i++) { |
|
2335 |
- var path = paths_1[_i]; |
|
2336 |
- var tmp = object_path_read(object, path, true); |
|
2337 |
- if ((tmp != undefined) && (tmp.toFlat != undefined)) { |
|
2338 |
- var tmp_ = tmp.toFlat([path, "."].join("")); |
|
2339 |
- for (var key in tmp_) { |
|
2340 |
- ret[key] = tmp_[key]; |
|
2341 | 2273 |
} |
2274 |
+ lib_object.patch = patch; |
|
2275 |
+ /** |
|
2276 |
+ * @author fenris |
|
2277 |
+ */ |
|
2278 |
+ function patched(core, mantle, deep) { |
|
2279 |
+ if (deep === void 0) { deep = undefined; } |
|
2280 |
+ var result = {}; |
|
2281 |
+ patch(result, core, deep); |
|
2282 |
+ patch(result, mantle, deep); |
|
2283 |
+ return result; |
|
2342 | 2284 |
} |
2343 |
- else { |
|
2344 |
- ret[prefix + path] = tmp; |
|
2285 |
+ lib_object.patched = patched; |
|
2286 |
+ /** |
|
2287 |
+ * @author fenris |
|
2288 |
+ */ |
|
2289 |
+ function attached(object, key, value) { |
|
2290 |
+ var mantle = {}; |
|
2291 |
+ mantle[key] = value; |
|
2292 |
+ return patched(object, mantle, false); |
|
2345 | 2293 |
} |
2294 |
+ lib_object.attached = attached; |
|
2295 |
+ /** |
|
2296 |
+ * @author fenris |
|
2297 |
+ */ |
|
2298 |
+ function copy(object) { |
|
2299 |
+ return patched({}, object); |
|
2346 | 2300 |
} |
2347 |
- return ret; |
|
2301 |
+ lib_object.copy = copy; |
|
2302 |
+})(lib_object || (lib_object = {})); |
|
2303 |
+/** |
|
2304 |
+ * @desc adapters for old syntax |
|
2305 |
+ * @author fenris |
|
2306 |
+ */ |
|
2307 |
+var object_fetch = lib_object.fetch; |
|
2308 |
+var object_map = lib_object.map; |
|
2309 |
+var object_a2o = lib_object.from_array; |
|
2310 |
+var object_o2a = lib_object.to_array; |
|
2311 |
+var object_matches = lib_object.matches; |
|
2312 |
+var object_clash = lib_object.clash; |
|
2313 |
+///<reference path="../../base/build/logic-decl.d.ts"/> |
|
2314 |
+/** |
|
2315 |
+ * @param {Object} map |
|
2316 |
+ * @return {string} |
|
2317 |
+ * @author frac |
|
2318 |
+ */ |
|
2319 |
+/*export*/ var object_map2string = function (map) { |
|
2320 |
+ return (" " + Object.keys(map) |
|
2321 |
+ .filter(function (key) { return (key != "isMapped"); }) |
|
2322 |
+ .map(function (key) { return ("" + ((map[key] == null) ? "-" : map[key].toString()) + ""); }) |
|
2323 |
+ .join(" ") |
|
2324 |
+ + ""); |
|
2348 | 2325 |
}; |
2349 | 2326 |
/** |
2350 |
- * parse |
|
2351 |
- * @param {String} value |
|
2352 |
- * @returns {Object} |
|
2327 |
+ * @param {Array} array |
|
2328 |
+ * @return {string} |
|
2329 |
+ * @author frac |
|
2353 | 2330 |
*/ |
2354 |
-var object_parse = function (value) { |
|
2355 |
- var content = JSON.parse(value); |
|
2356 |
- var m = { "root": content }; |
|
2357 |
- (new Mapper()).mapClasses(m); |
|
2358 |
- return m["root"]; |
|
2331 |
+/*export*/ var object_array2string = function (array) { |
|
2332 |
+ return ("" + array.map(function (element, index) { |
|
2333 |
+ switch (typeof (element)) { |
|
2334 |
+ case "object": return object_map2string(element); |
|
2335 |
+ default: return String(element); |
|
2336 |
+ } |
|
2337 |
+ }).join(",") + ""); |
|
2359 | 2338 |
}; |
2360 | 2339 |
/** |
2361 |
- * stringify |
|
2362 |
- * |
|
2363 |
- * @description stringify object as JSON |
|
2340 |
+ * @desc follows a path in an object-tree |
|
2341 |
+ * @param {Object} object the object in which the path lies |
|
2342 |
+ * @param {string} path the steps |
|
2343 |
+ * @param {boolean} [create] whether to create not yet existing branches |
|
2344 |
+ * @return {Object} {'successful': successful, 'position': position} where the branch or leaf at the end of the path |
|
2345 |
+ * @author frac |
|
2364 | 2346 |
*/ |
2365 |
-var object_stringify = function (object, readable) { |
|
2366 |
- if (readable === void 0) { readable = false; } |
|
2367 |
- return (JSON.stringify(object, function (key, value) { |
|
2368 |
- if ((key == "parents") && (value !== null)) { |
|
2347 |
+var object_path_walk = function (object, path, create, null_on_missing) { |
|
2348 |
+ if (create === void 0) { create = true; } |
|
2349 |
+ if (null_on_missing === void 0) { null_on_missing = false; } |
|
2350 |
+ var steps = ((path == "") ? [] : path.split(".")); |
|
2351 |
+ if (steps.length == 0) { |
|
2352 |
+ return object; |
|
2353 |
+ } |
|
2354 |
+ else { |
|
2355 |
+ var head = steps[0]; |
|
2356 |
+ // create |
|
2357 |
+ { |
|
2358 |
+ if (!(head in object)) { |
|
2359 |
+ if (create) { |
|
2360 |
+ var value = null; |
|
2361 |
+ if (steps.length >= 2) { |
|
2362 |
+ var next = steps[1]; |
|
2363 |
+ var index = parseInt(next); |
|
2364 |
+ if (!isNaN(index)) { |
|
2365 |
+ value = []; |
|
2366 |
+ } |
|
2367 |
+ else { |
|
2368 |
+ value = {}; |
|
2369 |
+ } |
|
2370 |
+ } |
|
2371 |
+ else { |
|
2372 |
+ value = {}; |
|
2373 |
+ } |
|
2374 |
+ object[head] = value; |
|
2375 |
+ } |
|
2376 |
+ else { |
|
2377 |
+ // console.info("[object_path_walk] object is ", object); |
|
2378 |
+ var message = "[object_path_walk] can not walk step \u00BB" + head + "\u00AB in path \u00BB" + path + "\u00AB on object"; |
|
2379 |
+ if (null_on_missing) { |
|
2380 |
+ console.warn(message); |
|
2369 | 2381 |
return null; |
2370 | 2382 |
} |
2371 |
- if (key == "changeActions") { |
|
2372 |
- return undefined; |
|
2383 |
+ else { |
|
2384 |
+ throw (new Error(message)); |
|
2373 | 2385 |
} |
2374 |
- if (key == "observer") { |
|
2375 |
- return undefined; |
|
2376 | 2386 |
} |
2377 |
- if (key == "isMapped") { |
|
2378 |
- return undefined; |
|
2387 |
+ } |
|
2388 |
+ } |
|
2389 |
+ // execute rest |
|
2390 |
+ { |
|
2391 |
+ var object_ = object[head]; |
|
2392 |
+ var path_ = steps.slice(1).join("."); |
|
2393 |
+ return object_path_walk(object_, path_, create, null_on_missing); |
|
2394 |
+ } |
|
2379 | 2395 |
} |
2380 | 2396 |
/* |
2381 |
- if (value === null) { |
|
2382 |
- return undefined; |
|
2397 |
+ return ( |
|
2398 |
+ string_split(path, ".").reduce( |
|
2399 |
+ function (position : any, step : string) : any { |
|
2400 |
+ if (! lib_call.is_def(position[step], true)) { |
|
2401 |
+ if (create) { |
|
2402 |
+ position[step] = {}; |
|
2403 |
+ } |
|
2404 |
+ else { |
|
2405 |
+ // console.info("[object_path_walk] object is ", object); |
|
2406 |
+ let message : string = sprintf("[object_path_walk] can not walk step »%s« in path »%s« on object", [step, path]); |
|
2407 |
+ if (null_on_missing) { |
|
2408 |
+ console.warn(message); |
|
2409 |
+ return null; |
|
2410 |
+ } |
|
2411 |
+ else { |
|
2412 |
+ throw (new Error(message)); |
|
2413 |
+ } |
|
2414 |
+ } |
|
2383 | 2415 |
} |
2416 |
+ return position[step]; |
|
2417 |
+ }, |
|
2418 |
+ object |
|
2419 |
+ ) |
|
2420 |
+ ); |
|
2384 | 2421 |
*/ |
2385 |
- return value; |
|
2386 |
- }, readable ? 1 : 0)); |
|
2387 |
-}; |
|
2388 |
-var __extends = (this && this.__extends) || (function () { |
|
2389 |
- var extendStatics = Object.setPrototypeOf || |
|
2390 |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
2391 |
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; |
|
2392 |
- return function (d, b) { |
|
2393 |
- extendStatics(d, b); |
|
2394 |
- function __() { this.constructor = d; } |
|
2395 |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
2396 | 2422 |
}; |
2397 |
-})(); |
|
2398 |
-var lib_meta; |
|
2399 |
-(function (lib_meta) { |
|
2400 |
- /** |
|
2401 |
- * @author frac |
|
2402 |
- */ |
|
2403 |
- function type_toString(type) { |
|
2404 |
- // return ("<" + type.id + ">"); |
|
2405 |
- return JSON.stringify(type); |
|
2406 |
- } |
|
2407 |
- lib_meta.type_toString = type_toString; |
|
2408 | 2423 |
/** |
2424 |
+ * @desc reads a branch/leaf from an object-tree |
|
2409 | 2425 |
* @author frac |
2410 | 2426 |
*/ |
2411 |
- var class_pool = {}; |
|
2427 |
+/*export*/ var object_path_read = function (object, path, null_on_missing) { |
|
2428 |
+ if (null_on_missing === void 0) { null_on_missing = false; } |
|
2429 |
+ return object_path_walk(object, path, false, null_on_missing); |
|
2430 |
+}; |
|
2412 | 2431 |
/** |
2432 |
+ * @desc writes a branch/leaf to an object-tree |
|
2413 | 2433 |
* @author frac |
2414 | 2434 |
*/ |
2415 |
- function class_set(name, class_) { |
|
2416 |
- class_pool[name] = class_; |
|
2435 |
+/*export*/ var object_path_write = function (object, path, value) { |
|
2436 |
+ // for "initializing" the object (important if the value to write is an entry in a yet not existing array) |
|
2437 |
+ /*let old : any = */ object_path_walk(object, path, true, true); |
|
2438 |
+ var steps = ((path == "") ? [] : path.split(".")); |
|
2439 |
+ var position = object_path_walk(object, steps.slice(0, steps.length - 1).join("."), true); |
|
2440 |
+ if (position == undefined) { |
|
2441 |
+ console.warn("can't set \u00BB" + steps[steps.length - 1] + "\u00AB in undefined"); |
|
2417 | 2442 |
} |
2418 |
- lib_meta.class_set = class_set; |
|
2419 |
- /** |
|
2420 |
- * @author frac |
|
2421 |
- */ |
|
2422 |
- function class_get(name) { |
|
2423 |
- if (name in class_pool) { |
|
2424 |
- return class_pool[name]; |
|
2443 |
+ else { |
|
2444 |
+ position[steps[steps.length - 1]] = value; |
|
2445 |
+ } |
|
2446 |
+}; |
|
2447 |
+/*export*/ var object_object_path_write_ex = function (obj, path, val) { |
|
2448 |
+ var ref = obj; |
|
2449 |
+ var paths = path.split("."); |
|
2450 |
+ var i; |
|
2451 |
+ for (i = 0; i < paths.length - 1; i++) { |
|
2452 |
+ if (ref[paths[i]] === void 0) { |
|
2453 |
+ if (/^(0|[1-9][0-9]*)$/.test(paths[i + 1])) { |
|
2454 |
+ ref[paths[i]] = []; |
|
2425 | 2455 |
} |
2426 | 2456 |
else { |
2427 |
- throw (new Error("no class registered for name '" + name + "'")); |
|
2457 |
+ ref[paths[i]] = {}; |
|
2428 | 2458 |
} |
2429 | 2459 |
} |
2430 |
- lib_meta.class_get = class_get; |
|
2460 |
+ ref = ref[paths[i]]; |
|
2461 |
+ } |
|
2462 |
+ ref[paths[i]] = val; |
|
2463 |
+}; |
|
2431 | 2464 |
/** |
2465 |
+ * @desc filters branches from an object |
|
2466 |
+ * @param {Object} object the object to read from |
|
2467 |
+ * @param {Array} paths a list of string-lists, that are the paths to be propagated |
|
2468 |
+ * @return {Object} the object with only the selected branches |
|
2432 | 2469 |
* @author frac |
2433 | 2470 |
*/ |
2434 |
- function transform_field(name, attributes) { |
|
2435 |
- var type = attributes["type"]; |
|
2436 |
- var path = name; |
|
2437 |
- var label = ((attributes["title"] != undefined) ? attributes["title"] : name); |
|
2438 |
- var display = ((attributes["display"] != undefined) ? attributes["display"] : true); |
|
2439 |
- return ({ |
|
2440 |
- "path": path, |
|
2441 |
- "type": type, |
|
2442 |
- "label": label, |
|
2443 |
- "display": display |
|
2444 |
- }); |
|
2445 |
- } |
|
2446 |
- lib_meta.transform_field = transform_field; |
|
2447 |
- /** |
|
2448 |
- * @author frac |
|
2449 |
- */ |
|
2450 |
- function transform_description(label, description, groups_raw) { |
|
2451 |
- if (groups_raw === void 0) { groups_raw = null; } |
|
2452 |
- var fieldmap; |
|
2453 |
- var fields = Object.keys(description).map(function (key) { return transform_field(key, description[key]); }); |
|
2454 |
- var groups = ((groups_raw == null) |
|
2455 |
- ? |
|
2456 |
- null |
|
2457 |
- : |
|
2458 |
- groups_raw.map(function (group_raw) { |
|
2459 |
- return { |
|
2460 |
- "label": group_raw["label"], |
|
2461 |
- "fields": group_raw["fields"].map(function (field_name) { |
|
2462 |
- var index = fields["findIndex"](function (field) { return (field.path == field_name); }); |
|
2463 |
- if (index < 0) { |
|
2464 |
- throw (new Error("field " + field_name + " not found in model-description")); |
|
2465 |
- } |
|
2466 |
- return index; |
|
2467 |
- }) |
|
2468 |
- }; |
|
2469 |
- })); |
|
2470 |
- return { |
|
2471 |
- "fields": fields, |
|
2472 |
- "description": null, |
|
2473 |
- "title": label, |
|
2474 |
- "groups": groups |
|
2475 |
- }; |
|
2471 |
+/*export*/ var object_path_filter = function (object, paths) { |
|
2472 |
+ var result = {}; |
|
2473 |
+ paths.forEach(function (path) { |
|
2474 |
+ var value = null; |
|
2475 |
+ try { |
|
2476 |
+ value = object_path_read(object, path); |
|
2476 | 2477 |
} |
2477 |
- lib_meta.transform_description = transform_description; |
|
2478 |
- /** |
|
2479 |
- * @author frac |
|
2480 |
- */ |
|
2481 |
- function transform_description_groups(label, description_model, description_groups) { |
|
2482 |
- return ({ |
|
2483 |
- "label": label, |
|
2484 |
- "groups": description_groups.map(function (group_raw) { |
|
2485 |
- return { |
|
2486 |
- "label": group_raw["label"], |
|
2487 |
- "fields": group_raw["fields"].map(function (path) { |
|
2488 |
- var field_raw = description_model[path]; |
|
2489 |
- return transform_field(path, field_raw); |
|
2490 |
- }) |
|
2491 |
- }; |
|
2492 |
- }) |
|
2493 |
- }); |
|
2478 |
+ catch (exception) { |
|
2479 |
+ console.warn(exception); |
|
2494 | 2480 |
} |
2495 |
- lib_meta.transform_description_groups = transform_description_groups; |
|
2496 |
-})(lib_meta || (lib_meta = {})); |
|
2497 |
-/// <reference path="../../base/build/logic-decl.d.ts"/> |
|
2498 |
-/// <reference path="../../object/build/logic-decl.d.ts"/> |
|
2499 |
-var lib_meta; |
|
2500 |
-(function (lib_meta) { |
|
2501 |
- /** |
|
2502 |
- * @author fenris |
|
2503 |
- */ |
|
2504 |
- lib_meta._logprefix = "[lib_meta] "; |
|
2505 |
- /** |
|
2506 |
- * @author fenris |
|
2507 |
- */ |
|
2508 |
- lib_meta._verbosity = 1; |
|
2509 |
-})(lib_meta || (lib_meta = {})); |
|
2510 |
-var lib_meta; |
|
2511 |
-(function (lib_meta) { |
|
2512 |
- /** |
|
2513 |
- * @author fenris |
|
2514 |
- */ |
|
2515 |
- var class_shape = (function () { |
|
2516 |
- /** |
|
2517 |
- * @desc [constructor] |
|
2518 |
- * @author fenris |
|
2519 |
- */ |
|
2520 |
- function class_shape(_a) { |
|
2521 |
- var _b = _a["primitive"], primitive = _b === void 0 ? false : _b, _c = _a["soft"], soft = _c === void 0 ? true : _c, _d = _a["defaultvalue"], defaultvalue = _d === void 0 ? null : _d; |
|
2522 |
- /* |
|
2523 |
- if ((! soft) && (defaultvalue == null)) { |
|
2524 |
- throw (new Error("'null' is not a valid defaultvalue for hard shapes")); |
|
2481 |
+ if (value != null) { |
|
2482 |
+ object_path_write(result, path, value); |
|
2525 | 2483 |
} |
2526 |
- */ |
|
2527 |
- this.primitive = primitive; |
|
2528 |
- this.soft = soft; |
|
2529 |
- this.defaultvalue = defaultvalue; |
|
2484 |
+ else { |
|
2485 |
+ console.warn("skipped path \"" + path + "\" while filtering"); |
|
2530 | 2486 |
} |
2531 |
- /** |
|
2532 |
- * @desc [accessor] [getter] |
|
2533 |
- * @author fenris |
|
2534 |
- */ |
|
2535 |
- class_shape.prototype.primitive_get = function () { |
|
2536 |
- return this.primitive; |
|
2537 |
- }; |
|
2538 |
- /** |
|
2539 |
- * @desc [accessor] [getter] |
|
2540 |
- * @author fenris |
|
2541 |
- */ |
|
2542 |
- class_shape.prototype.soft_get = function () { |
|
2543 |
- return this.soft; |
|
2544 |
- }; |
|
2545 |
- /** |
|
2546 |
- * @desc [accessor] [getter] |
|
2547 |
- * @author fenris |
|
2548 |
- */ |
|
2549 |
- class_shape.prototype.defaultvalue_get = function () { |
|
2550 |
- return this.defaultvalue; |
|
2487 |
+ }); |
|
2488 |
+ return result; |
|
2551 | 2489 |
}; |
2552 | 2490 |
/** |
2553 |
- * @desc [accessor] |
|
2554 |
- * @author fenris |
|
2491 |
+ * @desc dunno… returns a list of object-paths? |
|
2492 |
+ * @param {Object} object |
|
2493 |
+ * @param {string} p |
|
2494 |
+ * @todo can probably be merged with getLeafg |
|
2555 | 2495 |
*/ |
2556 |
- class_shape.prototype.inspect = function (value) { |
|
2557 |
- var messages = []; |
|
2558 |
- if ((!this.soft) && (value == null)) { |
|
2559 |
- messages.push("shape does not allow 'null' as value"); |
|
2496 |
+/*export*/ var object_path_list = function (object, path, visited) { |
|
2497 |
+ if (path === void 0) { path = null; } |
|
2498 |
+ if (visited === void 0) { visited = []; } |
|
2499 |
+ var result = []; |
|
2500 |
+ visited.push(object); |
|
2501 |
+ for (var key in object) { |
|
2502 |
+ var value = object[key]; |
|
2503 |
+ if (visited.indexOf(value) === -1) { |
|
2504 |
+ var key_ = (path == null) ? key : (path + "." + key); |
|
2505 |
+ if (typeof (value) === "object") { |
|
2506 |
+ result = result.concat(object_path_list(value, key_, visited)); |
|
2560 | 2507 |
} |
2561 |
- return messages; |
|
2562 |
- }; |
|
2563 |
- /** |
|
2564 |
- * @desc [accessor] |
|
2565 |
- * @author fenris |
|
2566 |
- */ |
|
2567 |
- class_shape.prototype.check = function (value) { |
|
2568 |
- var messages = this.inspect(value); |
|
2569 |
- if (lib_meta._verbosity >= 1) { |
|
2570 |
- messages.forEach(function (message) { return console.warn("" + lib_meta._logprefix + message); }); |
|
2508 |
+ else { |
|
2509 |
+ result.push({ "key": key_, "value": value }); |
|
2571 | 2510 |
} |
2572 |
- return (messages.length == 0); |
|
2573 |
- }; |
|
2574 |
- return class_shape; |
|
2575 |
- }()); |
|
2576 |
- lib_meta.class_shape = class_shape; |
|
2577 |
- /** |
|
2578 |
- * @author fenris |
|
2579 |
- */ |
|
2580 |
- var class_shape_buildin = (function (_super) { |
|
2581 |
- __extends(class_shape_buildin, _super); |
|
2582 |
- /** |
|
2583 |
- * @author fenris |
|
2584 |
- */ |
|
2585 |
- function class_shape_buildin(_a) { |
|
2586 |
- var typename = _a["typename"], _b = _a["primitive"], primitive = _b === void 0 ? undefined : _b, _c = _a["soft"], soft = _c === void 0 ? undefined : _c, _d = _a["defaultvalue"], defaultvalue = _d === void 0 ? undefined : _d; |
|
2587 |
- var _this = _super.call(this, { |
|
2588 |
- "primitive": primitive, |
|
2589 |
- "soft": soft, |
|
2590 |
- "defaultvalue": defaultvalue |
|
2591 |
- }) || this; |
|
2592 |
- _this.typename = typename; |
|
2593 |
- return _this; |
|
2594 | 2511 |
} |
2595 |
- /** |
|
2596 |
- * @override |
|
2597 |
- * @author fenris |
|
2598 |
- */ |
|
2599 |
- class_shape_buildin.prototype.inspect = function (value) { |
|
2600 |
- var messages = _super.prototype.inspect.call(this, value); |
|
2601 |
- if ((!this.soft) && (typeof (value) != this.typename)) { |
|
2602 |
- messages.push("typename is not '" + this.typename + "'"); |
|
2603 | 2512 |
} |
2604 |
- return messages; |
|
2513 |
+ return result; |
|
2605 | 2514 |
}; |
2606 | 2515 |
/** |
2607 |
- * @desc [implementation] |
|
2608 |
- * @author fenris |
|
2516 |
+ * theroreticaly loop prof walk through all elements and subelements of an object |
|
2517 |
+ * and call a callback for each entry |
|
2518 |
+ * @param {object} obj object to iterate through |
|
2519 |
+ * @param {function} callback |
|
2609 | 2520 |
*/ |
2610 |
- class_shape_buildin.prototype._show = function () { |
|
2611 |
- var str = ""; |
|
2612 |
- str = this.typename; |
|
2613 |
- if (!this.soft) { |
|
2614 |
- str = str + "_or_null"; |
|
2615 |
- } |
|
2616 |
- return str; |
|
2521 |
+/*export*/ var object_iterate = function (obj, callback, leafs_only, path, visited) { |
|
2522 |
+ if (leafs_only === void 0) { leafs_only = false; } |
|
2523 |
+ if (visited === void 0) { visited = []; } |
|
2524 |
+ var have_seen = function (ob) { |
|
2525 |
+ return visited.some(function (e) { return ((typeof (ob) === "object") && (ob !== null) && (e === ob)); }); |
|
2617 | 2526 |
}; |
2618 |
- return class_shape_buildin; |
|
2619 |
- }(class_shape)); |
|
2620 |
- lib_meta.class_shape_buildin = class_shape_buildin; |
|
2621 |
- /** |
|
2622 |
- * @author fenris |
|
2623 |
- */ |
|
2624 |
- var _pool = {}; |
|
2625 |
- /** |
|
2626 |
- * @author fenris |
|
2627 |
- */ |
|
2628 |
- function register(id, factory) { |
|
2629 |
- if (id in _pool) { |
|
2630 |
- var message = "shape '" + id + "' already registered"; |
|
2631 |
- throw (new Error(message)); |
|
2527 |
+ var next = []; |
|
2528 |
+ Object.keys(obj).forEach(function (key) { |
|
2529 |
+ var elem = obj[key]; |
|
2530 |
+ if (!have_seen(elem)) { |
|
2531 |
+ visited.push(elem); |
|
2532 |
+ var _path = ""; |
|
2533 |
+ if (typeof path === "undefined") { |
|
2534 |
+ _path = key; |
|
2632 | 2535 |
} |
2633 | 2536 |
else { |
2634 |
- _pool[id] = factory; |
|
2635 |
- } |
|
2537 |
+ _path += [path, key].join("."); |
|
2636 | 2538 |
} |
2637 |
- lib_meta.register = register; |
|
2638 |
- /** |
|
2639 |
- * @author fenris |
|
2640 |
- */ |
|
2641 |
- function construct(id, parameters) { |
|
2642 |
- if (parameters === void 0) { parameters = {}; } |
|
2643 |
- if (!(id in _pool)) { |
|
2644 |
- var message = "no shape found with id " + id; |
|
2645 |
- throw (new Error(message)); |
|
2539 |
+ if (!leafs_only) |
|
2540 |
+ callback(_path, elem, key); |
|
2541 |
+ if (typeof (elem) === "object") { |
|
2542 |
+ (function (elem_, callback_, _path_, visited_) { |
|
2543 |
+ next.push(function () { object_iterate(elem_, callback_, leafs_only, _path_, visited_); }); |
|
2544 |
+ })(elem, callback, _path, visited); |
|
2646 | 2545 |
} |
2647 | 2546 |
else { |
2648 |
- return _pool[id](parameters); |
|
2547 |
+ if (leafs_only) |
|
2548 |
+ callback(_path, elem, key); |
|
2649 | 2549 |
} |
2650 | 2550 |
} |
2651 |
- lib_meta.construct = construct; |
|
2652 |
- /** |
|
2653 |
- * @author fenris |
|
2654 |
- */ |
|
2655 |
- function from_raw(shape_raw) { |
|
2656 |
- return construct(shape_raw.id, shape_raw.parameters); |
|
2551 |
+ }); |
|
2552 |
+ var func; |
|
2553 |
+ while (func = next.shift()) { |
|
2554 |
+ func(); |
|
2657 | 2555 |
} |
2658 |
- lib_meta.from_raw = from_raw; |
|
2556 |
+}; |
|
2659 | 2557 |
/** |
2660 |
- * @author fenris |
|
2558 |
+ * @desc get the leaf-nodes of an object |
|
2559 |
+ * @param {object} object |
|
2560 |
+ * @return {Array<string>} a list containing all leaf-nodes |
|
2561 |
+ * @author frac |
|
2661 | 2562 |
*/ |
2662 |
- function define(id, shape_raw) { |
|
2663 |
- register(id, function (parameters) { return from_raw(shape_raw); }); |
|
2563 |
+/*export*/ var getLeafs = function (object) { |
|
2564 |
+ var skip = { |
|
2565 |
+ "className": true, |
|
2566 |
+ "timeStamp": true, |
|
2567 |
+ "parentId": true, |
|
2568 |
+ "transactionID": true, |
|
2569 |
+ "guid": true, |
|
2570 |
+ "_id": true, |
|
2571 |
+ "parents": true, |
|
2572 |
+ "children": true |
|
2573 |
+ }; |
|
2574 |
+ return (Object.keys(object).reduce(function (leafs, key) { |
|
2575 |
+ try { |
|
2576 |
+ var value = object[key]; |
|
2577 |
+ if (key in skip) { |
|
2578 |
+ console.warn("skipping field \"" + key + "\""); |
|
2579 |
+ return leafs; |
|
2664 | 2580 |
} |
2665 |
- lib_meta.define = define; |
|
2666 |
- /** |
|
2667 |
- * @author fenris |
|
2668 |
- */ |
|
2669 |
- function retrieve(id) { |
|
2670 |
- return construct(id, {}); |
|
2581 |
+ else { |
|
2582 |
+ if ((typeof (value) === "object") && (value != null)) { |
|
2583 |
+ return leafs.concat(getLeafs(value).map(function (leaf) { return (key + "." + leaf); })); |
|
2671 | 2584 |
} |
2672 |
- lib_meta.retrieve = retrieve; |
|
2673 |
-})(lib_meta || (lib_meta = {})); |
|
2674 |
-var lib_meta; |
|
2675 |
-(function (lib_meta) { |
|
2676 |
- /** |
|
2677 |
- * @author fenris |
|
2678 |
- */ |
|
2679 |
- var class_shape_boolean = (function (_super) { |
|
2680 |
- __extends(class_shape_boolean, _super); |
|
2681 |
- /** |
|
2682 |
- * @author fenris |
|
2683 |
- */ |
|
2684 |
- function class_shape_boolean(_a) { |
|
2685 |
- var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? false : _c; |
|
2686 |
- return _super.call(this, { |
|
2687 |
- "typename": "boolean", |
|
2688 |
- "primitive": true, |
|
2689 |
- "soft": soft, |
|
2690 |
- "defaultvalue": defaultvalue |
|
2691 |
- }) || this; |
|
2585 |
+ else { |
|
2586 |
+ return leafs.concat([key]); |
|
2692 | 2587 |
} |
2693 |
- /** |
|
2694 |
- * @override |
|
2695 |
- * @author fenris |
|
2696 |
- */ |
|
2697 |
- class_shape_boolean.prototype.to_raw = function () { |
|
2698 |
- return { |
|
2699 |
- "id": "boolean", |
|
2700 |
- "parameters": { |
|
2701 |
- "soft": this.soft |
|
2702 | 2588 |
} |
2703 |
- }; |
|
2704 |
- }; |
|
2705 |
- return class_shape_boolean; |
|
2706 |
- }(lib_meta.class_shape_buildin)); |
|
2707 |
- lib_meta.class_shape_boolean = class_shape_boolean; |
|
2708 |
- lib_meta.register("boolean", function (parameters) { |
|
2709 |
- return (new class_shape_boolean({ |
|
2710 |
- "soft": parameters["soft"] |
|
2711 |
- })); |
|
2712 |
- }); |
|
2713 |
- lib_meta.register("bool", function (parameters) { return lib_meta.construct("boolean", parameters); }); |
|
2714 |
-})(lib_meta || (lib_meta = {})); |
|
2715 |
-var lib_meta; |
|
2716 |
-(function (lib_meta) { |
|
2717 |
- /** |
|
2718 |
- * @author fenris |
|
2719 |
- */ |
|
2720 |
- var class_shape_integer = (function (_super) { |
|
2721 |
- __extends(class_shape_integer, _super); |
|
2722 |
- /** |
|
2723 |
- * @author fenris |
|
2724 |
- */ |
|
2725 |
- function class_shape_integer(_a) { |
|
2726 |
- var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? 0 : _c, _d = _a["min"], min = _d === void 0 ? null : _d, _e = _a["max"], max = _e === void 0 ? null : _e; |
|
2727 |
- var _this = _super.call(this, { |
|
2728 |
- "typename": "number", |
|
2729 |
- "primitive": true, |
|
2730 |
- "soft": soft, |
|
2731 |
- "defaultvalue": defaultvalue |
|
2732 |
- }) || this; |
|
2733 |
- _this.min = min; |
|
2734 |
- _this.max = max; |
|
2735 |
- return _this; |
|
2736 | 2589 |
} |
2737 |
- /** |
|
2738 |
- * @desc [accessor] [getter] |
|
2739 |
- * @author fenris |
|
2740 |
- */ |
|
2741 |
- class_shape_integer.prototype.min_get = function () { |
|
2742 |
- return this.min; |
|
2743 |
- }; |
|
2744 |
- /** |
|
2745 |
- * @desc [accessor] [getter] |
|
2746 |
- * @author fenris |
|
2747 |
- */ |
|
2748 |
- class_shape_integer.prototype.max_get = function () { |
|
2749 |
- return this.max; |
|
2590 |
+ catch (exception) { |
|
2591 |
+ console.warn(exception); |
|
2592 |
+ console.info("key: ", key); |
|
2593 |
+ return null; |
|
2594 |
+ } |
|
2595 |
+ }, new Array())); |
|
2750 | 2596 |
}; |
2751 | 2597 |
/** |
2752 |
- * @override |
|
2753 |
- * @author fenris |
|
2598 |
+ * |
|
2599 |
+ * @desc merges two arrays by probing |
|
2600 |
+ * @param {Array} core |
|
2601 |
+ * @param {Array} mantle |
|
2602 |
+ * @param {function} match |
|
2754 | 2603 |
*/ |
2755 |
- class_shape_integer.prototype.inspect = function (value) { |
|
2756 |
- var messages = _super.prototype.inspect.call(this, value); |
|
2757 |
- if (value != null) { |
|
2758 |
- if ((this.min != null) && (value < this.min)) { |
|
2759 |
- messages.push("value is below minimum of " + this.min.toString()); |
|
2760 |
- } |
|
2761 |
- if ((this.max != null) && (value > this.max)) { |
|
2762 |
- messages.push("value is over maximum of " + this.max.toString()); |
|
2604 |
+/*export*/ var merge_array = function (core, mantle, match) { |
|
2605 |
+ if (match === void 0) { match = (function (x, y) { return (x === y); }); } |
|
2606 |
+ if ((core == undefined) || (mantle == undefined)) { |
|
2607 |
+ throw (new Error("Error: " |
|
2608 |
+ + ((core == undefined) ? " core must be an array and not '" + typeof (core) + "'" : "") |
|
2609 |
+ + ((mantle == undefined) ? " mantle must be an array and not '" + typeof (mantle) + "'" : ""))); |
|
2763 | 2610 |
} |
2611 |
+ var ret = core; |
|
2612 |
+ for (var i = 0; i < mantle.length; i++) { |
|
2613 |
+ var entry = mantle[i]; |
|
2614 |
+ try { |
|
2615 |
+ var matching_index = core.find(function (element) { return match(element, entry); }); |
|
2616 |
+ ret[matching_index] = object_merge_objects(core[matching_index], entry); |
|
2764 | 2617 |
} |
2765 |
- return messages; |
|
2766 |
- }; |
|
2767 |
- /** |
|
2768 |
- * @override |
|
2769 |
- * @author fenris |
|
2770 |
- */ |
|
2771 |
- class_shape_integer.prototype.to_raw = function () { |
|
2772 |
- return { |
|
2773 |
- "id": "integer", |
|
2774 |
- "parameters": { |
|
2775 |
- "soft": this.soft, |
|
2776 |
- "min": this.min, |
|
2777 |
- "max": this.max |
|
2618 |
+ catch (e) { |
|
2619 |
+ ret.push(entry); |
|
2778 | 2620 |
} |
2779 |
- }; |
|
2780 |
- }; |
|
2781 |
- return class_shape_integer; |
|
2782 |
- }(lib_meta.class_shape_buildin)); |
|
2783 |
- lib_meta.class_shape_integer = class_shape_integer; |
|
2784 |
- lib_meta.register("integer", function (parameters) { |
|
2785 |
- return (new class_shape_integer({ |
|
2786 |
- "min": parameters["min"], |
|
2787 |
- "max": parameters["max"], |
|
2788 |
- "soft": parameters["soft"] |
|
2789 |
- })); |
|
2790 |
- }); |
|
2791 |
- lib_meta.register("int", function (parameters) { return lib_meta.construct("integer", parameters); }); |
|
2792 |
-})(lib_meta || (lib_meta = {})); |
|
2793 |
-var lib_meta; |
|
2794 |
-(function (lib_meta) { |
|
2795 |
- /** |
|
2796 |
- * @author fenris |
|
2797 |
- */ |
|
2798 |
- var class_shape_float = (function (_super) { |
|
2799 |
- __extends(class_shape_float, _super); |
|
2800 |
- /** |
|
2801 |
- * @author fenris |
|
2802 |
- */ |
|
2803 |
- function class_shape_float(_a) { |
|
2804 |
- var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? 0.0 : _c, _d = _a["min"], min = _d === void 0 ? null : _d, _e = _a["max"], max = _e === void 0 ? null : _e; |
|
2805 |
- var _this = _super.call(this, { |
|
2806 |
- "typename": "number", |
|
2807 |
- "primitive": true, |
|
2808 |
- "soft": soft, |
|
2809 |
- "defaultvalue": defaultvalue |
|
2810 |
- }) || this; |
|
2811 |
- _this.min = min; |
|
2812 |
- _this.max = max; |
|
2813 |
- return _this; |
|
2814 | 2621 |
} |
2815 |
- /** |
|
2816 |
- * @desc [accessor] [getter] |
|
2817 |
- * @author fenris |
|
2818 |
- */ |
|
2819 |
- class_shape_float.prototype.min_get = function () { |
|
2820 |
- return this.min; |
|
2821 |
- }; |
|
2822 |
- /** |
|
2823 |
- * @desc [accessor] [getter] |
|
2824 |
- * @author fenris |
|
2825 |
- */ |
|
2826 |
- class_shape_float.prototype.max_get = function () { |
|
2827 |
- return this.max; |
|
2622 |
+ return ret; |
|
2828 | 2623 |
}; |
2829 | 2624 |
/** |
2830 |
- * @override |
|
2831 |
- * @author fenris |
|
2625 |
+ * @desc merges two objects recursivly |
|
2626 |
+ * @param {Object} object1 core |
|
2627 |
+ * @param {Object} object2 mantle |
|
2628 |
+ * @param {Array} [ignore_keys] |
|
2629 |
+ * @param [do_not_overwrite_existing_values] |
|
2630 |
+ * @returns {Object} a clone of object1 will be returned |
|
2832 | 2631 |
*/ |
2833 |
- class_shape_float.prototype.inspect = function (value) { |
|
2834 |
- var messages = _super.prototype.inspect.call(this, value); |
|
2835 |
- if (value != null) { |
|
2836 |
- if ((this.min != null) && (value < this.min)) { |
|
2837 |
- messages.push("value is below minimum of " + this.min.toString()); |
|
2632 |
+/*export*/ var object_merge_objects = function (object1, object2, ignore_keys, do_not_overwrite_existing_values, ignore_null, path) { |
|
2633 |
+ if (object1 === void 0) { object1 = null; } |
|
2634 |
+ if (object2 === void 0) { object2 = null; } |
|
2635 |
+ if (ignore_keys === void 0) { ignore_keys = ["parents"]; } |
|
2636 |
+ if (do_not_overwrite_existing_values === void 0) { do_not_overwrite_existing_values = false; } |
|
2637 |
+ if (ignore_null === void 0) { ignore_null = false; } |
|
2638 |
+ if (path === void 0) { path = []; } |
|
2639 |
+ if (object1 == null) { |
|
2640 |
+ if (object2 instanceof Array) { |
|
2641 |
+ object1 = []; |
|
2838 | 2642 |
} |
2839 |
- if ((this.max != null) && (value > this.max)) { |
|
2840 |
- messages.push("value is over maximum of " + this.max.toString()); |
|
2643 |
+ else { |
|
2644 |
+ object1 = {}; |
|
2841 | 2645 |
} |
2842 | 2646 |
} |
2843 |
- return messages; |
|
2844 |
- }; |
|
2845 |
- /** |
|
2846 |
- * @override |
|
2847 |
- * @author fenris |
|
2848 |
- */ |
|
2849 |
- class_shape_float.prototype.to_raw = function () { |
|
2850 |
- return { |
|
2851 |
- "id": "float", |
|
2852 |
- "parameters": { |
|
2853 |
- "soft": this.soft, |
|
2854 |
- "min": this.min, |
|
2855 |
- "max": this.max |
|
2647 |
+ var iteration_keys = Object.keys(object2); |
|
2648 |
+ if (ignore_keys === []) { |
|
2649 |
+ if (path.indexOf(object2) >= 0) |
|
2650 |
+ return undefined; |
|
2651 |
+ path.push(object2); |
|
2856 | 2652 |
} |
2857 |
- }; |
|
2858 |
- }; |
|
2859 |
- return class_shape_float; |
|
2860 |
- }(lib_meta.class_shape_buildin)); |
|
2861 |
- lib_meta.class_shape_float = class_shape_float; |
|
2862 |
- lib_meta.register("float", function (parameters) { |
|
2863 |
- return (new class_shape_float({ |
|
2864 |
- "min": parameters["min"], |
|
2865 |
- "max": parameters["max"], |
|
2866 |
- "soft": parameters["soft"] |
|
2867 |
- })); |
|
2868 |
- }); |
|
2869 |
-})(lib_meta || (lib_meta = {})); |
|
2870 |
-var lib_meta; |
|
2871 |
-(function (lib_meta) { |
|
2872 |
- /** |
|
2873 |
- * @author fenris |
|
2874 |
- */ |
|
2875 |
- var class_shape_string = (function (_super) { |
|
2876 |
- __extends(class_shape_string, _super); |
|
2877 |
- /** |
|
2878 |
- * @author fenris |
|
2879 |
- */ |
|
2880 |
- function class_shape_string(_a) { |
|
2881 |
- var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? "" : _c; |
|
2882 |
- return _super.call(this, { |
|
2883 |
- "typename": "string", |
|
2884 |
- "primitive": true, |
|
2885 |
- "soft": soft, |
|
2886 |
- "defaultvalue": defaultvalue |
|
2887 |
- }) || this; |
|
2653 |
+ // |
|
2654 |
+ for (var i = 0; i < iteration_keys.length; i += 1) { |
|
2655 |
+ var key = iteration_keys[i]; |
|
2656 |
+ if (ignore_keys.some(function (k) { |
|
2657 |
+ return key == k; |
|
2658 |
+ })) { |
|
2659 |
+ // |
|
2888 | 2660 |
} |
2889 |
- /** |
|
2890 |
- * @override |
|
2891 |
- * @author fenris |
|
2892 |
- */ |
|
2893 |
- class_shape_string.prototype.to_raw = function () { |
|
2894 |
- return { |
|
2895 |
- "id": "string", |
|
2896 |
- "parameters": { |
|
2897 |
- "soft": this.soft |
|
2661 |
+ else if (object2[key] === null) { |
|
2662 |
+ if (!ignore_null) |
|
2663 |
+ object1[key] = null; |
|
2898 | 2664 |
} |
2899 |
- }; |
|
2900 |
- }; |
|
2901 |
- return class_shape_string; |
|
2902 |
- }(lib_meta.class_shape_buildin)); |
|
2903 |
- lib_meta.class_shape_string = class_shape_string; |
|
2904 |
- lib_meta.register("string", function (parameters) { |
|
2905 |
- return (new class_shape_string({ |
|
2906 |
- "soft": parameters["soft"] |
|
2907 |
- })); |
|
2908 |
- }); |
|
2909 |
- lib_meta.register("str", function (parameters) { return lib_meta.construct("string", parameters); }); |
|
2910 |
-})(lib_meta || (lib_meta = {})); |
|
2911 |
-var lib_meta; |
|
2912 |
-(function (lib_meta) { |
|
2913 |
- /** |
|
2914 |
- * @author fenris |
|
2915 |
- */ |
|
2916 |
- var class_shape_email = (function (_super) { |
|
2917 |
- __extends(class_shape_email, _super); |
|
2918 |
- /** |
|
2919 |
- * @author fenris |
|
2920 |
- */ |
|
2921 |
- function class_shape_email(_a) { |
|
2922 |
- var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? "" : _c; |
|
2923 |
- return _super.call(this, { |
|
2924 |
- "primitive": true, |
|
2925 |
- "soft": soft, |
|
2926 |
- "defaultvalue": defaultvalue |
|
2927 |
- }) || this; |
|
2665 |
+ else if ((typeof (object2[key]) === "object") && ((typeof (object1[key]) === "object") || (typeof (object1[key]) === "undefined"))) { |
|
2666 |
+ object1[key] = object_merge_objects(object1[key], object2[key], ignore_keys, do_not_overwrite_existing_values, ignore_null, path); |
|
2928 | 2667 |
} |
2929 |
- /** |
|
2930 |
- * @override |
|
2931 |
- * @author fenris |
|
2932 |
- */ |
|
2933 |
- class_shape_email.prototype.to_raw = function () { |
|
2934 |
- return { |
|
2935 |
- "id": "email", |
|
2936 |
- "parameters": { |
|
2937 |
- "soft": this.soft |
|
2668 |
+ else { |
|
2669 |
+ if ((do_not_overwrite_existing_values === false) || (typeof (object1[key]) === "undefined")) { |
|
2670 |
+ object1[key] = object2[key]; |
|
2938 | 2671 |
} |
2672 |
+ } |
|
2673 |
+ } |
|
2674 |
+ return object1; |
|
2939 | 2675 |
}; |
2676 |
+/* |
|
2677 |
+ * @param {object} recipie ex: { "name" : { extract : function(o) { return o["name"]; }}} |
|
2678 |
+ * */ |
|
2679 |
+var flatten_object = function (obj, recipie, drop_key) { |
|
2680 |
+ if (drop_key === void 0) { drop_key = (function (k) { return ["parents", "parent", "children"].indexOf(k) > -1; }); } |
|
2681 |
+ var ret = {}; |
|
2682 |
+ for (var key in recipie) { |
|
2683 |
+ if (!drop_key(key)) { |
|
2684 |
+ var prefix = (recipie[key].prefix || ""); |
|
2685 |
+ var recursive = (recipie[key].recursive || -1); |
|
2686 |
+ var extract = (recipie[key].extract || (function (x) { return x; })); |
|
2687 |
+ var _obj = extract(obj[key]); |
|
2688 |
+ if ((_obj !== null) && ((typeof _obj == "object") || (obj[key] instanceof Array)) && (!(recursive == 0))) { |
|
2689 |
+ var tmp = {}; |
|
2690 |
+ var _recipie = {}; |
|
2691 |
+ for (var _i = 0, _a = Object.keys(_obj); _i < _a.length; _i++) { |
|
2692 |
+ var k = _a[_i]; |
|
2693 |
+ _recipie[k] = { |
|
2694 |
+ "prefix": (prefix + key + "."), |
|
2695 |
+ "recursive": (recursive - 1), |
|
2696 |
+ "extract": (function (x) { return x; }) |
|
2940 | 2697 |
}; |
2941 |
- /** |
|
2942 |
- * @desc [implementation] |
|
2943 |
- * @author fenris |
|
2944 |
- */ |
|
2945 |
- class_shape_email.prototype._show = function () { |
|
2946 |
- var str = "email"; |
|
2947 |
- return str; |
|
2948 |
- }; |
|
2949 |
- return class_shape_email; |
|
2950 |
- }(lib_meta.class_shape)); |
|
2951 |
- lib_meta.class_shape_email = class_shape_email; |
|
2952 |
- lib_meta.register("email", function (parameters) { |
|
2953 |
- return (new class_shape_email({ |
|
2954 |
- "soft": parameters["soft"] |
|
2955 |
- })); |
|
2956 |
- }); |
|
2957 |
-})(lib_meta || (lib_meta = {})); |
|
2958 |
-var lib_meta; |
|
2959 |
-(function (lib_meta) { |
|
2960 |
- /** |
|
2961 |
- * @author fenris |
|
2962 |
- */ |
|
2963 |
- var class_shape_array = (function (_super) { |
|
2964 |
- __extends(class_shape_array, _super); |
|
2965 |
- /** |
|
2966 |
- * @author fenris |
|
2967 |
- */ |
|
2968 |
- function class_shape_array(_a) { |
|
2969 |
- var shape_element = _a["shape_element"], _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? [] : _c; |
|
2970 |
- var _this = _super.call(this, { |
|
2971 |
- "primitive": false, |
|
2972 |
- "soft": soft, |
|
2973 |
- "defaultvalue": defaultvalue |
|
2974 |
- }) || this; |
|
2975 |
- _this.shape_element = shape_element; |
|
2976 |
- return _this; |
|
2977 | 2698 |
} |
2978 |
- /** |
|
2979 |
- * @desc [accessor] [getter] |
|
2980 |
- * @author fenris |
|
2981 |
- */ |
|
2982 |
- class_shape_array.prototype.shape_element_get = function () { |
|
2983 |
- return this.shape_element; |
|
2984 |
- }; |
|
2985 |
- /** |
|
2986 |
- * @override |
|
2987 |
- * @author fenris |
|
2988 |
- */ |
|
2989 |
- class_shape_array.prototype.inspect = function (value) { |
|
2990 |
- var _this = this; |
|
2991 |
- var messages = _super.prototype.inspect.call(this, value); |
|
2992 |
- if (value != null) { |
|
2993 |
- if (!((typeof (value) == "object") && (value instanceof Array))) { |
|
2994 |
- messages.push("value is not an array"); |
|
2699 |
+ tmp = flatten_object(_obj, _recipie, drop_key); |
|
2700 |
+ ret = object_merge_objects(ret, tmp); |
|
2995 | 2701 |
} |
2996 | 2702 |
else { |
2997 |
- var array = (value); |
|
2998 |
- array.forEach(function (element, index) { |
|
2999 |
- messages = messages.concat(_this.shape_element.inspect(element).map(function (message) { return "array element #" + index.toString() + ": " + message; })); |
|
3000 |
- }); |
|
2703 |
+ ret[prefix + key] = _obj; |
|
3001 | 2704 |
} |
3002 | 2705 |
} |
3003 |
- return messages; |
|
2706 |
+ } |
|
2707 |
+ return ret; |
|
3004 | 2708 |
}; |
3005 | 2709 |
/** |
3006 |
- * @override |
|
3007 |
- * @author fenris |
|
2710 |
+ * use the complete path of an objects entry as key to make an one dimensional object |
|
2711 |
+ * @param {object} object the object which should be moade flat |
|
2712 |
+ * @param {string} [path] for the recursive call the current path |
|
3008 | 2713 |
*/ |
3009 |
- class_shape_array.prototype.to_raw = function () { |
|
3010 |
- return { |
|
3011 |
- "id": "array", |
|
3012 |
- "parameters": { |
|
3013 |
- "shape_element": this.shape_element.to_raw(), |
|
3014 |
- "soft": this.soft |
|
2714 |
+/*export*/ var object_make_flat = function (object, path, filter, split_char, objects) { |
|
2715 |
+ if (path === void 0) { path = null; } |
|
2716 |
+ if (filter === void 0) { filter = ["parent", "children"]; } |
|
2717 |
+ if (split_char === void 0) { split_char = "."; } |
|
2718 |
+ if (objects === void 0) { objects = []; } |
|
2719 |
+ if (object.toFlat != undefined) { |
|
2720 |
+ return object.toFlat(); |
|
2721 |
+ } |
|
2722 |
+ else { |
|
2723 |
+ var ret = {}; |
|
2724 |
+ var default_visited_key = "___visited_path___"; |
|
2725 |
+ var visited_key; |
|
2726 |
+ if (object != void 0) { |
|
2727 |
+ var iterate = function (key) { |
|
2728 |
+ var newkey = key; |
|
2729 |
+ if ((path != undefined) && (path !== "")) { |
|
2730 |
+ newkey = path + split_char + newkey; |
|
2731 |
+ } |
|
2732 |
+ // do not touch objects we alrdy know |
|
2733 |
+ if ((obj_ref[key] != undefined) && (!objects.some(function (e) { return (e === obj_ref); }))) { |
|
2734 |
+ //if (lib_call.is_def(obj_ref[key]) && (! obj_ref[key].hasOwnProperty(visited_key)) && (key !== visited_key)) { |
|
2735 |
+ if (typeof obj_ref[key] === "object") { |
|
2736 |
+ ret = object_merge_objects(ret, object_make_flat(obj_ref[key], newkey, filter, split_char, objects.concat(object))); |
|
2737 |
+ } |
|
2738 |
+ else if (typeof obj_ref[key] === "function") { |
|
2739 |
+ // o.O a function ... doing nothing might be the best choice |
|
2740 |
+ } |
|
2741 |
+ else { |
|
2742 |
+ var value = obj_ref[key]; |
|
2743 |
+ ret[newkey] = value; |
|
2744 |
+ } |
|
3015 | 2745 |
} |
3016 | 2746 |
}; |
2747 |
+ visited_key = default_visited_key; |
|
2748 |
+ //object[visited_key] = true; |
|
2749 |
+ var obj_ref = object; |
|
2750 |
+ Object.keys(object).filter(function (key) { return (filter.indexOf(key) < 0); }).forEach(iterate); |
|
2751 |
+ if (typeof object.getComputedValues == "function") { |
|
2752 |
+ visited_key = default_visited_key + "_" + Math.random().toString(); |
|
2753 |
+ obj_ref = object.getComputedValues(); |
|
2754 |
+ obj_ref[visited_key] = true; |
|
2755 |
+ Object.keys(obj_ref).filter(function (key) { return (filter.indexOf(key) < 0); }).forEach(iterate); |
|
2756 |
+ } |
|
2757 |
+ } |
|
2758 |
+ else { |
|
2759 |
+ //console.warn("something went wrong with that object: ", object, "on this path:", path); |
|
2760 |
+ } |
|
2761 |
+ return ret; |
|
2762 |
+ } |
|
3017 | 2763 |
}; |
3018 | 2764 |
/** |
3019 |
- * @desc [implementation] |
|
3020 |
- * @author fenris |
|
2765 |
+ * splits a flat oject into an array of objects if there are paths containing numbers, which indicates |
|
2766 |
+ * that there might be an array |
|
2767 |
+ * used for normalisation of imports |
|
2768 |
+ * @param entry |
|
2769 |
+ * @param number_replace_string |
|
2770 |
+ * @param {function} [match_function] how to test key if it causes a split |
|
2771 |
+ * @returns {Array} |
|
3021 | 2772 |
*/ |
3022 |
- class_shape_array.prototype._show = function () { |
|
3023 |
- var str = "array"; |
|
3024 |
- str += "<" + instance_show(this.shape_element) + ">"; |
|
3025 |
- return str; |
|
2773 |
+var object_split_flat_object = function (entry, number_replace_string, fab_function, match_function) { |
|
2774 |
+ if (typeof (match_function) === "undefined") { |
|
2775 |
+ match_function = function (key) { |
|
2776 |
+ return (!key.match(/^custom/)) && key.match(/\.[0-9]+\./); |
|
3026 | 2777 |
}; |
3027 |
- return class_shape_array; |
|
3028 |
- }(lib_meta.class_shape)); |
|
3029 |
- lib_meta.class_shape_array = class_shape_array; |
|
3030 |
- lib_meta.register("array", function (parameters) { |
|
3031 |
- var shape_element_raw = lib_object.fetch(parameters, "shape_element", null, 2); |
|
3032 |
- var shape_element = lib_meta.from_raw(shape_element_raw); |
|
3033 |
- return (new class_shape_array({ |
|
3034 |
- "shape_element": shape_element, |
|
3035 |
- "soft": parameters["soft"] |
|
3036 |
- })); |
|
2778 |
+ } |
|
2779 |
+ if (typeof (fab_function) === "undefined") { |
|
2780 |
+ fab_function = function (obj, e) { |
|
2781 |
+ return obj; |
|
2782 |
+ }; |
|
2783 |
+ } |
|
2784 |
+ if (typeof (number_replace_string) === "undefined") { |
|
2785 |
+ number_replace_string = "%d"; |
|
2786 |
+ } |
|
2787 |
+ var ret = {}; |
|
2788 |
+ var _ret = []; |
|
2789 |
+ var keys = Object.keys(entry); |
|
2790 |
+ var group_keys = keys.filter(match_function); |
|
2791 |
+ keys.forEach(function (key) { |
|
2792 |
+ var index = 0; |
|
2793 |
+ var nkey = key; |
|
2794 |
+ if (match_function(key)) { |
|
2795 |
+ index = Number(key.match(/[0-9]+/)[0]).valueOf(); |
|
2796 |
+ nkey = key.replace(/\.[0-9]+\./, "." + number_replace_string + "."); |
|
2797 |
+ } |
|
2798 |
+ if (!ret[index]) { |
|
2799 |
+ ret[index] = {}; |
|
2800 |
+ } |
|
2801 |
+ ret[index][nkey] = entry[key]; |
|
3037 | 2802 |
}); |
3038 |
- lib_meta.register("arr", function (parameters) { return lib_meta.construct("array", parameters); }); |
|
3039 |
-})(lib_meta || (lib_meta = {})); |
|
3040 |
-var lib_meta; |
|
3041 |
-(function (lib_meta) { |
|
3042 |
- /** |
|
3043 |
- * @author fenris |
|
3044 |
- */ |
|
3045 |
- var class_shape_object = (function (_super) { |
|
3046 |
- __extends(class_shape_object, _super); |
|
3047 |
- /** |
|
3048 |
- * @author fenris |
|
3049 |
- */ |
|
3050 |
- function class_shape_object(_a) { |
|
3051 |
- var fields = _a["fields"], _b = _a["soft"], soft = _b === void 0 ? true : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? null : _c; |
|
3052 |
- var _this = this; |
|
3053 |
- if (defaultvalue == null) { |
|
3054 |
- defaultvalue = {}; |
|
3055 |
- fields.forEach(function (field) { |
|
3056 |
- defaultvalue[field.name] = field.shape.defaultvalue_get(); |
|
2803 |
+ keys = Object.keys(ret).sort(); |
|
2804 |
+ _ret.push(ret[0]); |
|
2805 |
+ for (var index = 1; index < keys.length; index++) { |
|
2806 |
+ _ret.push(fab_function(ret[keys[index]], entry)); |
|
2807 |
+ } |
|
2808 |
+ _ret[0] = object_merge_objects(_ret[0], ret[0]); |
|
2809 |
+ return _ret; |
|
2810 |
+}; |
|
2811 |
+// TODO: move to exporter, it's to specific |
|
2812 |
+// to normalize the objects convert paths of a tree-like structure to a |
|
2813 |
+// key-value list with complete paths as key |
|
2814 |
+// the info object is passed to the next function as it is |
|
2815 |
+// and a flat_object (key : value) |
|
2816 |
+/*export*/ var object_make_flat_async = function (data, callback, on_progress) { |
|
2817 |
+ setTimeout((function (_obj, _cb, _info) { |
|
2818 |
+ return (function () { |
|
2819 |
+ var ret = _obj.map(function (o) { return object_make_flat(o); }); |
|
2820 |
+ _cb({ "flat_object": ret, "objects": ret, "info": _info }); |
|
3057 | 2821 |
}); |
2822 |
+ })((typeof (data.processed.objects) === "undefined") ? data.processed.source_object : data.processed.objects, callback, data.processed.info), 0); |
|
2823 |
+}; |
|
2824 |
+var object_flatten = function (object, paths, prefix) { |
|
2825 |
+ if (prefix === void 0) { prefix = ""; } |
|
2826 |
+ var ret = {}; |
|
2827 |
+ var paths_ = paths.reduce(function (prev, current) { |
|
2828 |
+ if (current.split(".").some(function (x) { return (x === "%d"); })) { |
|
2829 |
+ var path = current.split(".%d").shift(); |
|
2830 |
+ var len = object_path_read(object, path).length; |
|
2831 |
+ for (var i = 0; i < len; i++) { |
|
2832 |
+ // prev.push(sprintf(current, [i])); |
|
2833 |
+ prev.push(current.replace(new RegExp("%d"), i.toFixed(0))); |
|
3058 | 2834 |
} |
3059 |
- _this = _super.call(this, { |
|
3060 |
- "typename": "object", |
|
3061 |
- "primitive": false, |
|
3062 |
- "soft": soft, |
|
3063 |
- "defaultvalue": defaultvalue |
|
3064 |
- }) || this; |
|
3065 |
- _this.fields = fields; |
|
3066 |
- return _this; |
|
3067 | 2835 |
} |
3068 |
- /** |
|
3069 |
- * @desc [accessor] [getter] |
|
3070 |
- * @author fenris |
|
3071 |
- */ |
|
3072 |
- class_shape_object.prototype.fields_get = function () { |
|
3073 |
- return this.fields; |
|
2836 |
+ else { |
|
2837 |
+ prev.push(current); |
|
2838 |
+ } |
|
2839 |
+ return prev; |
|
2840 |
+ }, []); |
|
2841 |
+ for (var _i = 0, paths_1 = paths_; _i < paths_1.length; _i++) { |
|
2842 |
+ var path = paths_1[_i]; |
|
2843 |
+ var tmp = object_path_read(object, path, true); |
|
2844 |
+ if ((tmp != undefined) && (tmp.toFlat != undefined)) { |
|
2845 |
+ var tmp_ = tmp.toFlat([path, "."].join("")); |
|
2846 |
+ for (var key in tmp_) { |
|
2847 |
+ ret[key] = tmp_[key]; |
|
2848 |
+ } |
|
2849 |
+ } |
|
2850 |
+ else { |
|
2851 |
+ ret[prefix + path] = tmp; |
|
2852 |
+ } |
|
2853 |
+ } |
|
2854 |
+ return ret; |
|
3074 | 2855 |
}; |
3075 | 2856 |
/** |
3076 |
- * @override |
|
3077 |
- * @author fenris |
|
3078 |
- * @todo check for superfluous fields? |
|
2857 |
+ * parse |
|
2858 |
+ * @param {String} value |
|
2859 |
+ * @returns {Object} |
|
3079 | 2860 |
*/ |
3080 |
- class_shape_object.prototype.inspect = function (value) { |
|
3081 |
- var messages = _super.prototype.inspect.call(this, value); |
|
3082 |
- if (value != null) { |
|
3083 |
- this.fields.forEach(function (field, index) { |
|
3084 |
- var value_ = value[field.name]; |
|
3085 |
- messages = messages.concat(field.shape.inspect(value_).map(function (message) { return "object field '" + field.name + "': " + message; })); |
|
3086 |
- }); |
|
3087 |
- } |
|
3088 |
- return messages; |
|
2861 |
+var object_parse = function (value) { |
|
2862 |
+ var content = JSON.parse(value); |
|
2863 |
+ var m = { "root": content }; |
|
2864 |
+ (new Mapper()).mapClasses(m); |
|
2865 |
+ return m["root"]; |
|
3089 | 2866 |
}; |
3090 | 2867 |
/** |
3091 |
- * @override |
|
3092 |
- * @author fenris |
|
2868 |
+ * stringify |
|
2869 |
+ * |
|
2870 |
+ * @description stringify object as JSON |
|
3093 | 2871 |
*/ |
3094 |
- class_shape_object.prototype.to_raw = function () { |
|
3095 |
- return { |
|
3096 |
- "id": "object", |
|
3097 |
- "parameters": { |
|
3098 |
- "soft": this.soft, |
|
3099 |
- "fields": this.fields.map(function (field) { |
|
3100 |
- return { |
|
3101 |
- "name": field.name, |
|
3102 |
- "shape": field.shape.to_raw(), |
|
3103 |
- "label": field.label |
|
3104 |
- }; |
|
3105 |
- }) |
|
2872 |
+var object_stringify = function (object, readable) { |
|
2873 |
+ if (readable === void 0) { readable = false; } |
|
2874 |
+ return (JSON.stringify(object, function (key, value) { |
|
2875 |
+ if ((key == "parents") && (value !== null)) { |
|
2876 |
+ return null; |
|
2877 |
+ } |
|
2878 |
+ if (key == "changeActions") { |
|
2879 |
+ return undefined; |
|
2880 |
+ } |
|
2881 |
+ if (key == "observer") { |
|
2882 |
+ return undefined; |
|
2883 |
+ } |
|
2884 |
+ if (key == "isMapped") { |
|
2885 |
+ return undefined; |
|
2886 |
+ } |
|
2887 |
+ /* |
|
2888 |
+ if (value === null) { |
|
2889 |
+ return undefined; |
|
3106 | 2890 |
} |
3107 |
- }; |
|
3108 |
- }; |
|
3109 |
- /** |
|
3110 |
- * @desc [implementation] |
|
3111 |
- * @author fenris |
|
3112 | 2891 |
*/ |
3113 |
- class_shape_object.prototype._show = function () { |
|
3114 |
- var str = _super.prototype._show.call(this); |
|
3115 |
- var str_ = this.fields.map(function (field) { return field.name + ":" + instance_show(field.shape); }).join(","); |
|
3116 |
- str = str + "<" + str_ + ">"; |
|
3117 |
- return str; |
|
2892 |
+ return value; |
|
2893 |
+ }, readable ? 1 : 0)); |
|
3118 | 2894 |
}; |
3119 |
- return class_shape_object; |
|
3120 |
- }(lib_meta.class_shape_buildin)); |
|
3121 |
- lib_meta.class_shape_object = class_shape_object; |
|
3122 |
- lib_meta.register("object", function (parameters) { |
|
3123 |
- var fields_ = lib_object.fetch(parameters, "fields", [], 1); |
|
3124 |
- return (new class_shape_object({ |
|
3125 |
- "fields": fields_.map(function (field_) { |
|
3126 |
- var name = lib_object.fetch(field_, "name", null, 2); |
|
3127 |
- var shape_raw = lib_object.fetch(field_, "shape", null, 2); |
|
3128 |
- var shape = lib_meta.construct(shape_raw.id, shape_raw.parameters); |
|
3129 |
- var label = lib_object.fetch(field_, "label", null, 1); |
|
3130 |
- return { |
|
3131 |
- "name": name, |
|
3132 |
- "shape": shape, |
|
3133 |
- "label": label |
|
2895 |
+var __extends = (this && this.__extends) || (function () { |
|
2896 |
+ var extendStatics = Object.setPrototypeOf || |
|
2897 |
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
2898 |
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; |
|
2899 |
+ return function (d, b) { |
|
2900 |
+ extendStatics(d, b); |
|
2901 |
+ function __() { this.constructor = d; } |
|
2902 |
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
3134 | 2903 |
}; |
3135 |
- }), |
|
3136 |
- "soft": parameters["soft"] |
|
3137 |
- })); |
|
3138 |
- }); |
|
3139 |
- lib_meta.register("obj", function (parameters) { return lib_meta.construct("object", parameters); }); |
|
3140 |
-})(lib_meta || (lib_meta = {})); |
|
2904 |
+})(); |
|
3141 | 2905 |
var lib_meta; |
3142 | 2906 |
(function (lib_meta) { |
3143 | 2907 |
/** |
3144 |
- * @author fenris |
|
2908 |
+ * @author frac |
|
3145 | 2909 |
*/ |
3146 |
- var class_shape_date = (function (_super) { |
|
3147 |
- __extends(class_shape_date, _super); |
|
2910 |
+ function type_toString(type) { |
|
2911 |
+ // return ("<" + type.id + ">"); |
|
2912 |
+ return JSON.stringify(type); |
|
2913 |
+ } |
|
2914 |
+ lib_meta.type_toString = type_toString; |
|
3148 | 2915 |
/** |
3149 |
- * @author fenris |
|
2916 |
+ * @author frac |
|
3150 | 2917 |
*/ |
3151 |
- function class_shape_date(_a) { |
|
3152 |
- var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? new Date(Date.now()) : _c; |
|
3153 |
- return _super.call(this, { |
|
3154 |
- "primitive": true, |
|
3155 |
- "soft": soft, |
|
3156 |
- "defaultvalue": defaultvalue |
|
3157 |
- }) || this; |
|
2918 |
+ var class_pool = {}; |
|
2919 |
+ /** |
|
2920 |
+ * @author frac |
|
2921 |
+ */ |
|
2922 |
+ function class_set(name, class_) { |
|
2923 |
+ class_pool[name] = class_; |
|
3158 | 2924 |
} |
2925 |
+ lib_meta.class_set = class_set; |
|
3159 | 2926 |
/** |
3160 |
- * @override |
|
3161 |
- * @author fenris |
|
2927 |
+ * @author frac |
|
3162 | 2928 |
*/ |
3163 |
- class_shape_date.prototype.inspect = function (value) { |
|
3164 |
- var messages = _super.prototype.inspect.call(this, value); |
|
3165 |
- if (value != null) { |
|
3166 |
- if (!((typeof (value) == "object") && (value instanceof Date))) { |
|
3167 |
- messages.push("value is not a date"); |
|
2929 |
+ function class_get(name) { |
|
2930 |
+ if (name in class_pool) { |
|
2931 |
+ return class_pool[name]; |
|
3168 | 2932 |
} |
2933 |
+ else { |
|
2934 |
+ throw (new Error("no class registered for name '" + name + "'")); |
|
3169 | 2935 |
} |
3170 |
- return messages; |
|
3171 |
- }; |
|
2936 |
+ } |
|
2937 |
+ lib_meta.class_get = class_get; |
|
3172 | 2938 |
/** |
3173 |
- * @override |
|
3174 |
- * @author fenris |
|
2939 |
+ * @author frac |
|
3175 | 2940 |
*/ |
3176 |
- class_shape_date.prototype.to_raw = function () { |
|
3177 |
- return { |
|
2941 |
+ function transform_field(name, attributes) { |
|
2942 |
+ var type = attributes["type"]; |
|
2943 |
+ var path = name; |
|
2944 |
+ var label = ((attributes["title"] != undefined) ? attributes["title"] : name); |
|
2945 |
+ var display = ((attributes["display"] != undefined) ? attributes["display"] : true); |
|
2946 |
+ return ({ |
|
2947 |
+ "path": path, |
|
2948 |
+ "type": type, |
|
2949 |
+ "label": label, |
|
2950 |
+ "display": display |
|
2951 |
+ }); |
|
2952 |
+ } |
|
2953 |
+ lib_meta.transform_field = transform_field; |
|
2954 |
+ /** |
|
2955 |
+ * @author frac |
|
2956 |
+ */ |
|
2957 |
+ function transform_description(label, description, groups_raw) { |
|
2958 |
+ if (groups_raw === void 0) { groups_raw = null; } |
|
2959 |
+ var fieldmap; |
|
2960 |
+ var fields = Object.keys(description).map(function (key) { return transform_field(key, description[key]); }); |
|
2961 |
+ var groups = ((groups_raw == null) |
|
2962 |
+ ? |
|
2963 |
+ null |
|
2964 |
+ : |
|
2965 |
+ groups_raw.map(function (group_raw) { |
|
2966 |
+ return { |
|
2967 |
+ "label": group_raw["label"], |
|
2968 |
+ "fields": group_raw["fields"].map(function (field_name) { |
|
2969 |
+ var index = fields["findIndex"](function (field) { return (field.path == field_name); }); |
|
2970 |
+ if (index < 0) { |
|
2971 |
+ throw (new Error("field " + field_name + " not found in model-description")); |
|
2972 |
+ } |
|
2973 |
+ return index; |
|
2974 |
+ }) |
|
2975 |
+ }; |
|
2976 |
+ })); |
|
2977 |
+ return { |
|
2978 |
+ "fields": fields, |
|
2979 |
+ "description": null, |
|
2980 |
+ "title": label, |
|
2981 |
+ "groups": groups |
|
2982 |
+ }; |
|
2983 |
+ } |
|
2984 |
+ lib_meta.transform_description = transform_description; |
|
2985 |
+ /** |
|
2986 |
+ * @author frac |
|
2987 |
+ */ |
|
2988 |
+ function transform_description_groups(label, description_model, description_groups) { |
|
2989 |
+ return ({ |
|
2990 |
+ "label": label, |
|
2991 |
+ "groups": description_groups.map(function (group_raw) { |
|
2992 |
+ return { |
|
2993 |
+ "label": group_raw["label"], |
|
2994 |
+ "fields": group_raw["fields"].map(function (path) { |
|
2995 |
+ var field_raw = description_model[path]; |
|
2996 |
+ return transform_field(path, field_raw); |
|
2997 |
+ }) |
|
2998 |
+ }; |
|
2999 |
+ }) |
|
3000 |
+ }); |
|
3001 |
+ } |
|
3002 |
+ lib_meta.transform_description_groups = transform_description_groups; |
|
3003 |
+})(lib_meta || (lib_meta = {})); |
|
3004 |
+/// <reference path="../../base/build/logic-decl.d.ts"/> |
|
3005 |
+/// <reference path="../../object/build/logic-decl.d.ts"/> |
|
3006 |
+var lib_meta; |
|
3007 |
+(function (lib_meta) { |
|
3008 |
+ /** |
|
3009 |
+ * @author fenris |
|
3010 |
+ */ |
|
3011 |
+ lib_meta._logprefix = "[lib_meta] "; |
|
3012 |
+ /** |
|
3013 |
+ * @author fenris |
|
3014 |
+ */ |
|
3015 |
+ lib_meta._verbosity = 1; |
|
3016 |
+})(lib_meta || (lib_meta = {})); |
|
3017 |
+var lib_meta; |
|
3018 |
+(function (lib_meta) { |
|
3019 |
+ /** |
|
3020 |
+ * @author fenris |
|
3021 |
+ */ |
|
3022 |
+ var class_shape = (function () { |
|
3023 |
+ /** |
|
3024 |
+ * @desc [constructor] |
|
3025 |
+ * @author fenris |
|
3026 |
+ */ |
|
3027 |
+ function class_shape(_a) { |
|
3028 |
+ var _b = _a["primitive"], primitive = _b === void 0 ? false : _b, _c = _a["soft"], soft = _c === void 0 ? true : _c, _d = _a["defaultvalue"], defaultvalue = _d === void 0 ? null : _d; |
|
3029 |
+ /* |
|
3030 |
+ if ((! soft) && (defaultvalue == null)) { |
|
3031 |
+ throw (new Error("'null' is not a valid defaultvalue for hard shapes")); |
|
3032 |
+ } |
|
3033 |
+ */ |
|
3034 |
+ this.primitive = primitive; |
|
3035 |
+ this.soft = soft; |
|
3036 |
+ this.defaultvalue = defaultvalue; |
|
3037 |
+ } |
|
3038 |
+ /** |
|
3039 |
+ * @desc [accessor] [getter] |
|
3040 |
+ * @author fenris |
|
3041 |
+ */ |
|
3042 |
+ class_shape.prototype.primitive_get = function () { |
|
3043 |
+ return this.primitive; |
|
3044 |
+ }; |
|
3045 |
+ /** |
|
3046 |
+ * @desc [accessor] [getter] |
|
3047 |
+ * @author fenris |
|
3048 |
+ */ |
|
3049 |
+ class_shape.prototype.soft_get = function () { |
|
3050 |
+ return this.soft; |
|
3051 |
+ }; |
|
3052 |
+ /** |
|
3053 |
+ * @desc [accessor] [getter] |
|
3054 |
+ * @author fenris |
|
3055 |
+ */ |
|
3056 |
+ class_shape.prototype.defaultvalue_get = function () { |
|
3057 |
+ return this.defaultvalue; |
|
3058 |
+ }; |
|
3059 |
+ /** |
|
3060 |
+ * @desc [accessor] |
|
3061 |
+ * @author fenris |
|
3062 |
+ */ |
|
3063 |
+ class_shape.prototype.inspect = function (value) { |
|
3064 |
+ var messages = []; |
|
3065 |
+ if ((!this.soft) && (value == null)) { |
|
3066 |
+ messages.push("shape does not allow 'null' as value"); |
|
3067 |
+ } |
|
3068 |
+ return messages; |
|
3069 |
+ }; |
|
3070 |
+ /** |
|
3071 |
+ * @desc [accessor] |
|
3072 |
+ * @author fenris |
|
3073 |
+ */ |
|
3074 |
+ class_shape.prototype.check = function (value) { |
|
3075 |
+ var messages = this.inspect(value); |
|
3076 |
+ if (lib_meta._verbosity >= 1) { |
|
3077 |
+ messages.forEach(function (message) { return console.warn("" + lib_meta._logprefix + message); }); |
|
3078 |
+ } |
|
3079 |
+ return (messages.length == 0); |
|
3080 |
+ }; |
|
3081 |
+ return class_shape; |
|
3082 |
+ }()); |
|
3083 |
+ lib_meta.class_shape = class_shape; |
|
3084 |
+ /** |
|
3085 |
+ * @author fenris |
|
3086 |
+ */ |
|
3087 |
+ var class_shape_buildin = (function (_super) { |
|
3088 |
+ __extends(class_shape_buildin, _super); |
|
3089 |
+ /** |
|
3090 |
+ * @author fenris |
|
3091 |
+ */ |
|
3092 |
+ function class_shape_buildin(_a) { |
|
3093 |
+ var typename = _a["typename"], _b = _a["primitive"], primitive = _b === void 0 ? undefined : _b, _c = _a["soft"], soft = _c === void 0 ? undefined : _c, _d = _a["defaultvalue"], defaultvalue = _d === void 0 ? undefined : _d; |
|
3094 |
+ var _this = _super.call(this, { |
|
3095 |
+ "primitive": primitive, |
|
3096 |
+ "soft": soft, |
|
3097 |
+ "defaultvalue": defaultvalue |
|
3098 |
+ }) || this; |
|
3099 |
+ _this.typename = typename; |
|
3100 |
+ return _this; |
|
3101 |
+ } |
|
3102 |
+ /** |
|
3103 |
+ * @override |
|
3104 |
+ * @author fenris |
|
3105 |
+ */ |
|
3106 |
+ class_shape_buildin.prototype.inspect = function (value) { |
|
3107 |
+ var messages = _super.prototype.inspect.call(this, value); |
|
3108 |
+ if ((!this.soft) && (typeof (value) != this.typename)) { |
|
3109 |
+ messages.push("typename is not '" + this.typename + "'"); |
|
3110 |
+ } |
|
3111 |
+ return messages; |
|
3112 |
+ }; |
|
3113 |
+ /** |
|
3114 |
+ * @desc [implementation] |
|
3115 |
+ * @author fenris |
|
3116 |
+ */ |
|
3117 |
+ class_shape_buildin.prototype._show = function () { |
|
3118 |
+ var str = ""; |
|
3119 |
+ str = this.typename; |
|
3120 |
+ if (this.soft) { |
|
3121 |
+ str = str + "_or_null"; |
|
3122 |
+ } |
|
3123 |
+ return str; |
|
3124 |
+ }; |
|
3125 |
+ return class_shape_buildin; |
|
3126 |
+ }(class_shape)); |
|
3127 |
+ lib_meta.class_shape_buildin = class_shape_buildin; |
|
3128 |
+ /** |
|
3129 |
+ * @author fenris |
|
3130 |
+ */ |
|
3131 |
+ var _pool = {}; |
|
3132 |
+ /** |
|
3133 |
+ * @author fenris |
|
3134 |
+ */ |
|
3135 |
+ function register(id, factory) { |
|
3136 |
+ if (id in _pool) { |
|
3137 |
+ var message = "shape '" + id + "' already registered"; |
|
3138 |
+ throw (new Error(message)); |
|
3139 |
+ } |
|
3140 |
+ else { |
|
3141 |
+ _pool[id] = factory; |
|
3142 |
+ } |
|
3143 |
+ } |
|
3144 |
+ lib_meta.register = register; |
|
3145 |
+ /** |
|
3146 |
+ * @author fenris |
|
3147 |
+ */ |
|
3148 |
+ function construct(id, parameters) { |
|
3149 |
+ if (parameters === void 0) { parameters = {}; } |
|
3150 |
+ if (!(id in _pool)) { |
|
3151 |
+ var message = "no shape found with id " + id; |
|
3152 |
+ throw (new Error(message)); |
|
3153 |
+ } |
|
3154 |
+ else { |
|
3155 |
+ return _pool[id](parameters); |
|
3156 |
+ } |
|
3157 |
+ } |
|
3158 |
+ lib_meta.construct = construct; |
|
3159 |
+ /** |
|
3160 |
+ * @author fenris |
|
3161 |
+ */ |
|
3162 |
+ function from_raw(shape_raw) { |
|
3163 |
+ return construct(shape_raw.id, shape_raw.parameters); |
|
3164 |
+ } |
|
3165 |
+ lib_meta.from_raw = from_raw; |
|
3166 |
+ /** |
|
3167 |
+ * @author fenris |
|
3168 |
+ */ |
|
3169 |
+ function define(id, shape_raw) { |
|
3170 |
+ register(id, function (parameters) { return from_raw(shape_raw); }); |
|
3171 |
+ } |
|
3172 |
+ lib_meta.define = define; |
|
3173 |
+ /** |
|
3174 |
+ * @author fenris |
|
3175 |
+ */ |
|
3176 |
+ function retrieve(id) { |
|
3177 |
+ return construct(id, {}); |
|
3178 |
+ } |
|
3179 |
+ lib_meta.retrieve = retrieve; |
|
3180 |
+})(lib_meta || (lib_meta = {})); |
|
3181 |
+var lib_meta; |
|
3182 |
+(function (lib_meta) { |
|
3183 |
+ /** |
|
3184 |
+ * @author fenris |
|
3185 |
+ */ |
|
3186 |
+ var class_shape_any = (function (_super) { |
|
3187 |
+ __extends(class_shape_any, _super); |
|
3188 |
+ /** |
|
3189 |
+ * @author fenris |
|
3190 |
+ */ |
|
3191 |
+ function class_shape_any(_a) { |
|
3192 |
+ var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? 0 : _c; |
|
3193 |
+ return _super.call(this, { |
|
3194 |
+ "soft": soft, |
|
3195 |
+ "defaultvalue": defaultvalue |
|
3196 |
+ }) || this; |
|
3197 |
+ } |
|
3198 |
+ /** |
|
3199 |
+ * @override |
|
3200 |
+ * @author fenris |
|
3201 |
+ */ |
|
3202 |
+ class_shape_any.prototype.inspect = function (value) { |
|
3203 |
+ var messages = _super.prototype.inspect.call(this, value); |
|
3204 |
+ return messages; |
|
3205 |
+ }; |
|
3206 |
+ /** |
|
3207 |
+ * @override |
|
3208 |
+ * @author fenris |
|
3209 |
+ */ |
|
3210 |
+ class_shape_any.prototype.to_raw = function () { |
|
3211 |
+ return { |
|
3212 |
+ "id": "any", |
|
3213 |
+ "parameters": { |
|
3214 |
+ "soft": this.soft |
|
3215 |
+ } |
|
3216 |
+ }; |
|
3217 |
+ }; |
|
3218 |
+ /** |
|
3219 |
+ * @desc [implementation] |
|
3220 |
+ * @author fenris |
|
3221 |
+ */ |
|
3222 |
+ class_shape_any.prototype._show = function () { |
|
3223 |
+ var str = "any"; |
|
3224 |
+ return str; |
|
3225 |
+ }; |
|
3226 |
+ return class_shape_any; |
|
3227 |
+ }(lib_meta.class_shape)); |
|
3228 |
+ lib_meta.class_shape_any = class_shape_any; |
|
3229 |
+ lib_meta.register("any", function (parameters) { |
|
3230 |
+ return (new class_shape_any({ |
|
3231 |
+ "soft": parameters["soft"] |
|
3232 |
+ })); |
|
3233 |
+ }); |
|
3234 |
+})(lib_meta || (lib_meta = {})); |
|
3235 |
+var lib_meta; |
|
3236 |
+(function (lib_meta) { |
|
3237 |
+ /** |
|
3238 |
+ * @author fenris |
|
3239 |
+ */ |
|
3240 |
+ var class_shape_boolean = (function (_super) { |
|
3241 |
+ __extends(class_shape_boolean, _super); |
|
3242 |
+ /** |
|
3243 |
+ * @author fenris |
|
3244 |
+ */ |
|
3245 |
+ function class_shape_boolean(_a) { |
|
3246 |
+ var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? false : _c; |
|
3247 |
+ return _super.call(this, { |
|
3248 |
+ "typename": "boolean", |
|
3249 |
+ "primitive": true, |
|
3250 |
+ "soft": soft, |
|
3251 |
+ "defaultvalue": defaultvalue |
|
3252 |
+ }) || this; |
|
3253 |
+ } |
|
3254 |
+ /** |
|
3255 |
+ * @override |
|
3256 |
+ * @author fenris |
|
3257 |
+ */ |
|
3258 |
+ class_shape_boolean.prototype.to_raw = function () { |
|
3259 |
+ return { |
|
3260 |
+ "id": "boolean", |
|
3261 |
+ "parameters": { |
|
3262 |
+ "soft": this.soft |
|
3263 |
+ } |
|
3264 |
+ }; |
|
3265 |
+ }; |
|
3266 |
+ return class_shape_boolean; |
|
3267 |
+ }(lib_meta.class_shape_buildin)); |
|
3268 |
+ lib_meta.class_shape_boolean = class_shape_boolean; |
|
3269 |
+ lib_meta.register("boolean", function (parameters) { |
|
3270 |
+ return (new class_shape_boolean({ |
|
3271 |
+ "soft": parameters["soft"] |
|
3272 |
+ })); |
|
3273 |
+ }); |
|
3274 |
+ lib_meta.register("bool", function (parameters) { return lib_meta.construct("boolean", parameters); }); |
|
3275 |
+})(lib_meta || (lib_meta = {})); |
|
3276 |
+var lib_meta; |
|
3277 |
+(function (lib_meta) { |
|
3278 |
+ /** |
|
3279 |
+ * @author fenris |
|
3280 |
+ */ |
|
3281 |
+ var class_shape_integer = (function (_super) { |
|
3282 |
+ __extends(class_shape_integer, _super); |
|
3283 |
+ /** |
|
3284 |
+ * @author fenris |
|
3285 |
+ */ |
|
3286 |
+ function class_shape_integer(_a) { |
|
3287 |
+ var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? 0 : _c, _d = _a["min"], min = _d === void 0 ? null : _d, _e = _a["max"], max = _e === void 0 ? null : _e; |
|
3288 |
+ var _this = _super.call(this, { |
|
3289 |
+ "typename": "number", |
|
3290 |
+ "primitive": true, |
|
3291 |
+ "soft": soft, |
|
3292 |
+ "defaultvalue": defaultvalue |
|
3293 |
+ }) || this; |
|
3294 |
+ _this.min = min; |
|
3295 |
+ _this.max = max; |
|
3296 |
+ return _this; |
|
3297 |
+ } |
|
3298 |
+ /** |
|
3299 |
+ * @desc [accessor] [getter] |
|
3300 |
+ * @author fenris |
|
3301 |
+ */ |
|
3302 |
+ class_shape_integer.prototype.min_get = function () { |
|
3303 |
+ return this.min; |
|
3304 |
+ }; |
|
3305 |
+ /** |
|
3306 |
+ * @desc [accessor] [getter] |
|
3307 |
+ * @author fenris |
|
3308 |
+ */ |
|
3309 |
+ class_shape_integer.prototype.max_get = function () { |
|
3310 |
+ return this.max; |
|
3311 |
+ }; |
|
3312 |
+ /** |
|
3313 |
+ * @override |
|
3314 |
+ * @author fenris |
|
3315 |
+ */ |
|
3316 |
+ class_shape_integer.prototype.inspect = function (value) { |
|
3317 |
+ var messages = _super.prototype.inspect.call(this, value); |
|
3318 |
+ if (value != null) { |
|
3319 |
+ if ((this.min != null) && (value < this.min)) { |
|
3320 |
+ messages.push("value is below minimum of " + this.min.toString()); |
|
3321 |
+ } |
|
3322 |
+ if ((this.max != null) && (value > this.max)) { |
|
3323 |
+ messages.push("value is over maximum of " + this.max.toString()); |
|
3324 |
+ } |
|
3325 |
+ } |
|
3326 |
+ return messages; |
|
3327 |
+ }; |
|
3328 |
+ /** |
|
3329 |
+ * @override |
|
3330 |
+ * @author fenris |
|
3331 |
+ */ |
|
3332 |
+ class_shape_integer.prototype.to_raw = function () { |
|
3333 |
+ return { |
|
3334 |
+ "id": "integer", |
|
3335 |
+ "parameters": { |
|
3336 |
+ "soft": this.soft, |
|
3337 |
+ "min": this.min, |
|
3338 |
+ "max": this.max |
|
3339 |
+ } |
|
3340 |
+ }; |
|
3341 |
+ }; |
|
3342 |
+ return class_shape_integer; |
|
3343 |
+ }(lib_meta.class_shape_buildin)); |
|
3344 |
+ lib_meta.class_shape_integer = class_shape_integer; |
|
3345 |
+ lib_meta.register("integer", function (parameters) { |
|
3346 |
+ return (new class_shape_integer({ |
|
3347 |
+ "min": parameters["min"], |
|
3348 |
+ "max": parameters["max"], |
|
3349 |
+ "soft": parameters["soft"] |
|
3350 |
+ })); |
|
3351 |
+ }); |
|
3352 |
+ lib_meta.register("int", function (parameters) { return lib_meta.construct("integer", parameters); }); |
|
3353 |
+})(lib_meta || (lib_meta = {})); |
|
3354 |
+var lib_meta; |
|
3355 |
+(function (lib_meta) { |
|
3356 |
+ /** |
|
3357 |
+ * @author fenris |
|
3358 |
+ */ |
|
3359 |
+ var class_shape_float = (function (_super) { |
|
3360 |
+ __extends(class_shape_float, _super); |
|
3361 |
+ /** |
|
3362 |
+ * @author fenris |
|
3363 |
+ */ |
|
3364 |
+ function class_shape_float(_a) { |
|
3365 |
+ var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? 0.0 : _c, _d = _a["min"], min = _d === void 0 ? null : _d, _e = _a["max"], max = _e === void 0 ? null : _e; |
|
3366 |
+ var _this = _super.call(this, { |
|
3367 |
+ "typename": "number", |
|
3368 |
+ "primitive": true, |
|
3369 |
+ "soft": soft, |
|
3370 |
+ "defaultvalue": defaultvalue |
|
3371 |
+ }) || this; |
|
3372 |
+ _this.min = min; |
|
3373 |
+ _this.max = max; |
|
3374 |
+ return _this; |
|
3375 |
+ } |
|
3376 |
+ /** |
|
3377 |
+ * @desc [accessor] [getter] |
|
3378 |
+ * @author fenris |
|
3379 |
+ */ |
|
3380 |
+ class_shape_float.prototype.min_get = function () { |
|
3381 |
+ return this.min; |
|
3382 |
+ }; |
|
3383 |
+ /** |
|
3384 |
+ * @desc [accessor] [getter] |
|
3385 |
+ * @author fenris |
|
3386 |
+ */ |
|
3387 |
+ class_shape_float.prototype.max_get = function () { |
|
3388 |
+ return this.max; |
|
3389 |
+ }; |
|
3390 |
+ /** |
|
3391 |
+ * @override |
|
3392 |
+ * @author fenris |
|
3393 |
+ */ |
|
3394 |
+ class_shape_float.prototype.inspect = function (value) { |
|
3395 |
+ var messages = _super.prototype.inspect.call(this, value); |
|
3396 |
+ if (value != null) { |
|
3397 |
+ if ((this.min != null) && (value < this.min)) { |
|
3398 |
+ messages.push("value is below minimum of " + this.min.toString()); |
|
3399 |
+ } |
|
3400 |
+ if ((this.max != null) && (value > this.max)) { |
|
3401 |
+ messages.push("value is over maximum of " + this.max.toString()); |
|
3402 |
+ } |
|
3403 |
+ } |
|
3404 |
+ return messages; |
|
3405 |
+ }; |
|
3406 |
+ /** |
|
3407 |
+ * @override |
|
3408 |
+ * @author fenris |
|
3409 |
+ */ |
|
3410 |
+ class_shape_float.prototype.to_raw = function () { |
|
3411 |
+ return { |
|
3412 |
+ "id": "float", |
|
3413 |
+ "parameters": { |
|
3414 |
+ "soft": this.soft, |
|
3415 |
+ "min": this.min, |
|
3416 |
+ "max": this.max |
|
3417 |
+ } |
|
3418 |
+ }; |
|
3419 |
+ }; |
|
3420 |
+ return class_shape_float; |
|
3421 |
+ }(lib_meta.class_shape_buildin)); |
|
3422 |
+ lib_meta.class_shape_float = class_shape_float; |
|
3423 |
+ lib_meta.register("float", function (parameters) { |
|
3424 |
+ return (new class_shape_float({ |
|
3425 |
+ "min": parameters["min"], |
|
3426 |
+ "max": parameters["max"], |
|
3427 |
+ "soft": parameters["soft"] |
|
3428 |
+ })); |
|
3429 |
+ }); |
|
3430 |
+})(lib_meta || (lib_meta = {})); |
|
3431 |
+var lib_meta; |
|
3432 |
+(function (lib_meta) { |
|
3433 |
+ /** |
|
3434 |
+ * @author fenris |
|
3435 |
+ */ |
|
3436 |
+ var class_shape_string = (function (_super) { |
|
3437 |
+ __extends(class_shape_string, _super); |
|
3438 |
+ /** |
|
3439 |
+ * @author fenris |
|
3440 |
+ */ |
|
3441 |
+ function class_shape_string(_a) { |
|
3442 |
+ var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? "" : _c; |
|
3443 |
+ return _super.call(this, { |
|
3444 |
+ "typename": "string", |
|
3445 |
+ "primitive": true, |
|
3446 |
+ "soft": soft, |
|
3447 |
+ "defaultvalue": defaultvalue |
|
3448 |
+ }) || this; |
|
3449 |
+ } |
|
3450 |
+ /** |
|
3451 |
+ * @override |
|
3452 |
+ * @author fenris |
|
3453 |
+ */ |
|
3454 |
+ class_shape_string.prototype.to_raw = function () { |
|
3455 |
+ return { |
|
3456 |
+ "id": "string", |
|
3457 |
+ "parameters": { |
|
3458 |
+ "soft": this.soft |
|
3459 |
+ } |
|
3460 |
+ }; |
|
3461 |
+ }; |
|
3462 |
+ return class_shape_string; |
|
3463 |
+ }(lib_meta.class_shape_buildin)); |
|
3464 |
+ lib_meta.class_shape_string = class_shape_string; |
|
3465 |
+ /** |
|
3466 |
+ * @author fenris |
|
3467 |
+ */ |
|
3468 |
+ lib_meta.register("string", function (parameters) { |
|
3469 |
+ return (new class_shape_string({ |
|
3470 |
+ "soft": parameters["soft"] |
|
3471 |
+ })); |
|
3472 |
+ }); |
|
3473 |
+ lib_meta.register("str", function (parameters) { return lib_meta.construct("string", parameters); }); |
|
3474 |
+})(lib_meta || (lib_meta = {})); |
|
3475 |
+var lib_meta; |
|
3476 |
+(function (lib_meta) { |
|
3477 |
+ /** |
|
3478 |
+ * @author fenris |
|
3479 |
+ */ |
|
3480 |
+ var class_shape_email = (function (_super) { |
|
3481 |
+ __extends(class_shape_email, _super); |
|
3482 |
+ /** |
|
3483 |
+ * @author fenris |
|
3484 |
+ */ |
|
3485 |
+ function class_shape_email(_a) { |
|
3486 |
+ var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? "" : _c; |
|
3487 |
+ return _super.call(this, { |
|
3488 |
+ "primitive": true, |
|
3489 |
+ "soft": soft, |
|
3490 |
+ "defaultvalue": defaultvalue |
|
3491 |
+ }) || this; |
|
3492 |
+ } |
|
3493 |
+ /** |
|
3494 |
+ * @override |
|
3495 |
+ * @author fenris |
|
3496 |
+ */ |
|
3497 |
+ class_shape_email.prototype.to_raw = function () { |
|
3498 |
+ return { |
|
3499 |
+ "id": "email", |
|
3500 |
+ "parameters": { |
|
3501 |
+ "soft": this.soft |
|
3502 |
+ } |
|
3503 |
+ }; |
|
3504 |
+ }; |
|
3505 |
+ /** |
|
3506 |
+ * @desc [implementation] |
|
3507 |
+ * @author fenris |
|
3508 |
+ */ |
|
3509 |
+ class_shape_email.prototype._show = function () { |
|
3510 |
+ var str = "email"; |
|
3511 |
+ return str; |
|
3512 |
+ }; |
|
3513 |
+ return class_shape_email; |
|
3514 |
+ }(lib_meta.class_shape)); |
|
3515 |
+ lib_meta.class_shape_email = class_shape_email; |
|
3516 |
+ lib_meta.register("email", function (parameters) { |
|
3517 |
+ return (new class_shape_email({ |
|
3518 |
+ "soft": parameters["soft"] |
|
3519 |
+ })); |
|
3520 |
+ }); |
|
3521 |
+})(lib_meta || (lib_meta = {})); |
|
3522 |
+var lib_meta; |
|
3523 |
+(function (lib_meta) { |
|
3524 |
+ /** |
|
3525 |
+ * @author fenris |
|
3526 |
+ */ |
|
3527 |
+ var class_shape_array = (function (_super) { |
|
3528 |
+ __extends(class_shape_array, _super); |
|
3529 |
+ /** |
|
3530 |
+ * @author fenris |
|
3531 |
+ */ |
|
3532 |
+ function class_shape_array(_a) { |
|
3533 |
+ var shape_element = _a["shape_element"], _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? [] : _c; |
|
3534 |
+ var _this = _super.call(this, { |
|
3535 |
+ "primitive": false, |
|
3536 |
+ "soft": soft, |
|
3537 |
+ "defaultvalue": defaultvalue |
|
3538 |
+ }) || this; |
|
3539 |
+ _this.shape_element = shape_element; |
|
3540 |
+ return _this; |
|
3541 |
+ } |
|
3542 |
+ /** |
|
3543 |
+ * @desc [accessor] [getter] |
|
3544 |
+ * @author fenris |
|
3545 |
+ */ |
|
3546 |
+ class_shape_array.prototype.shape_element_get = function () { |
|
3547 |
+ return this.shape_element; |
|
3548 |
+ }; |
|
3549 |
+ /** |
|
3550 |
+ * @override |
|
3551 |
+ * @author fenris |
|
3552 |
+ */ |
|
3553 |
+ class_shape_array.prototype.inspect = function (value) { |
|
3554 |
+ var _this = this; |
|
3555 |
+ var messages = _super.prototype.inspect.call(this, value); |
|
3556 |
+ if (value != null) { |
|
3557 |
+ if (!((typeof (value) == "object") && (value instanceof Array))) { |
|
3558 |
+ messages.push("value is not an array"); |
|
3559 |
+ } |
|
3560 |
+ else { |
|
3561 |
+ var array = (value); |
|
3562 |
+ array.forEach(function (element, index) { |
|
3563 |
+ messages = messages.concat(_this.shape_element.inspect(element).map(function (message) { return "array element #" + index.toString() + ": " + message; })); |
|
3564 |
+ }); |
|
3565 |
+ } |
|
3566 |
+ } |
|
3567 |
+ return messages; |
|
3568 |
+ }; |
|
3569 |
+ /** |
|
3570 |
+ * @override |
|
3571 |
+ * @author fenris |
|
3572 |
+ */ |
|
3573 |
+ class_shape_array.prototype.to_raw = function () { |
|
3574 |
+ return { |
|
3575 |
+ "id": "array", |
|
3576 |
+ "parameters": { |
|
3577 |
+ "shape_element": this.shape_element.to_raw(), |
|
3578 |
+ "soft": this.soft |
|
3579 |
+ } |
|
3580 |
+ }; |
|
3581 |
+ }; |
|
3582 |
+ /** |
|
3583 |
+ * @desc [implementation] |
|
3584 |
+ * @author fenris |
|
3585 |
+ */ |
|
3586 |
+ class_shape_array.prototype._show = function () { |
|
3587 |
+ var str = "array"; |
|
3588 |
+ str += "<" + instance_show(this.shape_element) + ">"; |
|
3589 |
+ return str; |
|
3590 |
+ }; |
|
3591 |
+ return class_shape_array; |
|
3592 |
+ }(lib_meta.class_shape)); |
|
3593 |
+ lib_meta.class_shape_array = class_shape_array; |
|
3594 |
+ lib_meta.register("array", function (parameters) { |
|
3595 |
+ var shape_element_raw = lib_object.fetch(parameters, "shape_element", null, 2); |
|
3596 |
+ var shape_element = lib_meta.from_raw(shape_element_raw); |
|
3597 |
+ return (new class_shape_array({ |
|
3598 |
+ "shape_element": shape_element, |
|
3599 |
+ "soft": parameters["soft"] |
|
3600 |
+ })); |
|
3601 |
+ }); |
|
3602 |
+ lib_meta.register("arr", function (parameters) { return lib_meta.construct("array", parameters); }); |
|
3603 |
+})(lib_meta || (lib_meta = {})); |
|
3604 |
+var lib_meta; |
|
3605 |
+(function (lib_meta) { |
|
3606 |
+ /** |
|
3607 |
+ * @author fenris |
|
3608 |
+ */ |
|
3609 |
+ var class_shape_object = (function (_super) { |
|
3610 |
+ __extends(class_shape_object, _super); |
|
3611 |
+ /** |
|
3612 |
+ * @author fenris |
|
3613 |
+ */ |
|
3614 |
+ function class_shape_object(_a) { |
|
3615 |
+ var fields = _a["fields"], _b = _a["soft"], soft = _b === void 0 ? true : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? null : _c; |
|
3616 |
+ var _this = this; |
|
3617 |
+ if (defaultvalue == null) { |
|
3618 |
+ defaultvalue = {}; |
|
3619 |
+ fields.forEach(function (field) { |
|
3620 |
+ defaultvalue[field.name] = field.shape.defaultvalue_get(); |
|
3621 |
+ }); |
|
3622 |
+ } |
|
3623 |
+ _this = _super.call(this, { |
|
3624 |
+ "typename": "object", |
|
3625 |
+ "primitive": false, |
|
3626 |
+ "soft": soft, |
|
3627 |
+ "defaultvalue": defaultvalue |
|
3628 |
+ }) || this; |
|
3629 |
+ _this.fields = fields; |
|
3630 |
+ return _this; |
|
3631 |
+ } |
|
3632 |
+ /** |
|
3633 |
+ * @desc [accessor] [getter] |
|
3634 |
+ * @author fenris |
|
3635 |
+ */ |
|
3636 |
+ class_shape_object.prototype.fields_get = function () { |
|
3637 |
+ return this.fields; |
|
3638 |
+ }; |
|
3639 |
+ /** |
|
3640 |
+ * @override |
|
3641 |
+ * @author fenris |
|
3642 |
+ * @todo check for superfluous fields? |
|
3643 |
+ */ |
|
3644 |
+ class_shape_object.prototype.inspect = function (value) { |
|
3645 |
+ var messages = _super.prototype.inspect.call(this, value); |
|
3646 |
+ if (value != null) { |
|
3647 |
+ this.fields.forEach(function (field, index) { |
|
3648 |
+ var value_ = value[field.name]; |
|
3649 |
+ messages = messages.concat(field.shape.inspect(value_).map(function (message) { return "object field '" + field.name + "': " + message; })); |
|
3650 |
+ }); |
|
3651 |
+ } |
|
3652 |
+ return messages; |
|
3653 |
+ }; |
|
3654 |
+ /** |
|
3655 |
+ * @override |
|
3656 |
+ * @author fenris |
|
3657 |
+ */ |
|
3658 |
+ class_shape_object.prototype.to_raw = function () { |
|
3659 |
+ return { |
|
3660 |
+ "id": "object", |
|
3661 |
+ "parameters": { |
|
3662 |
+ "soft": this.soft, |
|
3663 |
+ "fields": this.fields.map(function (field) { |
|
3664 |
+ return { |
|
3665 |
+ "name": field.name, |
|
3666 |
+ "shape": field.shape.to_raw(), |
|
3667 |
+ "label": field.label |
|
3668 |
+ }; |
|
3669 |
+ }) |
|
3670 |
+ } |
|
3671 |
+ }; |
|
3672 |
+ }; |
|
3673 |
+ /** |
|
3674 |
+ * @desc [implementation] |
|
3675 |
+ * @author fenris |
|
3676 |
+ */ |
|
3677 |
+ class_shape_object.prototype._show = function () { |
|
3678 |
+ var str = _super.prototype._show.call(this); |
|
3679 |
+ var str_ = this.fields.map(function (field) { return field.name + ":" + instance_show(field.shape); }).join(","); |
|
3680 |
+ str = str + "<" + str_ + ">"; |
|
3681 |
+ return str; |
|
3682 |
+ }; |
|
3683 |
+ return class_shape_object; |
|
3684 |
+ }(lib_meta.class_shape_buildin)); |
|
3685 |
+ lib_meta.class_shape_object = class_shape_object; |
|
3686 |
+ lib_meta.register("object", function (parameters) { |
|
3687 |
+ var fields_ = lib_object.fetch(parameters, "fields", [], 1); |
|
3688 |
+ return (new class_shape_object({ |
|
3689 |
+ "fields": fields_.map(function (field_) { |
|
3690 |
+ var name = lib_object.fetch(field_, "name", null, 2); |
|
3691 |
+ var shape_raw = lib_object.fetch(field_, "shape", null, 2); |
|
3692 |
+ var shape = lib_meta.construct(shape_raw.id, shape_raw.parameters); |
|
3693 |
+ var label = lib_object.fetch(field_, "label", null, 1); |
|
3694 |
+ return { |
|
3695 |
+ "name": name, |
|
3696 |
+ "shape": shape, |
|
3697 |
+ "label": label |
|
3698 |
+ }; |
|
3699 |
+ }), |
|
3700 |
+ "soft": parameters["soft"] |
|
3701 |
+ })); |
|
3702 |
+ }); |
|
3703 |
+ lib_meta.register("obj", function (parameters) { return lib_meta.construct("object", parameters); }); |
|
3704 |
+})(lib_meta || (lib_meta = {})); |
|
3705 |
+var lib_meta; |
|
3706 |
+(function (lib_meta) { |
|
3707 |
+ /** |
|
3708 |
+ * @author fenris |
|
3709 |
+ */ |
|
3710 |
+ var class_shape_date = (function (_super) { |
|
3711 |
+ __extends(class_shape_date, _super); |
|
3712 |
+ /** |
|
3713 |
+ * @author fenris |
|
3714 |
+ */ |
|
3715 |
+ function class_shape_date(_a) { |
|
3716 |
+ var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? new Date(Date.now()) : _c; |
|
3717 |
+ return _super.call(this, { |
|
3718 |
+ "primitive": true, |
|
3719 |
+ "soft": soft, |
|
3720 |
+ "defaultvalue": defaultvalue |
|
3721 |
+ }) || this; |
|
3722 |
+ } |
|
3723 |
+ /** |
|
3724 |
+ * @override |
|
3725 |
+ * @author fenris |
|
3726 |
+ */ |
|
3727 |
+ class_shape_date.prototype.inspect = function (value) { |
|
3728 |
+ var messages = _super.prototype.inspect.call(this, value); |
|
3729 |
+ if (value != null) { |
|
3730 |
+ if (!((typeof (value) == "object") && (value instanceof Date))) { |
|
3731 |
+ messages.push("value is not a date"); |
|
3732 |
+ } |
|
3733 |
+ } |
|
3734 |
+ return messages; |
|
3735 |
+ }; |
|
3736 |
+ /** |
|
3737 |
+ * @override |
|
3738 |
+ * @author fenris |
|
3739 |
+ */ |
|
3740 |
+ class_shape_date.prototype.to_raw = function () { |
|
3741 |
+ return { |
|
3178 | 3742 |
"id": "date", |
3179 | 3743 |
"parameters": { |
3180 | 3744 |
"soft": this.soft |
3181 | 3745 |
} |
3182 | 3746 |
}; |
3183 | 3747 |
}; |
3184 |
- /** |
|
3185 |
- * @desc [implementation] |
|
3186 |
- * @author fenris |
|
3187 |
- */ |
|
3188 |
- class_shape_date.prototype._show = function () { |
|
3189 |
- var str = "date"; |
|
3190 |
- return str; |
|
3748 |
+ /** |
|
3749 |
+ * @desc [implementation] |
|
3750 |
+ * @author fenris |
|
3751 |
+ */ |
|
3752 |
+ class_shape_date.prototype._show = function () { |
|
3753 |
+ var str = "date"; |
|
3754 |
+ return str; |
|
3755 |
+ }; |
|
3756 |
+ return class_shape_date; |
|
3757 |
+ }(lib_meta.class_shape)); |
|
3758 |
+ lib_meta.class_shape_date = class_shape_date; |
|
3759 |
+ lib_meta.register("date", function (parameters) { |
|
3760 |
+ return (new class_shape_date({ |
|
3761 |
+ "soft": parameters["soft"] |
|
3762 |
+ })); |
|
3763 |
+ }); |
|
3764 |
+})(lib_meta || (lib_meta = {})); |
|
3765 |
+var lib_meta; |
|
3766 |
+(function (lib_meta) { |
|
3767 |
+ /** |
|
3768 |
+ * @desc represented as milliseconds of day |
|
3769 |
+ * @author fenris |
|
3770 |
+ */ |
|
3771 |
+ var class_shape_time = (function (_super) { |
|
3772 |
+ __extends(class_shape_time, _super); |
|
3773 |
+ /** |
|
3774 |
+ * @author fenris |
|
3775 |
+ */ |
|
3776 |
+ function class_shape_time(_a) { |
|
3777 |
+ var _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? class_shape_time.from_timestamp(Date.now()) : _c; |
|
3778 |
+ return _super.call(this, { |
|
3779 |
+ "primitive": true, |
|
3780 |
+ "soft": soft, |
|
3781 |
+ "defaultvalue": defaultvalue |
|
3782 |
+ }) || this; |
|
3783 |
+ } |
|
3784 |
+ /** |
|
3785 |
+ * @override |
|
3786 |
+ * @author fenris |
|
3787 |
+ */ |
|
3788 |
+ class_shape_time.prototype.inspect = function (value) { |
|
3789 |
+ var messages = _super.prototype.inspect.call(this, value); |
|
3790 |
+ if (value != null) { |
|
3791 |
+ if (!(typeof (value) == "object")) { |
|
3792 |
+ messages.push("value is not a time"); |
|
3793 |
+ } |
|
3794 |
+ else { |
|
3795 |
+ if (!("hours" in value)) { |
|
3796 |
+ messages.push("hour is missing"); |
|
3797 |
+ } |
|
3798 |
+ if (!("minutes" in value)) { |
|
3799 |
+ messages.push("minutes is missing"); |
|
3800 |
+ } |
|
3801 |
+ if (!("seconds" in value)) { |
|
3802 |
+ messages.push("seconds is missing"); |
|
3803 |
+ } |
|
3804 |
+ } |
|
3805 |
+ } |
|
3806 |
+ return messages; |
|
3807 |
+ }; |
|
3808 |
+ /** |
|
3809 |
+ * @override |
|
3810 |
+ * @author fenris |
|
3811 |
+ */ |
|
3812 |
+ class_shape_time.prototype.to_raw = function () { |
|
3813 |
+ return { |
|
3814 |
+ "id": "time", |
|
3815 |
+ "parameters": { |
|
3816 |
+ "soft": this.soft |
|
3817 |
+ } |
|
3818 |
+ }; |
|
3819 |
+ }; |
|
3820 |
+ /** |
|
3821 |
+ * @desc [implementation] |
|
3822 |
+ * @author fenris |
|
3823 |
+ */ |
|
3824 |
+ class_shape_time.prototype._show = function () { |
|
3825 |
+ var str = "time"; |
|
3826 |
+ return str; |
|
3827 |
+ }; |
|
3828 |
+ /** |
|
3829 |
+ * @author fenris |
|
3830 |
+ */ |
|
3831 |
+ class_shape_time.from_date = function (date) { |
|
3832 |
+ var hours = date.getHours(); |
|
3833 |
+ var minutes = date.getMinutes(); |
|
3834 |
+ var seconds = date.getSeconds(); |
|
3835 |
+ return { "hours": hours, "minutes": minutes, "seconds": seconds }; |
|
3836 |
+ }; |
|
3837 |
+ /** |
|
3838 |
+ * @author fenris |
|
3839 |
+ */ |
|
3840 |
+ class_shape_time.from_timestamp = function (timestamp) { |
|
3841 |
+ var date = new Date(timestamp); |
|
3842 |
+ return this.from_date(date); |
|
3843 |
+ }; |
|
3844 |
+ /** |
|
3845 |
+ * @author fenris |
|
3846 |
+ */ |
|
3847 |
+ class_shape_time.now = function () { |
|
3848 |
+ return this.from_timestamp(Date.now()); |
|
3849 |
+ }; |
|
3850 |
+ return class_shape_time; |
|
3851 |
+ }(lib_meta.class_shape)); |
|
3852 |
+ lib_meta.class_shape_time = class_shape_time; |
|
3853 |
+ /** |
|
3854 |
+ * @author fenris |
|
3855 |
+ */ |
|
3856 |
+ lib_meta.register("time", function (parameters) { |
|
3857 |
+ return (new class_shape_time({ |
|
3858 |
+ "soft": parameters["soft"] |
|
3859 |
+ })); |
|
3860 |
+ }); |
|
3861 |
+})(lib_meta || (lib_meta = {})); |
|
3862 |
+var lib_meta; |
|
3863 |
+(function (lib_meta) { |
|
3864 |
+ /** |
|
3865 |
+ * @author fenris |
|
3866 |
+ */ |
|
3867 |
+ var class_shape_enumeration = (function (_super) { |
|
3868 |
+ __extends(class_shape_enumeration, _super); |
|
3869 |
+ /** |
|
3870 |
+ * @author fenris |
|
3871 |
+ */ |
|
3872 |
+ function class_shape_enumeration(_a) { |
|
3873 |
+ var shape_option = _a["shape_option"], options = _a["options"], _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? undefined : _c; |
|
3874 |
+ var _this = this; |
|
3875 |
+ if (defaultvalue === undefined) { |
|
3876 |
+ if (soft) { |
|
3877 |
+ defaultvalue = null; |
|
3878 |
+ } |
|
3879 |
+ else { |
|
3880 |
+ if (options.length == 0) { |
|
3881 |
+ throw (new Error("a hard enumeration must have at least one option")); |
|
3882 |
+ } |
|
3883 |
+ else { |
|
3884 |
+ defaultvalue = options[0].value; |
|
3885 |
+ } |
|
3886 |
+ } |
|
3887 |
+ } |
|
3888 |
+ _this = _super.call(this, { |
|
3889 |
+ "primitive": true, |
|
3890 |
+ "soft": soft, |
|
3891 |
+ "defaultvalue": defaultvalue |
|
3892 |
+ }) || this; |
|
3893 |
+ _this.shape_option = shape_option; |
|
3894 |
+ _this.options = options; |
|
3895 |
+ return _this; |
|
3896 |
+ } |
|
3897 |
+ /** |
|
3898 |
+ * @desc [accessor] [getter] |
|
3899 |
+ * @author fenris |
|
3900 |
+ */ |
|
3901 |
+ class_shape_enumeration.prototype.shape_option_get = function () { |
|
3902 |
+ return this.shape_option; |
|
3903 |
+ }; |
|
3904 |
+ /** |
|
3905 |
+ * @desc [accessor] [getter] |
|
3906 |
+ * @author fenris |
|
3907 |
+ */ |
|
3908 |
+ class_shape_enumeration.prototype.options_get = function () { |
|
3909 |
+ return this.options; |
|
3910 |
+ }; |
|
3911 |
+ /** |
|
3912 |
+ * @override |
|
3913 |
+ * @author fenris |
|
3914 |
+ */ |
|
3915 |
+ class_shape_enumeration.prototype.inspect = function (value) { |
|
3916 |
+ var messages = _super.prototype.inspect.call(this, value); |
|
3917 |
+ if (value != null) { |
|
3918 |
+ if (!this.shape_option.check(value)) { |
|
3919 |
+ messages.push("value has not the specified option shape"); |
|
3920 |
+ } |
|
3921 |
+ else { |
|
3922 |
+ var found = this.options.some(function (option) { return instance_collate(option.value, value); }); |
|
3923 |
+ if (!found) { |
|
3924 |
+ messages.push("value is not one of the specified options"); |
|
3925 |
+ } |
|
3926 |
+ } |
|
3927 |
+ } |
|
3928 |
+ return messages; |
|
3929 |
+ }; |
|
3930 |
+ /** |
|
3931 |
+ * @override |
|
3932 |
+ * @author fenris |
|
3933 |
+ */ |
|
3934 |
+ class_shape_enumeration.prototype.to_raw = function () { |
|
3935 |
+ return { |
|
3936 |
+ "id": "enumeration", |
|
3937 |
+ "parameters": { |
|
3938 |
+ "shape_option": this.shape_option.to_raw(), |
|
3939 |
+ "options": this.options.map(function (option) { |
|
3940 |
+ return { |
|
3941 |
+ "value": option.value, |
|
3942 |
+ "label": option.label |
|
3943 |
+ }; |
|
3944 |
+ }), |
|
3945 |
+ "soft": this.soft |
|
3946 |
+ } |
|
3947 |
+ }; |
|
3948 |
+ }; |
|
3949 |
+ /** |
|
3950 |
+ * @desc [implementation] |
|
3951 |
+ * @author fenris |
|
3952 |
+ */ |
|
3953 |
+ class_shape_enumeration.prototype._show = function () { |
|
3954 |
+ var str = "enumeration"; |
|
3955 |
+ { |
|
3956 |
+ str = str + "<" + instance_show(this.shape_option) + ">"; |
|
3957 |
+ } |
|
3958 |
+ { |
|
3959 |
+ var str_ = this.options.map(function (option) { return instance_show(option.value); }).join(","); |
|
3960 |
+ str = str + "[" + str_ + "]"; |
|
3961 |
+ } |
|
3962 |
+ return str; |
|
3963 |
+ }; |
|
3964 |
+ return class_shape_enumeration; |
|
3965 |
+ }(lib_meta.class_shape)); |
|
3966 |
+ lib_meta.class_shape_enumeration = class_shape_enumeration; |
|
3967 |
+ lib_meta.register("enumeration", function (parameters) { |
|
3968 |
+ var shape_option_raw = lib_object.fetch(parameters, "shape_option", null, 2); |
|
3969 |
+ var shape_option = lib_meta.from_raw(shape_option_raw); |
|
3970 |
+ var options = lib_object.fetch(parameters, "options", [], 2); |
|
3971 |
+ return (new class_shape_enumeration({ |
|
3972 |
+ "shape_option": shape_option, |
|
3973 |
+ "options": options, |
|
3974 |
+ "soft": parameters["soft"] |
|
3975 |
+ })); |
|
3976 |
+ }); |
|
3977 |
+})(lib_meta || (lib_meta = {})); |
|
3978 |
+var lib_meta; |
|
3979 |
+(function (lib_meta) { |
|
3980 |
+ /** |
|
3981 |
+ * @author fenris |
|
3982 |
+ */ |
|
3983 |
+ var class_shape_map = (function (_super) { |
|
3984 |
+ __extends(class_shape_map, _super); |
|
3985 |
+ /** |
|
3986 |
+ * @author fenris |
|
3987 |
+ */ |
|
3988 |
+ function class_shape_map(_a) { |
|
3989 |
+ var shape_key = _a["shape_key"], shape_value = _a["shape_value"], _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? {} : _c; |
|
3990 |
+ var _this = _super.call(this, { |
|
3991 |
+ "primitive": true, |
|
3992 |
+ "soft": soft, |
|
3993 |
+ "defaultvalue": defaultvalue |
|
3994 |
+ }) || this; |
|
3995 |
+ _this.shape_key = shape_key; |
|
3996 |
+ _this.shape_value = shape_value; |
|
3997 |
+ return _this; |
|
3998 |
+ } |
|
3999 |
+ /** |
|
4000 |
+ * @desc [accessor] [getter] |
|
4001 |
+ * @author fenris |
|
4002 |
+ */ |
|
4003 |
+ class_shape_map.prototype.shape_key_get = function () { |
|
4004 |
+ return this.shape_key; |
|
4005 |
+ }; |
|
4006 |
+ /** |
|
4007 |
+ * @desc [accessor] [getter] |
|
4008 |
+ * @author fenris |
|
4009 |
+ */ |
|
4010 |
+ class_shape_map.prototype.shape_value_get = function () { |
|
4011 |
+ return this.shape_value; |
|
4012 |
+ }; |
|
4013 |
+ /** |
|
4014 |
+ * @override |
|
4015 |
+ * @author fenris |
|
4016 |
+ */ |
|
4017 |
+ class_shape_map.prototype.inspect = function (value) { |
|
4018 |
+ var _this = this; |
|
4019 |
+ var messages = _super.prototype.inspect.call(this, value); |
|
4020 |
+ if (value != null) { |
|
4021 |
+ if (typeof (value) != "object") { |
|
4022 |
+ messages.push("value is not an object"); |
|
4023 |
+ } |
|
4024 |
+ else { |
|
4025 |
+ Object.keys(value).forEach(function (key, index) { |
|
4026 |
+ var value_ = value[key]; |
|
4027 |
+ messages = messages.concat(_this.shape_key.inspect(key).map(function (message) { return "map entry #" + index.toString() + " key: " + message; })); |
|
4028 |
+ messages = messages.concat(_this.shape_value.inspect(value_).map(function (message) { return "map entry #" + index.toString() + " value: " + message; })); |
|
4029 |
+ }); |
|
4030 |
+ } |
|
4031 |
+ } |
|
4032 |
+ return messages; |
|
4033 |
+ }; |
|
4034 |
+ /** |
|
4035 |
+ * @override |
|
4036 |
+ * @author fenris |
|
4037 |
+ */ |
|
4038 |
+ class_shape_map.prototype.to_raw = function () { |
|
4039 |
+ return { |
|
4040 |
+ "id": "map", |
|
4041 |
+ "parameters": { |
|
4042 |
+ "shape_key": this.shape_key.to_raw(), |
|
4043 |
+ "shape_value": this.shape_value.to_raw(), |
|
4044 |
+ "soft": this.soft |
|
4045 |
+ } |
|
4046 |
+ }; |
|
4047 |
+ }; |
|
4048 |
+ /** |
|
4049 |
+ * @desc [implementation] |
|
4050 |
+ * @author fenris |
|
4051 |
+ */ |
|
4052 |
+ class_shape_map.prototype._show = function () { |
|
4053 |
+ var str = "map"; |
|
4054 |
+ str += "<" + instance_show(this.shape_key) + "," + instance_show(this.shape_value) + ">"; |
|
4055 |
+ return str; |
|
4056 |
+ }; |
|
4057 |
+ return class_shape_map; |
|
4058 |
+ }(lib_meta.class_shape)); |
|
4059 |
+ lib_meta.class_shape_map = class_shape_map; |
|
4060 |
+ lib_meta.register("map", function (parameters) { |
|
4061 |
+ var shape_key_raw = lib_object.fetch(parameters, "shape_key", null, 2); |
|
4062 |
+ var shape_key = lib_meta.construct(shape_key_raw.id, shape_key_raw.parameters); |
|
4063 |
+ var shape_value_raw = lib_object.fetch(parameters, "shape_value", null, 2); |
|
4064 |
+ var shape_value = lib_meta.from_raw(shape_value_raw); |
|
4065 |
+ return (new class_shape_map({ |
|
4066 |
+ "shape_key": shape_key, |
|
4067 |
+ "shape_value": shape_value, |
|
4068 |
+ "soft": parameters["soft"] |
|
4069 |
+ })); |
|
4070 |
+ }); |
|
4071 |
+})(lib_meta || (lib_meta = {})); |
|
4072 |
+var lib_meta; |
|
4073 |
+(function (lib_meta) { |
|
4074 |
+ /** |
|
4075 |
+ * @author fenris |
|
4076 |
+ */ |
|
4077 |
+ var class_shape_function = (function (_super) { |
|
4078 |
+ __extends(class_shape_function, _super); |
|
4079 |
+ /** |
|
4080 |
+ * @author fenris |
|
4081 |
+ */ |
|
4082 |
+ function class_shape_function(_a) { |
|
4083 |
+ var shape_input = _a["shape_input"], shape_output = _a["shape_output"], _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? {} : _c; |
|
4084 |
+ var _this = _super.call(this, { |
|
4085 |
+ "primitive": true, |
|
4086 |
+ "soft": soft, |
|
4087 |
+ "defaultvalue": defaultvalue |
|
4088 |
+ }) || this; |
|
4089 |
+ _this.shape_input = shape_input; |
|
4090 |
+ _this.shape_output = shape_output; |
|
4091 |
+ return _this; |
|
4092 |
+ } |
|
4093 |
+ /** |
|
4094 |
+ * @desc [accessor] [getter] |
|
4095 |
+ * @author fenris |
|
4096 |
+ */ |
|
4097 |
+ class_shape_function.prototype.shape_input_get = function () { |
|
4098 |
+ return this.shape_input; |
|
4099 |
+ }; |
|
4100 |
+ /** |
|
4101 |
+ * @desc [accessor] [getter] |
|
4102 |
+ * @author fenris |
|
4103 |
+ */ |
|
4104 |
+ class_shape_function.prototype.shape_output_get = function () { |
|
4105 |
+ return this.shape_output; |
|
4106 |
+ }; |
|
4107 |
+ /** |
|
4108 |
+ * @override |
|
4109 |
+ * @author fenris |
|
4110 |
+ */ |
|
4111 |
+ class_shape_function.prototype.inspect = function (value) { |
|
4112 |
+ var messages = _super.prototype.inspect.call(this, value); |
|
4113 |
+ if (value != null) { |
|
4114 |
+ if (typeof (value) != "function") { |
|
4115 |
+ messages.push("value is not an object"); |
|
4116 |
+ } |
|
4117 |
+ else { |
|
4118 |
+ } |
|
4119 |
+ } |
|
4120 |
+ return messages; |
|
4121 |
+ }; |
|
4122 |
+ /** |
|
4123 |
+ * @override |
|
4124 |
+ * @author fenris |
|
4125 |
+ */ |
|
4126 |
+ class_shape_function.prototype.to_raw = function () { |
|
4127 |
+ return { |
|
4128 |
+ "id": "function", |
|
4129 |
+ "parameters": { |
|
4130 |
+ "shape_input": this.shape_input.to_raw(), |
|
4131 |
+ "shape_output": this.shape_output.to_raw(), |
|
4132 |
+ "soft": this.soft |
|
4133 |
+ } |
|
4134 |
+ }; |
|
4135 |
+ }; |
|
4136 |
+ /** |
|
4137 |
+ * @desc [implementation] |
|
4138 |
+ * @author fenris |
|
4139 |
+ */ |
|
4140 |
+ class_shape_function.prototype._show = function () { |
|
4141 |
+ var str = "function"; |
|
4142 |
+ str += "<" + instance_show(this.shape_input) + "," + instance_show(this.shape_output) + ">"; |
|
4143 |
+ return str; |
|
4144 |
+ }; |
|
4145 |
+ return class_shape_function; |
|
4146 |
+ }(lib_meta.class_shape)); |
|
4147 |
+ lib_meta.class_shape_function = class_shape_function; |
|
4148 |
+ lib_meta.register("function", function (parameters) { |
|
4149 |
+ var shape_input_raw = lib_object.fetch(parameters, "shape_input", null, 2); |
|
4150 |
+ var shape_input = lib_meta.construct(shape_input_raw.id, shape_input_raw.parameters); |
|
4151 |
+ var shape_output_raw = lib_object.fetch(parameters, "shape_output", null, 2); |
|
4152 |
+ var shape_output = lib_meta.from_raw(shape_output_raw); |
|
4153 |
+ return (new class_shape_function({ |
|
4154 |
+ "shape_input": shape_input, |
|
4155 |
+ "shape_output": shape_output, |
|
4156 |
+ "soft": parameters["soft"] |
|
4157 |
+ })); |
|
4158 |
+ }); |
|
4159 |
+})(lib_meta || (lib_meta = {})); |
|
4160 |
+var lib_meta; |
|
4161 |
+(function (lib_meta) { |
|
4162 |
+ /** |
|
4163 |
+ * @author fenris |
|
4164 |
+ * @todo use a treemap-function (but first make one :P) |
|
4165 |
+ */ |
|
4166 |
+ function adjust_labels(shape, transformator) { |
|
4167 |
+ if (false) { |
|
4168 |
+ } |
|
4169 |
+ else if (shape instanceof lib_meta.class_shape_enumeration) { |
|
4170 |
+ var shape_ = (shape); |
|
4171 |
+ return (new lib_meta.class_shape_enumeration({ |
|
4172 |
+ "shape_option": adjust_labels(shape_.shape_option_get(), transformator), |
|
4173 |
+ "options": shape_.options_get().map(function (option) { |
|
4174 |
+ return { |
|
4175 |
+ "value": option.value, |
|
4176 |
+ "label": transformator(option.label) |
|
4177 |
+ }; |
|
4178 |
+ }), |
|
4179 |
+ "soft": shape_.soft_get(), |
|
4180 |
+ "defaultvalue": shape_.defaultvalue_get() |
|
4181 |
+ })); |
|
4182 |
+ } |
|
4183 |
+ else if (shape instanceof lib_meta.class_shape_array) { |
|
4184 |
+ var shape_ = (shape); |
|
4185 |
+ return (new lib_meta.class_shape_array({ |
|
4186 |
+ "shape_element": adjust_labels(shape_.shape_element_get(), transformator), |
|
4187 |
+ "soft": shape_.soft_get(), |
|
4188 |
+ "defaultvalue": shape_.defaultvalue_get() |
|
4189 |
+ })); |
|
4190 |
+ } |
|
4191 |
+ else if (shape instanceof lib_meta.class_shape_object) { |
|
4192 |
+ var shape_ = (shape); |
|
4193 |
+ return (new lib_meta.class_shape_object({ |
|
4194 |
+ "fields": shape_.fields_get().map(function (field) { |
|
4195 |
+ return { |
|
4196 |
+ "name": field.name, |
|
4197 |
+ "shape": adjust_labels(field.shape, transformator), |
|
4198 |
+ "label": transformator(field.label) |
|
4199 |
+ }; |
|
4200 |
+ }), |
|
4201 |
+ "soft": shape_.soft_get(), |
|
4202 |
+ "defaultvalue": shape_.defaultvalue_get() |
|
4203 |
+ })); |
|
4204 |
+ } |
|
4205 |
+ else { |
|
4206 |
+ // shape["label"] = ((shape["label"] == null) ? null : transformator(shape["label"])); |
|
4207 |
+ return shape; |
|
4208 |
+ } |
|
4209 |
+ } |
|
4210 |
+ lib_meta.adjust_labels = adjust_labels; |
|
4211 |
+})(lib_meta || (lib_meta = {})); |
|
4212 |
+var plain_text_to_html = function (text) { |
|
4213 |
+ var ret = text; |
|
4214 |
+ ret = ret.replace(/ /g, " "); // convert multiple whitespace to forced ones |
|
4215 |
+ ret = ret.split("\n").join("<br/>"); |
|
4216 |
+ return ret; |
|
4217 |
+}; |
|
4218 |
+/** |
|
4219 |
+ * @desc makes a valid |
|
4220 |
+ */ |
|
4221 |
+var format_sentence = function (str, rtl, caseSense) { |
|
4222 |
+ if (rtl === void 0) { rtl = false; } |
|
4223 |
+ if (caseSense === void 0) { caseSense = true; } |
|
4224 |
+ if (str === "") { |
|
4225 |
+ return str; |
|
4226 |
+ } |
|
4227 |
+ else { |
|
4228 |
+ var marks = { |
|
4229 |
+ ".": true, |
|
4230 |
+ "?": true, |
|
4231 |
+ "!": true |
|
4232 |
+ }; |
|
4233 |
+ var default_mark = "."; |
|
4234 |
+ var ret = str.split(""); |
|
4235 |
+ if (!rtl) { |
|
4236 |
+ ret[0] = ret[0].toLocaleUpperCase(); |
|
4237 |
+ if (!(ret[ret.length - 1] in marks)) { |
|
4238 |
+ ret.push(default_mark); |
|
4239 |
+ } |
|
4240 |
+ } |
|
4241 |
+ else { |
|
4242 |
+ ret[ret.length - 1] = ret[ret.length - 1].toLocaleUpperCase(); |
|
4243 |
+ if (!(ret[0] in marks)) { |
|
4244 |
+ ret.unshift(default_mark); |
|
4245 |
+ } |
|
4246 |
+ } |
|
4247 |
+ return ret.join(""); |
|
4248 |
+ } |
|
4249 |
+}; |
|
4250 |
+var fill_string_template = function (template_string, object, fabric, delimiter, default_string, sloppy) { |
|
4251 |
+ if (fabric === void 0) { fabric = function (object, key) { return object[key]; }; } |
|
4252 |
+ if (delimiter === void 0) { delimiter = "%"; } |
|
4253 |
+ if (default_string === void 0) { default_string = null; } |
|
4254 |
+ function get_tags(str) { |
|
4255 |
+ var r = new RegExp(delimiter + "[^\\s^" + delimiter + "]+" + delimiter, "gi"); |
|
4256 |
+ return ((str.match(r) || []).map(function (e) { |
|
4257 |
+ return e.slice(delimiter.length, e.length - delimiter.length); |
|
4258 |
+ })); |
|
4259 |
+ } |
|
4260 |
+ function replace_tag(str, tag, value) { |
|
4261 |
+ var r = new RegExp(delimiter + tag + delimiter, "gi"); |
|
4262 |
+ return str.replace(r, value); |
|
4263 |
+ } |
|
4264 |
+ function replace_tags(str, obj) { |
|
4265 |
+ return (get_tags(str).reduce(function (ret, key) { |
|
4266 |
+ var value = ""; |
|
4267 |
+ try { |
|
4268 |
+ value = fabric(obj, key); |
|
4269 |
+ if ((!sloppy && (value === void 0)) || (sloppy && (value == void 0))) { |
|
4270 |
+ value = default_string; |
|
4271 |
+ } |
|
4272 |
+ } |
|
4273 |
+ catch (e) { |
|
4274 |
+ console.warn("invalid placeholder " + key); |
|
4275 |
+ value = default_string; |
|
4276 |
+ } |
|
4277 |
+ return replace_tag(ret, key, value); |
|
4278 |
+ }, str)); |
|
4279 |
+ } |
|
4280 |
+ return replace_tags(template_string, object); |
|
4281 |
+}; |
|
4282 |
+var make_string_template = function (_template, _fabrics) { |
|
4283 |
+ if (_fabrics === void 0) { _fabrics = {}; } |
|
4284 |
+ function replace_tag(str, tag, value) { |
|
4285 |
+ var r = new RegExp("%" + tag + "%", "gi"); |
|
4286 |
+ return str.replace(r, value); |
|
4287 |
+ } |
|
4288 |
+ function replace_tags(str, obj) { |
|
4289 |
+ return (Object.keys(obj).reduce(function (ret, key) { |
|
4290 |
+ return replace_tag(ret, key, _fabrics[key] || obj[key]); |
|
4291 |
+ }, str)); |
|
4292 |
+ } |
|
4293 |
+ return (function (tags) { |
|
4294 |
+ return replace_tags(_template, tags); |
|
4295 |
+ }); |
|
4296 |
+}; |
|
4297 |
+var make_eml_header = (function () { |
|
4298 |
+ var _template = ""; |
|
4299 |
+ _template += "From: %from%\n"; |
|
4300 |
+ _template += "To: %recipient%\n"; |
|
4301 |
+ _template += "Subject: %subject%\n"; |
|
4302 |
+ _template += "X-Mailer: greenscale-plankton.emlgen\n"; |
|
4303 |
+ return make_string_template(_template); |
|
4304 |
+})(); |
|
4305 |
+var make_eml_body = (function () { |
|
4306 |
+ var exports = {}; |
|
4307 |
+ exports["simple_body"] = make_string_template("Content-Type: %contenttype%\n\n%body%\n\n"); |
|
4308 |
+ // very basic implementation |
|
4309 |
+ // parts = [{contenttype:"text/html; charset=UTF-8", body: "<h1>foo</h1>" }, {...}] |
|
4310 |
+ exports["body_boundrary"] = function (parts, boundrary) { |
|
4311 |
+ var _template = ""; |
|
4312 |
+ _template += "--%boundrary%\n"; |
|
4313 |
+ _template += "Content-Type: %contenttype%\n\n%body%\n\n"; |
|
4314 |
+ //_template += "--%boundrary%--\n\n"; |
|
4315 |
+ var maker = make_string_template(_template); |
|
4316 |
+ return (parts.reduce(function (prev, curr) { |
|
4317 |
+ curr.boundrary = boundrary; |
|
4318 |
+ return [prev, maker(curr)].join(""); |
|
4319 |
+ }, "")); |
|
4320 |
+ }; |
|
4321 |
+ // body must be base64 encoded! |
|
4322 |
+ exports["attachment_boundrary"] = function (parts, boundrary) { |
|
4323 |
+ var _template = ""; |
|
4324 |
+ _template += "--%boundrary%\n"; |
|
4325 |
+ _template += "Content-Type: %contenttype%\n"; |
|
4326 |
+ _template += "Content-Transfer-Encoding: base64\n"; |
|
4327 |
+ _template += "Content-Disposition: %disposition%; filename=\"%name%\"\n\n"; |
|
4328 |
+ _template += "%body%\n\n"; |
|
4329 |
+ //_template += "--%boundrary%--\n\n"; |
|
4330 |
+ var maker = make_string_template(_template); |
|
4331 |
+ return (parts.reduce(function (prev, curr) { |
|
4332 |
+ curr.boundrary = boundrary; |
|
4333 |
+ if (curr.disposition === void 0) |
|
4334 |
+ curr.disposition = "inline"; |
|
4335 |
+ return [prev, maker(curr)].join(""); |
|
4336 |
+ }, "")); |
|
4337 |
+ }; |
|
4338 |
+ exports["gen_boundrary"] = function () { |
|
4339 |
+ return ("xxxxxxxxxxxxxxxxxxxxxx".replace(/[xy]/g, function (c) { |
|
4340 |
+ var r = crypto.getRandomValues(new Uint8Array(1))[0] % 16 | 0, v = c == "x" ? r : (r & 0x3 | 0x8); |
|
4341 |
+ return v.toString(16); |
|
4342 |
+ })); |
|
4343 |
+ }; |
|
4344 |
+ // simple implementation without alternatives (old rfc) |
|
4345 |
+ exports["complete_boundrary"] = function (bodyparts, attachments) { |
|
4346 |
+ var ret = ""; |
|
4347 |
+ var boundrary = exports["gen_boundrary"](); |
|
4348 |
+ ret += exports["body_boundrary"](bodyparts, boundrary); |
|
4349 |
+ ret += exports["attachment_boundrary"](attachments, boundrary); |
|
4350 |
+ ret += "--" + boundrary + "--\n\nINVISIBLE!!!!"; |
|
4351 |
+ return (exports["simple_body"]({ |
|
4352 |
+ "contenttype": sprintf("multipart/mixed; boundary=%s", [boundrary]), |
|
4353 |
+ "body": ret |
|
4354 |
+ })); |
|
4355 |
+ }; |
|
4356 |
+ return exports; |
|
4357 |
+})(); |
|
4358 |
+///<reference path="../../base/build/logic-decl.d.ts"/> |
|
4359 |
+var lib_string; |
|
4360 |
+(function (lib_string) { |
|
4361 |
+ /** |
|
4362 |
+ * @author frac |
|
4363 |
+ */ |
|
4364 |
+ var hexdigits = 4; |
|
4365 |
+ /** |
|
4366 |
+ * @author frac |
|
4367 |
+ */ |
|
4368 |
+ var index_max = 1 << (4 * hexdigits); |
|
4369 |
+ /** |
|
4370 |
+ * @author frac |
|
4371 |
+ */ |
|
4372 |
+ var index_is = 0; |
|
4373 |
+ /** |
|
4374 |
+ * @author neuc,frac |
|
4375 |
+ */ |
|
4376 |
+ function empty(str) { |
|
4377 |
+ var tmp = str.trim(); |
|
4378 |
+ return (tmp === ""); |
|
4379 |
+ } |
|
4380 |
+ lib_string.empty = empty; |
|
4381 |
+ /** |
|
4382 |
+ * @desc returns a unique string |
|
4383 |
+ * @param {string} prefix an optional prefix for the generated string |
|
4384 |
+ * @return {string} |
|
4385 |
+ * @author frac |
|
4386 |
+ */ |
|
4387 |
+ function generate(prefix) { |
|
4388 |
+ if (prefix === void 0) { prefix = "string_"; } |
|
4389 |
+ if (index_is > index_max) { |
|
4390 |
+ throw (new Error("[string_generate] out of valid indices")); |
|
4391 |
+ } |
|
4392 |
+ else { |
|
4393 |
+ return lib_string.sprintf(prefix + "%0" + hexdigits.toString() + "X", [index_is++]); |
|
4394 |
+ } |
|
4395 |
+ } |
|
4396 |
+ lib_string.generate = generate; |
|
4397 |
+ /** |
|
4398 |
+ * @desc splits a string, but returns an empty list, if the string is empty |
|
4399 |
+ * @param {string} chain |
|
4400 |
+ * @param {string} separator |
|
4401 |
+ * @return {Array<string>} |
|
4402 |
+ * @author frac |
|
4403 |
+ */ |
|
4404 |
+ function split(chain, separator) { |
|
4405 |
+ if (separator === void 0) { separator = " "; } |
|
4406 |
+ if (chain.length == 0) { |
|
4407 |
+ return []; |
|
4408 |
+ } |
|
4409 |
+ else { |
|
4410 |
+ return chain.split(separator); |
|
4411 |
+ } |
|
4412 |
+ } |
|
4413 |
+ lib_string.split = split; |
|
4414 |
+ /** |
|
4415 |
+ * @desc concats a given word with itself n times |
|
4416 |
+ * @param {string} word |
|
4417 |
+ * @param {int} |
|
4418 |
+ * @return {string} |
|
4419 |
+ * @author frac |
|
4420 |
+ */ |
|
4421 |
+ function repeat(word, count) { |
|
4422 |
+ return ((count == 0) ? "" : (word + repeat(word, count - 1))); |
|
4423 |
+ } |
|
4424 |
+ lib_string.repeat = repeat; |
|
4425 |
+ /** |
|
4426 |
+ * @desc lengthens a string by repeatedly appending or prepending another string |
|
4427 |
+ * @param {string} word the string to pad |
|
4428 |
+ * @param {int} length the length, which the result shall have |
|
4429 |
+ * @param {string} symbol the string, which will be added (multiple times) |
|
4430 |
+ * @param {boolean} [prepend]; whether to prepend (~true) or append (~false); default: false |
|
4431 |
+ * @return {string} the padded string |
|
4432 |
+ * @author frac |
|
4433 |
+ */ |
|
4434 |
+ function pad(word, length, symbol, prepend) { |
|
4435 |
+ if (prepend === void 0) { prepend = false; } |
|
4436 |
+ if (prepend) { |
|
4437 |
+ while (word.length < length) |
|
4438 |
+ word = symbol + word; |
|
4439 |
+ return word.substring(word.length - length); |
|
4440 |
+ } |
|
4441 |
+ else { |
|
4442 |
+ while (word.length < length) |
|
4443 |
+ word = word + symbol; |
|
4444 |
+ return word.substring(0, length); |
|
4445 |
+ } |
|
4446 |
+ } |
|
4447 |
+ lib_string.pad = pad; |
|
4448 |
+ /** |
|
4449 |
+ * @desc checks if a given string conttains a certain substring |
|
4450 |
+ * @param {string} string |
|
4451 |
+ * @param {string} part |
|
4452 |
+ * @return {boolean} |
|
4453 |
+ * @author frac |
|
4454 |
+ */ |
|
4455 |
+ function contains(chain, part) { |
|
4456 |
+ if (typeof (chain) !== "string") |
|
4457 |
+ return false; |
|
4458 |
+ return (chain.indexOf(part) >= 0); |
|
4459 |
+ } |
|
4460 |
+ lib_string.contains = contains; |
|
4461 |
+ /** |
|
4462 |
+ * @desc checks if a given string starts with a certain substring |
|
4463 |
+ * @param {string} string |
|
4464 |
+ * @param {string} part |
|
4465 |
+ * @return {boolean} |
|
4466 |
+ * @author frac |
|
4467 |
+ */ |
|
4468 |
+ function startsWith(chain, part) { |
|
4469 |
+ if (typeof (chain) !== "string") |
|
4470 |
+ return false; |
|
4471 |
+ // return (string.indexOf(part) === 0); |
|
4472 |
+ return ((function (m, n) { |
|
4473 |
+ if (n == 0) { |
|
4474 |
+ return true; |
|
4475 |
+ } |
|
4476 |
+ else { |
|
4477 |
+ if (m == 0) { |
|
4478 |
+ return false; |
|
4479 |
+ } |
|
4480 |
+ else { |
|
4481 |
+ return ((chain[0] == part[0]) && startsWith(chain.substring(1), part.substring(1))); |
|
4482 |
+ } |
|
4483 |
+ } |
|
4484 |
+ })(chain.length, part.length)); |
|
4485 |
+ } |
|
4486 |
+ lib_string.startsWith = startsWith; |
|
4487 |
+ /** |
|
4488 |
+ * @desc checks if a given string ends with a certain substring |
|
4489 |
+ * @param {string} string |
|
4490 |
+ * @param {string} part |
|
4491 |
+ * @return {boolean} |
|
4492 |
+ * @author frac |
|
4493 |
+ */ |
|
4494 |
+ function endsWith(chain, part) { |
|
4495 |
+ if (typeof (chain) !== "string") |
|
4496 |
+ return false; |
|
4497 |
+ // return (string.lastIndexOf(part) === string.length-part.length); |
|
4498 |
+ return ((function (m, n) { |
|
4499 |
+ if (n == 0) { |
|
4500 |
+ return true; |
|
4501 |
+ } |
|
4502 |
+ else { |
|
4503 |
+ if (m == 0) { |
|
4504 |
+ return false; |
|
4505 |
+ } |
|
4506 |
+ else { |
|
4507 |
+ // console.info(("(" + string[m-1] + " == " + part[n-1] + ")") + " = " + String(string[m-1] == part[n-1])); |
|
4508 |
+ return ((chain[m - 1] == part[n - 1]) && endsWith(chain.substring(0, m - 1), part.substring(0, n - 1))); |
|
4509 |
+ } |
|
4510 |
+ } |
|
4511 |
+ })(chain.length, part.length)); |
|
4512 |
+ } |
|
4513 |
+ lib_string.endsWith = endsWith; |
|
4514 |
+ /** |
|
4515 |
+ * @desc count the occourrences of a string in a string |
|
4516 |
+ * @param string haystack_string the string wich should be examined |
|
4517 |
+ * @param string needle_string the string which should be counted |
|
4518 |
+ * @author neuc |
|
4519 |
+ */ |
|
4520 |
+ function count_occourrences(haystack_string, needle_string, check_escape) { |
|
4521 |
+ var cnt = 0; |
|
4522 |
+ var pos = -1; |
|
4523 |
+ do { |
|
4524 |
+ pos = haystack_string.indexOf(needle_string, pos + 1); |
|
4525 |
+ if ((!check_escape) || (haystack_string[pos - 1] != "\\")) { |
|
4526 |
+ cnt++; |
|
4527 |
+ } |
|
4528 |
+ } while (pos >= 0); |
|
4529 |
+ return cnt - 1; |
|
4530 |
+ } |
|
4531 |
+ lib_string.count_occourrences = count_occourrences; |
|
4532 |
+ ; |
|
4533 |
+ /** |
|
4534 |
+ * @author fenris |
|
4535 |
+ */ |
|
4536 |
+ function stance(str, args) { |
|
4537 |
+ Object.keys(args).forEach(function (key) { |
|
4538 |
+ var value = args[key]; |
|
4539 |
+ var regexp_argument = new RegExp("\\${" + key + "}"); |
|
4540 |
+ str = str.replace(regexp_argument, value); |
|
4541 |
+ }); |
|
4542 |
+ return str; |
|
4543 |
+ } |
|
4544 |
+ lib_string.stance = stance; |
|
4545 |
+ /** |
|
4546 |
+ * @author fenris |
|
4547 |
+ */ |
|
4548 |
+ function make_url(_a) { |
|
4549 |
+ var _b = _a === void 0 ? {} : _a, _c = _b["protocol"], protocol = _c === void 0 ? null : _c, _d = _b["host"], host = _d === void 0 ? null : _d, _e = _b["port"], port = _e === void 0 ? null : _e, _f = _b["path"], path = _f === void 0 ? null : _f, _g = _b["arguments"], arguments_ = _g === void 0 ? null : _g; |
|
4550 |
+ var url = ""; |
|
4551 |
+ // protocol |
|
4552 |
+ { |
|
4553 |
+ if (protocol != null) { |
|
4554 |
+ url = protocol + ":" + url; |
|
4555 |
+ } |
|
4556 |
+ } |
|
4557 |
+ // host |
|
4558 |
+ { |
|
4559 |
+ if (host != null) { |
|
4560 |
+ url = url + "//" + host; |
|
4561 |
+ } |
|
4562 |
+ } |
|
4563 |
+ // port |
|
4564 |
+ { |
|
4565 |
+ if (port != null) { |
|
4566 |
+ url = url + ":" + port.toString(); |
|
4567 |
+ } |
|
4568 |
+ } |
|
4569 |
+ // path |
|
4570 |
+ { |
|
4571 |
+ if (path != null) { |
|
4572 |
+ url = url + "/" + path; |
|
4573 |
+ } |
|
4574 |
+ } |
|
4575 |
+ // arguments |
|
4576 |
+ { |
|
4577 |
+ if (arguments_ != null) { |
|
4578 |
+ var suffix = Object.keys(arguments_).map(function (key) { return key + "=" + arguments_[key]; }).join("&"); |
|
4579 |
+ url = url + "?" + suffix; |
|
4580 |
+ } |
|
4581 |
+ } |
|
4582 |
+ return url; |
|
4583 |
+ } |
|
4584 |
+ lib_string.make_url = make_url; |
|
4585 |
+})(lib_string || (lib_string = {})); |
|
4586 |
+/** |
|
4587 |
+ * @desc adapters for old syntax |
|
4588 |
+ */ |
|
4589 |
+var string_generate = lib_string.generate; |
|
4590 |
+var string_split = lib_string.split; |
|
4591 |
+var string_repeat = lib_string.repeat; |
|
4592 |
+var string_pad = lib_string.pad; |
|
4593 |
+var string_contains = lib_string.contains; |
|
4594 |
+var string_startsWith = lib_string.startsWith; |
|
4595 |
+var string_endsWith = lib_string.endsWith; |
|
4596 |
+var string_count_occourrences = lib_string.count_occourrences; |
|
4597 |
+var lib_string; |
|
4598 |
+(function (lib_string) { |
|
4599 |
+ var pattern = /%([-+#0 ]*)([0-9]*)[\.]{0,1}([0-9]*)([\w]{1})/; |
|
4600 |
+ var gpattern = /%([-+#0 ]*)([0-9]*)[\.]{0,1}([0-9]*)([\w]{1})/g; |
|
4601 |
+ function split_format(format) { |
|
4602 |
+ var tmp = format.match(pattern); |
|
4603 |
+ if (tmp === null) |
|
4604 |
+ return null; |
|
4605 |
+ return { |
|
4606 |
+ 'flags': tmp[1].split(""), |
|
4607 |
+ 'width': Number(tmp[2]), |
|
4608 |
+ 'precision': tmp[3] === '' ? null : Number(tmp[3]), |
|
4609 |
+ 'specifier': tmp[4], |
|
4610 |
+ 'string': format |
|
4611 |
+ }; |
|
4612 |
+ } |
|
4613 |
+ function make_err(format, arg, should) { |
|
4614 |
+ return ("[sprintf]" + " " + "argument for '" + format.string + "' has to be '" + should + "' but '" + arg + "' is '" + typeof arg + "'!"); |
|
4615 |
+ } |
|
4616 |
+ function test_arg(format, arg, should) { |
|
4617 |
+ if (typeof arg !== should) { |
|
4618 |
+ console.warn(make_err(format, arg, should)); |
|
4619 |
+ return false; |
|
4620 |
+ } |
|
4621 |
+ return true; |
|
4622 |
+ } |
|
4623 |
+ function string_fill(str, char, len, left) { |
|
4624 |
+ while (str.length < len) { |
|
4625 |
+ if (left) { |
|
4626 |
+ str += char; |
|
4627 |
+ } |
|
4628 |
+ else { |
|
4629 |
+ str = char + str; |
|
4630 |
+ } |
|
4631 |
+ } |
|
4632 |
+ return str; |
|
4633 |
+ } |
|
4634 |
+ /** |
|
4635 |
+ * the known_parameters are used to parse the different identifiers for the welln known syntax: |
|
4636 |
+ * flag width precision identifier |
|
4637 |
+ * %{[0#+- ]}{[0-9]*}.{[0-9]*}[fFdiueEgGsoxXaAsn] |
|
4638 |
+ * flags: |
|
4639 |
+ * 0 - fill with '0' instead of ' ' if the string length < width |
|
4640 |
+ * # - not implemented |
|
4641 |
+ * - - left-justified -> fill on the right side to reach width |
|
4642 |
+ * + - force using '+' on positive numbers |
|
4643 |
+ * ' ' - add a single space before positive numbers |
|
4644 |
+ * |
|
4645 |
+ * identifiers |
|
4646 |
+ * %f, %F - interpret given number as float, width: the minimal total width (fill with ' ' or '0' if the |
|
4647 |
+ * resulting string is too short, precision: cut more then given decimal places |
|
4648 |
+ * %d, %i, %u - interpret number as integer, decimal places will be cut. width: like float, precision: |
|
4649 |
+ * fill with '0' on right side until length given in precision is reached |
|
4650 |
+ * %e - interpret as float and write as scientifical number, width & precision like in float |
|
4651 |
+ * %E - same es %e but uppercase 'E' |
|
4652 |
+ * %g - use the shortest string of %f or %e |
|
4653 |
+ * %G - use the shortest string of %E or %E |
|
4654 |
+ * %s - simply print a string |
|
4655 |
+ * %o - print the given number in octal notation |
|
4656 |
+ * %x - print the given number in hex notation |
|
4657 |
+ * %X - same as %x but with uppercase characters |
|
4658 |
+ * %a - alias to %x |
|
4659 |
+ * %A - alias to %X |
|
4660 |
+ * %n - just print nothing |
|
4661 |
+ * @type {{}} |
|
4662 |
+ */ |
|
4663 |
+ var known_params = {}; |
|
4664 |
+ known_params["f"] = function (format, arg) { |
|
4665 |
+ if (!test_arg(format, arg, "number")) |
|
4666 |
+ return "Ø"; |
|
4667 |
+ var tmp = Math.abs(arg); |
|
4668 |
+ var sign = (arg < 0) ? -1 : 1; |
|
4669 |
+ var tmp_result = null; |
|
4670 |
+ if (format.precision !== null) { |
|
4671 |
+ tmp = Math.floor(Math.pow(10, format.precision) * tmp) / Math.pow(10, format.precision); |
|
4672 |
+ var tmp_ = (tmp * sign).toString().split("."); |
|
4673 |
+ if (tmp_.length === 1) |
|
4674 |
+ tmp_.push(""); |
|
4675 |
+ tmp_[1] = string_fill(tmp_[1], "0", format.precision, true); |
|
4676 |
+ tmp_result = tmp_.join("."); |
|
4677 |
+ } |
|
4678 |
+ else { |
|
4679 |
+ tmp_result = (sign * tmp).toString(); |
|
4680 |
+ } |
|
4681 |
+ if ((format.flags.indexOf(" ") >= 0) && (arg >= 0)) { |
|
4682 |
+ tmp_result = " " + tmp; |
|
4683 |
+ } |
|
4684 |
+ else if ((format.flags.indexOf("+") >= 0) && (arg >= 0)) { |
|
4685 |
+ tmp_result = "+" + tmp; |
|
4686 |
+ } |
|
4687 |
+ tmp_result = string_fill(tmp, (format.flags.indexOf("0") >= 0) ? "0" : " ", format.width, (format.flags.indexOf("-") >= 0)); |
|
4688 |
+ return tmp_result; |
|
4689 |
+ }; |
|
4690 |
+ known_params["F"] = known_params["f"]; |
|
4691 |
+ known_params["d"] = function (format, arg) { |
|
4692 |
+ if (!test_arg(format, arg, 'number')) |
|
4693 |
+ return 'Ø'; |
|
4694 |
+ var tmp = (((arg < 0 && format.specifier !== 'u') ? -1 : 1) * Math.floor(Math.abs(arg))).toString(); |
|
4695 |
+ if ((format.specifier === 'd' || format.specifier === 'i') && format.flags.indexOf(' ') >= 0 && arg >= 0) { |
|
4696 |
+ tmp = ' ' + tmp; |
|
4697 |
+ } |
|
4698 |
+ else if ((format.specifier === 'd' || format.specifier === 'i') && format.flags.indexOf('+') >= 0 && arg >= 0) { |
|
4699 |
+ tmp = '+' + tmp; |
|
4700 |
+ } |
|
4701 |
+ tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); |
|
4702 |
+ tmp = string_fill(tmp, '0', format.precision === null ? 0 : format.precision, false); |
|
4703 |
+ return tmp; |
|
4704 |
+ }; |
|
4705 |
+ known_params["i"] = known_params["d"]; |
|
4706 |
+ known_params["u"] = known_params["d"]; |
|
4707 |
+ known_params["e"] = function (format, arg) { |
|
4708 |
+ if (!test_arg(format, arg, 'number')) |
|
4709 |
+ return 'Ø'; |
|
4710 |
+ var tmp = arg.toExponential(format.precision === null ? undefined : format.precision).toString(); |
|
4711 |
+ if (format.flags.indexOf(' ') >= 0 && arg >= 0) { |
|
4712 |
+ tmp = ' ' + tmp; |
|
4713 |
+ } |
|
4714 |
+ else if (format.flags.indexOf('+') >= 0 && arg >= 0) { |
|
4715 |
+ tmp = '+' + tmp; |
|
4716 |
+ } |
|
4717 |
+ tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); |
|
4718 |
+ return tmp; |
|
4719 |
+ }; |
|
4720 |
+ known_params["E"] = function (format, arg) { |
|
4721 |
+ return known_params["e"](format, arg).toUpperCase(); |
|
4722 |
+ }; |
|
4723 |
+ known_params["g"] = function (format, arg) { |
|
4724 |
+ if (!test_arg(format, arg, 'number')) |
|
4725 |
+ return 'Ø'; |
|
4726 |
+ var tmpf = known_params["f"](format, arg); |
|
4727 |
+ var tmpe = known_params["e"](format, arg); |
|
4728 |
+ if (tmpf.length < tmpe.length) { |
|
4729 |
+ return tmpf; |
|
4730 |
+ } |
|
4731 |
+ else { |
|
4732 |
+ return tmpe; |
|
4733 |
+ } |
|
4734 |
+ }; |
|
4735 |
+ known_params["G"] = function (format, arg) { |
|
4736 |
+ return known_params["g"](format, arg).toUpperCase(); |
|
4737 |
+ }; |
|
4738 |
+ known_params["s"] = function (format, arg) { |
|
4739 |
+ if (!test_arg(format, arg, 'string')) |
|
4740 |
+ return 'o.O'; |
|
4741 |
+ var tmp = format.precision !== null ? arg.substr(0, format.precision) : arg; |
|
4742 |
+ tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); |
|
4743 |
+ return tmp; |
|
4744 |
+ }; |
|
4745 |
+ known_params["o"] = function (format, arg) { |
|
4746 |
+ if (!test_arg(format, arg, 'number')) |
|
4747 |
+ return 'Ø'; |
|
4748 |
+ var tmp = Math.floor(Math.round(Math.abs(arg))) * ((arg < 0) ? -1 : 1); |
|
4749 |
+ return known_params["s"](format, tmp.toString(8)); |
|
4750 |
+ }; |
|
4751 |
+ known_params["x"] = function (format, arg) { |
|
4752 |
+ if (!test_arg(format, arg, 'number')) |
|
4753 |
+ return 'Ø'; |
|
4754 |
+ var tmp = Math.floor(Math.round(Math.abs(arg))) * ((arg < 0) ? -1 : 1); |
|
4755 |
+ return known_params["s"](format, tmp.toString(16)); |
|
4756 |
+ }; |
|
4757 |
+ known_params["a"] = known_params["x"]; |
|
4758 |
+ known_params["X"] = function (format, arg) { |
|
4759 |
+ if (!test_arg(format, arg, 'number')) |
|
4760 |
+ return 'Ø'; |
|
4761 |
+ return known_params["x"](format, arg).toUpperCase(); |
|
4762 |
+ }; |
|
4763 |
+ known_params["A"] = known_params["X"]; |
|
4764 |
+ known_params["c"] = function (format, arg) { |
|
4765 |
+ var tmp = ""; |
|
4766 |
+ if (typeof arg === "number") { |
|
4767 |
+ tmp = String.fromCharCode(arg); |
|
4768 |
+ } |
|
4769 |
+ else if ((typeof arg === "string") && (arg.length === 1)) { |
|
4770 |
+ tmp = arg[0]; |
|
4771 |
+ } |
|
4772 |
+ else { |
|
4773 |
+ console.warn(make_err(format, arg, "number|string") + " and if string it needs to have the length of 1!"); |
|
4774 |
+ } |
|
4775 |
+ return known_params["s"](format, tmp); |
|
4776 |
+ }; |
|
4777 |
+ known_params["n"] = function () { |
|
4778 |
+ return ""; |
|
4779 |
+ }; |
|
4780 |
+ var decompose = function (chain, regexp) { |
|
4781 |
+ var result = regexp.exec(chain); |
|
4782 |
+ if (result == null) { |
|
4783 |
+ return null; |
|
4784 |
+ } |
|
4785 |
+ else { |
|
4786 |
+ var front = chain.substring(0, result.index); |
|
4787 |
+ var back = chain.substring(result.index + result[0].length); |
|
4788 |
+ return { "front": front, "match": result[0], "back": back }; |
|
4789 |
+ } |
|
4790 |
+ }; |
|
4791 |
+ /** |
|
4792 |
+ * an implementation of c sprintf |
|
4793 |
+ * @param {string} string format string |
|
4794 |
+ * @param {array} args arguments which should be filled into |
|
4795 |
+ * @returns {string} |
|
4796 |
+ */ |
|
4797 |
+ lib_string.sprintf = function (input, args, original) { |
|
4798 |
+ if (args === void 0) { args = []; } |
|
4799 |
+ if (original === void 0) { original = null; } |
|
4800 |
+ if (original == null) |
|
4801 |
+ original = input; |
|
4802 |
+ var components = decompose(input, pattern); |
|
4803 |
+ if (components == null) { |
|
4804 |
+ if (args.length > 0) { |
|
4805 |
+ console.warn("[sprintf] superfluous arguments while formatting '" + original + "': ", args); |
|
4806 |
+ } |
|
4807 |
+ return input; |
|
4808 |
+ } |
|
4809 |
+ else { |
|
4810 |
+ var arg; |
|
4811 |
+ var rest; |
|
4812 |
+ if (args.length > 0) { |
|
4813 |
+ arg = args[0]; |
|
4814 |
+ rest = args.slice(1); |
|
4815 |
+ } |
|
4816 |
+ else { |
|
4817 |
+ console.warn("[sprintf] out of arguments while formatting '" + original + "'"); |
|
4818 |
+ arg = null; |
|
4819 |
+ rest = []; |
|
4820 |
+ return input; |
|
4821 |
+ } |
|
4822 |
+ var fmt = split_format(components["match"]); |
|
4823 |
+ return (components["front"] |
|
4824 |
+ + known_params[fmt.specifier](fmt, arg) |
|
4825 |
+ + lib_string.sprintf(components["back"], rest, original)); |
|
4826 |
+ } |
|
4827 |
+ }; |
|
4828 |
+ /** |
|
4829 |
+ * an implementation of c printf |
|
4830 |
+ * @param {string} string format string |
|
4831 |
+ * @param {array} args arguments which should be filled into |
|
4832 |
+ * @returns {string} |
|
4833 |
+ */ |
|
4834 |
+ function printf(format, args) { |
|
4835 |
+ console.log(lib_string.sprintf(format, args)); |
|
4836 |
+ } |
|
4837 |
+ lib_string.printf = printf; |
|
4838 |
+})(lib_string || (lib_string = {})); |
|
4839 |
+var sprintf = lib_string.sprintf; |
|
4840 |
+var printf = lib_string.printf; |
|
4841 |
+/** |
|
4842 |
+ * @author neuc |
|
4843 |
+ */ |
|
4844 |
+var strftime; |
|
4845 |
+(function (strftime) { |
|
4846 |
+ var currentDate = new Date(); |
|
4847 |
+ var days = [ |
|
4848 |
+ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" |
|
4849 |
+ ]; |
|
4850 |
+ var months = [ |
|
4851 |
+ "January", "February", "March", "April", "May", "June", "July", "August", "September", |
|
4852 |
+ "October", "November", "December" |
|
4853 |
+ ]; |
|
4854 |
+ function set_days(day_names) { |
|
4855 |
+ days = day_names; |
|
4856 |
+ } |
|
4857 |
+ strftime.set_days = set_days; |
|
4858 |
+ function set_months(month_names) { |
|
4859 |
+ months = month_names; |
|
4860 |
+ } |
|
4861 |
+ strftime.set_months = set_months; |
|
4862 |
+ // source: https://stackoverflow.com/questions/8619879/javascript-calculate-the-day-of-the-year-1-366 |
|
4863 |
+ function helper_dayOfYear(date) { |
|
4864 |
+ var start = new Date(date.getFullYear(), 0, 0); |
|
4865 |
+ var diff = date - start; |
|
4866 |
+ var oneDay = 1000 * 60 * 60 * 24; |
|
4867 |
+ return Math.floor(diff / oneDay); |
|
4868 |
+ } |
|
4869 |
+ // source: http://weeknumber.net/how-to/javascript |
|
4870 |
+ function helper_weekOfYear(date_) { |
|
4871 |
+ var date = new Date(date_.getTime()); |
|
4872 |
+ date.setHours(0, 0, 0, 0); |
|
4873 |
+ // Thursday in current week decides the year. |
|
4874 |
+ date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7); |
|
4875 |
+ // January 4 is always in week 1. |
|
4876 |
+ var week1 = new Date(date.getFullYear(), 0, 4); |
|
4877 |
+ // Adjust to Thursday in week 1 and count number of weeks from date to week1. |
|
4878 |
+ return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 |
|
4879 |
+ - 3 + (week1.getDay() + 6) % 7) / 7); |
|
4880 |
+ } |
|
4881 |
+ function helper_englishWeekOfYear(date) { |
|
4882 |
+ var nr = helper_weekOfYear(date); |
|
4883 |
+ if (date.getDay() === 0) { |
|
4884 |
+ nr = nr - 1; |
|
4885 |
+ } |
|
4886 |
+ return nr; |
|
4887 |
+ } |
|
4888 |
+ function set_currentDate(date) { |
|
4889 |
+ currentDate = date; |
|
4890 |
+ } |
|
4891 |
+ strftime.set_currentDate = set_currentDate; |
|
4892 |
+ function parse(format, date) { |
|
4893 |
+ if (!date) { |
|
4894 |
+ date = currentDate; |
|
4895 |
+ } |
|
4896 |
+ var ret = format; |
|
4897 |
+ var re = new RegExp("%[a-z]", "gi"); |
|
4898 |
+ var match; |
|
4899 |
+ while (match = re.exec(format)) { |
|
4900 |
+ ret = ret.replace(match[0], parse_segment(match[0], date)); |
|
4901 |
+ } |
|
4902 |
+ return ret; |
|
4903 |
+ } |
|
4904 |
+ strftime.parse = parse; |
|
4905 |
+ function parse_segment(segment, date) { |
|
4906 |
+ if (!date) { |
|
4907 |
+ date = currentDate; |
|
4908 |
+ } |
|
4909 |
+ var hm_segments = { |
|
4910 |
+ "%a": function () { return days[date.getDay()].slice(0, 3); }, |
|
4911 |
+ "%A": function () { return days[date.getDay()]; }, |
|
4912 |
+ "%b": function () { return days[date.getMonth()].slice(0, 3); }, |
|
4913 |
+ "%B": function () { return days[date.getMonth()]; }, |
|
4914 |
+ "%c": function () { return date.toLocaleString(); }, |
|
4915 |
+ "%C": function () { return Math.floor((date.getFullYear()) / 100).toString(); }, |
|
4916 |
+ "%d": function () { return sprintf("%02d", [date.getDate()]); }, |
|
4917 |
+ "%D": function () { return parse("%m/%d/%y", date); }, |
|
4918 |
+ "%e": function () { return sprintf("%2d", [date.getDate()]); }, |
|
4919 |
+ "%F": function () { return parse("%Y-%m-%d", date); }, |
|
4920 |
+ "%g": function () { return sprintf("%02d", [date.getFullYear() % 1000]); }, |
|
4921 |
+ "%G": function () { return date.getFullYear().toString(); }, |
|
4922 |
+ "%h": function () { return parse("%b", date); }, |
|
4923 |
+ "%H": function () { return sprintf("%02d", [date.getHours()]); }, |
|
4924 |
+ "%I": function () { |
|
4925 |
+ return sprintf("%02d", [ |
|
4926 |
+ (date.getHours() > 12 ? date.getHours() - 12 : date.getHours()) |
|
4927 |
+ ]); |
|
4928 |
+ }, |
|
4929 |
+ "%j": function () { return sprintf("%03d", [helper_dayOfYear(date)]); }, |
|
4930 |
+ "%m": function () { return sprintf("%02d", [date.getMonth() + 1]); }, |
|
4931 |
+ "%M": function () { return sprintf("%02d", [date.getMinutes()]); }, |
|
4932 |
+ "%n": function () { return "\n"; }, |
|
4933 |
+ "%p": function () { return (date.getHours() > 12 ? "PM" : "AM"); }, |
|
4934 |
+ "%r": function () { return parse("%I:%M:%S %p", date); }, |
|
4935 |
+ "%R": function () { return parse("%H:%M", date); }, |
|
4936 |
+ "%S": function () { return date.getSeconds().toString(); }, |
|
4937 |
+ "%t": function () { return "\t"; }, |
|
4938 |
+ "%T": function () { return parse("%H:%M:%S", date); }, |
|
4939 |
+ "%u": function () { return sprintf("%02d", [(date.getDay() === 0 ? 7 : date.getDay())]); }, |
|
4940 |
+ "%U": function () { return sprintf("%02d", [helper_englishWeekOfYear(date)]); }, |
|
4941 |
+ "%V": function () { return sprintf("%02d", [helper_weekOfYear(date)]); }, |
|
4942 |
+ "%w": function () { return sprintf("%02d", [date.getDay().toString()]); }, |
|
4943 |
+ "%W": function () { return parse("%w", date); }, |
|
4944 |
+ "%x": function () { return parse("%m/%d/%G", date); }, |
|
4945 |
+ "%X": function () { return parse("%T", date); }, |
|
4946 |
+ "%y": function () { return parse("%g", date); }, |
|
4947 |
+ "%Y": function () { return parse("%G", date); }, |
|
4948 |
+ "%z": function () { return date.getTimezoneOffset().toString(); }, |
|
4949 |
+ "%Z": function () { return date.toUTCString().split(' ').pop(); }, |
|
4950 |
+ "%%": function () { return "%"; } |
|
4951 |
+ }; |
|
4952 |
+ if (!(segment in hm_segments)) { |
|
4953 |
+ throw "unknown format argument '" + segment + "'"; |
|
4954 |
+ } |
|
4955 |
+ return hm_segments[segment](); |
|
4956 |
+ } |
|
4957 |
+})(strftime || (strftime = {})); |
|
4958 |
+function locale_date(date, ignore_error) { |
|
4959 |
+ if (date === void 0) { date = new Date(); } |
|
4960 |
+ if (ignore_error === void 0) { ignore_error = false; } |
|
4961 |
+ if (!(date instanceof Date)) { |
|
4962 |
+ if (!ignore_error) { |
|
4963 |
+ throw new SyntaxError("date must be instance of Date"); |
|
4964 |
+ } |
|
4965 |
+ else { |
|
4966 |
+ console.warn("'" + date + "' seems not to be instance of Date try to force convert."); |
|
4967 |
+ var tmp = date; |
|
4968 |
+ date = new Date(tmp); |
|
4969 |
+ if ((date.toString() === "Invalid Date") || |
|
4970 |
+ (!(date < new Date(0)) && !(date > new Date(0)))) { |
|
4971 |
+ console.warn("conversion didn't work, returning default value"); |
|
4972 |
+ return "Ø"; |
|
4973 |
+ } |
|
4974 |
+ } |
|
4975 |
+ } |
|
4976 |
+ var conf = global_config.get_value("date") || { |
|
4977 |
+ "use_locale_date": true, |
|
4978 |
+ "format_string": "%d.%m.%Y" |
|
4979 |
+ }; |
|
4980 |
+ if (conf.use_locale_date) { |
|
4981 |
+ return date.toLocaleDateString(); |
|
4982 |
+ } |
|
4983 |
+ else { |
|
4984 |
+ return strftime.parse(conf.format_string, date); |
|
4985 |
+ } |
|
4986 |
+} |
|
4987 |
+; |
|
4988 |
+var make_logger = (function () { |
|
4989 |
+ var _loggers = {}; |
|
4990 |
+ var make_logger = function (prefix, current_loglevel) { |
|
4991 |
+ var log = []; |
|
4992 |
+ var level = [ |
|
4993 |
+ "LOG", "INFO", "WARNING", "DEBUG" |
|
4994 |
+ ]; |
|
4995 |
+ var logger = function (obj, lvl) { |
|
4996 |
+ var txt = obj.txt || obj; |
|
4997 |
+ if (lvl == void 0) |
|
4998 |
+ lvl = 0; |
|
4999 |
+ var date = new Date(); |
|
5000 |
+ log.push({ |
|
5001 |
+ "message": sprintf("%s [%s:%s] %s", [date.toString(), level[lvl], prefix, txt]), |
|
5002 |
+ "timeStamp": +(date) |
|
5003 |
+ }); |
|
5004 |
+ if (lvl <= current_loglevel) { |
|
5005 |
+ var msg = ["[" + prefix + "]", txt]; |
|
5006 |
+ if (obj.arg) |
|
5007 |
+ msg = ["[" + prefix + "]"].concat(Array.prototype.slice.call(obj.arg)); |
|
5008 |
+ if (lvl === 0) |
|
5009 |
+ console["_log"].apply(console, msg); |
|
5010 |
+ else if (lvl === 1) |
|
5011 |
+ console["_info"].apply(console, msg); |
|
5012 |
+ else if (lvl === 2) |
|
5013 |
+ console["_warn"].apply(console, msg); |
|
5014 |
+ else if (lvl >= 3) |
|
5015 |
+ console["_log"].apply(console, msg); |
|
5016 |
+ } |
|
5017 |
+ }; |
|
5018 |
+ _loggers[prefix] = { |
|
5019 |
+ "logger": logger, |
|
5020 |
+ "log": log |
|
5021 |
+ }; |
|
5022 |
+ return logger; |
|
3191 | 5023 |
}; |
3192 |
- return class_shape_date; |
|
3193 |
- }(lib_meta.class_shape)); |
|
3194 |
- lib_meta.class_shape_date = class_shape_date; |
|
3195 |
- lib_meta.register("date", function (parameters) { |
|
3196 |
- return (new class_shape_date({ |
|
3197 |
- "soft": parameters["soft"] |
|
3198 |
- })); |
|
5024 |
+ make_logger["loggers"] = _loggers; |
|
5025 |
+ make_logger["complete_log"] = function () { |
|
5026 |
+ var logs = Object.keys(_loggers) |
|
5027 |
+ .reduce(function (p, c) { |
|
5028 |
+ return [].concat(p, _loggers[c].log); |
|
5029 |
+ }, []); |
|
5030 |
+ logs.sort(function (x, y) { |
|
5031 |
+ return ((x.timeStamp > y.timeStamp) ? -1 : +1); |
|
3199 | 5032 |
}); |
3200 |
-})(lib_meta || (lib_meta = {})); |
|
3201 |
-var lib_meta; |
|
3202 |
-(function (lib_meta) { |
|
3203 |
- /** |
|
3204 |
- * @author fenris |
|
3205 |
- */ |
|
3206 |
- var class_shape_enumeration = (function (_super) { |
|
3207 |
- __extends(class_shape_enumeration, _super); |
|
3208 |
- /** |
|
3209 |
- * @author fenris |
|
3210 |
- */ |
|
3211 |
- function class_shape_enumeration(_a) { |
|
3212 |
- var shape_option = _a["shape_option"], options = _a["options"], _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? undefined : _c; |
|
3213 |
- var _this = this; |
|
3214 |
- if (defaultvalue === undefined) { |
|
3215 |
- if (soft) { |
|
3216 |
- defaultvalue = null; |
|
3217 |
- } |
|
3218 |
- else { |
|
3219 |
- if (options.length == 0) { |
|
3220 |
- throw (new Error("a hard enumeration must have at least one option")); |
|
5033 |
+ return logs.map(function (x, i, a) { |
|
5034 |
+ return x.message; |
|
5035 |
+ }); |
|
5036 |
+ }; |
|
5037 |
+ if (true) { |
|
5038 |
+ var _log_all = function (log, lvl, next) { |
|
5039 |
+ if (next === void 0) { next = function () { }; } |
|
5040 |
+ return function () { |
|
5041 |
+ var msg = []; |
|
5042 |
+ for (var i = 0; i < arguments.length; i++) { |
|
5043 |
+ if (typeof arguments[i] === "string") { |
|
5044 |
+ msg.push(arguments[i]); |
|
3221 | 5045 |
} |
3222 | 5046 |
else { |
3223 |
- defaultvalue = options[0].value; |
|
3224 |
- } |
|
3225 |
- } |
|
5047 |
+ msg.push(JSON.stringify(arguments[i])); |
|
3226 | 5048 |
} |
3227 |
- _this = _super.call(this, { |
|
3228 |
- "primitive": true, |
|
3229 |
- "soft": soft, |
|
3230 |
- "defaultvalue": defaultvalue |
|
3231 |
- }) || this; |
|
3232 |
- _this.shape_option = shape_option; |
|
3233 |
- _this.options = options; |
|
3234 |
- return _this; |
|
3235 | 5049 |
} |
3236 |
- /** |
|
3237 |
- * @desc [accessor] [getter] |
|
3238 |
- * @author fenris |
|
3239 |
- */ |
|
3240 |
- class_shape_enumeration.prototype.shape_option_get = function () { |
|
3241 |
- return this.shape_option; |
|
5050 |
+ var obj = { |
|
5051 |
+ txt: msg.join("\t"), |
|
5052 |
+ arg: arguments |
|
3242 | 5053 |
}; |
3243 |
- /** |
|
3244 |
- * @desc [accessor] [getter] |
|
3245 |
- * @author fenris |
|
3246 |
- */ |
|
3247 |
- class_shape_enumeration.prototype.options_get = function () { |
|
3248 |
- return this.options; |
|
5054 |
+ log(obj, lvl); |
|
5055 |
+ next(); |
|
3249 | 5056 |
}; |
3250 |
- /** |
|
3251 |
- * @override |
|
3252 |
- * @author fenris |
|
5057 |
+ }; |
|
5058 |
+ { |
|
5059 |
+ var __warn = make_logger("deprecated console.warn", 99); |
|
5060 |
+ var __error = make_logger("deprecated console.error", 99); |
|
5061 |
+ var __log = make_logger("deprecated console.log", 99); |
|
5062 |
+ var __info = make_logger("deprecated console.info", 99); |
|
5063 |
+ // bad ass |
|
5064 |
+ console["_log"] = console.log; |
|
5065 |
+ console["_error"] = console.error; |
|
5066 |
+ console["_warn"] = console.warn; |
|
5067 |
+ console["_info"] = console.info; |
|
5068 |
+ /* |
|
5069 |
+ console["log"] = _log_all(__log, 0); |
|
5070 |
+ console["error"] = _log_all(__error, 2); |
|
5071 |
+ console["warn"] = _log_all(__warn, 2); |
|
5072 |
+ console["info"] = _log_all(__info, 0); |
|
3253 | 5073 |
*/ |
3254 |
- class_shape_enumeration.prototype.inspect = function (value) { |
|
3255 |
- var messages = _super.prototype.inspect.call(this, value); |
|
3256 |
- if (value != null) { |
|
3257 |
- if (!this.shape_option.check(value)) { |
|
3258 |
- messages.push("value has not the specified option shape"); |
|
3259 | 5074 |
} |
3260 |
- else { |
|
3261 |
- var found = this.options.some(function (option) { return instance_collate(option.value, value); }); |
|
3262 |
- if (!found) { |
|
3263 |
- messages.push("value is not one of the specified options"); |
|
5075 |
+ /* |
|
5076 |
+ { |
|
5077 |
+ make_logger["send_log"] = function(){ |
|
5078 |
+ eml_log( |
|
5079 |
+ function () { |
|
5080 |
+ alert("fehlerbericht wurde gesendet!"); |
|
5081 |
+ } |
|
5082 |
+ ); |
|
5083 |
+ }; |
|
5084 |
+ var error_log = make_logger("global.error", 99); |
|
5085 |
+ window.onerror = _log_all( |
|
5086 |
+ error_log, |
|
5087 |
+ 1, |
|
5088 |
+ function(){ |
|
5089 |
+ if (global_config == undefined) { |
|
5090 |
+ return false; |
|
5091 |
+ } |
|
5092 |
+ if (global_config.report_error) { |
|
5093 |
+ make_logger["send_log"](); |
|
3264 | 5094 |
} |
3265 | 5095 |
} |
5096 |
+ ); |
|
3266 | 5097 |
} |
3267 |
- return messages; |
|
5098 |
+ */ |
|
5099 |
+ } |
|
5100 |
+ return make_logger; |
|
5101 |
+})(); |
|
5102 |
+var __extends = (this && this.__extends) || (function () { |
|
5103 |
+ var extendStatics = Object.setPrototypeOf || |
|
5104 |
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
5105 |
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; |
|
5106 |
+ return function (d, b) { |
|
5107 |
+ extendStatics(d, b); |
|
5108 |
+ function __() { this.constructor = d; } |
|
5109 |
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
3268 | 5110 |
}; |
5111 |
+})(); |
|
5112 |
+///<reference path="../../base/build/logic-decl.d.ts"/> |
|
5113 |
+///<reference path="../../string/build/logic-decl.d.ts"/> |
|
3269 | 5114 |
/** |
3270 |
- * @override |
|
3271 | 5115 |
* @author fenris |
3272 | 5116 |
*/ |
3273 |
- class_shape_enumeration.prototype.to_raw = function () { |
|
3274 |
- return { |
|
3275 |
- "id": "enumeration", |
|
3276 |
- "parameters": { |
|
3277 |
- "shape_option": this.shape_option.to_raw(), |
|
3278 |
- "options": this.options.map(function (option) { |
|
3279 |
- return { |
|
3280 |
- "value": option.value, |
|
3281 |
- "label": option.label |
|
3282 |
- }; |
|
3283 |
- }), |
|
3284 |
- "soft": this.soft |
|
3285 |
- } |
|
3286 |
- }; |
|
3287 |
- }; |
|
5117 |
+var lib_xml; |
|
5118 |
+(function (lib_xml) { |
|
3288 | 5119 |
/** |
3289 |
- * @desc [implementation] |
|
3290 | 5120 |
* @author fenris |
3291 | 5121 |
*/ |
3292 |
- class_shape_enumeration.prototype._show = function () { |
|
3293 |
- var str = "enumeration"; |
|
3294 |
- { |
|
3295 |
- str = str + "<" + instance_show(this.shape_option) + ">"; |
|
3296 |
- } |
|
3297 |
- { |
|
3298 |
- var str_ = this.options.map(function (option) { return instance_show(option.value); }).join(","); |
|
3299 |
- str = str + "[" + str_ + "]"; |
|
5122 |
+ var class_node = (function () { |
|
5123 |
+ function class_node() { |
|
3300 | 5124 |
} |
3301 |
- return str; |
|
3302 |
- }; |
|
3303 |
- return class_shape_enumeration; |
|
3304 |
- }(lib_meta.class_shape)); |
|
3305 |
- lib_meta.class_shape_enumeration = class_shape_enumeration; |
|
3306 |
- lib_meta.register("enumeration", function (parameters) { |
|
3307 |
- var shape_option_raw = lib_object.fetch(parameters, "shape_option", null, 2); |
|
3308 |
- var shape_option = lib_meta.from_raw(shape_option_raw); |
|
3309 |
- var options = lib_object.fetch(parameters, "options", [], 2); |
|
3310 |
- return (new class_shape_enumeration({ |
|
3311 |
- "shape_option": shape_option, |
|
3312 |
- "options": options, |
|
3313 |
- "soft": parameters["soft"] |
|
3314 |
- })); |
|
3315 |
- }); |
|
3316 |
-})(lib_meta || (lib_meta = {})); |
|
3317 |
-var lib_meta; |
|
3318 |
-(function (lib_meta) { |
|
5125 |
+ return class_node; |
|
5126 |
+ }()); |
|
5127 |
+ lib_xml.class_node = class_node; |
|
3319 | 5128 |
/** |
3320 | 5129 |
* @author fenris |
3321 | 5130 |
*/ |
3322 |
- var class_shape_map = (function (_super) { |
|
3323 |
- __extends(class_shape_map, _super); |
|
5131 |
+ var class_node_text = (function (_super) { |
|
5132 |
+ __extends(class_node_text, _super); |
|
3324 | 5133 |
/** |
3325 | 5134 |
* @author fenris |
3326 | 5135 |
*/ |
3327 |
- function class_shape_map(_a) { |
|
3328 |
- var shape_key = _a["shape_key"], shape_value = _a["shape_value"], _b = _a["soft"], soft = _b === void 0 ? false : _b, _c = _a["defaultvalue"], defaultvalue = _c === void 0 ? {} : _c; |
|
3329 |
- var _this = _super.call(this, { |
|
3330 |
- "primitive": true, |
|
3331 |
- "soft": soft, |
|
3332 |
- "defaultvalue": defaultvalue |
|
3333 |
- }) || this; |
|
3334 |
- _this.shape_key = shape_key; |
|
3335 |
- _this.shape_value = shape_value; |
|
5136 |
+ function class_node_text(content) { |
|
5137 |
+ var _this = _super.call(this) || this; |
|
5138 |
+ _this.content = content; |
|
3336 | 5139 |
return _this; |
3337 | 5140 |
} |
3338 | 5141 |
/** |
3339 |
- * @desc [accessor] [getter] |
|
3340 | 5142 |
* @author fenris |
3341 | 5143 |
*/ |
3342 |
- class_shape_map.prototype.shape_key_get = function () { |
|
3343 |
- return this.shape_key; |
|
5144 |
+ class_node_text.prototype.compile = function (depth) { |
|
5145 |
+ if (depth === void 0) { depth = 0; } |
|
5146 |
+ return (lib_string.repeat("\t", depth) + this.content + "\n"); |
|
3344 | 5147 |
}; |
5148 |
+ return class_node_text; |
|
5149 |
+ }(class_node)); |
|
5150 |
+ lib_xml.class_node_text = class_node_text; |
|
3345 | 5151 |
/** |
3346 |
- * @desc [accessor] [getter] |
|
3347 | 5152 |
* @author fenris |
3348 | 5153 |
*/ |
3349 |
- class_shape_map.prototype.shape_value_get = function () { |
|
3350 |
- return this.shape_value; |
|
3351 |
- }; |
|
5154 |
+ var class_node_comment = (function (_super) { |
|
5155 |
+ __extends(class_node_comment, _super); |
|
3352 | 5156 |
/** |
3353 |
- * @override |
|
3354 | 5157 |
* @author fenris |
3355 | 5158 |
*/ |
3356 |
- class_shape_map.prototype.inspect = function (value) { |
|
3357 |
- var _this = this; |
|
3358 |
- var messages = _super.prototype.inspect.call(this, value); |
|
3359 |
- if (value != null) { |
|
3360 |
- if (typeof (value) != "object") { |
|
3361 |
- messages.push("value is not an object"); |
|
3362 |
- } |
|
3363 |
- else { |
|
3364 |
- Object.keys(value).forEach(function (key, index) { |
|
3365 |
- var value_ = value[key]; |
|
3366 |
- messages = messages.concat(_this.shape_key.inspect(key).map(function (message) { return "map entry #" + index.toString() + " key: " + message; })); |
|
3367 |
- messages = messages.concat(_this.shape_value.inspect(value).map(function (message) { return "map entry #" + index.toString() + " value: " + message; })); |
|
3368 |
- }); |
|
3369 |
- } |
|
5159 |
+ function class_node_comment(content) { |
|
5160 |
+ var _this = _super.call(this) || this; |
|
5161 |
+ _this.content = content; |
|
5162 |
+ return _this; |
|
3370 | 5163 |
} |
3371 |
- return messages; |
|
3372 |
- }; |
|
3373 | 5164 |
/** |
3374 |
- * @override |
|
3375 | 5165 |
* @author fenris |
3376 | 5166 |
*/ |
3377 |
- class_shape_map.prototype.to_raw = function () { |
|
3378 |
- return { |
|
3379 |
- "id": "map", |
|
3380 |
- "parameters": { |
|
3381 |
- "shape_key": this.shape_key.to_raw(), |
|
3382 |
- "shape_value": this.shape_value.to_raw(), |
|
3383 |
- "soft": this.soft |
|
3384 |
- } |
|
3385 |
- }; |
|
5167 |
+ class_node_comment.prototype.compile = function (depth) { |
|
5168 |
+ if (depth === void 0) { depth = 0; } |
|
5169 |
+ return (lib_string.repeat("\t", depth) + "<!-- " + this.content + " -->" + "\n"); |
|
3386 | 5170 |
}; |
5171 |
+ return class_node_comment; |
|
5172 |
+ }(class_node)); |
|
5173 |
+ lib_xml.class_node_comment = class_node_comment; |
|
3387 | 5174 |
/** |
3388 |
- * @desc [implementation] |
|
3389 | 5175 |
* @author fenris |
3390 | 5176 |
*/ |
3391 |
- class_shape_map.prototype._show = function () { |
|
3392 |
- var str = "map"; |
|
3393 |
- str += "<" + instance_show(this.shape_key) + "," + instance_show(this.shape_value) + ">"; |
|
3394 |
- return str; |
|
3395 |
- }; |
|
3396 |
- return class_shape_map; |
|
3397 |
- }(lib_meta.class_shape)); |
|
3398 |
- lib_meta.class_shape_map = class_shape_map; |
|
3399 |
- lib_meta.register("map", function (parameters) { |
|
3400 |
- var shape_key_raw = lib_object.fetch(parameters, "shape_key", null, 2); |
|
3401 |
- var shape_key = lib_meta.construct(shape_key_raw.id, shape_key_raw.parameters); |
|
3402 |
- var shape_value_raw = lib_object.fetch(parameters, "shape_value", null, 2); |
|
3403 |
- var shape_value = lib_meta.from_raw(shape_value_raw); |
|
3404 |
- return (new class_shape_map({ |
|
3405 |
- "shape_key": shape_key, |
|
3406 |
- "shape_value": shape_value, |
|
3407 |
- "soft": parameters["soft"] |
|
3408 |
- })); |
|
3409 |
- }); |
|
3410 |
-})(lib_meta || (lib_meta = {})); |
|
3411 |
-var lib_meta; |
|
3412 |
-(function (lib_meta) { |
|
5177 |
+ var class_node_complex = (function (_super) { |
|
5178 |
+ __extends(class_node_complex, _super); |
|
3413 | 5179 |
/** |
3414 | 5180 |
* @author fenris |
3415 |
- * @todo use a treemap-function (but first make one :P) |
|
3416 | 5181 |
*/ |
3417 |
- function adjust_labels(shape, transformator) { |
|
3418 |
- if (false) { |
|
3419 |
- } |
|
3420 |
- else if (shape instanceof lib_meta.class_shape_enumeration) { |
|
3421 |
- var shape_ = (shape); |
|
3422 |
- return (new lib_meta.class_shape_enumeration({ |
|
3423 |
- "shape_option": adjust_labels(shape_.shape_option_get(), transformator), |
|
3424 |
- "options": shape_.options_get().map(function (option) { |
|
3425 |
- return { |
|
3426 |
- "value": option.value, |
|
3427 |
- "label": transformator(option.label) |
|
3428 |
- }; |
|
3429 |
- }), |
|
3430 |
- "soft": shape_.soft_get(), |
|
3431 |
- "defaultvalue": shape_.defaultvalue_get() |
|
3432 |
- })); |
|
3433 |
- } |
|
3434 |
- else if (shape instanceof lib_meta.class_shape_array) { |
|
3435 |
- var shape_ = (shape); |
|
3436 |
- return (new lib_meta.class_shape_array({ |
|
3437 |
- "shape_element": adjust_labels(shape_.shape_element_get(), transformator), |
|
3438 |
- "soft": shape_.soft_get(), |
|
3439 |
- "defaultvalue": shape_.defaultvalue_get() |
|
3440 |
- })); |
|
3441 |
- } |
|
3442 |
- else if (shape instanceof lib_meta.class_shape_object) { |
|
3443 |
- var shape_ = (shape); |
|
3444 |
- return (new lib_meta.class_shape_object({ |
|
3445 |
- "fields": shape_.fields_get().map(function (field) { |
|
3446 |
- return { |
|
3447 |
- "name": field.name, |
|
3448 |
- "shape": adjust_labels(field.shape, transformator), |
|
3449 |
- "label": transformator(field.label) |
|
3450 |
- }; |
|
3451 |
- }), |
|
3452 |
- "soft": shape_.soft_get(), |
|
3453 |
- "defaultvalue": shape_.defaultvalue_get() |
|
3454 |
- })); |
|
3455 |
- } |
|
3456 |
- else { |
|
3457 |
- // shape["label"] = ((shape["label"] == null) ? null : transformator(shape["label"])); |
|
3458 |
- return shape; |
|
3459 |
- } |
|
5182 |
+ function class_node_complex(name, attributes, children) { |
|
5183 |
+ if (attributes === void 0) { attributes = {}; } |
|
5184 |
+ if (children === void 0) { children = []; } |
|
5185 |
+ var _this = _super.call(this) || this; |
|
5186 |
+ _this.name = name; |
|
5187 |
+ _this.attributes = attributes; |
|
5188 |
+ _this.children = children; |
|
5189 |
+ return _this; |
|
3460 | 5190 |
} |
3461 |
- lib_meta.adjust_labels = adjust_labels; |
|
3462 |
-})(lib_meta || (lib_meta = {})); |
|
3463 |
-var plain_text_to_html = function (text) { |
|
3464 |
- var ret = text; |
|
3465 |
- ret = ret.replace(/ /g, " "); // convert multiple whitespace to forced ones |
|
3466 |
- ret = ret.split("\n").join("<br/>"); |
|
3467 |
- return ret; |
|
3468 |
-}; |
|
3469 | 5191 |
/** |
3470 |
- * @desc makes a valid |
|
5192 |
+ * @author fenris |
|
3471 | 5193 |
*/ |
3472 |
-var format_sentence = function (str, rtl, caseSense) { |
|
3473 |
- if (rtl === void 0) { rtl = false; } |
|
3474 |
- if (caseSense === void 0) { caseSense = true; } |
|
3475 |
- if (str === "") { |
|
3476 |
- return str; |
|
3477 |
- } |
|
3478 |
- else { |
|
3479 |
- var marks = { |
|
3480 |
- ".": true, |
|
3481 |
- "?": true, |
|
3482 |
- "!": true |
|
3483 |
- }; |
|
3484 |
- var default_mark = "."; |
|
3485 |
- var ret = str.split(""); |
|
3486 |
- if (!rtl) { |
|
3487 |
- ret[0] = ret[0].toLocaleUpperCase(); |
|
3488 |
- if (!(ret[ret.length - 1] in marks)) { |
|
3489 |
- ret.push(default_mark); |
|
3490 |
- } |
|
3491 |
- } |
|
3492 |
- else { |
|
3493 |
- ret[ret.length - 1] = ret[ret.length - 1].toLocaleUpperCase(); |
|
3494 |
- if (!(ret[0] in marks)) { |
|
3495 |
- ret.unshift(default_mark); |
|
3496 |
- } |
|
3497 |
- } |
|
3498 |
- return ret.join(""); |
|
3499 |
- } |
|
3500 |
-}; |
|
3501 |
-var fill_string_template = function (template_string, object, fabric, delimiter, default_string, sloppy) { |
|
3502 |
- if (fabric === void 0) { fabric = function (object, key) { return object[key]; }; } |
|
3503 |
- if (delimiter === void 0) { delimiter = "%"; } |
|
3504 |
- if (default_string === void 0) { default_string = null; } |
|
3505 |
- function get_tags(str) { |
|
3506 |
- var r = new RegExp(delimiter + "[^\\s^" + delimiter + "]+" + delimiter, "gi"); |
|
3507 |
- return ((str.match(r) || []).map(function (e) { |
|
3508 |
- return e.slice(delimiter.length, e.length - delimiter.length); |
|
3509 |
- })); |
|
3510 |
- } |
|
3511 |
- function replace_tag(str, tag, value) { |
|
3512 |
- var r = new RegExp(delimiter + tag + delimiter, "gi"); |
|
3513 |
- return str.replace(r, value); |
|
3514 |
- } |
|
3515 |
- function replace_tags(str, obj) { |
|
3516 |
- return (get_tags(str).reduce(function (ret, key) { |
|
3517 |
- var value = ""; |
|
3518 |
- try { |
|
3519 |
- value = fabric(obj, key); |
|
3520 |
- if ((!sloppy && (value === void 0)) || (sloppy && (value == void 0))) { |
|
3521 |
- value = default_string; |
|
3522 |
- } |
|
3523 |
- } |
|
3524 |
- catch (e) { |
|
3525 |
- console.warn("invalid placeholder " + key); |
|
3526 |
- value = default_string; |
|
3527 |
- } |
|
3528 |
- return replace_tag(ret, key, value); |
|
3529 |
- }, str)); |
|
3530 |
- } |
|
3531 |
- return replace_tags(template_string, object); |
|
3532 |
-}; |
|
3533 |
-var make_string_template = function (_template, _fabrics) { |
|
3534 |
- if (_fabrics === void 0) { _fabrics = {}; } |
|
3535 |
- function replace_tag(str, tag, value) { |
|
3536 |
- var r = new RegExp("%" + tag + "%", "gi"); |
|
3537 |
- return str.replace(r, value); |
|
3538 |
- } |
|
3539 |
- function replace_tags(str, obj) { |
|
3540 |
- return (Object.keys(obj).reduce(function (ret, key) { |
|
3541 |
- return replace_tag(ret, key, _fabrics[key] || obj[key]); |
|
3542 |
- }, str)); |
|
3543 |
- } |
|
3544 |
- return (function (tags) { |
|
3545 |
- return replace_tags(_template, tags); |
|
3546 |
- }); |
|
3547 |
-}; |
|
3548 |
-var make_eml_header = (function () { |
|
3549 |
- var _template = ""; |
|
3550 |
- _template += "From: %from%\n"; |
|
3551 |
- _template += "To: %recipient%\n"; |
|
3552 |
- _template += "Subject: %subject%\n"; |
|
3553 |
- _template += "X-Mailer: greenscale-plankton.emlgen\n"; |
|
3554 |
- return make_string_template(_template); |
|
3555 |
-})(); |
|
3556 |
-var make_eml_body = (function () { |
|
3557 |
- var exports = {}; |
|
3558 |
- exports["simple_body"] = make_string_template("Content-Type: %contenttype%\n\n%body%\n\n"); |
|
3559 |
- // very basic implementation |
|
3560 |
- // parts = [{contenttype:"text/html; charset=UTF-8", body: "<h1>foo</h1>" }, {...}] |
|
3561 |
- exports["body_boundrary"] = function (parts, boundrary) { |
|
3562 |
- var _template = ""; |
|
3563 |
- _template += "--%boundrary%\n"; |
|
3564 |
- _template += "Content-Type: %contenttype%\n\n%body%\n\n"; |
|
3565 |
- //_template += "--%boundrary%--\n\n"; |
|
3566 |
- var maker = make_string_template(_template); |
|
3567 |
- return (parts.reduce(function (prev, curr) { |
|
3568 |
- curr.boundrary = boundrary; |
|
3569 |
- return [prev, maker(curr)].join(""); |
|
3570 |
- }, "")); |
|
3571 |
- }; |
|
3572 |
- // body must be base64 encoded! |
|
3573 |
- exports["attachment_boundrary"] = function (parts, boundrary) { |
|
3574 |
- var _template = ""; |
|
3575 |
- _template += "--%boundrary%\n"; |
|
3576 |
- _template += "Content-Type: %contenttype%\n"; |
|
3577 |
- _template += "Content-Transfer-Encoding: base64\n"; |
|
3578 |
- _template += "Content-Disposition: %disposition%; filename=\"%name%\"\n\n"; |
|
3579 |
- _template += "%body%\n\n"; |
|
3580 |
- //_template += "--%boundrary%--\n\n"; |
|
3581 |
- var maker = make_string_template(_template); |
|
3582 |
- return (parts.reduce(function (prev, curr) { |
|
3583 |
- curr.boundrary = boundrary; |
|
3584 |
- if (curr.disposition === void 0) |
|
3585 |
- curr.disposition = "inline"; |
|
3586 |
- return [prev, maker(curr)].join(""); |
|
3587 |
- }, "")); |
|
3588 |
- }; |
|
3589 |
- exports["gen_boundrary"] = function () { |
|
3590 |
- return ("xxxxxxxxxxxxxxxxxxxxxx".replace(/[xy]/g, function (c) { |
|
3591 |
- var r = crypto.getRandomValues(new Uint8Array(1))[0] % 16 | 0, v = c == "x" ? r : (r & 0x3 | 0x8); |
|
3592 |
- return v.toString(16); |
|
3593 |
- })); |
|
5194 |
+ class_node_complex.prototype.compile = function (depth) { |
|
5195 |
+ var _this = this; |
|
5196 |
+ if (depth === void 0) { depth = 0; } |
|
5197 |
+ var output = ""; |
|
5198 |
+ var attributes = Object.keys(this.attributes).map(function (key) { return (" " + key + "=" + ("\"" + _this.attributes[key] + "\"")); }).join(""); |
|
5199 |
+ output += (lib_string.repeat("\t", depth) + "<" + this.name + attributes + ">" + "\n"); |
|
5200 |
+ this.children.forEach(function (child) { return (output += child.compile(depth + 1)); }); |
|
5201 |
+ output += (lib_string.repeat("\t", depth) + "</" + this.name + ">" + "\n"); |
|
5202 |
+ return output; |
|
3594 | 5203 |
}; |
3595 |
- // simple implementation without alternatives (old rfc) |
|
3596 |
- exports["complete_boundrary"] = function (bodyparts, attachments) { |
|
3597 |
- var ret = ""; |
|
3598 |
- var boundrary = exports["gen_boundrary"](); |
|
3599 |
- ret += exports["body_boundrary"](bodyparts, boundrary); |
|
3600 |
- ret += exports["attachment_boundrary"](attachments, boundrary); |
|
3601 |
- ret += "--" + boundrary + "--\n\nINVISIBLE!!!!"; |
|
3602 |
- return (exports["simple_body"]({ |
|
3603 |
- "contenttype": sprintf("multipart/mixed; boundary=%s", [boundrary]), |
|
3604 |
- "body": ret |
|
3605 |
- })); |
|
5204 |
+ return class_node_complex; |
|
5205 |
+ }(class_node)); |
|
5206 |
+ lib_xml.class_node_complex = class_node_complex; |
|
5207 |
+})(lib_xml || (lib_xml = {})); |
|
5208 |
+var __extends = (this && this.__extends) || (function () { |
|
5209 |
+ var extendStatics = Object.setPrototypeOf || |
|
5210 |
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
5211 |
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; |
|
5212 |
+ return function (d, b) { |
|
5213 |
+ extendStatics(d, b); |
|
5214 |
+ function __() { this.constructor = d; } |
|
5215 |
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
3606 | 5216 |
}; |
3607 |
- return exports; |
|
3608 | 5217 |
})(); |
3609 |
-///<reference path="../../base/build/logic-decl.d.ts"/> |
|
3610 |
-var lib_string; |
|
3611 |
-(function (lib_string) { |
|
5218 |
+var lib_path; |
|
5219 |
+(function (lib_path) { |
|
3612 | 5220 |
/** |
3613 |
- * @author frac |
|
5221 |
+ * @author fenris |
|
3614 | 5222 |
*/ |
3615 |
- var hexdigits = 4; |
|
5223 |
+ var class_step = (function () { |
|
5224 |
+ function class_step() { |
|
5225 |
+ } |
|
5226 |
+ return class_step; |
|
5227 |
+ }()); |
|
5228 |
+ lib_path.class_step = class_step; |
|
3616 | 5229 |
/** |
3617 |
- * @author frac |
|
5230 |
+ * @author fenris |
|
3618 | 5231 |
*/ |
3619 |
- var index_max = 1 << (4 * hexdigits); |
|
5232 |
+ var class_step_stay = (function (_super) { |
|
5233 |
+ __extends(class_step_stay, _super); |
|
5234 |
+ function class_step_stay() { |
|
5235 |
+ return _super !== null && _super.apply(this, arguments) || this; |
|
5236 |
+ } |
|
3620 | 5237 |
/** |
3621 |
- * @author frac |
|
5238 |
+ * @author fenris |
|
3622 | 5239 |
*/ |
3623 |
- var index_is = 0; |
|
5240 |
+ class_step_stay.prototype.invert = function () { |
|
5241 |
+ return (new class_step_stay()); |
|
5242 |
+ }; |
|
3624 | 5243 |
/** |
3625 |
- * @author neuc,frac |
|
5244 |
+ * @author fenris |
|
3626 | 5245 |
*/ |
3627 |
- function empty(str) { |
|
3628 |
- var tmp = str.trim(); |
|
3629 |
- return (tmp === ""); |
|
3630 |
- } |
|
3631 |
- lib_string.empty = empty; |
|
5246 |
+ class_step_stay.prototype.toString = function () { |
|
5247 |
+ return "."; |
|
5248 |
+ }; |
|
5249 |
+ return class_step_stay; |
|
5250 |
+ }(class_step)); |
|
5251 |
+ lib_path.class_step_stay = class_step_stay; |
|
3632 | 5252 |
/** |
3633 |
- * @desc returns a unique string |
|
3634 |
- * @param {string} prefix an optional prefix for the generated string |
|
3635 |
- * @return {string} |
|
3636 |
- * @author frac |
|
5253 |
+ * @author fenris |
|
3637 | 5254 |
*/ |
3638 |
- function generate(prefix) { |
|
3639 |
- if (prefix === void 0) { prefix = "string_"; } |
|
3640 |
- if (index_is > index_max) { |
|
3641 |
- throw (new Error("[string_generate] out of valid indices")); |
|
3642 |
- } |
|
3643 |
- else { |
|
3644 |
- return lib_string.sprintf(prefix + "%0" + hexdigits.toString() + "X", [index_is++]); |
|
3645 |
- } |
|
5255 |
+ var class_step_back = (function (_super) { |
|
5256 |
+ __extends(class_step_back, _super); |
|
5257 |
+ function class_step_back() { |
|
5258 |
+ return _super !== null && _super.apply(this, arguments) || this; |
|
3646 | 5259 |
} |
3647 |
- lib_string.generate = generate; |
|
3648 | 5260 |
/** |
3649 |
- * @desc splits a string, but returns an empty list, if the string is empty |
|
3650 |
- * @param {string} chain |
|
3651 |
- * @param {string} separator |
|
3652 |
- * @return {Array<string>} |
|
3653 |
- * @author frac |
|
5261 |
+ * @author fenris |
|
3654 | 5262 |
*/ |
3655 |
- function split(chain, separator) { |
|
3656 |
- if (separator === void 0) { separator = " "; } |
|
3657 |
- if (chain.length == 0) { |
|
3658 |
- return []; |
|
3659 |
- } |
|
3660 |
- else { |
|
3661 |
- return chain.split(separator); |
|
3662 |
- } |
|
3663 |
- } |
|
3664 |
- lib_string.split = split; |
|
5263 |
+ class_step_back.prototype.invert = function () { |
|
5264 |
+ throw (new Error("impossible")); |
|
5265 |
+ }; |
|
3665 | 5266 |
/** |
3666 |
- * @desc concats a given word with itself n times |
|
3667 |
- * @param {string} word |
|
3668 |
- * @param {int} |
|
3669 |
- * @return {string} |
|
3670 |
- * @author frac |
|
5267 |
+ * @author fenris |
|
3671 | 5268 |
*/ |
3672 |
- function repeat(word, count) { |
|
3673 |
- return ((count == 0) ? "" : (word + repeat(word, count - 1))); |
|
3674 |
- } |
|
3675 |
- lib_string.repeat = repeat; |
|
5269 |
+ class_step_back.prototype.toString = function () { |
|
5270 |
+ return ".."; |
|
5271 |
+ }; |
|
5272 |
+ return class_step_back; |
|
5273 |
+ }(class_step)); |
|
5274 |
+ lib_path.class_step_back = class_step_back; |
|
3676 | 5275 |
/** |
3677 |
- * @desc lengthens a string by repeatedly appending or prepending another string |
|
3678 |
- * @param {string} word the string to pad |
|
3679 |
- * @param {int} length the length, which the result shall have |
|
3680 |
- * @param {string} symbol the string, which will be added (multiple times) |
|
3681 |
- * @param {boolean} [prepend]; whether to prepend (~true) or append (~false); default: false |
|
3682 |
- * @return {string} the padded string |
|
3683 |
- * @author frac |
|
5276 |
+ * @author fenris |
|
3684 | 5277 |
*/ |
3685 |
- function pad(word, length, symbol, prepend) { |
|
3686 |
- if (prepend === void 0) { prepend = false; } |
|
3687 |
- if (prepend) { |
|
3688 |
- while (word.length < length) |
|
3689 |
- word = symbol + word; |
|
3690 |
- return word.substring(word.length - length); |
|
3691 |
- } |
|
3692 |
- else { |
|
3693 |
- while (word.length < length) |
|
3694 |
- word = word + symbol; |
|
3695 |
- return word.substring(0, length); |
|
3696 |
- } |
|
3697 |
- } |
|
3698 |
- lib_string.pad = pad; |
|
5278 |
+ var class_step_regular = (function (_super) { |
|
5279 |
+ __extends(class_step_regular, _super); |
|
3699 | 5280 |
/** |
3700 |
- * @desc checks if a given string conttains a certain substring |
|
3701 |
- * @param {string} string |
|
3702 |
- * @param {string} part |
|
3703 |
- * @return {boolean} |
|
3704 |
- * @author frac |
|
5281 |
+ * @author fenris |
|
3705 | 5282 |
*/ |
3706 |
- function contains(chain, part) { |
|
3707 |
- if (typeof (chain) !== "string") |
|
3708 |
- return false; |
|
3709 |
- return (chain.indexOf(part) >= 0); |
|
5283 |
+ function class_step_regular(name) { |
|
5284 |
+ var _this = _super.call(this) || this; |
|
5285 |
+ _this.name = name; |
|
5286 |
+ return _this; |
|
3710 | 5287 |
} |
3711 |
- lib_string.contains = contains; |
|
3712 | 5288 |
/** |
3713 |
- * @desc checks if a given string starts with a certain substring |
|
3714 |
- * @param {string} string |
|
3715 |
- * @param {string} part |
|
3716 |
- * @return {boolean} |
|
3717 |
- * @author frac |
|
5289 |
+ * @author fenris |
|
3718 | 5290 |
*/ |
3719 |
- function startsWith(chain, part) { |
|
3720 |
- if (typeof (chain) !== "string") |
|
3721 |
- return false; |
|
3722 |
- // return (string.indexOf(part) === 0); |
|
3723 |
- return ((function (m, n) { |
|
3724 |
- if (n == 0) { |
|
3725 |
- return true; |
|
3726 |
- } |
|
3727 |
- else { |
|
3728 |
- if (m == 0) { |
|
3729 |
- return false; |
|
3730 |
- } |
|
3731 |
- else { |
|
3732 |
- return ((chain[0] == part[0]) && startsWith(chain.substring(1), part.substring(1))); |
|
3733 |
- } |
|
3734 |
- } |
|
3735 |
- })(chain.length, part.length)); |
|
3736 |
- } |
|
3737 |
- lib_string.startsWith = startsWith; |
|
5291 |
+ class_step_regular.prototype.invert = function () { |
|
5292 |
+ return (new class_step_back()); |
|
5293 |
+ }; |
|
3738 | 5294 |
/** |
3739 |
- * @desc checks if a given string ends with a certain substring |
|
3740 |
- * @param {string} string |
|
3741 |
- * @param {string} part |
|
3742 |
- * @return {boolean} |
|
3743 |
- * @author frac |
|
5295 |
+ * @author fenris |
|
3744 | 5296 |
*/ |
3745 |
- function endsWith(chain, part) { |
|
3746 |
- if (typeof (chain) !== "string") |
|
3747 |
- return false; |
|
3748 |
- // return (string.lastIndexOf(part) === string.length-part.length); |
|
3749 |
- return ((function (m, n) { |
|
3750 |
- if (n == 0) { |
|
3751 |
- return true; |
|
3752 |
- } |
|
3753 |
- else { |
|
3754 |
- if (m == 0) { |
|
3755 |
- return false; |
|
3756 |
- } |
|
3757 |
- else { |
|
3758 |
- // console.info(("(" + string[m-1] + " == " + part[n-1] + ")") + " = " + String(string[m-1] == part[n-1])); |
|
3759 |
- return ((chain[m - 1] == part[n - 1]) && endsWith(chain.substring(0, m - 1), part.substring(0, n - 1))); |
|
5297 |
+ class_step_regular.prototype.toString = function () { |
|
5298 |
+ return this.name; |
|
5299 |
+ }; |
|
5300 |
+ return class_step_regular; |
|
5301 |
+ }(class_step)); |
|
5302 |
+ lib_path.class_step_regular = class_step_regular; |
|
5303 |
+ /** |
|
5304 |
+ * @author fenris |
|
5305 |
+ */ |
|
5306 |
+ function step_read(s) { |
|
5307 |
+ switch (s) { |
|
5308 |
+ case ".": { |
|
5309 |
+ return (new class_step_stay()); |
|
5310 |
+ // break; |
|
3760 | 5311 |
} |
5312 |
+ case "..": { |
|
5313 |
+ return (new class_step_back()); |
|
5314 |
+ // break; |
|
3761 | 5315 |
} |
3762 |
- })(chain.length, part.length)); |
|
5316 |
+ default: { |
|
5317 |
+ return (new class_step_regular(s)); |
|
5318 |
+ // break; |
|
3763 | 5319 |
} |
3764 |
- lib_string.endsWith = endsWith; |
|
3765 |
- /** |
|
3766 |
- * @desc count the occourrences of a string in a string |
|
3767 |
- * @param string haystack_string the string wich should be examined |
|
3768 |
- * @param string needle_string the string which should be counted |
|
3769 |
- * @author neuc |
|
3770 |
- */ |
|
3771 |
- function count_occourrences(haystack_string, needle_string, check_escape) { |
|
3772 |
- var cnt = 0; |
|
3773 |
- var pos = -1; |
|
3774 |
- do { |
|
3775 |
- pos = haystack_string.indexOf(needle_string, pos + 1); |
|
3776 |
- if ((!check_escape) || (haystack_string[pos - 1] != "\\")) { |
|
3777 |
- cnt++; |
|
3778 | 5320 |
} |
3779 |
- } while (pos >= 0); |
|
3780 |
- return cnt - 1; |
|
3781 | 5321 |
} |
3782 |
- lib_string.count_occourrences = count_occourrences; |
|
3783 |
- ; |
|
5322 |
+ lib_path.step_read = step_read; |
|
5323 |
+})(lib_path || (lib_path = {})); |
|
5324 |
+///<reference path="../../../plankton/object/build/logic-decl.d.ts"/> |
|
5325 |
+var lib_path; |
|
5326 |
+(function (lib_path) { |
|
3784 | 5327 |
/** |
3785 | 5328 |
* @author fenris |
3786 | 5329 |
*/ |
3787 |
- function stance(str, args) { |
|
3788 |
- Object.keys(args).forEach(function (key) { |
|
3789 |
- var value = args[key]; |
|
3790 |
- var regexp_argument = new RegExp("\\${" + key + "}"); |
|
3791 |
- str = str.replace(regexp_argument, value); |
|
3792 |
- }); |
|
3793 |
- return str; |
|
5330 |
+ var class_chain = (function () { |
|
5331 |
+ /** |
|
5332 |
+ * @author fenris |
|
5333 |
+ */ |
|
5334 |
+ function class_chain(steps) { |
|
5335 |
+ if (steps === void 0) { steps = []; } |
|
5336 |
+ this.steps = steps; |
|
3794 | 5337 |
} |
3795 |
- lib_string.stance = stance; |
|
3796 |
-})(lib_string || (lib_string = {})); |
|
3797 | 5338 |
/** |
3798 |
- * @desc adapters for old syntax |
|
5339 |
+ * @author fenris |
|
3799 | 5340 |
*/ |
3800 |
-var string_generate = lib_string.generate; |
|
3801 |
-var string_split = lib_string.split; |
|
3802 |
-var string_repeat = lib_string.repeat; |
|
3803 |
-var string_pad = lib_string.pad; |
|
3804 |
-var string_contains = lib_string.contains; |
|
3805 |
-var string_startsWith = lib_string.startsWith; |
|
3806 |
-var string_endsWith = lib_string.endsWith; |
|
3807 |
-var string_count_occourrences = lib_string.count_occourrences; |
|
3808 |
-var lib_string; |
|
3809 |
-(function (lib_string) { |
|
3810 |
- var pattern = /%([-+#0 ]*)([0-9]*)[\.]{0,1}([0-9]*)([\w]{1})/; |
|
3811 |
- var gpattern = /%([-+#0 ]*)([0-9]*)[\.]{0,1}([0-9]*)([\w]{1})/g; |
|
3812 |
- function split_format(format) { |
|
3813 |
- var tmp = format.match(pattern); |
|
3814 |
- if (tmp === null) |
|
3815 |
- return null; |
|
3816 |
- return { |
|
3817 |
- 'flags': tmp[1].split(""), |
|
3818 |
- 'width': Number(tmp[2]), |
|
3819 |
- 'precision': tmp[3] === '' ? null : Number(tmp[3]), |
|
3820 |
- 'specifier': tmp[4], |
|
3821 |
- 'string': format |
|
5341 |
+ class_chain.splitter = function (system) { |
|
5342 |
+ if (system === void 0) { system = "linux"; } |
|
5343 |
+ return (object_fetch({ |
|
5344 |
+ "linux": "/", |
|
5345 |
+ "bsd": "/", |
|
5346 |
+ "win": "\\" |
|
5347 |
+ }, system, "/", 2)); |
|
3822 | 5348 |
}; |
5349 |
+ /** |
|
5350 |
+ * @desc removes superfluent steps from the chain, e.g. infix ".." |
|
5351 |
+ * @author fenris |
|
5352 |
+ */ |
|
5353 |
+ class_chain.prototype.normalize = function () { |
|
5354 |
+ var steps = this.steps; |
|
5355 |
+ // filter "stay" |
|
5356 |
+ { |
|
5357 |
+ steps = steps.filter(function (step) { return (!(step instanceof lib_path.class_step_stay)); }); |
|
3823 | 5358 |
} |
3824 |
- function make_err(format, arg, should) { |
|
3825 |
- return ("[sprintf]" + " " + "argument for '" + format.string + "' has to be '" + should + "' but '" + arg + "' is '" + typeof arg + "'!"); |
|
3826 |
- } |
|
3827 |
- function test_arg(format, arg, should) { |
|
3828 |
- if (typeof arg !== should) { |
|
3829 |
- console.warn(make_err(format, arg, should)); |
|
3830 |
- return false; |
|
5359 |
+ // filter "regular-back" |
|
5360 |
+ { |
|
5361 |
+ var _loop_1 = function () { |
|
5362 |
+ if (steps.length < 1) { |
|
5363 |
+ return "break"; |
|
3831 | 5364 |
} |
5365 |
+ else { |
|
5366 |
+ var last_1 = steps[0]; |
|
5367 |
+ var found = steps.slice(1).some(function (step, index) { |
|
5368 |
+ if (step instanceof lib_path.class_step_back) { |
|
5369 |
+ if (last_1 instanceof lib_path.class_step_regular) { |
|
5370 |
+ steps.splice(index, 2); |
|
3832 | 5371 |
return true; |
3833 | 5372 |
} |
3834 |
- function string_fill(str, char, len, left) { |
|
3835 |
- while (str.length < len) { |
|
3836 |
- if (left) { |
|
3837 |
- str += char; |
|
3838 | 5373 |
} |
3839 |
- else { |
|
3840 |
- str = char + str; |
|
5374 |
+ last_1 = step; |
|
5375 |
+ return false; |
|
5376 |
+ }); |
|
5377 |
+ if (!found) { |
|
5378 |
+ return "break"; |
|
3841 | 5379 |
} |
3842 | 5380 |
} |
3843 |
- return str; |
|
5381 |
+ }; |
|
5382 |
+ while (true) { |
|
5383 |
+ var state_1 = _loop_1(); |
|
5384 |
+ if (state_1 === "break") |
|
5385 |
+ break; |
|
5386 |
+ } |
|
3844 | 5387 |
} |
5388 |
+ return (new class_chain(steps)); |
|
5389 |
+ }; |
|
3845 | 5390 |
/** |
3846 |
- * the known_parameters are used to parse the different identifiers for the welln known syntax: |
|
3847 |
- * flag width precision identifier |
|
3848 |
- * %{[0#+- ]}{[0-9]*}.{[0-9]*}[fFdiueEgGsoxXaAsn] |
|
3849 |
- * flags: |
|
3850 |
- * 0 - fill with '0' instead of ' ' if the string length < width |
|
3851 |
- * # - not implemented |
|
3852 |
- * - - left-justified -> fill on the right side to reach width |
|
3853 |
- * + - force using '+' on positive numbers |
|
3854 |
- * ' ' - add a single space before positive numbers |
|
3855 |
- * |
|
3856 |
- * identifiers |
|
3857 |
- * %f, %F - interpret given number as float, width: the minimal total width (fill with ' ' or '0' if the |
|
3858 |
- * resulting string is too short, precision: cut more then given decimal places |
|
3859 |
- * %d, %i, %u - interpret number as integer, decimal places will be cut. width: like float, precision: |
|
3860 |
- * fill with '0' on right side until length given in precision is reached |
|
3861 |
- * %e - interpret as float and write as scientifical number, width & precision like in float |
|
3862 |
- * %E - same es %e but uppercase 'E' |
|
3863 |
- * %g - use the shortest string of %f or %e |
|
3864 |
- * %G - use the shortest string of %E or %E |
|
3865 |
- * %s - simply print a string |
|
3866 |
- * %o - print the given number in octal notation |
|
3867 |
- * %x - print the given number in hex notation |
|
3868 |
- * %X - same as %x but with uppercase characters |
|
3869 |
- * %a - alias to %x |
|
3870 |
- * %A - alias to %X |
|
3871 |
- * %n - just print nothing |
|
3872 |
- * @type {{}} |
|
5391 |
+ * @author fenris |
|
3873 | 5392 |
*/ |
3874 |
- var known_params = {}; |
|
3875 |
- known_params["f"] = function (format, arg) { |
|
3876 |
- if (!test_arg(format, arg, "number")) |
|
3877 |
- return "Ø"; |
|
3878 |
- var tmp = Math.abs(arg); |
|
3879 |
- var sign = (arg < 0) ? -1 : 1; |
|
3880 |
- var tmp_result = null; |
|
3881 |
- if (format.precision !== null) { |
|
3882 |
- tmp = Math.floor(Math.pow(10, format.precision) * tmp) / Math.pow(10, format.precision); |
|
3883 |
- var tmp_ = (tmp * sign).toString().split("."); |
|
3884 |
- if (tmp_.length === 1) |
|
3885 |
- tmp_.push(""); |
|
3886 |
- tmp_[1] = string_fill(tmp_[1], "0", format.precision, true); |
|
3887 |
- tmp_result = tmp_.join("."); |
|
3888 |
- } |
|
3889 |
- else { |
|
3890 |
- tmp_result = (sign * tmp).toString(); |
|
3891 |
- } |
|
3892 |
- if ((format.flags.indexOf(" ") >= 0) && (arg >= 0)) { |
|
3893 |
- tmp_result = " " + tmp; |
|
3894 |
- } |
|
3895 |
- else if ((format.flags.indexOf("+") >= 0) && (arg >= 0)) { |
|
3896 |
- tmp_result = "+" + tmp; |
|
3897 |
- } |
|
3898 |
- tmp_result = string_fill(tmp, (format.flags.indexOf("0") >= 0) ? "0" : " ", format.width, (format.flags.indexOf("-") >= 0)); |
|
3899 |
- return tmp_result; |
|
5393 |
+ class_chain.prototype.invert = function () { |
|
5394 |
+ return (new class_chain(this.steps.map(function (step) { return step.invert(); }))); |
|
3900 | 5395 |
}; |
3901 |
- known_params["F"] = known_params["f"]; |
|
3902 |
- known_params["d"] = function (format, arg) { |
|
3903 |
- if (!test_arg(format, arg, 'number')) |
|
3904 |
- return 'Ø'; |
|
3905 |
- var tmp = (((arg < 0 && format.specifier !== 'u') ? -1 : 1) * Math.floor(Math.abs(arg))).toString(); |
|
3906 |
- if ((format.specifier === 'd' || format.specifier === 'i') && format.flags.indexOf(' ') >= 0 && arg >= 0) { |
|
3907 |
- tmp = ' ' + tmp; |
|
3908 |
- } |
|
3909 |
- else if ((format.specifier === 'd' || format.specifier === 'i') && format.flags.indexOf('+') >= 0 && arg >= 0) { |
|
3910 |
- tmp = '+' + tmp; |
|
3911 |
- } |
|
3912 |
- tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); |
|
3913 |
- tmp = string_fill(tmp, '0', format.precision === null ? 0 : format.precision, false); |
|
3914 |
- return tmp; |
|
5396 |
+ /** |
|
5397 |
+ * @author fenris |
|
5398 |
+ */ |
|
5399 |
+ class_chain.prototype.add = function (step) { |
|
5400 |
+ return (new class_chain(this.steps.concat([step]))).normalize(); |
|
3915 | 5401 |
}; |
3916 |
- known_params["i"] = known_params["d"]; |
|
3917 |
- known_params["u"] = known_params["d"]; |
|
3918 |
- known_params["e"] = function (format, arg) { |
|
3919 |
- if (!test_arg(format, arg, 'number')) |
|
3920 |
- return 'Ø'; |
|
3921 |
- var tmp = arg.toExponential(format.precision === null ? undefined : format.precision).toString(); |
|
3922 |
- if (format.flags.indexOf(' ') >= 0 && arg >= 0) { |
|
3923 |
- tmp = ' ' + tmp; |
|
3924 |
- } |
|
3925 |
- else if (format.flags.indexOf('+') >= 0 && arg >= 0) { |
|
3926 |
- tmp = '+' + tmp; |
|
3927 |
- } |
|
3928 |
- tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); |
|
3929 |
- return tmp; |
|
5402 |
+ /** |
|
5403 |
+ * @author fenris |
|
5404 |
+ */ |
|
5405 |
+ class_chain.prototype.extend = function (chain) { |
|
5406 |
+ return (new class_chain(this.steps.concat(chain.steps))).normalize(); |
|
3930 | 5407 |
}; |
3931 |
- known_params["E"] = function (format, arg) { |
|
3932 |
- return known_params["e"](format, arg).toUpperCase(); |
|
5408 |
+ /** |
|
5409 |
+ * @author fenris |
|
5410 |
+ */ |
|
5411 |
+ class_chain.prototype.as_string = function (system) { |
|
5412 |
+ if (system === void 0) { system = "linux"; } |
|
5413 |
+ var splitter = class_chain.splitter(system); |
|
5414 |
+ return ((this.steps.length == 0) ? ("." + splitter) : this.steps.map(function (step) { return (step.toString() + splitter); }).join("")); |
|
3933 | 5415 |
}; |
3934 |
- known_params["g"] = function (format, arg) { |
|
3935 |
- if (!test_arg(format, arg, 'number')) |
|
3936 |
- return 'Ø'; |
|
3937 |
- var tmpf = known_params["f"](format, arg); |
|
3938 |
- var tmpe = known_params["e"](format, arg); |
|
3939 |
- if (tmpf.length < tmpe.length) { |
|
3940 |
- return tmpf; |
|
5416 |
+ /** |
|
5417 |
+ * @author fenris |
|
5418 |
+ */ |
|
5419 |
+ class_chain.prototype.toString = function () { |
|
5420 |
+ return this.as_string(); |
|
5421 |
+ }; |
|
5422 |
+ return class_chain; |
|
5423 |
+ }()); |
|
5424 |
+ lib_path.class_chain = class_chain; |
|
5425 |
+ /** |
|
5426 |
+ * @author fenris |
|
5427 |
+ */ |
|
5428 |
+ function chain_read(str, system) { |
|
5429 |
+ if (system === void 0) { system = "linux"; } |
|
5430 |
+ var splitter = class_chain.splitter(system); |
|
5431 |
+ var parts = str.split(splitter); |
|
5432 |
+ if (parts[parts.length - 1] == "") |
|
5433 |
+ parts.pop(); |
|
5434 |
+ return (new class_chain(parts.map(lib_path.step_read))); |
|
3941 | 5435 |
} |
3942 |
- else { |
|
3943 |
- return tmpe; |
|
5436 |
+ lib_path.chain_read = chain_read; |
|
5437 |
+})(lib_path || (lib_path = {})); |
|
5438 |
+///<reference path="../../../plankton/object/build/logic-decl.d.ts"/> |
|
5439 |
+var lib_path; |
|
5440 |
+(function (lib_path) { |
|
5441 |
+ /** |
|
5442 |
+ * @author fenris |
|
5443 |
+ */ |
|
5444 |
+ var class_location = (function () { |
|
5445 |
+ /** |
|
5446 |
+ * @author fenris |
|
5447 |
+ */ |
|
5448 |
+ function class_location(anchor, chain) { |
|
5449 |
+ this.anchor = anchor; |
|
5450 |
+ this.chain = chain; |
|
3944 | 5451 |
} |
5452 |
+ /** |
|
5453 |
+ * @author fenris |
|
5454 |
+ */ |
|
5455 |
+ class_location.anchorpattern = function (system) { |
|
5456 |
+ if (system === void 0) { system = "linux"; } |
|
5457 |
+ return (object_fetch({ |
|
5458 |
+ "linux": new RegExp("/"), |
|
5459 |
+ "bsd": new RegExp("/"), |
|
5460 |
+ "win": new RegExp("[A-Z]:\\\\>") |
|
5461 |
+ }, system, new RegExp("/"), 1)); |
|
3945 | 5462 |
}; |
3946 |
- known_params["G"] = function (format, arg) { |
|
3947 |
- return known_params["g"](format, arg).toUpperCase(); |
|
3948 |
- }; |
|
3949 |
- known_params["s"] = function (format, arg) { |
|
3950 |
- if (!test_arg(format, arg, 'string')) |
|
3951 |
- return 'o.O'; |
|
3952 |
- var tmp = format.precision !== null ? arg.substr(0, format.precision) : arg; |
|
3953 |
- tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); |
|
3954 |
- return tmp; |
|
3955 |
- }; |
|
3956 |
- known_params["o"] = function (format, arg) { |
|
3957 |
- if (!test_arg(format, arg, 'number')) |
|
3958 |
- return 'Ø'; |
|
3959 |
- var tmp = Math.floor(Math.round(Math.abs(arg))) * ((arg < 0) ? -1 : 1); |
|
3960 |
- return known_params["s"](format, tmp.toString(8)); |
|
5463 |
+ /** |
|
5464 |
+ * @desc [accessor] |
|
5465 |
+ * @author fenris |
|
5466 |
+ */ |
|
5467 |
+ class_location.prototype.is_absolute = function () { |
|
5468 |
+ return (this.anchor != null); |
|
3961 | 5469 |
}; |
3962 |
- known_params["x"] = function (format, arg) { |
|
3963 |
- if (!test_arg(format, arg, 'number')) |
|
3964 |
- return 'Ø'; |
|
3965 |
- var tmp = Math.floor(Math.round(Math.abs(arg))) * ((arg < 0) ? -1 : 1); |
|
3966 |
- return known_params["s"](format, tmp.toString(16)); |
|
5470 |
+ /** |
|
5471 |
+ * @author fenris |
|
5472 |
+ */ |
|
5473 |
+ class_location.prototype.normalize = function () { |
|
5474 |
+ return (new class_location(this.anchor, this.chain.normalize())); |
|
3967 | 5475 |
}; |
3968 |
- known_params["a"] = known_params["x"]; |
|
3969 |
- known_params["X"] = function (format, arg) { |
|
3970 |
- if (!test_arg(format, arg, 'number')) |
|
3971 |
- return 'Ø'; |
|
3972 |
- return known_params["x"](format, arg).toUpperCase(); |
|
5476 |
+ /** |
|
5477 |
+ * @author fenris |
|
5478 |
+ */ |
|
5479 |
+ class_location.prototype.extend = function (chain) { |
|
5480 |
+ return (new class_location(this.anchor, this.chain.extend(chain))); |
|
3973 | 5481 |
}; |
3974 |
- known_params["A"] = known_params["X"]; |
|
3975 |
- known_params["c"] = function (format, arg) { |
|
3976 |
- var tmp = ""; |
|
3977 |
- if (typeof arg === "number") { |
|
3978 |
- tmp = String.fromCharCode(arg); |
|
3979 |
- } |
|
3980 |
- else if ((typeof arg === "string") && (arg.length === 1)) { |
|
3981 |
- tmp = arg[0]; |
|
5482 |
+ /** |
|
5483 |
+ * @desc [accessor] |
|
5484 |
+ * @author fenris |
|
5485 |
+ */ |
|
5486 |
+ class_location.prototype.relocate = function (location) { |
|
5487 |
+ if (this.is_absolute()) { |
|
5488 |
+ return (new class_location(this.anchor, this.chain)); |
|
3982 | 5489 |
} |
3983 | 5490 |
else { |
3984 |
- console.warn(make_err(format, arg, "number|string") + " and if string it needs to have the length of 1!"); |
|
5491 |
+ return location.extend(this.chain); |
|
3985 | 5492 |
} |
3986 |
- return known_params["s"](format, tmp); |
|
3987 | 5493 |
}; |
3988 |
- known_params["n"] = function () { |
|
3989 |
- return ""; |
|
5494 |
+ /** |
|
5495 |
+ * @author fenris |
|
5496 |
+ */ |
|
5497 |
+ class_location.prototype.go_thither = function () { |
|
5498 |
+ // console.error(">>", this.toString()); |
|
5499 |
+ process.chdir(this.toString()); |
|
3990 | 5500 |
}; |
3991 |
- var decompose = function (chain, regexp) { |
|
3992 |
- var result = regexp.exec(chain); |
|
3993 |
- if (result == null) { |
|
3994 |
- return null; |
|
5501 |
+ /** |
|
5502 |
+ * @author fenris |
|
5503 |
+ */ |
|
5504 |
+ class_location.prototype.expedition = function (core) { |
|
5505 |
+ var that = this; |
|
5506 |
+ var current = location_read(process.cwd()); |
|
5507 |
+ function begin() { |
|
5508 |
+ // (new class_message("changing directory to '" + that.toString() + "'")).stderr(); |
|
5509 |
+ that.go_thither(); |
|
3995 | 5510 |
} |
3996 |
- else { |
|
3997 |
- var front = chain.substring(0, result.index); |
|
3998 |
- var back = chain.substring(result.index + result[0].length); |
|
3999 |
- return { "front": front, "match": result[0], "back": back }; |
|
5511 |
+ function end() { |
|
5512 |
+ // (new class_message("changing directory to '" + current.toString() + "'")).stderr(); |
|
5513 |
+ current.go_thither(); |
|
4000 | 5514 |
} |
5515 |
+ begin(); |
|
5516 |
+ core(end); |
|
4001 | 5517 |
}; |
4002 | 5518 |
/** |
4003 |
- * an implementation of c sprintf |
|
4004 |
- * @param {string} string format string |
|
4005 |
- * @param {array} args arguments which should be filled into |
|
4006 |
- * @returns {string} |
|
5519 |
+ * @author fenris |
|
4007 | 5520 |
*/ |
4008 |
- lib_string.sprintf = function (input, args, original) { |
|
4009 |
- if (args === void 0) { args = []; } |
|
4010 |
- if (original === void 0) { original = null; } |
|
4011 |
- if (original == null) |
|
4012 |
- original = input; |
|
4013 |
- var components = decompose(input, pattern); |
|
4014 |
- if (components == null) { |
|
4015 |
- if (args.length > 0) { |
|
4016 |
- console.warn("[sprintf] superfluous arguments while formatting '" + original + "': ", args); |
|
4017 |
- } |
|
4018 |
- return input; |
|
5521 |
+ class_location.prototype.as_string = function (system) { |
|
5522 |
+ if (system === void 0) { system = "linux"; } |
|
5523 |
+ return (((this.anchor != null) ? this.anchor : "") + this.chain.as_string(system)); |
|
5524 |
+ }; |
|
5525 |
+ /** |
|
5526 |
+ * @author fenris |
|
5527 |
+ */ |
|
5528 |
+ class_location.prototype.toString = function () { |
|
5529 |
+ return this.as_string(); |
|
5530 |
+ }; |
|
5531 |
+ /** |
|
5532 |
+ * @author fenris |
|
5533 |
+ */ |
|
5534 |
+ class_location.current = function () { |
|
5535 |
+ // return class_location.read(process.cwd()); |
|
5536 |
+ return location_read(process.cwd()); |
|
5537 |
+ }; |
|
5538 |
+ /** |
|
5539 |
+ * @author fenris |
|
5540 |
+ */ |
|
5541 |
+ class_location.tempfolder = function (system) { |
|
5542 |
+ if (system === void 0) { system = "linux"; } |
|
5543 |
+ return (object_fetch({ |
|
5544 |
+ "linux": new class_location("/", new lib_path.class_chain([new lib_path.class_step_regular("tmp")])), |
|
5545 |
+ "bsd": new class_location("/", new lib_path.class_chain([new lib_path.class_step_regular("tmp")])), |
|
5546 |
+ "win": new class_location(null, new lib_path.class_chain([new lib_path.class_step_regular("%TEMP%")])) |
|
5547 |
+ }, system, null, 2)); |
|
5548 |
+ }; |
|
5549 |
+ return class_location; |
|
5550 |
+ }()); |
|
5551 |
+ lib_path.class_location = class_location; |
|
5552 |
+ /** |
|
5553 |
+ * @author fenris |
|
5554 |
+ */ |
|
5555 |
+ function location_read(str, system) { |
|
5556 |
+ if (system === void 0) { system = "linux"; } |
|
5557 |
+ var regexp = class_location.anchorpattern(system); |
|
5558 |
+ var matching = regexp.exec(str); |
|
5559 |
+ if ((matching == null) || (matching.index > 0)) { |
|
5560 |
+ return (new class_location(null, lib_path.chain_read(str, system))); |
|
4019 | 5561 |
} |
4020 | 5562 |
else { |
4021 |
- var arg; |
|
4022 |
- var rest; |
|
4023 |
- if (args.length > 0) { |
|
4024 |
- arg = args[0]; |
|
4025 |
- rest = args.slice(1); |
|
5563 |
+ return (new class_location(matching[0], lib_path.chain_read(str.slice(matching[0].length), system))); |
|
4026 | 5564 |
} |
4027 |
- else { |
|
4028 |
- console.warn("[sprintf] out of arguments while formatting '" + original + "'"); |
|
4029 |
- arg = null; |
|
4030 |
- rest = []; |
|
4031 |
- return input; |
|
4032 | 5565 |
} |
4033 |
- var fmt = split_format(components["match"]); |
|
4034 |
- return (components["front"] |
|
4035 |
- + known_params[fmt.specifier](fmt, arg) |
|
4036 |
- + lib_string.sprintf(components["back"], rest, original)); |
|
5566 |
+ lib_path.location_read = location_read; |
|
5567 |
+})(lib_path || (lib_path = {})); |
|
5568 |
+var lib_path; |
|
5569 |
+(function (lib_path) { |
|
5570 |
+ /** |
|
5571 |
+ * @author fenris |
|
5572 |
+ */ |
|
5573 |
+ var class_filepointer = (function () { |
|
5574 |
+ /** |
|
5575 |
+ * @author fenris |
|
5576 |
+ */ |
|
5577 |
+ function class_filepointer(location, filename) { |
|
5578 |
+ this.location = location; |
|
5579 |
+ this.filename = filename; |
|
4037 | 5580 |
} |
5581 |
+ /** |
|
5582 |
+ * @author fenris |
|
5583 |
+ */ |
|
5584 |
+ class_filepointer.prototype.normalize = function () { |
|
5585 |
+ return (new class_filepointer(this.location.normalize(), this.filename)); |
|
4038 | 5586 |
}; |
4039 | 5587 |
/** |
4040 |
- * an implementation of c printf |
|
4041 |
- * @param {string} string format string |
|
4042 |
- * @param {array} args arguments which should be filled into |
|
4043 |
- * @returns {string} |
|
5588 |
+ * @author fenris |
|
4044 | 5589 |
*/ |
4045 |
- function printf(format, args) { |
|
4046 |
- console.log(lib_string.sprintf(format, args)); |
|
4047 |
- } |
|
4048 |
- lib_string.printf = printf; |
|
4049 |
-})(lib_string || (lib_string = {})); |
|
4050 |
-var sprintf = lib_string.sprintf; |
|
4051 |
-var printf = lib_string.printf; |
|
5590 |
+ class_filepointer.prototype.foo = function (filepointer) { |
|
5591 |
+ return (new class_filepointer(this.location.extend(filepointer.location.chain), filepointer.filename)); |
|
5592 |
+ }; |
|
4052 | 5593 |
/** |
4053 |
- * @author neuc |
|
5594 |
+ * @desc [accessor] |
|
5595 |
+ * @author fenris |
|
4054 | 5596 |
*/ |
4055 |
-var strftime; |
|
4056 |
-(function (strftime) { |
|
4057 |
- var currentDate = new Date(); |
|
4058 |
- var days = [ |
|
4059 |
- "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" |
|
4060 |
- ]; |
|
4061 |
- var months = [ |
|
4062 |
- "January", "February", "March", "April", "May", "June", "July", "August", "September", |
|
4063 |
- "October", "November", "December" |
|
4064 |
- ]; |
|
4065 |
- function set_days(day_names) { |
|
4066 |
- days = day_names; |
|
4067 |
- } |
|
4068 |
- strftime.set_days = set_days; |
|
4069 |
- function set_months(month_names) { |
|
4070 |
- months = month_names; |
|
4071 |
- } |
|
4072 |
- strftime.set_months = set_months; |
|
4073 |
- // source: https://stackoverflow.com/questions/8619879/javascript-calculate-the-day-of-the-year-1-366 |
|
4074 |
- function helper_dayOfYear(date) { |
|
4075 |
- var start = new Date(date.getFullYear(), 0, 0); |
|
4076 |
- var diff = date - start; |
|
4077 |
- var oneDay = 1000 * 60 * 60 * 24; |
|
4078 |
- return Math.floor(diff / oneDay); |
|
4079 |
- } |
|
4080 |
- // source: http://weeknumber.net/how-to/javascript |
|
4081 |
- function helper_weekOfYear(date_) { |
|
4082 |
- var date = new Date(date_.getTime()); |
|
4083 |
- date.setHours(0, 0, 0, 0); |
|
4084 |
- // Thursday in current week decides the year. |
|
4085 |
- date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7); |
|
4086 |
- // January 4 is always in week 1. |
|
4087 |
- var week1 = new Date(date.getFullYear(), 0, 4); |
|
4088 |
- // Adjust to Thursday in week 1 and count number of weeks from date to week1. |
|
4089 |
- return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 |
|
4090 |
- - 3 + (week1.getDay() + 6) % 7) / 7); |
|
4091 |
- } |
|
4092 |
- function helper_englishWeekOfYear(date) { |
|
4093 |
- var nr = helper_weekOfYear(date); |
|
4094 |
- if (date.getDay() === 0) { |
|
4095 |
- nr = nr - 1; |
|
5597 |
+ class_filepointer.prototype.relocate = function (location) { |
|
5598 |
+ return (new class_filepointer(this.location.relocate(location), this.filename)); |
|
5599 |
+ }; |
|
5600 |
+ /** |
|
5601 |
+ * @author fenris |
|
5602 |
+ */ |
|
5603 |
+ class_filepointer.prototype.as_string = function (system) { |
|
5604 |
+ if (system === void 0) { system = "linux"; } |
|
5605 |
+ return (this.location.as_string(system) /* + "/"*/ + ((this.filename == null) ? "" : this.filename)); |
|
5606 |
+ }; |
|
5607 |
+ /** |
|
5608 |
+ * @author fenris |
|
5609 |
+ */ |
|
5610 |
+ class_filepointer.prototype.toString = function () { |
|
5611 |
+ return this.as_string(); |
|
5612 |
+ }; |
|
5613 |
+ return class_filepointer; |
|
5614 |
+ }()); |
|
5615 |
+ lib_path.class_filepointer = class_filepointer; |
|
5616 |
+ /** |
|
5617 |
+ * @author fenris |
|
5618 |
+ */ |
|
5619 |
+ function filepointer_read(str, system) { |
|
5620 |
+ if (system === void 0) { system = "linux"; } |
|
5621 |
+ var splitter = lib_path.class_chain.splitter(system); |
|
5622 |
+ var parts = str.split(splitter); |
|
5623 |
+ var last = parts[parts.length - 1]; |
|
5624 |
+ if (last == "") { |
|
5625 |
+ return (new class_filepointer(lib_path.location_read(parts.join(splitter), system), null)); |
|
4096 | 5626 |
} |
4097 |
- return nr; |
|
5627 |
+ else { |
|
5628 |
+ return (new class_filepointer(lib_path.location_read(parts.slice(0, parts.length - 1).join(splitter), system), last)); |
|
4098 | 5629 |
} |
4099 |
- function set_currentDate(date) { |
|
4100 |
- currentDate = date; |
|
4101 | 5630 |
} |
4102 |
- strftime.set_currentDate = set_currentDate; |
|
4103 |
- function parse(format, date) { |
|
4104 |
- if (!date) { |
|
4105 |
- date = currentDate; |
|
5631 |
+ lib_path.filepointer_read = filepointer_read; |
|
5632 |
+})(lib_path || (lib_path = {})); |
|
5633 |
+///<reference path="../../call/build/logic-decl.d.ts"/> |
|
5634 |
+var lib_file; |
|
5635 |
+(function (lib_file) { |
|
5636 |
+ /** |
|
5637 |
+ * @author fenris |
|
5638 |
+ */ |
|
5639 |
+ class class_file_abstract { |
|
5640 |
+ /** |
|
5641 |
+ * @desc reads a json file |
|
5642 |
+ * @author fenris |
|
5643 |
+ */ |
|
5644 |
+ read_json(path) { |
|
5645 |
+ return ((resolve, reject) => { |
|
5646 |
+ lib_call.executor_chain({}, [ |
|
5647 |
+ state => (resolve_, reject_) => { |
|
5648 |
+ this.read(path)(content => { |
|
5649 |
+ state.content = content; |
|
5650 |
+ resolve_(state); |
|
5651 |
+ }, reject_); |
|
5652 |
+ }, |
|
5653 |
+ state => (resolve_, reject_) => { |
|
5654 |
+ let error; |
|
5655 |
+ try { |
|
5656 |
+ state.data = JSON.parse(state.content); |
|
5657 |
+ error = null; |
|
4106 | 5658 |
} |
4107 |
- var ret = format; |
|
4108 |
- var re = new RegExp("%[a-z]", "gi"); |
|
4109 |
- var match; |
|
4110 |
- while (match = re.exec(format)) { |
|
4111 |
- ret = ret.replace(match[0], parse_segment(match[0], date)); |
|
5659 |
+ catch (exception) { |
|
5660 |
+ error = new class_error("invalid json '" + path + "'", [exception]); |
|
4112 | 5661 |
} |
4113 |
- return ret; |
|
5662 |
+ if (error == null) { |
|
5663 |
+ resolve_(state); |
|
4114 | 5664 |
} |
4115 |
- strftime.parse = parse; |
|
4116 |
- function parse_segment(segment, date) { |
|
4117 |
- if (!date) { |
|
4118 |
- date = currentDate; |
|
5665 |
+ else { |
|
5666 |
+ reject_(error); |
|
4119 | 5667 |
} |
4120 |
- var hm_segments = { |
|
4121 |
- "%a": function () { return days[date.getDay()].slice(0, 3); }, |
|
4122 |
- "%A": function () { return days[date.getDay()]; }, |
|
4123 |
- "%b": function () { return days[date.getMonth()].slice(0, 3); }, |
|
4124 |
- "%B": function () { return days[date.getMonth()]; }, |
|
4125 |
- "%c": function () { return date.toLocaleString(); }, |
|
4126 |
- "%C": function () { return Math.floor((date.getFullYear()) / 100).toString(); }, |
|
4127 |
- "%d": function () { return sprintf("%02d", [date.getDate()]); }, |
|
4128 |
- "%D": function () { return parse("%m/%d/%y", date); }, |
|
4129 |
- "%e": function () { return sprintf("%2d", [date.getDate()]); }, |
|
4130 |
- "%F": function () { return parse("%Y-%m-%d", date); }, |
|
4131 |
- "%g": function () { return sprintf("%02d", [date.getFullYear() % 1000]); }, |
|
4132 |
- "%G": function () { return date.getFullYear().toString(); }, |
|
4133 |
- "%h": function () { return parse("%b", date); }, |
|
4134 |
- "%H": function () { return sprintf("%02d", [date.getHours()]); }, |
|
4135 |
- "%I": function () { |
|
4136 |
- return sprintf("%02d", [ |
|
4137 |
- (date.getHours() > 12 ? date.getHours() - 12 : date.getHours()) |
|
4138 |
- ]); |
|
4139 | 5668 |
}, |
4140 |
- "%j": function () { return sprintf("%03d", [helper_dayOfYear(date)]); }, |
|
4141 |
- "%m": function () { return sprintf("%02d", [date.getMonth() + 1]); }, |
|
4142 |
- "%M": function () { return sprintf("%02d", [date.getMinutes()]); }, |
|
4143 |
- "%n": function () { return "\n"; }, |
|
4144 |
- "%p": function () { return (date.getHours() > 12 ? "PM" : "AM"); }, |
|
4145 |
- "%r": function () { return parse("%I:%M:%S %p", date); }, |
|
4146 |
- "%R": function () { return parse("%H:%M", date); }, |
|
4147 |
- "%S": function () { return date.getSeconds().toString(); }, |
|
4148 |
- "%t": function () { return "\t"; }, |
|
4149 |
- "%T": function () { return parse("%H:%M:%S", date); }, |
|
4150 |
- "%u": function () { return sprintf("%02d", [(date.getDay() === 0 ? 7 : date.getDay())]); }, |
|
4151 |
- "%U": function () { return sprintf("%02d", [helper_englishWeekOfYear(date)]); }, |
|
4152 |
- "%V": function () { return sprintf("%02d", [helper_weekOfYear(date)]); }, |
|
4153 |
- "%w": function () { return sprintf("%02d", [date.getDay().toString()]); }, |
|
4154 |
- "%W": function () { return parse("%w", date); }, |
|
4155 |
- "%x": function () { return parse("%m/%d/%G", date); }, |
|
4156 |
- "%X": function () { return parse("%T", date); }, |
|
4157 |
- "%y": function () { return parse("%g", date); }, |
|
4158 |
- "%Y": function () { return parse("%G", date); }, |
|
4159 |
- "%z": function () { return date.getTimezoneOffset().toString(); }, |
|
4160 |
- "%Z": function () { return date.toUTCString().split(' ').pop(); }, |
|
4161 |
- "%%": function () { return "%"; } |
|
4162 |
- }; |
|
4163 |
- if (!(segment in hm_segments)) { |
|
4164 |
- throw "unknown format argument '" + segment + "'"; |
|
5669 |
+ ])(state => resolve(state.data), reject); |
|
5670 |
+ }); |
|
4165 | 5671 |
} |
4166 |
- return hm_segments[segment](); |
|
5672 |
+ /** |
|
5673 |
+ * @desc writes a json file |
|
5674 |
+ * @author fenris |
|
5675 |
+ */ |
|
5676 |
+ write_json(path, data) { |
|
5677 |
+ return this.write(path, JSON.stringify(data, undefined, "\t")); |
|
4167 | 5678 |
} |
4168 |
-})(strftime || (strftime = {})); |
|
4169 |
-function locale_date(date, ignore_error) { |
|
4170 |
- if (date === void 0) { date = new Date(); } |
|
4171 |
- if (ignore_error === void 0) { ignore_error = false; } |
|
4172 |
- if (!(date instanceof Date)) { |
|
4173 |
- if (!ignore_error) { |
|
4174 |
- throw new SyntaxError("date must be instance of Date"); |
|
4175 | 5679 |
} |
4176 |
- else { |
|
4177 |
- console.warn("'" + date + "' seems not to be instance of Date try to force convert."); |
|
4178 |
- var tmp = date; |
|
4179 |
- date = new Date(tmp); |
|
4180 |
- if ((date.toString() === "Invalid Date") || |
|
4181 |
- (!(date < new Date(0)) && !(date > new Date(0)))) { |
|
4182 |
- console.warn("conversion didn't work, returning default value"); |
|
4183 |
- return "Ø"; |
|
5680 |
+ lib_file.class_file_abstract = class_file_abstract; |
|
5681 |
+})(lib_file || (lib_file = {})); |
|
5682 |
+///<reference path="../../call/build/logic-decl.d.ts"/> |
|
5683 |
+var lib_file; |
|
5684 |
+(function (lib_file) { |
|
5685 |
+ /** |
|
5686 |
+ * @author fenris |
|
5687 |
+ */ |
|
5688 |
+ class class_file_node extends lib_file.class_file_abstract { |
|
5689 |
+ /** |
|
5690 |
+ * @author maspr |
|
5691 |
+ */ |
|
5692 |
+ determine_handler(path) { |
|
5693 |
+ if (/^https?:\/\//.test(path)) { |
|
5694 |
+ return "http"; |
|
4184 | 5695 |
} |
5696 |
+ else { |
|
5697 |
+ return "file"; |
|
4185 | 5698 |
} |
4186 | 5699 |
} |
4187 |
- var conf = global_config.get_value("date") || { |
|
4188 |
- "use_locale_date": true, |
|
4189 |
- "format_string": "%d.%m.%Y" |
|
4190 |
- }; |
|
4191 |
- if (conf.use_locale_date) { |
|
4192 |
- return date.toLocaleDateString(); |
|
5700 |
+ /** |
|
5701 |
+ * @override |
|
5702 |
+ * @author fenris,maspr |
|
5703 |
+ * @todo clear up if http(s)-handling belongs here or not |
|
5704 |
+ */ |
|
5705 |
+ read(path, skip_error = false) { |
|
5706 |
+ switch (this.determine_handler(path)) { |
|
5707 |
+ case "file": |
|
5708 |
+ { |
|
5709 |
+ let nm_fs = require("fs"); |
|
5710 |
+ return ((resolve, reject) => { |
|
5711 |
+ nm_fs.readFile(path, { |
|
5712 |
+ "encoding": "utf8", |
|
5713 |
+ "flag": "r", |
|
5714 |
+ }, (error, content) => { |
|
5715 |
+ if (error == null) { |
|
5716 |
+ resolve(content); |
|
4193 | 5717 |
} |
4194 | 5718 |
else { |
4195 |
- return strftime.parse(conf.format_string, date); |
|
4196 |
- } |
|
5719 |
+ reject(error); |
|
4197 | 5720 |
} |
4198 |
-; |
|
4199 |
-var make_logger = (function () { |
|
4200 |
- var _loggers = {}; |
|
4201 |
- var make_logger = function (prefix, current_loglevel) { |
|
4202 |
- var log = []; |
|
4203 |
- var level = [ |
|
4204 |
- "LOG", "INFO", "WARNING", "DEBUG" |
|
4205 |
- ]; |
|
4206 |
- var logger = function (obj, lvl) { |
|
4207 |
- var txt = obj.txt || obj; |
|
4208 |
- if (lvl == void 0) |
|
4209 |
- lvl = 0; |
|
4210 |
- var date = new Date(); |
|
4211 |
- log.push({ |
|
4212 |
- "message": sprintf("%s [%s:%s] %s", [date.toString(), level[lvl], prefix, txt]), |
|
4213 |
- "timeStamp": +(date) |
|
4214 | 5721 |
}); |
4215 |
- if (lvl <= current_loglevel) { |
|
4216 |
- var msg = ["[" + prefix + "]", txt]; |
|
4217 |
- if (obj.arg) |
|
4218 |
- msg = ["[" + prefix + "]"].concat(Array.prototype.slice.call(obj.arg)); |
|
4219 |
- if (lvl === 0) |
|
4220 |
- console["_log"].apply(console, msg); |
|
4221 |
- else if (lvl === 1) |
|
4222 |
- console["_info"].apply(console, msg); |
|
4223 |
- else if (lvl === 2) |
|
4224 |
- console["_warn"].apply(console, msg); |
|
4225 |
- else if (lvl >= 3) |
|
4226 |
- console["_log"].apply(console, msg); |
|
5722 |
+ }); |
|
4227 | 5723 |
} |
5724 |
+ break; |
|
5725 |
+ case "http": |
|
5726 |
+ { |
|
5727 |
+ return (resolve, reject) => { |
|
5728 |
+ let nm_http = require("http"); |
|
5729 |
+ let nm_https = require("https"); |
|
5730 |
+ let nm_url = require("url"); |
|
5731 |
+ let parsed_url = nm_url.parse(path, false, true); |
|
5732 |
+ let client = (parsed_url.protocol == "https:") ? nm_https : nm_http; |
|
5733 |
+ let default_port = ((parsed_url.protocol == "https:") ? 443 : 80); |
|
5734 |
+ let options = { |
|
5735 |
+ hostname: parsed_url.hostname, |
|
5736 |
+ port: parsed_url.port || default_port, |
|
5737 |
+ path: parsed_url.path, |
|
5738 |
+ method: "GET" |
|
4228 | 5739 |
}; |
4229 |
- _loggers[prefix] = { |
|
4230 |
- "logger": logger, |
|
4231 |
- "log": log |
|
4232 |
- }; |
|
4233 |
- return logger; |
|
5740 |
+ let req = client.request(options, (res) => { |
|
5741 |
+ let data = ""; // @todo |
|
5742 |
+ res.on("data", (chunk) => { |
|
5743 |
+ data += chunk; |
|
5744 |
+ }); |
|
5745 |
+ res.on("end", () => { |
|
5746 |
+ resolve(data); |
|
5747 |
+ }); |
|
5748 |
+ }); |
|
5749 |
+ req.end(); |
|
5750 |
+ req.on("error", (error) => { |
|
5751 |
+ reject(error); |
|
5752 |
+ }); |
|
4234 | 5753 |
}; |
4235 |
- make_logger["loggers"] = _loggers; |
|
4236 |
- make_logger["complete_log"] = function () { |
|
4237 |
- var logs = Object.keys(_loggers) |
|
4238 |
- .reduce(function (p, c) { |
|
4239 |
- return [].concat(p, _loggers[c].log); |
|
4240 |
- }, []); |
|
4241 |
- logs.sort(function (x, y) { |
|
4242 |
- return ((x.timeStamp > y.timeStamp) ? -1 : +1); |
|
5754 |
+ } |
|
5755 |
+ break; |
|
5756 |
+ default: { |
|
5757 |
+ return ((resolve, reject) => reject(new Error("unhandled protocol"))); |
|
5758 |
+ } |
|
5759 |
+ } |
|
5760 |
+ } |
|
5761 |
+ /** |
|
5762 |
+ * @override |
|
5763 |
+ * @author fenris |
|
5764 |
+ */ |
|
5765 |
+ write(path, content) { |
|
5766 |
+ let nm_fs = require("fs"); |
|
5767 |
+ return ((resolve, reject) => { |
|
5768 |
+ nm_fs.writeFile(path, content, { |
|
5769 |
+ "encoding": "utf8", |
|
5770 |
+ "flag": "w", |
|
5771 |
+ }, (error) => { |
|
5772 |
+ if (error == null) { |
|
5773 |
+ resolve(undefined); |
|
5774 |
+ } |
|
5775 |
+ else { |
|
5776 |
+ reject(error); |
|
5777 |
+ } |
|
4243 | 5778 |
}); |
4244 |
- return logs.map(function (x, i, a) { |
|
4245 |
- return x.message; |
|
4246 | 5779 |
}); |
4247 |
- }; |
|
4248 |
- if (true) { |
|
4249 |
- var _log_all = function (log, lvl, next) { |
|
4250 |
- if (next === void 0) { next = function () { }; } |
|
4251 |
- return function () { |
|
4252 |
- var msg = []; |
|
4253 |
- for (var i = 0; i < arguments.length; i++) { |
|
4254 |
- if (typeof arguments[i] === "string") { |
|
4255 |
- msg.push(arguments[i]); |
|
5780 |
+ } |
|
5781 |
+ } |
|
5782 |
+ lib_file.class_file_node = class_file_node; |
|
5783 |
+})(lib_file || (lib_file = {})); |
|
5784 |
+///<reference path="../../call/build/logic-decl.d.ts"/> |
|
5785 |
+var lib_file; |
|
5786 |
+(function (lib_file) { |
|
5787 |
+ /** |
|
5788 |
+ * @author fenris |
|
5789 |
+ * @todo move to a dedicated lib (e.g. "http", "transport", etc.) |
|
5790 |
+ */ |
|
5791 |
+ function ajax({ "target": target /*: string*/, "data": data /*: {[key : string] : string}*/ = null, "method": method /* : string*/ = "GET" }) { |
|
5792 |
+ method = method.toLowerCase(); |
|
5793 |
+ return ((resolve, reject) => { |
|
5794 |
+ let datastring = ((data == null) ? null : Object.keys(data).map(key => `${key}=${data[key]}`).join("&")); |
|
5795 |
+ let suffix = ((method == "get") ? ("?" + datastring) : ""); |
|
5796 |
+ let sending = ((method == "get") ? null : datastring); |
|
5797 |
+ let request = new XMLHttpRequest(); |
|
5798 |
+ request.open(method.toUpperCase(), target + suffix, true); |
|
5799 |
+ request.onreadystatechange = function () { |
|
5800 |
+ if (request.readyState === 4) { |
|
5801 |
+ if (request.status === 200) { |
|
5802 |
+ resolve(request.responseText); |
|
4256 | 5803 |
} |
4257 | 5804 |
else { |
4258 |
- msg.push(JSON.stringify(arguments[i])); |
|
5805 |
+ reject(new Error("XMLHttpRequest failed")); |
|
4259 | 5806 |
} |
4260 | 5807 |
} |
4261 |
- var obj = { |
|
4262 |
- txt: msg.join("\t"), |
|
4263 |
- arg: arguments |
|
4264 |
- }; |
|
4265 |
- log(obj, lvl); |
|
4266 |
- next(); |
|
4267 | 5808 |
}; |
4268 |
- }; |
|
4269 |
- { |
|
4270 |
- var __warn = make_logger("deprecated console.warn", 99); |
|
4271 |
- var __error = make_logger("deprecated console.error", 99); |
|
4272 |
- var __log = make_logger("deprecated console.log", 99); |
|
4273 |
- var __info = make_logger("deprecated console.info", 99); |
|
4274 |
- // bad ass |
|
4275 |
- console["_log"] = console.log; |
|
4276 |
- console["_error"] = console.error; |
|
4277 |
- console["_warn"] = console.warn; |
|
4278 |
- console["_info"] = console.info; |
|
4279 |
- /* |
|
4280 |
- console["log"] = _log_all(__log, 0); |
|
4281 |
- console["error"] = _log_all(__error, 2); |
|
4282 |
- console["warn"] = _log_all(__warn, 2); |
|
4283 |
- console["info"] = _log_all(__info, 0); |
|
5809 |
+ request.send(sending); |
|
5810 |
+ }); |
|
5811 |
+ } |
|
5812 |
+ /** |
|
5813 |
+ * @author fenris |
|
5814 |
+ */ |
|
5815 |
+ class class_file_web extends lib_file.class_file_abstract { |
|
5816 |
+ /** |
|
5817 |
+ * @override |
|
5818 |
+ * @author fenris |
|
4284 | 5819 |
*/ |
5820 |
+ read(path, skip_error = false) { |
|
5821 |
+ return ((resolve, reject) => { |
|
5822 |
+ ajax({ |
|
5823 |
+ "target": path, |
|
5824 |
+ "method": "GET", |
|
5825 |
+ })(resolve, reason => (skip_error ? resolve(null) : reject(reason))); |
|
5826 |
+ }); |
|
4285 | 5827 |
} |
4286 |
- /* |
|
4287 |
- { |
|
4288 |
- make_logger["send_log"] = function(){ |
|
4289 |
- eml_log( |
|
4290 |
- function () { |
|
4291 |
- alert("fehlerbericht wurde gesendet!"); |
|
5828 |
+ /** |
|
5829 |
+ * @override |
|
5830 |
+ * @author fenris |
|
5831 |
+ */ |
|
5832 |
+ write(path, content) { |
|
5833 |
+ return ((resolve, reject) => { |
|
5834 |
+ reject(new Error("not implemented / not possible")); |
|
5835 |
+ }); |
|
4292 | 5836 |
} |
4293 |
- ); |
|
4294 |
- }; |
|
4295 |
- var error_log = make_logger("global.error", 99); |
|
4296 |
- window.onerror = _log_all( |
|
4297 |
- error_log, |
|
4298 |
- 1, |
|
4299 |
- function(){ |
|
4300 |
- if (global_config == undefined) { |
|
4301 |
- return false; |
|
4302 | 5837 |
} |
4303 |
- if (global_config.report_error) { |
|
4304 |
- make_logger["send_log"](); |
|
5838 |
+ lib_file.class_file_web = class_file_web; |
|
5839 |
+})(lib_file || (lib_file = {})); |
|
5840 |
+///<reference path="../../base/build/logic-decl.d.ts"/> |
|
5841 |
+///<reference path="../../call/build/logic-decl.d.ts"/> |
|
5842 |
+var lib_file; |
|
5843 |
+(function (lib_file) { |
|
5844 |
+ /** |
|
5845 |
+ * @desc selects the implementation which fits for the detected environment |
|
5846 |
+ * @author fenris |
|
5847 |
+ */ |
|
5848 |
+ function auto() { |
|
5849 |
+ let environment = lib_base.environment(); |
|
5850 |
+ switch (environment) { |
|
5851 |
+ case "node": { |
|
5852 |
+ return (new lib_file.class_file_node()); |
|
5853 |
+ break; |
|
4305 | 5854 |
} |
5855 |
+ case "web": { |
|
5856 |
+ return (new lib_file.class_file_web()); |
|
5857 |
+ break; |
|
5858 |
+ } |
|
5859 |
+ default: { |
|
5860 |
+ throw (new Error(`no implementation for environment '${environment}'`)); |
|
5861 |
+ break; |
|
4306 | 5862 |
} |
4307 |
- ); |
|
4308 | 5863 |
} |
5864 |
+ } |
|
5865 |
+ lib_file.auto = auto; |
|
5866 |
+ /** |
|
5867 |
+ * @author fenris |
|
5868 |
+ */ |
|
5869 |
+ class class_file extends lib_file.class_file_abstract { |
|
5870 |
+ /** |
|
5871 |
+ * @author fenris |
|
4309 | 5872 |
*/ |
5873 |
+ constructor() { |
|
5874 |
+ super(); |
|
5875 |
+ this.core = auto(); |
|
4310 | 5876 |
} |
4311 |
- return make_logger; |
|
4312 |
-})(); |
|
4313 |
-var __extends = (this && this.__extends) || (function () { |
|
4314 |
- var extendStatics = Object.setPrototypeOf || |
|
4315 |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
4316 |
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; |
|
4317 |
- return function (d, b) { |
|
4318 |
- extendStatics(d, b); |
|
4319 |
- function __() { this.constructor = d; } |
|
4320 |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
4321 |
- }; |
|
4322 |
-})(); |
|
4323 |
-///<reference path="../../base/build/logic-decl.d.ts"/> |
|
4324 |
-///<reference path="../../string/build/logic-decl.d.ts"/> |
|
4325 | 5877 |
/** |
5878 |
+ * @override |
|
4326 | 5879 |
* @author fenris |
4327 | 5880 |
*/ |
4328 |
-var lib_xml; |
|
4329 |
-(function (lib_xml) { |
|
5881 |
+ read(path, skip_error = false) { |
|
5882 |
+ return this.core.read(path, skip_error); |
|
5883 |
+ } |
|
4330 | 5884 |
/** |
5885 |
+ * @override |
|
4331 | 5886 |
* @author fenris |
4332 | 5887 |
*/ |
4333 |
- var class_node = (function () { |
|
4334 |
- function class_node() { |
|
5888 |
+ write(path, content) { |
|
5889 |
+ return this.core.write(path, content); |
|
4335 | 5890 |
} |
4336 |
- return class_node; |
|
4337 |
- }()); |
|
4338 |
- lib_xml.class_node = class_node; |
|
5891 |
+ } |
|
5892 |
+ lib_file.class_file = class_file; |
|
4339 | 5893 |
/** |
4340 | 5894 |
* @author fenris |
4341 | 5895 |
*/ |
4342 |
- var class_node_text = (function (_super) { |
|
4343 |
- __extends(class_node_text, _super); |
|
5896 |
+ var instance = auto(); |
|
4344 | 5897 |
/** |
4345 | 5898 |
* @author fenris |
4346 | 5899 |
*/ |
4347 |
- function class_node_text(content) { |
|
4348 |
- var _this = _super.call(this) || this; |
|
4349 |
- _this.content = content; |
|
4350 |
- return _this; |
|
5900 |
+ function read(path, skip_error = false) { |
|
5901 |
+ return instance.read(path, skip_error); |
|
4351 | 5902 |
} |
5903 |
+ lib_file.read = read; |
|
4352 | 5904 |
/** |
4353 | 5905 |
* @author fenris |
4354 | 5906 |
*/ |
4355 |
- class_node_text.prototype.compile = function (depth) { |
|
4356 |
- if (depth === void 0) { depth = 0; } |
|
4357 |
- return (lib_string.repeat("\t", depth) + this.content + "\n"); |
|
4358 |
- }; |
|
4359 |
- return class_node_text; |
|
4360 |
- }(class_node)); |
|
4361 |
- lib_xml.class_node_text = class_node_text; |
|
5907 |
+ function write(path, content) { |
|
5908 |
+ return instance.write(path, content); |
|
5909 |
+ } |
|
5910 |
+ lib_file.write = write; |
|
4362 | 5911 |
/** |
4363 | 5912 |
* @author fenris |
4364 | 5913 |
*/ |
4365 |
- var class_node_comment = (function (_super) { |
|
4366 |
- __extends(class_node_comment, _super); |
|
5914 |
+ function read_json(path) { |
|
5915 |
+ return instance.read_json(path); |
|
5916 |
+ } |
|
5917 |
+ lib_file.read_json = read_json; |
|
4367 | 5918 |
/** |
4368 | 5919 |
* @author fenris |
4369 | 5920 |
*/ |
4370 |
- function class_node_comment(content) { |
|
4371 |
- var _this = _super.call(this) || this; |
|
4372 |
- _this.content = content; |
|
4373 |
- return _this; |
|
5921 |
+ function write_json(path, data) { |
|
5922 |
+ return instance.write_json(path, data); |
|
4374 | 5923 |
} |
5924 |
+ lib_file.write_json = write_json; |
|
5925 |
+})(lib_file || (lib_file = {})); |
|
5926 |
+var lib_dot; |
|
5927 |
+(function (lib_dot) { |
|
4375 | 5928 |
/** |
4376 | 5929 |
* @author fenris |
4377 | 5930 |
*/ |
4378 |
- class_node_comment.prototype.compile = function (depth) { |
|
4379 |
- if (depth === void 0) { depth = 0; } |
|
4380 |
- return (lib_string.repeat("\t", depth) + "<!-- " + this.content + " -->" + "\n"); |
|
4381 |
- }; |
|
4382 |
- return class_node_comment; |
|
4383 |
- }(class_node)); |
|
4384 |
- lib_xml.class_node_comment = class_node_comment; |
|
5931 |
+ function make_line(head, attributes) { |
|
5932 |
+ let list = ((object => { |
|
5933 |
+ let list = []; |
|
5934 |
+ Object.keys(object).forEach(key => (list.push({ "key": key, "value": object[key] }))); |
|
5935 |
+ return list; |
|
5936 |
+ })(attributes)); |
|
5937 |
+ let attributes_ = list |
|
5938 |
+ .filter(entry => (entry.value != null)) |
|
5939 |
+ .map(entry => `${entry.key}="${entry.value}"`) |
|
5940 |
+ .join(", "); |
|
5941 |
+ return (`${head} [${attributes_}];`); |
|
5942 |
+ } |
|
4385 | 5943 |
/** |
4386 | 5944 |
* @author fenris |
4387 | 5945 |
*/ |
4388 |
- var class_node_complex = (function (_super) { |
|
4389 |
- __extends(class_node_complex, _super); |
|
5946 |
+ function format_line(line) { |
|
5947 |
+ return `\t${line}\n`; |
|
5948 |
+ } |
|
4390 | 5949 |
/** |
4391 | 5950 |
* @author fenris |
4392 | 5951 |
*/ |
4393 |
- function class_node_complex(name, attributes, children) { |
|
4394 |
- if (attributes === void 0) { attributes = {}; } |
|
4395 |
- if (children === void 0) { children = []; } |
|
4396 |
- var _this = _super.call(this) || this; |
|
4397 |
- _this.name = name; |
|
4398 |
- _this.attributes = attributes; |
|
4399 |
- _this.children = children; |
|
4400 |
- return _this; |
|
5952 |
+ function format_lines(lines) { |
|
5953 |
+ return lines.map(format_line).join(""); |
|
4401 | 5954 |
} |
4402 | 5955 |
/** |
4403 | 5956 |
* @author fenris |
4404 | 5957 |
*/ |
4405 |
- class_node_complex.prototype.compile = function (depth) { |
|
4406 |
- var _this = this; |
|
4407 |
- if (depth === void 0) { depth = 0; } |
|
4408 |
- var output = ""; |
|
4409 |
- var attributes = Object.keys(this.attributes).map(function (key) { return (" " + key + "=" + ("\"" + _this.attributes[key] + "\"")); }).join(""); |
|
4410 |
- output += (lib_string.repeat("\t", depth) + "<" + this.name + attributes + ">" + "\n"); |
|
4411 |
- this.children.forEach(function (child) { return (output += child.compile(depth + 1)); }); |
|
4412 |
- output += (lib_string.repeat("\t", depth) + "</" + this.name + ">" + "\n"); |
|
5958 |
+ function generate_graph(graphdefinition) { |
|
5959 |
+ let attributes = {}; |
|
5960 |
+ if (graphdefinition.fontname != undefined) { |
|
5961 |
+ attributes["fontname"] = graphdefinition.fontname; |
|
5962 |
+ } |
|
5963 |
+ if (graphdefinition.dimensions != undefined) { |
|
5964 |
+ attributes["dimen"] = graphdefinition.dimensions.toFixed(0); |
|
5965 |
+ } |
|
5966 |
+ if (graphdefinition.bgcolor != undefined) { |
|
5967 |
+ attributes["bgcolor"] = graphdefinition.bgcolor; |
|
5968 |
+ } |
|
5969 |
+ return format_lines([make_line("graph", attributes)] |
|
5970 |
+ .concat([])); |
|
5971 |
+ } |
|
5972 |
+ /** |
|
5973 |
+ * @author fenris |
|
5974 |
+ */ |
|
5975 |
+ function generate_nodes(nodedefinition) { |
|
5976 |
+ return format_lines([make_line("node", nodedefinition.head)] |
|
5977 |
+ .concat(nodedefinition.list.map(node => make_line(node.id, node.attributes)))); |
|
5978 |
+ } |
|
5979 |
+ /** |
|
5980 |
+ * @author fenris |
|
5981 |
+ */ |
|
5982 |
+ function generate_edges(edgedefinition, directed) { |
|
5983 |
+ let connector = (directed ? "->" : "--"); |
|
5984 |
+ return format_lines([make_line("edge", edgedefinition.head)] |
|
5985 |
+ .concat(edgedefinition.list.map(edge => make_line(`${edge.id_from} ${connector} ${edge.id_to}`, edge.attributes)))); |
|
5986 |
+ } |
|
5987 |
+ /** |
|
5988 |
+ * @author fenris |
|
5989 |
+ */ |
|
5990 |
+ function generate({ "name": name = null, "directed": directed = true, "common": graphdefinition = {}, "nodes": nodedefinition, "edges": edgedefinition } = {}) { |
|
5991 |
+ let output = ""; |
|
5992 |
+ output += ((directed ? "digraph" : "graph") + ((name == null) ? "" : (" " + name)) + "\n"); |
|
5993 |
+ output += `{\n`; |
|
5994 |
+ output += generate_graph(graphdefinition); |
|
5995 |
+ output += `\t\n`; |
|
5996 |
+ output += generate_nodes(nodedefinition); |
|
5997 |
+ output += `\t\n`; |
|
5998 |
+ output += generate_edges(edgedefinition, directed); |
|
5999 |
+ output += `}\n`; |
|
4413 | 6000 |
return output; |
4414 |
- }; |
|
4415 |
- return class_node_complex; |
|
4416 |
- }(class_node)); |
|
4417 |
- lib_xml.class_node_complex = class_node_complex; |
|
4418 |
-})(lib_xml || (lib_xml = {})); |
|
4419 |
-var __extends = (this && this.__extends) || function (d, b) { |
|
4420 |
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; |
|
6001 |
+ } |
|
6002 |
+ lib_dot.generate = generate; |
|
6003 |
+})(lib_dot || (lib_dot = {})); |
|
6004 |
+var __extends = (this && this.__extends) || (function () { |
|
6005 |
+ var extendStatics = Object.setPrototypeOf || |
|
6006 |
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
6007 |
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; |
|
6008 |
+ return function (d, b) { |
|
6009 |
+ extendStatics(d, b); |
|
4421 | 6010 |
function __() { this.constructor = d; } |
4422 | 6011 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
4423 | 6012 |
}; |
4424 |
-var lib_path; |
|
4425 |
-(function (lib_path) { |
|
6013 |
+})(); |
|
6014 |
+var lib_structures; |
|
6015 |
+(function (lib_structures) { |
|
4426 | 6016 |
/** |
4427 | 6017 |
* @author fenris |
4428 | 6018 |
*/ |
4429 |
- var class_step = (function () { |
|
4430 |
- function class_step() { |
|
4431 |
- } |
|
4432 |
- return class_step; |
|
4433 |
- }()); |
|
4434 |
- lib_path.class_step = class_step; |
|
6019 |
+ var class_pair = (function () { |
|
4435 | 6020 |
/** |
4436 | 6021 |
* @author fenris |
4437 | 6022 |
*/ |
4438 |
- var class_step_stay = (function (_super) { |
|
4439 |
- __extends(class_step_stay, _super); |
|
4440 |
- function class_step_stay() { |
|
4441 |
- return _super !== null && _super.apply(this, arguments) || this; |
|
6023 |
+ function class_pair(first, second) { |
|
6024 |
+ this.first = first; |
|
6025 |
+ this.second = second; |
|
4442 | 6026 |
} |
4443 | 6027 |
/** |
6028 |
+ * @desc [accessor] [getter] |
|
4444 | 6029 |
* @author fenris |
4445 | 6030 |
*/ |
4446 |
- class_step_stay.prototype.invert = function () { |
|
4447 |
- return (new class_step_stay()); |
|
6031 |
+ class_pair.prototype.first_get = function () { |
|
6032 |
+ return this.first; |
|
4448 | 6033 |
}; |
4449 | 6034 |
/** |
6035 |
+ * @desc [accessor] [getter] |
|
4450 | 6036 |
* @author fenris |
4451 | 6037 |
*/ |
4452 |
- class_step_stay.prototype.toString = function () { |
|
4453 |
- return "."; |
|
6038 |
+ class_pair.prototype.second_get = function () { |
|
6039 |
+ return this.second; |
|
4454 | 6040 |
}; |
4455 |
- return class_step_stay; |
|
4456 |
- }(class_step)); |
|
4457 |
- lib_path.class_step_stay = class_step_stay; |
|
4458 | 6041 |
/** |
6042 |
+ * @desc [mutator] [setter] |
|
4459 | 6043 |
* @author fenris |
4460 | 6044 |
*/ |
4461 |
- var class_step_back = (function (_super) { |
|
4462 |
- __extends(class_step_back, _super); |
|
4463 |
- function class_step_back() { |
|
4464 |
- return _super !== null && _super.apply(this, arguments) || this; |
|
4465 |
- } |
|
6045 |
+ class_pair.prototype.first_set = function (first) { |
|
6046 |
+ this.first = first; |
|
6047 |
+ }; |
|
4466 | 6048 |
/** |
6049 |
+ * @desc [mutator] [setter] |
|
4467 | 6050 |
* @author fenris |
4468 | 6051 |
*/ |
4469 |
- class_step_back.prototype.invert = function () { |
|
4470 |
- throw (new Error("impossible")); |
|
6052 |
+ class_pair.prototype.second_set = function (second) { |
|
6053 |
+ this.second = second; |
|
4471 | 6054 |
}; |
4472 | 6055 |
/** |
6056 |
+ * @desc [accessor] |
|
4473 | 6057 |
* @author fenris |
4474 | 6058 |
*/ |
4475 |
- class_step_back.prototype.toString = function () { |
|
4476 |
- return ".."; |
|
6059 |
+ class_pair.prototype.swap = function () { |
|
6060 |
+ return (new class_pair(this.second, this.first)); |
|
4477 | 6061 |
}; |
4478 |
- return class_step_back; |
|
4479 |
- }(class_step)); |
|
4480 |
- lib_path.class_step_back = class_step_back; |
|
4481 | 6062 |
/** |
6063 |
+ * @desc [accessor] |
|
4482 | 6064 |
* @author fenris |
4483 | 6065 |
*/ |
4484 |
- var class_step_regular = (function (_super) { |
|
4485 |
- __extends(class_step_regular, _super); |
|
6066 |
+ class_pair.prototype.transform = function (transform_first, transform_second) { |
|
6067 |
+ return (new class_pair(transform_first(this.first), transform_second(this.second))); |
|
6068 |
+ }; |
|
4486 | 6069 |
/** |
6070 |
+ * @desc [accessor] [implementation] |
|
4487 | 6071 |
* @author fenris |
4488 | 6072 |
*/ |
4489 |
- function class_step_regular(name) { |
|
4490 |
- var _this = _super.call(this) || this; |
|
4491 |
- _this.name = name; |
|
4492 |
- return _this; |
|
4493 |
- } |
|
6073 |
+ class_pair.prototype._clone = function () { |
|
6074 |
+ return (new class_pair(instance_clone(this.first), instance_clone(this.second))); |
|
6075 |
+ }; |
|
4494 | 6076 |
/** |
6077 |
+ * @desc [accessor] [implementation] |
|
4495 | 6078 |
* @author fenris |
4496 | 6079 |
*/ |
4497 |
- class_step_regular.prototype.invert = function () { |
|
4498 |
- return (new class_step_back()); |
|
6080 |
+ class_pair.prototype._hash = function () { |
|
6081 |
+ return ("pair_" + instance_hash(this.first) + "_" + instance_hash(this.second) + ""); |
|
4499 | 6082 |
}; |
4500 | 6083 |
/** |
6084 |
+ * @desc [accessor] [implementation] |
|
4501 | 6085 |
* @author fenris |
4502 | 6086 |
*/ |
4503 |
- class_step_regular.prototype.toString = function () { |
|
4504 |
- return this.name; |
|
6087 |
+ class_pair.prototype._collate = function (pair) { |
|
6088 |
+ return (instance_collate(this.first, pair.first) |
|
6089 |
+ && |
|
6090 |
+ instance_collate(this.second, pair.second)); |
|
4505 | 6091 |
}; |
4506 |
- return class_step_regular; |
|
4507 |
- }(class_step)); |
|
4508 |
- lib_path.class_step_regular = class_step_regular; |
|
4509 | 6092 |
/** |
6093 |
+ * @desc [accessor] [implementation] |
|
4510 | 6094 |
* @author fenris |
4511 | 6095 |
*/ |
4512 |
- function step_read(s) { |
|
4513 |
- switch (s) { |
|
4514 |
- case ".": { |
|
4515 |
- return (new class_step_stay()); |
|
4516 |
- } |
|
4517 |
- case "..": { |
|
4518 |
- return (new class_step_back()); |
|
4519 |
- } |
|
4520 |
- default: { |
|
4521 |
- return (new class_step_regular(s)); |
|
4522 |
- } |
|
4523 |
- } |
|
4524 |
- } |
|
4525 |
- lib_path.step_read = step_read; |
|
4526 |
-})(lib_path || (lib_path = {})); |
|
4527 |
-///<reference path="../../../plankton/object/build/logic-decl.d.ts"/> |
|
4528 |
-var lib_path; |
|
4529 |
-(function (lib_path) { |
|
6096 |
+ class_pair.prototype._show = function () { |
|
6097 |
+ return ("(" + instance_show(this.first) + "," + instance_show(this.second) + ")"); |
|
6098 |
+ }; |
|
6099 |
+ return class_pair; |
|
6100 |
+ }()); |
|
6101 |
+ lib_structures.class_pair = class_pair; |
|
6102 |
+})(lib_structures || (lib_structures = {})); |
|
6103 |
+var lib_structures; |
|
6104 |
+(function (lib_structures) { |
|
4530 | 6105 |
/** |
4531 | 6106 |
* @author fenris |
4532 | 6107 |
*/ |
4533 |
- var class_chain = (function () { |
|
6108 |
+ var class_set = (function () { |
|
4534 | 6109 |
/** |
4535 | 6110 |
* @author fenris |
4536 | 6111 |
*/ |
4537 |
- function class_chain(steps) { |
|
4538 |
- if (steps === void 0) { steps = []; } |
|
4539 |
- this.steps = steps; |
|
6112 |
+ function class_set(elements_, equality /*<type_element>*/) { |
|
6113 |
+ if (elements_ === void 0) { elements_ = []; } |
|
6114 |
+ if (equality === void 0) { equality = instance_collate; } /*<type_element>*/ |
|
6115 |
+ var _this = this; |
|
6116 |
+ this.elements = []; |
|
6117 |
+ this.equality = equality; |
|
6118 |
+ elements_.forEach(function (element) { return _this.add(element); }); |
|
4540 | 6119 |
} |
4541 | 6120 |
/** |
6121 |
+ * @desc [accessor] |
|
4542 | 6122 |
* @author fenris |
4543 | 6123 |
*/ |
4544 |
- class_chain.splitter = function (system) { |
|
4545 |
- if (system === void 0) { system = "linux"; } |
|
4546 |
- return (object_fetch({ |
|
4547 |
- "linux": "/", |
|
4548 |
- "bsd": "/", |
|
4549 |
- "win": "\\" |
|
4550 |
- }, system, "/", 2)); |
|
6124 |
+ class_set.prototype.size = function () { |
|
6125 |
+ return this.elements.length; |
|
4551 | 6126 |
}; |
4552 | 6127 |
/** |
4553 |
- * @desc removes superfluent steps from the chain, e.g. infix ".." |
|
6128 |
+ * @desc [accessor] |
|
4554 | 6129 |
* @author fenris |
4555 | 6130 |
*/ |
4556 |
- class_chain.prototype.normalize = function () { |
|
4557 |
- var steps = this.steps; |
|
4558 |
- // filter "stay" |
|
4559 |
- { |
|
4560 |
- steps = steps.filter(function (step) { return (!(step instanceof lib_path.class_step_stay)); }); |
|
4561 |
- } |
|
4562 |
- // filter "regular-back" |
|
4563 |
- { |
|
4564 |
- var _loop_1 = function () { |
|
4565 |
- if (steps.length < 1) { |
|
4566 |
- return "break"; |
|
4567 |
- } |
|
4568 |
- else { |
|
4569 |
- var last_1 = steps[0]; |
|
4570 |
- var found = steps.slice(1).some(function (step, index) { |
|
4571 |
- if (step instanceof lib_path.class_step_back) { |
|
4572 |
- if (last_1 instanceof lib_path.class_step_regular) { |
|
4573 |
- steps.splice(index, 2); |
|
4574 |
- return true; |
|
4575 |
- } |
|
4576 |
- } |
|
4577 |
- last_1 = step; |
|
4578 |
- return false; |
|
4579 |
- }); |
|
4580 |
- if (!found) { |
|
4581 |
- return "break"; |
|
4582 |
- } |
|
6131 |
+ class_set.prototype.has = function (element) { |
|
6132 |
+ var _this = this; |
|
6133 |
+ return this.elements.some(function (element_) { return _this.equality(element, element_); }); |
|
6134 |
+ }; |
|
6135 |
+ /** |
|
6136 |
+ * @desc [mutator] |
|
6137 |
+ * @author fenris |
|
6138 |
+ */ |
|
6139 |
+ class_set.prototype.add = function (element) { |
|
6140 |
+ if (!this.has(element)) { |
|
6141 |
+ this.elements.push(element); |
|
4583 | 6142 |
} |
4584 | 6143 |
}; |
4585 |
- while (true) { |
|
4586 |
- var state_1 = _loop_1(); |
|
4587 |
- if (state_1 === "break") |
|
4588 |
- break; |
|
6144 |
+ /** |
|
6145 |
+ * @desc [mutator] |
|
6146 |
+ * @author fenris |
|
6147 |
+ */ |
|
6148 |
+ class_set.prototype.pop = function () { |
|
6149 |
+ if (this.elements.length == 0) { |
|
6150 |
+ return (new class_nothing()); |
|
4589 | 6151 |
} |
6152 |
+ else { |
|
6153 |
+ return (new class_just(this.elements.pop())); |
|
4590 | 6154 |
} |
4591 |
- return (new class_chain(steps)); |
|
4592 | 6155 |
}; |
4593 | 6156 |
/** |
6157 |
+ * @desc [accessor] |
|
4594 | 6158 |
* @author fenris |
4595 | 6159 |
*/ |
4596 |
- class_chain.prototype.invert = function () { |
|
4597 |
- return (new class_chain(this.steps.map(function (step) { return step.invert(); }))); |
|
6160 |
+ class_set.prototype.forEach = function (function_) { |
|
6161 |
+ this.elements.forEach(function (element) { return function_(element); }); |
|
4598 | 6162 |
}; |
4599 | 6163 |
/** |
6164 |
+ * @desc [accessor] |
|
4600 | 6165 |
* @author fenris |
4601 | 6166 |
*/ |
4602 |
- class_chain.prototype.add = function (step) { |
|
4603 |
- return (new class_chain(this.steps.concat([step]))).normalize(); |
|
6167 |
+ class_set.prototype.map = function (transformator) { |
|
6168 |
+ return (new class_set(this.elements.map(transformator))); |
|
4604 | 6169 |
}; |
4605 | 6170 |
/** |
6171 |
+ * @desc [accessor] |
|
4606 | 6172 |
* @author fenris |
4607 | 6173 |
*/ |
4608 |
- class_chain.prototype.extend = function (chain) { |
|
4609 |
- return (new class_chain(this.steps.concat(chain.steps))).normalize(); |
|
6174 |
+ class_set.prototype.filter = function (predicate) { |
|
6175 |
+ return (new class_set(this.elements.filter(predicate))); |
|
4610 | 6176 |
}; |
4611 | 6177 |
/** |
6178 |
+ * @desc [accessor] |
|
4612 | 6179 |
* @author fenris |
4613 | 6180 |
*/ |
4614 |
- class_chain.prototype.as_string = function (system) { |
|
4615 |
- if (system === void 0) { system = "linux"; } |
|
4616 |
- var splitter = class_chain.splitter(system); |
|
4617 |
- return ((this.steps.length == 0) ? ("." + splitter) : this.steps.map(function (step) { return (step.toString() + splitter); }).join("")); |
|
6181 |
+ class_set.prototype.dump = function () { |
|
6182 |
+ return this.elements; |
|
4618 | 6183 |
}; |
4619 | 6184 |
/** |
6185 |
+ * @desc [accessor] |
|
4620 | 6186 |
* @author fenris |
4621 | 6187 |
*/ |
4622 |
- class_chain.prototype.toString = function () { |
|
4623 |
- return this.as_string(); |
|
6188 |
+ class_set.prototype.subset = function (set) { |
|
6189 |
+ var _this = this; |
|
6190 |
+ return set.elements.every(function (element) { return _this.has(element); }); |
|
4624 | 6191 |
}; |
4625 |
- return class_chain; |
|
4626 |
- }()); |
|
4627 |
- lib_path.class_chain = class_chain; |
|
4628 | 6192 |
/** |
6193 |
+ * @desc [accessor] |
|
4629 | 6194 |
* @author fenris |
4630 | 6195 |
*/ |
4631 |
- function chain_read(str, system) { |
|
4632 |
- if (system === void 0) { system = "linux"; } |
|
4633 |
- var splitter = class_chain.splitter(system); |
|
4634 |
- var parts = str.split(splitter); |
|
4635 |
- if (parts[parts.length - 1] == "") |
|
4636 |
- parts.pop(); |
|
4637 |
- return (new class_chain(parts.map(lib_path.step_read))); |
|
4638 |
- } |
|
4639 |
- lib_path.chain_read = chain_read; |
|
4640 |
-})(lib_path || (lib_path = {})); |
|
4641 |
-///<reference path="../../../plankton/object/build/logic-decl.d.ts"/> |
|
4642 |
-var lib_path; |
|
4643 |
-(function (lib_path) { |
|
6196 |
+ class_set.prototype.superset = function (set) { |
|
6197 |
+ return this.elements.every(function (element) { return set.has(element); }); |
|
6198 |
+ }; |
|
4644 | 6199 |
/** |
6200 |
+ * @desc [accessor] |
|
4645 | 6201 |
* @author fenris |
4646 | 6202 |
*/ |
4647 |
- var class_location = (function () { |
|
6203 |
+ class_set.prototype.equals = function (set) { |
|
6204 |
+ return (this.subset(set) && this.superset(set)); |
|
6205 |
+ }; |
|
4648 | 6206 |
/** |
6207 |
+ * @desc [accessor] |
|
4649 | 6208 |
* @author fenris |
4650 | 6209 |
*/ |
4651 |
- function class_location(anchor, chain) { |
|
4652 |
- this.anchor = anchor; |
|
4653 |
- this.chain = chain; |
|
4654 |
- } |
|
6210 |
+ class_set.prototype.toString = function () { |
|
6211 |
+ return ("{" + this.elements.map(instance_show /*<type_element>*/).join(",") + "}"); |
|
6212 |
+ }; |
|
4655 | 6213 |
/** |
6214 |
+ * @desc [accessor] |
|
4656 | 6215 |
* @author fenris |
4657 | 6216 |
*/ |
4658 |
- class_location.anchorpattern = function (system) { |
|
4659 |
- if (system === void 0) { system = "linux"; } |
|
4660 |
- return (object_fetch({ |
|
4661 |
- "linux": new RegExp("/"), |
|
4662 |
- "bsd": new RegExp("/"), |
|
4663 |
- "win": new RegExp("[A-Z]:\\\\>") |
|
4664 |
- }, system, new RegExp("/"), 1)); |
|
6217 |
+ class_set.prototype.empty = function () { |
|
6218 |
+ return (this.elements.length == 0); |
|
4665 | 6219 |
}; |
4666 | 6220 |
/** |
4667 | 6221 |
* @desc [accessor] |
4668 | 6222 |
* @author fenris |
4669 | 6223 |
*/ |
4670 |
- class_location.prototype.is_absolute = function () { |
|
4671 |
- return (this.anchor != null); |
|
6224 |
+ class_set.prototype.union = function (set) { |
|
6225 |
+ var set_ = new class_set([], this.equality); |
|
6226 |
+ this.elements.forEach(function (element) { return set_.add(element); }); |
|
6227 |
+ set.elements.forEach(function (element) { return set_.add(element); }); |
|
6228 |
+ return set_; |
|
4672 | 6229 |
}; |
4673 | 6230 |
/** |
6231 |
+ * @desc [accessor] |
|
4674 | 6232 |
* @author fenris |
4675 | 6233 |
*/ |
4676 |
- class_location.prototype.normalize = function () { |
|
4677 |
- return (new class_location(this.anchor, this.chain.normalize())); |
|
6234 |
+ class_set.prototype.intersection = function (set) { |
|
6235 |
+ var set_ = new class_set([], this.equality); |
|
6236 |
+ this.elements |
|
6237 |
+ .filter(function (element) { return set.has(element); }) |
|
6238 |
+ .forEach(function (element) { return set_.add(element); }); |
|
6239 |
+ return set_; |
|
4678 | 6240 |
}; |
4679 | 6241 |
/** |
6242 |
+ * @desc [accessor] |
|
4680 | 6243 |
* @author fenris |
4681 | 6244 |
*/ |
4682 |
- class_location.prototype.extend = function (chain) { |
|
4683 |
- return (new class_location(this.anchor, this.chain.extend(chain))); |
|
6245 |
+ class_set.prototype.difference = function (set) { |
|
6246 |
+ var set_ = new class_set([], this.equality); |
|
6247 |
+ this.elements |
|
6248 |
+ .filter(function (element) { return !set.has(element); }) |
|
6249 |
+ .forEach(function (element) { return set_.add(element); }); |
|
6250 |
+ return set_; |
|
4684 | 6251 |
}; |
4685 | 6252 |
/** |
4686 | 6253 |
* @desc [accessor] |
4687 | 6254 |
* @author fenris |
4688 | 6255 |
*/ |
4689 |
- class_location.prototype.relocate = function (location) { |
|
4690 |
- if (this.is_absolute()) { |
|
4691 |
- return (new class_location(this.anchor, this.chain)); |
|
4692 |
- } |
|
4693 |
- else { |
|
4694 |
- return location.extend(this.chain); |
|
4695 |
- } |
|
6256 |
+ class_set.prototype.symmetric_difference = function (set) { |
|
6257 |
+ return this.difference(set).union(set.difference(this)); |
|
4696 | 6258 |
}; |
4697 | 6259 |
/** |
6260 |
+ * @desc [accessor] [implementation] |
|
4698 | 6261 |
* @author fenris |
4699 | 6262 |
*/ |
4700 |
- class_location.prototype.go_thither = function () { |
|
4701 |
- // console.error(">>", this.toString()); |
|
4702 |
- process.chdir(this.toString()); |
|
6263 |
+ class_set.prototype._collate = function (set) { |
|
6264 |
+ return this.equals(set); |
|
4703 | 6265 |
}; |
4704 | 6266 |
/** |
6267 |
+ * @desc [accessor] [implementation] |
|
4705 | 6268 |
* @author fenris |
4706 | 6269 |
*/ |
4707 |
- class_location.prototype.expedition = function (core) { |
|
4708 |
- var that = this; |
|
4709 |
- var current = location_read(process.cwd()); |
|
4710 |
- function begin() { |
|
4711 |
- // (new class_message("changing directory to '" + that.toString() + "'")).stderr(); |
|
4712 |
- that.go_thither(); |
|
6270 |
+ class_set.prototype._show = function () { |
|
6271 |
+ return this.toString(); |
|
6272 |
+ }; |
|
6273 |
+ /** |
|
6274 |
+ * @author fenris |
|
6275 |
+ */ |
|
6276 |
+ class_set.union_all = function (sets) { |
|
6277 |
+ return (sets.reduce(function (x, y) { return ((x == null) ? y : x.union(y)); }, null)); |
|
6278 |
+ }; |
|
6279 |
+ /** |
|
6280 |
+ * @author fenris |
|
6281 |
+ */ |
|
6282 |
+ class_set.intersection_all = function (sets) { |
|
6283 |
+ return (sets.reduce(function (x, y) { return ((x == null) ? y : x.intersection(y)); }, null)); |
|
6284 |
+ }; |
|
6285 |
+ return class_set; |
|
6286 |
+ }()); |
|
6287 |
+ lib_structures.class_set = class_set; |
|
6288 |
+})(lib_structures || (lib_structures = {})); |
|
6289 |
+var lib_structures; |
|
6290 |
+(function (lib_structures) { |
|
6291 |
+ /** |
|
6292 |
+ * @author fenris |
|
6293 |
+ */ |
|
6294 |
+ var class_map_abstract = (function () { |
|
6295 |
+ function class_map_abstract() { |
|
4713 | 6296 |
} |
4714 |
- function end() { |
|
4715 |
- // (new class_message("changing directory to '" + current.toString() + "'")).stderr(); |
|
4716 |
- current.go_thither(); |
|
6297 |
+ /** |
|
6298 |
+ * @desc [mutator] [syntactic sugar] |
|
6299 |
+ * @author fenris |
|
6300 |
+ */ |
|
6301 |
+ class_map_abstract.prototype.del = function (key) { |
|
6302 |
+ return this["delete"](key); |
|
6303 |
+ }; |
|
6304 |
+ /** |
|
6305 |
+ * @desc [accessor] |
|
6306 |
+ * @author fenris |
|
6307 |
+ */ |
|
6308 |
+ class_map_abstract.prototype.map = function (transformator) { |
|
6309 |
+ var map_ = this.spawn(); |
|
6310 |
+ this.forEach(function (value, key) { |
|
6311 |
+ var value_ = transformator(value); |
|
6312 |
+ map_.set(key, value_); |
|
6313 |
+ }); |
|
6314 |
+ return map_; |
|
6315 |
+ }; |
|
6316 |
+ /** |
|
6317 |
+ * @desc [accessor] |
|
6318 |
+ * @author fenris |
|
6319 |
+ */ |
|
6320 |
+ class_map_abstract.prototype.filter = function (predicate) { |
|
6321 |
+ var map_ = this.spawn(); |
|
6322 |
+ this.forEach(function (value, key) { |
|
6323 |
+ if (predicate(value)) { |
|
6324 |
+ map_.set(key, value); |
|
4717 | 6325 |
} |
4718 |
- begin(); |
|
4719 |
- core(end); |
|
6326 |
+ }); |
|
6327 |
+ return map_; |
|
6328 |
+ }; |
|
6329 |
+ /** |
|
6330 |
+ * @desc [accessor] |
|
6331 |
+ * @author fenris |
|
6332 |
+ */ |
|
6333 |
+ class_map_abstract.prototype.pairs = function () { |
|
6334 |
+ var set = new lib_structures.class_set(); |
|
6335 |
+ this.forEach(function (value, key) { |
|
6336 |
+ set.add(new lib_structures.class_pair(key, value)); |
|
6337 |
+ }); |
|
6338 |
+ return set; |
|
6339 |
+ }; |
|
6340 |
+ /** |
|
6341 |
+ * @desc [accessor] |
|
6342 |
+ * @author fenris |
|
6343 |
+ */ |
|
6344 |
+ class_map_abstract.prototype.keys = function () { |
|
6345 |
+ var set = new lib_structures.class_set(); |
|
6346 |
+ this.forEach(function (value, key) { |
|
6347 |
+ set.add(key); |
|
6348 |
+ }); |
|
6349 |
+ return set; |
|
4720 | 6350 |
}; |
4721 | 6351 |
/** |
6352 |
+ * @desc [accessor] |
|
4722 | 6353 |
* @author fenris |
4723 | 6354 |
*/ |
4724 |
- class_location.prototype.as_string = function (system) { |
|
4725 |
- if (system === void 0) { system = "linux"; } |
|
4726 |
- return (((this.anchor != null) ? this.anchor : "") + this.chain.as_string(system)); |
|
6355 |
+ class_map_abstract.prototype.values = function () { |
|
6356 |
+ var set = new lib_structures.class_set(); |
|
6357 |
+ this.forEach(function (value, key) { |
|
6358 |
+ set.add(value); |
|
6359 |
+ }); |
|
6360 |
+ return set; |
|
4727 | 6361 |
}; |
6362 |
+ return class_map_abstract; |
|
6363 |
+ }()); |
|
6364 |
+ lib_structures.class_map_abstract = class_map_abstract; |
|
4728 | 6365 |
/** |
4729 | 6366 |
* @author fenris |
4730 | 6367 |
*/ |
4731 |
- class_location.prototype.toString = function () { |
|
4732 |
- return this.as_string(); |
|
6368 |
+ var class_map_simple = (function (_super) { |
|
6369 |
+ __extends(class_map_simple, _super); |
|
6370 |
+ /** |
|
6371 |
+ * @author fenris |
|
6372 |
+ */ |
|
6373 |
+ function class_map_simple() { |
|
6374 |
+ var _this = _super.call(this) || this; |
|
6375 |
+ _this.object = {}; |
|
6376 |
+ return _this; |
|
6377 |
+ } |
|
6378 |
+ /** |
|
6379 |
+ * @desc [accessor] |
|
6380 |
+ * @author fenris |
|
6381 |
+ */ |
|
6382 |
+ class_map_simple.from_object = function (object) { |
|
6383 |
+ var map = new class_map_simple(); |
|
6384 |
+ Object.keys(object).forEach(function (key) { return map.set(key, object[key]); }); |
|
6385 |
+ return map; |
|
4733 | 6386 |
}; |
4734 | 6387 |
/** |
6388 |
+ * @override |
|
4735 | 6389 |
* @author fenris |
4736 | 6390 |
*/ |
4737 |
- class_location.current = function () { |
|
4738 |
- // return class_location.read(process.cwd()); |
|
4739 |
- return location_read(process.cwd()); |
|
6391 |
+ class_map_simple.prototype.spawn = function () { |
|
6392 |
+ return (new class_map_simple()); |
|
4740 | 6393 |
}; |
4741 | 6394 |
/** |
6395 |
+ * @override |
|
4742 | 6396 |
* @author fenris |
4743 | 6397 |
*/ |
4744 |
- class_location.tempfolder = function (system) { |
|
4745 |
- if (system === void 0) { system = "linux"; } |
|
4746 |
- return (object_fetch({ |
|
4747 |
- "linux": new class_location("/", new lib_path.class_chain([new lib_path.class_step_regular("tmp")])), |
|
4748 |
- "bsd": new class_location("/", new lib_path.class_chain([new lib_path.class_step_regular("tmp")])), |
|
4749 |
- "win": new class_location(null, new lib_path.class_chain([new lib_path.class_step_regular("%TEMP%")])) |
|
4750 |
- }, system, null, 2)); |
|
6398 |
+ class_map_simple.prototype.has = function (key) { |
|
6399 |
+ return (key in this.object); |
|
4751 | 6400 |
}; |
4752 |
- return class_location; |
|
4753 |
- }()); |
|
4754 |
- lib_path.class_location = class_location; |
|
4755 | 6401 |
/** |
6402 |
+ * @override |
|
4756 | 6403 |
* @author fenris |
4757 | 6404 |
*/ |
4758 |
- function location_read(str, system) { |
|
4759 |
- if (system === void 0) { system = "linux"; } |
|
4760 |
- var regexp = class_location.anchorpattern(system); |
|
4761 |
- var matching = regexp.exec(str); |
|
4762 |
- if ((matching == null) || (matching.index > 0)) { |
|
4763 |
- return (new class_location(null, lib_path.chain_read(str, system))); |
|
6405 |
+ class_map_simple.prototype.get = function (key, strict, fallback) { |
|
6406 |
+ if (this.has(key)) { |
|
6407 |
+ return this.object[key]; |
|
4764 | 6408 |
} |
4765 | 6409 |
else { |
4766 |
- return (new class_location(matching[0], lib_path.chain_read(str.slice(matching[0].length), system))); |
|
6410 |
+ if (strict) { |
|
6411 |
+ throw (new Error("key not found")); |
|
4767 | 6412 |
} |
6413 |
+ else { |
|
6414 |
+ return fallback; |
|
4768 | 6415 |
} |
4769 |
- lib_path.location_read = location_read; |
|
4770 |
-})(lib_path || (lib_path = {})); |
|
4771 |
-var lib_path; |
|
4772 |
-(function (lib_path) { |
|
6416 |
+ } |
|
6417 |
+ }; |
|
4773 | 6418 |
/** |
6419 |
+ * @override |
|
4774 | 6420 |
* @author fenris |
4775 | 6421 |
*/ |
4776 |
- var class_filepointer = (function () { |
|
6422 |
+ class_map_simple.prototype.set = function (key, value) { |
|
6423 |
+ this.object[key] = value; |
|
6424 |
+ }; |
|
4777 | 6425 |
/** |
6426 |
+ * @override |
|
4778 | 6427 |
* @author fenris |
4779 | 6428 |
*/ |
4780 |
- function class_filepointer(location, filename) { |
|
4781 |
- this.location = location; |
|
4782 |
- this.filename = filename; |
|
4783 |
- } |
|
6429 |
+ class_map_simple.prototype.clear = function () { |
|
6430 |
+ this.object = {}; |
|
6431 |
+ }; |
|
4784 | 6432 |
/** |
6433 |
+ * @override |
|
4785 | 6434 |
* @author fenris |
4786 | 6435 |
*/ |
4787 |
- class_filepointer.prototype.normalize = function () { |
|
4788 |
- return (new class_filepointer(this.location.normalize(), this.filename)); |
|
6436 |
+ class_map_simple.prototype["delete"] = function (key) { |
|
6437 |
+ delete this.object[key]; |
|
4789 | 6438 |
}; |
4790 | 6439 |
/** |
6440 |
+ * @override |
|
4791 | 6441 |
* @author fenris |
4792 | 6442 |
*/ |
4793 |
- class_filepointer.prototype.foo = function (filepointer) { |
|
4794 |
- return (new class_filepointer(this.location.extend(filepointer.location.chain), filepointer.filename)); |
|
6443 |
+ class_map_simple.prototype.forEach = function (function_) { |
|
6444 |
+ var _this = this; |
|
6445 |
+ Object.keys(this.object).forEach(function (key) { |
|
6446 |
+ var value = _this.object[key]; |
|
6447 |
+ function_(value, key); |
|
6448 |
+ }); |
|
4795 | 6449 |
}; |
4796 | 6450 |
/** |
4797 | 6451 |
* @desc [accessor] |
4798 | 6452 |
* @author fenris |
6453 |
+ * @todo implement |
|
4799 | 6454 |
*/ |
4800 |
- class_filepointer.prototype.relocate = function (location) { |
|
4801 |
- return (new class_filepointer(this.location.relocate(location), this.filename)); |
|
6455 |
+ /* |
|
6456 |
+ public equals(map : class_map_simple<type_value>) : boolean { |
|
6457 |
+ |
|
6458 |
+ } |
|
6459 |
+ */ |
|
6460 |
+ /** |
|
6461 |
+ * @desc [accessor] |
|
6462 |
+ * @author fenris |
|
6463 |
+ */ |
|
6464 |
+ class_map_simple.prototype.toString = function () { |
|
6465 |
+ return ("{" + this.pairs().map(function (pair) { return instance_show(pair.first_get()) + " -> " + instance_show(pair.second_get()); }).dump().join(", ") + "}"); |
|
4802 | 6466 |
}; |
4803 | 6467 |
/** |
6468 |
+ * @desc [accessor] [implementation] |
|
4804 | 6469 |
* @author fenris |
4805 | 6470 |
*/ |
4806 |
- class_filepointer.prototype.as_string = function (system) { |
|
4807 |
- if (system === void 0) { system = "linux"; } |
|
4808 |
- return (this.location.as_string(system) /* + "/"*/ + ((this.filename == null) ? "" : this.filename)); |
|
6471 |
+ class_map_simple.prototype._clone = function () { |
|
6472 |
+ return (this.map(function (value) { return instance_clone(value); })); |
|
4809 | 6473 |
}; |
4810 | 6474 |
/** |
6475 |
+ * @desc [accessor] [implementation] |
|
4811 | 6476 |
* @author fenris |
4812 | 6477 |
*/ |
4813 |
- class_filepointer.prototype.toString = function () { |
|
4814 |
- return this.as_string(); |
|
6478 |
+ class_map_simple.prototype._show = function () { |
|
6479 |
+ return this.toString(); |
|
4815 | 6480 |
}; |
4816 |
- return class_filepointer; |
|
4817 |
- }()); |
|
4818 |
- lib_path.class_filepointer = class_filepointer; |
|
6481 |
+ return class_map_simple; |
|
6482 |
+ }(class_map_abstract)); |
|
6483 |
+ lib_structures.class_map_simple = class_map_simple; |
|
4819 | 6484 |
/** |
4820 | 6485 |
* @author fenris |
4821 | 6486 |
*/ |
4822 |
- function filepointer_read(str, system) { |
|
4823 |
- if (system === void 0) { system = "linux"; } |
|
4824 |
- var splitter = lib_path.class_chain.splitter(system); |
|
4825 |
- var parts = str.split(splitter); |
|
4826 |
- var last = parts[parts.length - 1]; |
|
4827 |
- if (last == "") { |
|
4828 |
- return (new class_filepointer(lib_path.location_read(parts.join(splitter), system), null)); |
|
4829 |
- } |
|
4830 |
- else { |
|
4831 |
- return (new class_filepointer(lib_path.location_read(parts.slice(0, parts.length - 1).join(splitter), system), last)); |
|
4832 |
- } |
|
6487 |
+ var class_map_equality = (function (_super) { |
|
6488 |
+ __extends(class_map_equality, _super); |
|
6489 |
+ /** |
|
6490 |
+ * @author fenris |
|
6491 |
+ */ |
|
6492 |
+ function class_map_equality(collate /*<type_key>*/) { |
|
6493 |
+ if (collate === void 0) { collate = instance_collate; } /*<type_key>*/ |
|
6494 |
+ var _this = _super.call(this) || this; |
|
6495 |
+ _this.pairs_ = []; |
|
6496 |
+ _this.collate = collate; |
|
6497 |
+ return _this; |
|
4833 | 6498 |
} |
4834 |
- lib_path.filepointer_read = filepointer_read; |
|
4835 |
-})(lib_path || (lib_path = {})); |
|
4836 |
-///<reference path="../../call/build/logic-decl.d.ts"/> |
|
4837 |
-var lib_file; |
|
4838 |
-(function (lib_file) { |
|
4839 | 6499 |
/** |
6500 |
+ * @override |
|
4840 | 6501 |
* @author fenris |
4841 | 6502 |
*/ |
4842 |
- class class_file_abstract { |
|
6503 |
+ class_map_equality.prototype.spawn = function () { |
|
6504 |
+ return (new class_map_equality(this.collate)); |
|
6505 |
+ }; |
|
4843 | 6506 |
/** |
4844 |
- * @desc reads a json file |
|
6507 |
+ * @override |
|
4845 | 6508 |
* @author fenris |
4846 | 6509 |
*/ |
4847 |
- read_json(path) { |
|
4848 |
- return ((resolve, reject) => { |
|
4849 |
- lib_call.executor_chain({}, [ |
|
4850 |
- state => (resolve_, reject_) => { |
|
4851 |
- this.read(path)(content => { |
|
4852 |
- state.content = content; |
|
4853 |
- resolve_(state); |
|
4854 |
- }, reject_); |
|
4855 |
- }, |
|
4856 |
- state => (resolve_, reject_) => { |
|
4857 |
- let error; |
|
4858 |
- try { |
|
4859 |
- state.data = JSON.parse(state.content); |
|
4860 |
- error = null; |
|
4861 |
- } |
|
4862 |
- catch (exception) { |
|
4863 |
- error = new class_error("invalid json '" + path + "'", [exception]); |
|
4864 |
- } |
|
4865 |
- if (error == null) { |
|
4866 |
- resolve_(state); |
|
6510 |
+ class_map_equality.prototype.has = function (key) { |
|
6511 |
+ var _this = this; |
|
6512 |
+ return this.pairs_.some(function (pair) { return _this.collate(pair.first_get(), key); }); |
|
6513 |
+ }; |
|
6514 |
+ /** |
|
6515 |
+ * @override |
|
6516 |
+ * @author fenris |
|
6517 |
+ */ |
|
6518 |
+ class_map_equality.prototype.get = function (key, strict, fallback) { |
|
6519 |
+ var _this = this; |
|
6520 |
+ if (strict === void 0) { strict = false; } |
|
6521 |
+ if (fallback === void 0) { fallback = null; } |
|
6522 |
+ var value; |
|
6523 |
+ var found = this.pairs_.some(function (pair) { |
|
6524 |
+ if (_this.collate(pair.first_get(), key)) { |
|
6525 |
+ value = pair.second_get(); |
|
6526 |
+ return true; |
|
4867 | 6527 |
} |
4868 | 6528 |
else { |
4869 |
- reject_(error); |
|
6529 |
+ return false; |
|
4870 | 6530 |
} |
4871 |
- }, |
|
4872 |
- ])(state => resolve(state.data), reject); |
|
4873 | 6531 |
}); |
6532 |
+ if (!found) { |
|
6533 |
+ if (strict) { |
|
6534 |
+ throw (new Error("key not found")); |
|
4874 | 6535 |
} |
4875 |
- /** |
|
4876 |
- * @desc writes a json file |
|
4877 |
- * @author fenris |
|
4878 |
- */ |
|
4879 |
- write_json(path, data) { |
|
4880 |
- return this.write(path, JSON.stringify(data, undefined, "\t")); |
|
6536 |
+ else { |
|
6537 |
+ value = fallback; |
|
4881 | 6538 |
} |
4882 | 6539 |
} |
4883 |
- lib_file.class_file_abstract = class_file_abstract; |
|
4884 |
-})(lib_file || (lib_file = {})); |
|
4885 |
-///<reference path="../../call/build/logic-decl.d.ts"/> |
|
4886 |
-var lib_file; |
|
4887 |
-(function (lib_file) { |
|
6540 |
+ return value; |
|
6541 |
+ }; |
|
4888 | 6542 |
/** |
6543 |
+ * @override |
|
4889 | 6544 |
* @author fenris |
4890 | 6545 |
*/ |
4891 |
- class class_file_node extends lib_file.class_file_abstract { |
|
4892 |
- /** |
|
4893 |
- * @author maspr |
|
4894 |
- */ |
|
4895 |
- determine_handler(path) { |
|
4896 |
- if (/^https?:\/\//.test(path)) { |
|
4897 |
- return "http"; |
|
6546 |
+ class_map_equality.prototype.set = function (key, value) { |
|
6547 |
+ var _this = this; |
|
6548 |
+ var found = this.pairs_.some(function (pair) { |
|
6549 |
+ if (_this.collate(pair.first_get(), key)) { |
|
6550 |
+ pair.second_set(value); |
|
6551 |
+ return true; |
|
4898 | 6552 |
} |
4899 | 6553 |
else { |
4900 |
- return "file"; |
|
6554 |
+ return false; |
|
4901 | 6555 |
} |
6556 |
+ }); |
|
6557 |
+ if (!found) { |
|
6558 |
+ this.pairs_.push(new lib_structures.class_pair(key, value)); |
|
4902 | 6559 |
} |
6560 |
+ }; |
|
4903 | 6561 |
/** |
4904 | 6562 |
* @override |
4905 |
- * @author fenris,maspr |
|
4906 |
- * @todo clear up if http(s)-handling belongs here or not |
|
6563 |
+ * @author fenris |
|
4907 | 6564 |
*/ |
4908 |
- read(path, skip_error = false) { |
|
4909 |
- switch (this.determine_handler(path)) { |
|
4910 |
- case "file": |
|
4911 |
- { |
|
4912 |
- let nm_fs = require("fs"); |
|
4913 |
- return ((resolve, reject) => { |
|
4914 |
- nm_fs.readFile(path, { |
|
4915 |
- "encoding": "utf8", |
|
4916 |
- "flag": "r", |
|
4917 |
- }, (error, content) => { |
|
4918 |
- if (error == null) { |
|
4919 |
- resolve(content); |
|
6565 |
+ class_map_equality.prototype.clear = function () { |
|
6566 |
+ this.pairs_ = []; |
|
6567 |
+ }; |
|
6568 |
+ /** |
|
6569 |
+ * @override |
|
6570 |
+ * @author fenris |
|
6571 |
+ */ |
|
6572 |
+ class_map_equality.prototype["delete"] = function (key) { |
|
6573 |
+ var _this = this; |
|
6574 |
+ var index; |
|
6575 |
+ var found = this.pairs_.some(function (pair, index_) { |
|
6576 |
+ if (_this.collate(pair.first_get(), key)) { |
|
6577 |
+ index = index_; |
|
6578 |
+ return true; |
|
4920 | 6579 |
} |
4921 | 6580 |
else { |
4922 |
- reject(error); |
|
6581 |
+ return false; |
|
4923 | 6582 |
} |
4924 | 6583 |
}); |
4925 |
- }); |
|
6584 |
+ if (found) { |
|
6585 |
+ this.pairs_.splice(index, 1); |
|
4926 | 6586 |
} |
4927 |
- break; |
|
4928 |
- case "http": |
|
4929 |
- { |
|
4930 |
- return (resolve, reject) => { |
|
4931 |
- let nm_http = require("http"); |
|
4932 |
- let nm_https = require("https"); |
|
4933 |
- let nm_url = require("url"); |
|
4934 |
- let parsed_url = nm_url.parse(path, false, true); |
|
4935 |
- let client = (parsed_url.protocol == "https:") ? nm_https : nm_http; |
|
4936 |
- let default_port = ((parsed_url.protocol == "https:") ? 443 : 80); |
|
4937 |
- let options = { |
|
4938 |
- hostname: parsed_url.hostname, |
|
4939 |
- port: parsed_url.port || default_port, |
|
4940 |
- path: parsed_url.path, |
|
4941 |
- method: "GET" |
|
4942 | 6587 |
}; |
4943 |
- let req = client.request(options, (res) => { |
|
4944 |
- let data = ""; // @todo |
|
4945 |
- res.on("data", (chunk) => { |
|
4946 |
- data += chunk; |
|
4947 |
- }); |
|
4948 |
- res.on("end", () => { |
|
4949 |
- resolve(data); |
|
4950 |
- }); |
|
4951 |
- }); |
|
4952 |
- req.end(); |
|
4953 |
- req.on("error", (error) => { |
|
4954 |
- reject(error); |
|
4955 |
- }); |
|
6588 |
+ /** |
|
6589 |
+ * @desc [accessor] |
|
6590 |
+ * @author fenris |
|
6591 |
+ */ |
|
6592 |
+ class_map_equality.prototype.forEach = function (function_) { |
|
6593 |
+ this.pairs_.forEach(function (pair) { return function_(pair.second_get(), pair.first_get()); }); |
|
4956 | 6594 |
}; |
6595 |
+ return class_map_equality; |
|
6596 |
+ }(class_map_abstract)); |
|
6597 |
+ lib_structures.class_map_equality = class_map_equality; |
|
6598 |
+ /** |
|
6599 |
+ * @author fenris |
|
6600 |
+ */ |
|
6601 |
+ var class_map = (function (_super) { |
|
6602 |
+ __extends(class_map, _super); |
|
6603 |
+ function class_map() { |
|
6604 |
+ return _super !== null && _super.apply(this, arguments) || this; |
|
4957 | 6605 |
} |
4958 |
- break; |
|
4959 |
- default: { |
|
4960 |
- return ((resolve, reject) => reject(new Error("unhandled protocol"))); |
|
4961 |
- } |
|
6606 |
+ return class_map; |
|
6607 |
+ }(class_map_equality)); |
|
6608 |
+ lib_structures.class_map = class_map; |
|
6609 |
+})(lib_structures || (lib_structures = {})); |
|
6610 |
+var lib_structures; |
|
6611 |
+(function (lib_structures) { |
|
6612 |
+ /** |
|
6613 |
+ * @author fenris |
|
6614 |
+ */ |
|
6615 |
+ var class_store = (function () { |
|
6616 |
+ function class_store() { |
|
4962 | 6617 |
} |
6618 |
+ return class_store; |
|
6619 |
+ }()); |
|
6620 |
+ lib_structures.class_store = class_store; |
|
6621 |
+})(lib_structures || (lib_structures = {})); |
|
6622 |
+var lib_structures; |
|
6623 |
+(function (lib_structures) { |
|
6624 |
+ /** |
|
6625 |
+ * @author fenris |
|
6626 |
+ */ |
|
6627 |
+ var class_stack = (function (_super) { |
|
6628 |
+ __extends(class_stack, _super); |
|
6629 |
+ /** |
|
6630 |
+ * @author fenris |
|
6631 |
+ */ |
|
6632 |
+ function class_stack() { |
|
6633 |
+ var _this = _super.call(this) || this; |
|
6634 |
+ _this.elements = []; |
|
6635 |
+ return _this; |
|
4963 | 6636 |
} |
4964 | 6637 |
/** |
4965 | 6638 |
* @override |
4966 | 6639 |
* @author fenris |
4967 | 6640 |
*/ |
4968 |
- write(path, content) { |
|
4969 |
- let nm_fs = require("fs"); |
|
4970 |
- return ((resolve, reject) => { |
|
4971 |
- nm_fs.writeFile(path, content, { |
|
4972 |
- "encoding": "utf8", |
|
4973 |
- "flag": "w", |
|
4974 |
- }, (error) => { |
|
4975 |
- if (error == null) { |
|
4976 |
- resolve(undefined); |
|
4977 |
- } |
|
4978 |
- else { |
|
4979 |
- reject(error); |
|
4980 |
- } |
|
4981 |
- }); |
|
4982 |
- }); |
|
4983 |
- } |
|
4984 |
- } |
|
4985 |
- lib_file.class_file_node = class_file_node; |
|
4986 |
-})(lib_file || (lib_file = {})); |
|
4987 |
-///<reference path="../../call/build/logic-decl.d.ts"/> |
|
4988 |
-var lib_file; |
|
4989 |
-(function (lib_file) { |
|
6641 |
+ class_stack.prototype.size = function () { |
|
6642 |
+ return this.elements.length; |
|
6643 |
+ }; |
|
4990 | 6644 |
/** |
6645 |
+ * @override |
|
4991 | 6646 |
* @author fenris |
4992 |
- * @todo move to a dedicated lib (e.g. "http", "transport", etc.) |
|
4993 | 6647 |
*/ |
4994 |
- function ajax({ "target": target /*: string*/, "data": data /*: {[key : string] : string}*/ = null, "method": method /* : string*/ = "GET" }) { |
|
4995 |
- method = method.toLowerCase(); |
|
4996 |
- return ((resolve, reject) => { |
|
4997 |
- let datastring = ((data == null) ? null : Object.keys(data).map(key => `${key}=${data[key]}`).join("&")); |
|
4998 |
- let suffix = ((method == "get") ? ("?" + datastring) : ""); |
|
4999 |
- let sending = ((method == "get") ? null : datastring); |
|
5000 |
- let request = new XMLHttpRequest(); |
|
5001 |
- request.open(method.toUpperCase(), target + suffix, true); |
|
5002 |
- request.onreadystatechange = function () { |
|
5003 |
- if (request.readyState === 4) { |
|
5004 |
- if (request.status === 200) { |
|
5005 |
- resolve(request.responseText); |
|
6648 |
+ class_stack.prototype.scan = function () { |
|
6649 |
+ if (this.size() == 0) { |
|
6650 |
+ throw (new Error("empty")); |
|
5006 | 6651 |
} |
5007 | 6652 |
else { |
5008 |
- reject(new Error("XMLHttpRequest failed")); |
|
5009 |
- } |
|
6653 |
+ return this.elements[this.elements.length - 1]; |
|
5010 | 6654 |
} |
5011 | 6655 |
}; |
5012 |
- request.send(sending); |
|
5013 |
- }); |
|
5014 |
- } |
|
5015 | 6656 |
/** |
6657 |
+ * @override |
|
5016 | 6658 |
* @author fenris |
5017 | 6659 |
*/ |
5018 |
- class class_file_web extends lib_file.class_file_abstract { |
|
6660 |
+ class_stack.prototype.give = function (element) { |
|
6661 |
+ this.elements.push(element); |
|
6662 |
+ }; |
|
5019 | 6663 |
/** |
5020 | 6664 |
* @override |
5021 | 6665 |
* @author fenris |
5022 | 6666 |
*/ |
5023 |
- read(path, skip_error = false) { |
|
5024 |
- return ((resolve, reject) => { |
|
5025 |
- ajax({ |
|
5026 |
- "target": path, |
|
5027 |
- "method": "GET", |
|
5028 |
- })(resolve, reason => (skip_error ? resolve(null) : reject(reason))); |
|
5029 |
- }); |
|
5030 |
- } |
|
6667 |
+ class_stack.prototype.take = function () { |
|
6668 |
+ var element = this.scan(); |
|
6669 |
+ this.elements.pop(); |
|
6670 |
+ return element; |
|
6671 |
+ }; |
|
6672 |
+ return class_stack; |
|
6673 |
+ }(lib_structures.class_store)); |
|
6674 |
+ lib_structures.class_stack = class_stack; |
|
6675 |
+})(lib_structures || (lib_structures = {})); |
|
6676 |
+var lib_structures; |
|
6677 |
+(function (lib_structures) { |
|
5031 | 6678 |
/** |
5032 |
- * @override |
|
5033 | 6679 |
* @author fenris |
5034 | 6680 |
*/ |
5035 |
- write(path, content) { |
|
5036 |
- return ((resolve, reject) => { |
|
5037 |
- reject(new Error("not implemented / not possible")); |
|
5038 |
- }); |
|
5039 |
- } |
|
5040 |
- } |
|
5041 |
- lib_file.class_file_web = class_file_web; |
|
5042 |
-})(lib_file || (lib_file = {})); |
|
5043 |
-///<reference path="../../base/build/logic-decl.d.ts"/> |
|
5044 |
-///<reference path="../../call/build/logic-decl.d.ts"/> |
|
5045 |
-var lib_file; |
|
5046 |
-(function (lib_file) { |
|
6681 |
+ var class_queue = (function (_super) { |
|
6682 |
+ __extends(class_queue, _super); |
|
5047 | 6683 |
/** |
5048 |
- * @desc selects the implementation which fits for the detected environment |
|
5049 | 6684 |
* @author fenris |
5050 | 6685 |
*/ |
5051 |
- function auto() { |
|
5052 |
- let environment = lib_base.environment(); |
|
5053 |
- switch (environment) { |
|
5054 |
- case "node": { |
|
5055 |
- return (new lib_file.class_file_node()); |
|
5056 |
- break; |
|
5057 |
- } |
|
5058 |
- case "web": { |
|
5059 |
- return (new lib_file.class_file_web()); |
|
5060 |
- break; |
|
5061 |
- } |
|
5062 |
- default: { |
|
5063 |
- throw (new Error(`no implementation for environment '${environment}'`)); |
|
5064 |
- break; |
|
5065 |
- } |
|
5066 |
- } |
|
6686 |
+ function class_queue() { |
|
6687 |
+ var _this = _super.call(this) || this; |
|
6688 |
+ _this.elements = []; |
|
6689 |
+ return _this; |
|
5067 | 6690 |
} |
5068 |
- lib_file.auto = auto; |
|
5069 | 6691 |
/** |
6692 |
+ * @override |
|
5070 | 6693 |
* @author fenris |
5071 | 6694 |
*/ |
5072 |
- class class_file extends lib_file.class_file_abstract { |
|
6695 |
+ class_queue.prototype.size = function () { |
|
6696 |
+ return this.elements.length; |
|
6697 |
+ }; |
|
5073 | 6698 |
/** |
6699 |
+ * @override |
|
5074 | 6700 |
* @author fenris |
5075 | 6701 |
*/ |
5076 |
- constructor() { |
|
5077 |
- super(); |
|
5078 |
- this.core = auto(); |
|
6702 |
+ class_queue.prototype.scan = function () { |
|
6703 |
+ if (this.size() == 0) { |
|
6704 |
+ throw (new Error("empty")); |
|
6705 |
+ } |
|
6706 |
+ else { |
|
6707 |
+ return this.elements[0]; |
|
5079 | 6708 |
} |
6709 |
+ }; |
|
5080 | 6710 |
/** |
5081 | 6711 |
* @override |
5082 | 6712 |
* @author fenris |
5083 | 6713 |
*/ |
5084 |
- read(path, skip_error = false) { |
|
5085 |
- return this.core.read(path, skip_error); |
|
5086 |
- } |
|
6714 |
+ class_queue.prototype.give = function (element) { |
|
6715 |
+ this.elements.push(element); |
|
6716 |
+ }; |
|
5087 | 6717 |
/** |
5088 | 6718 |
* @override |
5089 | 6719 |
* @author fenris |
5090 | 6720 |
*/ |
5091 |
- write(path, content) { |
|
5092 |
- return this.core.write(path, content); |
|
6721 |
+ class_queue.prototype.take = function () { |
|
6722 |
+ var element = this.scan(); |
|
6723 |
+ this.elements.shift(); |
|
6724 |
+ return element; |
|
6725 |
+ }; |
|
6726 |
+ return class_queue; |
|
6727 |
+ }(lib_structures.class_store)); |
|
6728 |
+ lib_structures.class_queue = class_queue; |
|
6729 |
+})(lib_structures || (lib_structures = {})); |
|
6730 |
+var lib_structures; |
|
6731 |
+(function (lib_structures) { |
|
6732 |
+ /** |
|
6733 |
+ * @author fenris |
|
6734 |
+ */ |
|
6735 |
+ var class_graph = (function () { |
|
6736 |
+ /** |
|
6737 |
+ * @author fenris |
|
6738 |
+ */ |
|
6739 |
+ function class_graph(equality, nodes, edges) { |
|
6740 |
+ if (equality === void 0) { equality = null; } |
|
6741 |
+ if (nodes === void 0) { nodes = []; } |
|
6742 |
+ if (edges === void 0) { edges = []; } |
|
6743 |
+ if (equality == null) { |
|
6744 |
+ // equality = ((node1, node2) => lib_trait.call("collatable", "collate", {"kind": "auto"}, {"first": node1, "second": node2})); |
|
6745 |
+ equality = instance_collate /*<type_node>*/; |
|
5093 | 6746 |
} |
6747 |
+ this.equality = equality; |
|
6748 |
+ this.nodes = nodes; |
|
6749 |
+ this.edges = edges; |
|
5094 | 6750 |
} |
5095 |
- lib_file.class_file = class_file; |
|
5096 | 6751 |
/** |
6752 |
+ * @desc [accessor] [getter] |
|
5097 | 6753 |
* @author fenris |
5098 | 6754 |
*/ |
5099 |
- var instance = auto(); |
|
6755 |
+ class_graph.prototype.nodes_get = function () { |
|
6756 |
+ return this.nodes; |
|
6757 |
+ }; |
|
5100 | 6758 |
/** |
6759 |
+ * @desc [mutator] |
|
5101 | 6760 |
* @author fenris |
5102 | 6761 |
*/ |
5103 |
- function read(path, skip_error = false) { |
|
5104 |
- return instance.read(path, skip_error); |
|
5105 |
- } |
|
5106 |
- lib_file.read = read; |
|
6762 |
+ class_graph.prototype.add_node = function (node) { |
|
6763 |
+ this.nodes.push(node); |
|
6764 |
+ }; |
|
5107 | 6765 |
/** |
6766 |
+ * @desc [accessor] [getter] |
|
5108 | 6767 |
* @author fenris |
5109 | 6768 |
*/ |
5110 |
- function write(path, content) { |
|
5111 |
- return instance.write(path, content); |
|
5112 |
- } |
|
5113 |
- lib_file.write = write; |
|
6769 |
+ class_graph.prototype.edges_get = function () { |
|
6770 |
+ return this.edges; |
|
6771 |
+ }; |
|
5114 | 6772 |
/** |
6773 |
+ * @desc [mutator] |
|
5115 | 6774 |
* @author fenris |
5116 | 6775 |
*/ |
5117 |
- function read_json(path) { |
|
5118 |
- return instance.read_json(path); |
|
6776 |
+ class_graph.prototype.add_edge = function (edge) { |
|
6777 |
+ this.edges.push(edge); |
|
6778 |
+ }; |
|
6779 |
+ /** |
|
6780 |
+ * @desc [accessor] |
|
6781 |
+ * @author fenris |
|
6782 |
+ */ |
|
6783 |
+ class_graph.prototype.has = function (node) { |
|
6784 |
+ var _this = this; |
|
6785 |
+ return this.nodes.some(function (node_) { return _this.equality(node, node_); }); |
|
6786 |
+ }; |
|
6787 |
+ /** |
|
6788 |
+ * @desc [accessor] |
|
6789 |
+ * @author fenris |
|
6790 |
+ */ |
|
6791 |
+ class_graph.prototype.outgoing = function (node) { |
|
6792 |
+ var _this = this; |
|
6793 |
+ return this.edges.filter(function (edge) { return _this.equality(edge.from, node); }); |
|
6794 |
+ }; |
|
6795 |
+ /** |
|
6796 |
+ * @desc [accessor] |
|
6797 |
+ * @author fenris |
|
6798 |
+ */ |
|
6799 |
+ class_graph.prototype.incoming = function (node) { |
|
6800 |
+ var _this = this; |
|
6801 |
+ return this.edges.filter(function (edge) { return _this.equality(edge.to, node); }); |
|
6802 |
+ }; |
|
6803 |
+ /** |
|
6804 |
+ * @desc [accessor] |
|
6805 |
+ * @author fenris |
|
6806 |
+ */ |
|
6807 |
+ class_graph.prototype.without = function (pivot) { |
|
6808 |
+ var _this = this; |
|
6809 |
+ return (new class_graph(this.equality, this.nodes.filter(function (node) { return (!_this.equality(node, pivot)); }), this.edges.filter(function (edge) { return ((!_this.equality(edge.from, pivot)) && (!_this.equality(edge.to, pivot))); }))); |
|
6810 |
+ }; |
|
6811 |
+ /** |
|
6812 |
+ * @desc [accessor] returns the topologic sorting of the nodes (if it exists) |
|
6813 |
+ * @author fenris |
|
6814 |
+ */ |
|
6815 |
+ class_graph.prototype.topsort = function () { |
|
6816 |
+ var _this = this; |
|
6817 |
+ var graph = this; |
|
6818 |
+ if (graph.nodes.length == 0) { |
|
6819 |
+ return []; |
|
5119 | 6820 |
} |
5120 |
- lib_file.read_json = read_json; |
|
6821 |
+ else { |
|
6822 |
+ var pivot_1; |
|
6823 |
+ var found = graph.nodes.some(function (node) { |
|
6824 |
+ var count = graph.edges.filter(function (edge) { return _this.equality(edge.to, node); }).length; |
|
6825 |
+ if (count == 0) { |
|
6826 |
+ pivot_1 = node; |
|
6827 |
+ return true; |
|
6828 |
+ } |
|
6829 |
+ else { |
|
6830 |
+ // console.info("'" + String(node) + "' has " + count.toString() + " incoming edges"); |
|
6831 |
+ return false; |
|
6832 |
+ } |
|
6833 |
+ }); |
|
6834 |
+ if (found) { |
|
6835 |
+ return [pivot_1].concat(graph.without(pivot_1).topsort()); |
|
6836 |
+ } |
|
6837 |
+ else { |
|
6838 |
+ throw (new Error("circular dependencies found")); |
|
6839 |
+ } |
|
6840 |
+ } |
|
6841 |
+ }; |
|
5121 | 6842 |
/** |
6843 |
+ * @desc [accessor] returns the reduced version of a graph representing an order relation (implicit transitivity) |
|
5122 | 6844 |
* @author fenris |
5123 | 6845 |
*/ |
5124 |
- function write_json(path, data) { |
|
5125 |
- return instance.write_json(path, data); |
|
6846 |
+ class_graph.prototype.hasse = function () { |
|
6847 |
+ var _this = this; |
|
6848 |
+ return (new class_graph(this.equality, this.nodes, this.edges.filter(function (edge) { |
|
6849 |
+ var reachable = (_this.outgoing(edge.from).map(function (edge_) { return edge_.to; }) |
|
6850 |
+ .map(function (node) { return _this.outgoing(node).map(function (edge_) { return edge_.to; }); }) |
|
6851 |
+ .reduce(function (x, y) { return x.concat(y); }, [])); |
|
6852 |
+ return (!reachable.some(function (node) { return _this.equality(node, edge.to); })); |
|
6853 |
+ }))); |
|
6854 |
+ }; |
|
6855 |
+ /** |
|
6856 |
+ * @author fenris |
|
6857 |
+ */ |
|
6858 |
+ class_graph.prototype.output_dot = function (_a) { |
|
6859 |
+ var _this = this; |
|
6860 |
+ var _b = _a === void 0 ? {} : _a, _c = _b["extract_id"], extract_id = _c === void 0 ? null : _c, _d = _b["extract_label"], extract_label = _d === void 0 ? null : _d; |
|
6861 |
+ var index = function (node) { |
|
6862 |
+ var i = -1; |
|
6863 |
+ var found = _this.nodes.some(function (node_, i_) { |
|
6864 |
+ if (_this.equality(node, node_)) { |
|
6865 |
+ i = i_; |
|
6866 |
+ return true; |
|
5126 | 6867 |
} |
5127 |
- lib_file.write_json = write_json; |
|
5128 |
-})(lib_file || (lib_file = {})); |
|
6868 |
+ else { |
|
6869 |
+ return false; |
|
6870 |
+ } |
|
6871 |
+ }); |
|
6872 |
+ return i; |
|
6873 |
+ }; |
|
6874 |
+ if (extract_id == null) { |
|
6875 |
+ // instance_hash |
|
6876 |
+ extract_id = (function (node) { return index(node).toFixed(0); }); |
|
6877 |
+ } |
|
6878 |
+ if (extract_label == null) { |
|
6879 |
+ extract_label = instance_show; |
|
6880 |
+ } |
|
6881 |
+ var nodeid = function (node) { |
|
6882 |
+ return ("node_" + extract_id(node)); |
|
6883 |
+ }; |
|
6884 |
+ return (lib_dot.generate({ |
|
6885 |
+ "common": { |
|
6886 |
+ "fontname": "Monospace" |
|
6887 |
+ }, |
|
6888 |
+ "nodes": { |
|
6889 |
+ "head": { |
|
6890 |
+ "fontname": "Monospace", |
|
6891 |
+ "style": "filled", |
|
6892 |
+ "fillcolor": "0.35+0.6+0.8" |
|
6893 |
+ }, |
|
6894 |
+ "list": this.nodes_get() |
|
6895 |
+ .map(function (node, index) { |
|
6896 |
+ return { |
|
6897 |
+ "id": nodeid(node), |
|
6898 |
+ "attributes": { |
|
6899 |
+ "label": extract_label(node) |
|
6900 |
+ } |
|
6901 |
+ }; |
|
6902 |
+ }) |
|
6903 |
+ }, |
|
6904 |
+ "edges": { |
|
6905 |
+ "head": { |
|
6906 |
+ "fontname": "Monospace" |
|
6907 |
+ }, |
|
6908 |
+ "list": this.edges_get() |
|
6909 |
+ .map(function (edge, index) { |
|
6910 |
+ return { |
|
6911 |
+ "id_from": nodeid(edge.from), |
|
6912 |
+ "id_to": nodeid(edge.to), |
|
6913 |
+ "attributes": {} |
|
6914 |
+ }; |
|
6915 |
+ }) |
|
6916 |
+ } |
|
6917 |
+ })); |
|
6918 |
+ }; |
|
6919 |
+ return class_graph; |
|
6920 |
+ }()); |
|
6921 |
+ lib_structures.class_graph = class_graph; |
|
6922 |
+})(lib_structures || (lib_structures = {})); |
|
5129 | 6923 |
var lib_args; |
5130 | 6924 |
(function (lib_args) { |
5131 | 6925 |
/** |
... | ... |
@@ -5672,21 +7466,11 @@ var lib_args; |
5672 | 7466 |
} |
5673 | 7467 |
return output; |
5674 | 7468 |
}; |
5675 |
- return class_handler; |
|
5676 |
- }()); |
|
5677 |
- lib_args.class_handler = class_handler; |
|
5678 |
-})(lib_args || (lib_args = {})); |
|
5679 |
- |
|
5680 |
-var __extends = (this && this.__extends) || (function () { |
|
5681 |
- var extendStatics = Object.setPrototypeOf || |
|
5682 |
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
5683 |
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; |
|
5684 |
- return function (d, b) { |
|
5685 |
- extendStatics(d, b); |
|
5686 |
- function __() { this.constructor = d; } |
|
5687 |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
5688 |
- }; |
|
5689 |
-})(); |
|
7469 |
+ return class_handler; |
|
7470 |
+ }()); |
|
7471 |
+ lib_args.class_handler = class_handler; |
|
7472 |
+})(lib_args || (lib_args = {})); |
|
7473 |
+ |
|
5690 | 7474 |
var nm_child_process = require("child_process"); |
5691 | 7475 |
var nm_fs = require("fs"); |
5692 | 7476 |
/** |
... | ... |
@@ -5709,7 +7493,7 @@ function dirwrap(location, core) { |
5709 | 7493 |
return core; |
5710 | 7494 |
} |
5711 | 7495 |
else { |
5712 |
- return "cd " + location.as_string(globalvars.configuration.system) + " > /dev/null && " + core + " ; cd - > /dev/null"; |
|
7496 |
+ return `cd ${location.as_string(globalvars.configuration.system)} > /dev/null && ${core} ; cd - > /dev/null`; |
|
5713 | 7497 |
} |
5714 | 7498 |
} |
5715 | 7499 |
/** |
... | ... |
@@ -5721,8 +7505,7 @@ function filepointer_adjust(filepointer, location) { |
5721 | 7505 |
/** |
5722 | 7506 |
* @author fenris |
5723 | 7507 |
*/ |
5724 |
-function path_augment(path, step, aggregate) { |
|
5725 |
- if (aggregate === void 0) { aggregate = true; } |
|
7508 |
+function path_augment(path, step, aggregate = true) { |
|
5726 | 7509 |
if (aggregate) { |
5727 | 7510 |
return path.concat([step]); |
5728 | 7511 |
} |
... | ... |
@@ -5739,12 +7522,11 @@ function path_dump(path) { |
5739 | 7522 |
/** |
5740 | 7523 |
* @author fenris |
5741 | 7524 |
*/ |
5742 |
-var class_message = (function () { |
|
7525 |
+class class_message { |
|
5743 | 7526 |
/** |
5744 | 7527 |
* @author fenris |
5745 | 7528 |
*/ |
5746 |
- function class_message(content, parameters) { |
|
5747 |
- if (parameters === void 0) { parameters = {}; } |
|
7529 |
+ constructor(content, parameters = {}) { |
|
5748 | 7530 |
/** |
5749 | 7531 |
* @author fenris |
5750 | 7532 |
*/ |
... | ... |
@@ -5758,9 +7540,8 @@ var class_message = (function () { |
5758 | 7540 |
/** |
5759 | 7541 |
* @author fenris |
5760 | 7542 |
*/ |
5761 |
- class_message.prototype.generate = function (with_type) { |
|
5762 |
- if (with_type === void 0) { with_type = true; } |
|
5763 |
- var output = ""; |
|
7543 |
+ generate(with_type = true) { |
|
7544 |
+ let output = ""; |
|
5764 | 7545 |
if (with_type) { |
5765 | 7546 |
if (this.type != null) { |
5766 | 7547 |
output += ("[" + this.type + "]" + " "); |
... | ... |
@@ -5775,23 +7556,23 @@ var class_message = (function () { |
5775 | 7556 |
output += "\n"; |
5776 | 7557 |
} |
5777 | 7558 |
return output; |
5778 |
- }; |
|
7559 |
+ } |
|
5779 | 7560 |
/** |
5780 | 7561 |
* @author fenris |
5781 | 7562 |
*/ |
5782 |
- class_message.prototype.stdout = function () { |
|
7563 |
+ stdout() { |
|
5783 | 7564 |
console.log(this.generate(true)); |
5784 |
- }; |
|
7565 |
+ } |
|
5785 | 7566 |
/** |
5786 | 7567 |
* @author fenris |
5787 | 7568 |
*/ |
5788 |
- class_message.prototype.stderr = function () { |
|
7569 |
+ stderr() { |
|
5789 | 7570 |
console.error(this.generate(true)); |
5790 |
- }; |
|
7571 |
+ } |
|
5791 | 7572 |
/** |
5792 | 7573 |
* @author fenris |
5793 | 7574 |
*/ |
5794 |
- class_message.prototype.console = function () { |
|
7575 |
+ console() { |
|
5795 | 7576 |
switch (this.type) { |
5796 | 7577 |
case "log": { |
5797 | 7578 |
console.log(this.generate(false)); |
... | ... |
@@ -5813,188 +7594,49 @@ var class_message = (function () { |
5813 | 7594 |
throw (new Error("unhandled type '" + this.type + "'")); |
5814 | 7595 |
} |
5815 | 7596 |
} |
5816 |
- }; |
|
5817 |
- return class_message; |
|
5818 |
-}()); |
|
7597 |
+ } |
|
7598 |
+} |
|
5819 | 7599 |
/** |
5820 | 7600 |
* @author fenris |
5821 | 7601 |
*/ |
5822 |
-var class_cliout = (function () { |
|
5823 |
- function class_cliout() { |
|
5824 |
- } |
|
7602 |
+class class_cliout { |
|
5825 | 7603 |
/** |
5826 | 7604 |
* @author fenris |
5827 | 7605 |
*/ |
5828 |
- class_cliout.stdout = function (content, depth) { |
|
5829 |
- if (depth === void 0) { depth = 0; } |
|
7606 |
+ static stdout(content, depth = 0) { |
|
5830 | 7607 |
console.log(lib_string.repeat("\t", depth) + content); |
5831 |
- }; |
|
7608 |
+ } |
|
5832 | 7609 |
/** |
5833 | 7610 |
* @author fenris |
5834 | 7611 |
*/ |
5835 |
- class_cliout.stderr = function (content, depth) { |
|
5836 |
- if (depth === void 0) { depth = 0; } |
|
7612 |
+ static stderr(content, depth = 0) { |
|
5837 | 7613 |
console.error(lib_string.repeat("\t", depth) + content); |
5838 |
- }; |
|
7614 |
+ } |
|
5839 | 7615 |
/** |
5840 | 7616 |
* @author fenris |
5841 | 7617 |
*/ |
5842 |
- class_cliout.log = function (content, depth) { |
|
5843 |
- if (depth === void 0) { depth = 0; } |
|
7618 |
+ static log(content, depth = 0) { |
|
5844 | 7619 |
this.stderr("-- " + content, depth); |
5845 |
- }; |
|
5846 |
- /** |
|
5847 |
- * @author fenris |
|
5848 |
- */ |
|
5849 |
- class_cliout.info = function (content, depth) { |
|
5850 |
- if (depth === void 0) { depth = 0; } |
|
5851 |
- this.stderr(">> " + content, depth); |
|
5852 |
- }; |
|
5853 |
- /** |
|
5854 |
- * @author fenris |
|
5855 |
- */ |
|
5856 |
- class_cliout.warn = function (content, depth) { |
|
5857 |
- if (depth === void 0) { depth = 0; } |
|
5858 |
- this.stderr(">> " + content, depth); |
|
5859 |
- }; |
|
7620 |
+ } |
|
5860 | 7621 |
/** |
5861 | 7622 |
* @author fenris |
5862 | 7623 |
*/ |
5863 |
- class_cliout.error = function (content, depth) { |
|
5864 |
- if (depth === void 0) { depth = 0; } |
|
7624 |
+ static info(content, depth = 0) { |
|
5865 | 7625 |
this.stderr(">> " + content, depth); |
5866 |
- }; |
|
5867 |
- return class_cliout; |
|
5868 |
-}()); |
|
5869 |
-/** |
|
5870 |
- * @author fenris |
|
5871 |
- */ |
|
5872 |
-var class_graph = (function () { |
|
5873 |
- /** |
|
5874 |
- * @author fenris |
|
5875 |
- */ |
|
5876 |
- function class_graph(equality, nodes, edges) { |
|
5877 |
- if (equality === void 0) { equality = (function (node1, node2) { return (node1 == node2); }); } |
|
5878 |
- if (nodes === void 0) { nodes = []; } |
|
5879 |
- if (edges === void 0) { edges = []; } |
|
5880 |
- /** |
|
5881 |
- * @author fenris |
|
5882 |
- */ |
|
5883 |
- this.equality = (function (node1, node2) { return (node1 == node2); }); |
|
5884 |
- this.equality = equality; |
|
5885 |
- this.nodes = nodes; |
|
5886 |
- this.edges = edges; |
|
5887 | 7626 |
} |
5888 |
- /** |
|
5889 |
- * @author frac |
|
5890 |
- */ |
|
5891 |
- class_graph.prototype.has = function (node) { |
|
5892 |
- var _this = this; |
|
5893 |
- return this.nodes.some(function (node_) { return _this.equality(node, node_); }); |
|
5894 |
- }; |
|
5895 |
- /** |
|
5896 |
- * @author fenris |
|
5897 |
- */ |
|
5898 |
- class_graph.prototype.without = function (pivot) { |
|
5899 |
- var _this = this; |
|
5900 |
- return (new class_graph(this.equality, this.nodes.filter(function (node) { return (!_this.equality(node, pivot)); }), this.edges.filter(function (edge) { return ((!_this.equality(edge.from, pivot)) && (!_this.equality(edge.to, pivot))); }))); |
|
5901 |
- }; |
|
5902 |
- /** |
|
5903 |
- * @author fenris |
|
5904 |
- */ |
|
5905 |
- class_graph.prototype.outgoing = function (node) { |
|
5906 |
- var _this = this; |
|
5907 |
- return this.edges.filter(function (edge) { return _this.equality(edge.from, node); }); |
|
5908 |
- }; |
|
5909 |
- /** |
|
5910 |
- * @author fenris |
|
5911 |
- */ |
|
5912 |
- class_graph.prototype.incoming = function (node) { |
|
5913 |
- var _this = this; |
|
5914 |
- return this.edges.filter(function (edge) { return _this.equality(edge.to, node); }); |
|
5915 |
- }; |
|
5916 | 7627 |
/** |
5917 | 7628 |
* @author fenris |
5918 | 7629 |
*/ |
5919 |
- class_graph.prototype.topsort = function () { |
|
5920 |
- var _this = this; |
|
5921 |
- var graph = this; |
|
5922 |
- if (graph.nodes.length == 0) { |
|
5923 |
- return []; |
|
5924 |
- } |
|
5925 |
- else { |
|
5926 |
- var pivot_1; |
|
5927 |
- var found = graph.nodes.some(function (node) { |
|
5928 |
- var count = graph.edges.filter(function (edge) { return _this.equality(edge.to, node); }).length; |
|
5929 |
- if (count == 0) { |
|
5930 |
- pivot_1 = node; |
|
5931 |
- return true; |
|
5932 |
- } |
|
5933 |
- else { |
|
5934 |
- // console.info("'" + String(node) + "' has " + count.toString() + " incoming edges"); |
|
5935 |
- return false; |
|
5936 |
- } |
|
5937 |
- }); |
|
5938 |
- if (found) { |
|
5939 |
- return [pivot_1].concat(graph.without(pivot_1).topsort()); |
|
5940 |
- } |
|
5941 |
- else { |
|
5942 |
- throw (new Error("circular dependencies found")); |
|
5943 |
- } |
|
7630 |
+ static warn(content, depth = 0) { |
|
7631 |
+ this.stderr(">> " + content, depth); |
|
5944 | 7632 |
} |
5945 |
- }; |
|
5946 |
- /** |
|
5947 |
- * @author fenris |
|
5948 |
- */ |
|
5949 |
- class_graph.prototype.hasse = function () { |
|
5950 |
- var _this = this; |
|
5951 |
- return (new class_graph(this.equality, this.nodes, this.edges.filter(function (edge) { |
|
5952 |
- var reachable = (_this.outgoing(edge.from).map(function (edge_) { return edge_.to; }) |
|
5953 |
- .map(function (node) { return _this.outgoing(node).map(function (edge_) { return edge_.to; }); }) |
|
5954 |
- .reduce(function (x, y) { return x.concat(y); }, [])); |
|
5955 |
- return (!reachable.some(function (node) { return _this.equality(node, edge.to); })); |
|
5956 |
- }))); |
|
5957 |
- }; |
|
5958 | 7633 |
/** |
5959 | 7634 |
* @author fenris |
5960 | 7635 |
*/ |
5961 |
- class_graph.prototype.output_graphviz = function (extract_label) { |
|
5962 |
- if (extract_label === void 0) { extract_label = (function (node) { return String(node); }); } |
|
5963 |
- var that = this; |
|
5964 |
- function get_nodeindex(node) { |
|
5965 |
- // return that.nodes.findIndex(node_ => that.equality(node, node_)); |
|
5966 |
- var index; |
|
5967 |
- for (var index_1 = 0; index_1 < that.nodes.length; ++index_1) { |
|
5968 |
- if (that.equality(node, that.nodes[index_1])) { |
|
5969 |
- return index_1; |
|
5970 |
- } |
|
5971 |
- } |
|
5972 |
- return undefined; |
|
5973 |
- } |
|
5974 |
- function nodeid(node) { |
|
5975 |
- return "x_" + get_nodeindex(node).toString(); |
|
5976 |
- } |
|
5977 |
- function nodelist() { |
|
5978 |
- return (["\tnode [fontname=\"Monospace\", style=\"filled\", fillcolor=\"0.4+0.8+0.8\"];\n"] |
|
5979 |
- .concat(that.nodes |
|
5980 |
- .map(function (node, index) { |
|
5981 |
- return "\t" + nodeid(node) + " [label=\"" + extract_label(node) + "\"];\n"; |
|
5982 |
- })) |
|
5983 |
- .join("")); |
|
7636 |
+ static error(content, depth = 0) { |
|
7637 |
+ this.stderr(">> " + content, depth); |
|
5984 | 7638 |
} |
5985 |
- function edgelist() { |
|
5986 |
- return (["\tedge [fontname=\"Monospace\"];\n"] |
|
5987 |
- .concat(that.edges |
|
5988 |
- .map(function (edge, index) { |
|
5989 |
- return "\t" + nodeid(edge.from) + " -> " + nodeid(edge.to) + " [];\n"; |
|
5990 |
- })) |
|
5991 |
- .join("")); |
|
5992 | 7639 |
} |
5993 |
- var output = "digraph\n{\n\tgraph [fontname=\"Monospace\"];\n" + nodelist() + "\n" + edgelist() + "\n}\n"; |
|
5994 |
- return output; |
|
5995 |
- }; |
|
5996 |
- return class_graph; |
|
5997 |
-}()); |
|
5998 | 7640 |
/** |
5999 | 7641 |
* @author fenris |
6000 | 7642 |
*/ |
... | ... |
@@ -6003,55 +7645,54 @@ var lib_gnumake; |
6003 | 7645 |
/** |
6004 | 7646 |
* @author fenris |
6005 | 7647 |
*/ |
6006 |
- function macro_command(_a) { |
|
6007 |
- var _b = _a["interpreter"], interpreter = _b === void 0 ? null : _b, path = _a["path"], _c = _a["args"], args = _c === void 0 ? [] : _c, _d = _a["output"], output = _d === void 0 ? null : _d, _e = _a["system"], system = _e === void 0 ? "linux" : _e; |
|
7648 |
+ function macro_command({ "interpreter": interpreter = null, "path": path, "args": args = [], "output": output = null, "system": system = "linux", }) { |
|
6008 | 7649 |
switch (system) { |
6009 | 7650 |
case "bsd": |
6010 | 7651 |
case "linux": { |
6011 |
- var command = path; |
|
7652 |
+ let command = path; |
|
6012 | 7653 |
{ |
6013 | 7654 |
if (interpreter != null) { |
6014 |
- command = interpreter + " " + command; |
|
7655 |
+ command = `${interpreter} ${command}`; |
|
6015 | 7656 |
} |
6016 | 7657 |
} |
6017 | 7658 |
{ |
6018 |
- var parts_1 = []; |
|
6019 |
- args.forEach(function (arg) { return parts_1.push(arg); }); |
|
6020 |
- command = command + " " + parts_1.join(" "); |
|
7659 |
+ let parts = []; |
|
7660 |
+ args.forEach(arg => parts.push(arg)); |
|
7661 |
+ command = `${command} ${parts.join(" ")}`; |
|
6021 | 7662 |
} |
6022 | 7663 |
{ |
6023 | 7664 |
if (output != null) { |
6024 |
- command = command + " > " + output; |
|
7665 |
+ command = `${command} > ${output}`; |
|
6025 | 7666 |
} |
6026 | 7667 |
} |
6027 | 7668 |
return command; |
6028 | 7669 |
break; |
6029 | 7670 |
} |
6030 | 7671 |
case "win": { |
6031 |
- var command = "cmd //c"; |
|
7672 |
+ let command = "cmd //c"; |
|
6032 | 7673 |
{ |
6033 |
- command = command + " " + path; |
|
7674 |
+ command = `${command} ${path}`; |
|
6034 | 7675 |
} |
6035 | 7676 |
{ |
6036 | 7677 |
if (interpreter != null) { |
6037 |
- command = command + " " + interpreter; |
|
7678 |
+ command = `${command} ${interpreter}`; |
|
6038 | 7679 |
} |
6039 | 7680 |
} |
6040 | 7681 |
{ |
6041 |
- var parts_2 = []; |
|
6042 |
- args.forEach(function (arg) { return parts_2.push(arg); }); |
|
6043 |
- command = command + " " + parts_2.join(" "); |
|
7682 |
+ let parts = []; |
|
7683 |
+ args.forEach(arg => parts.push(arg)); |
|
7684 |
+ command = `${command} ${parts.join(" ")}`; |
|
6044 | 7685 |
} |
6045 | 7686 |
{ |
6046 | 7687 |
if (output != null) { |
6047 |
- command = command + " > " + output; |
|
7688 |
+ command = `${command} > ${output}`; |
|
6048 | 7689 |
} |
6049 | 7690 |
} |
6050 | 7691 |
return command; |
6051 | 7692 |
break; |
6052 | 7693 |
} |
6053 | 7694 |
default: { |
6054 |
- throw (new Error("unhandled system '" + system + "'")); |
|
7695 |
+ throw (new Error(`unhandled system '${system}'`)); |
|
6055 | 7696 |
break; |
6056 | 7697 |
} |
6057 | 7698 |
} |
... | ... |
@@ -6060,13 +7701,12 @@ var lib_gnumake; |
6060 | 7701 |
/** |
6061 | 7702 |
* @author fenris |
6062 | 7703 |
*/ |
6063 |
- var class_rule = (function () { |
|
7704 |
+ class class_rule { |
|
6064 | 7705 |
/** |
6065 | 7706 |
* @author fenris |
6066 | 7707 |
*/ |
6067 | 7708 |
// public constructor(name : string, dependencies : Array<string>, actions : Array<string>, phony : boolean = false) { |
6068 |
- function class_rule(parameters) { |
|
6069 |
- if (parameters === void 0) { parameters = {}; } |
|
7709 |
+ constructor(parameters = {}) { |
|
6070 | 7710 |
this.name = object_fetch(parameters, "name", null, 2); |
6071 | 7711 |
this.dependencies = object_fetch(parameters, "dependencies", [], 0); |
6072 | 7712 |
this.actions = object_fetch(parameters, "actions", [], 0); |
... | ... |
@@ -6075,50 +7715,45 @@ var lib_gnumake; |
6075 | 7715 |
/** |
6076 | 7716 |
* @author fenris |
6077 | 7717 |
*/ |
6078 |
- class_rule.prototype.actions_get = function () { |
|
7718 |
+ actions_get() { |
|
6079 | 7719 |
return this.actions; |
6080 |
- }; |
|
7720 |
+ } |
|
6081 | 7721 |
/** |
6082 | 7722 |
* @author fenris |
6083 | 7723 |
*/ |
6084 |
- class_rule.prototype.compile = function (silent) { |
|
6085 |
- if (silent === void 0) { silent = false; } |
|
6086 |
- var output = ""; |
|
6087 |
- output += (this.name + ": " + this.dependencies.map(function (dependency) { return (" " + dependency); }).join("") + "\n"); |
|
6088 |
- this.actions.forEach(function (action) { return (output += "\t" + (silent ? "@ " : "") + action + "\n"); }); |
|
7724 |
+ compile(silent = false) { |
|
7725 |
+ let output = ""; |
|
7726 |
+ output += (`${this.name}: ${this.dependencies.map(dependency => (" " + dependency)).join("")}\n`); |
|
7727 |
+ this.actions.forEach(action => (output += `\t${(silent ? "@ " : "")}${action}\n`)); |
|
6089 | 7728 |
if (this.phony) { |
6090 |
- output += (".PHONY: " + this.name + "\n"); |
|
7729 |
+ output += (`.PHONY: ${this.name}\n`); |
|
6091 | 7730 |
} |
6092 | 7731 |
return output; |
6093 |
- }; |
|
6094 |
- return class_rule; |
|
6095 |
- }()); |
|
7732 |
+ } |
|
7733 |
+ } |
|
6096 | 7734 |
lib_gnumake.class_rule = class_rule; |
6097 | 7735 |
/** |
6098 | 7736 |
* @author fenris |
6099 | 7737 |
*/ |
6100 |
- var class_sheet = (function () { |
|
7738 |
+ class class_sheet { |
|
6101 | 7739 |
/** |
6102 | 7740 |
* @author fenris |
6103 | 7741 |
*/ |
6104 |
- function class_sheet(rules, comments) { |
|
6105 |
- if (comments === void 0) { comments = []; } |
|
7742 |
+ constructor(rules, comments = []) { |
|
6106 | 7743 |
this.rules = rules; |
6107 | 7744 |
this.comments = comments; |
6108 | 7745 |
} |
6109 | 7746 |
/** |
6110 | 7747 |
* @author fenris |
6111 | 7748 |
*/ |
6112 |
- class_sheet.prototype.compile = function (silent) { |
|
6113 |
- if (silent === void 0) { silent = false; } |
|
7749 |
+ compile(silent = false) { |
|
6114 | 7750 |
return ([] |
6115 |
- .concat(this.comments.map(function (comment) { return ("# " + comment); })) |
|
7751 |
+ .concat(this.comments.map(comment => ("# " + comment))) |
|
6116 | 7752 |
.concat([""]) |
6117 |
- .concat(this.rules.map(function (rule) { return rule.compile(silent); })) |
|
7753 |
+ .concat(this.rules.map(rule => rule.compile(silent))) |
|
6118 | 7754 |
.join("\n")); |
6119 |
- }; |
|
6120 |
- return class_sheet; |
|
6121 |
- }()); |
|
7755 |
+ } |
|
7756 |
+ } |
|
6122 | 7757 |
lib_gnumake.class_sheet = class_sheet; |
6123 | 7758 |
})(lib_gnumake || (lib_gnumake = {})); |
6124 | 7759 |
/** |
... | ... |
@@ -6129,48 +7764,46 @@ var lib_ant; |
6129 | 7764 |
/** |
6130 | 7765 |
* @author fenris |
6131 | 7766 |
*/ |
6132 |
- var class_comment = (function () { |
|
7767 |
+ class class_comment { |
|
6133 | 7768 |
/** |
6134 | 7769 |
* @author fenris |
6135 | 7770 |
*/ |
6136 |
- function class_comment(content) { |
|
7771 |
+ constructor(content) { |
|
6137 | 7772 |
this.content = content; |
6138 | 7773 |
} |
6139 | 7774 |
/** |
6140 | 7775 |
* @author fenris |
6141 | 7776 |
*/ |
6142 |
- class_comment.prototype.compile = function () { |
|
7777 |
+ compile() { |
|
6143 | 7778 |
return (new lib_xml.class_node_comment(this.content)); |
6144 |
- }; |
|
6145 |
- return class_comment; |
|
6146 |
- }()); |
|
7779 |
+ } |
|
7780 |
+ } |
|
6147 | 7781 |
lib_ant.class_comment = class_comment; |
6148 | 7782 |
/** |
6149 | 7783 |
* @author fenris |
6150 | 7784 |
*/ |
6151 |
- var class_action = (function () { |
|
7785 |
+ class class_action { |
|
6152 | 7786 |
/** |
6153 | 7787 |
* @author fenris |
6154 | 7788 |
*/ |
6155 |
- function class_action(representation) { |
|
7789 |
+ constructor(representation) { |
|
6156 | 7790 |
this.representation = representation; |
6157 | 7791 |
} |
6158 | 7792 |
/** |
6159 | 7793 |
* @author fenris |
6160 | 7794 |
*/ |
6161 |
- class_action.prototype.compile = function () { |
|
7795 |
+ compile() { |
|
6162 | 7796 |
return this.representation; |
6163 |
- }; |
|
7797 |
+ } |
|
6164 | 7798 |
/** |
6165 | 7799 |
* @author fenris |
6166 | 7800 |
*/ |
6167 |
- class_action.macro_exec = function (_a) { |
|
6168 |
- var _b = _a["interpreter"], interpreter = _b === void 0 ? null : _b, path = _a["path"], _c = _a["args"], args = _c === void 0 ? [] : _c, _d = _a["output"], output = _d === void 0 ? null : _d, _e = _a["system"], system = _e === void 0 ? "linux" : _e; |
|
7801 |
+ static macro_exec({ "interpreter": interpreter = null, "path": path, "args": args = [], "output": output = null, "system": system = "linux", }) { |
|
6169 | 7802 |
switch (system) { |
6170 | 7803 |
case "linux": |
6171 | 7804 |
case "bsd": { |
6172 |
- var attributes = {}; |
|
6173 |
- var args_ = []; |
|
7805 |
+ let attributes = {}; |
|
7806 |
+ let args_ = []; |
|
6174 | 7807 |
if (interpreter == null) { |
6175 | 7808 |
attributes["executable"] = path; |
6176 | 7809 |
} |
... | ... |
@@ -6182,12 +7815,12 @@ var lib_ant; |
6182 | 7815 |
attributes["output"] = output; |
6183 | 7816 |
} |
6184 | 7817 |
args_ = args_.concat(args); |
6185 |
- return (new lib_ant.class_action(new lib_xml.class_node_complex("exec", attributes, args_.map(function (arg) { return new lib_xml.class_node_complex("arg", { "value": arg }); })))); |
|
7818 |
+ return (new lib_ant.class_action(new lib_xml.class_node_complex("exec", attributes, args_.map(arg => new lib_xml.class_node_complex("arg", { "value": arg }))))); |
|
6186 | 7819 |
break; |
6187 | 7820 |
} |
6188 | 7821 |
case "win": { |
6189 |
- var attributes = {}; |
|
6190 |
- var args_ = []; |
|
7822 |
+ let attributes = {}; |
|
7823 |
+ let args_ = []; |
|
6191 | 7824 |
attributes["executable"] = "cmd"; |
6192 | 7825 |
args_.push("/c"); |
6193 | 7826 |
if (interpreter == null) { |
... | ... |
@@ -6200,31 +7833,29 @@ var lib_ant; |
6200 | 7833 |
if (output != null) { |
6201 | 7834 |
attributes["output"] = output; |
6202 | 7835 |
} |
6203 |
- return (new lib_ant.class_action(new lib_xml.class_node_complex("exec", attributes, args_.map(function (arg) { return new lib_xml.class_node_complex("arg", { "value": arg }); })))); |
|
7836 |
+ return (new lib_ant.class_action(new lib_xml.class_node_complex("exec", attributes, args_.map(arg => new lib_xml.class_node_complex("arg", { "value": arg }))))); |
|
6204 | 7837 |
break; |
6205 | 7838 |
} |
6206 | 7839 |
default: { |
6207 |
- throw (new Error("unhandled system " + system)); |
|
7840 |
+ throw (new Error(`unhandled system ${system}`)); |
|
6208 | 7841 |
break; |
6209 | 7842 |
} |
6210 | 7843 |
} |
6211 |
- }; |
|
7844 |
+ } |
|
6212 | 7845 |
/** |
6213 | 7846 |
* @author fenris |
6214 | 7847 |
*/ |
6215 |
- class_action.macro_command = function (cmdparams) { return this.macro_exec(cmdparams); }; |
|
6216 |
- return class_action; |
|
6217 |
- }()); |
|
7848 |
+ static macro_command(cmdparams) { return this.macro_exec(cmdparams); } |
|
7849 |
+ } |
|
6218 | 7850 |
lib_ant.class_action = class_action; |
6219 | 7851 |
/** |
6220 | 7852 |
* @author fenris |
6221 | 7853 |
*/ |
6222 |
- var class_target = (function () { |
|
7854 |
+ class class_target { |
|
6223 | 7855 |
/** |
6224 | 7856 |
* @author fenris |
6225 | 7857 |
*/ |
6226 |
- function class_target(parameters) { |
|
6227 |
- if (parameters === void 0) { parameters = {}; } |
|
7858 |
+ constructor(parameters = {}) { |
|
6228 | 7859 |
this.name = object_fetch(parameters, "name", null, 2); |
6229 | 7860 |
this.dependencies = object_fetch(parameters, "dependencies", [], 1); |
6230 | 7861 |
this.actions = object_fetch(parameters, "actions", [], 0); |
... | ... |
@@ -6232,30 +7863,28 @@ var lib_ant; |
6232 | 7863 |
/** |
6233 | 7864 |
* @author fenris |
6234 | 7865 |
*/ |
6235 |
- class_target.prototype.actions_get = function () { |
|
7866 |
+ actions_get() { |
|
6236 | 7867 |
return this.actions; |
6237 |
- }; |
|
7868 |
+ } |
|
6238 | 7869 |
/** |
6239 | 7870 |
* @author fenris |
6240 | 7871 |
*/ |
6241 |
- class_target.prototype.compile = function () { |
|
7872 |
+ compile() { |
|
6242 | 7873 |
return (new lib_xml.class_node_complex("target", { |
6243 | 7874 |
"name": this.name, |
6244 | 7875 |
"depends": this.dependencies.join(",") |
6245 |
- }, this.actions.map(function (action) { return action.compile(); }))); |
|
6246 |
- }; |
|
6247 |
- return class_target; |
|
6248 |
- }()); |
|
7876 |
+ }, this.actions.map(action => action.compile()))); |
|
7877 |
+ } |
|
7878 |
+ } |
|
6249 | 7879 |
lib_ant.class_target = class_target; |
6250 | 7880 |
/** |
6251 | 7881 |
* @author fenris |
6252 | 7882 |
*/ |
6253 |
- var class_project = (function () { |
|
7883 |
+ class class_project { |
|
6254 | 7884 |
/** |
6255 | 7885 |
* @author fenris |
6256 | 7886 |
*/ |
6257 |
- function class_project(parameters) { |
|
6258 |
- if (parameters === void 0) { parameters = {}; } |
|
7887 |
+ constructor(parameters = {}) { |
|
6259 | 7888 |
this.name = object_fetch(parameters, "name", null, 2); |
6260 | 7889 |
this.default_ = object_fetch(parameters, "default", null, 2); |
6261 | 7890 |
this.targets = object_fetch(parameters, "targets", [], 1); |
... | ... |
@@ -6264,84 +7893,122 @@ var lib_ant; |
6264 | 7893 |
/** |
6265 | 7894 |
* @author fenris |
6266 | 7895 |
*/ |
6267 |
- class_project.prototype.compile = function () { |
|
7896 |
+ compile() { |
|
6268 | 7897 |
return (new lib_xml.class_node_complex("project", { |
6269 | 7898 |
"name": this.name, |
6270 | 7899 |
"default": this.default_, |
6271 | 7900 |
}, ([] |
6272 |
- .concat(this.comments.map(function (comment) { return comment.compile(); })) |
|
7901 |
+ .concat(this.comments.map(comment => comment.compile())) |
|
6273 | 7902 |
.concat([ |
6274 | 7903 |
new lib_xml.class_node_complex("property", { |
6275 | 7904 |
"environment": "env" |
6276 | 7905 |
}), |
6277 | 7906 |
]) |
6278 |
- .concat(this.targets.map(function (target) { return target.compile(); }))))); |
|
6279 |
- }; |
|
6280 |
- return class_project; |
|
6281 |
- }()); |
|
7907 |
+ .concat(this.targets.map(target => target.compile()))))); |
|
7908 |
+ } |
|
7909 |
+ } |
|
6282 | 7910 |
lib_ant.class_project = class_project; |
6283 | 7911 |
})(lib_ant || (lib_ant = {})); |
7912 |
+var lib_markdown; |
|
7913 |
+(function (lib_markdown) { |
|
7914 |
+ /** |
|
7915 |
+ * @author fenris |
|
7916 |
+ */ |
|
7917 |
+ function italic(content) { |
|
7918 |
+ return ("_" + content + "_"); |
|
7919 |
+ } |
|
7920 |
+ lib_markdown.italic = italic; |
|
6284 | 7921 |
/** |
6285 | 7922 |
* @author fenris |
6286 | 7923 |
*/ |
6287 |
-var class_action = (function () { |
|
7924 |
+ function bold(content) { |
|
7925 |
+ return ("__" + content + "__"); |
|
7926 |
+ } |
|
7927 |
+ lib_markdown.bold = bold; |
|
6288 | 7928 |
/** |
6289 | 7929 |
* @author fenris |
6290 | 7930 |
*/ |
6291 |
- function class_action() { |
|
7931 |
+ function code(content) { |
|
7932 |
+ return ("`" + content + "`"); |
|
6292 | 7933 |
} |
6293 |
- return class_action; |
|
6294 |
-}()); |
|
7934 |
+ lib_markdown.code = code; |
|
6295 | 7935 |
/** |
6296 | 7936 |
* @author fenris |
6297 | 7937 |
*/ |
6298 |
-var class_action_adhoc = (function (_super) { |
|
6299 |
- __extends(class_action_adhoc, _super); |
|
7938 |
+ function section(level, title) { |
|
7939 |
+ return ("#".repeat(level) + " " + title + "\n"); |
|
7940 |
+ } |
|
7941 |
+ lib_markdown.section = section; |
|
6300 | 7942 |
/** |
6301 | 7943 |
* @author fenris |
6302 | 7944 |
*/ |
6303 |
- function class_action_adhoc() { |
|
6304 |
- return _super.call(this) || this; |
|
7945 |
+ function paragraph(content = "") { |
|
7946 |
+ return (content + "\n"); |
|
6305 | 7947 |
} |
6306 |
- return class_action_adhoc; |
|
6307 |
-}(class_action)); |
|
7948 |
+ lib_markdown.paragraph = paragraph; |
|
6308 | 7949 |
/** |
6309 | 7950 |
* @author fenris |
6310 | 7951 |
*/ |
6311 |
-var class_action_exec = (function (_super) { |
|
6312 |
- __extends(class_action_exec, _super); |
|
7952 |
+ function listitem(level, content) { |
|
7953 |
+ return (" ".repeat(level - 1) + "* " + content + "\n"); |
|
7954 |
+ } |
|
7955 |
+ lib_markdown.listitem = listitem; |
|
7956 |
+})(lib_markdown || (lib_markdown = {})); |
|
6313 | 7957 |
/** |
6314 | 7958 |
* @author fenris |
6315 | 7959 |
*/ |
6316 |
- function class_action_exec(_a) { |
|
6317 |
- var inputs = _a["inputs"], outputs = _a["outputs"], path = _a["path"], interpreter = _a["interpreter"], workdir = _a["workdir"]; |
|
6318 |
- var _this = _super.call(this) || this; |
|
6319 |
- _this.paths_input = inputs; |
|
6320 |
- _this.paths_output = outputs; |
|
6321 |
- _this.path_script = path; |
|
6322 |
- _this.path_interpreter = interpreter; |
|
6323 |
- _this.workdir = workdir; |
|
6324 |
- return _this; |
|
7960 |
+class class_action { |
|
7961 |
+ /** |
|
7962 |
+ * @author fenris |
|
7963 |
+ */ |
|
7964 |
+ constructor() { |
|
7965 |
+ } |
|
7966 |
+} |
|
7967 |
+/** |
|
7968 |
+ * @author fenris |
|
7969 |
+ */ |
|
7970 |
+class class_action_adhoc extends class_action { |
|
7971 |
+ /** |
|
7972 |
+ * @author fenris |
|
7973 |
+ */ |
|
7974 |
+ constructor() { |
|
7975 |
+ super(); |
|
7976 |
+ } |
|
7977 |
+} |
|
7978 |
+/** |
|
7979 |
+ * @author fenris |
|
7980 |
+ */ |
|
7981 |
+class class_action_exec extends class_action_adhoc { |
|
7982 |
+ /** |
|
7983 |
+ * @author fenris |
|
7984 |
+ */ |
|
7985 |
+ constructor({ "inputs": inputs, "outputs": outputs, "path": path, "interpreter": interpreter, "workdir": workdir, }) { |
|
7986 |
+ super(); |
|
7987 |
+ this.paths_input = inputs; |
|
7988 |
+ this.paths_output = outputs; |
|
7989 |
+ this.path_script = path; |
|
7990 |
+ this.path_interpreter = interpreter; |
|
7991 |
+ this.workdir = workdir; |
|
6325 | 7992 |
} |
6326 | 7993 |
/** |
6327 | 7994 |
* @desc for defining directly how the action is to be converted into a target-piece |
6328 | 7995 |
* @author fenris |
6329 | 7996 |
*/ |
6330 |
- class_action_exec.prototype.compilation = function (output_identifier) { |
|
7997 |
+ compilation(output_identifier) { |
|
6331 | 7998 |
switch (output_identifier) { |
6332 | 7999 |
case "gnumake": { |
6333 | 8000 |
switch (globalvars.configuration.system) { |
6334 | 8001 |
case "linux": |
6335 | 8002 |
case "bsd": |
6336 | 8003 |
case "win": { |
6337 |
- var command = ""; |
|
8004 |
+ let command = ""; |
|
6338 | 8005 |
{ |
6339 | 8006 |
command = lib_gnumake.macro_command({ |
6340 | 8007 |
"interpreter": ((this.path_interpreter != null) ? this.path_interpreter.as_string(globalvars.configuration.system) : null), |
6341 | 8008 |
"path": this.path_script.as_string(globalvars.configuration.system), |
6342 | 8009 |
"args": [ |
6343 |
- ("'" + this.paths_input.map(function (filepointer) { return filepointer.as_string(globalvars.configuration.system); }).join(",") + "'"), |
|
6344 |
- ("'" + this.paths_output.map(function (filepointer) { return filepointer.as_string(globalvars.configuration.system); }).join(",") + "'"), |
|
8010 |
+ ("'" + this.paths_input.map(filepointer => filepointer.as_string(globalvars.configuration.system)).join(",") + "'"), |
|
8011 |
+ ("'" + this.paths_output.map(filepointer => filepointer.as_string(globalvars.configuration.system)).join(",") + "'"), |
|
6345 | 8012 |
], |
6346 | 8013 |
"system": globalvars.configuration.system, |
6347 | 8014 |
}); |
... | ... |
@@ -6349,7 +8016,7 @@ var class_action_exec = (function (_super) { |
6349 | 8016 |
{ |
6350 | 8017 |
if (this.workdir != null) { |
6351 | 8018 |
// command = `pushd ${this.workdir.as_string(globalvars.configuration.system)} && ${command} ; popd` |
6352 |
- command = "cd " + this.workdir.as_string(globalvars.configuration.system) + " && " + command + " ; cd -"; |
|
8019 |
+ command = `cd ${this.workdir.as_string(globalvars.configuration.system)} && ${command} ; cd -`; |
|
6353 | 8020 |
} |
6354 | 8021 |
} |
6355 | 8022 |
return command; |
... | ... |
@@ -6367,40 +8034,37 @@ var class_action_exec = (function (_super) { |
6367 | 8034 |
"interpreter": ((this.path_interpreter != null) ? this.path_interpreter.as_string(globalvars.configuration.system) : null), |
6368 | 8035 |
"path": this.path_script.as_string("linux"), |
6369 | 8036 |
"args": [ |
6370 |
- ("'" + this.paths_input.map(function (filepointer) { return filepointer.as_string("linux"); }).join(",") + "'"), |
|
6371 |
- ("'" + this.paths_output.map(function (filepointer) { return filepointer.as_string("linux"); }).join(",") + "'"), |
|
8037 |
+ ("'" + this.paths_input.map(filepointer => filepointer.as_string("linux")).join(",") + "'"), |
|
8038 |
+ ("'" + this.paths_output.map(filepointer => filepointer.as_string("linux")).join(",") + "'"), |
|
6372 | 8039 |
], |
6373 | 8040 |
"system": globalvars.configuration.system, |
6374 | 8041 |
})); |
6375 | 8042 |
break; |
6376 | 8043 |
} |
6377 | 8044 |
default: { |
6378 |
- throw (new Error("unhandled output '" + output_identifier + "'")); |
|
8045 |
+ throw (new Error(`unhandled output '${output_identifier}'`)); |
|
6379 | 8046 |
break; |
6380 | 8047 |
} |
6381 | 8048 |
} |
6382 |
- }; |
|
6383 |
- return class_action_exec; |
|
6384 |
-}(class_action_adhoc)); |
|
8049 |
+ } |
|
8050 |
+} |
|
6385 | 8051 |
/** |
6386 | 8052 |
* @author fenris |
6387 | 8053 |
*/ |
6388 |
-var class_action_echo = (function (_super) { |
|
6389 |
- __extends(class_action_echo, _super); |
|
8054 |
+class class_action_echo extends class_action_adhoc { |
|
6390 | 8055 |
/** |
6391 | 8056 |
* @author fenris |
6392 | 8057 |
*/ |
6393 |
- function class_action_echo(message) { |
|
6394 |
- var _this = _super.call(this) || this; |
|
6395 |
- _this.message = message; |
|
6396 |
- return _this; |
|
8058 |
+ constructor(message) { |
|
8059 |
+ super(); |
|
8060 |
+ this.message = message; |
|
6397 | 8061 |
} |
6398 | 8062 |
/** |
6399 | 8063 |
* @desc for defining directly how the action is to be converted into a target-piece |
6400 | 8064 |
* @todo escape message |
6401 | 8065 |
* @author fenris |
6402 | 8066 |
*/ |
6403 |
- class_action_echo.prototype.compilation = function (target_identifier) { |
|
8067 |
+ compilation(target_identifier) { |
|
6404 | 8068 |
switch (target_identifier) { |
6405 | 8069 |
case "gnumake": { |
6406 | 8070 |
switch (globalvars.configuration["system"]) { |
... | ... |
@@ -6429,30 +8093,27 @@ var class_action_echo = (function (_super) { |
6429 | 8093 |
break; |
6430 | 8094 |
} |
6431 | 8095 |
} |
6432 |
- }; |
|
6433 |
- return class_action_echo; |
|
6434 |
-}(class_action_adhoc)); |
|
8096 |
+ } |
|
8097 |
+} |
|
6435 | 8098 |
/** |
6436 | 8099 |
* @author fenris |
6437 | 8100 |
*/ |
6438 |
-var class_action_mkdir = (function (_super) { |
|
6439 |
- __extends(class_action_mkdir, _super); |
|
8101 |
+class class_action_mkdir extends class_action_adhoc { |
|
6440 | 8102 |
/** |
6441 | 8103 |
* @author fenris |
6442 | 8104 |
*/ |
6443 |
- function class_action_mkdir(location) { |
|
6444 |
- var _this = _super.call(this) || this; |
|
6445 |
- _this.location = location; |
|
6446 |
- return _this; |
|
8105 |
+ constructor(location) { |
|
8106 |
+ super(); |
|
8107 |
+ this.location = location; |
|
6447 | 8108 |
} |
6448 | 8109 |
/** |
6449 | 8110 |
* @desc for defining directly how the action is to be converted into a target-piece |
6450 | 8111 |
* @author fenris |
6451 | 8112 |
*/ |
6452 |
- class_action_mkdir.prototype.compilation = function (target_identifier) { |
|
8113 |
+ compilation(target_identifier) { |
|
6453 | 8114 |
switch (target_identifier) { |
6454 | 8115 |
case "gnumake": { |
6455 |
- var parts = []; |
|
8116 |
+ let parts = []; |
|
6456 | 8117 |
parts.push("mkdir"); |
6457 | 8118 |
switch (globalvars.configuration["system"]) { |
6458 | 8119 |
case "linux": { |
... | ... |
@@ -6473,101 +8134,87 @@ var class_action_mkdir = (function (_super) { |
6473 | 8134 |
} |
6474 | 8135 |
parts.push(this.location.as_string(globalvars.configuration["system"])); |
6475 | 8136 |
return parts.join(" "); |
6476 |
- // break; |
|
6477 | 8137 |
} |
6478 | 8138 |
case "ant": { |
6479 | 8139 |
return (new lib_ant.class_action(new lib_xml.class_node_complex("mkdir", { "dir": this.location.as_string("linux") }))); |
6480 |
- // break; |
|
6481 | 8140 |
} |
6482 | 8141 |
default: { |
6483 | 8142 |
throw (new Error("unhandled target '" + target_identifier + "'")); |
6484 |
- // break; |
|
6485 | 8143 |
} |
6486 | 8144 |
} |
6487 |
- }; |
|
6488 |
- return class_action_mkdir; |
|
6489 |
-}(class_action_adhoc)); |
|
8145 |
+ } |
|
8146 |
+} |
|
6490 | 8147 |
/** |
6491 | 8148 |
* @author fenris |
6492 | 8149 |
*/ |
6493 |
-var class_action_touch = (function (_super) { |
|
6494 |
- __extends(class_action_touch, _super); |
|
8150 |
+class class_action_touch extends class_action_adhoc { |
|
6495 | 8151 |
/** |
6496 | 8152 |
* @author fenris |
6497 | 8153 |
*/ |
6498 |
- function class_action_touch(filepointer) { |
|
6499 |
- var _this = _super.call(this) || this; |
|
6500 |
- _this.filepointer = filepointer; |
|
6501 |
- return _this; |
|
8154 |
+ constructor(filepointer) { |
|
8155 |
+ super(); |
|
8156 |
+ this.filepointer = filepointer; |
|
6502 | 8157 |
} |
6503 | 8158 |
/** |
6504 | 8159 |
* @desc for defining directly how the action is to be converted into a target-piece |
6505 | 8160 |
* @author fenris |
6506 | 8161 |
*/ |
6507 |
- class_action_touch.prototype.compilation = function (target_identifier) { |
|
8162 |
+ compilation(target_identifier) { |
|
6508 | 8163 |
switch (target_identifier) { |
6509 | 8164 |
case "gnumake": { |
6510 | 8165 |
switch (globalvars.configuration["system"]) { |
6511 | 8166 |
case "bsd": |
6512 | 8167 |
case "linux": { |
6513 |
- var parts = []; |
|
8168 |
+ let parts = []; |
|
6514 | 8169 |
parts.push("touch"); |
6515 | 8170 |
parts.push(this.filepointer.toString()); |
6516 | 8171 |
return parts.join(" "); |
6517 |
- // break; |
|
6518 | 8172 |
} |
6519 | 8173 |
case "win": { |
6520 |
- var parts = []; |
|
8174 |
+ let parts = []; |
|
6521 | 8175 |
parts.push("echo."); |
6522 | 8176 |
parts.push(">"); |
6523 | 8177 |
parts.push(this.filepointer.toString()); |
6524 | 8178 |
return parts.join(" "); |
6525 |
- // break; |
|
6526 | 8179 |
} |
6527 | 8180 |
default: { |
6528 | 8181 |
throw (new Error("not implemented")); |
6529 |
- // break; |
|
6530 | 8182 |
} |
6531 | 8183 |
} |
6532 |
- // break; |
|
6533 | 8184 |
} |
6534 | 8185 |
case "ant": { |
6535 | 8186 |
return (new lib_ant.class_action(new lib_xml.class_node_complex("touch", { "file": this.filepointer.toString() }))); |
6536 |
- // break; |
|
6537 | 8187 |
} |
6538 | 8188 |
default: { |
6539 | 8189 |
throw (new Error("unhandled target '" + target_identifier + "'")); |
6540 | 8190 |
break; |
6541 | 8191 |
} |
6542 | 8192 |
} |
6543 |
- }; |
|
6544 |
- return class_action_touch; |
|
6545 |
-}(class_action_adhoc)); |
|
8193 |
+ } |
|
8194 |
+} |
|
6546 | 8195 |
/** |
6547 | 8196 |
* @author fenris |
6548 | 8197 |
*/ |
6549 |
-var class_action_copy = (function (_super) { |
|
6550 |
- __extends(class_action_copy, _super); |
|
8198 |
+class class_action_copy extends class_action_adhoc { |
|
6551 | 8199 |
/** |
6552 | 8200 |
* @author fenris |
6553 | 8201 |
*/ |
6554 |
- function class_action_copy(filepointer_from, filepointer_to, folder) { |
|
6555 |
- var _this = _super.call(this) || this; |
|
6556 |
- _this.filepointer_from = filepointer_from; |
|
6557 |
- _this.filepointer_to = filepointer_to; |
|
6558 |
- _this.folder = folder; |
|
6559 |
- return _this; |
|
8202 |
+ constructor(filepointer_from, filepointer_to, folder) { |
|
8203 |
+ super(); |
|
8204 |
+ this.filepointer_from = filepointer_from; |
|
8205 |
+ this.filepointer_to = filepointer_to; |
|
8206 |
+ this.folder = folder; |
|
6560 | 8207 |
} |
6561 | 8208 |
/** |
6562 | 8209 |
* @desc for defining directly how the action is to be converted into a target-piece |
6563 | 8210 |
* @author fenris |
6564 | 8211 |
*/ |
6565 |
- class_action_copy.prototype.compilation = function (target_identifier) { |
|
8212 |
+ compilation(target_identifier) { |
|
6566 | 8213 |
switch (target_identifier) { |
6567 | 8214 |
case "gnumake": { |
6568 | 8215 |
switch (globalvars.configuration.system) { |
6569 | 8216 |
case "linux": { |
6570 |
- var args = []; |
|
8217 |
+ let args = []; |
|
6571 | 8218 |
if (this.folder) { |
6572 | 8219 |
args.push("--recursive"); |
6573 | 8220 |
args.push("--update"); |
... | ... |
@@ -6585,7 +8232,7 @@ var class_action_copy = (function (_super) { |
6585 | 8232 |
break; |
6586 | 8233 |
} |
6587 | 8234 |
case "bsd": { |
6588 |
- var args = []; |
|
8235 |
+ let args = []; |
|
6589 | 8236 |
if (this.folder) { |
6590 | 8237 |
args.push("-r"); |
6591 | 8238 |
// args.push("-u"); |
... | ... |
@@ -6636,38 +8283,34 @@ var class_action_copy = (function (_super) { |
6636 | 8283 |
break; |
6637 | 8284 |
} |
6638 | 8285 |
} |
6639 |
- }; |
|
6640 |
- return class_action_copy; |
|
6641 |
-}(class_action_adhoc)); |
|
8286 |
+ } |
|
8287 |
+} |
|
6642 | 8288 |
/** |
6643 | 8289 |
* @author fenris |
6644 | 8290 |
*/ |
6645 |
-var class_action_move = (function (_super) { |
|
6646 |
- __extends(class_action_move, _super); |
|
8291 |
+class class_action_move extends class_action_adhoc { |
|
6647 | 8292 |
/** |
6648 | 8293 |
* @author fenris |
6649 | 8294 |
*/ |
6650 |
- function class_action_move(_a) { |
|
6651 |
- var from = _a["from"], to = _a["to"]; |
|
6652 |
- var _this = _super.call(this) || this; |
|
6653 |
- _this.from = from; |
|
6654 |
- _this.to = to; |
|
6655 |
- return _this; |
|
8295 |
+ constructor({ "from": from, "to": to, }) { |
|
8296 |
+ super(); |
|
8297 |
+ this.from = from; |
|
8298 |
+ this.to = to; |
|
6656 | 8299 |
} |
6657 | 8300 |
/** |
6658 | 8301 |
* @desc for defining directly how the action is to be converted into a target-piece |
6659 | 8302 |
* @author fenris |
6660 | 8303 |
*/ |
6661 |
- class_action_move.prototype.compilation = function (output_identifier) { |
|
8304 |
+ compilation(output_identifier) { |
|
6662 | 8305 |
switch (output_identifier) { |
6663 | 8306 |
case "gnumake": { |
6664 | 8307 |
switch (globalvars.configuration.system) { |
6665 | 8308 |
case "linux": |
6666 | 8309 |
case "bsd": |
6667 | 8310 |
case "win": { |
6668 |
- var from = this.from.as_string(globalvars.configuration.system); |
|
6669 |
- var to = this.to.as_string(globalvars.configuration.system); |
|
6670 |
- var command = ""; |
|
8311 |
+ let from = this.from.as_string(globalvars.configuration.system); |
|
8312 |
+ let to = this.to.as_string(globalvars.configuration.system); |
|
8313 |
+ let command = ""; |
|
6671 | 8314 |
{ |
6672 | 8315 |
command = lib_gnumake.macro_command({ |
6673 | 8316 |
"path": "mv", |
... | ... |
@@ -6677,7 +8320,7 @@ var class_action_move = (function (_super) { |
6677 | 8320 |
}); |
6678 | 8321 |
} |
6679 | 8322 |
{ |
6680 |
- command = "[ \"" + from + "\" -ef \"" + to + "\" ] || " + command; |
|
8323 |
+ command = `[ "${from}" -ef "${to}" ] || ${command}`; |
|
6681 | 8324 |
} |
6682 | 8325 |
return command; |
6683 | 8326 |
break; |
... | ... |
@@ -6697,34 +8340,30 @@ var class_action_move = (function (_super) { |
6697 | 8340 |
break; |
6698 | 8341 |
} |
6699 | 8342 |
default: { |
6700 |
- throw (new Error("unhandled output '" + output_identifier + "'")); |
|
8343 |
+ throw (new Error(`unhandled output '${output_identifier}'`)); |
|
6701 | 8344 |
break; |
6702 | 8345 |
} |
6703 | 8346 |
} |
6704 |
- }; |
|
6705 |
- return class_action_move; |
|
6706 |
-}(class_action_adhoc)); |
|
8347 |
+ } |
|
8348 |
+} |
|
6707 | 8349 |
/** |
6708 | 8350 |
* @author fenris |
6709 | 8351 |
*/ |
6710 |
-var class_action_concat = (function (_super) { |
|
6711 |
- __extends(class_action_concat, _super); |
|
8352 |
+class class_action_concat extends class_action_adhoc { |
|
6712 | 8353 |
/** |
6713 | 8354 |
* @author fenris |
6714 | 8355 |
*/ |
6715 |
- function class_action_concat(sources, destination, schwamminput) { |
|
6716 |
- if (schwamminput === void 0) { schwamminput = null; } |
|
6717 |
- var _this = _super.call(this) || this; |
|
6718 |
- _this.sources = sources; |
|
6719 |
- _this.destination = destination; |
|
6720 |
- _this.schwamminput = schwamminput; |
|
6721 |
- return _this; |
|
8356 |
+ constructor(sources, destination, schwamminput = null) { |
|
8357 |
+ super(); |
|
8358 |
+ this.sources = sources; |
|
8359 |
+ this.destination = destination; |
|
8360 |
+ this.schwamminput = schwamminput; |
|
6722 | 8361 |
} |
6723 | 8362 |
/** |
6724 | 8363 |
* @desc for defining directly how the action is to be converted into a target-piece |
6725 | 8364 |
* @author fenris |
6726 | 8365 |
*/ |
6727 |
- class_action_concat.prototype.compilation = function (output_identifier) { |
|
8366 |
+ compilation(output_identifier) { |
|
6728 | 8367 |
switch (output_identifier) { |
6729 | 8368 |
case "gnumake": { |
6730 | 8369 |
if (this.sources.length > 0) { |
... | ... |
@@ -6734,14 +8373,14 @@ var class_action_concat = (function (_super) { |
6734 | 8373 |
"bsd": "cat", |
6735 | 8374 |
"win": "type", |
6736 | 8375 |
}[globalvars.configuration.system], |
6737 |
- "args": this.sources.map(function (source) { return source.as_string(globalvars.configuration.system); }), |
|
8376 |
+ "args": this.sources.map(source => source.as_string(globalvars.configuration.system)), |
|
6738 | 8377 |
"output": this.destination.as_string(globalvars.configuration.system), |
6739 | 8378 |
})); |
6740 | 8379 |
} |
6741 | 8380 |
else { |
6742 | 8381 |
return (lib_gnumake.macro_command({ |
6743 | 8382 |
"path": "touch", |
6744 |
- "output": this.destination.as_string(globalvars.configuration.system), |
|
8383 |
+ "args": [this.destination.as_string(globalvars.configuration.system)], |
|
6745 | 8384 |
})); |
6746 | 8385 |
} |
6747 | 8386 |
break; |
... | ... |
@@ -6755,40 +8394,37 @@ var class_action_concat = (function (_super) { |
6755 | 8394 |
break; |
6756 | 8395 |
} |
6757 | 8396 |
default: { |
6758 |
- throw (new Error("unhandled output '" + output_identifier + "'")); |
|
8397 |
+ throw (new Error(`unhandled output '${output_identifier}'`)); |
|
6759 | 8398 |
break; |
6760 | 8399 |
} |
6761 | 8400 |
} |
6762 |
- }; |
|
6763 |
- return class_action_concat; |
|
6764 |
-}(class_action_adhoc)); |
|
8401 |
+ } |
|
8402 |
+} |
|
6765 | 8403 |
/** |
6766 | 8404 |
* @author fenris |
6767 | 8405 |
*/ |
6768 |
-var class_action_lessc = (function (_super) { |
|
6769 |
- __extends(class_action_lessc, _super); |
|
8406 |
+class class_action_lessc extends class_action_adhoc { |
|
6770 | 8407 |
/** |
6771 | 8408 |
* @author fenris |
6772 | 8409 |
*/ |
6773 |
- function class_action_lessc(filepointer_from, filepointer_to) { |
|
6774 |
- var _this = _super.call(this) || this; |
|
6775 |
- _this.filepointer_from = filepointer_from; |
|
6776 |
- _this.filepointer_to = filepointer_to; |
|
6777 |
- return _this; |
|
8410 |
+ constructor(filepointer_from, filepointer_to) { |
|
8411 |
+ super(); |
|
8412 |
+ this.filepointer_from = filepointer_from; |
|
8413 |
+ this.filepointer_to = filepointer_to; |
|
6778 | 8414 |
} |
6779 | 8415 |
/** |
6780 | 8416 |
* @override |
6781 | 8417 |
* @author fenris |
6782 | 8418 |
*/ |
6783 |
- class_action_lessc.prototype.compilation = function (target_identifier) { |
|
6784 |
- var args = []; |
|
8419 |
+ compilation(output_identifier) { |
|
8420 |
+ let args = []; |
|
6785 | 8421 |
args.push(this.filepointer_from.as_string(globalvars.configuration.system)); |
6786 |
- var cmdparams = { |
|
6787 |
- "path": "lessc", |
|
8422 |
+ let cmdparams = { |
|
8423 |
+ "path": globalvars.configuration.programpaths.lessc, |
|
6788 | 8424 |
"args": args, |
6789 | 8425 |
"output": this.filepointer_to.as_string(globalvars.configuration.system), |
6790 | 8426 |
}; |
6791 |
- switch (target_identifier) { |
|
8427 |
+ switch (output_identifier) { |
|
6792 | 8428 |
case "gnumake": { |
6793 | 8429 |
return lib_gnumake.macro_command(cmdparams); |
6794 | 8430 |
break; |
... | ... |
@@ -6798,39 +8434,37 @@ var class_action_lessc = (function (_super) { |
6798 | 8434 |
break; |
6799 | 8435 |
} |
6800 | 8436 |
default: { |
6801 |
- throw (new Error("unhandled target '" + target_identifier + "'")); |
|
8437 |
+ throw (new Error(`unhandled output '${output_identifier}'`)); |
|
6802 | 8438 |
break; |
6803 | 8439 |
} |
6804 | 8440 |
} |
6805 |
- }; |
|
6806 |
- return class_action_lessc; |
|
6807 |
-}(class_action_adhoc)); |
|
8441 |
+ } |
|
8442 |
+} |
|
6808 | 8443 |
/** |
6809 | 8444 |
* @author neu3no |
6810 | 8445 |
*/ |
6811 |
-var class_action_babel = (function (_super) { |
|
6812 |
- __extends(class_action_babel, _super); |
|
8446 |
+class class_action_babel extends class_action_adhoc { |
|
6813 | 8447 |
/** |
6814 | 8448 |
* @author neu3no |
6815 | 8449 |
*/ |
6816 |
- function class_action_babel(filepointers_from, filepointer_to, preset, minify) { |
|
6817 |
- var _this = _super.call(this) || this; |
|
6818 |
- _this.filepointers_from = filepointers_from; |
|
6819 |
- _this.filepointer_to = filepointer_to; |
|
6820 |
- _this.preset = preset; |
|
6821 |
- _this.minify = minify; |
|
6822 |
- return _this; |
|
8450 |
+ constructor(filepointers_from, filepointer_to, presets, plugins, minify) { |
|
8451 |
+ super(); |
|
8452 |
+ this.filepointers_from = filepointers_from; |
|
8453 |
+ this.filepointer_to = filepointer_to; |
|
8454 |
+ this.presets = presets; |
|
8455 |
+ this.plugins = plugins; |
|
8456 |
+ this.minify = minify; |
|
6823 | 8457 |
} |
6824 | 8458 |
/** |
6825 | 8459 |
* @override |
6826 | 8460 |
* @author neu3no,fenris |
6827 | 8461 |
*/ |
6828 |
- class_action_babel.prototype.compilation = function (target_identifier) { |
|
6829 |
- var args = []; |
|
8462 |
+ compilation(output_identifier) { |
|
8463 |
+ let args = []; |
|
6830 | 8464 |
args.push("--no-babelrc"); |
6831 | 8465 |
// input |
6832 | 8466 |
{ |
6833 |
- this.filepointers_from.forEach(function (filepointer) { return args.push(filepointer.as_string(globalvars.configuration.system)); }); |
|
8467 |
+ this.filepointers_from.forEach(filepointer => args.push(filepointer.as_string(globalvars.configuration.system))); |
|
6834 | 8468 |
} |
6835 | 8469 |
// output |
6836 | 8470 |
{ |
... | ... |
@@ -6839,24 +8473,30 @@ var class_action_babel = (function (_super) { |
6839 | 8473 |
} |
6840 | 8474 |
// presets |
6841 | 8475 |
{ |
6842 |
- var presets = []; |
|
6843 |
- if (this.preset !== null) { |
|
6844 |
- presets.push(this.preset); |
|
8476 |
+ if ((this.presets !== null) && (this.presets.length > 0)) { |
|
8477 |
+ args.push("--presets"); |
|
8478 |
+ args.push(this.presets.join(",")); |
|
8479 |
+ } |
|
8480 |
+ } |
|
8481 |
+ // plugins |
|
8482 |
+ { |
|
8483 |
+ if ((this.plugins != null) && (this.plugins.length > 0)) { |
|
8484 |
+ args.push("--plugins"); |
|
8485 |
+ args.push(this.plugins.join(",")); |
|
8486 |
+ } |
|
6845 | 8487 |
} |
8488 |
+ // minify |
|
8489 |
+ { |
|
6846 | 8490 |
if (this.minify) { |
6847 | 8491 |
args.push("--minified"); |
6848 | 8492 |
} |
6849 |
- if (presets.length > 0) { |
|
6850 |
- args.push("--presets"); |
|
6851 |
- args.push(presets.join(",")); |
|
6852 |
- } |
|
6853 | 8493 |
} |
6854 |
- var cmdparams = { |
|
6855 |
- "path": "babel", |
|
8494 |
+ let cmdparams = { |
|
8495 |
+ "path": globalvars.configuration.programpaths.babel, |
|
6856 | 8496 |
"args": args, |
6857 | 8497 |
"output": this.filepointer_to.as_string(globalvars.configuration.system), |
6858 | 8498 |
}; |
6859 |
- switch (target_identifier) { |
|
8499 |
+ switch (output_identifier) { |
|
6860 | 8500 |
case "gnumake": { |
6861 | 8501 |
return lib_gnumake.macro_command(cmdparams); |
6862 | 8502 |
break; |
... | ... |
@@ -6866,36 +8506,33 @@ var class_action_babel = (function (_super) { |
6866 | 8506 |
break; |
6867 | 8507 |
} |
6868 | 8508 |
default: { |
6869 |
- throw (new Error("unhandled target '" + target_identifier + "'")); |
|
8509 |
+ throw (new Error(`unhandled target '${output_identifier}'`)); |
|
6870 | 8510 |
break; |
6871 | 8511 |
} |
6872 | 8512 |
} |
6873 |
- }; |
|
6874 |
- return class_action_babel; |
|
6875 |
-}(class_action_adhoc)); |
|
8513 |
+ } |
|
8514 |
+} |
|
6876 | 8515 |
/** |
6877 | 8516 |
* @author fenris |
6878 | 8517 |
*/ |
6879 |
-var class_action_tsc = (function (_super) { |
|
6880 |
- __extends(class_action_tsc, _super); |
|
8518 |
+class class_action_tsc extends class_action_adhoc { |
|
6881 | 8519 |
/** |
6882 | 8520 |
* @author fenris |
6883 | 8521 |
*/ |
6884 |
- function class_action_tsc(paths_input, path_output, target, allowUnreachableCode, declaration) { |
|
6885 |
- var _this = _super.call(this) || this; |
|
6886 |
- _this.paths_input = paths_input; |
|
6887 |
- _this.path_output = path_output; |
|
6888 |
- _this.target = target; |
|
6889 |
- _this.allowUnreachableCode = allowUnreachableCode; |
|
6890 |
- _this.declaration = declaration; |
|
6891 |
- return _this; |
|
8522 |
+ constructor(paths_input, path_output, target, allowUnreachableCode, declaration) { |
|
8523 |
+ super(); |
|
8524 |
+ this.paths_input = paths_input; |
|
8525 |
+ this.path_output = path_output; |
|
8526 |
+ this.target = target; |
|
8527 |
+ this.allowUnreachableCode = allowUnreachableCode; |
|
8528 |
+ this.declaration = declaration; |
|
6892 | 8529 |
} |
6893 | 8530 |
/** |
6894 | 8531 |
* @author fenris |
6895 | 8532 |
* @todo handle declarion-path |
6896 | 8533 |
*/ |
6897 |
- class_action_tsc.prototype.compilation = function (output_identifier) { |
|
6898 |
- var args = []; |
|
8534 |
+ compilation(output_identifier) { |
|
8535 |
+ let args = []; |
|
6899 | 8536 |
{ |
6900 | 8537 |
if (this.allowUnreachableCode) { |
6901 | 8538 |
args.push("--allowUnreachableCode"); |
... | ... |
@@ -6908,7 +8545,7 @@ var class_action_tsc = (function (_super) { |
6908 | 8545 |
} |
6909 | 8546 |
} |
6910 | 8547 |
{ |
6911 |
- this.paths_input.forEach(function (filepointer) { return args.push(filepointer.as_string(globalvars.configuration.system)); }); |
|
8548 |
+ this.paths_input.forEach(filepointer => args.push(filepointer.as_string(globalvars.configuration.system))); |
|
6912 | 8549 |
} |
6913 | 8550 |
{ |
6914 | 8551 |
if (this.declaration != null) { |
... | ... |
@@ -6919,8 +8556,8 @@ var class_action_tsc = (function (_super) { |
6919 | 8556 |
args.push("--outFile"); |
6920 | 8557 |
args.push(this.path_output.as_string(globalvars.configuration.system)); |
6921 | 8558 |
} |
6922 |
- var cmdparams = { |
|
6923 |
- "path": "tsc", |
|
8559 |
+ let cmdparams = { |
|
8560 |
+ "path": globalvars.configuration.programpaths.tsc, |
|
6924 | 8561 |
"args": args, |
6925 | 8562 |
"system": globalvars.configuration.system, |
6926 | 8563 |
}; |
... | ... |
@@ -6934,101 +8571,84 @@ var class_action_tsc = (function (_super) { |
6934 | 8571 |
break; |
6935 | 8572 |
} |
6936 | 8573 |
default: { |
6937 |
- throw (new Error("unhandled output '" + output_identifier + "'")); |
|
8574 |
+ throw (new Error(`unhandled output '${output_identifier}'`)); |
|
6938 | 8575 |
break; |
6939 | 8576 |
} |
6940 | 8577 |
} |
6941 |
- }; |
|
6942 |
- return class_action_tsc; |
|
6943 |
-}(class_action_adhoc)); |
|
8578 |
+ } |
|
8579 |
+} |
|
6944 | 8580 |
/** |
6945 | 8581 |
* @author fenris |
6946 | 8582 |
*/ |
6947 |
-var class_action_php = (function (_super) { |
|
6948 |
- __extends(class_action_php, _super); |
|
8583 |
+class class_action_php extends class_action_adhoc { |
|
6949 | 8584 |
/** |
6950 | 8585 |
* @author fenris |
6951 | 8586 |
*/ |
6952 |
- function class_action_php(filepointers_from, filepointer_to, only_first, only_last) { |
|
6953 |
- var _this = _super.call(this) || this; |
|
6954 |
- _this.filepointers_from = filepointers_from; |
|
6955 |
- _this.filepointer_to = filepointer_to; |
|
6956 |
- _this.only_first = only_first; |
|
6957 |
- _this.only_last = only_last; |
|
6958 |
- return _this; |
|
8587 |
+ constructor(filepointers_from, filepointer_to, only_last) { |
|
8588 |
+ super(); |
|
8589 |
+ this.filepointers_from = filepointers_from; |
|
8590 |
+ this.filepointer_to = filepointer_to; |
|
8591 |
+ this.only_last = only_last; |
|
6959 | 8592 |
} |
6960 | 8593 |
/** |
6961 | 8594 |
* @desc for defining directly how the action is to be converted into a target-piece |
6962 | 8595 |
* @author fenris |
6963 | 8596 |
*/ |
6964 |
- class_action_php.prototype.compilation = function (target_identifier) { |
|
6965 |
- switch (target_identifier) { |
|
6966 |
- case "gnumake": { |
|
6967 |
- switch (globalvars.configuration.system) { |
|
6968 |
- case "bsd": |
|
6969 |
- case "linux": { |
|
6970 |
- var parts_3 = []; |
|
6971 |
- parts_3.push("php"); |
|
8597 |
+ compilation(output_identifier) { |
|
8598 |
+ let args = []; |
|
8599 |
+ { |
|
6972 | 8600 |
if (this.only_last) { |
6973 |
- parts_3.push(this.filepointers_from.slice(-1)[0].toString()); |
|
6974 |
- } |
|
6975 |
- else { |
|
6976 |
- if (this.only_first) { |
|
6977 |
- parts_3.push(this.filepointers_from[0].toString()); |
|
8601 |
+ this.filepointers_from.slice(-1).forEach(filepointer => args.push(filepointer.as_string(globalvars.configuration.system))); |
|
6978 | 8602 |
} |
6979 | 8603 |
else { |
6980 |
- this.filepointers_from.forEach(function (filepointer) { return parts_3.push(filepointer.toString()); }); |
|
6981 |
- } |
|
6982 |
- } |
|
6983 |
- parts_3.push(">"); |
|
6984 |
- parts_3.push(this.filepointer_to.toString()); |
|
6985 |
- return parts_3.join(" "); |
|
6986 |
- break; |
|
6987 |
- } |
|
6988 |
- default: { |
|
6989 |
- throw (new Error("not implemented")); |
|
6990 |
- break; |
|
8604 |
+ this.filepointers_from.forEach(filepointer => args.push(filepointer.as_string(globalvars.configuration.system))); |
|
6991 | 8605 |
} |
6992 | 8606 |
} |
8607 |
+ let cmdparams = { |
|
8608 |
+ "path": globalvars.configuration.programpaths.php, |
|
8609 |
+ "args": args, |
|
8610 |
+ "system": globalvars.configuration.system, |
|
8611 |
+ "output": this.filepointer_to.as_string(globalvars.configuration.system), |
|
8612 |
+ }; |
|
8613 |
+ switch (output_identifier) { |
|
8614 |
+ case "gnumake": { |
|
8615 |
+ return lib_gnumake.macro_command(cmdparams); |
|
6993 | 8616 |
break; |
6994 | 8617 |
} |
6995 | 8618 |
case "ant": { |
6996 |
- throw (new Error("not implemented")); |
|
8619 |
+ return lib_ant.class_action.macro_command(cmdparams); |
|
6997 | 8620 |
break; |
6998 | 8621 |
} |
6999 | 8622 |
default: { |
7000 |
- throw (new Error("unhandled target '" + target_identifier + "'")); |
|
8623 |
+ throw (new Error(`unhandled output '${output_identifier}'`)); |
|
7001 | 8624 |
break; |
7002 | 8625 |
} |
7003 | 8626 |
} |
7004 |
- }; |
|
7005 |
- return class_action_php; |
|
7006 |
-}(class_action_adhoc)); |
|
8627 |
+ } |
|
8628 |
+} |
|
7007 | 8629 |
/** |
7008 | 8630 |
* @author fenris |
7009 | 8631 |
*/ |
7010 |
-var class_action_gitpull = (function (_super) { |
|
7011 |
- __extends(class_action_gitpull, _super); |
|
8632 |
+class class_action_gitpull extends class_action_adhoc { |
|
7012 | 8633 |
/** |
7013 | 8634 |
* @author fenris |
7014 | 8635 |
*/ |
7015 |
- function class_action_gitpull(url) { |
|
7016 |
- var _this = _super.call(this) || this; |
|
7017 |
- _this.url = url; |
|
7018 |
- return _this; |
|
8636 |
+ constructor(url) { |
|
8637 |
+ super(); |
|
8638 |
+ this.url = url; |
|
7019 | 8639 |
} |
7020 | 8640 |
/** |
7021 | 8641 |
* @desc for defining directly how the action is to be converted into a target-piece |
7022 | 8642 |
* @todo escape message |
7023 | 8643 |
* @author fenris |
7024 | 8644 |
*/ |
7025 |
- class_action_gitpull.prototype.compilation = function (target_identifier) { |
|
8645 |
+ compilation(target_identifier) { |
|
7026 | 8646 |
switch (target_identifier) { |
7027 | 8647 |
case "gnumake": { |
7028 | 8648 |
switch (globalvars.configuration["system"]) { |
7029 | 8649 |
case "linux": |
7030 | 8650 |
case "win": { |
7031 |
- var parts = []; |
|
8651 |
+ let parts = []; |
|
7032 | 8652 |
parts.push("git pull"); |
7033 | 8653 |
parts.push(this.url); |
7034 | 8654 |
return parts.join(" "); |
... | ... |
@@ -7059,69 +8679,54 @@ var class_action_gitpull = (function (_super) { |
7059 | 8679 |
break; |
7060 | 8680 |
} |
7061 | 8681 |
} |
7062 |
- }; |
|
7063 |
- return class_action_gitpull; |
|
7064 |
-}(class_action_adhoc)); |
|
8682 |
+ } |
|
8683 |
+} |
|
7065 | 8684 |
/** |
7066 | 8685 |
* @author fenris |
7067 | 8686 |
*/ |
7068 |
-var class_action_schwamm = (function (_super) { |
|
7069 |
- __extends(class_action_schwamm, _super); |
|
8687 |
+class class_action_schwamm extends class_action_adhoc { |
|
7070 | 8688 |
/** |
7071 | 8689 |
* @author fenris |
7072 | 8690 |
*/ |
7073 |
- function class_action_schwamm(includes, inputs, save, dump_group, dump_filepointer, locmerge_domain, locmerge_identifier, locmerge_filepointer) { |
|
7074 |
- if (dump_group === void 0) { dump_group = null; } |
|
7075 |
- if (dump_filepointer === void 0) { dump_filepointer = null; } |
|
7076 |
- if (locmerge_domain === void 0) { locmerge_domain = null; } |
|
7077 |
- if (locmerge_identifier === void 0) { locmerge_identifier = null; } |
|
7078 |
- if (locmerge_filepointer === void 0) { locmerge_filepointer = null; } |
|
7079 |
- var _this = _super.call(this) || this; |
|
7080 |
- _this.includes = includes; |
|
7081 |
- _this.inputs = inputs; |
|
7082 |
- _this.save = save; |
|
7083 |
- _this.dump_group = dump_group; |
|
7084 |
- _this.dump_filepointer = dump_filepointer; |
|
7085 |
- _this.locmerge_domain = locmerge_domain; |
|
7086 |
- _this.locmerge_identifier = locmerge_identifier; |
|
7087 |
- _this.locmerge_filepointer = locmerge_filepointer; |
|
7088 |
- return _this; |
|
8691 |
+ constructor(includes, inputs, save, dump_group = null, dump_filepointer = null) { |
|
8692 |
+ super(); |
|
8693 |
+ this.includes = includes; |
|
8694 |
+ this.inputs = inputs; |
|
8695 |
+ this.save = save; |
|
8696 |
+ this.dump_group = dump_group; |
|
8697 |
+ this.dump_filepointer = dump_filepointer; |
|
7089 | 8698 |
} |
7090 | 8699 |
/** |
7091 | 8700 |
* @desc for defining directly how the action is to be converted into a target-piece |
7092 | 8701 |
* @author fenris |
7093 | 8702 |
*/ |
7094 |
- class_action_schwamm.prototype.compilation = function (target_identifier) { |
|
7095 |
- var args = []; |
|
7096 |
- this.includes.forEach(function (include) { |
|
7097 |
- args.push("--include=" + include.as_string(globalvars.configuration["system"])); |
|
8703 |
+ compilation(target_identifier) { |
|
8704 |
+ let args = []; |
|
8705 |
+ this.includes.forEach(include => { |
|
8706 |
+ args.push(`--include=${include.as_string(globalvars.configuration["system"])}`); |
|
7098 | 8707 |
}); |
7099 |
- lib_object.to_array(this.inputs).forEach(function (pair) { |
|
7100 |
- pair.value.forEach(function (member) { |
|
7101 |
- var filepointer = member; |
|
7102 |
- args.push("--input=" + filepointer.as_string(globalvars.configuration["system"]) + ":" + pair.key); |
|
8708 |
+ lib_object.to_array(this.inputs).forEach(pair => { |
|
8709 |
+ pair.value.forEach(member => { |
|
8710 |
+ let filepointer = member; |
|
8711 |
+ args.push(`--input=${filepointer.as_string(globalvars.configuration["system"])}:${pair.key}`); |
|
7103 | 8712 |
}); |
7104 | 8713 |
}); |
7105 | 8714 |
// args.push(`--file=${this.output.as_string(globalvars.configuration["system"])}`); |
7106 | 8715 |
// args.push(`--dir=${((this.dir != null) ? this.dir : this.output.location).as_string("system")}`); |
7107 |
- var target; |
|
8716 |
+ let target; |
|
7108 | 8717 |
if (this.save != undefined) { |
7109 |
- args.push("--output=native"); |
|
8718 |
+ args.push(`--output=native`); |
|
7110 | 8719 |
target = this.save; |
7111 | 8720 |
} |
7112 | 8721 |
else if (this.dump_group != null) { |
7113 |
- args.push("--output=dump:" + this.dump_group); |
|
8722 |
+ args.push(`--output=dump:${this.dump_group}`); |
|
7114 | 8723 |
target = this.dump_filepointer; |
7115 | 8724 |
} |
7116 |
- else if (this.locmerge_domain != null) { |
|
7117 |
- args.push("--output=locmerge:" + this.locmerge_domain + ":" + this.locmerge_identifier); |
|
7118 |
- target = this.locmerge_filepointer; |
|
7119 |
- } |
|
7120 | 8725 |
else { |
7121 | 8726 |
console.warn("output missing?"); |
7122 | 8727 |
} |
7123 |
- var cmdparams = { |
|
7124 |
- "path": "schwamm", |
|
8728 |
+ let cmdparams = { |
|
8729 |
+ "path": globalvars.configuration.programpaths.schwamm, |
|
7125 | 8730 |
"args": args, |
7126 | 8731 |
"output": target.as_string(globalvars.configuration["system"]), |
7127 | 8732 |
}; |
... | ... |
@@ -7135,49 +8740,45 @@ var class_action_schwamm = (function (_super) { |
7135 | 8740 |
break; |
7136 | 8741 |
} |
7137 | 8742 |
default: { |
7138 |
- throw (new Error("unhandled target '" + target_identifier + "'")); |
|
8743 |
+ throw (new Error(`unhandled target '${target_identifier}'`)); |
|
7139 | 8744 |
break; |
7140 | 8745 |
} |
7141 | 8746 |
} |
7142 |
- }; |
|
7143 |
- return class_action_schwamm; |
|
7144 |
-}(class_action_adhoc)); |
|
8747 |
+ } |
|
8748 |
+} |
|
7145 | 8749 |
/** |
7146 | 8750 |
* @author fenris |
7147 | 8751 |
*/ |
7148 |
-var class_action_schwamm_create = (function (_super) { |
|
7149 |
- __extends(class_action_schwamm_create, _super); |
|
8752 |
+class class_action_schwamm_create extends class_action_adhoc { |
|
7150 | 8753 |
/** |
7151 | 8754 |
* @author fenris |
7152 | 8755 |
*/ |
7153 |
- function class_action_schwamm_create(includes, adhoc, output, dir) { |
|
7154 |
- var _this = _super.call(this) || this; |
|
7155 |
- _this.includes = includes; |
|
7156 |
- _this.adhoc = adhoc; |
|
7157 |
- _this.output = output; |
|
7158 |
- _this.dir = dir; |
|
7159 |
- return _this; |
|
8756 |
+ constructor(includes, adhoc, output, dir) { |
|
8757 |
+ super(); |
|
8758 |
+ this.includes = includes; |
|
8759 |
+ this.adhoc = adhoc; |
|
8760 |
+ this.output = output; |
|
8761 |
+ this.dir = dir; |
|
7160 | 8762 |
} |
7161 | 8763 |
/** |
7162 | 8764 |
* @desc for defining directly how the action is to be converted into a target-piece |
7163 | 8765 |
* @author fenris |
7164 | 8766 |
*/ |
7165 |
- class_action_schwamm_create.prototype.compilation = function (target_identifier) { |
|
7166 |
- var _this = this; |
|
7167 |
- var args = []; |
|
7168 |
- this.includes.forEach(function (include) { |
|
7169 |
- args.push("--include=" + include.as_string(globalvars.configuration["system"])); |
|
8767 |
+ compilation(target_identifier) { |
|
8768 |
+ let args = []; |
|
8769 |
+ this.includes.forEach(include => { |
|
8770 |
+ args.push(`--include=${include.as_string(globalvars.configuration["system"])}`); |
|
7170 | 8771 |
}); |
7171 |
- Object.keys(this.adhoc).forEach(function (group) { |
|
7172 |
- _this.adhoc[group].forEach(function (member) { |
|
7173 |
- var filepointer = member; |
|
7174 |
- args.push("--input=" + filepointer.as_string(globalvars.configuration["system"]) + ":" + group); |
|
8772 |
+ Object.keys(this.adhoc).forEach(group => { |
|
8773 |
+ this.adhoc[group].forEach(member => { |
|
8774 |
+ let filepointer = member; |
|
8775 |
+ args.push(`--input=${filepointer.as_string(globalvars.configuration["system"])}:${group}`); |
|
7175 | 8776 |
}); |
7176 | 8777 |
}); |
7177 |
- args.push("--output=native"); |
|
8778 |
+ args.push(`--output=native`); |
|
7178 | 8779 |
// args.push(`--file=${this.output.as_string(globalvars.configuration["system"])}`); |
7179 | 8780 |
// args.push(`--dir=${((this.dir != null) ? this.dir : this.output.location).as_string("linux")}`); |
7180 |
- var cmdparams = { |
|
8781 |
+ let cmdparams = { |
|
7181 | 8782 |
"path": "schwamm", |
7182 | 8783 |
"args": args, |
7183 | 8784 |
"output": this.output.as_string(globalvars.configuration["system"]), |
... | ... |
@@ -7192,38 +8793,35 @@ var class_action_schwamm_create = (function (_super) { |
7192 | 8793 |
break; |
7193 | 8794 |
} |
7194 | 8795 |
default: { |
7195 |
- throw (new Error("unhandled target '" + target_identifier + "'")); |
|
8796 |
+ throw (new Error(`unhandled target '${target_identifier}'`)); |
|
7196 | 8797 |
break; |
7197 | 8798 |
} |
7198 | 8799 |
} |
7199 |
- }; |
|
7200 |
- return class_action_schwamm_create; |
|
7201 |
-}(class_action_adhoc)); |
|
8800 |
+ } |
|
8801 |
+} |
|
7202 | 8802 |
/** |
7203 | 8803 |
* @author fenris |
7204 | 8804 |
*/ |
7205 |
-var class_action_schwamm_apply = (function (_super) { |
|
7206 |
- __extends(class_action_schwamm_apply, _super); |
|
8805 |
+class class_action_schwamm_apply extends class_action_adhoc { |
|
7207 | 8806 |
/** |
7208 | 8807 |
* @author fenris |
7209 | 8808 |
*/ |
7210 |
- function class_action_schwamm_apply(path, output_group, output_filepointer) { |
|
7211 |
- var _this = _super.call(this) || this; |
|
7212 |
- _this.path = path; |
|
7213 |
- _this.output_group = output_group; |
|
7214 |
- _this.output_filepointer = output_filepointer; |
|
7215 |
- return _this; |
|
8809 |
+ constructor(path, output_group, output_filepointer) { |
|
8810 |
+ super(); |
|
8811 |
+ this.path = path; |
|
8812 |
+ this.output_group = output_group; |
|
8813 |
+ this.output_filepointer = output_filepointer; |
|
7216 | 8814 |
} |
7217 | 8815 |
/** |
7218 | 8816 |
* @desc for defining directly how the action is to be converted into a target-piece |
7219 | 8817 |
* @author fenris |
7220 | 8818 |
*/ |
7221 |
- class_action_schwamm_apply.prototype.compilation = function (target_identifier) { |
|
7222 |
- var args = []; |
|
7223 |
- args.push("--include=" + this.path.as_string(globalvars.configuration["system"])); |
|
7224 |
- args.push("--output=dump:" + this.output_group); |
|
7225 |
- var filepointer = lib_path.filepointer_read(globalvars.configuration["path"]).foo(this.output_filepointer); |
|
7226 |
- var cmdparams = { |
|
8819 |
+ compilation(target_identifier) { |
|
8820 |
+ let args = []; |
|
8821 |
+ args.push(`--include=${this.path.as_string(globalvars.configuration["system"])}`); |
|
8822 |
+ args.push(`--output=dump:${this.output_group}`); |
|
8823 |
+ let filepointer = lib_path.filepointer_read(globalvars.configuration["path"]).foo(this.output_filepointer); |
|
8824 |
+ let cmdparams = { |
|
7227 | 8825 |
"path": "schwamm", |
7228 | 8826 |
"args": args, |
7229 | 8827 |
"output": filepointer.as_string(globalvars.configuration["system"]), |
... | ... |
@@ -7238,744 +8836,1185 @@ var class_action_schwamm_apply = (function (_super) { |
7238 | 8836 |
break; |
7239 | 8837 |
} |
7240 | 8838 |
default: { |
7241 |
- throw (new Error("unhandled target '" + target_identifier + "'")); |
|
8839 |
+ throw (new Error(`unhandled target '${target_identifier}'`)); |
|
7242 | 8840 |
break; |
7243 | 8841 |
} |
7244 | 8842 |
} |
7245 |
- }; |
|
7246 |
- return class_action_schwamm_apply; |
|
7247 |
-}(class_action_adhoc)); |
|
8843 |
+ } |
|
8844 |
+} |
|
7248 | 8845 |
/** |
7249 | 8846 |
* @author fenris |
7250 | 8847 |
*/ |
7251 |
-var class_taskparameter = (function () { |
|
8848 |
+class class_action_locmerge extends class_action_adhoc { |
|
7252 | 8849 |
/** |
7253 | 8850 |
* @author fenris |
7254 | 8851 |
*/ |
7255 |
- function class_taskparameter(_a) { |
|
7256 |
- var type = _a["type"], name = _a["name"], key = _a["key"], mandatory = _a["mandatory"], default_ = _a["default"], description = _a["description"]; |
|
7257 |
- this.type = type; |
|
7258 |
- this.name = name; |
|
7259 |
- this.key = key; |
|
7260 |
- this.mandatory = mandatory; |
|
7261 |
- this.default_ = default_; |
|
7262 |
- this.description = description; |
|
8852 |
+ constructor(inputs, output) { |
|
8853 |
+ super(); |
|
8854 |
+ this.inputs = inputs; |
|
8855 |
+ this.output = output; |
|
7263 | 8856 |
} |
7264 | 8857 |
/** |
8858 |
+ * @override |
|
7265 | 8859 |
* @author fenris |
7266 | 8860 |
*/ |
7267 |
- class_taskparameter.prototype.toString = function () { |
|
7268 |
- var str = ""; |
|
7269 |
- // name |
|
8861 |
+ compilation(output_identifier) { |
|
8862 |
+ let args = []; |
|
8863 |
+ // inputs |
|
7270 | 8864 |
{ |
7271 |
- str = "" + this.name; |
|
8865 |
+ this.inputs.forEach(input => args.push(input.as_string(globalvars.configuration.system))); |
|
7272 | 8866 |
} |
7273 |
- // type |
|
7274 |
- { |
|
7275 |
- str = str + " : " + this.type.toString(); |
|
8867 |
+ let cmdparams = { |
|
8868 |
+ "path": globalvars.configuration.programpaths.locmerge, |
|
8869 |
+ "args": args, |
|
8870 |
+ "output": this.output.as_string(globalvars.configuration.system), |
|
8871 |
+ }; |
|
8872 |
+ switch (output_identifier) { |
|
8873 |
+ case "gnumake": { |
|
8874 |
+ return lib_gnumake.macro_command(cmdparams); |
|
8875 |
+ break; |
|
7276 | 8876 |
} |
7277 |
- // mandatory & default |
|
7278 |
- { |
|
7279 |
- if (this.mandatory) { |
|
8877 |
+ case "ant": { |
|
8878 |
+ return lib_ant.class_action.macro_command(cmdparams); |
|
8879 |
+ break; |
|
8880 |
+ } |
|
8881 |
+ default: { |
|
8882 |
+ throw (new Error(`unhandled target '${output_identifier}'`)); |
|
8883 |
+ break; |
|
7280 | 8884 |
} |
7281 |
- else { |
|
7282 |
- str = "[" + str + " = " + String(this.default_) + "]"; |
|
7283 | 8885 |
} |
7284 | 8886 |
} |
7285 |
- // description |
|
7286 |
- { |
|
7287 |
- str = str + " -- " + this.description; |
|
7288 | 8887 |
} |
7289 |
- return str; |
|
7290 |
- }; |
|
7291 |
- return class_taskparameter; |
|
7292 |
-}()); |
|
7293 | 8888 |
/** |
7294 | 8889 |
* @author fenris |
7295 | 8890 |
*/ |
7296 |
-var class_task = (function () { |
|
8891 |
+class class_task { |
|
7297 | 8892 |
/** |
7298 | 8893 |
* @author fenris |
7299 | 8894 |
*/ |
7300 |
- function class_task(name, sub, active, _inputs, _outputs, _actions) { |
|
7301 |
- if (sub === void 0) { sub = []; } |
|
7302 |
- if (active === void 0) { active = true; } |
|
7303 |
- if (_inputs === void 0) { _inputs = []; } |
|
7304 |
- if (_outputs === void 0) { _outputs = []; } |
|
7305 |
- if (_actions === void 0) { _actions = []; } |
|
7306 |
- this.identifier = lib_string.generate("task_"); |
|
7307 |
- this.name = ((name != null) ? name : this.identifier); |
|
8895 |
+ constructor({ "name": name = null, "active": active = true, "sub": sub = [], "inputs": _inputs = [], "outputs": _outputs = [], "actions": _actions = [], }) { |
|
8896 |
+ this.name = name; |
|
7308 | 8897 |
this.sub = sub; |
7309 | 8898 |
this.active = active; |
7310 | 8899 |
this._inputs = _inputs; |
7311 | 8900 |
this._outputs = _outputs; |
7312 | 8901 |
this._actions = _actions; |
7313 |
- // this.parameters = parameters; |
|
7314 | 8902 |
this.context = null; |
7315 | 8903 |
} |
7316 | 8904 |
/** |
7317 | 8905 |
* @desc [accessor] [getter] |
7318 | 8906 |
* @author fenris |
7319 | 8907 |
*/ |
7320 |
- class_task.prototype.identifier_get = function () { |
|
7321 |
- return this.identifier; |
|
7322 |
- }; |
|
7323 |
- /** |
|
7324 |
- * @desc [accessor] [getter] |
|
7325 |
- * @author fenris |
|
7326 |
- */ |
|
7327 |
- class_task.prototype.name_get = function () { |
|
8908 |
+ name_get() { |
|
7328 | 8909 |
return this.name; |
7329 |
- }; |
|
8910 |
+ } |
|
7330 | 8911 |
/** |
7331 | 8912 |
* @desc [accessor] [getter] |
7332 | 8913 |
* @author fenris |
7333 | 8914 |
*/ |
7334 |
- class_task.prototype.sub_get = function () { |
|
8915 |
+ sub_get() { |
|
7335 | 8916 |
return this.sub; |
7336 |
- }; |
|
8917 |
+ } |
|
7337 | 8918 |
/** |
7338 | 8919 |
* @desc [accessor] [getter] |
7339 | 8920 |
* @author fenris |
7340 | 8921 |
*/ |
7341 |
- class_task.prototype.active_get = function () { |
|
8922 |
+ active_get() { |
|
7342 | 8923 |
return this.active; |
7343 |
- }; |
|
8924 |
+ } |
|
7344 | 8925 |
/** |
7345 | 8926 |
* @desc [mutator] [setter] |
7346 | 8927 |
* @author fenris |
7347 | 8928 |
*/ |
7348 |
- class_task.prototype.context_set = function (context) { |
|
8929 |
+ context_set(context) { |
|
7349 | 8930 |
this.context = context; |
7350 |
- }; |
|
8931 |
+ } |
|
7351 | 8932 |
/** |
7352 | 8933 |
* @desc [accessor] [getter] |
7353 | 8934 |
* @author fenris |
7354 | 8935 |
*/ |
7355 |
- class_task.prototype.context_get = function () { |
|
8936 |
+ context_get() { |
|
7356 | 8937 |
return this.context; |
7357 |
- }; |
|
8938 |
+ } |
|
7358 | 8939 |
/** |
7359 | 8940 |
* @returns the subgraph of all active tasks |
7360 | 8941 |
* @author fenris |
7361 | 8942 |
*/ |
7362 |
- class_task.prototype.clean = function (root) { |
|
7363 |
- if (root === void 0) { root = true; } |
|
8943 |
+ clean(root = true) { |
|
7364 | 8944 |
if (root && (!this.active)) { |
7365 | 8945 |
throw (new Error("cant't clean inactive root")); |
7366 | 8946 |
} |
7367 | 8947 |
else { |
7368 |
- this.sub = this.sub.filter(function (task_) { return task_.active; }); |
|
7369 |
- this.sub.forEach(function (task_) { return task_.clean(false); }); |
|
8948 |
+ this.sub = this.sub.filter(task_ => task_.active); |
|
8949 |
+ this.sub.forEach(task_ => task_.clean(false)); |
|
8950 |
+ } |
|
7370 | 8951 |
} |
7371 |
- }; |
|
7372 | 8952 |
/** |
7373 | 8953 |
* @desc [accessor] [getter] |
7374 | 8954 |
* @author fenris |
7375 | 8955 |
*/ |
7376 |
- class_task.prototype.values = function (raw) { |
|
8956 |
+ values(raw) { |
|
7377 | 8957 |
return null; |
7378 |
- }; |
|
8958 |
+ } |
|
7379 | 8959 |
/** |
7380 | 8960 |
* @desc [accessor] [getter] a list of paths which represent input-files of the task |
7381 | 8961 |
* @author fenris |
7382 | 8962 |
*/ |
7383 |
- class_task.prototype.inputs = function () { |
|
8963 |
+ inputs() { |
|
7384 | 8964 |
return this._inputs; |
7385 |
- }; |
|
8965 |
+ } |
|
7386 | 8966 |
/** |
7387 | 8967 |
* @desc [accessor] [getter] a list of paths which represent output-files of the task |
7388 | 8968 |
* @author fenris |
7389 | 8969 |
*/ |
7390 |
- class_task.prototype.outputs = function () { |
|
8970 |
+ outputs() { |
|
7391 | 8971 |
return this._outputs; |
7392 |
- }; |
|
8972 |
+ } |
|
7393 | 8973 |
/** |
7394 | 8974 |
* @desc [accessor] [getter] generates all actions which have to be executed in order to fulfil the task |
7395 | 8975 |
* @author fenris |
7396 | 8976 |
*/ |
7397 |
- class_task.prototype.actions = function () { |
|
8977 |
+ actions() { |
|
7398 | 8978 |
return this._actions; |
7399 |
- }; |
|
8979 |
+ } |
|
8980 |
+} |
|
8981 |
+/** |
|
8982 |
+ * @author fenris |
|
8983 |
+ */ |
|
8984 |
+class class_taskparameter { |
|
8985 |
+ /** |
|
8986 |
+ * @author fenris |
|
8987 |
+ */ |
|
8988 |
+ constructor({ "name": name, "extraction": extraction = lib_call.id, "shape": shape = lib_meta.from_raw({ "id": "any" }), "default": default_ = new class_nothing(), "description": description = null, }) { |
|
8989 |
+ this.name = name; |
|
8990 |
+ this.extraction = extraction; |
|
8991 |
+ this.shape = shape; |
|
8992 |
+ this.default_ = default_; |
|
8993 |
+ this.description = description; |
|
8994 |
+ } |
|
8995 |
+ /** |
|
8996 |
+ * @author fenris |
|
8997 |
+ */ |
|
8998 |
+ static input_single({ "description": description = "the list of paths to the input files", "default": default_ = new class_nothing(), } = {}) { |
|
8999 |
+ return (new class_taskparameter({ |
|
9000 |
+ "name": "input", |
|
9001 |
+ "extraction": raw => lib_path.filepointer_read(raw), |
|
9002 |
+ "shape": lib_meta.from_raw({ |
|
9003 |
+ "id": "string" |
|
9004 |
+ }), |
|
9005 |
+ "default": default_, |
|
9006 |
+ "description": description, |
|
9007 |
+ })); |
|
9008 |
+ } |
|
9009 |
+ /** |
|
9010 |
+ * @author fenris |
|
9011 |
+ */ |
|
9012 |
+ static input_list({ "description": description = "the list of paths to the input files", "default": default_ = new class_nothing(), } = {}) { |
|
9013 |
+ return (new class_taskparameter({ |
|
9014 |
+ "name": "inputs", |
|
9015 |
+ "extraction": raw => raw.map(x => lib_path.filepointer_read(x)), |
|
9016 |
+ "shape": lib_meta.from_raw({ |
|
9017 |
+ "id": "array", |
|
9018 |
+ "parameters": { |
|
9019 |
+ "shape_element": { |
|
9020 |
+ "id": "string" |
|
9021 |
+ } |
|
9022 |
+ } |
|
9023 |
+ }), |
|
9024 |
+ "default": default_, |
|
9025 |
+ "description": description, |
|
9026 |
+ })); |
|
9027 |
+ } |
|
9028 |
+ /** |
|
9029 |
+ * @author fenris |
|
9030 |
+ */ |
|
9031 |
+ static input_schwamm({ "description": description = "parameters for a schwamm which holds a list of files in a group", "default": default_ = new class_nothing(), } = {}) { |
|
9032 |
+ return (new class_taskparameter({ |
|
9033 |
+ "name": "input_from_schwamm", |
|
9034 |
+ "extraction": raw => { |
|
9035 |
+ if (raw == null) { |
|
9036 |
+ return []; |
|
9037 |
+ } |
|
9038 |
+ else { |
|
9039 |
+ let regexp; |
|
9040 |
+ if (raw["filter"] != null) { |
|
9041 |
+ regexp = new RegExp(raw["filter"]); |
|
9042 |
+ } |
|
9043 |
+ else { |
|
9044 |
+ regexp = null; |
|
9045 |
+ } |
|
9046 |
+ let command = `schwamm --include=${raw["path"]} --output=list:${raw["group"]}`; |
|
9047 |
+ let result = nm_child_process.execSync(command); |
|
9048 |
+ let output = result.toString(); |
|
9049 |
+ let paths = output.split("\n"); |
|
9050 |
+ return (paths |
|
9051 |
+ .filter(path => (path.trim().length > 0)) |
|
9052 |
+ .filter(path => ((regexp == null) ? true : regexp.test(path))) |
|
9053 |
+ .map(path => lib_path.filepointer_read(path))); |
|
9054 |
+ } |
|
9055 |
+ }, |
|
9056 |
+ "shape": lib_meta.from_raw({ |
|
9057 |
+ "id": "object", |
|
9058 |
+ "parameters": { |
|
9059 |
+ "fields": [ |
|
9060 |
+ { |
|
9061 |
+ "name": "path", |
|
9062 |
+ "shape": { |
|
9063 |
+ "id": "string" |
|
9064 |
+ } |
|
9065 |
+ }, |
|
9066 |
+ { |
|
9067 |
+ "name": "group", |
|
9068 |
+ "shape": { |
|
9069 |
+ "id": "string" |
|
9070 |
+ } |
|
9071 |
+ }, |
|
9072 |
+ { |
|
9073 |
+ "name": "filter", |
|
9074 |
+ "shape": { |
|
9075 |
+ "id": "string", |
|
9076 |
+ "parameters": { |
|
9077 |
+ "soft": true |
|
9078 |
+ } |
|
9079 |
+ } |
|
9080 |
+ }, |
|
9081 |
+ ] |
|
9082 |
+ } |
|
9083 |
+ }), |
|
9084 |
+ "default": default_, |
|
9085 |
+ "description": description, |
|
9086 |
+ })); |
|
9087 |
+ } |
|
9088 |
+ /** |
|
9089 |
+ * @author fenris |
|
9090 |
+ */ |
|
9091 |
+ static output_single({ "description": description = "the list of paths to the input files", } = {}) { |
|
9092 |
+ return (new class_taskparameter({ |
|
9093 |
+ "name": "output", |
|
9094 |
+ "extraction": raw => lib_path.filepointer_read(raw), |
|
9095 |
+ "shape": lib_meta.from_raw({ |
|
9096 |
+ "id": "string" |
|
9097 |
+ }), |
|
9098 |
+ "default": new class_nothing(), |
|
9099 |
+ "description": description, |
|
9100 |
+ })); |
|
9101 |
+ } |
|
9102 |
+ /** |
|
9103 |
+ * @author fenris |
|
9104 |
+ */ |
|
9105 |
+ static output_list({ "description": description = "the list of paths to the output files", "default": default_ = new class_just([]), } = {}) { |
|
9106 |
+ return (new class_taskparameter({ |
|
9107 |
+ "name": "outputs", |
|
9108 |
+ "extraction": raw => raw.map(x => lib_path.filepointer_read(x)), |
|
9109 |
+ "shape": lib_meta.from_raw({ |
|
9110 |
+ "id": "array", |
|
9111 |
+ "parameters": { |
|
9112 |
+ "shape_element": { |
|
9113 |
+ "id": "string" |
|
9114 |
+ } |
|
9115 |
+ } |
|
9116 |
+ }), |
|
9117 |
+ "default": default_, |
|
9118 |
+ "description": description, |
|
9119 |
+ })); |
|
9120 |
+ } |
|
9121 |
+} |
|
9122 |
+/** |
|
9123 |
+ * @desc defines how a raw task is converted into a real task and provides information to the user how to form the raw task |
|
9124 |
+ * @author fenris |
|
9125 |
+ */ |
|
9126 |
+class class_tasktemplate { |
|
9127 |
+ /** |
|
9128 |
+ * @author fenris |
|
9129 |
+ */ |
|
9130 |
+ constructor({ "description": description = null, "parameters": parameters = [], "factory": factory, }) { |
|
9131 |
+ this.description = description; |
|
9132 |
+ this.parameters = parameters; |
|
9133 |
+ this.factory = factory; |
|
9134 |
+ } |
|
9135 |
+ /** |
|
9136 |
+ * @desc converts raw parameter values to real ones |
|
9137 |
+ * @author fenris |
|
9138 |
+ */ |
|
9139 |
+ convert(object_raw, task_name) { |
|
9140 |
+ let object_ready = {}; |
|
9141 |
+ this.parameters.forEach(parameter => { |
|
9142 |
+ let value_raw; |
|
9143 |
+ if ((object_raw != null) && (parameter.name in object_raw)) { |
|
9144 |
+ value_raw = object_raw[parameter.name]; |
|
9145 |
+ } |
|
9146 |
+ else { |
|
9147 |
+ if (parameter.default_.is_nothing()) { |
|
9148 |
+ throw (new Error(`mandatory parameter '${parameter.name}' is missing in task '${task_name}'`)); |
|
9149 |
+ } |
|
9150 |
+ else { |
|
9151 |
+ value_raw = parameter.default_.cull(); |
|
9152 |
+ } |
|
9153 |
+ } |
|
9154 |
+ let messages = parameter.shape.inspect(value_raw); |
|
9155 |
+ if (messages.length > 0) { |
|
9156 |
+ let message = ""; |
|
9157 |
+ message += `given value '${instance_show(value_raw)}'`; |
|
9158 |
+ message += ` for parameter '${parameter.name}'`; |
|
9159 |
+ message += ` with shape '${instance_show(parameter.shape)}'`; |
|
9160 |
+ message += ` is malformed`; |
|
9161 |
+ message += `: ${messages.join("; ")}`; |
|
9162 |
+ throw (new Error(message)); |
|
9163 |
+ } |
|
9164 |
+ else { |
|
9165 |
+ let value_ready = parameter.extraction(value_raw); |
|
9166 |
+ object_ready[parameter.name] = value_ready; |
|
9167 |
+ } |
|
9168 |
+ }); |
|
9169 |
+ if (object_raw != null) { |
|
9170 |
+ Object.keys(object_raw) |
|
9171 |
+ .filter(key => (!this.parameters.some(parameter => (parameter.name == key)))) |
|
9172 |
+ .forEach(key => { |
|
9173 |
+ (new class_message(`unrecognized parameter '${key}' in task '${task_name}'`, { "type": "warning", "prefix": "koralle" })).stderr(); |
|
9174 |
+ }); |
|
9175 |
+ } |
|
9176 |
+ return object_ready; |
|
9177 |
+ } |
|
7400 | 9178 |
/** |
9179 |
+ * @desc does the actual conversion to a real task |
|
7401 | 9180 |
* @author fenris |
7402 | 9181 |
*/ |
7403 |
- class_task.create = function (_a, nameprefix) { |
|
7404 |
- var _b = _a["name"], name = _b === void 0 ? null : _b, _c = _a["type"], type = _c === void 0 ? null : _c, _d = _a["sub"], sub = _d === void 0 ? [] : _d, _e = _a["active"], active = _e === void 0 ? true : _e, _f = _a["parameters"], parameters = _f === void 0 ? {} : _f; |
|
7405 |
- if (nameprefix === void 0) { nameprefix = null; } |
|
7406 |
- return (class_task.get(type)(((nameprefix == null) ? "" + name : nameprefix + "-" + name), sub.map(function (rawtask) { return class_task.create(rawtask, nameprefix); }), active, parameters)); |
|
7407 |
- }; |
|
9182 |
+ create(rawtask, nameprefix = null) { |
|
9183 |
+ let data = this.convert(rawtask.parameters, rawtask.name); |
|
9184 |
+ let stuff = this.factory(data, rawtask); |
|
9185 |
+ let name = ""; |
|
9186 |
+ { |
|
9187 |
+ name = ((rawtask.name != undefined) ? rawtask.name : lib_string.generate("task_")); |
|
9188 |
+ if (nameprefix != null) { |
|
9189 |
+ name = `${nameprefix}-${name}`; |
|
9190 |
+ } |
|
9191 |
+ } |
|
9192 |
+ let active; |
|
9193 |
+ { |
|
9194 |
+ active = ((rawtask.active != undefined) ? rawtask.active : true); |
|
9195 |
+ } |
|
9196 |
+ let sub = []; |
|
9197 |
+ { |
|
9198 |
+ if (rawtask["sub"] != undefined) { |
|
9199 |
+ sub = sub.concat(rawtask.sub.map(rawtask_ => class_tasktemplate.create(rawtask_, nameprefix))); |
|
9200 |
+ } |
|
9201 |
+ if (stuff["sub"] != undefined) { |
|
9202 |
+ sub = sub.concat(stuff["sub"]); |
|
9203 |
+ } |
|
9204 |
+ } |
|
9205 |
+ let inputs = (stuff["inputs"] || []); |
|
9206 |
+ let outputs = (stuff["outputs"] || []); |
|
9207 |
+ let actions = (stuff["actions"] || []); |
|
9208 |
+ return (new class_task({ |
|
9209 |
+ "name": name, |
|
9210 |
+ "active": active, |
|
9211 |
+ "sub": sub, |
|
9212 |
+ "inputs": inputs, |
|
9213 |
+ "outputs": outputs, |
|
9214 |
+ "actions": actions, |
|
9215 |
+ })); |
|
9216 |
+ } |
|
7408 | 9217 |
/** |
9218 |
+ * @desc adds a tasktemplate to the pool |
|
7409 | 9219 |
* @author fenris |
7410 | 9220 |
*/ |
7411 |
- class_task.register = function (id, factory) { |
|
7412 |
- this.pool[id] = factory; |
|
7413 |
- }; |
|
9221 |
+ static register(id, tasktemplate) { |
|
9222 |
+ this.pool[id] = tasktemplate; |
|
9223 |
+ } |
|
7414 | 9224 |
/** |
9225 |
+ * @desc retrieves a registered tasktemplate from the pool |
|
7415 | 9226 |
* @author fenris |
7416 | 9227 |
*/ |
7417 |
- class_task.get = function (id) { |
|
9228 |
+ static get(id) { |
|
7418 | 9229 |
if (id in this.pool) { |
7419 | 9230 |
return this.pool[id]; |
7420 | 9231 |
} |
7421 | 9232 |
else { |
7422 |
- throw (new Error("no task registered with id '" + id + "'")); |
|
9233 |
+ throw (new Error(`no task registered with name '${id}'`)); |
|
9234 |
+ } |
|
7423 | 9235 |
} |
7424 |
- }; |
|
7425 | 9236 |
/** |
9237 |
+ * @desc searches for the corresponding registered tasktemplate and creates a real task |
|
7426 | 9238 |
* @author fenris |
7427 | 9239 |
*/ |
7428 |
- class_task.list = function () { |
|
7429 |
- return Object.keys(this.pool); |
|
7430 |
- }; |
|
9240 |
+ static create(rawtask, nameprefix = null) { |
|
9241 |
+ let tasktemplate = this.get(rawtask.type); |
|
9242 |
+ return tasktemplate.create(rawtask, nameprefix); |
|
9243 |
+ } |
|
7431 | 9244 |
/** |
9245 |
+ * @desc returns an overview over all available tasktemplates in markdown format |
|
7432 | 9246 |
* @author fenris |
7433 | 9247 |
*/ |
7434 |
- class_task.errormessage_mandatoryparamater = function (type, name, fieldname) { |
|
7435 |
- return "mandatory paramater '" + fieldname + "' missing in " + type + "-task '" + name + "'"; |
|
7436 |
- }; |
|
7437 |
- return class_task; |
|
7438 |
-}()); |
|
9248 |
+ static list() { |
|
9249 |
+ let str = ""; |
|
9250 |
+ lib_object.to_array(this.pool).forEach(({ "key": id, "value": tasktemplate }) => { |
|
9251 |
+ str += lib_markdown.section(2, "Task '" + lib_markdown.code(id) + "'"); |
|
9252 |
+ { |
|
9253 |
+ str += lib_markdown.section(3, "Description"); |
|
9254 |
+ str += lib_markdown.paragraph(((tasktemplate.description != null) ? tasktemplate.description : "(missing)")); |
|
9255 |
+ str += lib_markdown.paragraph(); |
|
9256 |
+ } |
|
9257 |
+ { |
|
9258 |
+ str += lib_markdown.section(3, "Parameters"); |
|
9259 |
+ tasktemplate.parameters.forEach(taskparameter => { |
|
9260 |
+ let str_ = ""; |
|
9261 |
+ { |
|
9262 |
+ // name |
|
9263 |
+ { |
|
9264 |
+ str_ += lib_markdown.paragraph(lib_markdown.code(taskparameter.name)); |
|
9265 |
+ } |
|
9266 |
+ // shape |
|
9267 |
+ { |
|
9268 |
+ str_ += lib_markdown.listitem(2, "type: " + lib_markdown.italic(instance_show(taskparameter.shape))); |
|
9269 |
+ } |
|
9270 |
+ // kind |
|
9271 |
+ { |
|
9272 |
+ let content; |
|
9273 |
+ if (taskparameter.default_.is_nothing()) { |
|
9274 |
+ content = "mandatory"; |
|
9275 |
+ } |
|
9276 |
+ else { |
|
9277 |
+ content = ("optional (default: " + lib_markdown.code(instance_show(taskparameter.default_.cull())) + ")"); |
|
9278 |
+ } |
|
9279 |
+ str_ += lib_markdown.listitem(2, "kind: " + content); |
|
9280 |
+ } |
|
9281 |
+ // description |
|
9282 |
+ { |
|
9283 |
+ str_ += lib_markdown.listitem(2, "description: " + ((taskparameter.description == null) ? "(missing)" : taskparameter.description)); |
|
9284 |
+ } |
|
9285 |
+ } |
|
9286 |
+ str += lib_markdown.listitem(1, str_); |
|
9287 |
+ }); |
|
9288 |
+ str += lib_markdown.paragraph(); |
|
9289 |
+ } |
|
9290 |
+ }); |
|
9291 |
+ return str; |
|
9292 |
+ } |
|
9293 |
+} |
|
7439 | 9294 |
/** |
9295 |
+ * @desc holds the registered tasktemplates |
|
7440 | 9296 |
* @author fenris |
7441 | 9297 |
*/ |
7442 |
-class_task.pool = {}; |
|
9298 |
+class_tasktemplate.pool = {}; |
|
7443 | 9299 |
/** |
9300 |
+ * @desc a tasktemplate for tasks which have a single input and a single output |
|
7444 | 9301 |
* @author fenris |
7445 | 9302 |
*/ |
7446 |
-var class_task_empty = (function (_super) { |
|
7447 |
- __extends(class_task_empty, _super); |
|
9303 |
+class class_tasktemplate_transductor extends class_tasktemplate { |
|
7448 | 9304 |
/** |
7449 | 9305 |
* @author fenris |
7450 | 9306 |
*/ |
7451 |
- function class_task_empty(_a) { |
|
7452 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"]["output"], output_raw = _b === void 0 ? undefined : _b; |
|
7453 |
- var _this = this; |
|
7454 |
- if (output_raw == undefined) { |
|
7455 |
- throw (new Error(class_task.errormessage_mandatoryparamater("empty", name, "output"))); |
|
9307 |
+ constructor({ "description": description = null, "parameters_additional": parameters_additional = [], "factory": factory, }) { |
|
9308 |
+ super({ |
|
9309 |
+ "description": description, |
|
9310 |
+ "parameters": ([ |
|
9311 |
+ class_taskparameter.input_single(), |
|
9312 |
+ class_taskparameter.output_single(), |
|
9313 |
+ ] |
|
9314 |
+ .concat(parameters_additional)), |
|
9315 |
+ "factory": factory, |
|
9316 |
+ }); |
|
7456 | 9317 |
} |
7457 |
- var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
|
7458 |
- _this = _super.call(this, name, sub, active, [], [output], [ |
|
7459 |
- new class_action_mkdir(output.location), |
|
7460 |
- new class_action_touch(output), |
|
7461 |
- ]) || this; |
|
7462 |
- return _this; |
|
7463 | 9318 |
} |
7464 |
- return class_task_empty; |
|
7465 |
-}(class_task)); |
|
7466 |
-class_task.register("empty", function (name, sub, active, parameters) { return new class_task_empty({ |
|
7467 |
- "name": name, "sub": sub, "active": active, |
|
7468 |
- "parameters": parameters, |
|
7469 |
-}); }); |
|
7470 | 9319 |
/** |
9320 |
+ * @desc a tasktemplate for tasks which have a list of inputs and a single output |
|
7471 | 9321 |
* @author fenris |
7472 | 9322 |
*/ |
7473 |
-var class_task_group = (function (_super) { |
|
7474 |
- __extends(class_task_group, _super); |
|
9323 |
+class class_tasktemplate_aggregator extends class_tasktemplate { |
|
7475 | 9324 |
/** |
7476 | 9325 |
* @author fenris |
7477 | 9326 |
*/ |
7478 |
- function class_task_group(_a) { |
|
7479 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"]; |
|
7480 |
- return _super.call(this, name, sub, active, [], [], []) || this; |
|
9327 |
+ constructor({ "description": description = null, "parameters_additional": parameters_additional = [], "factory": factory, }) { |
|
9328 |
+ super({ |
|
9329 |
+ "description": description, |
|
9330 |
+ "parameters": ([ |
|
9331 |
+ class_taskparameter.input_single({ "default": new class_just("DUMMY") }), |
|
9332 |
+ class_taskparameter.input_list({ "default": new class_just([]) }), |
|
9333 |
+ class_taskparameter.input_schwamm({ "default": new class_just(null) }), |
|
9334 |
+ class_taskparameter.output_single(), |
|
9335 |
+ ] |
|
9336 |
+ .concat(parameters_additional)), |
|
9337 |
+ "factory": factory, |
|
9338 |
+ }); |
|
7481 | 9339 |
} |
7482 |
- return class_task_group; |
|
7483 |
-}(class_task)); |
|
7484 |
-class_task.register("group", function (name, sub, active, parameters) { return new class_task_group({ |
|
7485 |
- "name": name, "sub": sub, "active": active, |
|
7486 |
- "parameters": parameters, |
|
7487 |
-}); }); |
|
7488 | 9340 |
/** |
7489 | 9341 |
* @author fenris |
7490 | 9342 |
*/ |
7491 |
-var class_task_script = (function (_super) { |
|
7492 |
- __extends(class_task_script, _super); |
|
9343 |
+ static inputs_all(data) { |
|
9344 |
+ return ([] |
|
9345 |
+ .concat((data["input"].as_string().includes("DUMMY")) |
|
9346 |
+ ? [] |
|
9347 |
+ : [data["input"]]) |
|
9348 |
+ .concat(data["inputs"]) |
|
9349 |
+ .concat((data["input_from_schwamm"] == null) |
|
9350 |
+ ? [] |
|
9351 |
+ : data["input_from_schwamm"])); |
|
9352 |
+ } |
|
9353 |
+} |
|
7493 | 9354 |
/** |
7494 | 9355 |
* @author fenris |
7495 | 9356 |
*/ |
7496 |
- function class_task_script(_a) { |
|
7497 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"], _c = _b["path"], path_raw = _c === void 0 ? undefined : _c, _d = _b["interpreter"], interpreter_raw = _d === void 0 ? null : _d, _e = _b["workdir"], workdir_raw = _e === void 0 ? null : _e, _f = _b["inputs"], inputs_raw = _f === void 0 ? [] : _f, _g = _b["outputs"], outputs_raw = _g === void 0 ? [] : _g; |
|
7498 |
- var _this = this; |
|
7499 |
- if (path_raw == undefined) { |
|
7500 |
- throw (new Error(class_task.errormessage_mandatoryparamater("script", name, "path"))); |
|
7501 |
- } |
|
7502 |
- var path = lib_call.use(path_raw, function (x) { return lib_path.filepointer_read(x); }); |
|
7503 |
- var workdir = lib_call.use(workdir_raw, function (x) { return ((x == null) ? null : lib_path.location_read(x)); }); |
|
7504 |
- var interpreter = lib_call.use(interpreter_raw, function (x) { return ((x == null) ? null : lib_path.filepointer_read(x)); }); |
|
7505 |
- var inputs = lib_call.use(inputs_raw, function (x) { return x.map(function (y) { return lib_path.filepointer_read(y); }); }); |
|
7506 |
- var outputs = lib_call.use(outputs_raw, function (x) { return x.map(function (y) { return lib_path.filepointer_read(y); }); }); |
|
7507 |
- _this = _super.call(this, name, sub, active, inputs, outputs, ([] |
|
7508 |
- .concat(outputs.map(function (output) { return new class_action_mkdir(output.location); })) |
|
7509 |
- .concat([ |
|
7510 |
- new class_action_exec({ |
|
7511 |
- "inputs": inputs, |
|
7512 |
- "outputs": outputs, |
|
7513 |
- "path": path, |
|
7514 |
- "interpreter": interpreter, |
|
7515 |
- "workdir": workdir, |
|
7516 |
- }), |
|
7517 |
- ]))) || this; |
|
7518 |
- return _this; |
|
9357 |
+class_tasktemplate.register("group", new class_tasktemplate({ |
|
9358 |
+ "description": "does nothing but executing the sub tasks", |
|
9359 |
+ "factory": (data) => { |
|
9360 |
+ return {}; |
|
7519 | 9361 |
} |
7520 |
- return class_task_script; |
|
7521 |
-}(class_task)); |
|
7522 |
-class_task.register("script", function (name, sub, active, parameters) { return new class_task_script({ |
|
7523 |
- "name": name, "sub": sub, "active": active, |
|
7524 |
- "parameters": parameters, |
|
7525 |
-}); }); |
|
9362 |
+})); |
|
7526 | 9363 |
/** |
7527 | 9364 |
* @author fenris |
7528 | 9365 |
*/ |
7529 |
-var class_task_copy = (function (_super) { |
|
7530 |
- __extends(class_task_copy, _super); |
|
9366 |
+function task_each_generate_output(input_raw, output_description, index) { |
|
9367 |
+ switch (output_description.kind) { |
|
9368 |
+ case "replace": { |
|
9369 |
+ let regexp = new RegExp(output_description.parameters["from"]); |
|
9370 |
+ // let filter : boolean = ((output_description.parameters["filter"] == undefined) || (output_description.parameters["from"] == true)); |
|
9371 |
+ let execute = true; |
|
9372 |
+ if (execute) { |
|
9373 |
+ let output_raw = input_raw.replace(regexp, output_description.parameters["to"]); |
|
9374 |
+ if (input_raw == output_raw) { |
|
9375 |
+ (new class_message(`replacement for input '${input_raw}' resulted in the same string`, { |
|
9376 |
+ "type": "warning", |
|
9377 |
+ "prefix": "koralle" |
|
9378 |
+ })).stderr(); |
|
9379 |
+ } |
|
9380 |
+ return output_raw; |
|
9381 |
+ } |
|
9382 |
+ else { |
|
9383 |
+ return null; |
|
9384 |
+ } |
|
9385 |
+ break; |
|
9386 |
+ } |
|
9387 |
+ case "enumerate": { |
|
9388 |
+ let folder = (output_description["parameters"]["folder"] || "build/"); |
|
9389 |
+ let prefix = (output_description["parameters"]["prefix"] || "output_"); |
|
9390 |
+ let suffix = (output_description["parameters"]["suffix"]); |
|
9391 |
+ let output_raw = (folder + "/" + prefix + index.toString() + ((suffix == null) ? "" : ("." + suffix))); |
|
9392 |
+ return output_raw; |
|
9393 |
+ break; |
|
9394 |
+ } |
|
9395 |
+ default: { |
|
9396 |
+ throw (new Error(`unhandled kind '${output_description.kind}'`)); |
|
9397 |
+ break; |
|
9398 |
+ } |
|
9399 |
+ } |
|
9400 |
+} |
|
7531 | 9401 |
/** |
7532 | 9402 |
* @author fenris |
7533 | 9403 |
*/ |
7534 |
- function class_task_copy(_a) { |
|
7535 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"], _c = _b["input"], input_raw = _c === void 0 ? null : _c, _d = _b["output"], output_raw = _d === void 0 ? null : _d, _e = _b["folder"], folder = _e === void 0 ? false : _e; |
|
7536 |
- var _this = this; |
|
7537 |
- if (input_raw == undefined) { |
|
7538 |
- throw (new Error(class_task.errormessage_mandatoryparamater("copy", name, "input"))); |
|
9404 |
+class_tasktemplate.register("each", new class_tasktemplate({ |
|
9405 |
+ "description": "executes a specific task for a list of inputs", |
|
9406 |
+ "parameters": [ |
|
9407 |
+ class_taskparameter.input_list({ "default": new class_just([]) }), |
|
9408 |
+ class_taskparameter.input_schwamm({ "default": new class_just(null) }), |
|
9409 |
+ new class_taskparameter({ |
|
9410 |
+ "name": "element_type", |
|
9411 |
+ "shape": lib_meta.from_raw({ "id": "string" }), |
|
9412 |
+ "default": new class_nothing(), |
|
9413 |
+ "description": "the type of the inner task" |
|
9414 |
+ }), |
|
9415 |
+ new class_taskparameter({ |
|
9416 |
+ "name": "element_parameters", |
|
9417 |
+ "shape": lib_meta.from_raw({ "id": "any" }), |
|
9418 |
+ "default": new class_just({}), |
|
9419 |
+ "description": "the parameters for the inner task" |
|
9420 |
+ }), |
|
9421 |
+ new class_taskparameter({ |
|
9422 |
+ "name": "output_description", |
|
9423 |
+ "shape": lib_meta.from_raw({ "id": "any" }), |
|
9424 |
+ "default": new class_nothing(), |
|
9425 |
+ "description": "how the output paths are generated" |
|
9426 |
+ }), |
|
9427 |
+ ], |
|
9428 |
+ "factory": (data, rawtask) => { |
|
9429 |
+ let inputs = data["inputs"].concat(data["input_from_schwamm"]); |
|
9430 |
+ return { |
|
9431 |
+ "sub": inputs.map((input, index) => { |
|
9432 |
+ let input_raw = input.as_string(); |
|
9433 |
+ let output_raw = task_each_generate_output(input_raw, data["output_description"], index); |
|
9434 |
+ if (output_raw == null) { |
|
9435 |
+ return null; |
|
7539 | 9436 |
} |
7540 |
- var input = lib_call.use(input_raw, function (x) { return lib_path.filepointer_read(x); }); |
|
7541 |
- if (output_raw == undefined) { |
|
7542 |
- throw (new Error(class_task.errormessage_mandatoryparamater("copy", name, "output"))); |
|
9437 |
+ else { |
|
9438 |
+ return (class_tasktemplate.create({ |
|
9439 |
+ "name": index.toString(), |
|
9440 |
+ "type": data["element_type"], |
|
9441 |
+ "parameters": lib_object.patched(data["element_parameters"], { |
|
9442 |
+ "input": input_raw, |
|
9443 |
+ "output": output_raw, |
|
9444 |
+ }) |
|
9445 |
+ }, rawtask["name"])); |
|
7543 | 9446 |
} |
7544 |
- var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
|
7545 |
- _this = _super.call(this, name, sub, active, folder ? [] : [input], folder ? [] : [output], [ |
|
7546 |
- new class_action_mkdir(output.location), |
|
7547 |
- new class_action_copy(input, output, folder), |
|
7548 |
- ]) || this; |
|
7549 |
- return _this; |
|
9447 |
+ }).filter(x => (x != null)), |
|
9448 |
+ }; |
|
7550 | 9449 |
} |
7551 |
- return class_task_copy; |
|
7552 |
-}(class_task)); |
|
7553 |
-class_task.register("copy", function (name, sub, active, parameters) { return new class_task_copy({ |
|
7554 |
- "name": name, "sub": sub, "active": active, |
|
7555 |
- "parameters": parameters, |
|
7556 |
-}); }); |
|
9450 |
+})); |
|
7557 | 9451 |
/** |
7558 | 9452 |
* @author fenris |
7559 | 9453 |
*/ |
7560 |
-var class_task_concat = (function (_super) { |
|
7561 |
- __extends(class_task_concat, _super); |
|
9454 |
+class_tasktemplate.register("empty", new class_tasktemplate({ |
|
9455 |
+ "description": "creates an empty output file", |
|
9456 |
+ "parameters": [ |
|
9457 |
+ new class_taskparameter({ |
|
9458 |
+ "name": "output", |
|
9459 |
+ "extraction": raw => lib_path.filepointer_read(raw), |
|
9460 |
+ "shape": lib_meta.from_raw({ "id": "string" }), |
|
9461 |
+ "default": new class_nothing(), |
|
9462 |
+ "description": "the path to the output file" |
|
9463 |
+ }) |
|
9464 |
+ ], |
|
9465 |
+ "factory": (data) => { |
|
9466 |
+ return { |
|
9467 |
+ "outputs": [data["output"]], |
|
9468 |
+ "actions": [ |
|
9469 |
+ new class_action_mkdir(data["output"].location), |
|
9470 |
+ new class_action_touch(data["output"]), |
|
9471 |
+ ], |
|
9472 |
+ }; |
|
9473 |
+ } |
|
9474 |
+})); |
|
7562 | 9475 |
/** |
7563 | 9476 |
* @author fenris |
7564 | 9477 |
*/ |
7565 |
- function class_task_concat(_a) { |
|
7566 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"], _c = _b["inputs"], inputs_raw = _c === void 0 ? [] : _c, _d = _b["input_from_schwamm"], schwamminput_raw = _d === void 0 ? null : _d, _e = _b["output"], output_raw = _e === void 0 ? undefined : _e; |
|
7567 |
- var _this = this; |
|
7568 |
- if (inputs_raw == undefined) { |
|
7569 |
- throw (new Error(class_task.errormessage_mandatoryparamater("concat", name, "inputs"))); |
|
7570 |
- } |
|
7571 |
- var inputs = lib_call.use(inputs_raw, function (x) { return x.map(function (y) { return lib_path.filepointer_read(y); }); }); |
|
7572 |
- var schwamminput = ((schwamminput_raw == null) |
|
7573 |
- ? null |
|
7574 |
- : { |
|
7575 |
- "path": lib_path.filepointer_read(schwamminput_raw.path), |
|
7576 |
- "group": schwamminput_raw.group, |
|
7577 |
- }); |
|
7578 |
- if (output_raw == undefined) { |
|
7579 |
- throw (new Error(class_task.errormessage_mandatoryparamater("concat", name, "output"))); |
|
7580 |
- } |
|
7581 |
- var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
|
7582 |
- _this = _super.call(this, name, sub, active, ([] |
|
7583 |
- .concat(inputs) |
|
7584 |
- .concat((schwamminput == null) |
|
7585 |
- ? [] |
|
7586 |
- : [schwamminput.path])), [output], [ |
|
7587 |
- new class_action_mkdir(output.location), |
|
7588 |
- new class_action_concat(inputs, output), |
|
7589 |
- ]) || this; |
|
7590 |
- return _this; |
|
9478 |
+class_tasktemplate.register("copy", new class_tasktemplate_transductor({ |
|
9479 |
+ "description": "copies a file", |
|
9480 |
+ "parameters_additional": [ |
|
9481 |
+ new class_taskparameter({ |
|
9482 |
+ "name": "folder", |
|
9483 |
+ "default": new class_just(false), |
|
9484 |
+ }), |
|
9485 |
+ ], |
|
9486 |
+ "factory": (data) => { |
|
9487 |
+ return { |
|
9488 |
+ "inputs": [data["input"]], |
|
9489 |
+ "outputs": /*[data["output"]]*/ [], |
|
9490 |
+ "actions": [ |
|
9491 |
+ new class_action_mkdir(data["output"].location), |
|
9492 |
+ new class_action_copy(data["input"], data["output"], data["folder"]), |
|
9493 |
+ ], |
|
9494 |
+ }; |
|
7591 | 9495 |
} |
7592 |
- return class_task_concat; |
|
7593 |
-}(class_task)); |
|
7594 |
-class_task.register("concat", function (name, sub, active, parameters) { return new class_task_concat({ |
|
7595 |
- "name": name, "sub": sub, "active": active, |
|
7596 |
- "parameters": parameters, |
|
7597 |
-}); }); |
|
9496 |
+})); |
|
7598 | 9497 |
/** |
7599 | 9498 |
* @author fenris |
7600 | 9499 |
*/ |
7601 |
-var class_task_lesscss = (function (_super) { |
|
7602 |
- __extends(class_task_lesscss, _super); |
|
9500 |
+class_tasktemplate.register("concat", new class_tasktemplate_aggregator({ |
|
9501 |
+ "description": "concatenates a list of files", |
|
9502 |
+ "factory": (data) => { |
|
9503 |
+ let inputs = class_tasktemplate_aggregator.inputs_all(data); |
|
9504 |
+ let output = data["output"]; |
|
9505 |
+ return { |
|
9506 |
+ "inputs": inputs, |
|
9507 |
+ "outputs": [output], |
|
9508 |
+ "actions": [ |
|
9509 |
+ new class_action_mkdir(output.location), |
|
9510 |
+ new class_action_concat(inputs, output), |
|
9511 |
+ ], |
|
9512 |
+ }; |
|
9513 |
+ } |
|
9514 |
+})); |
|
7603 | 9515 |
/** |
7604 | 9516 |
* @author fenris |
7605 | 9517 |
*/ |
7606 |
- function class_task_lesscss(_a) { |
|
7607 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"], _c = _b["inputs"], inputs_raw = _c === void 0 ? [] : _c, _d = _b["output"], output_raw = _d === void 0 ? undefined : _d; |
|
7608 |
- var _this = this; |
|
7609 |
- if (inputs_raw == undefined) { |
|
7610 |
- throw (new Error(class_task.errormessage_mandatoryparamater("lesscss", name, "inputs"))); |
|
7611 |
- } |
|
7612 |
- var inputs = lib_call.use(inputs_raw, function (x) { return x.map(function (y) { return lib_path.filepointer_read(y); }); }); |
|
7613 |
- if (output_raw == undefined) { |
|
7614 |
- throw (new Error(class_task.errormessage_mandatoryparamater("lesscss", name, "output"))); |
|
7615 |
- } |
|
7616 |
- var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
|
7617 |
- var filepointer_temp = new lib_path.class_filepointer(lib_path.location_read(globalvars.configuration["tempfolder"]), "_.less"); |
|
7618 |
- _this = _super.call(this, name, sub, active, inputs, [output], [ |
|
7619 |
- new class_action_mkdir(output.location), |
|
7620 |
- new class_action_concat(inputs, filepointer_temp), |
|
7621 |
- new class_action_lessc(filepointer_temp, output), |
|
7622 |
- ]) || this; |
|
7623 |
- return _this; |
|
9518 |
+class_tasktemplate.register("typescript", new class_tasktemplate_aggregator({ |
|
9519 |
+ "description": "compiles a list of typescript input files to a single javascript output file", |
|
9520 |
+ "parameters_additional": [ |
|
9521 |
+ new class_taskparameter({ |
|
9522 |
+ "name": "declaration", |
|
9523 |
+ "extraction": raw => ((raw == null) ? null : lib_path.filepointer_read(raw)), |
|
9524 |
+ "shape": lib_meta.from_raw({ "id": "string", "parameters": { "soft": true } }), |
|
9525 |
+ "default": new class_just(null), |
|
9526 |
+ "description": "the path of the file in which to write the declaration; if not set, no declaration-script will be created", |
|
9527 |
+ }), |
|
9528 |
+ new class_taskparameter({ |
|
9529 |
+ "name": "target", |
|
9530 |
+ "shape": lib_meta.from_raw({ "id": "string", "parameters": { "soft": true } }), |
|
9531 |
+ "default": new class_just(null), |
|
9532 |
+ "description": "the tsc-switch 'target'; value NULL means 'don't specify'", |
|
9533 |
+ }), |
|
9534 |
+ new class_taskparameter({ |
|
9535 |
+ "name": "allowUnreachableCode", |
|
9536 |
+ "shape": lib_meta.from_raw({ "id": "boolean", "parameters": { "soft": true } }), |
|
9537 |
+ "default": new class_just(null), |
|
9538 |
+ "description": "the tsc-switch 'allowUnreachableCode'; value NULL means 'don't specify'", |
|
9539 |
+ }), |
|
9540 |
+ ], |
|
9541 |
+ "factory": (data) => { |
|
9542 |
+ let inputs = class_tasktemplate_aggregator.inputs_all(data); |
|
9543 |
+ let outputs = [data["output"]]; |
|
9544 |
+ let actions = [ |
|
9545 |
+ new class_action_mkdir(data["output"].location), |
|
9546 |
+ new class_action_tsc(inputs, data["output"], data["target"], data["allowUnreachableCode"], data["declaration"]), |
|
9547 |
+ ]; |
|
9548 |
+ if (data["declaration"] != null) { |
|
9549 |
+ outputs = outputs.concat([ |
|
9550 |
+ data["declaration"], |
|
9551 |
+ ]); |
|
9552 |
+ actions = actions.concat([ |
|
9553 |
+ new class_action_mkdir(data["declaration"].location), |
|
9554 |
+ new class_action_move({ |
|
9555 |
+ "from": new lib_path.class_filepointer(data["output"].location, data["output"].filename.replace(new RegExp(".js$"), ".d.ts")), |
|
9556 |
+ "to": data["declaration"], |
|
9557 |
+ }), |
|
9558 |
+ ]); |
|
7624 | 9559 |
} |
7625 |
- return class_task_lesscss; |
|
7626 |
-}(class_task)); |
|
7627 |
-class_task.register("lesscss", function (name, sub, active, parameters) { return new class_task_lesscss({ |
|
7628 |
- "name": name, "sub": sub, "active": active, |
|
7629 |
- "parameters": parameters, |
|
7630 |
-}); }); |
|
9560 |
+ return { |
|
9561 |
+ "inputs": inputs, |
|
9562 |
+ "outputs": outputs, |
|
9563 |
+ "actions": actions, |
|
9564 |
+ }; |
|
9565 |
+ }, |
|
9566 |
+})); |
|
7631 | 9567 |
/** |
7632 |
- * @author neu3no |
|
9568 |
+ * @author fenris |
|
7633 | 9569 |
*/ |
7634 |
-var class_task_babel = (function (_super) { |
|
7635 |
- __extends(class_task_babel, _super); |
|
9570 |
+class_tasktemplate.register("lesscss", new class_tasktemplate_aggregator({ |
|
9571 |
+ "description": "compiles a list of lesscss input files to a single css output file", |
|
9572 |
+ "factory": (data) => { |
|
9573 |
+ let filepointer_temp = new lib_path.class_filepointer(lib_path.location_read(globalvars.configuration["tempfolder"]), "_.less"); |
|
9574 |
+ return { |
|
9575 |
+ "inputs": class_tasktemplate_aggregator.inputs_all(data), |
|
9576 |
+ "outputs": data["outputs"], |
|
9577 |
+ "actions": [ |
|
9578 |
+ new class_action_mkdir(data["output"].location), |
|
9579 |
+ new class_action_concat(class_tasktemplate_aggregator.inputs_all(data), filepointer_temp), |
|
9580 |
+ new class_action_lessc(filepointer_temp, data["output"]), |
|
9581 |
+ ], |
|
9582 |
+ }; |
|
9583 |
+ }, |
|
9584 |
+})); |
|
7636 | 9585 |
/** |
7637 |
- * @author neu3no |
|
9586 |
+ * @author fenris |
|
7638 | 9587 |
*/ |
7639 |
- function class_task_babel(_a) { |
|
7640 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"], minify = _b["minify"], preset = _b["preset"], inputs_raw = _b["inputs"], output_raw = _b["output"]; |
|
7641 |
- var _this = this; |
|
7642 |
- if (inputs_raw == undefined) { |
|
7643 |
- throw (new Error(class_task.errormessage_mandatoryparamater("babel", name, "inputs"))); |
|
7644 |
- } |
|
7645 |
- var inputs = lib_call.use(inputs_raw, function (x) { return x.map(function (y) { return lib_path.filepointer_read(y); }); }); |
|
7646 |
- if (output_raw == undefined) { |
|
7647 |
- throw (new Error(class_task.errormessage_mandatoryparamater("babel", name, "output"))); |
|
7648 |
- } |
|
7649 |
- var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
|
7650 |
- _this = _super.call(this, name, sub, active, inputs, [output], [ |
|
7651 |
- new class_action_mkdir(output.location), |
|
7652 |
- new class_action_babel(inputs, output, preset, minify), |
|
7653 |
- ]) || this; |
|
7654 |
- return _this; |
|
7655 |
- } |
|
7656 |
- return class_task_babel; |
|
7657 |
-}(class_task)); |
|
7658 |
-class_task.register("babel", function (name, sub, active, parameters) { return new class_task_babel({ |
|
7659 |
- "name": name, "sub": sub, "active": active, |
|
7660 |
- "parameters": parameters, |
|
7661 |
-}); }); |
|
9588 |
+class_tasktemplate.register("php", new class_tasktemplate_aggregator({ |
|
9589 |
+ "description": "compiles a list of php input files to a single output file", |
|
9590 |
+ "parameters_additional": [ |
|
9591 |
+ new class_taskparameter({ |
|
9592 |
+ "name": "only_last", |
|
9593 |
+ "shape": lib_meta.from_raw({ "id": "boolean" }), |
|
9594 |
+ "default": new class_just(false), |
|
9595 |
+ "description": "only compile the last file in the list and use the others as dependencies", |
|
9596 |
+ }), |
|
9597 |
+ ], |
|
9598 |
+ "factory": (data) => { |
|
9599 |
+ let inputs = class_tasktemplate_aggregator.inputs_all(data); |
|
9600 |
+ return { |
|
9601 |
+ "inputs": inputs, |
|
9602 |
+ "outputs": data["outputs"], |
|
9603 |
+ "actions": [ |
|
9604 |
+ new class_action_mkdir(data["output"].location), |
|
9605 |
+ new class_action_php(inputs, data["output"], data["only_last"]), |
|
9606 |
+ ], |
|
9607 |
+ }; |
|
9608 |
+ }, |
|
9609 |
+})); |
|
7662 | 9610 |
/** |
7663 |
- * @author fenris |
|
9611 |
+ * @author fenris,neu3no |
|
7664 | 9612 |
*/ |
7665 |
-var class_task_typescript = (function (_super) { |
|
7666 |
- __extends(class_task_typescript, _super); |
|
9613 |
+class_tasktemplate.register("babel", new class_tasktemplate_aggregator({ |
|
9614 |
+ "description": "executes the babel transpiler", |
|
9615 |
+ "parameters_additional": [ |
|
9616 |
+ new class_taskparameter({ |
|
9617 |
+ "name": "preset", |
|
9618 |
+ "shape": lib_meta.from_raw({ "id": "string" }), |
|
9619 |
+ "default": new class_just(null), |
|
9620 |
+ "description": "[deprecated] single plugin; use 'presets' parameter instead (you can still use this parameter; its value is added to the plugin list)", |
|
9621 |
+ }), |
|
9622 |
+ new class_taskparameter({ |
|
9623 |
+ "name": "presets", |
|
9624 |
+ "shape": lib_meta.from_raw({ "id": "array", "parameters": { "shape_element": { "id": "string" } } }), |
|
9625 |
+ "default": new class_just([]), |
|
9626 |
+ "description": "a list of presets to use", |
|
9627 |
+ }), |
|
9628 |
+ new class_taskparameter({ |
|
9629 |
+ "name": "plugins", |
|
9630 |
+ "shape": lib_meta.from_raw({ "id": "array", "parameters": { "shape_element": { "id": "string" } } }), |
|
9631 |
+ "default": new class_just([]), |
|
9632 |
+ "description": "a list of plugins to use", |
|
9633 |
+ }), |
|
9634 |
+ new class_taskparameter({ |
|
9635 |
+ "name": "minify", |
|
9636 |
+ "shape": lib_meta.from_raw({ "id": "boolean" }), |
|
9637 |
+ "default": new class_just(false), |
|
9638 |
+ "description": "whether to pass the 'minify' argument to the babel command", |
|
9639 |
+ }), |
|
9640 |
+ ], |
|
9641 |
+ "factory": (data) => { |
|
9642 |
+ let inputs = class_tasktemplate_aggregator.inputs_all(data); |
|
9643 |
+ return { |
|
9644 |
+ "inputs": inputs, |
|
9645 |
+ "outputs": [data["output"]], |
|
9646 |
+ "actions": [ |
|
9647 |
+ new class_action_mkdir(data["output"].location), |
|
9648 |
+ new class_action_babel(inputs, data["output"], data["presets"].concat((data["preset"] == null) ? [] : [data["preset"]]), data["plugins"], data["minify"]), |
|
9649 |
+ ], |
|
9650 |
+ }; |
|
9651 |
+ } |
|
9652 |
+})); |
|
7667 | 9653 |
/** |
7668 | 9654 |
* @author fenris |
7669 | 9655 |
*/ |
7670 |
- function class_task_typescript(_a) { |
|
7671 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"], _c = _b["inputs"], inputs_raw = _c === void 0 ? [] : _c, _d = _b["output"], output_raw = _d === void 0 ? null : _d, _e = _b["target"], target = _e === void 0 ? null : _e, _f = _b["allowUnreachableCode"], allowUnreachableCode = _f === void 0 ? null : _f, _g = _b["declaration"], declaration_raw = _g === void 0 ? null : _g; |
|
7672 |
- var _this = this; |
|
7673 |
- /* |
|
7674 |
- [ |
|
7675 |
- new class_taskparameter<Array<string>, Array<lib_path.class_filepointer>>( |
|
7676 |
- { |
|
9656 |
+class_tasktemplate.register("schwamm", new class_tasktemplate({ |
|
9657 |
+ "description": null, |
|
9658 |
+ "parameters": [ |
|
9659 |
+ new class_taskparameter({ |
|
9660 |
+ "name": "includes", |
|
9661 |
+ "extraction": raw => raw.map(path => lib_path.filepointer_read(path)), |
|
9662 |
+ "shape": lib_meta.from_raw({ |
|
9663 |
+ "id": "array", |
|
9664 |
+ "parameters": { |
|
9665 |
+ "shape_element": { |
|
9666 |
+ "id": "string" |
|
9667 |
+ } |
|
9668 |
+ } |
|
9669 |
+ }), |
|
9670 |
+ "default": new class_just([]), |
|
9671 |
+ }), |
|
9672 |
+ new class_taskparameter({ |
|
7677 | 9673 |
"name": "inputs", |
7678 |
- "type": { |
|
9674 |
+ "extraction": raw => lib_object.map(raw, paths => paths.map(path => lib_path.filepointer_read(path))), |
|
9675 |
+ "shape": lib_meta.from_raw({ |
|
9676 |
+ "id": "map", |
|
9677 |
+ "parameters": { |
|
9678 |
+ "shape_key": { |
|
9679 |
+ "id": "string" |
|
9680 |
+ }, |
|
9681 |
+ "shape_value": { |
|
7679 | 9682 |
"id": "array", |
7680 | 9683 |
"parameters": { |
7681 |
- "type_element": { |
|
9684 |
+ "shape_element": { |
|
9685 |
+ "id": "string" |
|
9686 |
+ } |
|
9687 |
+ } |
|
9688 |
+ } |
|
9689 |
+ } |
|
9690 |
+ }), |
|
9691 |
+ "default": new class_just({}), |
|
9692 |
+ }), |
|
9693 |
+ new class_taskparameter({ |
|
9694 |
+ "name": "output", |
|
9695 |
+ "extraction": raw => { |
|
9696 |
+ let result = {}; |
|
9697 |
+ if ("save" in raw) { |
|
9698 |
+ result["save"] = lib_path.filepointer_read(raw["save"]); |
|
9699 |
+ } |
|
9700 |
+ if ("dump" in raw) { |
|
9701 |
+ result["dump"] = lib_object.map(raw["dump"], path => lib_path.filepointer_read(path)); |
|
9702 |
+ } |
|
9703 |
+ return result; |
|
9704 |
+ }, |
|
9705 |
+ "shape": lib_meta.from_raw({ |
|
9706 |
+ "id": "object", |
|
9707 |
+ "parameters": { |
|
9708 |
+ "fields": [ |
|
9709 |
+ { |
|
9710 |
+ "name": "save", |
|
9711 |
+ "shape": { |
|
7682 | 9712 |
"id": "string", |
9713 |
+ "parameters": { |
|
9714 |
+ "soft": true |
|
9715 |
+ } |
|
9716 |
+ } |
|
7683 | 9717 |
}, |
9718 |
+ { |
|
9719 |
+ "name": "dump", |
|
9720 |
+ "shape": { |
|
9721 |
+ "id": "map", |
|
9722 |
+ "parameters": { |
|
9723 |
+ "shape_key": { |
|
9724 |
+ "id": "string" |
|
7684 | 9725 |
}, |
9726 |
+ "shape_value": { |
|
9727 |
+ "id": "string" |
|
7685 | 9728 |
}, |
7686 |
- "mandatory": false, |
|
7687 |
- "default": [], |
|
7688 |
- "key": "inputs", |
|
7689 |
- "extraction": raw => lib_call.use( |
|
7690 |
- raw, |
|
7691 |
- x => x.map(y => lib_path.filepointer_read(y)) |
|
7692 |
- ), |
|
7693 |
- "description": "the paths of the source files", |
|
7694 |
- } |
|
7695 |
- ), |
|
7696 |
- new class_taskparameter<string>( |
|
9729 |
+ "soft": true |
|
9730 |
+ } |
|
9731 |
+ } |
|
9732 |
+ } |
|
9733 |
+ ] |
|
9734 |
+ } |
|
9735 |
+ }), |
|
9736 |
+ }), |
|
9737 |
+ ], |
|
9738 |
+ "factory": (data) => { |
|
9739 |
+ let inputs = []; |
|
9740 |
+ let outputs = []; |
|
9741 |
+ let actions = []; |
|
9742 |
+ // includes |
|
7697 | 9743 |
{ |
7698 |
- "type": { |
|
7699 |
- "id": "string", |
|
9744 |
+ inputs = inputs.concat(data["includes"]); |
|
9745 |
+ } |
|
9746 |
+ // inputs |
|
9747 |
+ { |
|
9748 |
+ inputs = inputs.concat(lib_object.values(data["inputs"]).reduce((x, y) => x.concat(y), [])); |
|
9749 |
+ } |
|
9750 |
+ // output |
|
9751 |
+ { |
|
9752 |
+ if ("save" in data["output"]) { |
|
9753 |
+ outputs = outputs.concat(data["output"]["save"]); |
|
9754 |
+ actions = actions.concat([ |
|
9755 |
+ new class_action_mkdir(data["output"]["save"].location), |
|
9756 |
+ new class_action_schwamm(data["includes"], data["inputs"], data["output"]["save"]), |
|
9757 |
+ ]); |
|
9758 |
+ } |
|
9759 |
+ if ("dump" in data["output"]) { |
|
9760 |
+ outputs = outputs.concat(lib_object.values(data["output"]["dump"]).reduce((x, y) => x.concat(y), [])); |
|
9761 |
+ actions = actions.concat(lib_object.to_array(data["output"]["dump"]) |
|
9762 |
+ .map(({ "key": key, "value": value }) => [ |
|
9763 |
+ new class_action_mkdir(value.location), |
|
9764 |
+ new class_action_schwamm(data["includes"], data["inputs"], undefined, key, value), |
|
9765 |
+ ]) |
|
9766 |
+ .reduce((x, y) => x.concat(y), [])); |
|
9767 |
+ } |
|
9768 |
+ } |
|
9769 |
+ return { |
|
9770 |
+ "inputs": inputs, |
|
9771 |
+ "outputs": outputs, |
|
9772 |
+ "actions": actions, |
|
9773 |
+ }; |
|
7700 | 9774 |
}, |
7701 |
- "name": "output", |
|
7702 |
- "key": "output", |
|
7703 |
- "mandatory": true, |
|
7704 |
- "default": null, |
|
7705 |
- "description": "the path of the file in which to write the compilation", |
|
9775 |
+})); |
|
9776 |
+/** |
|
9777 |
+ * @author fenris |
|
9778 |
+ */ |
|
9779 |
+class_tasktemplate.register("schwamm-create", new class_tasktemplate({ |
|
9780 |
+ "description": null, |
|
9781 |
+ "parameters": [ |
|
9782 |
+ new class_taskparameter({ |
|
9783 |
+ "name": "includes", |
|
9784 |
+ "extraction": raw => raw.map(path => lib_path.filepointer_read(path)), |
|
9785 |
+ "shape": lib_meta.from_raw({ |
|
9786 |
+ "id": "array", |
|
9787 |
+ "parameters": { |
|
9788 |
+ "shape_element": { |
|
9789 |
+ "id": "string" |
|
9790 |
+ } |
|
7706 | 9791 |
} |
7707 |
- ), |
|
7708 |
- new class_taskparameter<string>( |
|
7709 |
- { |
|
7710 |
- "type": { |
|
7711 |
- "id": "string", |
|
9792 |
+ }), |
|
9793 |
+ "default": new class_just([]), |
|
9794 |
+ }), |
|
9795 |
+ new class_taskparameter({ |
|
9796 |
+ "name": "adhoc", |
|
9797 |
+ "extraction": raw => lib_object.map(raw, paths => paths.map(path => lib_path.filepointer_read(path))), |
|
9798 |
+ "shape": lib_meta.from_raw({ |
|
9799 |
+ "id": "map", |
|
9800 |
+ "parameters": { |
|
9801 |
+ "shape_key": { |
|
9802 |
+ "id": "string" |
|
7712 | 9803 |
}, |
7713 |
- "name": "declaration", |
|
7714 |
- "key": "declaration", |
|
7715 |
- "mandatory": false, |
|
7716 |
- "default": null, |
|
7717 |
- "description": "the path of the file in which to write the declaration; if not set, no declaration-script will be created", |
|
9804 |
+ "shape_value": { |
|
9805 |
+ "id": "array", |
|
9806 |
+ "parameters": { |
|
9807 |
+ "shape_element": { |
|
9808 |
+ "id": "string" |
|
7718 | 9809 |
} |
7719 |
- ), |
|
7720 |
- new class_taskparameter<string>( |
|
7721 |
- { |
|
7722 |
- "type": { |
|
7723 |
- "id": "string", |
|
7724 |
- }, |
|
7725 |
- "name": "target", |
|
7726 |
- "key": "target", |
|
7727 |
- "mandatory": false, |
|
7728 |
- "default": null, |
|
7729 |
- "description": "the tsc-switch 'target'; default: don't specify", |
|
7730 | 9810 |
} |
7731 |
- ), |
|
7732 |
- new class_taskparameter<boolean>( |
|
7733 |
- { |
|
7734 |
- "type": { |
|
7735 |
- "id": "boolean", |
|
7736 |
- }, |
|
7737 |
- "name": "allowUnreachableCode", |
|
7738 |
- "key": "allow_unreachable_code", |
|
7739 |
- "mandatory": false, |
|
7740 |
- "default": null, |
|
7741 |
- "description": "the tsc-switch 'allowUnreachableCode'; default: don't specify", |
|
7742 | 9811 |
} |
7743 |
- ), |
|
7744 |
- ] |
|
7745 |
- */ |
|
7746 |
- var inputs = lib_call.use(inputs_raw, function (x) { return x.map(function (y) { return lib_path.filepointer_read(y); }); }); |
|
7747 |
- if (output_raw == undefined) { |
|
7748 |
- throw (new Error(class_task.errormessage_mandatoryparamater("typescript", name, "output"))); |
|
7749 | 9812 |
} |
7750 |
- var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
|
7751 |
- var declaration = lib_call.use(declaration_raw, function (x) { return ((x == null) ? null : lib_path.filepointer_read(x)); }); |
|
7752 |
- var original = lib_call.use(output_raw, lib_call.compose(function (x) { return x.replace(new RegExp(".js$"), ".d.ts"); }, function (x) { return lib_path.filepointer_read(x); })); |
|
7753 |
- _this = _super.call(this, name, sub, active, inputs, ([] |
|
7754 |
- .concat([output]) |
|
7755 |
- .concat((declaration == null) |
|
7756 |
- ? [] |
|
7757 |
- : [declaration])), ([] |
|
7758 |
- .concat([ |
|
7759 |
- new class_action_mkdir(output.location), |
|
7760 |
- new class_action_tsc(inputs, output, target, allowUnreachableCode, declaration), |
|
7761 |
- ]) |
|
7762 |
- .concat((declaration == null) |
|
7763 |
- ? |
|
7764 |
- [] |
|
7765 |
- : |
|
7766 |
- [ |
|
7767 |
- new class_action_mkdir(declaration.location), |
|
7768 |
- new class_action_move({ |
|
7769 |
- "from": original, |
|
7770 |
- "to": declaration, |
|
7771 | 9813 |
}), |
7772 |
- ]))) || this; |
|
7773 |
- return _this; |
|
9814 |
+ "default": new class_just({}), |
|
9815 |
+ }), |
|
9816 |
+ class_taskparameter.output_single(), |
|
9817 |
+ ], |
|
9818 |
+ "factory": (data) => { |
|
9819 |
+ let inputs = []; |
|
9820 |
+ let outputs = []; |
|
9821 |
+ let actions = []; |
|
9822 |
+ // includes |
|
9823 |
+ { |
|
9824 |
+ inputs = inputs.concat(data["includes"]); |
|
7774 | 9825 |
} |
7775 |
- return class_task_typescript; |
|
7776 |
-}(class_task)); |
|
7777 |
-class_task.register("typescript", function (name, sub, active, parameters) { return new class_task_typescript({ |
|
7778 |
- "name": name, "sub": sub, "active": active, |
|
7779 |
- "parameters": parameters, |
|
7780 |
-}); }); |
|
7781 |
-/** |
|
7782 |
- * @author fenris |
|
7783 |
- */ |
|
7784 |
-var class_task_php = (function (_super) { |
|
7785 |
- __extends(class_task_php, _super); |
|
7786 |
- /** |
|
7787 |
- * @author fenris |
|
7788 |
- */ |
|
7789 |
- function class_task_php(_a) { |
|
7790 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"], _c = _b["inputs"], inputs_raw = _c === void 0 ? [] : _c, _d = _b["output"], output_raw = _d === void 0 ? null : _d, _e = _b["only_first"], only_first = _e === void 0 ? false : _e, _f = _b["only_last"], only_last = _f === void 0 ? false : _f; |
|
7791 |
- var _this = this; |
|
7792 |
- var inputs = lib_call.use(inputs_raw, function (x) { return x.map(function (y) { return lib_path.filepointer_read(y); }); }); |
|
7793 |
- if (output_raw == undefined) { |
|
7794 |
- throw (new Error(class_task.errormessage_mandatoryparamater("php", name, "output"))); |
|
9826 |
+ // adhoc |
|
9827 |
+ { |
|
9828 |
+ inputs = inputs.concat(lib_object.values(data["adhoc"]).reduce((x, y) => x.concat(y), [])); |
|
7795 | 9829 |
} |
7796 |
- var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
|
7797 |
- _this = _super.call(this, name, sub, active, inputs, [output], [ |
|
7798 |
- new class_action_mkdir(output.location), |
|
7799 |
- new class_action_php(inputs, output, only_first, only_last), |
|
7800 |
- ]) || this; |
|
7801 |
- return _this; |
|
9830 |
+ // output |
|
9831 |
+ { |
|
9832 |
+ outputs = outputs.concat([data["output"]]); |
|
9833 |
+ actions = actions.concat([ |
|
9834 |
+ new class_action_mkdir(data["output"].location), |
|
9835 |
+ new class_action_schwamm(data["includes"], data["adhoc"], data["output"]), |
|
9836 |
+ ]); |
|
7802 | 9837 |
} |
7803 |
- return class_task_php; |
|
7804 |
-}(class_task)); |
|
7805 |
-class_task.register("php", function (name, sub, active, parameters) { return new class_task_php({ |
|
7806 |
- "name": name, "sub": sub, "active": active, |
|
7807 |
- "parameters": parameters, |
|
7808 |
-}); }); |
|
7809 |
-/** |
|
7810 |
- * @author fenris |
|
7811 |
- */ |
|
7812 |
-var class_task_schwamm = (function (_super) { |
|
7813 |
- __extends(class_task_schwamm, _super); |
|
9838 |
+ return { |
|
9839 |
+ "inputs": inputs, |
|
9840 |
+ "outputs": outputs, |
|
9841 |
+ "actions": actions, |
|
9842 |
+ }; |
|
9843 |
+ }, |
|
9844 |
+})); |
|
7814 | 9845 |
/** |
7815 | 9846 |
* @author fenris |
7816 | 9847 |
*/ |
7817 |
- function class_task_schwamm(_a) { |
|
7818 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"], _c = _b["includes"], includes_raw = _c === void 0 ? [] : _c, _d = _b["inputs"], inputs_raw = _d === void 0 ? {} : _d, _e = _b["output"], _f = _e["save"], save_raw = _f === void 0 ? null : _f, _g = _e["dump"], dump_raw = _g === void 0 ? {} : _g, _h = _e["locmerge"], locmerge_raw = _h === void 0 ? {} : _h; |
|
7819 |
- var _this = this; |
|
7820 |
- var includes = lib_call.use(includes_raw, function (x) { return x.map(function (y) { return lib_path.filepointer_read(y); }); }); |
|
7821 |
- var inputs = lib_call.use(inputs_raw, function (x) { return lib_object.map(x, function (members) { return members.map(function (member) { return lib_path.filepointer_read(member); }); }); }); |
|
7822 |
- var save = lib_call.use(save_raw, function (y) { return ((y == null) ? null : lib_path.filepointer_read(y)); }); |
|
7823 |
- var dump = lib_call.use(dump_raw, function (x) { return lib_object.map(x, function (y) { return lib_path.filepointer_read(y); }); }); |
|
7824 |
- var locmerge = lib_call.use(locmerge_raw, function (x) { return lib_object.map(x, function (y) { return lib_object.map(y, function (z) { return lib_path.filepointer_read(z); }); }); }); |
|
7825 |
- _this = _super.call(this, name, sub, active, ([] |
|
7826 |
- .concat(includes) |
|
7827 |
- .concat(lib_object.values(inputs).reduce(function (x, y) { return x.concat(y); }, []))), ([] |
|
7828 |
- .concat((save == null) |
|
7829 |
- ? [] |
|
7830 |
- : [save]) |
|
7831 |
- .concat(lib_object.values(dump).reduce(function (x, y) { return x.concat(y); }, [])) |
|
7832 |
- .concat(lib_object.values(locmerge) |
|
7833 |
- .map(function (z) { return lib_object.values(z).reduce(function (x, y) { return x.concat(y); }, []); }) |
|
7834 |
- .reduce(function (x, y) { return x.concat(y); }, []))), ([] |
|
7835 |
- .concat((save == null) |
|
7836 |
- ? [] |
|
7837 |
- : [ |
|
7838 |
- new class_action_mkdir(save.location), |
|
7839 |
- new class_action_schwamm(includes, inputs, save), |
|
9848 |
+class_tasktemplate.register("schwamm-apply", new class_tasktemplate({ |
|
9849 |
+ "description": null, |
|
9850 |
+ "parameters": [ |
|
9851 |
+ new class_taskparameter({ |
|
9852 |
+ "name": "path", |
|
9853 |
+ "extraction": raw => lib_path.filepointer_read(raw), |
|
9854 |
+ "shape": lib_meta.from_raw({ "id": "string" }), |
|
9855 |
+ }), |
|
9856 |
+ new class_taskparameter({ |
|
9857 |
+ "name": "outputs", |
|
9858 |
+ "extraction": raw => lib_object.map(raw, paths => paths.map(path => lib_path.filepointer_read(path))), |
|
9859 |
+ "shape": lib_meta.from_raw({ |
|
9860 |
+ "id": "map", |
|
9861 |
+ "parameters": { |
|
9862 |
+ "shape_key": { |
|
9863 |
+ "id": "string" |
|
9864 |
+ }, |
|
9865 |
+ "shape_value": { |
|
9866 |
+ "id": "array", |
|
9867 |
+ "parameters": { |
|
9868 |
+ "shape_element": { |
|
9869 |
+ "id": "string" |
|
9870 |
+ } |
|
9871 |
+ } |
|
9872 |
+ } |
|
9873 |
+ } |
|
9874 |
+ }), |
|
9875 |
+ "default": new class_just({}), |
|
9876 |
+ }), |
|
9877 |
+ ], |
|
9878 |
+ "factory": (data) => { |
|
9879 |
+ let inputs = []; |
|
9880 |
+ let outputs = []; |
|
9881 |
+ let actions = []; |
|
9882 |
+ // path |
|
9883 |
+ { |
|
9884 |
+ inputs = inputs.concat([data["path"]]); |
|
9885 |
+ } |
|
9886 |
+ // output |
|
9887 |
+ { |
|
9888 |
+ outputs = outputs.concat(lib_object.values(data["output"]).reduce((x, y) => x.concat(y), [])); |
|
9889 |
+ actions = actions.concat(lib_object.to_array(data["output"]) |
|
9890 |
+ .map(({ "key": key, "value": value }) => [ |
|
9891 |
+ new class_action_mkdir(value.location), |
|
9892 |
+ new class_action_schwamm([data["path"]], {}, undefined, key, value), |
|
7840 | 9893 |
]) |
7841 |
- .concat(lib_object.to_array(dump) |
|
7842 |
- .map(function (pair) { return [ |
|
7843 |
- new class_action_mkdir(pair.value.location), |
|
7844 |
- new class_action_schwamm(includes, inputs, undefined, pair.key, pair.value), |
|
7845 |
- ]; }) |
|
7846 |
- .reduce(function (x, y) { return x.concat(y); }, [])) |
|
7847 |
- .concat(lib_object.to_array(locmerge) |
|
7848 |
- .map(function (pair) { return lib_object.to_array(pair.value) |
|
7849 |
- .map(function (pair_) { return [ |
|
7850 |
- new class_action_mkdir(pair_.value.location), |
|
7851 |
- new class_action_schwamm(includes, inputs, undefined, undefined, undefined, pair.key, pair_.key, pair_.value), |
|
7852 |
- ]; }) |
|
7853 |
- .reduce(function (x, y) { return x.concat(y); }, []); }) |
|
7854 |
- .reduce(function (x, y) { return x.concat(y); }, [])))) || this; |
|
7855 |
- return _this; |
|
9894 |
+ .reduce((x, y) => x.concat(y), [])); |
|
7856 | 9895 |
} |
7857 |
- return class_task_schwamm; |
|
7858 |
-}(class_task)); |
|
7859 |
-class_task.register("schwamm", function (name, sub, active, parameters) { return new class_task_schwamm({ |
|
7860 |
- "name": name, "sub": sub, "active": active, |
|
7861 |
- "parameters": parameters, |
|
7862 |
-}); }); |
|
9896 |
+ return { |
|
9897 |
+ "inputs": inputs, |
|
9898 |
+ "outputs": outputs, |
|
9899 |
+ "actions": actions, |
|
9900 |
+ }; |
|
9901 |
+ }, |
|
9902 |
+})); |
|
7863 | 9903 |
/** |
7864 | 9904 |
* @author fenris |
7865 | 9905 |
*/ |
7866 |
-var class_task_schwamm_create = (function (_super) { |
|
7867 |
- __extends(class_task_schwamm_create, _super); |
|
9906 |
+class_tasktemplate.register("locmerge", new class_tasktemplate_aggregator({ |
|
9907 |
+ "description": "executes a locmerge command", |
|
9908 |
+ "parameters_additional": [], |
|
9909 |
+ "factory": (data) => { |
|
9910 |
+ let inputs = class_tasktemplate_aggregator.inputs_all(data); |
|
9911 |
+ return { |
|
9912 |
+ "inputs": inputs, |
|
9913 |
+ "outputs": [], |
|
9914 |
+ "actions": [ |
|
9915 |
+ new class_action_mkdir(data["output"].location), |
|
9916 |
+ new class_action_locmerge(inputs, data["output"]), |
|
9917 |
+ ], |
|
9918 |
+ }; |
|
9919 |
+ }, |
|
9920 |
+})); |
|
7868 | 9921 |
/** |
7869 | 9922 |
* @author fenris |
7870 | 9923 |
*/ |
7871 |
- function class_task_schwamm_create(_a) { |
|
7872 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"], _c = _b["includes"], includes_raw = _c === void 0 ? [] : _c, _d = _b["adhoc"], adhoc_raw = _d === void 0 ? {} : _d, _e = _b["output"], output_raw = _e === void 0 ? null : _e, _f = _b["dir"], dir_raw = _f === void 0 ? null : _f; |
|
7873 |
- var _this = this; |
|
7874 |
- var includes = lib_call.use(includes_raw, function (x) { return x.map(function (y) { return lib_path.filepointer_read(y); }); }); |
|
7875 |
- var adhoc = lib_call.use(adhoc_raw, function (x) { return lib_object.map(x, function (members) { return members.map(function (member) { return lib_path.filepointer_read(member); }); }); }); |
|
7876 |
- if (output_raw == undefined) { |
|
7877 |
- throw (new Error(class_task.errormessage_mandatoryparamater("schamm-create", name, "output"))); |
|
7878 |
- } |
|
7879 |
- var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
|
7880 |
- var dir = lib_call.use(dir_raw, function (x) { return ((x == null) ? null : lib_path.location_read(x)); }); |
|
7881 |
- _this = _super.call(this, name, sub, active, includes.concat(lib_object.values(adhoc).reduce(function (x, y) { return x.concat(y); }, [])), [output], [ |
|
7882 |
- new class_action_mkdir(output.location), |
|
7883 |
- new class_action_schwamm_create(includes, adhoc, output, dir), |
|
7884 |
- ]) || this; |
|
7885 |
- return _this; |
|
7886 |
- } |
|
7887 |
- return class_task_schwamm_create; |
|
7888 |
-}(class_task)); |
|
7889 |
-class_task.register("schwamm-create", function (name, sub, active, parameters) { return new class_task_schwamm_create({ |
|
7890 |
- "name": name, "sub": sub, "active": active, |
|
7891 |
- "parameters": parameters, |
|
7892 |
-}); }); |
|
9924 |
+class_tasktemplate.register("script", new class_tasktemplate({ |
|
9925 |
+ "description": "executes an external script", |
|
9926 |
+ "parameters": [ |
|
9927 |
+ class_taskparameter.input_list({ "default": new class_just([]) }), |
|
9928 |
+ class_taskparameter.output_list({ "default": new class_just([]) }), |
|
9929 |
+ new class_taskparameter({ |
|
9930 |
+ "name": "path", |
|
9931 |
+ "extraction": raw => lib_path.filepointer_read(raw), |
|
9932 |
+ "shape": lib_meta.from_raw({ "id": "string" }), |
|
9933 |
+ "default": new class_nothing(), |
|
9934 |
+ "description": "the path to the script", |
|
9935 |
+ }), |
|
9936 |
+ new class_taskparameter({ |
|
9937 |
+ "name": "interpreter", |
|
9938 |
+ "extraction": raw => ((raw == null) ? null : lib_path.filepointer_read(raw)), |
|
9939 |
+ "shape": lib_meta.from_raw({ "id": "string", "parameters": { "soft": true } }), |
|
9940 |
+ "default": new class_just(null), |
|
9941 |
+ "description": "the path to the interpreter to use; if value NULL is given, it is assumed that the script is self-executable", |
|
9942 |
+ }), |
|
9943 |
+ new class_taskparameter({ |
|
9944 |
+ "name": "workdir", |
|
9945 |
+ "extraction": raw => ((raw == null) ? null : lib_path.location_read(raw)), |
|
9946 |
+ "shape": lib_meta.from_raw({ "id": "string", "parameters": { "soft": true } }), |
|
9947 |
+ "default": new class_just(null), |
|
9948 |
+ "description": "the path to the directory from where the script shall be executed; if value NULL is given, the workdir is the location of the script", |
|
9949 |
+ }), |
|
9950 |
+ ], |
|
9951 |
+ "factory": (data) => { |
|
9952 |
+ return { |
|
9953 |
+ "inputs": data["inputs"], |
|
9954 |
+ "outputs": data["outputs"], |
|
9955 |
+ "actions": ([] |
|
9956 |
+ .concat(data["outputs"].map(output => new class_action_mkdir(output.location))) |
|
9957 |
+ .concat([ |
|
9958 |
+ new class_action_exec({ |
|
9959 |
+ "inputs": data["inputs"], |
|
9960 |
+ "outputs": data["outputs"], |
|
9961 |
+ "path": data["path"], |
|
9962 |
+ "interpreter": data["interpreter"], |
|
9963 |
+ "workdir": data["workdir"], |
|
9964 |
+ }), |
|
9965 |
+ ])), |
|
9966 |
+ }; |
|
9967 |
+ }, |
|
9968 |
+})); |
|
7893 | 9969 |
/** |
7894 | 9970 |
* @author fenris |
7895 | 9971 |
*/ |
7896 |
-var class_task_schwamm_apply = (function (_super) { |
|
7897 |
- __extends(class_task_schwamm_apply, _super); |
|
9972 |
+class class_target { |
|
7898 | 9973 |
/** |
7899 | 9974 |
* @author fenris |
7900 | 9975 |
*/ |
7901 |
- function class_task_schwamm_apply(_a) { |
|
7902 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"], path_raw = _b["path"], _c = _b["outputs"], outputs_raw = _c === void 0 ? null : _c; |
|
7903 |
- var _this = this; |
|
7904 |
- if (path_raw == undefined) { |
|
7905 |
- throw (new Error(class_task.errormessage_mandatoryparamater("schamm-apply", name, "path"))); |
|
7906 |
- } |
|
7907 |
- var path = lib_call.use(path_raw, function (x) { return lib_path.filepointer_read(x); }); |
|
7908 |
- if (outputs_raw == undefined) { |
|
7909 |
- throw (new Error(class_task.errormessage_mandatoryparamater("schamm-apply", name, "outputs"))); |
|
7910 |
- } |
|
7911 |
- var outputs = lib_call.use(outputs_raw, function (x) { return lib_object.map(x, function (output) { return lib_path.filepointer_read(output); }); }); |
|
7912 |
- _this = _super.call(this, name, sub, active, [path], lib_object.to_array(outputs).map(function (x) { return x.value; }), (lib_object.to_array(outputs).map(function (pair) { return [ |
|
7913 |
- new class_action_mkdir(pair.value.location), |
|
7914 |
- new class_action_schwamm_apply(path, pair.key, pair.value), |
|
7915 |
- ]; }) |
|
7916 |
- .reduce(function (x, y) { return x.concat(y); }, []))) || this; |
|
7917 |
- return _this; |
|
9976 |
+ constructor() { |
|
7918 | 9977 |
} |
7919 |
- return class_task_schwamm_apply; |
|
7920 |
-}(class_task)); |
|
7921 |
-class_task.register("schwamm-apply", function (name, sub, active, parameters) { return new class_task_schwamm_apply({ |
|
7922 |
- "name": name, "sub": sub, "active": active, |
|
7923 |
- "parameters": parameters, |
|
7924 |
-}); }); |
|
7925 |
-/** |
|
7926 |
- * @author fenris |
|
7927 |
- */ |
|
7928 |
-var class_target = (function () { |
|
7929 |
- /** |
|
7930 |
- * @author fenris |
|
7931 |
- */ |
|
7932 |
- function class_target() { |
|
7933 | 9978 |
} |
7934 |
- return class_target; |
|
7935 |
-}()); |
|
7936 | 9979 |
/** |
7937 | 9980 |
* @author fenris |
7938 | 9981 |
*/ |
7939 |
-var class_target_regular = (function (_super) { |
|
7940 |
- __extends(class_target_regular, _super); |
|
9982 |
+class class_target_regular extends class_target { |
|
7941 | 9983 |
/** |
7942 | 9984 |
* @author fenris |
7943 | 9985 |
*/ |
7944 |
- function class_target_regular(identifier) { |
|
7945 |
- var _this = _super.call(this) || this; |
|
7946 |
- _this.identifier = identifier; |
|
7947 |
- return _this; |
|
9986 |
+ constructor(identifier) { |
|
9987 |
+ super(); |
|
9988 |
+ this.identifier = identifier; |
|
7948 | 9989 |
} |
7949 | 9990 |
/** |
7950 | 9991 |
* @author fenris |
7951 | 9992 |
*/ |
7952 |
- class_target_regular.prototype.compile_action = function (action) { |
|
9993 |
+ compile_action(action) { |
|
7953 | 9994 |
if (action instanceof class_action_adhoc) { |
7954 |
- var action_ = (action); |
|
9995 |
+ let action_ = (action); |
|
7955 | 9996 |
return (action_.compilation(this.identifier)); |
7956 | 9997 |
} |
7957 | 9998 |
else { |
7958 | 9999 |
throw (new Error("no delegation for action '" + JSON.stringify(action) + "'")); |
7959 | 10000 |
} |
7960 |
- }; |
|
7961 |
- return class_target_regular; |
|
7962 |
-}(class_target)); |
|
10001 |
+ } |
|
10002 |
+} |
|
7963 | 10003 |
/** |
7964 | 10004 |
* @author fenris |
7965 | 10005 |
*/ |
7966 |
-var class_target_ant = (function (_super) { |
|
7967 |
- __extends(class_target_ant, _super); |
|
10006 |
+class class_target_ant extends class_target_regular { |
|
7968 | 10007 |
/** |
7969 | 10008 |
* @author fenris |
7970 | 10009 |
*/ |
7971 |
- function class_target_ant() { |
|
7972 |
- return _super.call(this, "ant") || this; |
|
10010 |
+ constructor() { |
|
10011 |
+ super("ant"); |
|
7973 | 10012 |
} |
7974 | 10013 |
/** |
7975 | 10014 |
* @override |
7976 | 10015 |
* @author fenris |
7977 | 10016 |
*/ |
7978 |
- class_target_ant.prototype.tempfolder = function () { |
|
10017 |
+ tempfolder() { |
|
7979 | 10018 |
switch (globalvars.configuration.system) { |
7980 | 10019 |
case "linux": { |
7981 | 10020 |
return "/tmp/"; |
... | ... |
@@ -7990,30 +10029,28 @@ var class_target_ant = (function (_super) { |
7990 | 10029 |
break; |
7991 | 10030 |
} |
7992 | 10031 |
default: { |
7993 |
- throw (new Error("invalid system '" + globalvars.configuration.system + "'")); |
|
10032 |
+ throw (new Error(`invalid system '${globalvars.configuration.system}'`)); |
|
7994 | 10033 |
break; |
7995 | 10034 |
} |
7996 | 10035 |
} |
7997 |
- }; |
|
10036 |
+ } |
|
7998 | 10037 |
/** |
7999 | 10038 |
* @author fenris |
8000 | 10039 |
*/ |
8001 |
- class_target_ant.prototype.compile_task = function (_a) { |
|
8002 |
- var _this = this; |
|
8003 |
- var task = _a["task"], _b = _a["path"], path = _b === void 0 ? [] : _b, _c = _a["context"], context = _c === void 0 ? null : _c; |
|
8004 |
- var aggregate = false; |
|
8005 |
- var path_ = path_augment(path, task.name_get(), aggregate); |
|
8006 |
- var targets_core = [ |
|
10040 |
+ compile_task({ "task": task, "path": path = [], "context": context = null, }) { |
|
10041 |
+ let aggregate = false; |
|
10042 |
+ let path_ = path_augment(path, task.name_get(), aggregate); |
|
10043 |
+ let targets_core = [ |
|
8007 | 10044 |
new lib_ant.class_target({ |
8008 | 10045 |
"name": path_dump(path_), |
8009 | 10046 |
"dependencies": (task.sub_get() |
8010 |
- .filter(function (task_) { return task_.active_get(); }) |
|
8011 |
- .map(function (task_) { return path_dump(path_augment(path_, task_.name_get(), aggregate)); })), |
|
10047 |
+ .filter(task_ => task_.active_get()) |
|
10048 |
+ .map(task_ => path_dump(path_augment(path_, task_.name_get(), aggregate)))), |
|
8012 | 10049 |
"actions": ([] |
8013 | 10050 |
.concat((context == null) |
8014 | 10051 |
? ([] |
8015 | 10052 |
.concat(task.actions() |
8016 |
- .map(function (action) { return _this.compile_action(action); }))) |
|
10053 |
+ .map(action => this.compile_action(action)))) |
|
8017 | 10054 |
: [ |
8018 | 10055 |
new lib_ant.class_action(new lib_xml.class_node_complex("ant", { |
8019 | 10056 |
"antfile": "${ant.file}", |
... | ... |
@@ -8025,7 +10062,7 @@ var class_target_ant = (function (_super) { |
8025 | 10062 |
])) |
8026 | 10063 |
}) |
8027 | 10064 |
]; |
8028 |
- var targets_sub = [] |
|
10065 |
+ let targets_sub = [] |
|
8029 | 10066 |
.concat((context == null) |
8030 | 10067 |
? [] |
8031 | 10068 |
: [ |
... | ... |
@@ -8033,56 +10070,55 @@ var class_target_ant = (function (_super) { |
8033 | 10070 |
"name": path_dump(path_augment(path_, name_mark("inner"))), |
8034 | 10071 |
"dependencies": [], |
8035 | 10072 |
"actions": (task.actions() |
8036 |
- .map(function (action) { return _this.compile_action(action); })), |
|
10073 |
+ .map(action => this.compile_action(action))), |
|
8037 | 10074 |
}) |
8038 | 10075 |
]) |
8039 | 10076 |
.concat(task.sub_get() |
8040 |
- .map(function (task_) { return _this.compile_task({ |
|
10077 |
+ .map(task_ => this.compile_task({ |
|
8041 | 10078 |
"task": task_, |
8042 | 10079 |
"path": path_, |
8043 | 10080 |
"context": ((context == null) ? task_.context_get() : ((task_.context_get() == null) ? context : context.relocate(task_.context_get()))), |
8044 |
- }); }) |
|
8045 |
- .reduce(function (x, y) { return x.concat(y); }, [])); |
|
10081 |
+ })) |
|
10082 |
+ .reduce((x, y) => x.concat(y), [])); |
|
8046 | 10083 |
return [].concat(targets_core).concat(targets_sub); |
8047 |
- }; |
|
10084 |
+ } |
|
8048 | 10085 |
/** |
8049 | 10086 |
* @author fenris |
8050 | 10087 |
*/ |
8051 |
- class_target_ant.prototype.compile_project = function (project) { |
|
8052 |
- var comments = [ |
|
8053 |
- "Project \"" + project.name_get() + "\"", |
|
8054 |
- "This build script was generated by Koralle " + globalvars.configuration.version, |
|
8055 |
- ].map(function (x) { return new lib_ant.class_comment(x); }); |
|
8056 |
- var targets = this.compile_task({ "task": project.roottask_get() }); |
|
10088 |
+ compile_project(project) { |
|
10089 |
+ let comments = [ |
|
10090 |
+ `Project \"${project.name_get()}\"`, |
|
10091 |
+ `This build script was generated by Koralle ${globalvars.configuration.version}`, |
|
10092 |
+ ].map(x => new lib_ant.class_comment(x)); |
|
10093 |
+ let targets = this.compile_task({ "task": project.roottask_get() }); |
|
8057 | 10094 |
return (new lib_ant.class_project({ |
8058 | 10095 |
"name": project.name_get(), |
8059 | 10096 |
"default": name_mark("root"), |
8060 | 10097 |
"comments": comments, |
8061 | 10098 |
"targets": targets, |
8062 | 10099 |
})); |
8063 |
- }; |
|
10100 |
+ } |
|
8064 | 10101 |
/** |
8065 | 10102 |
* @override |
8066 | 10103 |
* @author fenris |
8067 | 10104 |
*/ |
8068 |
- class_target_ant.prototype.compile_project_string = function (project) { |
|
10105 |
+ compile_project_string(project) { |
|
8069 | 10106 |
return this.compile_project(project).compile().compile(); |
8070 |
- }; |
|
10107 |
+ } |
|
8071 | 10108 |
/** |
8072 | 10109 |
* @override |
8073 | 10110 |
* @author fenris |
8074 | 10111 |
*/ |
8075 |
- class_target_ant.prototype.execute = function (filepointer, workdir) { |
|
8076 |
- if (workdir === void 0) { workdir = "."; } |
|
8077 |
- return (function (resolve, reject) { |
|
8078 |
- var cp = nm_child_process.spawn("ant", [ |
|
8079 |
- "-f", |
|
8080 |
- "" + filepointer.as_string(globalvars.configuration.system), |
|
10112 |
+ execute(filepointer, workdir = ".") { |
|
10113 |
+ return ((resolve, reject) => { |
|
10114 |
+ let cp = nm_child_process.spawn("ant", [ |
|
10115 |
+ `-f`, |
|
10116 |
+ `${filepointer.as_string(globalvars.configuration.system)}`, |
|
8081 | 10117 |
], {}); |
8082 |
- cp.stdout.on("data", [function (x) { return x.toString(); }, function (x) { return x.slice(0, x.length - 1); }, console.log].reduce(lib_call.compose)); |
|
8083 |
- cp.stderr.on("data", [function (x) { return x.toString(); }, function (x) { return x.slice(0, x.length - 1); }, console.error].reduce(lib_call.compose)); |
|
8084 |
- cp.on("error", function (error) { return reject(new class_error("subprocess not finish successfully", [error])); }); |
|
8085 |
- cp.on("close", function (code) { |
|
10118 |
+ cp.stdout.on("data", [x => x.toString(), x => x.slice(0, x.length - 1), console.log].reduce(lib_call.compose)); |
|
10119 |
+ cp.stderr.on("data", [x => x.toString(), x => x.slice(0, x.length - 1), console.error].reduce(lib_call.compose)); |
|
10120 |
+ cp.on("error", error => reject(new class_error("subprocess not finish successfully", [error]))); |
|
10121 |
+ cp.on("close", code => { |
|
8086 | 10122 |
if (code == 0) { |
8087 | 10123 |
resolve(undefined); |
8088 | 10124 |
} |
... | ... |
@@ -8091,25 +10127,23 @@ var class_target_ant = (function (_super) { |
8091 | 10127 |
} |
8092 | 10128 |
}); |
8093 | 10129 |
}); |
8094 |
- }; |
|
8095 |
- return class_target_ant; |
|
8096 |
-}(class_target_regular)); |
|
10130 |
+ } |
|
10131 |
+} |
|
8097 | 10132 |
/** |
8098 | 10133 |
* @author fenris |
8099 | 10134 |
*/ |
8100 |
-var class_target_gnumake = (function (_super) { |
|
8101 |
- __extends(class_target_gnumake, _super); |
|
10135 |
+class class_target_gnumake extends class_target_regular { |
|
8102 | 10136 |
/** |
8103 | 10137 |
* @author fenris |
8104 | 10138 |
*/ |
8105 |
- function class_target_gnumake() { |
|
8106 |
- return _super.call(this, "gnumake") || this; |
|
10139 |
+ constructor() { |
|
10140 |
+ super("gnumake"); |
|
8107 | 10141 |
} |
8108 | 10142 |
/** |
8109 | 10143 |
* @override |
8110 | 10144 |
* @author fenris |
8111 | 10145 |
*/ |
8112 |
- class_target_gnumake.prototype.tempfolder = function () { |
|
10146 |
+ tempfolder() { |
|
8113 | 10147 |
switch (globalvars.configuration.system) { |
8114 | 10148 |
case "linux": { |
8115 | 10149 |
return "/tmp/"; |
... | ... |
@@ -8124,24 +10158,22 @@ var class_target_gnumake = (function (_super) { |
8124 | 10158 |
break; |
8125 | 10159 |
} |
8126 | 10160 |
default: { |
8127 |
- throw (new Error("invalid system '" + globalvars.configuration.system + "'")); |
|
10161 |
+ throw (new Error(`invalid system '${globalvars.configuration.system}'`)); |
|
8128 | 10162 |
break; |
8129 | 10163 |
} |
8130 | 10164 |
} |
8131 |
- }; |
|
10165 |
+ } |
|
8132 | 10166 |
/** |
8133 | 10167 |
* @author fenris |
8134 | 10168 |
*/ |
8135 |
- class_target_gnumake.prototype.compile_task = function (_a) { |
|
8136 |
- var _this = this; |
|
8137 |
- var task = _a["task"], _b = _a["branch"], branch = _b === void 0 ? [] : _b, _c = _a["depth"], depth = _c === void 0 ? 0 : _c, _d = _a["context"], context = _d === void 0 ? null : _d, _e = _a["prefix"], prefix = _e === void 0 ? null : _e; |
|
8138 |
- var log_begin = true; |
|
8139 |
- var log_end = false; |
|
8140 |
- var aggregate = false; |
|
8141 |
- var branch_ = path_augment(branch, task.name_get(), aggregate); |
|
8142 |
- var logging_begin = new class_action_echo((new class_message(path_dump(branch_), { "type": "log", "depth": depth, "prefix": prefix })).generate()); |
|
8143 |
- var logging_end = new class_action_echo((new class_message("✔", { "type": "log", "depth": depth, "prefix": prefix })).generate()); |
|
8144 |
- var rules_core = []; |
|
10169 |
+ compile_task({ "task": task, "branch": branch = [], "depth": depth = 0, "context": context = null, "prefix": prefix = null }) { |
|
10170 |
+ let log_begin = true; |
|
10171 |
+ let log_end = false; |
|
10172 |
+ let aggregate = false; |
|
10173 |
+ let branch_ = path_augment(branch, task.name_get(), aggregate); |
|
10174 |
+ let logging_begin = new class_action_echo((new class_message(path_dump(branch_), { "type": "log", "depth": depth, "prefix": prefix })).generate()); |
|
10175 |
+ let logging_end = new class_action_echo((new class_message("✔", { "type": "log", "depth": depth, "prefix": prefix })).generate()); |
|
10176 |
+ let rules_core = []; |
|
8145 | 10177 |
{ |
8146 | 10178 |
// meta rule |
8147 | 10179 |
rules_core.push(new lib_gnumake.class_rule({ |
... | ... |
@@ -8151,89 +10183,88 @@ var class_target_gnumake = (function (_super) { |
8151 | 10183 |
? [path_dump(path_augment(branch_, name_mark("logging"), true))] |
8152 | 10184 |
: []) |
8153 | 10185 |
.concat(task.sub_get() |
8154 |
- .filter(function (task_) { return task_.active_get(); }) |
|
8155 |
- .map(function (task_) { return path_dump(path_augment(branch_, task_.name_get(), aggregate)); })) |
|
8156 |
- .concat(task.outputs().map(function (filepointer) { return filepointer_adjust(filepointer, context).as_string(globalvars.configuration.system); }))), |
|
10186 |
+ .filter(task_ => task_.active_get()) |
|
10187 |
+ .map(task_ => path_dump(path_augment(branch_, task_.name_get(), aggregate)))) |
|
10188 |
+ .concat(task.outputs().map(filepointer => filepointer_adjust(filepointer, context).as_string(globalvars.configuration.system)))), |
|
8157 | 10189 |
"actions": ([] |
8158 | 10190 |
.concat((task.outputs().length == 0) |
8159 |
- ? task.actions().map(function (action) { return dirwrap(context, _this.compile_action(action)); }) |
|
10191 |
+ ? task.actions().map(action => dirwrap(context, this.compile_action(action))) |
|
8160 | 10192 |
: []) |
8161 | 10193 |
.concat((log_end |
8162 | 10194 |
? [logging_end] |
8163 | 10195 |
: []) |
8164 |
- .map(function (action) { return _this.compile_action(action); }))), |
|
10196 |
+ .map(action => this.compile_action(action)))), |
|
8165 | 10197 |
"phony": true, |
8166 | 10198 |
})); |
8167 | 10199 |
// logging |
8168 | 10200 |
if (log_begin) { |
8169 | 10201 |
rules_core.push(new lib_gnumake.class_rule({ |
8170 | 10202 |
"name": path_dump(path_augment(branch_, name_mark("logging"), true)), |
8171 |
- "actions": [logging_begin].map(function (action) { return _this.compile_action(action); }), |
|
10203 |
+ "actions": [logging_begin].map(action => this.compile_action(action)), |
|
8172 | 10204 |
"phony": true, |
8173 | 10205 |
})); |
8174 | 10206 |
} |
8175 | 10207 |
// actual rule |
8176 | 10208 |
if (task.outputs().length > 0) { |
8177 | 10209 |
rules_core.push(new lib_gnumake.class_rule({ |
8178 |
- "name": task.outputs().map(function (filepointer) { return filepointer_adjust(filepointer, context).as_string(globalvars.configuration.system); }).join(" "), |
|
8179 |
- "dependencies": task.inputs().map(function (filepointer) { return filepointer_adjust(filepointer, context).as_string(globalvars.configuration.system); }), |
|
8180 |
- "actions": task.actions().map(function (action) { return _this.compile_action(action); }).map(function (x) { return dirwrap(context, x); }), |
|
10210 |
+ "name": task.outputs().map(filepointer => filepointer_adjust(filepointer, context).as_string(globalvars.configuration.system)).join(" "), |
|
10211 |
+ "dependencies": task.inputs().map(filepointer => filepointer_adjust(filepointer, context).as_string(globalvars.configuration.system)), |
|
10212 |
+ "actions": task.actions().map(action => this.compile_action(action)).map(x => dirwrap(context, x)), |
|
8181 | 10213 |
"phony": false, |
8182 | 10214 |
})); |
8183 | 10215 |
} |
8184 | 10216 |
} |
8185 |
- var rules_sub = []; |
|
10217 |
+ let rules_sub = []; |
|
8186 | 10218 |
{ |
8187 | 10219 |
rules_sub = task.sub_get() |
8188 |
- .map(function (task_) { return _this.compile_task({ |
|
10220 |
+ .map(task_ => this.compile_task({ |
|
8189 | 10221 |
"task": task_, |
8190 | 10222 |
"branch": branch_, |
8191 | 10223 |
"depth": depth + 1, |
8192 | 10224 |
"context": ((context == null) ? task_.context_get() : ((task_.context_get() == null) ? context : context.relocate(task_.context_get()))), |
8193 | 10225 |
"prefix": prefix, |
8194 |
- }); }) |
|
8195 |
- .reduce(function (x, y) { return x.concat(y); }, []); |
|
10226 |
+ })) |
|
10227 |
+ .reduce((x, y) => x.concat(y), []); |
|
8196 | 10228 |
} |
8197 | 10229 |
return [].concat(rules_core).concat(rules_sub); |
8198 |
- }; |
|
10230 |
+ } |
|
8199 | 10231 |
/** |
8200 | 10232 |
* @author fenris |
8201 | 10233 |
*/ |
8202 |
- class_target_gnumake.prototype.compile_project = function (project) { |
|
8203 |
- var comments = [ |
|
8204 |
- "Project \"" + project.name_get() + "\"", |
|
8205 |
- "This makefile was generated by Koralle " + globalvars.configuration.version, |
|
8206 |
- ].map(function (x) { return x; }); |
|
8207 |
- var rules = this.compile_task({ |
|
10234 |
+ compile_project(project) { |
|
10235 |
+ let comments = [ |
|
10236 |
+ `Project \"${project.name_get()}\"`, |
|
10237 |
+ `This makefile was generated by Koralle ${globalvars.configuration.version}`, |
|
10238 |
+ ].map(x => x); |
|
10239 |
+ let rules = this.compile_task({ |
|
8208 | 10240 |
"task": project.roottask_get(), |
8209 | 10241 |
"prefix": project.name_get(), |
8210 | 10242 |
}); |
8211 | 10243 |
return (new lib_gnumake.class_sheet(rules, comments)); |
8212 |
- }; |
|
10244 |
+ } |
|
8213 | 10245 |
/** |
8214 | 10246 |
* @override |
8215 | 10247 |
* @author fenris |
8216 | 10248 |
*/ |
8217 |
- class_target_gnumake.prototype.compile_project_string = function (project) { |
|
10249 |
+ compile_project_string(project) { |
|
8218 | 10250 |
return (this.compile_project(project).compile(true)); |
8219 |
- }; |
|
10251 |
+ } |
|
8220 | 10252 |
/** |
8221 | 10253 |
* @override |
8222 | 10254 |
* @author fenris |
8223 | 10255 |
*/ |
8224 |
- class_target_gnumake.prototype.execute = function (filepointer, workdir) { |
|
8225 |
- if (workdir === void 0) { workdir = process.cwd(); } |
|
8226 |
- return (function (resolve, reject) { |
|
8227 |
- var cp = nm_child_process.spawn("make", [ |
|
10256 |
+ execute(filepointer, workdir = process.cwd()) { |
|
10257 |
+ return ((resolve, reject) => { |
|
10258 |
+ let cp = nm_child_process.spawn("make", [ |
|
8228 | 10259 |
// `--directory=${workdir}`, |
8229 | 10260 |
// `--file=${filepointer.as_string(globalvars.configuration.system)}`, |
8230 |
- "-f", |
|
8231 |
- "" + filepointer.as_string(globalvars.configuration.system), |
|
10261 |
+ `-f`, |
|
10262 |
+ `${filepointer.as_string(globalvars.configuration.system)}`, |
|
8232 | 10263 |
], {}); |
8233 |
- cp.stdout.on("data", [function (x) { return x.toString(); }, function (x) { return x.slice(0, x.length - 1); }, console.log].reduce(lib_call.compose)); |
|
8234 |
- cp.stderr.on("data", [function (x) { return x.toString(); }, function (x) { return x.slice(0, x.length - 1); }, console.error].reduce(lib_call.compose)); |
|
8235 |
- cp.on("error", function (error) { return reject(new class_error("subprocess not finish successfully", [error])); }); |
|
8236 |
- cp.on("close", function (code) { |
|
10264 |
+ cp.stdout.on("data", [x => x.toString(), x => x.slice(0, x.length - 1), console.log].reduce(lib_call.compose)); |
|
10265 |
+ cp.stderr.on("data", [x => x.toString(), x => x.slice(0, x.length - 1), console.error].reduce(lib_call.compose)); |
|
10266 |
+ cp.on("error", error => reject(new class_error("subprocess not finish successfully", [error]))); |
|
10267 |
+ cp.on("close", code => { |
|
8237 | 10268 |
if (code == 0) { |
8238 | 10269 |
resolve(undefined); |
8239 | 10270 |
} |
... | ... |
@@ -8242,50 +10273,49 @@ var class_target_gnumake = (function (_super) { |
8242 | 10273 |
} |
8243 | 10274 |
}); |
8244 | 10275 |
}); |
8245 |
- }; |
|
8246 |
- return class_target_gnumake; |
|
8247 |
-}(class_target_regular)); |
|
10276 |
+ } |
|
10277 |
+} |
|
8248 | 10278 |
/** |
8249 | 10279 |
* scans a project and its subprojects and constructs a dependency-graph (more precise: a depth first spanning tree) |
8250 |
- * @param {class_filepointer} filepointet the filepointer to the project.json, relative to the current working directory |
|
10280 |
+ * @param {type_depgraphnode} node the filepointer to the project.json, relative to the current working directory |
|
8251 | 10281 |
* @author fenris |
8252 | 10282 |
*/ |
8253 |
-function scan(node, graph, depth) { |
|
8254 |
- if (graph === void 0) { graph = null; } |
|
8255 |
- if (depth === void 0) { depth = 0; } |
|
10283 |
+function scan(node, graph = null, depth = 0) { |
|
8256 | 10284 |
log("exploring node " + JSON.stringify(node), 4); |
8257 |
- var make_node = function (filepointer, rawproject) { |
|
8258 |
- if (rawproject === void 0) { rawproject = null; } |
|
8259 |
- var node = { "filepointer": filepointer, "rawproject": rawproject }; |
|
10285 |
+ let make_node = function (filepointer, rawproject = null) { |
|
10286 |
+ let node = { |
|
10287 |
+ "filepointer": filepointer, |
|
10288 |
+ "rawproject": rawproject |
|
10289 |
+ }; |
|
8260 | 10290 |
return node; |
8261 | 10291 |
}; |
8262 | 10292 |
if (graph == null) { |
8263 | 10293 |
log("creating new graph", 4); |
8264 |
- graph = new class_graph(function (x, y) { return (x.filepointer.toString() == y.filepointer.toString()); }); |
|
8265 |
- graph.nodes.push(node); |
|
10294 |
+ graph = new lib_structures.class_graph((x, y) => (x.filepointer.toString() == y.filepointer.toString())); |
|
10295 |
+ graph.add_node(node); |
|
8266 | 10296 |
} |
8267 |
- return (function (resolve, reject) { |
|
10297 |
+ return ((resolve, reject) => { |
|
8268 | 10298 |
log("reading description file", 4); |
8269 |
- lib_file.read_json(node.filepointer.toString())(function (data) { |
|
10299 |
+ lib_file.read_json(node.filepointer.toString())(data => { |
|
8270 | 10300 |
log("got data", 4); |
8271 | 10301 |
node.rawproject = data; |
8272 |
- lib_call.executor_chain(graph, lib_object.fetch(lib_object.fetch(node, "rawproject", {}, 0), "dependencies", [], 0).map(function (path) { return function (graph_) { return function (resolve_, reject_) { |
|
10302 |
+ lib_call.executor_chain(graph, lib_object.fetch(lib_object.fetch(node, "rawproject", {}, 0), "dependencies", [], 0).map(path => graph_ => (resolve_, reject_) => { |
|
8273 | 10303 |
log("looking through path " + path, 4); |
8274 |
- var node_ = make_node(node.filepointer.foo(lib_path.filepointer_read(path))); |
|
8275 |
- var edge = { "from": node_, "to": node }; |
|
8276 |
- graph_.edges.push(edge); |
|
10304 |
+ let node_ = make_node(node.filepointer.foo(lib_path.filepointer_read(path))); |
|
10305 |
+ let edge = { "from": node_, "to": node }; |
|
10306 |
+ graph_.add_edge(edge); |
|
8277 | 10307 |
if (graph.has(node_)) { |
8278 | 10308 |
// return lib_call.executor_resolve<class_graph<type_depgraphnode>, Error>(graph); |
8279 | 10309 |
resolve_(graph_); |
8280 | 10310 |
} |
8281 | 10311 |
else { |
8282 |
- graph.nodes.push(node_); |
|
8283 |
- scan(node_, graph_, depth + 1)(function (graph_) { |
|
10312 |
+ graph.add_node(node_); |
|
10313 |
+ scan(node_, graph_, depth + 1)(graph_ => { |
|
8284 | 10314 |
resolve_(graph_ /*.hasse()*/); |
8285 | 10315 |
}, reject_); |
8286 | 10316 |
} |
8287 |
- }; }; }))(resolve, reject); |
|
8288 |
- }, function (reason) { |
|
10317 |
+ }))(resolve, reject); |
|
10318 |
+ }, reason => { |
|
8289 | 10319 |
reject(reason); |
8290 | 10320 |
}); |
8291 | 10321 |
}); |
... | ... |
@@ -8293,11 +10323,11 @@ function scan(node, graph, depth) { |
8293 | 10323 |
/** |
8294 | 10324 |
* @author fenris |
8295 | 10325 |
*/ |
8296 |
-var class_project = (function () { |
|
10326 |
+class class_project { |
|
8297 | 10327 |
/** |
8298 | 10328 |
* @author fenris |
8299 | 10329 |
*/ |
8300 |
- function class_project(name, version, task) { |
|
10330 |
+ constructor(name, version, task) { |
|
8301 | 10331 |
this.name = name; |
8302 | 10332 |
this.version = version; |
8303 | 10333 |
this.task = task; |
... | ... |
@@ -8306,29 +10336,29 @@ var class_project = (function () { |
8306 | 10336 |
/** |
8307 | 10337 |
* @author fenris |
8308 | 10338 |
*/ |
8309 |
- class_project.prototype.name_get = function () { |
|
10339 |
+ name_get() { |
|
8310 | 10340 |
return this.name; |
8311 |
- }; |
|
10341 |
+ } |
|
8312 | 10342 |
/** |
8313 | 10343 |
* @author fenris |
8314 | 10344 |
*/ |
8315 |
- class_project.prototype.roottask_get = function () { |
|
10345 |
+ roottask_get() { |
|
8316 | 10346 |
return this.task; |
8317 |
- }; |
|
10347 |
+ } |
|
8318 | 10348 |
/** |
8319 | 10349 |
* @desc [mutator] [setter] |
8320 | 10350 |
* @author fenris |
8321 | 10351 |
*/ |
8322 |
- class_project.prototype.graph_set = function (graph) { |
|
10352 |
+ graph_set(graph) { |
|
8323 | 10353 |
this.graph = graph; |
8324 |
- }; |
|
10354 |
+ } |
|
8325 | 10355 |
/** |
8326 | 10356 |
* @desc [accessor] [getter] |
8327 | 10357 |
* @author fenris |
8328 | 10358 |
*/ |
8329 |
- class_project.prototype.graph_get = function () { |
|
10359 |
+ graph_get() { |
|
8330 | 10360 |
return this.graph; |
8331 |
- }; |
|
10361 |
+ } |
|
8332 | 10362 |
/** |
8333 | 10363 |
* @author fenris |
8334 | 10364 |
*/ |
... | ... |
@@ -8357,20 +10387,19 @@ var class_project = (function () { |
8357 | 10387 |
/** |
8358 | 10388 |
* @author fenris |
8359 | 10389 |
*/ |
8360 |
- class_project.create = function (filepointer, nameprefix) { |
|
8361 |
- if (nameprefix === void 0) { nameprefix = null; } |
|
8362 |
- return (function (resolve, reject) { |
|
8363 |
- var node = { "filepointer": filepointer, "rawproject": null }; |
|
10390 |
+ static create(filepointer, nameprefix = null) { |
|
10391 |
+ return ((resolve, reject) => { |
|
10392 |
+ let node = { "filepointer": filepointer, "rawproject": null }; |
|
8364 | 10393 |
log("scanning dependencies", 3); |
8365 |
- scan(node)(function (graph) { |
|
10394 |
+ scan(node)(graph => { |
|
8366 | 10395 |
log("got dependency graph", 3); |
8367 |
- var dependencynodes = null; |
|
8368 |
- var error = null; |
|
10396 |
+ let dependencynodes = null; |
|
10397 |
+ let error = null; |
|
8369 | 10398 |
try { |
8370 | 10399 |
log("applying topsort", 3); |
8371 | 10400 |
dependencynodes = graph |
8372 | 10401 |
.topsort() |
8373 |
- .filter(function (node) { return (node.filepointer.toString() != filepointer.toString()); }); |
|
10402 |
+ .filter(node => (node.filepointer.toString() != filepointer.toString())); |
|
8374 | 10403 |
error = null; |
8375 | 10404 |
} |
8376 | 10405 |
catch (exception) { |
... | ... |
@@ -8378,64 +10407,68 @@ var class_project = (function () { |
8378 | 10407 |
} |
8379 | 10408 |
if (error == null) { |
8380 | 10409 |
log("creating core task", 3); |
8381 |
- var core = class_task.create(node.rawproject.roottask); |
|
10410 |
+ let core = class_tasktemplate.create(node.rawproject.roottask); |
|
8382 | 10411 |
log("creating dependency tasks", 3); |
8383 |
- var dependencies = dependencynodes.map(function (node, index) { |
|
8384 |
- var task = class_task.create(node.rawproject.roottask, name_mark("dependency_" + (node.rawproject.name || lib_string.generate()))); |
|
10412 |
+ let dependencies = dependencynodes.map((node, index) => { |
|
10413 |
+ let task = class_tasktemplate.create(node.rawproject.roottask, name_mark("dependency_" + (node.rawproject.name || lib_string.generate()))); |
|
8385 | 10414 |
task.context_set(node.filepointer.location); |
8386 | 10415 |
return task; |
8387 | 10416 |
}); |
8388 | 10417 |
log("creating root task", 3); |
8389 |
- var task = new class_task_group({ |
|
10418 |
+ let task = new class_task({ |
|
8390 | 10419 |
"name": name_mark("root"), |
8391 | 10420 |
"sub": [ |
8392 |
- new class_task_group({ |
|
10421 |
+ new class_task({ |
|
8393 | 10422 |
"name": name_mark("dependencies"), |
8394 | 10423 |
"sub": dependencies, |
8395 | 10424 |
}), |
8396 |
- new class_task_group({ |
|
10425 |
+ new class_task({ |
|
8397 | 10426 |
"name": name_mark("core"), |
8398 | 10427 |
"sub": [core], |
8399 | 10428 |
}), |
8400 | 10429 |
] |
8401 | 10430 |
}); |
8402 | 10431 |
log("creating project", 3); |
8403 |
- var project = new class_project(node.rawproject.name || "(nameless project)", node.rawproject.version || "0.0.0", task); |
|
10432 |
+ let project = new class_project(node.rawproject.name || "(nameless project)", node.rawproject.version || "0.0.0", task); |
|
8404 | 10433 |
project.graph = graph; |
8405 | 10434 |
resolve(project); |
8406 | 10435 |
} |
8407 | 10436 |
else { |
8408 | 10437 |
reject(error); |
8409 | 10438 |
} |
8410 |
- }, function (reason) { return reject(new class_error("scanning dependencies failed", [reason])); }); |
|
10439 |
+ }, reason => reject(new class_error("scanning dependencies failed", [reason]))); |
|
8411 | 10440 |
}); |
8412 |
- }; |
|
8413 |
- return class_project; |
|
8414 |
-}()); |
|
10441 |
+ } |
|
10442 |
+} |
|
8415 | 10443 |
globalvars.invocation = { |
8416 | 10444 |
"interpreter": null, |
8417 | 10445 |
"path": "koralle", |
8418 | 10446 |
}; |
8419 | 10447 |
globalvars.configuration = { |
8420 |
- "version": "0.1.1", |
|
10448 |
+ "version": "0.2.1", |
|
8421 | 10449 |
"tempfolder": null, |
8422 |
- "path_source": "source", |
|
8423 |
- "path_build": "build", |
|
8424 |
- "system": "linux", |
|
10450 |
+ "system": null, |
|
8425 | 10451 |
"execute": false, |
8426 |
- "output": "gnumake", |
|
8427 |
- "file": null, |
|
8428 |
- "path": "project.json", |
|
10452 |
+ "output_target": null, |
|
10453 |
+ "output_path": null, |
|
10454 |
+ "sheet_path": null, |
|
8429 | 10455 |
"showgraph": false, |
8430 | 10456 |
"verbosity": 0, |
8431 | 10457 |
"name_splitter": "_", |
8432 | 10458 |
"name_prefix": "~", |
10459 |
+ "programpaths": { |
|
10460 |
+ "php": null, |
|
10461 |
+ "tsc": null, |
|
10462 |
+ "babel": null, |
|
10463 |
+ "lessc": null, |
|
10464 |
+ "schwamm": null, |
|
10465 |
+ "locmerge": null, |
|
10466 |
+ } |
|
8433 | 10467 |
}; |
8434 | 10468 |
/** |
8435 | 10469 |
* @author fenris |
8436 | 10470 |
*/ |
8437 |
-function log(message, level) { |
|
8438 |
- if (level === void 0) { level = 0; } |
|
10471 |
+function log(message, level = 0) { |
|
8439 | 10472 |
if (level <= globalvars.configuration.verbosity) { |
8440 | 10473 |
(new class_message(message, { "type": "log", "prefix": "koralle" })).stderr(); |
8441 | 10474 |
} |
... | ... |
@@ -8445,7 +10478,7 @@ function log(message, level) { |
8445 | 10478 |
*/ |
8446 | 10479 |
function main(args) { |
8447 | 10480 |
log("starting", 2); |
8448 |
- var arghandler = new lib_args.class_handler([ |
|
10481 |
+ let arghandler = new lib_args.class_handler([ |
|
8449 | 10482 |
new lib_args.class_argument({ |
8450 | 10483 |
"name": "path", |
8451 | 10484 |
"type": "string", |
... | ... |
@@ -8508,8 +10541,8 @@ function main(args) { |
8508 | 10541 |
new lib_args.class_argument({ |
8509 | 10542 |
"name": "system", |
8510 | 10543 |
"type": "string", |
8511 |
- "default": "linux", |
|
8512 |
- "info": "the target platform; valid values are 'linux', 'bsd', 'win'", |
|
10544 |
+ "default": "own", |
|
10545 |
+ "info": "the target platform; valid values are 'own' (the system executing koralle), 'linux', 'bsd', 'win'", |
|
8513 | 10546 |
"kind": "volatile", |
8514 | 10547 |
"parameters": { |
8515 | 10548 |
"indicators_long": ["system"], |
... | ... |
@@ -8540,119 +10573,203 @@ function main(args) { |
8540 | 10573 |
new lib_args.class_argument({ |
8541 | 10574 |
"name": "showgraph", |
8542 | 10575 |
"type": "boolean", |
8543 |
- "info": "if set, the graphviz description of the dependency graph is written to stderr", |
|
10576 |
+ "info": "if set, the dot language description of the dependency graph is printed to stdout", |
|
8544 | 10577 |
"kind": "volatile", |
8545 | 10578 |
"parameters": { |
8546 | 10579 |
"indicators_long": ["showgraph"], |
8547 | 10580 |
"indicators_short": ["g"], |
8548 | 10581 |
}, |
8549 | 10582 |
}), |
10583 |
+ new lib_args.class_argument({ |
|
10584 |
+ "name": "path_php", |
|
10585 |
+ "type": "string", |
|
10586 |
+ "default": "php", |
|
10587 |
+ "info": "the path to the program 'php'", |
|
10588 |
+ "kind": "volatile", |
|
10589 |
+ "parameters": { |
|
10590 |
+ "indicators_long": ["path-php"], |
|
10591 |
+ "indicators_short": [], |
|
10592 |
+ }, |
|
10593 |
+ }), |
|
10594 |
+ new lib_args.class_argument({ |
|
10595 |
+ "name": "path_tsc", |
|
10596 |
+ "type": "string", |
|
10597 |
+ "default": "tsc", |
|
10598 |
+ "info": "the path to the program 'tsc'", |
|
10599 |
+ "kind": "volatile", |
|
10600 |
+ "parameters": { |
|
10601 |
+ "indicators_long": ["path-tsc"], |
|
10602 |
+ "indicators_short": [], |
|
10603 |
+ }, |
|
10604 |
+ }), |
|
10605 |
+ new lib_args.class_argument({ |
|
10606 |
+ "name": "path_babel", |
|
10607 |
+ "type": "string", |
|
10608 |
+ "default": "babel", |
|
10609 |
+ "info": "the path to the program 'babel'", |
|
10610 |
+ "kind": "volatile", |
|
10611 |
+ "parameters": { |
|
10612 |
+ "indicators_long": ["path-babel"], |
|
10613 |
+ "indicators_short": [], |
|
10614 |
+ }, |
|
10615 |
+ }), |
|
10616 |
+ new lib_args.class_argument({ |
|
10617 |
+ "name": "path_lessc", |
|
10618 |
+ "type": "string", |
|
10619 |
+ "default": "lessc", |
|
10620 |
+ "info": "the path to the program 'lessc'", |
|
10621 |
+ "kind": "volatile", |
|
10622 |
+ "parameters": { |
|
10623 |
+ "indicators_long": ["path-lessc"], |
|
10624 |
+ "indicators_short": [], |
|
10625 |
+ }, |
|
10626 |
+ }), |
|
10627 |
+ new lib_args.class_argument({ |
|
10628 |
+ "name": "path_schwamm", |
|
10629 |
+ "type": "string", |
|
10630 |
+ "default": "schwamm", |
|
10631 |
+ "info": "the path to the program 'schwamm'", |
|
10632 |
+ "kind": "volatile", |
|
10633 |
+ "parameters": { |
|
10634 |
+ "indicators_long": ["path-schwamm"], |
|
10635 |
+ "indicators_short": [], |
|
10636 |
+ }, |
|
10637 |
+ }), |
|
10638 |
+ new lib_args.class_argument({ |
|
10639 |
+ "name": "path_locmerge", |
|
10640 |
+ "type": "string", |
|
10641 |
+ "default": "locmerge", |
|
10642 |
+ "info": "the path to the program 'locmerge'", |
|
10643 |
+ "kind": "volatile", |
|
10644 |
+ "parameters": { |
|
10645 |
+ "indicators_long": ["path-locmerge"], |
|
10646 |
+ "indicators_short": [], |
|
10647 |
+ }, |
|
10648 |
+ }), |
|
8550 | 10649 |
]); |
8551 | 10650 |
// lib_args.verbosity = 5; |
8552 | 10651 |
log("reading command line arguments", 2); |
8553 |
- var argdata = arghandler.read("cli", args.join(" ")); |
|
8554 |
- var procede = true; |
|
8555 |
- if (argdata["help"]) { |
|
8556 |
- (new class_message(arghandler.generate_help({ |
|
10652 |
+ let argdata = arghandler.read("cli", args.join(" ")); |
|
10653 |
+ globalvars.configuration.sheet_path = argdata["path"]; |
|
10654 |
+ { |
|
10655 |
+ // todo: auslagern (nach "plankton/base" vllt.) |
|
10656 |
+ let systemmap = { |
|
10657 |
+ "linux": "linux", |
|
10658 |
+ "freebsd": "bsd", |
|
10659 |
+ "openbsd": "bsd", |
|
10660 |
+ "win32": "win" |
|
10661 |
+ }; |
|
10662 |
+ globalvars.configuration.system = (argdata["system"] == "own") ? systemmap[process.platform] : argdata["system"]; |
|
10663 |
+ } |
|
10664 |
+ globalvars.configuration.output_target = argdata["output"]; |
|
10665 |
+ globalvars.configuration.execute = argdata["execute"]; |
|
10666 |
+ globalvars.configuration.show_help = argdata["help"]; |
|
10667 |
+ globalvars.configuration.show_version = argdata["version"]; |
|
10668 |
+ globalvars.configuration.show_tasklist = argdata["tasklist"]; |
|
10669 |
+ globalvars.configuration.showgraph = argdata["showgraph"]; |
|
10670 |
+ globalvars.configuration.output_path = argdata["file"]; |
|
10671 |
+ globalvars.configuration.verbosity = argdata["verbosity"]; |
|
10672 |
+ globalvars.configuration.programpaths.php = argdata["path_php"]; |
|
10673 |
+ globalvars.configuration.programpaths.tsc = argdata["path_tsc"]; |
|
10674 |
+ globalvars.configuration.programpaths.babel = argdata["path_babel"]; |
|
10675 |
+ globalvars.configuration.programpaths.lessc = argdata["path_lessc"]; |
|
10676 |
+ globalvars.configuration.programpaths.schwamm = argdata["path_schwamm"]; |
|
10677 |
+ globalvars.configuration.programpaths.locmerge = argdata["path_locmerge"]; |
|
10678 |
+ return (lib_call.promise_resolve({}) |
|
10679 |
+ .then(state => { |
|
10680 |
+ // help |
|
10681 |
+ if (globalvars.configuration.show_help) { |
|
10682 |
+ let message = arghandler.generate_help({ |
|
8557 | 10683 |
"programname": "Koralle Build System Abstractor", |
8558 | 10684 |
"executable": "koralle", |
8559 | 10685 |
"author": "Christian Fraß <frass@greenscale.de>", |
8560 | 10686 |
"description": "Koralle is not a build-system itself. Instead it generates scripts for existing build-systems (e.g. GNU Make, Apache Ant, …) on base of a common json-description-file (usually named 'project.json'). Koralle is designed for reducing the amount of text needed to define the build-process.", |
8561 |
- }))).stdout(); |
|
8562 |
- procede = false; |
|
10687 |
+ }); |
|
10688 |
+ (new class_message(message)).stdout(); |
|
10689 |
+ return lib_call.promise_resolve(state); |
|
8563 | 10690 |
} |
8564 |
- else if (argdata["version"]) { |
|
10691 |
+ else if (globalvars.configuration.show_version) { |
|
8565 | 10692 |
(new class_message(globalvars.configuration.version.toString())).stdout(); |
8566 |
- procede = false; |
|
10693 |
+ return lib_call.promise_resolve(state); |
|
8567 | 10694 |
} |
8568 |
- else if (argdata["tasklist"]) { |
|
8569 |
- new class_message(class_task.list().map(function (entry) { return "\t" + entry + "\n"; }).join("")).stdout(); |
|
8570 |
- procede = false; |
|
10695 |
+ else if (globalvars.configuration.show_tasklist) { |
|
10696 |
+ (new class_message(class_tasktemplate.list())).stdout(); |
|
10697 |
+ return lib_call.promise_resolve(state); |
|
8571 | 10698 |
} |
8572 | 10699 |
else { |
8573 |
- globalvars.configuration.path = argdata["path"]; |
|
8574 |
- globalvars.configuration.system = argdata["system"]; |
|
8575 |
- globalvars.configuration.output = argdata["output"]; |
|
8576 |
- globalvars.configuration.execute = argdata["execute"]; |
|
8577 |
- globalvars.configuration.showgraph = argdata["showgraph"]; |
|
8578 |
- globalvars.configuration.file = argdata["file"]; |
|
8579 |
- globalvars.configuration.verbosity = argdata["verbosity"]; |
|
8580 |
- procede = true; |
|
8581 |
- } |
|
8582 |
- if (procede) { |
|
8583 |
- lib_call.executor_chain({}, [ |
|
8584 |
- // environment |
|
8585 |
- function (state) { return function (resolve, reject) { |
|
10700 |
+ return (lib_call.promise_resolve(state) |
|
10701 |
+ .then(state => lib_call.promise_make((resolve, reject) => { |
|
8586 | 10702 |
log("setting up environment", 2); |
8587 |
- var filepointer = lib_path.filepointer_read(globalvars.configuration.path); |
|
8588 |
- filepointer.location.go_thither(); |
|
8589 |
- state.filepointer = filepointer; |
|
10703 |
+ let sheet_filepointer = lib_path.filepointer_read(globalvars.configuration.sheet_path); |
|
10704 |
+ // sheet_filepointer.location.go_thither(); |
|
10705 |
+ state.sheet_filepointer = sheet_filepointer; |
|
8590 | 10706 |
resolve(state); |
8591 |
- }; }, |
|
8592 |
- // setup output |
|
8593 |
- function (state) { return function (resolve, reject) { |
|
10707 |
+ })) |
|
10708 |
+ .then(state => lib_call.promise_make((resolve, reject) => { |
|
8594 | 10709 |
log("setting up output", 2); |
8595 |
- var mapping = { |
|
10710 |
+ let mapping = { |
|
8596 | 10711 |
"ant": new class_target_ant(), |
8597 | 10712 |
"gnumake": new class_target_gnumake(), |
8598 | 10713 |
"make": new class_target_gnumake(), |
8599 | 10714 |
}; |
8600 |
- var output = lib_object.fetch(mapping, globalvars.configuration.output, null, 0); |
|
8601 |
- if (output == null) { |
|
8602 |
- reject(new class_error("no implementation found for output '" + globalvars.configuration.output + "'")); |
|
10715 |
+ let output_target = lib_object.fetch(mapping, globalvars.configuration.output_target, null, 0); |
|
10716 |
+ if (output_target == null) { |
|
10717 |
+ reject(new class_error(`no implementation found for output_target '${globalvars.configuration.output_target}'`)); |
|
8603 | 10718 |
} |
8604 | 10719 |
else { |
8605 |
- state.output = output; |
|
10720 |
+ state.output_target = output_target; |
|
8606 | 10721 |
resolve(state); |
8607 | 10722 |
} |
8608 |
- }; }, |
|
8609 |
- // setup temp-folder |
|
8610 |
- function (state) { return function (resolve, reject) { |
|
10723 |
+ })) |
|
10724 |
+ .then(state => lib_call.promise_make((resolve, reject) => { |
|
8611 | 10725 |
log("setting up temp-folder", 2); |
8612 | 10726 |
try { |
8613 |
- globalvars.configuration.tempfolder = state.output.tempfolder(); |
|
10727 |
+ globalvars.configuration.tempfolder = state.output_target.tempfolder(); |
|
8614 | 10728 |
resolve(state); |
8615 | 10729 |
} |
8616 | 10730 |
catch (exception) { |
8617 | 10731 |
reject(new class_error("couldn't setup temp folder", [exception])); |
8618 | 10732 |
} |
8619 |
- }; }, |
|
8620 |
- // setup project |
|
8621 |
- function (state) { return function (resolve, reject) { |
|
10733 |
+ })) |
|
10734 |
+ .then(state => lib_call.promise_make((resolve, reject) => { |
|
8622 | 10735 |
log("setting up project", 2); |
8623 |
- class_project.create(state.filepointer)(function (project) { |
|
10736 |
+ class_project.create(state.sheet_filepointer)(project => { |
|
8624 | 10737 |
state.project = project; |
8625 | 10738 |
resolve(state); |
8626 | 10739 |
}, reject); |
8627 |
- }; }, |
|
8628 |
- // show graph |
|
8629 |
- function (state) { return function (resolve, reject) { |
|
8630 |
- log("showing graph?", 2); |
|
10740 |
+ })) |
|
10741 |
+ .then(state => { |
|
10742 |
+ // graph |
|
8631 | 10743 |
if (globalvars.configuration.showgraph) { |
8632 |
- var output = state.project.graph_get() |
|
10744 |
+ return (lib_call.promise_resolve(state) |
|
10745 |
+ .then(state => lib_call.promise_make((resolve, reject) => { |
|
10746 |
+ log("showing graph", 2); |
|
10747 |
+ let output = (state.project.graph_get() |
|
8633 | 10748 |
.hasse() |
8634 |
- .output_graphviz(function (node) { return node.rawproject.name || node.filepointer.toString(); }); |
|
8635 |
- (new class_message(output)).stderr(); |
|
8636 |
- } |
|
10749 |
+ .output_dot({ |
|
10750 |
+ "extract_label": node => (node.rawproject.name || node.filepointer.toString()) |
|
10751 |
+ })); |
|
10752 |
+ (new class_message(output)).stdout(); |
|
8637 | 10753 |
resolve(state); |
8638 |
- }; }, |
|
8639 |
- // generate |
|
8640 |
- function (state) { return function (resolve, reject) { |
|
10754 |
+ }))); |
|
10755 |
+ } |
|
10756 |
+ else { |
|
10757 |
+ return (lib_call.promise_resolve(state) |
|
10758 |
+ .then(state => lib_call.promise_make((resolve, reject) => { |
|
8641 | 10759 |
log("generating output", 2); |
8642 | 10760 |
try { |
8643 |
- var script = state.output.compile_project_string(state.project); |
|
8644 |
- state.script = script; |
|
10761 |
+ let output_script = state.output_target.compile_project_string(state.project); |
|
10762 |
+ state.output_script = output_script; |
|
8645 | 10763 |
resolve(state); |
8646 | 10764 |
} |
8647 | 10765 |
catch (exception) { |
8648 | 10766 |
reject(new class_error("generating build script failed", [exception])); |
8649 | 10767 |
} |
8650 |
- }; }, |
|
8651 |
- // write |
|
8652 |
- function (state) { return function (resolve, reject) { |
|
10768 |
+ })) |
|
10769 |
+ .then(state => lib_call.promise_make((resolve, reject) => { |
|
8653 | 10770 |
log("writing to file", 2); |
8654 |
- var filepointer; |
|
8655 |
- if (globalvars.configuration.file == null) { |
|
10771 |
+ let filepointer; |
|
10772 |
+ if (globalvars.configuration.output_path == null) { |
|
8656 | 10773 |
if (!globalvars.configuration.execute) { |
8657 | 10774 |
filepointer = null; |
8658 | 10775 |
} |
... | ... |
@@ -8665,15 +10782,15 @@ function main(args) { |
8665 | 10782 |
} |
8666 | 10783 |
} |
8667 | 10784 |
else { |
8668 |
- filepointer = lib_path.filepointer_read(globalvars.configuration.file); |
|
10785 |
+ filepointer = lib_path.filepointer_read(globalvars.configuration.output_path); |
|
8669 | 10786 |
} |
8670 |
- state.file = filepointer; |
|
10787 |
+ state.output_filepointer = filepointer; |
|
8671 | 10788 |
if (filepointer == null) { |
8672 |
- (new class_message(state.script)).stdout(); |
|
10789 |
+ (new class_message(state.output_script)).stdout(); |
|
8673 | 10790 |
resolve(state); |
8674 | 10791 |
} |
8675 | 10792 |
else { |
8676 |
- nm_fs.writeFile(filepointer.toString(), state.script, function (error) { |
|
10793 |
+ nm_fs.writeFile(filepointer.toString(), state.output_script, error => { |
|
8677 | 10794 |
if (error == null) { |
8678 | 10795 |
resolve(state); |
8679 | 10796 |
} |
... | ... |
@@ -8682,31 +10799,33 @@ function main(args) { |
8682 | 10799 |
} |
8683 | 10800 |
}); |
8684 | 10801 |
} |
8685 |
- }; }, |
|
8686 |
- // execute |
|
8687 |
- function (state) { return function (resolve, reject) { |
|
10802 |
+ })) |
|
10803 |
+ .then(state => lib_call.promise_make((resolve, reject) => { |
|
8688 | 10804 |
log("executing", 2); |
8689 | 10805 |
if (!globalvars.configuration.execute) { |
8690 | 10806 |
resolve(state); |
8691 | 10807 |
} |
8692 | 10808 |
else { |
8693 |
- state.output.execute(state.file)(function (result) { return resolve(state); }, function (reason) { return reject(new class_error("execution of build script failed", [reason])); }); |
|
10809 |
+ state.output_target.execute(state.output_filepointer)(result => resolve(state), reason => reject(new class_error("execution of build script failed", [reason]))); |
|
8694 | 10810 |
} |
8695 |
- }; }, |
|
8696 |
- ])(function (state) { |
|
8697 |
- // (new class_message("successfull", {"type": "information", "prefix": "koralle"})).stderr(); |
|
8698 |
- process.exit(0); |
|
8699 |
- }, function (reason) { |
|
8700 |
- // throw reason; |
|
8701 |
- console.error(reason); |
|
8702 |
- (new class_message("the following error occured: '" + reason.toString() + "'", { "type": "error", "prefix": "koralle" })).stderr(); |
|
8703 |
- process.exit(-1); |
|
8704 |
- }); |
|
10811 |
+ }))); |
|
10812 |
+ } |
|
10813 |
+ })); |
|
8705 | 10814 |
} |
10815 |
+ })); |
|
8706 | 10816 |
} |
8707 | 10817 |
log("intro", 2); |
8708 | 10818 |
globalvars.invocation = { |
8709 | 10819 |
"interpreter": process.argv[0], |
8710 | 10820 |
"path": process.argv[1], |
8711 | 10821 |
}; |
8712 |
-main(process.argv.slice(2)); |
|
10822 |
+main(process.argv.slice(2)) |
|
10823 |
+ .then(function (dummy) { |
|
10824 |
+ // (new class_message("successfull", {"type": "information", "prefix": "koralle"})).stderr(); |
|
10825 |
+ process.exit(0); |
|
10826 |
+}, function (reason) { |
|
10827 |
+ // throw reason; |
|
10828 |
+ console.error(reason); |
|
10829 |
+ (new class_message(`the following error occured: '${reason.toString()}'`, { "type": "error", "prefix": "koralle" })).stderr(); |
|
10830 |
+ process.exit(-1); |
|
10831 |
+}); |
|
8713 | 10832 |