Christian Fraß commited on 2017-07-02 19:38:23
Zeige 11 geänderte Dateien mit 4636 Einfügungen und 3401 Löschungen.
... | ... |
@@ -0,0 +1,77 @@ |
1 |
+# Project "fs-draft" |
|
2 |
+# This makefile was generated by Koralle 0.2.0 |
|
3 |
+ |
|
4 |
+~root: ~root_~logging ~dependencies ~core |
|
5 |
+.PHONY: ~root |
|
6 |
+ |
|
7 |
+~root_~logging: |
|
8 |
+ @ echo "[log] <fs-draft> ~root" |
|
9 |
+.PHONY: ~root_~logging |
|
10 |
+ |
|
11 |
+~dependencies: ~dependencies_~logging |
|
12 |
+.PHONY: ~dependencies |
|
13 |
+ |
|
14 |
+~dependencies_~logging: |
|
15 |
+ @ echo "[log] <fs-draft> ~dependencies" |
|
16 |
+.PHONY: ~dependencies_~logging |
|
17 |
+ |
|
18 |
+~core: ~core_~logging build |
|
19 |
+.PHONY: ~core |
|
20 |
+ |
|
21 |
+~core_~logging: |
|
22 |
+ @ echo "[log] <fs-draft> ~core" |
|
23 |
+.PHONY: ~core_~logging |
|
24 |
+ |
|
25 |
+build: build_~logging structure logic style media |
|
26 |
+.PHONY: build |
|
27 |
+ |
|
28 |
+build_~logging: |
|
29 |
+ @ echo "[log] <fs-draft> build" |
|
30 |
+.PHONY: build_~logging |
|
31 |
+ |
|
32 |
+structure: structure_~logging |
|
33 |
+ @ mkdir --parents build/ |
|
34 |
+ @ php source/content/draft.html.php > build/draft.html |
|
35 |
+.PHONY: structure |
|
36 |
+ |
|
37 |
+structure_~logging: |
|
38 |
+ @ echo "[log] <fs-draft> structure" |
|
39 |
+.PHONY: structure_~logging |
|
40 |
+ |
|
41 |
+logic: logic_~logging build/draft.js |
|
42 |
+.PHONY: logic |
|
43 |
+ |
|
44 |
+logic_~logging: |
|
45 |
+ @ echo "[log] <fs-draft> logic" |
|
46 |
+.PHONY: logic_~logging |
|
47 |
+ |
|
48 |
+build/draft.js: source/logic/client/tools.js source/logic/client/table.js source/logic/client/toc.js source/logic/client/main.js |
|
49 |
+ @ mkdir --parents build/ |
|
50 |
+ @ cat source/logic/client/tools.js source/logic/client/table.js source/logic/client/toc.js source/logic/client/main.js > build/draft.js |
|
51 |
+ |
|
52 |
+style: style_~logging |
|
53 |
+ @ mkdir --parents build/ |
|
54 |
+ @ cat source/style/functions.less source/style/theme.less source/style/common.less source/style/concrete.less > /tmp/_.less |
|
55 |
+ @ lessc /tmp/_.less > build/draft.css |
|
56 |
+.PHONY: style |
|
57 |
+ |
|
58 |
+style_~logging: |
|
59 |
+ @ echo "[log] <fs-draft> style" |
|
60 |
+.PHONY: style_~logging |
|
61 |
+ |
|
62 |
+media: media_~logging logo |
|
63 |
+.PHONY: media |
|
64 |
+ |
|
65 |
+media_~logging: |
|
66 |
+ @ echo "[log] <fs-draft> media" |
|
67 |
+.PHONY: media_~logging |
|
68 |
+ |
|
69 |
+logo: logo_~logging |
|
70 |
+ @ mkdir --parents build/ |
|
71 |
+ @ cp source/media/logo.svg build/logo.svg |
|
72 |
+.PHONY: logo |
|
73 |
+ |
|
74 |
+logo_~logging: |
|
75 |
+ @ echo "[log] <fs-draft> logo" |
|
76 |
+.PHONY: logo_~logging |
|
77 |
+ |
... | ... |
@@ -29,7 +29,7 @@ |
29 | 29 |
$data = sql_cross($data, $data_adpositions["references"]); |
30 | 30 |
$data = sql_select($data, function ($row) {return ($row["reference_id"] == $row["id"]);}); |
31 | 31 |
$data = sql_delete($data, ["reference_id", "id"]); |
32 |
- $data = sql_rename($data, "name", "kind_name"); |
|
32 |
+ $data = sql_rename($data, "name", "reference_name"); |
|
33 | 33 |
} |
34 | 34 |
} |
35 | 35 |
|
... | ... |
@@ -39,7 +39,7 @@ |
39 | 39 |
new class_column("Language", "language_id"), |
40 | 40 |
new class_column("Situation", "situation_name"), |
41 | 41 |
new class_column("Type", "type_name"), |
42 |
- new class_column("Kind", "kind_name"), |
|
42 |
+ new class_column("Reference", "reference_name"), |
|
43 | 43 |
new class_column("Words", "words", function ($x) {return json_encode($x);}), |
44 | 44 |
], |
45 | 45 |
$data |
... | ... |
@@ -12,8 +12,8 @@ |
12 | 12 |
{"id": "x09", "name": "between"} |
13 | 13 |
], |
14 | 14 |
"types": [ |
15 |
- {"id": "pos", "name": "Positive"}, |
|
16 |
- {"id": "dir", "name": "Directive"} |
|
15 |
+ {"id": "dir", "name": "Directive"}, |
|
16 |
+ {"id": "pos", "name": "Positive"} |
|
17 | 17 |
], |
18 | 18 |
"references": [ |
19 | 19 |
{"id": "abs", "name": "Absolute"}, |
... | ... |
@@ -21,56 +21,56 @@ |
21 | 21 |
{"id": "att", "name": "Attributive"} |
22 | 22 |
], |
23 | 23 |
"words": [ |
24 |
- {"language_id": "fs", "situation_id": "x00", "type_id": "pos", "reference_id": "abs", "words": ["for"]}, |
|
25 |
- {"language_id": "fs", "situation_id": "x00", "type_id": "pos", "reference_id": "rel", "words": ["for (lut)"]}, |
|
26 |
- {"language_id": "fs", "situation_id": "x00", "type_id": "pos", "reference_id": "att", "words": ["for arend"]}, |
|
27 |
- {"language_id": "fs", "situation_id": "x00", "type_id": "dir", "reference_id": "abs", "words": ["to for"]}, |
|
28 |
- {"language_id": "fs", "situation_id": "x00", "type_id": "dir", "reference_id": "rel", "words": ["to for (lut)"]}, |
|
29 |
- {"language_id": "fs", "situation_id": "x01", "type_id": "pos", "reference_id": "abs", "words": ["bak"]}, |
|
30 |
- {"language_id": "fs", "situation_id": "x01", "type_id": "pos", "reference_id": "rel", "words": ["bak (lut)"]}, |
|
31 |
- {"language_id": "fs", "situation_id": "x01", "type_id": "pos", "reference_id": "att", "words": ["bak arend"]}, |
|
32 |
- {"language_id": "fs", "situation_id": "x01", "type_id": "dir", "reference_id": "abs", "words": ["to bak"]}, |
|
33 |
- {"language_id": "fs", "situation_id": "x01", "type_id": "dir", "reference_id": "rel", "words": ["to bak (lut)"]}, |
|
34 |
- {"language_id": "fs", "situation_id": "x02", "type_id": "pos", "reference_id": "abs", "words": ["uver"]}, |
|
35 |
- {"language_id": "fs", "situation_id": "x02", "type_id": "pos", "reference_id": "rel", "words": ["uver (lut)"]}, |
|
36 |
- {"language_id": "fs", "situation_id": "x02", "type_id": "pos", "reference_id": "att", "words": ["uver arend"]}, |
|
37 |
- {"language_id": "fs", "situation_id": "x02", "type_id": "dir", "reference_id": "abs", "words": ["to uver"]}, |
|
38 |
- {"language_id": "fs", "situation_id": "x02", "type_id": "dir", "reference_id": "rel", "words": ["to uver (lut)"]}, |
|
39 |
- {"language_id": "fs", "situation_id": "x03", "type_id": "pos", "reference_id": "abs", "words": ["neder"]}, |
|
40 |
- {"language_id": "fs", "situation_id": "x03", "type_id": "pos", "reference_id": "rel", "words": ["neder (lut)"]}, |
|
41 |
- {"language_id": "fs", "situation_id": "x03", "type_id": "pos", "reference_id": "att", "words": ["neder arend"]}, |
|
42 |
- {"language_id": "fs", "situation_id": "x03", "type_id": "dir", "reference_id": "abs", "words": ["to neder"]}, |
|
43 |
- {"language_id": "fs", "situation_id": "x03", "type_id": "dir", "reference_id": "rel", "words": ["to neder (lut)"]}, |
|
44 |
- {"language_id": "fs", "situation_id": "x04", "type_id": "pos", "reference_id": "abs", "words": ["vinst"]}, |
|
45 |
- {"language_id": "fs", "situation_id": "x04", "type_id": "pos", "reference_id": "rel", "words": ["vinst (lut)"]}, |
|
46 |
- {"language_id": "fs", "situation_id": "x04", "type_id": "pos", "reference_id": "att", "words": ["vinst arend"]}, |
|
47 |
- {"language_id": "fs", "situation_id": "x04", "type_id": "dir", "reference_id": "abs", "words": ["to vinst"]}, |
|
48 |
- {"language_id": "fs", "situation_id": "x04", "type_id": "dir", "reference_id": "rel", "words": ["to vinst (lut)"]}, |
|
49 |
- {"language_id": "fs", "situation_id": "x05", "type_id": "pos", "reference_id": "abs", "words": ["hög"]}, |
|
50 |
- {"language_id": "fs", "situation_id": "x05", "type_id": "pos", "reference_id": "rel", "words": ["hög (lut)"]}, |
|
51 |
- {"language_id": "fs", "situation_id": "x05", "type_id": "pos", "reference_id": "att", "words": ["hög arend"]}, |
|
52 |
- {"language_id": "fs", "situation_id": "x05", "type_id": "dir", "reference_id": "abs", "words": ["to hög"]}, |
|
53 |
- {"language_id": "fs", "situation_id": "x05", "type_id": "dir", "reference_id": "rel", "words": ["to hög (lut)"]}, |
|
54 |
- {"language_id": "fs", "situation_id": "x06", "type_id": "pos", "reference_id": "abs", "words": ["ine"]}, |
|
55 |
- {"language_id": "fs", "situation_id": "x06", "type_id": "pos", "reference_id": "rel", "words": ["ine (lut)"]}, |
|
56 |
- {"language_id": "fs", "situation_id": "x06", "type_id": "pos", "reference_id": "att", "words": ["ine arend"]}, |
|
24 |
+ {"language_id": "fs", "situation_id": "x00", "type_id": "pos", "reference_id": "abs", "words": ["foran"]}, |
|
25 |
+ {"language_id": "fs", "situation_id": "x00", "type_id": "pos", "reference_id": "rel", "words": ["foran (av)"]}, |
|
26 |
+ {"language_id": "fs", "situation_id": "x00", "type_id": "pos", "reference_id": "att", "words": ["forer"]}, |
|
27 |
+ {"language_id": "fs", "situation_id": "x00", "type_id": "dir", "reference_id": "abs", "words": ["for"]}, |
|
28 |
+ {"language_id": "fs", "situation_id": "x00", "type_id": "dir", "reference_id": "rel", "words": ["for (av)"]}, |
|
29 |
+ {"language_id": "fs", "situation_id": "x01", "type_id": "pos", "reference_id": "abs", "words": ["bakan"]}, |
|
30 |
+ {"language_id": "fs", "situation_id": "x01", "type_id": "pos", "reference_id": "rel", "words": ["bakan (av)"]}, |
|
31 |
+ {"language_id": "fs", "situation_id": "x01", "type_id": "pos", "reference_id": "att", "words": ["baker"]}, |
|
32 |
+ {"language_id": "fs", "situation_id": "x01", "type_id": "dir", "reference_id": "abs", "words": ["bak"]}, |
|
33 |
+ {"language_id": "fs", "situation_id": "x01", "type_id": "dir", "reference_id": "rel", "words": ["bak (av)"]}, |
|
34 |
+ {"language_id": "fs", "situation_id": "x02", "type_id": "pos", "reference_id": "abs", "words": ["uveran"]}, |
|
35 |
+ {"language_id": "fs", "situation_id": "x02", "type_id": "pos", "reference_id": "rel", "words": ["uveran (av)"]}, |
|
36 |
+ {"language_id": "fs", "situation_id": "x02", "type_id": "pos", "reference_id": "att", "words": ["uverer"]}, |
|
37 |
+ {"language_id": "fs", "situation_id": "x02", "type_id": "dir", "reference_id": "abs", "words": ["uver"]}, |
|
38 |
+ {"language_id": "fs", "situation_id": "x02", "type_id": "dir", "reference_id": "rel", "words": ["uver (av)"]}, |
|
39 |
+ {"language_id": "fs", "situation_id": "x03", "type_id": "pos", "reference_id": "abs", "words": ["nederan"]}, |
|
40 |
+ {"language_id": "fs", "situation_id": "x03", "type_id": "pos", "reference_id": "rel", "words": ["nederan (av)"]}, |
|
41 |
+ {"language_id": "fs", "situation_id": "x03", "type_id": "pos", "reference_id": "att", "words": ["nederer"]}, |
|
42 |
+ {"language_id": "fs", "situation_id": "x03", "type_id": "dir", "reference_id": "abs", "words": ["neder"]}, |
|
43 |
+ {"language_id": "fs", "situation_id": "x03", "type_id": "dir", "reference_id": "rel", "words": ["neder (av)"]}, |
|
44 |
+ {"language_id": "fs", "situation_id": "x04", "type_id": "pos", "reference_id": "abs", "words": ["vinstan"]}, |
|
45 |
+ {"language_id": "fs", "situation_id": "x04", "type_id": "pos", "reference_id": "rel", "words": ["vinstan (av)"]}, |
|
46 |
+ {"language_id": "fs", "situation_id": "x04", "type_id": "pos", "reference_id": "att", "words": ["vinster"]}, |
|
47 |
+ {"language_id": "fs", "situation_id": "x04", "type_id": "dir", "reference_id": "abs", "words": ["vinst"]}, |
|
48 |
+ {"language_id": "fs", "situation_id": "x04", "type_id": "dir", "reference_id": "rel", "words": ["vinst (av)"]}, |
|
49 |
+ {"language_id": "fs", "situation_id": "x05", "type_id": "pos", "reference_id": "abs", "words": ["hegan"]}, |
|
50 |
+ {"language_id": "fs", "situation_id": "x05", "type_id": "pos", "reference_id": "rel", "words": ["hegan (av)"]}, |
|
51 |
+ {"language_id": "fs", "situation_id": "x05", "type_id": "pos", "reference_id": "att", "words": ["heger"]}, |
|
52 |
+ {"language_id": "fs", "situation_id": "x05", "type_id": "dir", "reference_id": "abs", "words": ["heg"]}, |
|
53 |
+ {"language_id": "fs", "situation_id": "x05", "type_id": "dir", "reference_id": "rel", "words": ["heg (av)"]}, |
|
54 |
+ {"language_id": "fs", "situation_id": "x06", "type_id": "pos", "reference_id": "abs", "words": ["inan"]}, |
|
55 |
+ {"language_id": "fs", "situation_id": "x06", "type_id": "pos", "reference_id": "rel", "words": ["inan (av)"]}, |
|
56 |
+ {"language_id": "fs", "situation_id": "x06", "type_id": "pos", "reference_id": "att", "words": ["iner"]}, |
|
57 | 57 |
{"language_id": "fs", "situation_id": "x06", "type_id": "dir", "reference_id": "abs", "words": ["in"]}, |
58 |
- {"language_id": "fs", "situation_id": "x06", "type_id": "dir", "reference_id": "rel", "words": ["in (lut)"]}, |
|
59 |
- {"language_id": "fs", "situation_id": "x07", "type_id": "pos", "reference_id": "abs", "words": ["ute"]}, |
|
60 |
- {"language_id": "fs", "situation_id": "x07", "type_id": "pos", "reference_id": "rel", "words": ["ute (lut)"]}, |
|
61 |
- {"language_id": "fs", "situation_id": "x07", "type_id": "pos", "reference_id": "att", "words": ["ute arend"]}, |
|
58 |
+ {"language_id": "fs", "situation_id": "x06", "type_id": "dir", "reference_id": "rel", "words": ["in (av)"]}, |
|
59 |
+ {"language_id": "fs", "situation_id": "x07", "type_id": "pos", "reference_id": "abs", "words": ["utan"]}, |
|
60 |
+ {"language_id": "fs", "situation_id": "x07", "type_id": "pos", "reference_id": "rel", "words": ["utan (av)"]}, |
|
61 |
+ {"language_id": "fs", "situation_id": "x07", "type_id": "pos", "reference_id": "att", "words": ["uter"]}, |
|
62 | 62 |
{"language_id": "fs", "situation_id": "x07", "type_id": "dir", "reference_id": "abs", "words": ["ut"]}, |
63 |
- {"language_id": "fs", "situation_id": "x07", "type_id": "dir", "reference_id": "rel", "words": ["ut (lut)"]}, |
|
64 |
- {"language_id": "fs", "situation_id": "x08", "type_id": "pos", "reference_id": "abs", "words": ["upe"]}, |
|
65 |
- {"language_id": "fs", "situation_id": "x08", "type_id": "pos", "reference_id": "rel", "words": ["upe (lut)"]}, |
|
66 |
- {"language_id": "fs", "situation_id": "x08", "type_id": "pos", "reference_id": "att", "words": ["upe arend"]}, |
|
63 |
+ {"language_id": "fs", "situation_id": "x07", "type_id": "dir", "reference_id": "rel", "words": ["ut (av)"]}, |
|
64 |
+ {"language_id": "fs", "situation_id": "x08", "type_id": "pos", "reference_id": "abs", "words": ["upan"]}, |
|
65 |
+ {"language_id": "fs", "situation_id": "x08", "type_id": "pos", "reference_id": "rel", "words": ["upan (av)"]}, |
|
66 |
+ {"language_id": "fs", "situation_id": "x08", "type_id": "pos", "reference_id": "att", "words": ["uper"]}, |
|
67 | 67 |
{"language_id": "fs", "situation_id": "x08", "type_id": "dir", "reference_id": "abs", "words": ["up"]}, |
68 |
- {"language_id": "fs", "situation_id": "x08", "type_id": "dir", "reference_id": "rel", "words": ["up (lut)"]}, |
|
69 |
- {"language_id": "fs", "situation_id": "x09", "type_id": "pos", "reference_id": "abs", "words": ["mel"]}, |
|
70 |
- {"language_id": "fs", "situation_id": "x09", "type_id": "pos", "reference_id": "rel", "words": ["mel (lut)"]}, |
|
71 |
- {"language_id": "fs", "situation_id": "x09", "type_id": "pos", "reference_id": "att", "words": ["mel arend"]}, |
|
72 |
- {"language_id": "fs", "situation_id": "x09", "type_id": "dir", "reference_id": "abs", "words": ["to mel"]}, |
|
73 |
- {"language_id": "fs", "situation_id": "x09", "type_id": "dir", "reference_id": "rel", "words": ["to mel (lut)"]}, |
|
68 |
+ {"language_id": "fs", "situation_id": "x08", "type_id": "dir", "reference_id": "rel", "words": ["up (av)"]}, |
|
69 |
+ {"language_id": "fs", "situation_id": "x09", "type_id": "pos", "reference_id": "abs", "words": ["melan"]}, |
|
70 |
+ {"language_id": "fs", "situation_id": "x09", "type_id": "pos", "reference_id": "rel", "words": ["melan (av)"]}, |
|
71 |
+ {"language_id": "fs", "situation_id": "x09", "type_id": "pos", "reference_id": "att", "words": ["meler"]}, |
|
72 |
+ {"language_id": "fs", "situation_id": "x09", "type_id": "dir", "reference_id": "abs", "words": ["mel"]}, |
|
73 |
+ {"language_id": "fs", "situation_id": "x09", "type_id": "dir", "reference_id": "rel", "words": ["mel (av)"]}, |
|
74 | 74 |
{"language_id": "en", "situation_id": "x00", "type_id": "pos", "reference_id": "abs", "words": ["in front"]}, |
75 | 75 |
{"language_id": "en", "situation_id": "x00", "type_id": "pos", "reference_id": "rel", "words": ["in front of"]}, |
76 | 76 |
{"language_id": "en", "situation_id": "x00", "type_id": "pos", "reference_id": "att", "words": ["fore", "front"]}, |
... | ... |
@@ -27,77 +27,77 @@ |
27 | 27 |
{"language_id": "fs", "domain_id": "con", "type_id": "def", "words": ["jen"]}, |
28 | 28 |
{"language_id": "fs", "domain_id": "con", "type_id": "den", "words": ["dis"]}, |
29 | 29 |
{"language_id": "fs", "domain_id": "con", "type_id": "uni", "words": ["al"]}, |
30 |
- {"language_id": "fs", "domain_id": "con", "type_id": "und", "words": ["et"]}, |
|
31 |
- {"language_id": "fs", "domain_id": "con", "type_id": "neg", "words": ["ni","nit et"]}, |
|
30 |
+ {"language_id": "fs", "domain_id": "con", "type_id": "und", "words": ["ed"]}, |
|
31 |
+ {"language_id": "fs", "domain_id": "con", "type_id": "neg", "words": ["ni","nit ed"]}, |
|
32 | 32 |
{"language_id": "fs", "domain_id": "thi", "type_id": "int", "words": ["vilk ding", "vat"]}, |
33 | 33 |
{"language_id": "fs", "domain_id": "thi", "type_id": "rel", "words": ["vilk ding", "vat"]}, |
34 | 34 |
{"language_id": "fs", "domain_id": "thi", "type_id": "def", "words": ["jen ding", "dat"]}, |
35 | 35 |
{"language_id": "fs", "domain_id": "thi", "type_id": "den", "words": ["dis ding"]}, |
36 | 36 |
{"language_id": "fs", "domain_id": "thi", "type_id": "uni", "words": ["al ding", "alvat"]}, |
37 |
- {"language_id": "fs", "domain_id": "thi", "type_id": "und", "words": ["et ding", "etvat"]}, |
|
37 |
+ {"language_id": "fs", "domain_id": "thi", "type_id": "und", "words": ["ed ding", "edvat"]}, |
|
38 | 38 |
{"language_id": "fs", "domain_id": "thi", "type_id": "neg", "words": ["ni ding", "nivat"]}, |
39 | 39 |
{"language_id": "fs", "domain_id": "per", "type_id": "int", "words": ["vilk man", "ve"]}, |
40 | 40 |
{"language_id": "fs", "domain_id": "per", "type_id": "rel", "words": ["vilk man", "ve"]}, |
41 | 41 |
{"language_id": "fs", "domain_id": "per", "type_id": "def", "words": ["jen man"]}, |
42 | 42 |
{"language_id": "fs", "domain_id": "per", "type_id": "den", "words": ["dis man"]}, |
43 | 43 |
{"language_id": "fs", "domain_id": "per", "type_id": "uni", "words": ["al man", "alve"]}, |
44 |
- {"language_id": "fs", "domain_id": "per", "type_id": "und", "words": ["et man", "etve"]}, |
|
44 |
+ {"language_id": "fs", "domain_id": "per", "type_id": "und", "words": ["ed man", "edve"]}, |
|
45 | 45 |
{"language_id": "fs", "domain_id": "per", "type_id": "neg", "words": ["ni man", "nive"]}, |
46 | 46 |
{"language_id": "fs", "domain_id": "pos", "type_id": "int", "words": ["av vilk man", "ves"]}, |
47 | 47 |
{"language_id": "fs", "domain_id": "pos", "type_id": "rel", "words": ["av vilk man", "ves"]}, |
48 | 48 |
{"language_id": "fs", "domain_id": "pos", "type_id": "def", "words": ["av jen man"]}, |
49 | 49 |
{"language_id": "fs", "domain_id": "pos", "type_id": "den", "words": ["av dis man"]}, |
50 | 50 |
{"language_id": "fs", "domain_id": "pos", "type_id": "uni", "words": ["av al man", "alves"]}, |
51 |
- {"language_id": "fs", "domain_id": "pos", "type_id": "und", "words": ["av et man", "etves"]}, |
|
51 |
+ {"language_id": "fs", "domain_id": "pos", "type_id": "und", "words": ["av ed man", "edves"]}, |
|
52 | 52 |
{"language_id": "fs", "domain_id": "pos", "type_id": "neg", "words": ["av ni man", "nives"]}, |
53 | 53 |
{"language_id": "fs", "domain_id": "tim", "type_id": "int", "words": ["vilk tid", "van"]}, |
54 | 54 |
{"language_id": "fs", "domain_id": "tim", "type_id": "rel", "words": ["vilk tid", "van"]}, |
55 | 55 |
{"language_id": "fs", "domain_id": "tim", "type_id": "def", "words": ["jen tid", "dan"]}, |
56 | 56 |
{"language_id": "fs", "domain_id": "tim", "type_id": "den", "words": ["dis tid", "no"]}, |
57 | 57 |
{"language_id": "fs", "domain_id": "tim", "type_id": "uni", "words": ["al tid", "alvan"]}, |
58 |
- {"language_id": "fs", "domain_id": "tim", "type_id": "und", "words": ["et tid", "etvan"]}, |
|
58 |
+ {"language_id": "fs", "domain_id": "tim", "type_id": "und", "words": ["ed tid", "edvan"]}, |
|
59 | 59 |
{"language_id": "fs", "domain_id": "tim", "type_id": "neg", "words": ["ni tid", "nivan"]}, |
60 | 60 |
{"language_id": "fs", "domain_id": "loc", "type_id": "int", "words": ["vilk sted", "var"]}, |
61 | 61 |
{"language_id": "fs", "domain_id": "loc", "type_id": "rel", "words": ["vilk sted", "var"]}, |
62 | 62 |
{"language_id": "fs", "domain_id": "loc", "type_id": "def", "words": ["jen sted", "dar"]}, |
63 | 63 |
{"language_id": "fs", "domain_id": "loc", "type_id": "den", "words": ["dis sted", "har"]}, |
64 | 64 |
{"language_id": "fs", "domain_id": "loc", "type_id": "uni", "words": ["al sted", "alvar"]}, |
65 |
- {"language_id": "fs", "domain_id": "loc", "type_id": "und", "words": ["et sted", "etvar"]}, |
|
65 |
+ {"language_id": "fs", "domain_id": "loc", "type_id": "und", "words": ["ed sted", "edvar"]}, |
|
66 | 66 |
{"language_id": "fs", "domain_id": "loc", "type_id": "neg", "words": ["ni sted", "nivar"]}, |
67 | 67 |
{"language_id": "fs", "domain_id": "dir", "type_id": "int", "words": ["to vilk sted", "varto"]}, |
68 | 68 |
{"language_id": "fs", "domain_id": "dir", "type_id": "rel", "words": ["to vilk sted", "varto"]}, |
69 | 69 |
{"language_id": "fs", "domain_id": "dir", "type_id": "def", "words": ["to jen sted", "darto"]}, |
70 | 70 |
{"language_id": "fs", "domain_id": "dir", "type_id": "den", "words": ["to dis sted", "harto"]}, |
71 | 71 |
{"language_id": "fs", "domain_id": "dir", "type_id": "uni", "words": ["to al sted", "alto"]}, |
72 |
- {"language_id": "fs", "domain_id": "dir", "type_id": "und", "words": ["to et sted", "etto"]}, |
|
72 |
+ {"language_id": "fs", "domain_id": "dir", "type_id": "und", "words": ["to ed sted", "edto"]}, |
|
73 | 73 |
{"language_id": "fs", "domain_id": "dir", "type_id": "neg", "words": ["to ni sted", "nito"]}, |
74 | 74 |
{"language_id": "fs", "domain_id": "cau", "type_id": "int", "words": ["fur vilk grund", "varfur"]}, |
75 | 75 |
{"language_id": "fs", "domain_id": "cau", "type_id": "rel", "words": ["fur vilk grund", "varfur"]}, |
76 | 76 |
{"language_id": "fs", "domain_id": "cau", "type_id": "def", "words": ["fur jen grund", "darfur"]}, |
77 | 77 |
{"language_id": "fs", "domain_id": "cau", "type_id": "den", "words": ["fur dis grund", "harfur"]}, |
78 | 78 |
{"language_id": "fs", "domain_id": "cau", "type_id": "uni", "words": ["fur al grund", "alfur"]}, |
79 |
- {"language_id": "fs", "domain_id": "cau", "type_id": "und", "words": ["fur et grund", "etfur"]}, |
|
79 |
+ {"language_id": "fs", "domain_id": "cau", "type_id": "und", "words": ["fur ed grund", "edfur"]}, |
|
80 | 80 |
{"language_id": "fs", "domain_id": "cau", "type_id": "neg", "words": ["fur ni grund", "nifur"]}, |
81 | 81 |
{"language_id": "fs", "domain_id": "man", "type_id": "int", "words": ["vilk mot", "hur"]}, |
82 | 82 |
{"language_id": "fs", "domain_id": "man", "type_id": "rel", "words": ["vilk mot", "hur"]}, |
83 | 83 |
{"language_id": "fs", "domain_id": "man", "type_id": "def", "words": ["jen mot", "so"]}, |
84 | 84 |
{"language_id": "fs", "domain_id": "man", "type_id": "den", "words": ["dis mot", "so"]}, |
85 | 85 |
{"language_id": "fs", "domain_id": "man", "type_id": "uni", "words": ["al mot"]}, |
86 |
- {"language_id": "fs", "domain_id": "man", "type_id": "und", "words": ["et mot"]}, |
|
86 |
+ {"language_id": "fs", "domain_id": "man", "type_id": "und", "words": ["ed mot"]}, |
|
87 | 87 |
{"language_id": "fs", "domain_id": "man", "type_id": "neg", "words": ["ni mot"]}, |
88 | 88 |
{"language_id": "fs", "domain_id": "typ", "type_id": "int", "words": ["vilk slag"]}, |
89 | 89 |
{"language_id": "fs", "domain_id": "typ", "type_id": "rel", "words": ["vilk slag"]}, |
90 | 90 |
{"language_id": "fs", "domain_id": "typ", "type_id": "def", "words": ["jen slag", "solk"]}, |
91 | 91 |
{"language_id": "fs", "domain_id": "typ", "type_id": "den", "words": ["dis slag"]}, |
92 | 92 |
{"language_id": "fs", "domain_id": "typ", "type_id": "uni", "words": ["al slag"]}, |
93 |
- {"language_id": "fs", "domain_id": "typ", "type_id": "und", "words": ["et slag"]}, |
|
93 |
+ {"language_id": "fs", "domain_id": "typ", "type_id": "und", "words": ["ed slag"]}, |
|
94 | 94 |
{"language_id": "fs", "domain_id": "typ", "type_id": "neg", "words": ["ni slag"]}, |
95 | 95 |
{"language_id": "fs", "domain_id": "amo", "type_id": "int", "words": ["vilk mang"]}, |
96 | 96 |
{"language_id": "fs", "domain_id": "amo", "type_id": "rel", "words": ["vilk mang"]}, |
97 | 97 |
{"language_id": "fs", "domain_id": "amo", "type_id": "def", "words": ["jen mang"]}, |
98 | 98 |
{"language_id": "fs", "domain_id": "amo", "type_id": "den", "words": ["dis mang"]}, |
99 | 99 |
{"language_id": "fs", "domain_id": "amo", "type_id": "uni", "words": ["al mang"]}, |
100 |
- {"language_id": "fs", "domain_id": "amo", "type_id": "und", "words": ["et mang"]}, |
|
100 |
+ {"language_id": "fs", "domain_id": "amo", "type_id": "und", "words": ["ed mang"]}, |
|
101 | 101 |
{"language_id": "fs", "domain_id": "amo", "type_id": "neg", "words": ["ni mang"]}, |
102 | 102 |
{"language_id": "en", "domain_id": "con", "type_id": "int", "words": ["which"]}, |
103 | 103 |
{"language_id": "en", "domain_id": "con", "type_id": "rel", "words": ["which"]}, |
... | ... |
@@ -2,13 +2,13 @@ |
2 | 2 |
"de_grot_diktator": { |
3 | 3 |
"title": "De grot diktator", |
4 | 4 |
"paragraphs": [ |
5 |
- "Ek bid fur fargiving, dok ek vil nit are de verlds herskar — ek ar nit solk en man. Ek vil nit beherske er neddrüke et man, insted ek vil helpe de maner alvan and alvar: De judisk, de hejdisk, de fargig, de vit, …. Vi al skal helpe en de ander fur at vi kan leve ine en beter verld. Vi vil nit hate er farakte us. Dis verld hav plats fur al maner and ur erd ar so rik, at vi al kan ete nok. De levrid kan are so fri and skön; dok vi hav farlatet de veg.", |
|
6 |
- "Gridhed hav sükent de maners seler and hav fült de verld med hatrid; hit hav ledet us to elend and blutsketrid. Vi hav utvikelt raskhed, dok ur gester stan stil. Vi lat makiner verke fur us; ur vetrid hav makt us hokmudig and ur klughed hard and unfrendlik; vi denk altu mang and föl altu lit. Dok mer den makiner vi treng manlikhed; mer den klughed vi treng frendlikhed and gudhed. An dis egenheder, ur levrid ar frükridig and al ding ar lost.", |
|
7 |
- "Med de helprid av flügtüger and de radio vi ar narer en to de ander den et tid ruk. Fur at de manskap kan bruke dis utfindinger fur en gud sak, hit mut leve med enhed and bruderlikhed. Selv nu mang tused in der verld kan höre min stem, mang tusend fartvivelt verer, kviner and smal kinder — ofaringer av en sistem, vilk fang and kvel unskuldig maner. Ek rup to al, vilk kan hör mek nu: Fartvivel nit! De elend skal farsvinde, van de gridhed farsvind and de biterhed av maner, vilk frük de manskaps forskritrid. De Maners hatrid skal farsvinde and diktarorer skal döe. Dan de kraft, vilk di hav takt fra de folk, skal kome bak to de folk. Selv ef mang blud ar sketet: Tu kempe fur de frihed ar en gud sak.", |
|
8 |
- "Kemparer: Kemp nit fur tiraner; maner, vilk farakt ju and mak ju to sklaver; vilk vertskat nit jer levrid, vilk seg to ju, vat je skal make, true and föle! Di skend ju, föd ju, behandel ju lik kanon-föding. Kemp nit fur dis fardervt maner — makin-maner med makin-hövder and makin-herter! Je ar nit makiner, je ar nit direr, je ar maner. Lat de manlikhed blive ine jer herter! Je skal nit hate; bar de unlivt hat, de unlivt and de fardervt.", |
|
9 |
- "Kemperar: Kemp nit fur de sklavskap! Kemp fur de frihed! Ine de 17. avsniding av de hajlig Lukas ar skrivt: ‚God ar ine al maner.‘ — nit bar ine en grup av maner, insted ine al maner, ine ju. Je, de folk, hav de kraft; de kraft fur tu bue vapener, dok ok de kraft fur tu sprede gladhed. Je, de folk, hav de kraft fur tu make dis levrid fri and skön, fur tu make dis levrid en vunderfült sak. Darfur: Ine de nam av folkherskrid: Lat us bruke dis kraft! Lat us verde en! Lat us kempe fur en nü verld, fur en beter verld, vilk giv to de maner magrid tu verke, vilk giv en eftertid to de jung and sikerhed to de eld. Ok de tiraner hav truent dis to us fur tu foe de vold, dok di hav lügt. Di mak nit sant dir luving, di vil ni tid. Tiraner frien bar dim selv, dok de folk skal blive sklaver.", |
|
10 |
- "Lat us nu kempe fur tu upfüle dis luving. Lat us kempe fur tu make de verld fri, fur tu uvervinde landmarker, gridhed, hatrid and de untillatrid. Lat us kempe fur en verld med farstanrid, en verld, var vetridskap and forskritrid skal lede to al mans gladhed.", |
|
11 |
- "Kemparer: Ine de nam av folkherskrid: Lat us al verde en!" |
|
5 |
+ "Ek bid fur fargiving, dok ek vil nit are de verlds herskar — ek ar nit solk en man. Ek vil nit beherske er neddrüke et man, insted ek vil helpe de maner alvan and alvar: De judisk, de hejdisk, de fargig, de vit, …. Vi al skal helpe en de ander fur at vi kan leve inan en beter verld. Vi vil nit hate er farakte us. Dis verld hav rum fur al maner and ur erd ar so rik, at vi al kan ete nok. De levrid kan are so fri and skön; dok vi hav farlatet de veg.", |
|
6 |
+ "Gridhed hav sükent de maners seler and hav fült de verld med hatrid; hit hav ledet us to elend and blutskedrid. Vi hav utvikelt raskhed, dok ur gester sta stil. Vi lat makiner verke fur us; ur vetrid hav makt us hokmudig and ur klughed hard and unfrendlik; vi denk altu mang and föl altu lit. Dok mer den makiner vi treng manlikhed; mer den klughed vi treng frendlikhed and gudhed. An dis egenheder, ur levrid ar frükridig and al ding ar lost.", |
|
7 |
+ "Med de helprid av flügtüger and de radio vi ar narer en to de ander den et tid bak. Fur at de manskap kan bruke dis utfindinger fur en gud sak, hit mut leve med enhed and bruderlikhed. Selv nu mang tused in der verld kan höre min stem, mang tusend fartvivelt verer, kviner and smal kinder — ofaringer av en sistem, vilk fang and kvel unskuldig maner. Ek rup to al, vilk kan höre mek nu: Fartvivel nit! De elend skal farsvinde, van de gridhed farsvind and de biterhed av maner, vilk frük de manskaps forskridrid. De Maners hatrid skal farsvinde and diktarorer skal döe. Dan de kraft, vilk di hav takt fra de folk, skal kome bak to de folk. Selv ef mang blud ar skedet: Tu fekte fur de frihed ar en gud sak.", |
|
8 |
+ "Fektarer: Fekt nit fur tiraner; maner, vilk farakt ju and mak ju to sklaver; vilk vertskat nit jer levrid, vilk seg to ju, vat je skal make, true and föle! Di skend ju, föd ju, behandel ju lik kanon-föding. Fekt nit fur dis fardervt maner — makin-maner med makin-hövder and makin-herter! Je ar nit makiner, je ar nit direr, je ar maner. Lat de manlikhed blive inan jer herter! Je skal nit hate; bar de unlivt hat, de unlivt and de fardervt.", |
|
9 |
+ "Fektarer: Fekt nit fur de sklavskap! Fekt fur de frihed! Inan de 17. avsniding av de hajlig Lukas ar skrivt: ‚God ar inan al maner.‘ — nit bar inan en grup ut maner, insted inan al maner, inan ju. Je, de folk, hav de kraft; de kraft fur tu bue vapener, dok ok de kraft fur tu sprede gladhed. Je, de folk, hav de kraft fur tu make dis levrid fri and skön, fur tu make dis levrid en vunderfült sak. Darfur: Inan de nam av folkherskrid: Lat us bruke dis kraft! Lat us verde en! Lat us fekte fur en nü verld, fur en beter verld, vilk giv to de maner de magrid tu verke, vilk giv en eftertid to de jung and sikerhed to de eld. Ok de tiraner hav truent dis to us fur tu foe de vold, dok di hav lügt. Di mak nit san dir luving, di vil ni tid. Tiraner frien bar dim selv, dok de folk skal blive sklaver.", |
|
10 |
+ "Lat us nu fekte fur tu upfüle dis luving. Lat us fekte fur tu make de verld fri, fur tu uvervinde landmarker, gridhed, hatrid and de untillatrid. Lat us fekte fur en verld med farstarid, en verld, var vetridskap and forskridrid skal lede to al mans gladhed.", |
|
11 |
+ "Fektarer: Inan de nam av folkherskrid: Lat us al verde en!" |
|
12 | 12 |
] |
13 | 13 |
} |
14 | 14 |
} |
... | ... |
@@ -19,13 +19,31 @@ |
19 | 19 |
|
20 | 20 |
*/ |
21 | 21 |
|
22 |
-var __extends = (this && this.__extends) || function (d, b) { |
|
23 |
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; |
|
22 |
+var __extends = (this && this.__extends) || (function () { |
|
23 |
+ var extendStatics = Object.setPrototypeOf || |
|
24 |
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
25 |
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; |
|
26 |
+ return function (d, b) { |
|
27 |
+ extendStatics(d, b); |
|
24 | 28 |
function __() { this.constructor = d; } |
25 | 29 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
26 | 30 |
}; |
31 |
+})(); |
|
27 | 32 |
// module lib_base { |
28 | 33 |
// } |
34 |
+// Web |
|
35 |
+/* |
|
36 |
+declare class Window { |
|
37 |
+ console : any; |
|
38 |
+ navigator : any; |
|
39 |
+ setTimeout : (function_ : (...params : Array<any>)=>void, delay : number, ...params : Array<any>)=>number; |
|
40 |
+}; |
|
41 |
+declare var window : Window; |
|
42 |
+declare class Document { |
|
43 |
+}; |
|
44 |
+declare var document : Document; |
|
45 |
+ */ |
|
46 |
+; |
|
29 | 47 |
var lib_base; |
30 | 48 |
(function (lib_base) { |
31 | 49 |
/** |
... | ... |
@@ -36,17 +54,17 @@ var lib_base; |
36 | 54 |
{ |
37 | 55 |
"id": "web", |
38 | 56 |
"name": "Web", |
39 |
- "predicate": function () { return (typeof (document) !== "undefined"); } |
|
57 |
+ "predicate": function () { return (typeof (document) !== "undefined"); }, |
|
40 | 58 |
}, |
41 | 59 |
{ |
42 | 60 |
"id": "node", |
43 | 61 |
"name": "Node.js", |
44 |
- "predicate": function () { return (typeof (process) !== "undefined"); } |
|
62 |
+ "predicate": function () { return (typeof (process) !== "undefined"); }, |
|
45 | 63 |
}, |
46 | 64 |
{ |
47 | 65 |
"id": "rhino", |
48 | 66 |
"name": "Rhino", |
49 |
- "predicate": function () { return (typeof (java) !== "undefined"); } |
|
67 |
+ "predicate": function () { return (typeof (java) !== "undefined"); }, |
|
50 | 68 |
}, |
51 | 69 |
]; |
52 | 70 |
var id; |
... | ... |
@@ -68,39 +86,168 @@ var lib_base; |
68 | 86 |
} |
69 | 87 |
lib_base.environment = environment; |
70 | 88 |
})(lib_base || (lib_base = {})); |
71 |
-function hash(value) { |
|
89 |
+/** |
|
90 |
+ * @author fenris |
|
91 |
+ */ |
|
92 |
+var instance_verbosity = 0; |
|
93 |
+/** |
|
94 |
+ * @author fenris |
|
95 |
+ */ |
|
96 |
+function instance_collate(value1, value2) { |
|
97 |
+ if (typeof (value1) === "object") { |
|
98 |
+ if (value1 == null) { |
|
99 |
+ return (value2 == null); |
|
100 |
+ } |
|
101 |
+ else { |
|
102 |
+ if ("_collate" in value1) { |
|
103 |
+ return value1["_collate"](value2); |
|
104 |
+ } |
|
105 |
+ else { |
|
106 |
+ throw (new Error("[collate]" + " " + "object has no such method")); |
|
107 |
+ } |
|
108 |
+ } |
|
109 |
+ } |
|
110 |
+ else { |
|
111 |
+ if (instance_verbosity >= 1) { |
|
112 |
+ lib_log.warn("[collate]" + " " + "primitive value; using default implementation"); |
|
113 |
+ } |
|
114 |
+ return (value1 === value2); |
|
115 |
+ } |
|
116 |
+} |
|
117 |
+/** |
|
118 |
+ * @author fenris |
|
119 |
+ */ |
|
120 |
+function instance_compare(value1, value2) { |
|
121 |
+ if (typeof (value1) === "object") { |
|
122 |
+ if ("_compare" in value1) { |
|
123 |
+ return value1["_compare"](value2); |
|
124 |
+ } |
|
125 |
+ else { |
|
126 |
+ throw (new Error("[compare]" + " " + "object has no such method")); |
|
127 |
+ } |
|
128 |
+ } |
|
129 |
+ else { |
|
130 |
+ if (instance_verbosity >= 1) { |
|
131 |
+ lib_log.warn("[compare]" + " " + "primitive value; using default implementation"); |
|
132 |
+ } |
|
133 |
+ return (value1 <= value2); |
|
134 |
+ } |
|
135 |
+} |
|
136 |
+/** |
|
137 |
+ * @author fenris |
|
138 |
+ */ |
|
139 |
+function instance_clone(value) { |
|
72 | 140 |
if (typeof (value) === "object") { |
73 |
- if ("hash" in value) |
|
74 |
- return value.hash(); |
|
75 |
- else |
|
76 |
- throw (new Error("[hash]" + " " + "object has no hash-method")); |
|
141 |
+ if ("_clone" in value) { |
|
142 |
+ return value["_clone"](); |
|
77 | 143 |
} |
78 | 144 |
else { |
79 |
- return value.toString(); |
|
145 |
+ throw (new Error("[clone]" + " " + "object has no such method")); |
|
146 |
+ } |
|
147 |
+ } |
|
148 |
+ else { |
|
149 |
+ if (instance_verbosity >= 1) { |
|
150 |
+ lib_log.warn("[clone]" + " " + "primitive value; using default implementation"); |
|
151 |
+ } |
|
152 |
+ return value; |
|
153 |
+ } |
|
154 |
+} |
|
155 |
+/** |
|
156 |
+ * @desc the ability to generate a string out of the element, which identifies it to a high degree |
|
157 |
+ * @author fenris |
|
158 |
+ */ |
|
159 |
+function instance_hash(value) { |
|
160 |
+ if (typeof (value) === "object") { |
|
161 |
+ if ("_hash" in value) { |
|
162 |
+ return value["_hash"](); |
|
80 | 163 |
} |
164 |
+ else { |
|
165 |
+ throw (new Error("[hash]" + " " + "object has no such method")); |
|
81 | 166 |
} |
82 |
-function equals(value_x, value_y) { |
|
83 |
- if (typeof (value_x) === "object") { |
|
84 |
- if ("equals" in value_x) |
|
85 |
- return value_x.equals(value_y); |
|
86 |
- else |
|
87 |
- throw (new Error("[equals]" + " " + "object has no equals-method")); |
|
88 | 167 |
} |
89 | 168 |
else { |
90 |
- return (value_x === value_y); |
|
169 |
+ if (instance_verbosity >= 1) { |
|
170 |
+ lib_log.warn("[hash]" + " " + "primitive value; using default implementation"); |
|
91 | 171 |
} |
172 |
+ return String(value); |
|
92 | 173 |
} |
93 |
-function show(value) { |
|
174 |
+} |
|
175 |
+/** |
|
176 |
+ * @desc the ability to map the element to a textual representation (most likely not injective) |
|
177 |
+ * @author fenris |
|
178 |
+ */ |
|
179 |
+function instance_show(value) { |
|
94 | 180 |
if (typeof (value) === "object") { |
95 |
- if ("show" in value) |
|
96 |
- return value.show(); |
|
97 |
- else |
|
98 |
- throw (new Error("[show]" + " " + "object has no show-method")); |
|
181 |
+ if (value == null) { |
|
182 |
+ return "NULL"; |
|
99 | 183 |
} |
100 | 184 |
else { |
101 |
- return value.toString(); |
|
185 |
+ if ("_show" in value) { |
|
186 |
+ return value["_show"](); |
|
187 |
+ } |
|
188 |
+ else { |
|
189 |
+ // throw (new Error("[show]" + " " + "object has no such method")); |
|
190 |
+ return JSON.stringify(value); |
|
191 |
+ } |
|
192 |
+ } |
|
193 |
+ } |
|
194 |
+ else { |
|
195 |
+ if (instance_verbosity >= 1) { |
|
196 |
+ lib_log.warn("[show]" + " " + "primitive value; using default implementation"); |
|
102 | 197 |
} |
198 |
+ return String(value); |
|
103 | 199 |
} |
200 |
+} |
|
201 |
+/** |
|
202 |
+ * @todo outsource to dedicated plankton-lib |
|
203 |
+ */ |
|
204 |
+var lib_log; |
|
205 |
+(function (lib_log) { |
|
206 |
+ /** |
|
207 |
+ * @author fenris |
|
208 |
+ */ |
|
209 |
+ function log() { |
|
210 |
+ var args = []; |
|
211 |
+ for (var _i = 0; _i < arguments.length; _i++) { |
|
212 |
+ args[_i] = arguments[_i]; |
|
213 |
+ } |
|
214 |
+ /*window.*/ console.log(args); |
|
215 |
+ } |
|
216 |
+ lib_log.log = log; |
|
217 |
+ /** |
|
218 |
+ * @author fenris |
|
219 |
+ */ |
|
220 |
+ function info() { |
|
221 |
+ var args = []; |
|
222 |
+ for (var _i = 0; _i < arguments.length; _i++) { |
|
223 |
+ args[_i] = arguments[_i]; |
|
224 |
+ } |
|
225 |
+ /*window.*/ console.info(args); |
|
226 |
+ } |
|
227 |
+ lib_log.info = info; |
|
228 |
+ /** |
|
229 |
+ * @author fenris |
|
230 |
+ */ |
|
231 |
+ function warn() { |
|
232 |
+ var args = []; |
|
233 |
+ for (var _i = 0; _i < arguments.length; _i++) { |
|
234 |
+ args[_i] = arguments[_i]; |
|
235 |
+ } |
|
236 |
+ /*window.*/ console.warn(args); |
|
237 |
+ } |
|
238 |
+ lib_log.warn = warn; |
|
239 |
+ /** |
|
240 |
+ * @author fenris |
|
241 |
+ */ |
|
242 |
+ function error() { |
|
243 |
+ var args = []; |
|
244 |
+ for (var _i = 0; _i < arguments.length; _i++) { |
|
245 |
+ args[_i] = arguments[_i]; |
|
246 |
+ } |
|
247 |
+ /*window.*/ console.error(args); |
|
248 |
+ } |
|
249 |
+ lib_log.error = error; |
|
250 |
+})(lib_log || (lib_log = {})); |
|
104 | 251 |
/** |
105 | 252 |
* @author frac |
106 | 253 |
*/ |
... | ... |
@@ -194,87 +341,116 @@ export interface interface_writeable<type_value> { |
194 | 341 |
} |
195 | 342 |
*/ |
196 | 343 |
/** |
197 |
- * @author frac |
|
344 |
+ * @author fenris |
|
198 | 345 |
*/ |
199 | 346 |
/*export*/ var class_maybe = (function () { |
200 | 347 |
function class_maybe() { |
201 | 348 |
} |
202 | 349 |
/** |
203 | 350 |
* @desc whether the wrapper is nothing |
204 |
- * @author frac |
|
351 |
+ * @author fenris |
|
205 | 352 |
*/ |
206 | 353 |
class_maybe.prototype.is_nothing = function () { |
207 | 354 |
throw (new Error("not implemented: class_maybe.is_nothing")); |
208 | 355 |
}; |
209 | 356 |
/** |
210 | 357 |
* @desc whether the wrapper is just |
211 |
- * @author frac |
|
358 |
+ * @author fenris |
|
212 | 359 |
*/ |
213 | 360 |
class_maybe.prototype.is_just = function () { |
214 | 361 |
throw (new Error("not implemented: class_maybe.is_just")); |
215 | 362 |
}; |
216 | 363 |
/** |
217 | 364 |
* @desc return the value, stored in the maybe-wrapper |
218 |
- * @author frac |
|
365 |
+ * @author fenris |
|
219 | 366 |
*/ |
220 | 367 |
class_maybe.prototype.cull = function () { |
221 | 368 |
throw (new Error("not implemented: class_maybe.cull")); |
222 | 369 |
}; |
223 | 370 |
/** |
224 |
- * @author frac |
|
371 |
+ * @author fenris |
|
372 |
+ */ |
|
373 |
+ class_maybe.prototype.toString = function () { |
|
374 |
+ throw (new Error("not implemented: class_maybe.cull")); |
|
375 |
+ }; |
|
376 |
+ /** |
|
377 |
+ * @author fenris |
|
225 | 378 |
*/ |
226 | 379 |
class_maybe.prototype.distinguish = function (action_just, action_nothing) { |
227 | 380 |
if (action_nothing === void 0) { action_nothing = function () { }; } |
228 | 381 |
throw (new Error("not implemented: class_maybe.distinguish")); |
229 | 382 |
}; |
230 | 383 |
/** |
231 |
- * @author frac |
|
384 |
+ * @author fenris |
|
232 | 385 |
*/ |
233 | 386 |
class_maybe.prototype.propagate = function (action) { |
234 | 387 |
throw (new Error("not implemented: class_maybe.propagate")); |
235 | 388 |
}; |
389 |
+ /** |
|
390 |
+ * @desc [implementation] |
|
391 |
+ * @author fenris |
|
392 |
+ */ |
|
393 |
+ class_maybe.prototype._show = function () { |
|
394 |
+ return this.toString(); |
|
395 |
+ }; |
|
236 | 396 |
return class_maybe; |
237 | 397 |
}()); |
238 | 398 |
/** |
239 |
- * @author frac |
|
399 |
+ * @author fenris |
|
240 | 400 |
*/ |
241 | 401 |
/*export*/ var class_nothing = (function (_super) { |
242 | 402 |
__extends(class_nothing, _super); |
243 | 403 |
/** |
244 |
- * @author frac |
|
404 |
+ * @author fenris |
|
245 | 405 |
*/ |
246 | 406 |
function class_nothing(reason) { |
247 | 407 |
if (reason === void 0) { reason = null; } |
248 |
- _super.call(this); |
|
249 |
- this.reason = reason; |
|
408 |
+ var _this = _super.call(this) || this; |
|
409 |
+ _this.reason = reason; |
|
410 |
+ return _this; |
|
250 | 411 |
} |
251 | 412 |
/** |
252 |
- * @author frac |
|
413 |
+ * @author fenris |
|
253 | 414 |
*/ |
254 | 415 |
class_nothing.prototype.is_nothing = function () { |
255 | 416 |
return true; |
256 | 417 |
}; |
257 | 418 |
/** |
258 |
- * @author frac |
|
419 |
+ * @author fenris |
|
259 | 420 |
*/ |
260 | 421 |
class_nothing.prototype.is_just = function () { |
261 | 422 |
return false; |
262 | 423 |
}; |
263 | 424 |
/** |
264 |
- * @author frac |
|
425 |
+ * @author fenris |
|
265 | 426 |
*/ |
266 | 427 |
class_nothing.prototype.cull = function () { |
428 |
+ var message = "you shouldn't cull a nothing-value …"; |
|
429 |
+ lib_log.warn(message); |
|
267 | 430 |
return null; |
268 | 431 |
}; |
269 | 432 |
/** |
270 |
- * @author frac |
|
433 |
+ * @author fenris |
|
434 |
+ */ |
|
435 |
+ class_nothing.prototype.toString = function () { |
|
436 |
+ return "<\u00B7>"; |
|
437 |
+ }; |
|
438 |
+ /** |
|
439 |
+ * @author fenris |
|
440 |
+ */ |
|
441 |
+ class_nothing.prototype.reason_get = function () { |
|
442 |
+ var content = ((this.reason == null) ? "·" : this.reason); |
|
443 |
+ return "<- " + content + " ->"; |
|
444 |
+ }; |
|
445 |
+ /** |
|
446 |
+ * @author fenris |
|
271 | 447 |
*/ |
272 | 448 |
class_nothing.prototype.distinguish = function (action_just, action_nothing) { |
273 | 449 |
if (action_nothing === void 0) { action_nothing = function () { }; } |
274 | 450 |
action_nothing(this.reason); |
275 | 451 |
}; |
276 | 452 |
/** |
277 |
- * @author frac |
|
453 |
+ * @author fenris |
|
278 | 454 |
*/ |
279 | 455 |
class_nothing.prototype.propagate = function (action) { |
280 | 456 |
return (new class_nothing(this.reason)); |
... | ... |
@@ -282,44 +458,52 @@ export interface interface_writeable<type_value> { |
282 | 458 |
return class_nothing; |
283 | 459 |
}(class_maybe)); |
284 | 460 |
/** |
285 |
- * @author frac |
|
461 |
+ * @author fenris |
|
286 | 462 |
*/ |
287 | 463 |
/*export*/ var class_just = (function (_super) { |
288 | 464 |
__extends(class_just, _super); |
289 | 465 |
/** |
290 |
- * @author frac |
|
466 |
+ * @author fenris |
|
291 | 467 |
*/ |
292 | 468 |
function class_just(value) { |
293 |
- _super.call(this); |
|
294 |
- this.value = value; |
|
469 |
+ var _this = _super.call(this) || this; |
|
470 |
+ _this.value = value; |
|
471 |
+ return _this; |
|
295 | 472 |
} |
296 | 473 |
/** |
297 |
- * @author frac |
|
474 |
+ * @author fenris |
|
298 | 475 |
*/ |
299 | 476 |
class_just.prototype.is_nothing = function () { |
300 | 477 |
return false; |
301 | 478 |
}; |
302 | 479 |
/** |
303 |
- * @author frac |
|
480 |
+ * @author fenris |
|
304 | 481 |
*/ |
305 | 482 |
class_just.prototype.is_just = function () { |
306 | 483 |
return true; |
307 | 484 |
}; |
308 | 485 |
/** |
309 |
- * @author frac |
|
486 |
+ * @author fenris |
|
310 | 487 |
*/ |
311 | 488 |
class_just.prototype.cull = function () { |
312 | 489 |
return this.value; |
313 | 490 |
}; |
314 | 491 |
/** |
315 |
- * @author frac |
|
492 |
+ * @author fenris |
|
493 |
+ */ |
|
494 |
+ class_just.prototype.toString = function () { |
|
495 |
+ var content = instance_show(this.value); |
|
496 |
+ return "<+ " + content + " +>"; |
|
497 |
+ }; |
|
498 |
+ /** |
|
499 |
+ * @author fenris |
|
316 | 500 |
*/ |
317 | 501 |
class_just.prototype.distinguish = function (action_just, action_nothing) { |
318 | 502 |
if (action_nothing === void 0) { action_nothing = function () { }; } |
319 | 503 |
action_just(this.value); |
320 | 504 |
}; |
321 | 505 |
/** |
322 |
- * @author frac |
|
506 |
+ * @author fenris |
|
323 | 507 |
*/ |
324 | 508 |
class_just.prototype.propagate = function (action) { |
325 | 509 |
return action(this.value); |
... | ... |
@@ -336,9 +520,10 @@ var class_error = (function (_super) { |
336 | 520 |
*/ |
337 | 521 |
function class_error(message, suberrors) { |
338 | 522 |
if (suberrors === void 0) { suberrors = []; } |
339 |
- _super.call(this, message); |
|
340 |
- this.suberrors = suberrors; |
|
341 |
- this.mess = message; |
|
523 |
+ var _this = _super.call(this, message) || this; |
|
524 |
+ _this.suberrors = suberrors; |
|
525 |
+ _this.mess = message; |
|
526 |
+ return _this; |
|
342 | 527 |
} |
343 | 528 |
/** |
344 | 529 |
* @override |
... | ... |
@@ -349,588 +534,146 @@ var class_error = (function (_super) { |
349 | 534 |
}; |
350 | 535 |
return class_error; |
351 | 536 |
}(Error)); |
352 |
-// module lib_base { |
|
353 |
-// import _instances = require("instances"); |
|
354 |
-// declare var hash; |
|
355 |
-// declare var equals; |
|
537 |
+///<reference path="../../base/build/logic-decl.d.ts"/> |
|
538 |
+var lib_call; |
|
539 |
+(function (lib_call) { |
|
356 | 540 |
/** |
541 |
+ * @desc this is kind of an ugly hack; the motivation is, that the JS-interpreter of many Gecko-based browsers |
|
542 |
+ * (e.g. Firefox) won't accept a larger number of stack-frames, which come up when using executor-chains often. |
|
543 |
+ * This can be circumvented by deferring inner calls, such that they are moved outside the own stack-frame. This |
|
544 |
+ * is possible due to the asynchronous nature of executors. However this does also significantly increase the |
|
545 |
+ * overall-time for a long executor-chain (or rather executor-tree) to finish. Therefore it is not recommended |
|
546 |
+ * to do this by default. |
|
357 | 547 |
* @author frac |
358 | 548 |
*/ |
359 |
-/*export*/ var Pair = (function () { |
|
360 |
- function Pair(first, second) { |
|
361 |
- this.first = first; |
|
362 |
- this.second = second; |
|
549 |
+ lib_call.default_deferred = ((lib_base.environment() == "web") && (window.navigator.userAgent.indexOf("Firefox") >= 0)); |
|
550 |
+ /** |
|
551 |
+ * @author fenris |
|
552 |
+ */ |
|
553 |
+ function schedule(function_, deferred = lib_call.default_deferred) { |
|
554 |
+ if (!deferred) { |
|
555 |
+ function_(); |
|
363 | 556 |
} |
364 |
- Pair.prototype.equals = function (pair) { |
|
365 |
- var first_equals; |
|
366 |
- var second_equals; |
|
367 |
- var exceptions = new Array(); |
|
368 |
- try { |
|
369 |
- first_equals = equals(this.first, pair.first); |
|
557 |
+ else { |
|
558 |
+ setTimeout(function_, 0); |
|
370 | 559 |
} |
371 |
- catch (exception) { |
|
372 |
- exceptions.push(exception); |
|
373 | 560 |
} |
374 |
- try { |
|
375 |
- second_equals = equals(this.second, pair.second); |
|
561 |
+ lib_call.schedule = schedule; |
|
562 |
+})(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 { |
|
376 | 571 |
} |
377 |
- catch (exception) { |
|
378 |
- exceptions.push(exception); |
|
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; |
|
379 | 585 |
} |
380 |
- if (exceptions.length == 0) { |
|
381 |
- return (first_equals && second_equals); |
|
586 |
+ /** |
|
587 |
+ * @author frac |
|
588 |
+ */ |
|
589 |
+ run_(dependencies) { |
|
590 |
+ if (dependencies.length > 0) { |
|
591 |
+ dependencies[0](() => this.run_(dependencies.slice(1))); |
|
382 | 592 |
} |
383 | 593 |
else { |
384 |
- throw (new Exception("Pair:equals:components", "Missing equality-implementation for components while trying to compute equality of pairs", exceptions)); |
|
385 |
- } |
|
386 |
- }; |
|
387 |
- Pair.prototype.hash = function () { |
|
388 |
- var first_hash; |
|
389 |
- var second_hash; |
|
390 |
- var exceptions = new Array(); |
|
391 |
- try { |
|
392 |
- first_hash = hash(this.first); |
|
393 |
- } |
|
394 |
- catch (exception) { |
|
395 |
- exceptions.push(exception); |
|
396 |
- } |
|
397 |
- try { |
|
398 |
- second_hash = hash(this.second); |
|
594 |
+ this.action(); |
|
399 | 595 |
} |
400 |
- catch (exception) { |
|
401 |
- exceptions.push(exception); |
|
402 | 596 |
} |
403 |
- if (exceptions.length == 0) { |
|
404 |
- return (first_hash + "_" + second_hash); |
|
597 |
+ /** |
|
598 |
+ * @author frac |
|
599 |
+ */ |
|
600 |
+ run() { |
|
601 |
+ this.run_(this.dependencies); |
|
405 | 602 |
} |
406 |
- else { |
|
407 |
- throw (new Exception("Pair:hash:components", "Missing hash for components while trying to retrieve hash of pair", exceptions)); |
|
408 | 603 |
} |
409 |
- }; |
|
410 |
- Pair.prototype.toString = function () { |
|
411 |
- return ("(" + this.first.toString() + ", " + this.second.toString() + ")"); |
|
412 |
- }; |
|
413 |
- return Pair; |
|
414 |
-}()); |
|
604 |
+ lib_call.class_wait_sequential = class_wait_sequential; |
|
415 | 605 |
/** |
416 | 606 |
* @author frac |
607 |
+ * @todo could possibly be replaced by Promise-system |
|
417 | 608 |
*/ |
418 |
-/*export*/ var AbstractMap = (function () { |
|
419 |
- function AbstractMap() { |
|
420 |
- this.size = 0; |
|
421 |
- } |
|
422 |
- AbstractMap.prototype.get = function (key) { |
|
423 |
- throw (new ExceptionAbstract("Map:get")); |
|
424 |
- }; |
|
425 |
- AbstractMap.prototype.get_fallback = function (key, fallback) { |
|
426 |
- if (fallback === void 0) { fallback = null; } |
|
427 |
- try { |
|
428 |
- return this.get(key); |
|
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)); |
|
429 | 619 |
} |
430 |
- catch (exception) { |
|
431 |
- if (exception_is(exception, "Map:get:not_found")) |
|
432 |
- return fallback; |
|
433 |
- else |
|
434 |
- throw exception; |
|
620 |
+ /** |
|
621 |
+ * @author frac |
|
622 |
+ */ |
|
623 |
+ add_dependency(dependency) { |
|
624 |
+ this.dependencies["dependency_" + this.index.toString()] = dependency; |
|
625 |
+ this.index += 1; |
|
435 | 626 |
} |
436 |
- }; |
|
437 |
- AbstractMap.prototype.has = function (key) { |
|
438 |
- throw (new ExceptionAbstract("Map:has")); |
|
439 |
- }; |
|
440 |
- AbstractMap.prototype.set = function (key, value) { |
|
441 |
- throw (new ExceptionAbstract("Map:set")); |
|
442 |
- }; |
|
443 |
- AbstractMap.prototype.extend = function (map) { |
|
444 |
- (function (this_) { |
|
445 |
- map.forEach(function (value, key) { |
|
446 |
- this_.set(key, value); |
|
447 |
- }); |
|
448 |
- })(this); |
|
449 |
- }; |
|
450 |
- AbstractMap.prototype.delete = function (key) { |
|
451 |
- throw (new ExceptionAbstract("Map:delete")); |
|
452 |
- }; |
|
453 |
- AbstractMap.prototype.clear = function () { |
|
454 |
- throw (new ExceptionAbstract("Map:clear")); |
|
455 |
- }; |
|
456 |
- AbstractMap.prototype.forEach = function (action) { |
|
457 |
- throw (new ExceptionAbstract("Map:get")); |
|
458 |
- }; |
|
459 |
- AbstractMap.prototype.pairs = function () { |
|
460 |
- var pairs = new Array(); |
|
461 |
- this.forEach(function (value, key) { |
|
462 |
- pairs.push(new Pair(key, value)); |
|
463 |
- }); |
|
464 |
- return pairs; |
|
465 |
- }; |
|
466 |
- AbstractMap.prototype.toString = function () { |
|
467 |
- return ("{" + this.pairs().map(function (pair) { return (pair.first.toString() + ": " + pair.second.toString()); }).join(", ") + "}"); |
|
468 |
- }; |
|
469 |
- return AbstractMap; |
|
470 |
-}()); |
|
471 | 627 |
/** |
472 | 628 |
* @author frac |
473 | 629 |
*/ |
474 |
-/*export*/ var EqualityMap = (function (_super) { |
|
475 |
- __extends(EqualityMap, _super); |
|
476 |
- function EqualityMap() { |
|
477 |
- _super.call(this); |
|
478 |
- this.clear(); |
|
630 |
+ remove_dependency(id) { |
|
631 |
+ if (!(id in this.dependencies)) { |
|
632 |
+ throw (new Error("dependency does not exist")); |
|
479 | 633 |
} |
480 |
- EqualityMap.prototype.get_index = function (key) { |
|
481 |
- var index = this.pairs_["findIndex"](function (pair) { return equals(pair.first, key); }); |
|
482 |
- return ((index < 0) ? null : index); |
|
483 |
- }; |
|
484 |
- EqualityMap.prototype.get_pair = function (key) { |
|
485 |
- var index = this.get_index(key); |
|
486 |
- return ((index == null) ? null : this.pairs_[index]); |
|
487 |
- }; |
|
488 |
- EqualityMap.prototype.get = function (key) { |
|
489 |
- return this.get_pair(key).second; |
|
490 |
- }; |
|
491 |
- EqualityMap.prototype.has = function (key) { |
|
492 |
- try { |
|
493 |
- this.get(key); |
|
494 |
- return true; |
|
634 |
+ else { |
|
635 |
+ delete this.dependencies[id]; |
|
636 |
+ if (Object.keys(this.dependencies).length == 0) { |
|
637 |
+ this.action(); |
|
495 | 638 |
} |
496 |
- catch (exception) { |
|
497 |
- if (exception_is(exception, "Map:get:not_found")) |
|
498 |
- return false; |
|
499 |
- else |
|
500 |
- throw exception; |
|
501 | 639 |
} |
502 |
- }; |
|
503 |
- EqualityMap.prototype.set = function (key, value) { |
|
504 |
- var pair = this.get_pair(key); |
|
505 |
- if (pair != null) { |
|
506 |
- console.warn("overwriting value for the following key: ", key); |
|
507 |
- pair.second = value; |
|
508 | 640 |
} |
509 |
- else { |
|
510 |
- this.pairs_.push(new Pair(key, value)); |
|
511 |
- this.size += 1; |
|
512 |
- } |
|
513 |
- return this; |
|
514 |
- }; |
|
515 |
- EqualityMap.prototype.delete = function (key) { |
|
516 |
- var index; |
|
517 |
- var present; |
|
518 |
- try { |
|
519 |
- index = this.get_index(key); |
|
520 |
- present = true; |
|
521 |
- } |
|
522 |
- catch (exception) { |
|
523 |
- if (exception_is(exception, "Map:get:not_found")) |
|
524 |
- present = false; |
|
525 |
- else |
|
526 |
- throw exception; |
|
527 |
- } |
|
528 |
- if (present) { |
|
529 |
- this.pairs_ = this.pairs_.splice(index, 1); |
|
530 |
- this.size -= 1; |
|
531 |
- return true; |
|
532 |
- } |
|
533 |
- else { |
|
534 |
- return false; |
|
535 |
- } |
|
536 |
- }; |
|
537 |
- EqualityMap.prototype.clear = function () { |
|
538 |
- this.pairs_ = new Array(); |
|
539 |
- this.size = 0; |
|
540 |
- }; |
|
541 |
- EqualityMap.prototype.forEach = function (action) { |
|
542 |
- (function (this_) { |
|
543 |
- this_.pairs_.forEach(function (pair) { |
|
544 |
- action(pair.second, pair.first, this_); |
|
545 |
- }); |
|
546 |
- })(this); |
|
547 |
- }; |
|
548 |
- return EqualityMap; |
|
549 |
-}(AbstractMap)); |
|
550 |
-/** |
|
551 |
- * @author frac |
|
552 |
- */ |
|
553 |
-/*export*/ var HashMap = (function (_super) { |
|
554 |
- __extends(HashMap, _super); |
|
555 |
- function HashMap() { |
|
556 |
- _super.call(this); |
|
557 |
- this.clear(); |
|
558 |
- } |
|
559 |
- HashMap.prototype.get = function (key) { |
|
560 |
- var hashvalue = hash(key); |
|
561 |
- if (hashvalue in this.object) |
|
562 |
- return this.object[hashvalue]; |
|
563 |
- else |
|
564 |
- throw (new Exception("Map:get:not_found", "no entry for the given key (hashvalue: '" + hashvalue + "')")); |
|
565 |
- }; |
|
566 |
- HashMap.prototype.has = function (key) { |
|
567 |
- return (hash(key) in this.object); |
|
568 |
- }; |
|
569 |
- HashMap.prototype.set = function (key, value) { |
|
570 |
- var hashvalue = hash(key); |
|
571 |
- if (hashvalue in this.object) { |
|
572 |
- console.warn("overwriting value for key with hashvalue '" + hashvalue + "'"); |
|
573 |
- this.object[hashvalue] = value; |
|
574 |
- } |
|
575 |
- else { |
|
576 |
- this.keys_original.push(key); |
|
577 |
- this.object[hashvalue] = value; |
|
578 |
- this.size += 1; |
|
579 |
- } |
|
580 |
- return this; |
|
581 |
- }; |
|
582 |
- HashMap.prototype.delete = function (key) { |
|
583 |
- var hashvalue = hash(key); |
|
584 |
- if (hashvalue in this.object) { |
|
585 |
- this.keys_original = this.keys_original.filter(function (key_) { |
|
586 |
- return (hash(key_) != hashvalue); |
|
587 |
- }); |
|
588 |
- delete this.object[hashvalue]; |
|
589 |
- this.size -= 1; |
|
590 |
- return true; |
|
591 |
- } |
|
592 |
- else { |
|
593 |
- return false; |
|
594 |
- } |
|
595 |
- }; |
|
596 |
- HashMap.prototype.clear = function () { |
|
597 |
- this.keys_original = new Array(); |
|
598 |
- this.object = {}; |
|
599 |
- this.size = 0; |
|
600 |
- }; |
|
601 |
- HashMap.prototype.forEach = function (action) { |
|
602 |
- (function (this_) { |
|
603 |
- this_.keys_original.forEach(function (key) { |
|
604 |
- var hashvalue = hash(key); |
|
605 |
- var value = this_.object[hashvalue]; |
|
606 |
- action(value, key, this_); |
|
607 |
- }); |
|
608 |
- })(this); |
|
609 |
- }; |
|
610 |
- return HashMap; |
|
611 |
-}(AbstractMap)); |
|
612 |
-/** |
|
613 |
- * @author frac |
|
614 |
- */ |
|
615 |
-/*exports*/ var SimpleMap = (function (_super) { |
|
616 |
- __extends(SimpleMap, _super); |
|
617 |
- function SimpleMap() { |
|
618 |
- _super.call(this); |
|
619 |
- } |
|
620 |
- return SimpleMap; |
|
621 |
-}(HashMap)); |
|
622 |
-/** |
|
623 |
- * @author frac |
|
624 |
- */ |
|
625 |
-/*export*/ var Tree = (function () { |
|
626 |
- // constructors |
|
627 |
- function Tree(parent, value, children) { |
|
628 |
- if (parent === void 0) { parent = null; } |
|
629 |
- if (value === void 0) { value = null; } |
|
630 |
- if (children === void 0) { children = new Array(); } |
|
631 |
- this.parent = parent; |
|
632 |
- this.value = value; |
|
633 |
- this.children = children; |
|
634 |
- var this_ = this; |
|
635 |
- if (children != null) |
|
636 |
- this.children.forEach(function (tree) { tree.parent = this_; }); |
|
637 |
- } |
|
638 |
- // accessors |
|
639 |
- Tree.prototype.value_get = function () { |
|
640 |
- return this.value; |
|
641 |
- }; |
|
642 |
- Tree.prototype.map = function (transformator, parent) { |
|
643 |
- if (parent === void 0) { parent = null; } |
|
644 |
- var tree = new Tree(parent, transformator(this.value)); |
|
645 |
- tree.children = this.children.map(function (tree_) { return tree_.map(transformator, tree); }); |
|
646 |
- return tree; |
|
647 |
- }; |
|
648 |
- /* |
|
649 |
- public children_iterate():void |
|
650 |
- { |
|
651 |
- this.children.forEach(function (tree:Tree<Value>) {yield tree;}); |
|
652 |
- } |
|
653 |
- */ |
|
654 |
- Tree.prototype.flatten = function (postorder) { |
|
655 |
- if (postorder === void 0) { postorder = false; } |
|
656 |
- var reduce = postorder ? 'reduceRight' : 'reduce'; |
|
657 |
- return this.children[reduce](function (list, tree) { return list.concat(tree.flatten(postorder)); }, [this]); |
|
658 |
- }; |
|
659 |
- Tree.prototype.traverse = function (postorder) { |
|
660 |
- if (postorder === void 0) { postorder = false; } |
|
661 |
- return this.flatten().map(function (tree) { return tree.value; }); |
|
662 |
- }; |
|
663 |
- Tree.prototype.graph = function (prefix) { |
|
664 |
- if (prefix === void 0) { prefix = "x"; } |
|
665 |
- var vertices = new Array(); |
|
666 |
- var edges = new Array(); |
|
667 |
- vertices.push(new Pair(prefix, this.value)); |
|
668 |
- this.children.forEach(function (tree, index) { |
|
669 |
- var prefix_ = prefix + "_" + index.toString(); |
|
670 |
- edges.push(new Pair(new Pair(prefix, prefix_), null)); |
|
671 |
- var graph = tree.graph(prefix_); |
|
672 |
- vertices = vertices.concat(graph.get_vertices()); |
|
673 |
- edges = edges.concat(graph.get_edges()); |
|
674 |
- }); |
|
675 |
- return new Graph(vertices, edges); |
|
676 |
- }; |
|
677 |
- // mutators |
|
678 |
- Tree.prototype.value_set = function (value) { |
|
679 |
- this.value = value; |
|
680 |
- }; |
|
681 |
- Tree.prototype.children_add = function (tree) { |
|
682 |
- this.children.push(tree); |
|
683 |
- tree.parent = this; |
|
684 |
- }; |
|
685 |
- return Tree; |
|
686 |
-}()); |
|
687 |
-/** |
|
688 |
- * @author frac |
|
689 |
- */ |
|
690 |
-/*export*/ var Graph = (function () { |
|
691 |
- function Graph(vertices, edges) { |
|
692 |
- // [ToDo] check consistency |
|
693 |
- this.vertices = vertices; |
|
694 |
- this.edges = edges; |
|
695 |
- } |
|
696 |
- Graph.prototype.get_vertices = function () { |
|
697 |
- return this.vertices; |
|
698 |
- }; |
|
699 |
- Graph.prototype.get_edges = function () { |
|
700 |
- return this.edges; |
|
701 |
- }; |
|
702 |
- Graph.prototype.graphviz = function (name) { |
|
703 |
- if (name === void 0) { name = "conversion"; } |
|
704 |
- var script = ""; |
|
705 |
- script += ("digraph " + name + "\n"); |
|
706 |
- script += ("{\n"); |
|
707 |
- this.vertices.forEach(function (vertex) { |
|
708 |
- var line = ""; |
|
709 |
- line += ("\t" + vertex.first); |
|
710 |
- var parameters = new HashMap(); |
|
711 |
- parameters.set("shape", "circle"); |
|
712 |
- if (vertex.first != null) |
|
713 |
- parameters.set("label", vertex.second.toString()); |
|
714 |
- line += (" [" + parameters.pairs().map(function (pair) { return (pair.first + "='" + pair.second + "'"); }).join(",") + "]"); |
|
715 |
- line += "\n"; |
|
716 |
- script += line; |
|
717 |
- }); |
|
718 |
- script += ("\t\n"); |
|
719 |
- this.edges.forEach(function (edge) { |
|
720 |
- var line = ""; |
|
721 |
- line += ("\t" + edge.first.first + " -> " + edge.first.second); |
|
722 |
- var parameters = new HashMap(); |
|
723 |
- if (edge.second != null) |
|
724 |
- parameters.set("label", edge.second.toString()); |
|
725 |
- line += (" [" + parameters.pairs().map(function (pair) { return (pair.first + "='" + pair.second + "'"); }).join(",") + "]"); |
|
726 |
- line += "\n"; |
|
727 |
- script += line; |
|
728 |
- }); |
|
729 |
- script += ("}\n"); |
|
730 |
- return script; |
|
731 |
- }; |
|
732 |
- return Graph; |
|
733 |
-}()); |
|
734 |
-/*export*/ function tree_test() { |
|
735 |
- var tree = new Tree(null, 3, [ |
|
736 |
- new Tree(null, 1, [ |
|
737 |
- new Tree(null, 0), |
|
738 |
- new Tree(null, 2), |
|
739 |
- ]), |
|
740 |
- new Tree(null, 5, [ |
|
741 |
- new Tree(null, 4), |
|
742 |
- new Tree(null, 6), |
|
743 |
- ]), |
|
744 |
- ]); |
|
745 |
- return tree; |
|
746 |
-} |
|
747 |
-/* |
|
748 |
-*/ |
|
749 |
-// } |
|
750 |
-/** |
|
751 |
- * @author frac |
|
752 |
- */ |
|
753 |
-var class_set = (function () { |
|
754 |
- /** |
|
755 |
- * @author frac |
|
756 |
- */ |
|
757 |
- function class_set(elements) { |
|
758 |
- var _this = this; |
|
759 |
- if (elements === void 0) { elements = []; } |
|
760 |
- this.elements = []; |
|
761 |
- elements.forEach(function (element) { return _this.add(element); }); |
|
762 |
- } |
|
763 |
- /** |
|
764 |
- * @author frac |
|
765 |
- */ |
|
766 |
- class_set.prototype.elements_get = function () { |
|
767 |
- return this.elements; |
|
768 |
- }; |
|
769 |
- /** |
|
770 |
- * @author frac |
|
771 |
- */ |
|
772 |
- class_set.prototype.add = function (element) { |
|
773 |
- if (this.elements.indexOf(element) < 0) { |
|
774 |
- this.elements.push(element); |
|
775 |
- } |
|
776 |
- }; |
|
777 |
- /** |
|
778 |
- * @author frac |
|
779 |
- */ |
|
780 |
- class_set.prototype.forEach = function (action) { |
|
781 |
- this.elements.forEach(action); |
|
782 |
- }; |
|
783 |
- return class_set; |
|
784 |
-}()); |
|
785 |
-var __extends = (this && this.__extends) || function (d, b) { |
|
786 |
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; |
|
787 |
- function __() { this.constructor = d; } |
|
788 |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
789 |
-}; |
|
790 |
-var lib_call; |
|
791 |
-(function (lib_call) { |
|
792 |
- /** |
|
793 |
- * @desc this is kind of an ugly hack; the motivation is, that the JS-interpreter of many Gecko-based browsers |
|
794 |
- * (e.g. Firefox) won't accept a larger number of stack-frames, which come up when using executor-chains often. |
|
795 |
- * This can be circumvented by deferring inner calls, such that they are moved outside the own stack-frame. This |
|
796 |
- * is possible due to the asynchronous nature of executors. However this does also significantly increase the |
|
797 |
- * overall-time for a long executor-chain (or rather executor-tree) to finish. Therefore it is not recommended |
|
798 |
- * to do this by default. |
|
799 |
- * @author frac |
|
800 |
- */ |
|
801 |
- lib_call.default_deferred = ((typeof (navigator) === "undefined") ? false : (navigator.userAgent.indexOf("Firefox") >= 0)); |
|
802 |
- /** |
|
803 |
- * @author fenris |
|
804 |
- */ |
|
805 |
- function schedule(function_, deferred) { |
|
806 |
- if (deferred === void 0) { deferred = lib_call.default_deferred; } |
|
807 |
- if (!deferred) { |
|
808 |
- function_(); |
|
809 |
- } |
|
810 |
- else { |
|
811 |
- setTimeout(function_, 0); |
|
812 |
- } |
|
813 |
- } |
|
814 |
- lib_call.schedule = schedule; |
|
815 |
-})(lib_call || (lib_call = {})); |
|
816 |
-///<reference path="../../base/build/logic.d.ts"/> |
|
817 |
-var lib_call; |
|
818 |
-(function (lib_call) { |
|
819 |
- /** |
|
820 |
- * @author frac |
|
821 |
- * @todo could possibly be replaced by Promise-system |
|
822 |
- */ |
|
823 |
- var class_wait = (function () { |
|
824 |
- function class_wait() { |
|
825 |
- } |
|
826 |
- return class_wait; |
|
827 |
- }()); |
|
828 |
- lib_call.class_wait = class_wait; |
|
829 |
- /** |
|
830 |
- * @author frac |
|
831 |
- * @todo could possibly be replaced by Promise-system |
|
832 |
- */ |
|
833 |
- var class_wait_sequential = (function (_super) { |
|
834 |
- __extends(class_wait_sequential, _super); |
|
835 |
- /** |
|
836 |
- * @author frac |
|
837 |
- */ |
|
838 |
- function class_wait_sequential(dependencies, action) { |
|
839 |
- if (action === void 0) { action = function () { console.log("all done"); }; } |
|
840 |
- _super.call(this); |
|
841 |
- this.dependencies = dependencies; |
|
842 |
- this.action = action; |
|
843 |
- } |
|
844 |
- /** |
|
845 |
- * @author frac |
|
846 |
- */ |
|
847 |
- class_wait_sequential.prototype.run_ = function (dependencies) { |
|
848 |
- var _this = this; |
|
849 |
- if (dependencies.length > 0) { |
|
850 |
- dependencies[0](function () { return _this.run_(dependencies.slice(1)); }); |
|
851 |
- } |
|
852 |
- else { |
|
853 |
- this.action(); |
|
854 |
- } |
|
855 |
- }; |
|
856 |
- /** |
|
857 |
- * @author frac |
|
858 |
- */ |
|
859 |
- class_wait_sequential.prototype.run = function () { |
|
860 |
- this.run_(this.dependencies); |
|
861 |
- }; |
|
862 |
- return class_wait_sequential; |
|
863 |
- }(class_wait)); |
|
864 |
- lib_call.class_wait_sequential = class_wait_sequential; |
|
865 |
- /** |
|
866 |
- * @author frac |
|
867 |
- * @todo could possibly be replaced by Promise-system |
|
868 |
- */ |
|
869 |
- var class_wait_parallel = (function (_super) { |
|
870 |
- __extends(class_wait_parallel, _super); |
|
871 |
- /** |
|
872 |
- * @author frac |
|
873 |
- */ |
|
874 |
- function class_wait_parallel(dependencies, action) { |
|
875 |
- var _this = this; |
|
876 |
- if (action === void 0) { action = function () { console.log("all done"); }; } |
|
877 |
- _super.call(this); |
|
878 |
- this.index = 0; |
|
879 |
- this.dependencies = {}; |
|
880 |
- this.action = action; |
|
881 |
- dependencies.forEach(function (dependency) { return _this.add_dependency(dependency); }); |
|
882 |
- } |
|
883 |
- /** |
|
884 |
- * @author frac |
|
885 |
- */ |
|
886 |
- class_wait_parallel.prototype.add_dependency = function (dependency) { |
|
887 |
- this.dependencies["dependency_" + this.index.toString()] = dependency; |
|
888 |
- this.index += 1; |
|
889 |
- }; |
|
890 | 641 |
/** |
891 | 642 |
* @author frac |
892 | 643 |
*/ |
893 |
- class_wait_parallel.prototype.remove_dependency = function (id) { |
|
894 |
- if (!(id in this.dependencies)) { |
|
895 |
- throw (new Error("dependency does not exist")); |
|
896 |
- } |
|
897 |
- else { |
|
898 |
- delete this.dependencies[id]; |
|
899 |
- if (Object.keys(this.dependencies).length == 0) { |
|
900 |
- this.action(); |
|
901 |
- } |
|
902 |
- } |
|
903 |
- }; |
|
904 |
- /** |
|
905 |
- * @author frac |
|
906 |
- */ |
|
907 |
- class_wait_parallel.prototype.run = function () { |
|
908 |
- var that = this; |
|
644 |
+ run() { |
|
645 |
+ let that = this; |
|
909 | 646 |
if (Object.keys(this.dependencies).length == 0) { |
910 | 647 |
this.action(); |
911 | 648 |
} |
912 | 649 |
else { |
913 | 650 |
Object.keys(this.dependencies).forEach(function (id) { |
914 |
- var dependency = that.dependencies[id]; |
|
651 |
+ let dependency = that.dependencies[id]; |
|
915 | 652 |
dependency(function () { |
916 | 653 |
that.remove_dependency(id); |
917 | 654 |
}); |
918 | 655 |
}); |
919 | 656 |
} |
920 |
- }; |
|
921 |
- return class_wait_parallel; |
|
922 |
- }(class_wait)); |
|
657 |
+ } |
|
658 |
+ } |
|
923 | 659 |
lib_call.class_wait_parallel = class_wait_parallel; |
924 | 660 |
})(lib_call || (lib_call = {})); |
925 |
-///<reference path="../../base/build/logic.d.ts"/> |
|
926 | 661 |
var lib_call; |
927 | 662 |
(function (lib_call) { |
663 |
+ /** |
|
664 |
+ * @author fenris |
|
665 |
+ */ |
|
666 |
+ function timeout(function_, delay, ...params) { |
|
667 |
+ return ( |
|
668 |
+ /*window.*/ setTimeout.apply( |
|
669 |
+ /*window.*/ setTimeout, [function_, delay].concat(params))); |
|
670 |
+ } |
|
671 |
+ lib_call.timeout = timeout; |
|
928 | 672 |
/** |
929 | 673 |
* @desc a definition for a value being "defined" |
930 | 674 |
* @author neuc |
931 | 675 |
*/ |
932 |
- function is_def(obj, null_is_valid) { |
|
933 |
- if (null_is_valid === void 0) { null_is_valid = false; } |
|
676 |
+ function is_def(obj, null_is_valid = false) { |
|
934 | 677 |
return (!((typeof (obj) === "undefined") || (!null_is_valid && (obj === null)))); |
935 | 678 |
} |
936 | 679 |
lib_call.is_def = is_def; |
... | ... |
@@ -938,9 +681,7 @@ var lib_call; |
938 | 681 |
* @desc returns the value if set and, when a type is specified, if the type is corret, if not return default_value |
939 | 682 |
* @author neuc |
940 | 683 |
*/ |
941 |
- function def_val(value, default_value, type, null_is_valid) { |
|
942 |
- if (type === void 0) { type = null; } |
|
943 |
- if (null_is_valid === void 0) { null_is_valid = false; } |
|
684 |
+ function def_val(value, default_value, type = null, null_is_valid = false) { |
|
944 | 685 |
if (is_def(value, null_is_valid) && (is_def(type) ? ((typeof value === type) || ((value === null) && null_is_valid)) : true)) { |
945 | 686 |
return value; |
946 | 687 |
} |
... | ... |
@@ -952,21 +693,21 @@ var lib_call; |
952 | 693 |
; |
953 | 694 |
/** |
954 | 695 |
* @desc just the empty function; useful for some callbacks etc. |
955 |
- * @author frac |
|
696 |
+ * @author fenris |
|
956 | 697 |
*/ |
957 | 698 |
function nothing() { |
958 | 699 |
} |
959 | 700 |
lib_call.nothing = nothing; |
960 | 701 |
/** |
961 | 702 |
* @desc just the identity; useful for some callbacks etc. |
962 |
- * @author frac |
|
703 |
+ * @author fenris |
|
963 | 704 |
*/ |
964 | 705 |
function id(x) { |
965 | 706 |
return x; |
966 | 707 |
} |
967 | 708 |
lib_call.id = id; |
968 | 709 |
/** |
969 |
- * @author frac |
|
710 |
+ * @author fenris |
|
970 | 711 |
*/ |
971 | 712 |
function use(input, function_) { |
972 | 713 |
return function_(input); |
... | ... |
@@ -974,36 +715,36 @@ var lib_call; |
974 | 715 |
lib_call.use = use; |
975 | 716 |
/** |
976 | 717 |
* @desc outputs |
977 |
- * @author frac |
|
718 |
+ * @author fenris |
|
978 | 719 |
*/ |
979 |
- function output(x) { |
|
980 |
- console["_info"].apply(console, arguments); |
|
720 |
+ function output(...args) { |
|
721 |
+ lib_log.info.apply(lib_log, args); |
|
981 | 722 |
} |
982 | 723 |
lib_call.output = output; |
983 | 724 |
/** |
984 | 725 |
* @desc converts the "arguments"-map into an array |
985 | 726 |
* @param {Object} args |
986 |
- * @author frac |
|
727 |
+ * @author fenris |
|
987 | 728 |
*/ |
988 | 729 |
function args2list(args) { |
989 |
- return Object.keys(args).map(function (key) { return args[key]; }); |
|
730 |
+ return Object.keys(args).map(key => args[key]); |
|
990 | 731 |
} |
991 | 732 |
lib_call.args2list = args2list; |
992 | 733 |
/** |
993 | 734 |
* @desc provides the call for an attribute of a class as a regular function |
994 | 735 |
* @param {string} name the name of the attribute |
995 | 736 |
* @return {*} |
996 |
- * @author frac |
|
737 |
+ * @author fenris |
|
997 | 738 |
*/ |
998 | 739 |
function attribute(name) { |
999 |
- return (function (object) { return object[name]; }); |
|
740 |
+ return ((object) => object[name]); |
|
1000 | 741 |
} |
1001 | 742 |
lib_call.attribute = attribute; |
1002 | 743 |
/** |
1003 | 744 |
* @desc provides a method of a class as a regular function |
1004 | 745 |
* @param {string} name the name of the method |
1005 | 746 |
* @return {function} |
1006 |
- * @author frac |
|
747 |
+ * @author fenris |
|
1007 | 748 |
*/ |
1008 | 749 |
function method(name) { |
1009 | 750 |
return (function (object) { return object[name].apply(object, args2list(arguments).slice(1)); }); |
... | ... |
@@ -1013,7 +754,7 @@ var lib_call; |
1013 | 754 |
* @desc composes two functions (i.e. returns a function that return the result of the successive execution of both input-functions) |
1014 | 755 |
* @param {function} function_f |
1015 | 756 |
* @param {function} function_g |
1016 |
- * @author frac |
|
757 |
+ * @author fenris |
|
1017 | 758 |
*/ |
1018 | 759 |
function compose(function_f, function_g) { |
1019 | 760 |
return (function (x) { |
... | ... |
@@ -1027,33 +768,33 @@ var lib_call; |
1027 | 768 |
* @param {function} f |
1028 | 769 |
* @param {int} n (don't set manually) |
1029 | 770 |
* @return {function} the currified version of the in put function |
1030 |
- * @author frac |
|
771 |
+ * @author fenris |
|
1031 | 772 |
*/ |
1032 |
- function curryfy(f, n) { |
|
1033 |
- if (n === void 0) { n = f.length; } |
|
773 |
+ function curryfy(f, n = f.length) { |
|
1034 | 774 |
switch (n) { |
1035 | 775 |
case 0: { |
1036 | 776 |
throw (new Error("[curryfy] impossible")); |
777 |
+ // break; |
|
1037 | 778 |
} |
1038 | 779 |
case 1: { |
1039 | 780 |
return f; |
781 |
+ // break; |
|
1040 | 782 |
} |
1041 | 783 |
default: { |
1042 | 784 |
return (function (x) { |
1043 | 785 |
return (curryfy(function () { return f.apply(f, [x].concat(args2list(arguments))); }, n - 1)); |
1044 | 786 |
}); |
787 |
+ // break; |
|
1045 | 788 |
} |
1046 | 789 |
} |
1047 | 790 |
} |
1048 | 791 |
lib_call.curryfy = curryfy; |
1049 | 792 |
/** |
1050 | 793 |
* @desc adapter for old syntax |
1051 |
- * @author frac |
|
794 |
+ * @author fenris |
|
1052 | 795 |
*/ |
1053 |
- function wait(dependencies, action, parallel) { |
|
1054 |
- if (action === void 0) { action = function () { console.log("all done"); }; } |
|
1055 |
- if (parallel === void 0) { parallel = true; } |
|
1056 |
- var wait = (parallel ? (new lib_call.class_wait_parallel(dependencies, action)) : (new lib_call.class_wait_sequential(dependencies, action))); |
|
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))); |
|
1057 | 798 |
wait.run(); |
1058 | 799 |
} |
1059 | 800 |
lib_call.wait = wait; |
... | ... |
@@ -1066,16 +807,13 @@ var lib_call; |
1066 | 807 |
* @param {function} on_stateChange called before the next function is called |
1067 | 808 |
* @returns {function} |
1068 | 809 |
*/ |
1069 |
- function simple_process(_process, on_stateChange, on_progress) { |
|
1070 |
- if (on_stateChange === void 0) { on_stateChange = function (msg) { console.info("State changed " + msg); }; } |
|
1071 |
- if (on_progress === void 0) { on_progress = function (msg, pos, max) { console.info("Progress '" + msg + "' " + pos + "/" + max); }; } |
|
810 |
+ function simple_process(_process, on_stateChange = function (msg) { lib_log.info("State changed " + msg); }, on_progress = function (msg, pos, max) { lib_log.info("Progress '" + msg + "' " + pos + "/" + max); }) { |
|
1072 | 811 |
var data_hashmap = {}; |
1073 |
- var _orchestrate = function (data, pos) { |
|
1074 |
- if (pos === void 0) { pos = 0; } |
|
812 |
+ var _orchestrate = function (data, pos = 0) { |
|
1075 | 813 |
if (is_def(data)) { |
1076 | 814 |
// data_hashmap[pos] = object_merge_objects({}, data, ["parents", "parent", "children"]); |
1077 | 815 |
data_hashmap[pos] = {}; |
1078 |
- Object.keys(data).filter(function (key) { return (["parents", "parent", "children"].indexOf(key) < 0); }).forEach(function (key) { return (data_hashmap[pos][key] = data[key]); }); |
|
816 |
+ Object.keys(data).filter(key => (["parents", "parent", "children"].indexOf(key) < 0)).forEach(key => (data_hashmap[pos][key] = data[key])); |
|
1079 | 817 |
} |
1080 | 818 |
else { |
1081 | 819 |
if (is_def(data_hashmap[pos]) && is_def(data_hashmap[pos].processed)) { |
... | ... |
@@ -1094,79 +832,87 @@ var lib_call; |
1094 | 832 |
on_stateChange(_process[pos].state); |
1095 | 833 |
} |
1096 | 834 |
return (_func(data, function (processed_data) { |
1097 |
- setTimeout(_orchestrate({ "processed": processed_data }, pos + 1), 0); |
|
835 |
+ timeout(_orchestrate({ "processed": processed_data }, pos + 1), 0); |
|
1098 | 836 |
}, on_progress)); |
1099 | 837 |
} |
1100 | 838 |
else { |
1101 |
- console.error("o.O."); |
|
839 |
+ lib_log.error("o.O."); |
|
1102 | 840 |
} |
1103 | 841 |
}; |
1104 | 842 |
return _orchestrate; |
1105 | 843 |
} |
1106 | 844 |
lib_call.simple_process = simple_process; |
1107 | 845 |
})(lib_call || (lib_call = {})); |
1108 |
-///<reference path="../../base/build/logic.d.ts"/> |
|
846 |
+///<reference path="../../base/build/logic-decl.d.ts"/> |
|
1109 | 847 |
"use strict"; |
1110 | 848 |
var lib_call; |
1111 | 849 |
(function (lib_call) { |
1112 | 850 |
/** |
1113 |
- * @author frac |
|
851 |
+ * @author fenris |
|
1114 | 852 |
*/ |
1115 | 853 |
function executor_resolve(result) { |
1116 |
- return (function (resolve, reject) { return resolve(result); }); |
|
854 |
+ return ((resolve, reject) => resolve(result)); |
|
1117 | 855 |
} |
1118 | 856 |
lib_call.executor_resolve = executor_resolve; |
1119 | 857 |
/** |
1120 |
- * @author frac |
|
858 |
+ * @author fenris |
|
1121 | 859 |
*/ |
1122 | 860 |
function executor_reject(reason) { |
1123 |
- return (function (resolve, reject) { return reject(reason); }); |
|
861 |
+ return ((resolve, reject) => reject(reason)); |
|
1124 | 862 |
} |
1125 | 863 |
lib_call.executor_reject = executor_reject; |
1126 | 864 |
/** |
1127 |
- * @author frac |
|
865 |
+ * @author fenris |
|
1128 | 866 |
*/ |
1129 | 867 |
function executor_transform(executor, transform_result, transform_reason) { |
1130 |
- return (function (resolve, reject) { |
|
1131 |
- executor(function (result) { return resolve(transform_result(result)); }, function (reason) { return reject(transform_reason(reason)); }); |
|
868 |
+ return ((resolve, reject) => { |
|
869 |
+ executor(result => resolve(transform_result(result)), reason => reject(transform_reason(reason))); |
|
1132 | 870 |
}); |
1133 | 871 |
} |
1134 | 872 |
lib_call.executor_transform = executor_transform; |
1135 | 873 |
/** |
1136 |
- * @author frac |
|
874 |
+ * @author fenris |
|
1137 | 875 |
*/ |
1138 |
- function executor_transform_default(executor, transform_result, wrap_string) { |
|
1139 |
- if (wrap_string === void 0) { wrap_string = null; } |
|
1140 |
- var transform_reason = (function (error) { return ((wrap_string == null) ? error : new class_error(wrap_string, [error])); }); |
|
876 |
+ function executor_transform_default(executor, transform_result, wrap_string = null) { |
|
877 |
+ let transform_reason = (error => ((wrap_string == null) ? error : new class_error(wrap_string, [error]))); |
|
1141 | 878 |
return (executor_transform(executor, transform_result, transform_reason)); |
1142 | 879 |
} |
1143 | 880 |
lib_call.executor_transform_default = executor_transform_default; |
1144 | 881 |
/** |
1145 |
- * @author frac |
|
882 |
+ * @author fenris |
|
1146 | 883 |
*/ |
1147 |
- function executor_compose_sequential(first, second, deferred) { |
|
1148 |
- if (deferred === void 0) { deferred = undefined; } |
|
1149 |
- return (function (resolve, reject) { |
|
1150 |
- first(function (result) { |
|
1151 |
- lib_call.schedule(function () { return second(result)(resolve, reject); }, deferred); |
|
1152 |
- }, function (reason) { |
|
884 |
+ function executor_compose_sequential(first, second, deferred = undefined) { |
|
885 |
+ return ((resolve, reject) => { |
|
886 |
+ first(result => { |
|
887 |
+ lib_call.schedule(() => second(result)(resolve, reject), deferred); |
|
888 |
+ }, reason => { |
|
1153 | 889 |
reject(reason); |
1154 | 890 |
}); |
1155 | 891 |
}); |
1156 | 892 |
} |
1157 | 893 |
lib_call.executor_compose_sequential = executor_compose_sequential; |
1158 | 894 |
/** |
1159 |
- * @author frac |
|
895 |
+ * @author fenris |
|
1160 | 896 |
*/ |
1161 |
- function executor_chain(state, executors, deferred) { |
|
1162 |
- if (deferred === void 0) { deferred = lib_call.default_deferred; } |
|
1163 |
- return (function (resolve, reject) { |
|
897 |
+ function executor_chain(state, executors, deferred = lib_call.default_deferred) { |
|
898 |
+ return ((resolve, reject) => { |
|
1164 | 899 |
if (executors.length == 0) { |
1165 | 900 |
return resolve(state); |
1166 | 901 |
} |
1167 | 902 |
else { |
1168 |
- return executors[0](state)(function (result) { |
|
1169 |
- lib_call.schedule(function () { return executor_chain(result, executors.slice(1))(resolve, reject); }); |
|
903 |
+ return executors[0](state)(result => { |
|
904 |
+ /* |
|
905 |
+ schedule( |
|
906 |
+ () => executor_chain(result, executors.slice(1))(resolve, reject) |
|
907 |
+ ); |
|
908 |
+ */ |
|
909 |
+ /* |
|
910 |
+ setTimeout( |
|
911 |
+ () => executor_chain(result, executors.slice(1))(resolve, reject), |
|
912 |
+ 0 |
|
913 |
+ ); |
|
914 |
+ */ |
|
915 |
+ executor_chain(result, executors.slice(1))(resolve, reject); |
|
1170 | 916 |
}, reject); |
1171 | 917 |
} |
1172 | 918 |
}); |
... | ... |
@@ -1201,7 +947,7 @@ var lib_call; |
1201 | 947 |
} |
1202 | 948 |
lib_call.executor_chain = executor_chain; |
1203 | 949 |
/** |
1204 |
- * @author frac |
|
950 |
+ * @author fenris |
|
1205 | 951 |
*/ |
1206 | 952 |
function executor_first(executors) { |
1207 | 953 |
/* |
... | ... |
@@ -1223,50 +969,50 @@ var lib_call; |
1223 | 969 |
} |
1224 | 970 |
); |
1225 | 971 |
*/ |
1226 |
- return (function (resolve, reject) { |
|
1227 |
- executor_chain([], executors.map(function (executor) { return function (reasons) { return function (resolve_, reject_) { |
|
1228 |
- executor(function (result) { return reject_(result); }, function (reason) { return resolve_(reasons.concat([reason])); }); |
|
1229 |
- }; }; }))(function (errors) { return reject(errors); }, function (result) { return resolve(result); }); |
|
972 |
+ return ((resolve, reject) => { |
|
973 |
+ executor_chain([], executors.map(executor => reasons => (resolve_, reject_) => { |
|
974 |
+ executor(result => reject_(result), reason => resolve_(reasons.concat([reason]))); |
|
975 |
+ }))(errors => reject(errors), result => resolve(result)); |
|
1230 | 976 |
}); |
1231 | 977 |
} |
1232 | 978 |
lib_call.executor_first = executor_first; |
1233 | 979 |
/** |
1234 |
- * @author frac |
|
980 |
+ * @author fenris |
|
1235 | 981 |
*/ |
1236 | 982 |
function executor_condense(executors) { |
1237 |
- return (executor_chain([], executors.map(function (executor) { return function (result) { return function (resolve, reject) { |
|
1238 |
- executor(function (element) { return resolve(result.concat([element])); }, reject); |
|
1239 |
- }; }; }))); |
|
983 |
+ return (executor_chain([], executors.map(executor => result => (resolve, reject) => { |
|
984 |
+ executor(element => resolve(result.concat([element])), reject); |
|
985 |
+ }))); |
|
1240 | 986 |
} |
1241 | 987 |
lib_call.executor_condense = executor_condense; |
1242 | 988 |
/** |
1243 |
- * @author frac |
|
989 |
+ * @author fenris |
|
1244 | 990 |
* @deprecated use condense |
1245 | 991 |
*/ |
1246 | 992 |
function executor_filter(executors, predicate) { |
1247 |
- return (executor_chain([], executors.map(function (executor) { return function (result) { return function (resolve, reject) { |
|
1248 |
- executor(function (element) { return resolve(predicate(element) ? result.concat([element]) : result); }, reject); |
|
1249 |
- }; }; }))); |
|
993 |
+ return (executor_chain([], executors.map(executor => result => (resolve, reject) => { |
|
994 |
+ executor(element => resolve(predicate(element) ? result.concat([element]) : result), reject); |
|
995 |
+ }))); |
|
1250 | 996 |
} |
1251 | 997 |
lib_call.executor_filter = executor_filter; |
1252 | 998 |
/** |
1253 |
- * @author frac |
|
999 |
+ * @author fenris |
|
1254 | 1000 |
* @deprecated use condense |
1255 | 1001 |
*/ |
1256 | 1002 |
function executor_map(executors, transformator) { |
1257 |
- return (executor_chain([], executors.map(function (executor) { return function (result) { return function (resolve, reject) { |
|
1258 |
- executor(function (element1) { return resolve(result.concat([transformator(element1)])); }, reject); |
|
1259 |
- }; }; }))); |
|
1003 |
+ return (executor_chain([], executors.map(executor => result => (resolve, reject) => { |
|
1004 |
+ executor(element1 => resolve(result.concat([transformator(element1)])), reject); |
|
1005 |
+ }))); |
|
1260 | 1006 |
} |
1261 | 1007 |
lib_call.executor_map = executor_map; |
1262 | 1008 |
/** |
1263 |
- * @author frac |
|
1009 |
+ * @author fenris |
|
1264 | 1010 |
* @deprecated use condense |
1265 | 1011 |
*/ |
1266 | 1012 |
function executor_reduce(executors, initial, accumulator) { |
1267 |
- return (executor_chain(initial, executors.map(function (executor) { return function (result) { return function (resolve, reject) { |
|
1268 |
- executor(function (element) { return resolve(accumulator(result, element)); }, reject); |
|
1269 |
- }; }; }))); |
|
1013 |
+ return (executor_chain(initial, executors.map(executor => result => (resolve, reject) => { |
|
1014 |
+ executor(element => resolve(accumulator(result, element)), reject); |
|
1015 |
+ }))); |
|
1270 | 1016 |
} |
1271 | 1017 |
lib_call.executor_reduce = executor_reduce; |
1272 | 1018 |
})(lib_call || (lib_call = {})); |
... | ... |
@@ -1301,66 +1047,66 @@ var lib_call; |
1301 | 1047 |
* @author fenris |
1302 | 1048 |
*/ |
1303 | 1049 |
function knot_resolver(output) { |
1304 |
- return (function (input) { return function (resolve, reject) { return resolve(output); }; }); |
|
1050 |
+ return (input => (resolve, reject) => resolve(output)); |
|
1305 | 1051 |
} |
1306 | 1052 |
lib_call.knot_resolver = knot_resolver; |
1307 | 1053 |
/** |
1308 | 1054 |
* @author fenris |
1309 | 1055 |
*/ |
1310 | 1056 |
function knot_id() { |
1311 |
- return (function (input) { return function (resolve, reject) { return resolve(input); }; }); |
|
1057 |
+ return (input => (resolve, reject) => resolve(input)); |
|
1312 | 1058 |
} |
1313 | 1059 |
lib_call.knot_id = knot_id; |
1314 | 1060 |
/** |
1315 | 1061 |
* @author fenris |
1316 | 1062 |
*/ |
1317 | 1063 |
function knot_rejector(error) { |
1318 |
- return (function (input) { return function (resolve, reject) { return reject(error); }; }); |
|
1064 |
+ return (input => (resolve, reject) => reject(error)); |
|
1319 | 1065 |
} |
1320 | 1066 |
lib_call.knot_rejector = knot_rejector; |
1321 | 1067 |
/** |
1322 | 1068 |
* @author fenris |
1323 | 1069 |
*/ |
1324 | 1070 |
function knot_from_function(function_) { |
1325 |
- return (function (input) { return function (resolve, reject) { |
|
1071 |
+ return (input => (resolve, reject) => { |
|
1326 | 1072 |
try { |
1327 |
- var output_1 = function_(input); |
|
1328 |
- resolve(output_1); |
|
1073 |
+ let output = function_(input); |
|
1074 |
+ resolve(output); |
|
1329 | 1075 |
} |
1330 | 1076 |
catch (exception) { |
1331 | 1077 |
reject((exception)); |
1332 | 1078 |
} |
1333 |
- }; }); |
|
1079 |
+ }); |
|
1334 | 1080 |
} |
1335 | 1081 |
lib_call.knot_from_function = knot_from_function; |
1336 | 1082 |
/** |
1337 | 1083 |
* @author fenris |
1338 | 1084 |
*/ |
1339 | 1085 |
function knot_wrap(inner, convert_input, convert_output, convert_error) { |
1340 |
- return (function (input_outer) { return function (resolve, reject) { |
|
1341 |
- var input_inner = convert_input(input_outer); |
|
1342 |
- inner(input_inner)(function (output_inner) { |
|
1343 |
- var output_outer = convert_output(output_inner); |
|
1086 |
+ return (input_outer => (resolve, reject) => { |
|
1087 |
+ let input_inner = convert_input(input_outer); |
|
1088 |
+ inner(input_inner)(output_inner => { |
|
1089 |
+ let output_outer = convert_output(output_inner); |
|
1344 | 1090 |
return resolve(output_outer); |
1345 |
- }, function (error_inner) { |
|
1346 |
- var error_outer = convert_error(error_inner); |
|
1091 |
+ }, error_inner => { |
|
1092 |
+ let error_outer = convert_error(error_inner); |
|
1347 | 1093 |
return reject(error_outer); |
1348 | 1094 |
}); |
1349 |
- }; }); |
|
1095 |
+ }); |
|
1350 | 1096 |
} |
1351 | 1097 |
lib_call.knot_wrap = knot_wrap; |
1352 | 1098 |
/** |
1353 | 1099 |
* @author fenris |
1354 | 1100 |
*/ |
1355 | 1101 |
function knot_wrap_log(inner) { |
1356 |
- return (knot_wrap(inner, function (input) { |
|
1357 |
- console.error("--", "input:", JSON.stringify(input)); |
|
1102 |
+ return (knot_wrap(inner, input => { |
|
1103 |
+ lib_log.error("--", "input:", JSON.stringify(input)); |
|
1358 | 1104 |
return input; |
1359 |
- }, function (output) { |
|
1360 |
- console.error("--", "output:", JSON.stringify(output)); |
|
1105 |
+ }, output => { |
|
1106 |
+ lib_log.error("--", "output:", JSON.stringify(output)); |
|
1361 | 1107 |
return output; |
1362 |
- }, function (error) { |
|
1363 |
- console.error("--", "error:", JSON.stringify(error)); |
|
1108 |
+ }, error => { |
|
1109 |
+ lib_log.error("--", "error:", JSON.stringify(error)); |
|
1364 | 1110 |
return error; |
1365 | 1111 |
})); |
1366 | 1112 |
} |
... | ... |
@@ -1369,23 +1115,47 @@ var lib_call; |
1369 | 1115 |
* @author fenris |
1370 | 1116 |
*/ |
1371 | 1117 |
function knot_compose_sequential(first, second) { |
1372 |
- var second_ = ((knot_loglevel_get() >= 1) |
|
1118 |
+ let second_ = ((knot_loglevel_get() >= 1) |
|
1373 | 1119 |
? knot_wrap_log(second) |
1374 | 1120 |
: second); |
1375 |
- return (function (input) { return function (resolve, reject) { |
|
1376 |
- first(input)(function (between) { return lib_call.schedule(function () { return second_(between)(resolve, reject); }); }, reject); |
|
1377 |
- }; }); |
|
1121 |
+ return (input => (resolve, reject) => { |
|
1122 |
+ first(input)(between => lib_call.schedule(() => second_(between)(resolve, reject)), reject); |
|
1123 |
+ }); |
|
1378 | 1124 |
} |
1379 | 1125 |
lib_call.knot_compose_sequential = knot_compose_sequential; |
1380 | 1126 |
/** |
1381 | 1127 |
* @author fenris |
1382 | 1128 |
*/ |
1383 |
- function knot_chain(knots) { |
|
1384 |
- return (knots.reduce(knot_compose_sequential, knot_id())); |
|
1129 |
+ function knot_chain(knots, logging = false) { |
|
1130 |
+ /* |
|
1131 |
+ return ( |
|
1132 |
+ knots.reduce<type_knot<type_input, type_output, type_error>>( |
|
1133 |
+ knot_compose_sequential, |
|
1134 |
+ knot_id<any, type_error>() |
|
1135 |
+ ) |
|
1136 |
+ ); |
|
1137 |
+ */ |
|
1138 |
+ let knots_ = (logging |
|
1139 |
+ ? knots.map(knot_wrap_log) |
|
1140 |
+ : knots); |
|
1141 |
+ if (knots_.length == 0) { |
|
1142 |
+ return (input => (resolve, reject) => { |
|
1143 |
+ resolve(input); |
|
1144 |
+ }); |
|
1145 |
+ } |
|
1146 |
+ else { |
|
1147 |
+ return (input => (resolve, reject) => { |
|
1148 |
+ return knots_[0](input)(result => { |
|
1149 |
+ return knot_chain(knots_.slice(1), false)(result)(resolve, reject); |
|
1150 |
+ }, error => { |
|
1151 |
+ return reject(error); |
|
1152 |
+ }); |
|
1153 |
+ }); |
|
1154 |
+ } |
|
1385 | 1155 |
} |
1386 | 1156 |
lib_call.knot_chain = knot_chain; |
1387 | 1157 |
/** |
1388 |
- * @author frac |
|
1158 |
+ * @author fenris |
|
1389 | 1159 |
*/ |
1390 | 1160 |
/* |
1391 | 1161 |
export function knot_compose_parallel<>( |
... | ... |
@@ -1406,2003 +1176,3246 @@ var lib_call; |
1406 | 1176 |
* @author fenris |
1407 | 1177 |
*/ |
1408 | 1178 |
function knot_bunch(knots) { |
1409 |
- return (function (input) { return function (resolve, reject) { |
|
1410 |
- var done = false; |
|
1411 |
- var master_output = {}; |
|
1412 |
- var ready = {}; |
|
1413 |
- var master_resolve = function (id, output) { |
|
1179 |
+ return (input => (resolve, reject) => { |
|
1180 |
+ let done = false; |
|
1181 |
+ let master_output = {}; |
|
1182 |
+ let ready = {}; |
|
1183 |
+ let master_resolve = (id, output) => { |
|
1414 | 1184 |
if (!done) { |
1415 | 1185 |
master_output[id] = output; |
1416 | 1186 |
ready[id] = true; |
1417 |
- if (Object.keys(knots).every(function (id) { return (id in ready); })) { |
|
1187 |
+ if (Object.keys(knots).every(id => (id in ready))) { |
|
1418 | 1188 |
done = true; |
1419 | 1189 |
resolve(master_output); |
1420 | 1190 |
} |
1421 | 1191 |
else { |
1192 |
+ // nothing to do |
|
1422 | 1193 |
} |
1423 | 1194 |
} |
1424 | 1195 |
else { |
1196 |
+ // nothing to do |
|
1425 | 1197 |
} |
1426 | 1198 |
}; |
1427 |
- var master_reject = function (id, error) { |
|
1199 |
+ let master_reject = (id, error) => { |
|
1428 | 1200 |
if (!done) { |
1429 | 1201 |
done = true; |
1430 | 1202 |
reject(error); |
1431 | 1203 |
} |
1432 | 1204 |
else { |
1205 |
+ // nothing to do |
|
1433 | 1206 |
} |
1434 | 1207 |
}; |
1435 |
- Object.keys(knots).forEach(function (id) { |
|
1436 |
- knots[id](input)(function (output) { return master_resolve(id, output); }, function (error) { return master_reject(id, error); }); |
|
1208 |
+ Object.keys(knots).forEach(id => { |
|
1209 |
+ knots[id](input)(output => master_resolve(id, output), error => master_reject(id, error)); |
|
1210 |
+ }); |
|
1437 | 1211 |
}); |
1438 |
- }; }); |
|
1439 | 1212 |
} |
1440 | 1213 |
lib_call.knot_bunch = knot_bunch; |
1441 | 1214 |
/** |
1442 |
- * @author frac |
|
1215 |
+ * @author fenris |
|
1443 | 1216 |
*/ |
1444 | 1217 |
function knot_condense(knots) { |
1445 |
- return (function (input) { return knot_chain(knots.map(function (knot) { return function (list) { return function (resolve, reject) { |
|
1446 |
- knot(input)(function (element) { return resolve(list.concat([element])); }, reject); |
|
1447 |
- }; }; }))([]); }); |
|
1218 |
+ /* |
|
1219 |
+ return ( |
|
1220 |
+ input => knot_chain<Array<type_output>, Array<type_output>, type_error>( |
|
1221 |
+ knots.map<type_knot<Array<type_output>, Array<type_output>, type_error>>( |
|
1222 |
+ knot => list => (resolve, reject) => { |
|
1223 |
+ knot(input)( |
|
1224 |
+ element => resolve(list.concat([element])), |
|
1225 |
+ reject |
|
1226 |
+ ); |
|
1227 |
+ } |
|
1228 |
+ ) |
|
1229 |
+ )([]) |
|
1230 |
+ ); |
|
1231 |
+ */ |
|
1232 |
+ if (knots.length == 0) { |
|
1233 |
+ return (input => (resolve, reject) => { |
|
1234 |
+ resolve([]); |
|
1235 |
+ }); |
|
1236 |
+ } |
|
1237 |
+ else { |
|
1238 |
+ return (input => (resolve, reject) => { |
|
1239 |
+ knots[0](input)(element => { |
|
1240 |
+ knot_condense(knots.slice(1))(input)(restlist => { |
|
1241 |
+ resolve([element].concat(restlist)); |
|
1242 |
+ }, reject); |
|
1243 |
+ }, error => { |
|
1244 |
+ reject(error); |
|
1245 |
+ }); |
|
1246 |
+ }); |
|
1247 |
+ } |
|
1448 | 1248 |
} |
1449 | 1249 |
lib_call.knot_condense = knot_condense; |
1450 |
-})(lib_call || (lib_call = {})); |
|
1451 |
-var lib_meta; |
|
1452 |
-(function (lib_meta) { |
|
1453 | 1250 |
/** |
1454 |
- * @author frac |
|
1251 |
+ * @author fenris |
|
1455 | 1252 |
*/ |
1456 |
- function type_toString(type) { |
|
1457 |
- return ("<" + type.id + ">"); |
|
1253 |
+ function knot_first(knots) { |
|
1254 |
+ return (input => (resolve, reject) => { |
|
1255 |
+ knot_condense(knots.map(knot => input_ => (resolve_, reject_) => knot(input)(reject_, resolve_)))(input)(reject, resolve); |
|
1256 |
+ }); |
|
1458 | 1257 |
} |
1459 |
- lib_meta.type_toString = type_toString; |
|
1258 |
+ lib_call.knot_first = knot_first; |
|
1460 | 1259 |
/** |
1461 |
- * @author frac |
|
1260 |
+ * @author fenris |
|
1462 | 1261 |
*/ |
1463 |
- var class_pool = {}; |
|
1262 |
+ function knot_repeat(knot, attempts = 5, delay = (attempt => 250)) { |
|
1263 |
+ let seq = (n => ((n == 0) ? [] : seq(n - 1).concat([n - 1]))); |
|
1264 |
+ return (knot_first(seq(attempts).map((_, attempt) => input => (resolve, reject) => knot(input)(resolve, error => { |
|
1265 |
+ setTimeout(() => reject(error), delay(attempt)); |
|
1266 |
+ })))); |
|
1267 |
+ } |
|
1268 |
+ lib_call.knot_repeat = knot_repeat; |
|
1464 | 1269 |
/** |
1465 |
- * @author frac |
|
1270 |
+ * @desc useful for e.g. asynchronous singletons |
|
1271 |
+ * @author fenris |
|
1466 | 1272 |
*/ |
1467 |
- function class_set(name, class_) { |
|
1468 |
- class_pool[name] = class_; |
|
1469 |
- } |
|
1470 |
- lib_meta.class_set = class_set; |
|
1273 |
+ class class_knot_initializer { |
|
1471 | 1274 |
/** |
1472 |
- * @author frac |
|
1275 |
+ * @author fenris |
|
1473 | 1276 |
*/ |
1474 |
- function class_get(name) { |
|
1475 |
- if (name in class_pool) { |
|
1476 |
- return class_pool[name]; |
|
1477 |
- } |
|
1478 |
- else { |
|
1479 |
- throw (new Error("no class registered for name '" + name + "'")); |
|
1480 |
- } |
|
1481 |
- } |
|
1482 |
- lib_meta.class_get = class_get; |
|
1277 |
+ constructor(fetcher) { |
|
1483 | 1278 |
/** |
1484 |
- * @author frac |
|
1279 |
+ * @author fenris |
|
1280 |
+ * 0 : initial |
|
1281 |
+ * 1 : waiting |
|
1282 |
+ * 2 : done, successful |
|
1283 |
+ * 3 : done, failed |
|
1485 | 1284 |
*/ |
1486 |
- function transform_field(name, attributes) { |
|
1487 |
- var type = attributes["type"]; |
|
1488 |
- var path = name; |
|
1489 |
- var label = ((attributes["title"] != undefined) ? attributes["title"] : name); |
|
1490 |
- var display = ((attributes["display"] != undefined) ? attributes["display"] : true); |
|
1491 |
- return ({ |
|
1492 |
- "path": path, |
|
1493 |
- "type": type, |
|
1494 |
- "label": label, |
|
1495 |
- "display": display |
|
1496 |
- }); |
|
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; |
|
1497 | 1299 |
} |
1498 |
- lib_meta.transform_field = transform_field; |
|
1499 | 1300 |
/** |
1500 |
- * @author frac |
|
1301 |
+ * @author fenris |
|
1501 | 1302 |
*/ |
1502 |
- function transform_description(label, description, groups_raw) { |
|
1503 |
- if (groups_raw === void 0) { groups_raw = null; } |
|
1504 |
- var fieldmap; |
|
1505 |
- var fields = Object.keys(description).map(function (key) { return transform_field(key, description[key]); }); |
|
1506 |
- var groups = ((groups_raw == null) |
|
1507 |
- ? |
|
1508 |
- null |
|
1509 |
- : |
|
1510 |
- groups_raw.map(function (group_raw) { |
|
1511 |
- return { |
|
1512 |
- "label": group_raw["label"], |
|
1513 |
- "fields": group_raw["fields"].map(function (field_name) { |
|
1514 |
- var index = fields["findIndex"](function (field) { return (field.path == field_name); }); |
|
1515 |
- if (index < 0) { |
|
1516 |
- throw (new Error("field " + field_name + " not found in model-description")); |
|
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 |
+ } |
|
1517 | 1317 |
} |
1518 |
- return index; |
|
1519 |
- }) |
|
1520 |
- }; |
|
1521 |
- })); |
|
1522 |
- return { |
|
1523 |
- "fields": fields, |
|
1524 |
- "description": null, |
|
1525 |
- "title": label, |
|
1526 |
- "groups": groups |
|
1527 |
- }; |
|
1528 | 1318 |
} |
1529 |
- lib_meta.transform_description = transform_description; |
|
1530 | 1319 |
/** |
1531 |
- * @author frac |
|
1320 |
+ * @author fenris |
|
1532 | 1321 |
*/ |
1533 |
- function transform_description_groups(label, description_model, description_groups) { |
|
1534 |
- return ({ |
|
1535 |
- "label": label, |
|
1536 |
- "groups": description_groups.map(function (group_raw) { |
|
1537 |
- return { |
|
1538 |
- "label": group_raw["label"], |
|
1539 |
- "fields": group_raw["fields"].map(function (path) { |
|
1540 |
- var field_raw = description_model[path]; |
|
1541 |
- return transform_field(path, field_raw); |
|
1542 |
- }) |
|
1543 |
- }; |
|
1544 |
- }) |
|
1545 |
- }); |
|
1322 |
+ reset() { |
|
1323 |
+ this.state = 0; |
|
1324 |
+ this.queue = []; |
|
1546 | 1325 |
} |
1547 |
- lib_meta.transform_description_groups = transform_description_groups; |
|
1548 |
-})(lib_meta || (lib_meta = {})); |
|
1549 |
-var plain_text_to_html = function (text) { |
|
1550 |
- var ret = text; |
|
1551 |
- ret = ret.replace(/ /g, " "); // convert multiple whitespace to forced ones |
|
1552 |
- ret = ret.split("\n").join("<br/>"); |
|
1553 |
- return ret; |
|
1554 |
-}; |
|
1555 | 1326 |
/** |
1556 |
- * @desc makes a valid |
|
1327 |
+ * @author fenris |
|
1557 | 1328 |
*/ |
1558 |
-var format_sentence = function (str, rtl, caseSense) { |
|
1559 |
- if (rtl === void 0) { rtl = false; } |
|
1560 |
- if (caseSense === void 0) { caseSense = true; } |
|
1561 |
- if (str === "") { |
|
1562 |
- return str; |
|
1329 |
+ 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; |
|
1563 | 1346 |
} |
1564 |
- else { |
|
1565 |
- var marks = { |
|
1566 |
- ".": true, |
|
1567 |
- "?": true, |
|
1568 |
- "!": true |
|
1569 |
- }; |
|
1570 |
- var default_mark = "."; |
|
1571 |
- var ret = str.split(""); |
|
1572 |
- if (!rtl) { |
|
1573 |
- ret[0] = ret[0].toLocaleUpperCase(); |
|
1574 |
- if (!(ret[ret.length - 1] in marks)) { |
|
1575 |
- ret.push(default_mark); |
|
1347 |
+ case 1: { |
|
1348 |
+ return (_ => (resolve, reject) => this.queue.push({ "resolve": resolve, "reject": reject })); |
|
1349 |
+ break; |
|
1576 | 1350 |
} |
1351 |
+ case 2: { |
|
1352 |
+ return knot_resolver(this.output); |
|
1353 |
+ break; |
|
1577 | 1354 |
} |
1578 |
- else { |
|
1579 |
- ret[ret.length - 1] = ret[ret.length - 1].toLocaleUpperCase(); |
|
1580 |
- if (!(ret[0] in marks)) { |
|
1581 |
- ret.unshift(default_mark); |
|
1355 |
+ case 3: { |
|
1356 |
+ return knot_rejector(this.error); |
|
1357 |
+ break; |
|
1582 | 1358 |
} |
1359 |
+ default: { |
|
1360 |
+ throw (new Error(`unhandled state ${this.state}`)); |
|
1361 |
+ break; |
|
1583 | 1362 |
} |
1584 |
- return ret.join(""); |
|
1585 | 1363 |
} |
1586 |
-}; |
|
1587 |
-var fill_string_template = function (template_string, object, fabric, delimiter, default_string) { |
|
1588 |
- if (fabric === void 0) { fabric = function (object, key) { return object[key]; }; } |
|
1589 |
- if (delimiter === void 0) { delimiter = "%"; } |
|
1590 |
- if (default_string === void 0) { default_string = null; } |
|
1591 |
- function get_tags(str) { |
|
1592 |
- var r = new RegExp(delimiter + "[^\\s^" + delimiter + "]+" + delimiter, "gi"); |
|
1593 |
- return ((str.match(r) || []).map(function (e) { |
|
1594 |
- return e.slice(delimiter.length, e.length - delimiter.length); |
|
1595 |
- })); |
|
1596 | 1364 |
} |
1597 |
- function replace_tag(str, tag, value) { |
|
1598 |
- var r = new RegExp(delimiter + tag + delimiter, "gi"); |
|
1599 |
- return str.replace(r, value); |
|
1600 | 1365 |
} |
1601 |
- function replace_tags(str, obj) { |
|
1602 |
- return (get_tags(str).reduce(function (ret, key) { |
|
1603 |
- var value = ""; |
|
1604 |
- try { |
|
1605 |
- value = fabric(obj, key); |
|
1606 |
- if (value === void 0) { |
|
1607 |
- value = default_string; |
|
1366 |
+ lib_call.class_knot_initializer = class_knot_initializer; |
|
1367 |
+})(lib_call || (lib_call = {})); |
|
1368 |
+var lib_call; |
|
1369 |
+(function (lib_call) { |
|
1370 |
+ /** |
|
1371 |
+ * @author fenris |
|
1372 |
+ */ |
|
1373 |
+ function promise_reject(reason) { |
|
1374 |
+ return Promise.reject(reason); |
|
1608 | 1375 |
} |
1376 |
+ lib_call.promise_reject = promise_reject; |
|
1377 |
+ /** |
|
1378 |
+ * @author fenris |
|
1379 |
+ */ |
|
1380 |
+ function promise_resolve(result) { |
|
1381 |
+ return Promise.resolve(result); |
|
1609 | 1382 |
} |
1610 |
- catch (e) { |
|
1611 |
- console.warn("invalid placeholder " + key); |
|
1612 |
- value = default_string; |
|
1383 |
+ lib_call.promise_resolve = promise_resolve; |
|
1384 |
+ /** |
|
1385 |
+ * @author fenris |
|
1386 |
+ */ |
|
1387 |
+ function promise_make(executor) { |
|
1388 |
+ return (new Promise(executor)); |
|
1613 | 1389 |
} |
1614 |
- return replace_tag(ret, key, value); |
|
1615 |
- }, str)); |
|
1390 |
+ lib_call.promise_make = promise_make; |
|
1391 |
+ /** |
|
1392 |
+ * @author fenris |
|
1393 |
+ */ |
|
1394 |
+ function promise_all(promises) { |
|
1395 |
+ return Promise.all(promises); |
|
1616 | 1396 |
} |
1617 |
- return replace_tags(template_string, object); |
|
1618 |
-}; |
|
1619 |
-var make_string_template = function (_template, _fabrics) { |
|
1620 |
- if (_fabrics === void 0) { _fabrics = {}; } |
|
1621 |
- function replace_tag(str, tag, value) { |
|
1622 |
- var r = new RegExp("%" + tag + "%", "gi"); |
|
1623 |
- return str.replace(r, value); |
|
1397 |
+ lib_call.promise_all = promise_all; |
|
1398 |
+})(lib_call || (lib_call = {})); |
|
1399 |
+ |
|
1400 |
+(function (exports) { |
|
1401 |
+ |
|
1402 |
+ /** |
|
1403 |
+ * @author fenris |
|
1404 |
+ */ |
|
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 |
+ ); |
|
1624 | 1414 |
} |
1625 |
- function replace_tags(str, obj) { |
|
1626 |
- return (Object.keys(obj).reduce(function (ret, key) { |
|
1627 |
- return replace_tag(ret, key, _fabrics[key] || obj[key]); |
|
1628 |
- }, str)); |
|
1415 |
+ exports.promise_chain = promise_chain; |
|
1416 |
+ |
|
1417 |
+ |
|
1418 |
+ /** |
|
1419 |
+ * @author fenris |
|
1420 |
+ */ |
|
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 |
+ ) |
|
1629 | 1433 |
} |
1630 |
- return (function (tags) { |
|
1631 |
- return replace_tags(_template, tags); |
|
1632 |
- }); |
|
1633 |
-}; |
|
1634 |
-var make_eml_header = (function () { |
|
1635 |
- var _template = ""; |
|
1636 |
- _template += "From: %from%\n"; |
|
1637 |
- _template += "To: %recipient%\n"; |
|
1638 |
- _template += "Subject: %subject%\n"; |
|
1639 |
- _template += "X-Mailer: greenscale-plankton.emlgen\n"; |
|
1640 |
- return make_string_template(_template); |
|
1641 |
-})(); |
|
1642 |
-var make_eml_body = (function () { |
|
1643 |
- var exports = {}; |
|
1644 |
- exports["simple_body"] = make_string_template("Content-Type: %contenttype%\n\n%body%\n\n"); |
|
1645 |
- // very basic implementation |
|
1646 |
- // parts = [{contenttype:"text/html; charset=UTF-8", body: "<h1>foo</h1>" }, {...}] |
|
1647 |
- exports["body_boundrary"] = function (parts, boundrary) { |
|
1648 |
- var _template = ""; |
|
1649 |
- _template += "--%boundrary%\n"; |
|
1650 |
- _template += "Content-Type: %contenttype%\n\n%body%\n\n"; |
|
1651 |
- //_template += "--%boundrary%--\n\n"; |
|
1652 |
- var maker = make_string_template(_template); |
|
1653 |
- return (parts.reduce(function (prev, curr) { |
|
1654 |
- curr.boundrary = boundrary; |
|
1655 |
- return [prev, maker(curr)].join(""); |
|
1656 |
- }, "")); |
|
1657 |
- }; |
|
1658 |
- // body must be base64 encoded! |
|
1659 |
- exports["attachment_boundrary"] = function (parts, boundrary) { |
|
1660 |
- var _template = ""; |
|
1661 |
- _template += "--%boundrary%\n"; |
|
1662 |
- _template += "Content-Type: %contenttype%\n"; |
|
1663 |
- _template += "Content-Transfer-Encoding: base64\n"; |
|
1664 |
- _template += "Content-Disposition: %disposition%; filename=\"%name%\"\n\n"; |
|
1665 |
- _template += "%body%\n\n"; |
|
1666 |
- //_template += "--%boundrary%--\n\n"; |
|
1667 |
- var maker = make_string_template(_template); |
|
1668 |
- return (parts.reduce(function (prev, curr) { |
|
1669 |
- curr.boundrary = boundrary; |
|
1670 |
- if (curr.disposition === void 0) |
|
1671 |
- curr.disposition = "inline"; |
|
1672 |
- return [prev, maker(curr)].join(""); |
|
1673 |
- }, "")); |
|
1674 |
- }; |
|
1675 |
- exports["gen_boundrary"] = function () { |
|
1676 |
- return ("xxxxxxxxxxxxxxxxxxxxxx".replace(/[xy]/g, function (c) { |
|
1677 |
- var r = crypto.getRandomValues(new Uint8Array(1))[0] % 16 | 0, v = c == "x" ? r : (r & 0x3 | 0x8); |
|
1678 |
- return v.toString(16); |
|
1679 |
- })); |
|
1680 |
- }; |
|
1681 |
- // simple implementation without alternatives (old rfc) |
|
1682 |
- exports["complete_boundrary"] = function (bodyparts, attachments) { |
|
1683 |
- var ret = ""; |
|
1684 |
- var boundrary = exports["gen_boundrary"](); |
|
1685 |
- ret += exports["body_boundrary"](bodyparts, boundrary); |
|
1686 |
- ret += exports["attachment_boundrary"](attachments, boundrary); |
|
1687 |
- ret += "--" + boundrary + "--\n\nINVISIBLE!!!!"; |
|
1688 |
- return (exports["simple_body"]({ |
|
1689 |
- "contenttype": sprintf("multipart/mixed; boundary=%s", [boundrary]), |
|
1690 |
- "body": ret |
|
1691 |
- })); |
|
1692 |
- }; |
|
1693 |
- return exports; |
|
1694 |
-})(); |
|
1695 |
-///<reference path="../../base/build/logic.d.ts"/> |
|
1696 |
-var lib_string; |
|
1697 |
-(function (lib_string) { |
|
1698 |
- /** |
|
1699 |
- * @author frac |
|
1700 |
- */ |
|
1701 |
- var hexdigits = 4; |
|
1702 |
- /** |
|
1703 |
- * @author frac |
|
1704 |
- */ |
|
1705 |
- var index_max = 1 << (4 * hexdigits); |
|
1434 |
+ ) |
|
1435 |
+ ); |
|
1436 |
+ } |
|
1437 |
+ exports.promise_wrap = promise_wrap; |
|
1438 |
+ |
|
1439 |
+ |
|
1706 | 1440 |
/** |
1707 |
- * @author frac |
|
1441 |
+ * @author fenris |
|
1708 | 1442 |
*/ |
1709 |
- var index_is = 0; |
|
1443 |
+ function promise_log(state) { |
|
1444 |
+ return ( |
|
1445 |
+ new Promise( |
|
1446 |
+ (resolve, reject) => { |
|
1447 |
+ lib_log.info(state); |
|
1448 |
+ resolve(state); |
|
1449 |
+ } |
|
1450 |
+ ) |
|
1451 |
+ ); |
|
1452 |
+ } |
|
1453 |
+ exports.promise_log = promise_log; |
|
1454 |
+ |
|
1455 |
+ |
|
1710 | 1456 |
/** |
1711 |
- * @author neuc,frac |
|
1457 |
+ * @author fenris |
|
1712 | 1458 |
*/ |
1713 |
- function empty(str) { |
|
1714 |
- var tmp = str.trim(); |
|
1715 |
- return (tmp === ""); |
|
1459 |
+ function promise_attach( |
|
1460 |
+ state, |
|
1461 |
+ promise, |
|
1462 |
+ name |
|
1463 |
+ ) { |
|
1464 |
+ return ( |
|
1465 |
+ promise_wrap( |
|
1466 |
+ promise, |
|
1467 |
+ result => { |
|
1468 |
+ state[name] = result; |
|
1469 |
+ return state; |
|
1716 | 1470 |
} |
1717 |
- lib_string.empty = empty; |
|
1471 |
+ ) |
|
1472 |
+ ); |
|
1473 |
+ } |
|
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) { |
|
1718 | 1481 |
/** |
1719 |
- * @desc returns a unique string |
|
1720 |
- * @param {string} prefix an optional prefix for the generated string |
|
1721 |
- * @return {string} |
|
1722 |
- * @author frac |
|
1482 |
+ * @author fenris |
|
1723 | 1483 |
*/ |
1724 |
- function generate(prefix) { |
|
1725 |
- if (prefix === void 0) { prefix = "string_"; } |
|
1726 |
- if (index_is > index_max) { |
|
1727 |
- throw (new Error("[string_generate] out of valid indices")); |
|
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]; |
|
1728 | 1489 |
} |
1729 | 1490 |
else { |
1730 |
- return lib_string.sprintf(prefix + "%0" + hexdigits.toString() + "X", [index_is++]); |
|
1491 |
+ switch (escalation) { |
|
1492 |
+ case 0: { |
|
1493 |
+ return fallback; |
|
1494 |
+ break; |
|
1731 | 1495 |
} |
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 |
+ break; |
|
1732 | 1502 |
} |
1733 |
- lib_string.generate = generate; |
|
1503 |
+ case 2: { |
|
1504 |
+ var message = ("field '" + fieldname + "' not in structure"); |
|
1505 |
+ throw (new Error(message)); |
|
1506 |
+ break; |
|
1507 |
+ } |
|
1508 |
+ default: { |
|
1509 |
+ throw (new Error("invalid escalation level " + escalation)); |
|
1510 |
+ break; |
|
1511 |
+ } |
|
1512 |
+ } |
|
1513 |
+ } |
|
1514 |
+ } |
|
1515 |
+ lib_object.fetch = fetch; |
|
1734 | 1516 |
/** |
1735 |
- * @desc splits a string, but returns an empty list, if the string is empty |
|
1736 |
- * @param {string} chain |
|
1737 |
- * @param {string} separator |
|
1738 |
- * @return {Array<string>} |
|
1739 |
- * @author frac |
|
1517 |
+ * @author fenris |
|
1740 | 1518 |
*/ |
1741 |
- function split(chain, separator) { |
|
1742 |
- if (separator === void 0) { separator = " "; } |
|
1743 |
- if (chain.length == 0) { |
|
1744 |
- return []; |
|
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; |
|
1745 | 1523 |
} |
1746 |
- else { |
|
1747 |
- return chain.split(separator); |
|
1524 |
+ lib_object.map = map; |
|
1525 |
+ /** |
|
1526 |
+ * @author fenris |
|
1527 |
+ */ |
|
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; |
|
1748 | 1534 |
} |
1535 |
+ }); |
|
1536 |
+ return object_to; |
|
1749 | 1537 |
} |
1750 |
- lib_string.split = split; |
|
1538 |
+ lib_object.filter = filter; |
|
1751 | 1539 |
/** |
1752 |
- * @desc concats a given word with itself n times |
|
1753 |
- * @param {string} word |
|
1754 |
- * @param {int} |
|
1755 |
- * @return {string} |
|
1756 |
- * @author frac |
|
1540 |
+ * @author fenris |
|
1757 | 1541 |
*/ |
1758 |
- function repeat(word, count) { |
|
1759 |
- return ((count == 0) ? "" : (word + repeat(word, count - 1))); |
|
1542 |
+ function from_array(array) { |
|
1543 |
+ var object = {}; |
|
1544 |
+ array.forEach(function (entry) { return (object[entry.key] = entry.value); }); |
|
1545 |
+ return object; |
|
1760 | 1546 |
} |
1761 |
- lib_string.repeat = repeat; |
|
1547 |
+ lib_object.from_array = from_array; |
|
1762 | 1548 |
/** |
1763 |
- * @desc lengthens a string by repeatedly appending or prepending another string |
|
1764 |
- * @param {string} word the string to pad |
|
1765 |
- * @param {int} length the length, which the result shall have |
|
1766 |
- * @param {string} symbol the string, which will be added (multiple times) |
|
1767 |
- * @param {boolean} [prepend]; whether to prepend (~true) or append (~false); default: false |
|
1768 |
- * @return {string} the padded string |
|
1769 |
- * @author frac |
|
1549 |
+ * @author fenris |
|
1770 | 1550 |
*/ |
1771 |
- function pad(word, length, symbol, prepend) { |
|
1772 |
- if (prepend === void 0) { prepend = false; } |
|
1773 |
- if (prepend) { |
|
1774 |
- while (word.length < length) |
|
1775 |
- word = symbol + word; |
|
1776 |
- return word.substring(word.length - length); |
|
1777 |
- } |
|
1778 |
- else { |
|
1779 |
- while (word.length < length) |
|
1780 |
- word = word + symbol; |
|
1781 |
- return word.substring(0, length); |
|
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; |
|
1782 | 1555 |
} |
1556 |
+ lib_object.to_array = to_array; |
|
1557 |
+ /** |
|
1558 |
+ * @author fenris |
|
1559 |
+ */ |
|
1560 |
+ function keys(object) { |
|
1561 |
+ return Object.keys(object); |
|
1783 | 1562 |
} |
1784 |
- lib_string.pad = pad; |
|
1563 |
+ lib_object.keys = keys; |
|
1785 | 1564 |
/** |
1786 |
- * @desc checks if a given string conttains a certain substring |
|
1787 |
- * @param {string} string |
|
1788 |
- * @param {string} part |
|
1789 |
- * @return {boolean} |
|
1790 |
- * @author frac |
|
1565 |
+ * @author fenris |
|
1791 | 1566 |
*/ |
1792 |
- function contains(chain, part) { |
|
1793 |
- if (typeof (chain) !== "string") |
|
1794 |
- return false; |
|
1795 |
- return (chain.indexOf(part) >= 0); |
|
1567 |
+ function values(object) { |
|
1568 |
+ return to_array(object).map(function (entry) { return entry.value; }); |
|
1796 | 1569 |
} |
1797 |
- lib_string.contains = contains; |
|
1570 |
+ lib_object.values = values; |
|
1798 | 1571 |
/** |
1799 |
- * @desc checks if a given string starts with a certain substring |
|
1800 |
- * @param {string} string |
|
1801 |
- * @param {string} part |
|
1802 |
- * @return {boolean} |
|
1803 |
- * @author frac |
|
1572 |
+ * @author fenris |
|
1804 | 1573 |
*/ |
1805 |
- function startsWith(chain, part) { |
|
1806 |
- if (typeof (chain) !== "string") |
|
1807 |
- return false; |
|
1808 |
- // return (string.indexOf(part) === 0); |
|
1809 |
- return ((function (m, n) { |
|
1810 |
- if (n == 0) { |
|
1811 |
- return true; |
|
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")); |
|
1812 | 1580 |
} |
1813 | 1581 |
else { |
1814 |
- if (m == 0) { |
|
1815 |
- return false; |
|
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); |
|
1816 | 1589 |
} |
1817 | 1590 |
else { |
1818 |
- return ((chain[0] == part[0]) && startsWith(chain.substring(1), part.substring(1))); |
|
1591 |
+ return object_fetch({}, "_dummy_", fallback, escalation); |
|
1819 | 1592 |
} |
1820 | 1593 |
} |
1821 |
- })(chain.length, part.length)); |
|
1822 | 1594 |
} |
1823 |
- lib_string.startsWith = startsWith; |
|
1595 |
+ lib_object.path_read = path_read; |
|
1824 | 1596 |
/** |
1825 |
- * @desc checks if a given string ends with a certain substring |
|
1826 |
- * @param {string} string |
|
1827 |
- * @param {string} part |
|
1828 |
- * @return {boolean} |
|
1829 |
- * @author frac |
|
1597 |
+ * @author fenris |
|
1830 | 1598 |
*/ |
1831 |
- function endsWith(chain, part) { |
|
1832 |
- if (typeof (chain) !== "string") |
|
1833 |
- return false; |
|
1834 |
- // return (string.lastIndexOf(part) === string.length-part.length); |
|
1835 |
- return ((function (m, n) { |
|
1836 |
- if (n == 0) { |
|
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")); |
|
1604 |
+ } |
|
1605 |
+ 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]; |
|
1837 | 1613 |
return true; |
1838 | 1614 |
} |
1839 | 1615 |
else { |
1840 |
- if (m == 0) { |
|
1841 | 1616 |
return false; |
1842 | 1617 |
} |
1618 |
+ } |
|
1843 | 1619 |
else { |
1844 |
- // console.info(("(" + string[m-1] + " == " + part[n-1] + ")") + " = " + String(string[m-1] == part[n-1])); |
|
1845 |
- return ((chain[m - 1] == part[n - 1]) && endsWith(chain.substring(0, m - 1), part.substring(0, n - 1))); |
|
1620 |
+ position_2 = position_; |
|
1621 |
+ return true; |
|
1846 | 1622 |
} |
1623 |
+ }); |
|
1624 |
+ if (reachable) { |
|
1625 |
+ position_2[steps[steps.length - 1]] = value; |
|
1847 | 1626 |
} |
1848 |
- })(chain.length, part.length)); |
|
1627 |
+ else { |
|
1628 |
+ throw (new Error("path " + path + " does not exist and may not be constructed")); |
|
1849 | 1629 |
} |
1850 |
- lib_string.endsWith = endsWith; |
|
1630 |
+ } |
|
1631 |
+ } |
|
1632 |
+ lib_object.path_write = path_write; |
|
1851 | 1633 |
/** |
1852 |
- * @desc count the occourrences of a string in a string |
|
1853 |
- * @param string haystack_string the string wich should be examined |
|
1854 |
- * @param string needle_string the string which should be counted |
|
1855 |
- * @author neuc |
|
1634 |
+ * @author fenris |
|
1856 | 1635 |
*/ |
1857 |
- function count_occourrences(haystack_string, needle_string, check_escape) { |
|
1858 |
- var cnt = 0; |
|
1859 |
- var pos = -1; |
|
1860 |
- do { |
|
1861 |
- pos = haystack_string.indexOf(needle_string, pos + 1); |
|
1862 |
- if ((!check_escape) || (haystack_string[pos - 1] != "\\")) { |
|
1863 |
- cnt++; |
|
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]); }); |
|
1864 | 1639 |
} |
1865 |
- } while (pos >= 0); |
|
1866 |
- return cnt - 1; |
|
1867 |
- } |
|
1868 |
- lib_string.count_occourrences = count_occourrences; |
|
1869 |
- ; |
|
1870 |
-})(lib_string || (lib_string = {})); |
|
1640 |
+ lib_object.matches = matches; |
|
1871 | 1641 |
/** |
1872 |
- * @desc adapters for old syntax |
|
1642 |
+ * @author fenris |
|
1873 | 1643 |
*/ |
1874 |
-var string_generate = lib_string.generate; |
|
1875 |
-var string_split = lib_string.split; |
|
1876 |
-var string_repeat = lib_string.repeat; |
|
1877 |
-var string_pad = lib_string.pad; |
|
1878 |
-var string_contains = lib_string.contains; |
|
1879 |
-var string_startsWith = lib_string.startsWith; |
|
1880 |
-var string_endsWith = lib_string.endsWith; |
|
1881 |
-var string_count_occourrences = lib_string.count_occourrences; |
|
1882 |
-var lib_string; |
|
1883 |
-(function (lib_string) { |
|
1884 |
- var pattern = /%([-+#0 ]*)([0-9]*)[\.]{0,1}([0-9]*)([\w]{1})/; |
|
1885 |
- var gpattern = /%([-+#0 ]*)([0-9]*)[\.]{0,1}([0-9]*)([\w]{1})/g; |
|
1886 |
- function split_format(format) { |
|
1887 |
- var tmp = format.match(pattern); |
|
1888 |
- if (tmp === null) |
|
1889 |
- return null; |
|
1890 |
- return { |
|
1891 |
- 'flags': tmp[1].split(""), |
|
1892 |
- 'width': Number(tmp[2]), |
|
1893 |
- 'precision': tmp[3] === '' ? null : Number(tmp[3]), |
|
1894 |
- 'specifier': tmp[4], |
|
1895 |
- 'string': format |
|
1896 |
- }; |
|
1644 |
+ function flatten(value) { |
|
1645 |
+ var integrate = function (result, key_, value_) { |
|
1646 |
+ if (value_ == null) { |
|
1647 |
+ result[key_] = value_; |
|
1897 | 1648 |
} |
1898 |
- function make_err(format, arg, should) { |
|
1899 |
- return ("[sprintf]" + " " + "argument for '" + format.string + "' has to be '" + should + "' but '" + arg + "' is '" + typeof arg + "'!"); |
|
1649 |
+ else { |
|
1650 |
+ if (typeof (value_) != "object") { |
|
1651 |
+ result[key_] = value_; |
|
1900 | 1652 |
} |
1901 |
- function test_arg(format, arg, should) { |
|
1902 |
- if (typeof arg !== should) { |
|
1903 |
- console.warn(make_err(format, arg, should)); |
|
1904 |
- return false; |
|
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 |
+ }); |
|
1905 | 1659 |
} |
1906 |
- return true; |
|
1907 | 1660 |
} |
1908 |
- function string_fill(str, char, len, left) { |
|
1909 |
- while (str.length < len) { |
|
1910 |
- if (left) { |
|
1911 |
- str += char; |
|
1661 |
+ }; |
|
1662 |
+ if (value == null) { |
|
1663 |
+ return null; |
|
1912 | 1664 |
} |
1913 | 1665 |
else { |
1914 |
- str = char + str; |
|
1666 |
+ var result_2 = {}; |
|
1667 |
+ if (typeof (value) != "object") { |
|
1668 |
+ result_2["value"] = value; |
|
1669 |
+ } |
|
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 |
+ } |
|
1675 |
+ else { |
|
1676 |
+ var object_1 = (value); |
|
1677 |
+ Object.keys(object_1).forEach(function (key) { return integrate(result_2, key, object_1[key]); }); |
|
1915 | 1678 |
} |
1916 | 1679 |
} |
1917 |
- return str; |
|
1680 |
+ return result_2; |
|
1681 |
+ } |
|
1918 | 1682 |
} |
1683 |
+ lib_object.flatten = flatten; |
|
1919 | 1684 |
/** |
1920 |
- * the known_parameters are used to parse the different identifiers for the welln known syntax: |
|
1921 |
- * flag width precision identifier |
|
1922 |
- * %{[0#+- ]}{[0-9]*}.{[0-9]*}[fFdiueEgGsoxXaAsn] |
|
1923 |
- * flags: |
|
1924 |
- * 0 - fill with '0' instead of ' ' if the string length < width |
|
1925 |
- * # - not implemented |
|
1926 |
- * - - left-justified -> fill on the right side to reach width |
|
1927 |
- * + - force using '+' on positive numbers |
|
1928 |
- * ' ' - add a single space before positive numbers |
|
1929 |
- * |
|
1930 |
- * identifiers |
|
1931 |
- * %f, %F - interpret given number as float, width: the minimal total width (fill with ' ' or '0' if the |
|
1932 |
- * resulting string is too short, precision: cut more then given decimal places |
|
1933 |
- * %d, %i, %u - interpret number as integer, decimal places will be cut. width: like float, precision: |
|
1934 |
- * fill with '0' on right side until length given in precision is reached |
|
1935 |
- * %e - interpret as float and write as scientifical number, width & precision like in float |
|
1936 |
- * %E - same es %e but uppercase 'E' |
|
1937 |
- * %g - use the shortest string of %f or %e |
|
1938 |
- * %G - use the shortest string of %E or %E |
|
1939 |
- * %s - simply print a string |
|
1940 |
- * %o - print the given number in octal notation |
|
1941 |
- * %x - print the given number in hex notation |
|
1942 |
- * %X - same as %x but with uppercase characters |
|
1943 |
- * %a - alias to %x |
|
1944 |
- * %A - alias to %X |
|
1945 |
- * %n - just print nothing |
|
1946 |
- * @type {{}} |
|
1685 |
+ * @author fenris |
|
1947 | 1686 |
*/ |
1948 |
- var known_params = {}; |
|
1949 |
- known_params["f"] = function (format, arg) { |
|
1950 |
- if (!test_arg(format, arg, "number")) |
|
1951 |
- return "Ø"; |
|
1952 |
- var tmp = Math.abs(arg); |
|
1953 |
- var sign = (arg < 0) ? -1 : 1; |
|
1954 |
- var tmp_result = null; |
|
1955 |
- if (format.precision !== null) { |
|
1956 |
- tmp = Math.floor(Math.pow(10, format.precision) * tmp) / Math.pow(10, format.precision); |
|
1957 |
- var tmp_ = (tmp * sign).toString().split("."); |
|
1958 |
- if (tmp_.length === 1) |
|
1959 |
- tmp_.push(""); |
|
1960 |
- tmp_[1] = string_fill(tmp_[1], "0", format.precision, true); |
|
1961 |
- tmp_result = tmp_.join("."); |
|
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"); }); |
|
1691 |
+ } |
|
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 |
+ } |
|
1962 | 1702 |
} |
1963 | 1703 |
else { |
1964 |
- tmp_result = (sign * tmp).toString(); |
|
1704 |
+ z[key] = y[key]; |
|
1965 | 1705 |
} |
1966 |
- if ((format.flags.indexOf(" ") >= 0) && (arg >= 0)) { |
|
1967 |
- tmp_result = " " + tmp; |
|
1706 |
+ }); |
|
1707 |
+ return z; |
|
1968 | 1708 |
} |
1969 |
- else if ((format.flags.indexOf("+") >= 0) && (arg >= 0)) { |
|
1970 |
- tmp_result = "+" + tmp; |
|
1709 |
+ lib_object.clash = clash; |
|
1710 |
+ /** |
|
1711 |
+ * @author fenris |
|
1712 |
+ */ |
|
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); |
|
1971 | 1718 |
} |
1972 |
- tmp_result = string_fill(tmp, (format.flags.indexOf("0") >= 0) ? "0" : " ", format.width, (format.flags.indexOf("-") >= 0)); |
|
1973 |
- return tmp_result; |
|
1974 |
- }; |
|
1975 |
- known_params["F"] = known_params["f"]; |
|
1976 |
- known_params["d"] = function (format, arg) { |
|
1977 |
- if (!test_arg(format, arg, 'number')) |
|
1978 |
- return 'Ø'; |
|
1979 |
- var tmp = (((arg < 0 && format.specifier !== 'u') ? -1 : 1) * Math.floor(Math.abs(arg))).toString(); |
|
1980 |
- if ((format.specifier === 'd' || format.specifier === 'i') && format.flags.indexOf(' ') >= 0 && arg >= 0) { |
|
1981 |
- tmp = ' ' + tmp; |
|
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_); |
|
1982 | 1732 |
} |
1983 |
- else if ((format.specifier === 'd' || format.specifier === 'i') && format.flags.indexOf('+') >= 0 && arg >= 0) { |
|
1984 |
- tmp = '+' + tmp; |
|
1733 |
+ else { |
|
1734 |
+ core[key].push(element); |
|
1985 | 1735 |
} |
1986 |
- tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); |
|
1987 |
- tmp = string_fill(tmp, '0', format.precision === null ? 0 : format.precision, false); |
|
1988 |
- return tmp; |
|
1989 |
- }; |
|
1990 |
- known_params["i"] = known_params["d"]; |
|
1991 |
- known_params["u"] = known_params["d"]; |
|
1992 |
- known_params["e"] = function (format, arg) { |
|
1993 |
- if (!test_arg(format, arg, 'number')) |
|
1994 |
- return 'Ø'; |
|
1995 |
- var tmp = arg.toExponential(format.precision === null ? undefined : format.precision).toString(); |
|
1996 |
- if (format.flags.indexOf(' ') >= 0 && arg >= 0) { |
|
1997 |
- tmp = ' ' + tmp; |
|
1736 |
+ }); |
|
1998 | 1737 |
} |
1999 |
- else if (format.flags.indexOf('+') >= 0 && arg >= 0) { |
|
2000 |
- tmp = '+' + tmp; |
|
1738 |
+ else { |
|
1739 |
+ core[key] = {}; |
|
1740 |
+ patch(core[key], value_mantle, deep, path_); |
|
2001 | 1741 |
} |
2002 |
- tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); |
|
2003 |
- return tmp; |
|
2004 |
- }; |
|
2005 |
- known_params["E"] = function (format, arg) { |
|
2006 |
- return known_params["e"](format, arg).toUpperCase(); |
|
2007 |
- }; |
|
2008 |
- known_params["g"] = function (format, arg) { |
|
2009 |
- if (!test_arg(format, arg, 'number')) |
|
2010 |
- return 'Ø'; |
|
2011 |
- var tmpf = known_params["f"](format, arg); |
|
2012 |
- var tmpe = known_params["e"](format, arg); |
|
2013 |
- if (tmpf.length < tmpe.length) { |
|
2014 |
- return tmpf; |
|
2015 | 1742 |
} |
2016 | 1743 |
else { |
2017 |
- return tmpe; |
|
1744 |
+ core[key] = value_mantle; |
|
2018 | 1745 |
} |
2019 |
- }; |
|
2020 |
- known_params["G"] = function (format, arg) { |
|
2021 |
- return known_params["g"](format, arg).toUpperCase(); |
|
2022 |
- }; |
|
2023 |
- known_params["s"] = function (format, arg) { |
|
2024 |
- if (!test_arg(format, arg, 'string')) |
|
2025 |
- return 'o.O'; |
|
2026 |
- var tmp = format.precision !== null ? arg.substr(0, format.precision) : arg; |
|
2027 |
- tmp = string_fill(tmp, format.flags.indexOf('0') >= 0 ? '0' : ' ', format.width, format.flags.indexOf('-') >= 0); |
|
2028 |
- return tmp; |
|
2029 |
- }; |
|
2030 |
- known_params["o"] = function (format, arg) { |
|
2031 |
- if (!test_arg(format, arg, 'number')) |
|
2032 |
- return 'Ø'; |
|
2033 |
- var tmp = Math.floor(Math.round(Math.abs(arg))) * ((arg < 0) ? -1 : 1); |
|
2034 |
- return known_params["s"](format, tmp.toString(8)); |
|
2035 |
- }; |
|
2036 |
- known_params["x"] = function (format, arg) { |
|
2037 |
- if (!test_arg(format, arg, 'number')) |
|
2038 |
- return 'Ø'; |
|
2039 |
- var tmp = Math.floor(Math.round(Math.abs(arg))) * ((arg < 0) ? -1 : 1); |
|
2040 |
- return known_params["s"](format, tmp.toString(16)); |
|
2041 |
- }; |
|
2042 |
- known_params["a"] = known_params["x"]; |
|
2043 |
- known_params["X"] = function (format, arg) { |
|
2044 |
- if (!test_arg(format, arg, 'number')) |
|
2045 |
- return 'Ø'; |
|
2046 |
- return known_params["x"](format, arg).toUpperCase(); |
|
2047 |
- }; |
|
2048 |
- known_params["A"] = known_params["X"]; |
|
2049 |
- known_params["c"] = function (format, arg) { |
|
2050 |
- var tmp = ""; |
|
2051 |
- if (typeof arg === "number") { |
|
2052 |
- tmp = String.fromCharCode(arg); |
|
2053 | 1746 |
} |
2054 |
- else if ((typeof arg === "string") && (arg.length === 1)) { |
|
2055 |
- tmp = arg[0]; |
|
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_); |
|
2056 | 1752 |
} |
2057 | 1753 |
else { |
2058 |
- console.warn(make_err(format, arg, "number|string") + " and if string it needs to have the length of 1!"); |
|
1754 |
+ core[key] = value_mantle; |
|
2059 | 1755 |
} |
2060 |
- return known_params["s"](format, tmp); |
|
2061 |
- }; |
|
2062 |
- known_params["n"] = function () { |
|
2063 |
- return ""; |
|
2064 |
- }; |
|
2065 |
- var decompose = function (chain, regexp) { |
|
2066 |
- var result = regexp.exec(chain); |
|
2067 |
- if (result == null) { |
|
2068 |
- return null; |
|
2069 | 1756 |
} |
2070 | 1757 |
else { |
2071 |
- var front = chain.substring(0, result.index); |
|
2072 |
- var back = chain.substring(result.index + result[0].length); |
|
2073 |
- return { "front": front, "match": result[0], "back": back }; |
|
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)); |
|
2074 | 1762 |
} |
2075 |
- }; |
|
2076 |
- /** |
|
2077 |
- * an implementation of c sprintf |
|
2078 |
- * @param {string} string format string |
|
2079 |
- * @param {array} args arguments which should be filled into |
|
2080 |
- * @returns {string} |
|
2081 |
- */ |
|
2082 |
- lib_string.sprintf = function (input, args, original) { |
|
2083 |
- if (args === void 0) { args = []; } |
|
2084 |
- if (original === void 0) { original = null; } |
|
2085 |
- if (original == null) |
|
2086 |
- original = input; |
|
2087 |
- var components = decompose(input, pattern); |
|
2088 |
- if (components == null) { |
|
2089 |
- if (args.length > 0) { |
|
2090 |
- console.warn("[sprintf] superfluous arguments while formatting '" + original + "': ", args); |
|
2091 | 1763 |
} |
2092 |
- return input; |
|
1764 |
+ }); |
|
2093 | 1765 |
} |
2094 |
- else { |
|
2095 |
- var arg; |
|
2096 |
- var rest; |
|
2097 |
- if (args.length > 0) { |
|
2098 |
- arg = args[0]; |
|
2099 |
- rest = args.slice(1); |
|
2100 | 1766 |
} |
2101 |
- else { |
|
2102 |
- console.warn("[sprintf] out of arguments while formatting '" + original + "'"); |
|
2103 |
- arg = null; |
|
2104 |
- rest = []; |
|
2105 |
- return input; |
|
1767 |
+ lib_object.patch = patch; |
|
1768 |
+ /** |
|
1769 |
+ * @author fenris |
|
1770 |
+ */ |
|
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; |
|
2106 | 1777 |
} |
2107 |
- var fmt = split_format(components["match"]); |
|
2108 |
- return (components["front"] |
|
2109 |
- + known_params[fmt.specifier](fmt, arg) |
|
2110 |
- + lib_string.sprintf(components["back"], rest, original)); |
|
1778 |
+ lib_object.patched = patched; |
|
1779 |
+ /** |
|
1780 |
+ * @author fenris |
|
1781 |
+ */ |
|
1782 |
+ function attached(object, key, value) { |
|
1783 |
+ var mantle = {}; |
|
1784 |
+ mantle[key] = value; |
|
1785 |
+ return patched(object, mantle, false); |
|
1786 |
+ } |
|
1787 |
+ lib_object.attached = attached; |
|
1788 |
+ /** |
|
1789 |
+ * @author fenris |
|
1790 |
+ */ |
|
1791 |
+ function copy(object) { |
|
1792 |
+ return patched({}, object); |
|
2111 | 1793 |
} |
1794 |
+ lib_object.copy = copy; |
|
1795 |
+})(lib_object || (lib_object = {})); |
|
1796 |
+/** |
|
1797 |
+ * @desc adapters for old syntax |
|
1798 |
+ * @author fenris |
|
1799 |
+ */ |
|
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 |
+ + ""); |
|
2112 | 1818 |
}; |
2113 | 1819 |
/** |
2114 |
- * an implementation of c printf |
|
2115 |
- * @param {string} string format string |
|
2116 |
- * @param {array} args arguments which should be filled into |
|
2117 |
- * @returns {string} |
|
1820 |
+ * @param {Array} array |
|
1821 |
+ * @return {string} |
|
1822 |
+ * @author frac |
|
2118 | 1823 |
*/ |
2119 |
- function printf(format, args) { |
|
2120 |
- console.log(lib_string.sprintf(format, args)); |
|
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); |
|
2121 | 1829 |
} |
2122 |
- lib_string.printf = printf; |
|
2123 |
-})(lib_string || (lib_string = {})); |
|
2124 |
-var sprintf = lib_string.sprintf; |
|
2125 |
-var printf = lib_string.printf; |
|
1830 |
+ }).join(",") + ""); |
|
1831 |
+}; |
|
2126 | 1832 |
/** |
2127 |
- * @author neuc |
|
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 |
|
2128 | 1839 |
*/ |
2129 |
-var strftime; |
|
2130 |
-(function (strftime) { |
|
2131 |
- var currentDate = new Date(); |
|
2132 |
- var days = [ |
|
2133 |
- "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" |
|
2134 |
- ]; |
|
2135 |
- var months = [ |
|
2136 |
- "January", "February", "March", "April", "May", "June", "July", "August", "September", |
|
2137 |
- "October", "November", "December" |
|
2138 |
- ]; |
|
2139 |
- function set_days(day_names) { |
|
2140 |
- days = day_names; |
|
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; |
|
2141 | 1846 |
} |
2142 |
- strftime.set_days = set_days; |
|
2143 |
- function set_months(month_names) { |
|
2144 |
- months = month_names; |
|
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 = []; |
|
2145 | 1859 |
} |
2146 |
- strftime.set_months = set_months; |
|
2147 |
- // source: https://stackoverflow.com/questions/8619879/javascript-calculate-the-day-of-the-year-1-366 |
|
2148 |
- function helper_dayOfYear(date) { |
|
2149 |
- var start = new Date(date.getFullYear(), 0, 0); |
|
2150 |
- var diff = date - start; |
|
2151 |
- var oneDay = 1000 * 60 * 60 * 24; |
|
2152 |
- return Math.floor(diff / oneDay); |
|
1860 |
+ else { |
|
1861 |
+ value = {}; |
|
2153 | 1862 |
} |
2154 |
- // source: http://weeknumber.net/how-to/javascript |
|
2155 |
- function helper_weekOfYear(date_) { |
|
2156 |
- var date = new Date(date_.getTime()); |
|
2157 |
- date.setHours(0, 0, 0, 0); |
|
2158 |
- // Thursday in current week decides the year. |
|
2159 |
- date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7); |
|
2160 |
- // January 4 is always in week 1. |
|
2161 |
- var week1 = new Date(date.getFullYear(), 0, 4); |
|
2162 |
- // Adjust to Thursday in week 1 and count number of weeks from date to week1. |
|
2163 |
- return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 |
|
2164 |
- - 3 + (week1.getDay() + 6) % 7) / 7); |
|
2165 | 1863 |
} |
2166 |
- function helper_englishWeekOfYear(date) { |
|
2167 |
- var nr = helper_weekOfYear(date); |
|
2168 |
- if (date.getDay() === 0) { |
|
2169 |
- nr = nr - 1; |
|
1864 |
+ else { |
|
1865 |
+ value = {}; |
|
2170 | 1866 |
} |
2171 |
- return nr; |
|
1867 |
+ object[head] = value; |
|
2172 | 1868 |
} |
2173 |
- function set_currentDate(date) { |
|
2174 |
- currentDate = date; |
|
1869 |
+ 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; |
|
2175 | 1875 |
} |
2176 |
- strftime.set_currentDate = set_currentDate; |
|
2177 |
- function parse(format, date) { |
|
2178 |
- if (!date) { |
|
2179 |
- date = currentDate; |
|
1876 |
+ else { |
|
1877 |
+ throw (new Error(message)); |
|
2180 | 1878 |
} |
2181 |
- var ret = format; |
|
2182 |
- var re = new RegExp("%[a-z]", "gi"); |
|
2183 |
- var match; |
|
2184 |
- while (match = re.exec(format)) { |
|
2185 |
- ret = ret.replace(match[0], parse_segment(match[0], date)); |
|
2186 | 1879 |
} |
2187 |
- return ret; |
|
2188 | 1880 |
} |
2189 |
- strftime.parse = parse; |
|
2190 |
- function parse_segment(segment, date) { |
|
2191 |
- if (!date) { |
|
2192 |
- date = currentDate; |
|
2193 | 1881 |
} |
2194 |
- var hm_segments = { |
|
2195 |
- "%a": function () { return days[date.getDay()].slice(0, 3); }, |
|
2196 |
- "%A": function () { return days[date.getDay()]; }, |
|
2197 |
- "%b": function () { return days[date.getMonth()].slice(0, 3); }, |
|
2198 |
- "%B": function () { return days[date.getMonth()]; }, |
|
2199 |
- "%c": function () { return date.toLocaleString(); }, |
|
2200 |
- "%C": function () { return Math.floor((date.getFullYear()) / 100).toString(); }, |
|
2201 |
- "%d": function () { return sprintf("%02d", [date.getDate()]); }, |
|
2202 |
- "%D": function () { return parse("%m/%d/%y", date); }, |
|
2203 |
- "%e": function () { return sprintf("%2d", [date.getDate()]); }, |
|
2204 |
- "%F": function () { return parse("%Y-%m-%d", date); }, |
|
2205 |
- "%g": function () { return sprintf("%02d", [date.getFullYear() % 1000]); }, |
|
2206 |
- "%G": function () { return date.getFullYear().toString(); }, |
|
2207 |
- "%h": function () { return parse("%b", date); }, |
|
2208 |
- "%H": function () { return sprintf("%02d", [date.getHours()]); }, |
|
2209 |
- "%I": function () { |
|
2210 |
- return sprintf("%02d", [ |
|
2211 |
- (date.getHours() > 12 ? date.getHours() - 12 : date.getHours()) |
|
2212 |
- ]); |
|
2213 |
- }, |
|
2214 |
- "%j": function () { return sprintf("%03d", [helper_dayOfYear(date)]); }, |
|
2215 |
- "%m": function () { return sprintf("%02d", [date.getMonth() + 1]); }, |
|
2216 |
- "%M": function () { return sprintf("%02d", [date.getMinutes()]); }, |
|
2217 |
- "%n": function () { return "\n"; }, |
|
2218 |
- "%p": function () { return (date.getHours() > 12 ? "PM" : "AM"); }, |
|
2219 |
- "%r": function () { return parse("%I:%M:%S %p", date); }, |
|
2220 |
- "%R": function () { return parse("%H:%M", date); }, |
|
2221 |
- "%S": function () { return date.getSeconds().toString(); }, |
|
2222 |
- "%t": function () { return "\t"; }, |
|
2223 |
- "%T": function () { return parse("%H:%M:%S", date); }, |
|
2224 |
- "%u": function () { return sprintf("%02d", [(date.getDay() === 0 ? 7 : date.getDay())]); }, |
|
2225 |
- "%U": function () { return sprintf("%02d", [helper_englishWeekOfYear(date)]); }, |
|
2226 |
- "%V": function () { return sprintf("%02d", [helper_weekOfYear(date)]); }, |
|
2227 |
- "%w": function () { return sprintf("%02d", [date.getDay().toString()]); }, |
|
2228 |
- "%W": function () { return parse("%w", date); }, |
|
2229 |
- "%x": function () { return parse("%m/%d/%G", date); }, |
|
2230 |
- "%X": function () { return parse("%T", date); }, |
|
2231 |
- "%y": function () { return parse("%g", date); }, |
|
2232 |
- "%Y": function () { return parse("%G", date); }, |
|
2233 |
- "%z": function () { return date.getTimezoneOffset().toString(); }, |
|
2234 |
- "%Z": function () { return date.toUTCString().split(' ').pop(); }, |
|
2235 |
- "%%": function () { return "%"; } |
|
2236 |
- }; |
|
2237 |
- if (!(segment in hm_segments)) { |
|
2238 |
- throw "unknown format argument '" + segment + "'"; |
|
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); |
|
2239 | 1887 |
} |
2240 |
- return hm_segments[segment](); |
|
2241 | 1888 |
} |
2242 |
-})(strftime || (strftime = {})); |
|
2243 |
-function locale_date(date, ignore_error) { |
|
2244 |
- if (date === void 0) { date = new Date(); } |
|
2245 |
- if (ignore_error === void 0) { ignore_error = false; } |
|
2246 |
- if (!(date instanceof Date)) { |
|
2247 |
- if (!ignore_error) { |
|
2248 |
- throw new SyntaxError("date must be instance of Date"); |
|
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] = {}; |
|
2249 | 1896 |
} |
2250 | 1897 |
else { |
2251 |
- console.warn("'" + date + "' seems not to be instance of Date try to force convert."); |
|
2252 |
- var tmp = date; |
|
2253 |
- date = new Date(tmp); |
|
2254 |
- if ((date.toString() === "Invalid Date") || |
|
2255 |
- (!(date < new Date(0)) && !(date > new Date(0)))) { |
|
2256 |
- console.warn("conversion didn't work, returning default value"); |
|
2257 |
- return "Ø"; |
|
2258 |
- } |
|
2259 |
- } |
|
2260 |
- } |
|
2261 |
- var conf = global_config.get_value("date") || { |
|
2262 |
- "use_locale_date": true, |
|
2263 |
- "format_string": "%d.%m.%Y" |
|
2264 |
- }; |
|
2265 |
- if (conf.use_locale_date) { |
|
2266 |
- return date.toLocaleDateString(); |
|
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; |
|
2267 | 1903 |
} |
2268 | 1904 |
else { |
2269 |
- return strftime.parse(conf.format_string, date); |
|
1905 |
+ throw (new Error(message)); |
|
2270 | 1906 |
} |
2271 | 1907 |
} |
2272 |
-; |
|
2273 |
-///<reference path="../../call/build/logic.d.ts"/> |
|
2274 |
-var make_logger = (function () { |
|
2275 |
- var _loggers = {}; |
|
2276 |
- var make_logger = function (prefix, current_loglevel) { |
|
2277 |
- var log = []; |
|
2278 |
- var level = [ |
|
2279 |
- "LOG", "INFO", "WARNING", "DEBUG" |
|
2280 |
- ]; |
|
2281 |
- var logger = function (obj, lvl) { |
|
2282 |
- var txt = obj.txt || obj; |
|
2283 |
- if (!lib_call.is_def(lvl)) |
|
2284 |
- lvl = 0; |
|
2285 |
- var date = new Date(); |
|
2286 |
- log.push({ |
|
2287 |
- "message": sprintf("%s [%s:%s] %s", [date.toString(), level[lvl], prefix, txt]), |
|
2288 |
- "timeStamp": +(date) |
|
2289 |
- }); |
|
2290 |
- if (lvl <= current_loglevel) { |
|
2291 |
- var msg = ["[" + prefix + "]", txt]; |
|
2292 |
- if (obj.arg) |
|
2293 |
- msg = ["[" + prefix + "]"].concat(Array.prototype.slice.call(obj.arg)); |
|
2294 |
- if (lvl === 0) |
|
2295 |
- console["_log"].apply(console, msg); |
|
2296 |
- else if (lvl === 1) |
|
2297 |
- console["_info"].apply(console, msg); |
|
2298 |
- else if (lvl === 2) |
|
2299 |
- console["_warn"].apply(console, msg); |
|
2300 |
- else if (lvl >= 3) |
|
2301 |
- console["_log"].apply(console, msg); |
|
2302 | 1908 |
} |
1909 |
+ return position[step]; |
|
1910 |
+ }, |
|
1911 |
+ object |
|
1912 |
+ ) |
|
1913 |
+ ); |
|
1914 |
+ */ |
|
2303 | 1915 |
}; |
2304 |
- _loggers[prefix] = { |
|
2305 |
- "logger": logger, |
|
2306 |
- "log": log |
|
2307 |
- }; |
|
2308 |
- return logger; |
|
2309 |
- }; |
|
2310 |
- make_logger["loggers"] = _loggers; |
|
2311 |
- make_logger["complete_log"] = function () { |
|
2312 |
- var logs = Object.keys(_loggers) |
|
2313 |
- .reduce(function (p, c) { |
|
2314 |
- return [].concat(p, _loggers[c].log); |
|
2315 |
- }, []); |
|
2316 |
- logs.sort(function (x, y) { |
|
2317 |
- return ((x.timeStamp > y.timeStamp) ? -1 : +1); |
|
2318 |
- }); |
|
2319 |
- return logs.map(function (x, i, a) { |
|
2320 |
- return x.message; |
|
2321 |
- }); |
|
1916 |
+/** |
|
1917 |
+ * @desc reads a branch/leaf from an object-tree |
|
1918 |
+ * @author frac |
|
1919 |
+ */ |
|
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); |
|
2322 | 1923 |
}; |
2323 |
- if (true) { |
|
2324 |
- var _log_all = function (log, lvl, next) { |
|
2325 |
- if (next === void 0) { next = function () { }; } |
|
2326 |
- return function () { |
|
2327 |
- var msg = []; |
|
2328 |
- for (var i = 0; i < arguments.length; i++) { |
|
2329 |
- if (typeof arguments[i] === "string") { |
|
2330 |
- msg.push(arguments[i]); |
|
1924 |
+/** |
|
1925 |
+ * @desc writes a branch/leaf to an object-tree |
|
1926 |
+ * @author frac |
|
1927 |
+ */ |
|
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"); |
|
2331 | 1935 |
} |
2332 | 1936 |
else { |
2333 |
- msg.push(JSON.stringify(arguments[i])); |
|
2334 |
- } |
|
1937 |
+ position[steps[steps.length - 1]] = value; |
|
2335 | 1938 |
} |
2336 |
- var obj = { |
|
2337 |
- txt: msg.join("\t"), |
|
2338 |
- arg: arguments |
|
2339 |
- }; |
|
2340 |
- log(obj, lvl); |
|
2341 |
- next(); |
|
2342 | 1939 |
}; |
2343 |
- }; |
|
2344 |
- { |
|
2345 |
- var __warn = make_logger("deprecated console.warn", 99); |
|
2346 |
- var __error = make_logger("deprecated console.error", 99); |
|
2347 |
- var __log = make_logger("deprecated console.log", 99); |
|
2348 |
- var __info = make_logger("deprecated console.info", 99); |
|
2349 |
- // bad ass |
|
2350 |
- console["_log"] = console.log; |
|
2351 |
- console["_error"] = console.error; |
|
2352 |
- console["_warn"] = console.warn; |
|
2353 |
- console["_info"] = console.info; |
|
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]] = []; |
|
2354 | 1948 |
} |
1949 |
+ else { |
|
1950 |
+ ref[paths[i]] = {}; |
|
2355 | 1951 |
} |
2356 |
- return make_logger; |
|
2357 |
-})(); |
|
2358 |
-var __extends = (this && this.__extends) || function (d, b) { |
|
2359 |
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; |
|
2360 |
- function __() { this.constructor = d; } |
|
2361 |
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
2362 |
-}; |
|
2363 |
-///<reference path="../../base/build/logic.d.ts"/> |
|
2364 |
-///<reference path="../../string/build/logic.d.ts"/> |
|
2365 |
-/** |
|
2366 |
- * @author fenris |
|
2367 |
- */ |
|
2368 |
-var lib_xml; |
|
2369 |
-(function (lib_xml) { |
|
2370 |
- /** |
|
2371 |
- * @author fenris |
|
2372 |
- */ |
|
2373 |
- var class_node = (function () { |
|
2374 |
- function class_node() { |
|
2375 | 1952 |
} |
2376 |
- return class_node; |
|
2377 |
- }()); |
|
2378 |
- lib_xml.class_node = class_node; |
|
2379 |
- /** |
|
2380 |
- * @author fenris |
|
2381 |
- */ |
|
2382 |
- var class_node_text = (function (_super) { |
|
2383 |
- __extends(class_node_text, _super); |
|
2384 |
- /** |
|
2385 |
- * @author fenris |
|
2386 |
- */ |
|
2387 |
- function class_node_text(content) { |
|
2388 |
- _super.call(this); |
|
2389 |
- this.content = content; |
|
1953 |
+ ref = ref[paths[i]]; |
|
2390 | 1954 |
} |
2391 |
- /** |
|
2392 |
- * @author fenris |
|
2393 |
- */ |
|
2394 |
- class_node_text.prototype.compile = function (depth) { |
|
2395 |
- if (depth === void 0) { depth = 0; } |
|
2396 |
- return (lib_string.repeat("\t", depth) + this.content + "\n"); |
|
1955 |
+ ref[paths[i]] = val; |
|
2397 | 1956 |
}; |
2398 |
- return class_node_text; |
|
2399 |
- }(class_node)); |
|
2400 |
- lib_xml.class_node_text = class_node_text; |
|
2401 |
- /** |
|
2402 |
- * @author fenris |
|
2403 |
- */ |
|
2404 |
- var class_node_comment = (function (_super) { |
|
2405 |
- __extends(class_node_comment, _super); |
|
2406 | 1957 |
/** |
2407 |
- * @author fenris |
|
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 |
|
2408 | 1963 |
*/ |
2409 |
- function class_node_comment(content) { |
|
2410 |
- _super.call(this); |
|
2411 |
- this.content = content; |
|
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); |
|
2412 | 1970 |
} |
2413 |
- /** |
|
2414 |
- * @author fenris |
|
2415 |
- */ |
|
2416 |
- class_node_comment.prototype.compile = function (depth) { |
|
2417 |
- if (depth === void 0) { depth = 0; } |
|
2418 |
- return (lib_string.repeat("\t", depth) + "<!-- " + this.content + " -->" + "\n"); |
|
1971 |
+ catch (exception) { |
|
1972 |
+ console.warn(exception); |
|
1973 |
+ } |
|
1974 |
+ if (value != null) { |
|
1975 |
+ object_path_write(result, path, value); |
|
1976 |
+ } |
|
1977 |
+ else { |
|
1978 |
+ console.warn("skipped path \"" + path + "\" while filtering"); |
|
1979 |
+ } |
|
1980 |
+ }); |
|
1981 |
+ return result; |
|
2419 | 1982 |
}; |
2420 |
- return class_node_comment; |
|
2421 |
- }(class_node)); |
|
2422 |
- lib_xml.class_node_comment = class_node_comment; |
|
2423 |
- /** |
|
2424 |
- * @author fenris |
|
2425 |
- */ |
|
2426 |
- var class_node_complex = (function (_super) { |
|
2427 |
- __extends(class_node_complex, _super); |
|
2428 | 1983 |
/** |
2429 |
- * @author fenris |
|
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 |
|
2430 | 1988 |
*/ |
2431 |
- function class_node_complex(name, attributes, children) { |
|
2432 |
- if (attributes === void 0) { attributes = {}; } |
|
2433 |
- if (children === void 0) { children = []; } |
|
2434 |
- _super.call(this); |
|
2435 |
- this.name = name; |
|
2436 |
- this.attributes = attributes; |
|
2437 |
- this.children = children; |
|
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)); |
|
2000 |
+ } |
|
2001 |
+ else { |
|
2002 |
+ result.push({ "key": key_, "value": value }); |
|
2003 |
+ } |
|
2438 | 2004 |
} |
2005 |
+ } |
|
2006 |
+ return result; |
|
2007 |
+}; |
|
2439 | 2008 |
/** |
2440 |
- * @author fenris |
|
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 |
|
2441 | 2013 |
*/ |
2442 |
- class_node_complex.prototype.compile = function (depth) { |
|
2443 |
- var _this = this; |
|
2444 |
- if (depth === void 0) { depth = 0; } |
|
2445 |
- var output = ""; |
|
2446 |
- var attributes = Object.keys(this.attributes).map(function (key) { return (" " + key + "=" + ("\"" + _this.attributes[key] + "\"")); }).join(""); |
|
2447 |
- output += (lib_string.repeat("\t", depth) + "<" + this.name + attributes + ">" + "\n"); |
|
2448 |
- this.children.forEach(function (child) { return (output += child.compile(depth + 1)); }); |
|
2449 |
- output += (lib_string.repeat("\t", depth) + "</" + this.name + ">" + "\n"); |
|
2450 |
- return output; |
|
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)); }); |
|
2451 | 2019 |
}; |
2452 |
- return class_node_complex; |
|
2453 |
- }(class_node)); |
|
2454 |
- lib_xml.class_node_complex = class_node_complex; |
|
2455 |
-})(lib_xml || (lib_xml = {})); |
|
2456 |
-///<reference path="../../base/build/logic.d.ts"/> |
|
2457 |
-var lib_object; |
|
2458 |
-(function (lib_object) { |
|
2459 |
- /** |
|
2460 |
- * @author fenris |
|
2461 |
- */ |
|
2462 |
- function fetch(object, fieldname, fallback, escalation) { |
|
2463 |
- if (fallback === void 0) { fallback = null; } |
|
2464 |
- if (escalation === void 0) { escalation = 1; } |
|
2465 |
- if ((fieldname in object) && (object[fieldname] !== undefined)) { |
|
2466 |
- return object[fieldname]; |
|
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; |
|
2467 | 2028 |
} |
2468 | 2029 |
else { |
2469 |
- switch (escalation) { |
|
2470 |
- case 0: { |
|
2471 |
- return fallback; |
|
2472 |
- break; |
|
2473 |
- } |
|
2474 |
- case 1: { |
|
2475 |
- var message = ("field '" + fieldname + "' not in structure"); |
|
2476 |
- message += ("; using fallback value '" + String(fallback) + "'"); |
|
2477 |
- // console.warn(message); |
|
2478 |
- return fallback; |
|
2479 |
- break; |
|
2480 |
- } |
|
2481 |
- case 2: { |
|
2482 |
- var message = ("field '" + fieldname + "' not in structure"); |
|
2483 |
- throw (new Error(message)); |
|
2484 |
- break; |
|
2485 |
- } |
|
2486 |
- default: { |
|
2487 |
- throw (new Error("invalid escalation level " + escalation)); |
|
2488 |
- break; |
|
2489 |
- } |
|
2490 |
- } |
|
2491 |
- } |
|
2030 |
+ _path += [path, key].join("."); |
|
2492 | 2031 |
} |
2493 |
- lib_object.fetch = fetch; |
|
2494 |
- /** |
|
2495 |
- * @author fenris |
|
2496 |
- */ |
|
2497 |
- function map(object_from, transformator) { |
|
2498 |
- var object_to = {}; |
|
2499 |
- Object.keys(object_from).forEach(function (key) { return (object_to[key] = transformator(object_from[key], key)); }); |
|
2500 |
- return object_to; |
|
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); |
|
2501 | 2038 |
} |
2502 |
- lib_object.map = map; |
|
2503 |
- /** |
|
2504 |
- * @author fenris |
|
2505 |
- */ |
|
2506 |
- function from_array(array) { |
|
2507 |
- var object = {}; |
|
2508 |
- array.forEach(function (entry) { return (object[entry.key] = entry.value); }); |
|
2509 |
- return object; |
|
2039 |
+ else { |
|
2040 |
+ if (leafs_only) |
|
2041 |
+ callback(_path, elem, key); |
|
2510 | 2042 |
} |
2511 |
- lib_object.from_array = from_array; |
|
2512 |
- /** |
|
2513 |
- * @author fenris |
|
2514 |
- */ |
|
2515 |
- function to_array(object) { |
|
2516 |
- var array = []; |
|
2517 |
- Object.keys(object).forEach(function (key) { return array.push({ "key": key, "value": object[key] }); }); |
|
2518 |
- return array; |
|
2519 | 2043 |
} |
2520 |
- lib_object.to_array = to_array; |
|
2521 |
- /** |
|
2522 |
- * @author fenris |
|
2523 |
- */ |
|
2524 |
- function values(object) { |
|
2525 |
- return to_array(object).map(function (entry) { return entry.value; }); |
|
2044 |
+ }); |
|
2045 |
+ var func; |
|
2046 |
+ while (func = next.shift()) { |
|
2047 |
+ func(); |
|
2526 | 2048 |
} |
2527 |
- lib_object.values = values; |
|
2049 |
+}; |
|
2528 | 2050 |
/** |
2529 |
- * @author fenris |
|
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 |
|
2530 | 2055 |
*/ |
2531 |
- function path_read(object, path, fallback, escalation) { |
|
2532 |
- if (fallback === void 0) { fallback = null; } |
|
2533 |
- if (escalation === void 0) { escalation = 1; } |
|
2534 |
- var steps = ((path.length == 0) ? [] : path.split(".")); |
|
2535 |
- if (steps.length == 0) { |
|
2536 |
- throw (new Error("empty path")); |
|
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; |
|
2537 | 2073 |
} |
2538 | 2074 |
else { |
2539 |
- var position_1 = object; |
|
2540 |
- var reachable = steps.slice(0, steps.length - 1).every(function (step) { |
|
2541 |
- position_1 = object_fetch(position_1, step, null, 0); |
|
2542 |
- return (position_1 != null); |
|
2543 |
- }); |
|
2544 |
- if (reachable) { |
|
2545 |
- return object_fetch(position_1, steps[steps.length - 1], fallback, escalation); |
|
2075 |
+ if ((typeof (value) === "object") && (value != null)) { |
|
2076 |
+ return leafs.concat(getLeafs(value).map(function (leaf) { return (key + "." + leaf); })); |
|
2546 | 2077 |
} |
2547 | 2078 |
else { |
2548 |
- return object_fetch({}, "_dummy_", fallback, escalation); |
|
2079 |
+ return leafs.concat([key]); |
|
2549 | 2080 |
} |
2550 | 2081 |
} |
2551 | 2082 |
} |
2552 |
- lib_object.path_read = path_read; |
|
2083 |
+ catch (exception) { |
|
2084 |
+ console.warn(exception); |
|
2085 |
+ console.info("key: ", key); |
|
2086 |
+ return null; |
|
2087 |
+ } |
|
2088 |
+ }, new Array())); |
|
2089 |
+}; |
|
2553 | 2090 |
/** |
2554 |
- * @author fenris |
|
2091 |
+ * |
|
2092 |
+ * @desc merges two arrays by probing |
|
2093 |
+ * @param {Array} core |
|
2094 |
+ * @param {Array} mantle |
|
2095 |
+ * @param {function} match |
|
2555 | 2096 |
*/ |
2556 |
- function path_write(object, path, value, construct) { |
|
2557 |
- if (construct === void 0) { construct = true; } |
|
2558 |
- var steps = ((path.length == 0) ? [] : path.split(".")); |
|
2559 |
- if (steps.length == 0) { |
|
2560 |
- throw (new Error("empty path")); |
|
2561 |
- } |
|
2562 |
- else { |
|
2563 |
- var position_2 = object; |
|
2564 |
- var reachable = steps.slice(0, steps.length - 1).every(function (step) { |
|
2565 |
- var position_ = object_fetch(position_2, step, null, 0); |
|
2566 |
- if (position_ == null) { |
|
2567 |
- if (construct) { |
|
2568 |
- position_2[step] = {}; |
|
2569 |
- position_2 = position_2[step]; |
|
2570 |
- return true; |
|
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) + "'" : ""))); |
|
2571 | 2103 |
} |
2572 |
- else { |
|
2573 |
- return false; |
|
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); |
|
2574 | 2110 |
} |
2111 |
+ catch (e) { |
|
2112 |
+ ret.push(entry); |
|
2575 | 2113 |
} |
2576 |
- else { |
|
2577 |
- position_2 = position_; |
|
2578 |
- return true; |
|
2579 | 2114 |
} |
2580 |
- }); |
|
2581 |
- if (reachable) { |
|
2582 |
- position_2[steps[steps.length - 1]] = value; |
|
2115 |
+ return ret; |
|
2116 |
+}; |
|
2117 |
+/** |
|
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 |
|
2124 |
+ */ |
|
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 = []; |
|
2583 | 2135 |
} |
2584 | 2136 |
else { |
2585 |
- throw (new Error("path " + path + " does not exist and may not be constructed")); |
|
2137 |
+ object1 = {}; |
|
2586 | 2138 |
} |
2587 | 2139 |
} |
2140 |
+ var iteration_keys = Object.keys(object2); |
|
2141 |
+ if (ignore_keys === []) { |
|
2142 |
+ if (path.indexOf(object2) >= 0) |
|
2143 |
+ return undefined; |
|
2144 |
+ path.push(object2); |
|
2588 | 2145 |
} |
2589 |
- lib_object.path_write = path_write; |
|
2590 |
- /** |
|
2591 |
- * @author fenris |
|
2592 |
- */ |
|
2593 |
- function matches(object, pattern) { |
|
2594 |
- return Object.keys(pattern).every(function (key) { return (pattern[key] == object[key]); }); |
|
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 |
+ // |
|
2595 | 2153 |
} |
2596 |
- lib_object.matches = matches; |
|
2597 |
- /** |
|
2598 |
- * @author fenris |
|
2599 |
- */ |
|
2600 |
- function flatten(value) { |
|
2601 |
- var integrate = function (result, key_, value_) { |
|
2602 |
- if (value_ == null) { |
|
2603 |
- result[key_] = value_; |
|
2154 |
+ else if (object2[key] === null) { |
|
2155 |
+ if (!ignore_null) |
|
2156 |
+ object1[key] = null; |
|
2604 | 2157 |
} |
2605 |
- else { |
|
2606 |
- if (typeof (value_) != "object") { |
|
2607 |
- result[key_] = value_; |
|
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); |
|
2608 | 2160 |
} |
2609 | 2161 |
else { |
2610 |
- var result_1 = flatten(value_); |
|
2611 |
- Object.keys(result_1).forEach(function (key__) { |
|
2612 |
- var value__ = result_1[key__]; |
|
2613 |
- result[(key_ + "." + key__)] = value__; |
|
2614 |
- }); |
|
2162 |
+ if ((do_not_overwrite_existing_values === false) || (typeof (object1[key]) === "undefined")) { |
|
2163 |
+ object1[key] = object2[key]; |
|
2615 | 2164 |
} |
2616 | 2165 |
} |
2166 |
+ } |
|
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; }) |
|
2617 | 2190 |
}; |
2618 |
- if (value == null) { |
|
2619 |
- return null; |
|
2620 |
- } |
|
2621 |
- else { |
|
2622 |
- var result_2 = {}; |
|
2623 |
- if (typeof (value) != "object") { |
|
2624 |
- result_2["value"] = value; |
|
2625 | 2191 |
} |
2626 |
- else { |
|
2627 |
- if (value instanceof Array) { |
|
2628 |
- var array = (value); |
|
2629 |
- array.forEach(function (element, index) { return integrate(result_2, "element_" + index, element); }); |
|
2192 |
+ tmp = flatten_object(_obj, _recipie, drop_key); |
|
2193 |
+ ret = object_merge_objects(ret, tmp); |
|
2630 | 2194 |
} |
2631 | 2195 |
else { |
2632 |
- var object_1 = (value); |
|
2633 |
- Object.keys(object_1).forEach(function (key) { return integrate(result_2, key, object_1[key]); }); |
|
2634 |
- } |
|
2635 |
- } |
|
2636 |
- return result_2; |
|
2637 |
- } |
|
2196 |
+ ret[prefix + key] = _obj; |
|
2638 | 2197 |
} |
2639 |
- lib_object.flatten = flatten; |
|
2640 |
- /** |
|
2641 |
- * @author frac |
|
2642 |
- */ |
|
2643 |
- function clash(x, y) { |
|
2644 |
- var z = {}; |
|
2645 |
- Object.keys(x).forEach(function (key) { return (z[key] = x[key]); }); |
|
2646 |
- Object.keys(y).forEach(function (key) { return (z[key] = y[key]); }); |
|
2647 |
- return z; |
|
2648 | 2198 |
} |
2649 |
- lib_object.clash = clash; |
|
2650 |
-})(lib_object || (lib_object = {})); |
|
2651 |
-/** |
|
2652 |
- * @desc adapters for old syntax |
|
2653 |
- * @author fenris |
|
2654 |
- */ |
|
2655 |
-var object_fetch = lib_object.fetch; |
|
2656 |
-var object_map = lib_object.map; |
|
2657 |
-var object_a2o = lib_object.from_array; |
|
2658 |
-var object_o2a = lib_object.to_array; |
|
2659 |
-var object_matches = lib_object.matches; |
|
2660 |
-var object_clash = lib_object.clash; |
|
2661 |
-///<reference path="../../base/build/logic.d.ts"/> |
|
2662 |
-///<reference path="../../string/build/logic.d.ts"/> |
|
2663 |
-/** |
|
2664 |
- * @param {Object} map |
|
2665 |
- * @return {string} |
|
2666 |
- * @author frac |
|
2667 |
- */ |
|
2668 |
-/*export*/ var object_map2string = function (map) { |
|
2669 |
- return (" " + Object.keys(map) |
|
2670 |
- .filter(function (key) { return (key != "isMapped"); }) |
|
2671 |
- .map(function (key) { return ("" + ((map[key] == null) ? "-" : map[key].toString()) + ""); }) |
|
2672 |
- .join(" ") |
|
2673 |
- + ""); |
|
2674 |
-}; |
|
2675 |
-/** |
|
2676 |
- * @param {Array} array |
|
2677 |
- * @return {string} |
|
2678 |
- * @author frac |
|
2679 |
- */ |
|
2680 |
-/*export*/ var object_array2string = function (array) { |
|
2681 |
- return ("" + array.map(function (element, index) { |
|
2682 |
- switch (typeof (element)) { |
|
2683 |
- case "object": return object_map2string(element); |
|
2684 |
- default: return String(element); |
|
2685 | 2199 |
} |
2686 |
- }).join(",") + ""); |
|
2200 |
+ return ret; |
|
2687 | 2201 |
}; |
2688 | 2202 |
/** |
2689 |
- * @desc follows a path in an object-tree |
|
2690 |
- * @param {Object} object the object in which the path lies |
|
2691 |
- * @param {string} path the steps |
|
2692 |
- * @param {boolean} [create] whether to create not yet existing branches |
|
2693 |
- * @return {Object} {'successful': successful, 'position': position} where the branch or leaf at the end of the path |
|
2694 |
- * @author frac |
|
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 |
|
2695 | 2206 |
*/ |
2696 |
-var object_path_walk = function (object, path, create, null_on_missing) { |
|
2697 |
- if (create === void 0) { create = true; } |
|
2698 |
- if (null_on_missing === void 0) { null_on_missing = false; } |
|
2699 |
- var steps = ((path == "") ? [] : path.split(".")); |
|
2700 |
- if (steps.length == 0) { |
|
2701 |
- return object; |
|
2702 |
- } |
|
2703 |
- else { |
|
2704 |
- var head = steps[0]; |
|
2705 |
- // create |
|
2706 |
- { |
|
2707 |
- if (!(head in object)) { |
|
2708 |
- if (create) { |
|
2709 |
- var value = null; |
|
2710 |
- if (steps.length >= 2) { |
|
2711 |
- var next = steps[1]; |
|
2712 |
- var index = parseInt(next); |
|
2713 |
- if (!isNaN(index)) { |
|
2714 |
- value = []; |
|
2715 |
- } |
|
2716 |
- else { |
|
2717 |
- value = {}; |
|
2718 |
- } |
|
2207 |
+/*export*/ var object_make_flat = function (object, path, filter, split_char, objects) { |
|
2208 |
+ 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(); |
|
2719 | 2214 |
} |
2720 | 2215 |
else { |
2721 |
- value = {}; |
|
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; |
|
2722 | 2224 |
} |
2723 |
- object[head] = value; |
|
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))); |
|
2724 | 2230 |
} |
2725 |
- else { |
|
2726 |
- // console.info("[object_path_walk] object is ", object); |
|
2727 |
- var message = "[object_path_walk] can not walk step \u00BB" + head + "\u00AB in path \u00BB" + path + "\u00AB on object"; |
|
2728 |
- if (null_on_missing) { |
|
2729 |
- console.warn(message); |
|
2730 |
- return null; |
|
2231 |
+ else if (typeof obj_ref[key] === "function") { |
|
2232 |
+ // o.O a function ... doing nothing might be the best choice |
|
2731 | 2233 |
} |
2732 | 2234 |
else { |
2733 |
- throw (new Error(message)); |
|
2734 |
- } |
|
2735 |
- } |
|
2736 |
- } |
|
2737 |
- } |
|
2738 |
- // execute rest |
|
2739 |
- { |
|
2740 |
- var object_ = object[head]; |
|
2741 |
- var path_ = steps.slice(1).join("."); |
|
2742 |
- return object_path_walk(object_, path_, create, null_on_missing); |
|
2235 |
+ var value = obj_ref[key]; |
|
2236 |
+ ret[newkey] = value; |
|
2743 | 2237 |
} |
2744 | 2238 |
} |
2745 |
- /* |
|
2746 |
- return ( |
|
2747 |
- string_split(path, ".").reduce( |
|
2748 |
- function (position : any, step : string) : any { |
|
2749 |
- if (! lib_call.is_def(position[step], true)) { |
|
2750 |
- if (create) { |
|
2751 |
- position[step] = {}; |
|
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); |
|
2752 | 2249 |
} |
2753 |
- else { |
|
2754 |
- // console.info("[object_path_walk] object is ", object); |
|
2755 |
- let message : string = sprintf("[object_path_walk] can not walk step »%s« in path »%s« on object", [step, path]); |
|
2756 |
- if (null_on_missing) { |
|
2757 |
- console.warn(message); |
|
2758 |
- return null; |
|
2759 | 2250 |
} |
2760 | 2251 |
else { |
2761 |
- throw (new Error(message)); |
|
2762 |
- } |
|
2252 |
+ //console.warn("something went wrong with that object: ", object, "on this path:", path); |
|
2763 | 2253 |
} |
2254 |
+ return ret; |
|
2764 | 2255 |
} |
2765 |
- return position[step]; |
|
2766 |
- }, |
|
2767 |
- object |
|
2768 |
- ) |
|
2769 |
- ); |
|
2770 |
- */ |
|
2771 | 2256 |
}; |
2772 | 2257 |
/** |
2773 |
- * @desc reads a branch/leaf from an object-tree |
|
2774 |
- * @author frac |
|
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} |
|
2775 | 2265 |
*/ |
2776 |
-/*export*/ var object_path_read = function (object, path, null_on_missing) { |
|
2777 |
- if (null_on_missing === void 0) { null_on_missing = false; } |
|
2778 |
- return object_path_walk(object, path, false, null_on_missing); |
|
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]+\./); |
|
2779 | 2270 |
}; |
2780 |
-/** |
|
2781 |
- * @desc writes a branch/leaf to an object-tree |
|
2782 |
- * @author frac |
|
2783 |
- */ |
|
2784 |
-/*export*/ var object_path_write = function (object, path, value) { |
|
2785 |
- // for "initializing" the object (important if the value to write is an entry in a yet not existing array) |
|
2786 |
- /*let old : any = */ object_path_walk(object, path, true, true); |
|
2787 |
- var steps = ((path == "") ? [] : path.split(".")); |
|
2788 |
- var position = object_path_walk(object, steps.slice(0, steps.length - 1).join("."), true); |
|
2789 |
- if (position == undefined) { |
|
2790 |
- console.warn("can't set \u00BB" + steps[steps.length - 1] + "\u00AB in undefined"); |
|
2791 |
- } |
|
2792 |
- else { |
|
2793 |
- position[steps[steps.length - 1]] = value; |
|
2794 | 2271 |
} |
2272 |
+ if (typeof (fab_function) === "undefined") { |
|
2273 |
+ fab_function = function (obj, e) { |
|
2274 |
+ return obj; |
|
2795 | 2275 |
}; |
2796 |
-/*export*/ var object_object_path_write_ex = function (obj, path, val) { |
|
2797 |
- var ref = obj; |
|
2798 |
- var paths = path.split("."); |
|
2799 |
- var i; |
|
2800 |
- for (i = 0; i < paths.length - 1; i++) { |
|
2801 |
- if (ref[paths[i]] === void 0) { |
|
2802 |
- if (/^(0|[1-9][0-9]*)$/.test(paths[i + 1])) { |
|
2803 |
- ref[paths[i]] = []; |
|
2804 | 2276 |
} |
2805 |
- else { |
|
2806 |
- ref[paths[i]] = {}; |
|
2277 |
+ if (typeof (number_replace_string) === "undefined") { |
|
2278 |
+ number_replace_string = "%d"; |
|
2807 | 2279 |
} |
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 + "."); |
|
2808 | 2290 |
} |
2809 |
- ref = ref[paths[i]]; |
|
2291 |
+ if (!ret[index]) { |
|
2292 |
+ ret[index] = {}; |
|
2810 | 2293 |
} |
2811 |
- ref[paths[i]] = val; |
|
2812 |
-}; |
|
2813 |
-/** |
|
2814 |
- * @desc filters branches from an object |
|
2815 |
- * @param {Object} object the object to read from |
|
2816 |
- * @param {Array} paths a list of string-lists, that are the paths to be propagated |
|
2817 |
- * @return {Object} the object with only the selected branches |
|
2818 |
- * @author frac |
|
2819 |
- */ |
|
2820 |
-/*export*/ var object_path_filter = function (object, paths) { |
|
2821 |
- var result = {}; |
|
2822 |
- paths.forEach(function (path) { |
|
2823 |
- var value = null; |
|
2824 |
- try { |
|
2825 |
- value = object_path_read(object, path); |
|
2294 |
+ ret[index][nkey] = entry[key]; |
|
2295 |
+ }); |
|
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)); |
|
2826 | 2300 |
} |
2827 |
- catch (exception) { |
|
2828 |
- console.warn(exception); |
|
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))); |
|
2829 | 2327 |
} |
2830 |
- if (value != null) { |
|
2831 |
- object_path_write(result, path, value); |
|
2832 | 2328 |
} |
2833 | 2329 |
else { |
2834 |
- console.warn("skipped path \"" + path + "\" while filtering"); |
|
2330 |
+ prev.push(current); |
|
2835 | 2331 |
} |
2836 |
- }); |
|
2837 |
- return result; |
|
2838 |
-}; |
|
2839 |
-/** |
|
2840 |
- * @desc dunno… returns a list of object-paths? |
|
2841 |
- * @param {Object} object |
|
2842 |
- * @param {string} p |
|
2843 |
- * @todo can probably be merged with getLeafg |
|
2844 |
- */ |
|
2845 |
-/*export*/ var object_path_list = function (object, path, visited) { |
|
2846 |
- if (path === void 0) { path = null; } |
|
2847 |
- if (visited === void 0) { visited = []; } |
|
2848 |
- var result = []; |
|
2849 |
- visited.push(object); |
|
2850 |
- for (var key in object) { |
|
2851 |
- var value = object[key]; |
|
2852 |
- if (visited.indexOf(value) === -1) { |
|
2853 |
- var key_ = (path == null) ? key : (path + "." + key); |
|
2854 |
- if (typeof (value) === "object") { |
|
2855 |
- result = result.concat(object_path_list(value, key_, visited)); |
|
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]; |
|
2856 | 2341 |
} |
2857 |
- else { |
|
2858 |
- result.push({ "key": key_, "value": value }); |
|
2859 | 2342 |
} |
2343 |
+ else { |
|
2344 |
+ ret[prefix + path] = tmp; |
|
2860 | 2345 |
} |
2861 | 2346 |
} |
2862 |
- return result; |
|
2347 |
+ return ret; |
|
2863 | 2348 |
}; |
2864 | 2349 |
/** |
2865 |
- * theroreticaly loop prof walk through all elements and subelements of an object |
|
2866 |
- * and call a callback for each entry |
|
2867 |
- * @param {object} obj object to iterate through |
|
2868 |
- * @param {function} callback |
|
2350 |
+ * parse |
|
2351 |
+ * @param {String} value |
|
2352 |
+ * @returns {Object} |
|
2869 | 2353 |
*/ |
2870 |
-/*export*/ var object_iterate = function (obj, callback, leafs_only, path, visited) { |
|
2871 |
- if (leafs_only === void 0) { leafs_only = false; } |
|
2872 |
- if (visited === void 0) { visited = []; } |
|
2873 |
- var have_seen = function (ob) { |
|
2874 |
- return visited.some(function (e) { return ((typeof ob === "Object") && (ob !== null) && (e === ob)); }); |
|
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"]; |
|
2875 | 2359 |
}; |
2876 |
- var next = []; |
|
2877 |
- Object.keys(obj).forEach(function (key) { |
|
2878 |
- var elem = obj[key]; |
|
2879 |
- if (!have_seen(elem)) { |
|
2880 |
- visited.push(elem); |
|
2881 |
- var _path = ""; |
|
2882 |
- if (typeof path === "undefined") { |
|
2883 |
- _path = key; |
|
2884 |
- } |
|
2885 |
- else { |
|
2886 |
- _path += [path, key].join("."); |
|
2360 |
+/** |
|
2361 |
+ * stringify |
|
2362 |
+ * |
|
2363 |
+ * @description stringify object as JSON |
|
2364 |
+ */ |
|
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)) { |
|
2369 |
+ return null; |
|
2887 | 2370 |
} |
2888 |
- if (!leafs_only) |
|
2889 |
- callback(_path, elem, key); |
|
2890 |
- if (typeof (elem) === "object") { |
|
2891 |
- (function (elem_, callback_, _path_, visited_) { |
|
2892 |
- next.push(function () { object_iterate(elem_, callback_, leafs_only, _path_, visited_); }); |
|
2893 |
- })(elem, callback, _path, visited); |
|
2371 |
+ if (key == "changeActions") { |
|
2372 |
+ return undefined; |
|
2894 | 2373 |
} |
2895 |
- else { |
|
2896 |
- if (leafs_only) |
|
2897 |
- callback(_path, elem, key); |
|
2374 |
+ if (key == "observer") { |
|
2375 |
+ return undefined; |
|
2898 | 2376 |
} |
2377 |
+ if (key == "isMapped") { |
|
2378 |
+ return undefined; |
|
2899 | 2379 |
} |
2900 |
- }); |
|
2901 |
- var func; |
|
2902 |
- while (func = next.shift()) { |
|
2903 |
- func(); |
|
2380 |
+ /* |
|
2381 |
+ if (value === null) { |
|
2382 |
+ return undefined; |
|
2904 | 2383 |
} |
2384 |
+ */ |
|
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 __()); |
|
2905 | 2396 |
}; |
2397 |
+})(); |
|
2398 |
+var lib_meta; |
|
2399 |
+(function (lib_meta) { |
|
2906 | 2400 |
/** |
2907 |
- * @desc get the leaf-nodes of an object |
|
2908 |
- * @param {object} object |
|
2909 |
- * @return {Array<string>} a list containing all leaf-nodes |
|
2910 | 2401 |
* @author frac |
2911 | 2402 |
*/ |
2912 |
-/*export*/ var getLeafs = function (object) { |
|
2913 |
- var skip = { |
|
2914 |
- "className": true, |
|
2915 |
- "timeStamp": true, |
|
2916 |
- "parentId": true, |
|
2917 |
- "transactionID": true, |
|
2918 |
- "guid": true, |
|
2919 |
- "_id": true, |
|
2920 |
- "parents": true, |
|
2921 |
- "children": true |
|
2922 |
- }; |
|
2923 |
- return (Object.keys(object).reduce(function (leafs, key) { |
|
2924 |
- try { |
|
2925 |
- var value = object[key]; |
|
2926 |
- if (key in skip) { |
|
2927 |
- console.warn("skipping field \"" + key + "\""); |
|
2928 |
- return leafs; |
|
2929 |
- } |
|
2930 |
- else { |
|
2931 |
- if ((typeof (value) === "object") && (value != null)) { |
|
2932 |
- return leafs.concat(getLeafs(value).map(function (leaf) { return (key + "." + leaf); })); |
|
2933 |
- } |
|
2934 |
- else { |
|
2935 |
- return leafs.concat([key]); |
|
2936 |
- } |
|
2937 |
- } |
|
2938 |
- } |
|
2939 |
- catch (exception) { |
|
2940 |
- console.warn(exception); |
|
2941 |
- console.info("key: ", key); |
|
2942 |
- return null; |
|
2403 |
+ function type_toString(type) { |
|
2404 |
+ // return ("<" + type.id + ">"); |
|
2405 |
+ return JSON.stringify(type); |
|
2943 | 2406 |
} |
2944 |
- }, new Array())); |
|
2945 |
-}; |
|
2407 |
+ lib_meta.type_toString = type_toString; |
|
2946 | 2408 |
/** |
2947 |
- * |
|
2948 |
- * @desc merges two arrays by probing |
|
2949 |
- * @param {Array} core |
|
2950 |
- * @param {Array} mantle |
|
2951 |
- * @param {function} match |
|
2409 |
+ * @author frac |
|
2952 | 2410 |
*/ |
2953 |
-/*export*/ var merge_array = function (core, mantle, match) { |
|
2954 |
- if (match === void 0) { match = (function (x, y) { return (x === y); }); } |
|
2955 |
- if ((core == undefined) || (mantle == undefined)) { |
|
2956 |
- throw (new Error("Error: " |
|
2957 |
- + ((core == undefined) ? " core must be an array and not '" + typeof (core) + "'" : "") |
|
2958 |
- + ((mantle == undefined) ? " mantle must be an array and not '" + typeof (mantle) + "'" : ""))); |
|
2959 |
- } |
|
2960 |
- var ret = core; |
|
2961 |
- for (var i = 0; i < mantle.length; i++) { |
|
2962 |
- var entry = mantle[i]; |
|
2963 |
- try { |
|
2964 |
- var matching_index = core.find(function (element) { return match(element, entry); }); |
|
2965 |
- ret[matching_index] = object_merge_objects(core[matching_index], entry); |
|
2966 |
- } |
|
2967 |
- catch (e) { |
|
2968 |
- ret.push(entry); |
|
2969 |
- } |
|
2411 |
+ var class_pool = {}; |
|
2412 |
+ /** |
|
2413 |
+ * @author frac |
|
2414 |
+ */ |
|
2415 |
+ function class_set(name, class_) { |
|
2416 |
+ class_pool[name] = class_; |
|
2970 | 2417 |
} |
2971 |
- return ret; |
|
2972 |
-}; |
|
2418 |
+ lib_meta.class_set = class_set; |
|
2973 | 2419 |
/** |
2974 |
- * @desc merges two objects recursivly |
|
2975 |
- * @param {Object} object1 core |
|
2976 |
- * @param {Object} object2 mantle |
|
2977 |
- * @param {Array} [ignore_keys] |
|
2978 |
- * @param [do_not_overwrite_existing_values] |
|
2979 |
- * @returns {Object} a clone of object1 will be returned |
|
2420 |
+ * @author frac |
|
2980 | 2421 |
*/ |
2981 |
-/*export*/ var object_merge_objects = function (object1, object2, ignore_keys, do_not_overwrite_existing_values, ignore_null, path) { |
|
2982 |
- if (object1 === void 0) { object1 = null; } |
|
2983 |
- if (object2 === void 0) { object2 = null; } |
|
2984 |
- if (ignore_keys === void 0) { ignore_keys = ["parents"]; } |
|
2985 |
- if (do_not_overwrite_existing_values === void 0) { do_not_overwrite_existing_values = false; } |
|
2986 |
- if (ignore_null === void 0) { ignore_null = false; } |
|
2987 |
- if (path === void 0) { path = []; } |
|
2988 |
- if (object1 == null) { |
|
2989 |
- if (object2 instanceof Array) { |
|
2990 |
- object1 = []; |
|
2422 |
+ function class_get(name) { |
|
2423 |
+ if (name in class_pool) { |
|
2424 |
+ return class_pool[name]; |
|
2991 | 2425 |
} |
2992 | 2426 |
else { |
2993 |
- object1 = {}; |
|
2994 |
- } |
|
2995 |
- } |
|
2996 |
- var iteration_keys = Object.keys(object2); |
|
2997 |
- if (ignore_keys === []) { |
|
2998 |
- if (path.indexOf(object2) >= 0) |
|
2999 |
- return undefined; |
|
3000 |
- path.push(object2); |
|
3001 |
- } |
|
3002 |
- // |
|
3003 |
- for (var i = 0; i < iteration_keys.length; i += 1) { |
|
3004 |
- var key = iteration_keys[i]; |
|
3005 |
- if (ignore_keys.some(function (k) { |
|
3006 |
- return key == k; |
|
3007 |
- })) { |
|
2427 |
+ throw (new Error("no class registered for name '" + name + "'")); |
|
3008 | 2428 |
} |
3009 |
- else if (object2[key] === null) { |
|
3010 |
- if (!ignore_null) |
|
3011 |
- object1[key] = null; |
|
3012 | 2429 |
} |
3013 |
- else if ((typeof (object2[key]) === "object") && ((typeof (object1[key]) === "object") || (typeof (object1[key]) === "undefined"))) { |
|
3014 |
- object1[key] = object_merge_objects(object1[key], object2[key], ignore_keys, do_not_overwrite_existing_values, ignore_null, path); |
|
3015 |
- } |
|
3016 |
- else { |
|
3017 |
- if ((do_not_overwrite_existing_values === false) || (typeof (object1[key]) === "undefined")) { |
|
3018 |
- object1[key] = object2[key]; |
|
2430 |
+ lib_meta.class_get = class_get; |
|
2431 |
+ /** |
|
2432 |
+ * @author frac |
|
2433 |
+ */ |
|
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 |
+ }); |
|
3019 | 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")); |
|
3020 | 2465 |
} |
2466 |
+ return index; |
|
2467 |
+ }) |
|
2468 |
+ }; |
|
2469 |
+ })); |
|
2470 |
+ return { |
|
2471 |
+ "fields": fields, |
|
2472 |
+ "description": null, |
|
2473 |
+ "title": label, |
|
2474 |
+ "groups": groups |
|
2475 |
+ }; |
|
3021 | 2476 |
} |
3022 |
- return object1; |
|
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 |
+ }) |
|
3023 | 2491 |
}; |
2492 |
+ }) |
|
2493 |
+ }); |
|
2494 |
+ } |
|
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; |
|
3024 | 2522 |
/* |
3025 |
- * @param {object} recipie ex: { "name" : { extract : function(o) { return o["name"]; }}} |
|
3026 |
- * */ |
|
3027 |
-var flatten_object = function (obj, recipie, drop_key) { |
|
3028 |
- if (drop_key === void 0) { drop_key = (function (k) { return ["parents", "parent", "children"].indexOf(k) > -1; }); } |
|
3029 |
- var ret = {}; |
|
3030 |
- for (var key in recipie) { |
|
3031 |
- if (!drop_key(key)) { |
|
3032 |
- var prefix = (recipie[key].prefix || ""); |
|
3033 |
- var recursive = (recipie[key].recursive || -1); |
|
3034 |
- var extract = (recipie[key].extract || (function (x) { return x; })); |
|
3035 |
- var _obj = extract(obj[key]); |
|
3036 |
- if ((_obj !== null) && ((typeof _obj == "object") || (obj[key] instanceof Array)) && (!(recursive == 0))) { |
|
3037 |
- var tmp = {}; |
|
3038 |
- var _recipie = {}; |
|
3039 |
- for (var _i = 0, _a = Object.keys(_obj); _i < _a.length; _i++) { |
|
3040 |
- var k = _a[_i]; |
|
3041 |
- _recipie[k] = { |
|
3042 |
- "prefix": (prefix + key + "."), |
|
3043 |
- "recursive": (recursive - 1), |
|
3044 |
- "extract": (function (x) { return x; }) |
|
2523 |
+ if ((! soft) && (defaultvalue == null)) { |
|
2524 |
+ throw (new Error("'null' is not a valid defaultvalue for hard shapes")); |
|
2525 |
+ } |
|
2526 |
+ */ |
|
2527 |
+ this.primitive = primitive; |
|
2528 |
+ this.soft = soft; |
|
2529 |
+ this.defaultvalue = defaultvalue; |
|
2530 |
+ } |
|
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; |
|
3045 | 2551 |
}; |
2552 |
+ /** |
|
2553 |
+ * @desc [accessor] |
|
2554 |
+ * @author fenris |
|
2555 |
+ */ |
|
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"); |
|
3046 | 2560 |
} |
3047 |
- tmp = flatten_object(_obj, _recipie, drop_key); |
|
3048 |
- ret = object_merge_objects(ret, tmp); |
|
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); }); |
|
3049 | 2571 |
} |
3050 |
- else { |
|
3051 |
- ret[prefix + key] = _obj; |
|
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; |
|
3052 | 2594 |
} |
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 + "'"); |
|
3053 | 2603 |
} |
2604 |
+ return messages; |
|
2605 |
+ }; |
|
2606 |
+ /** |
|
2607 |
+ * @desc [implementation] |
|
2608 |
+ * @author fenris |
|
2609 |
+ */ |
|
2610 |
+ class_shape_buildin.prototype._show = function () { |
|
2611 |
+ var str = ""; |
|
2612 |
+ str = this.typename; |
|
2613 |
+ if (!this.soft) { |
|
2614 |
+ str = str + "_or_null"; |
|
3054 | 2615 |
} |
3055 |
- return ret; |
|
2616 |
+ return str; |
|
3056 | 2617 |
}; |
2618 |
+ return class_shape_buildin; |
|
2619 |
+ }(class_shape)); |
|
2620 |
+ lib_meta.class_shape_buildin = class_shape_buildin; |
|
3057 | 2621 |
/** |
3058 |
- * use the complete path of an objects entry as key to make an one dimensional object |
|
3059 |
- * @param {object} object the object which should be moade flat |
|
3060 |
- * @param {string} [path] for the recursive call the current path |
|
2622 |
+ * @author fenris |
|
3061 | 2623 |
*/ |
3062 |
-/*export*/ var object_make_flat = function (object, path, filter, split_char, objects) { |
|
3063 |
- if (path === void 0) { path = null; } |
|
3064 |
- if (filter === void 0) { filter = ["parent", "children"]; } |
|
3065 |
- if (split_char === void 0) { split_char = "."; } |
|
3066 |
- if (objects === void 0) { objects = []; } |
|
3067 |
- if (object.toFlat != undefined) { |
|
3068 |
- return object.toFlat(); |
|
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)); |
|
3069 | 2632 |
} |
3070 | 2633 |
else { |
3071 |
- var ret = {}; |
|
3072 |
- var default_visited_key = "___visited_path___"; |
|
3073 |
- var visited_key; |
|
3074 |
- if (object != void 0) { |
|
3075 |
- var iterate = function (key) { |
|
3076 |
- var newkey = key; |
|
3077 |
- if ((path != undefined) && (path !== "")) { |
|
3078 |
- newkey = path + split_char + newkey; |
|
2634 |
+ _pool[id] = factory; |
|
3079 | 2635 |
} |
3080 |
- // do not touch objects we alrdy know |
|
3081 |
- if ((obj_ref[key] != undefined) && (!objects.some(function (e) { return (e === obj_ref); }))) { |
|
3082 |
- //if (lib_call.is_def(obj_ref[key]) && (! obj_ref[key].hasOwnProperty(visited_key)) && (key !== visited_key)) { |
|
3083 |
- if (typeof obj_ref[key] === "object") { |
|
3084 |
- ret = object_merge_objects(ret, object_make_flat(obj_ref[key], newkey, filter, split_char, objects.concat(object))); |
|
3085 | 2636 |
} |
3086 |
- else if (typeof obj_ref[key] === "function") { |
|
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)); |
|
3087 | 2646 |
} |
3088 | 2647 |
else { |
3089 |
- var value = obj_ref[key]; |
|
3090 |
- ret[newkey] = value; |
|
2648 |
+ return _pool[id](parameters); |
|
3091 | 2649 |
} |
3092 | 2650 |
} |
3093 |
- }; |
|
3094 |
- visited_key = default_visited_key; |
|
3095 |
- //object[visited_key] = true; |
|
3096 |
- var obj_ref = object; |
|
3097 |
- Object.keys(object).filter(function (key) { return (filter.indexOf(key) < 0); }).forEach(iterate); |
|
3098 |
- if (typeof object.getComputedValues == "function") { |
|
3099 |
- visited_key = default_visited_key + "_" + Math.random().toString(); |
|
3100 |
- obj_ref = object.getComputedValues(); |
|
3101 |
- obj_ref[visited_key] = true; |
|
3102 |
- Object.keys(obj_ref).filter(function (key) { return (filter.indexOf(key) < 0); }).forEach(iterate); |
|
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); |
|
3103 | 2657 |
} |
2658 |
+ lib_meta.from_raw = from_raw; |
|
2659 |
+ /** |
|
2660 |
+ * @author fenris |
|
2661 |
+ */ |
|
2662 |
+ function define(id, shape_raw) { |
|
2663 |
+ register(id, function (parameters) { return from_raw(shape_raw); }); |
|
3104 | 2664 |
} |
3105 |
- else { |
|
2665 |
+ lib_meta.define = define; |
|
2666 |
+ /** |
|
2667 |
+ * @author fenris |
|
2668 |
+ */ |
|
2669 |
+ function retrieve(id) { |
|
2670 |
+ return construct(id, {}); |
|
3106 | 2671 |
} |
3107 |
- return ret; |
|
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; |
|
3108 | 2692 |
} |
3109 |
-}; |
|
3110 | 2693 |
/** |
3111 |
- * splits a flat oject into an array of objects if there are paths containing numbers, which indicates |
|
3112 |
- * that there might be an array |
|
3113 |
- * used for normalisation of imports |
|
3114 |
- * @param entry |
|
3115 |
- * @param number_replace_string |
|
3116 |
- * @param {function} [match_function] how to test key if it causes a split |
|
3117 |
- * @returns {Array} |
|
2694 |
+ * @override |
|
2695 |
+ * @author fenris |
|
3118 | 2696 |
*/ |
3119 |
-var object_split_flat_object = function (entry, number_replace_string, fab_function, match_function) { |
|
3120 |
- if (typeof (match_function) === "undefined") { |
|
3121 |
- match_function = function (key) { |
|
3122 |
- return (!key.match(/^custom/)) && key.match(/\.[0-9]+\./); |
|
3123 |
- }; |
|
2697 |
+ class_shape_boolean.prototype.to_raw = function () { |
|
2698 |
+ return { |
|
2699 |
+ "id": "boolean", |
|
2700 |
+ "parameters": { |
|
2701 |
+ "soft": this.soft |
|
3124 | 2702 |
} |
3125 |
- if (typeof (fab_function) === "undefined") { |
|
3126 |
- fab_function = function (obj, e) { |
|
3127 |
- return obj; |
|
3128 | 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; |
|
3129 | 2736 |
} |
3130 |
- if (typeof (number_replace_string) === "undefined") { |
|
3131 |
- number_replace_string = "%d"; |
|
3132 |
- } |
|
3133 |
- var ret = {}; |
|
3134 |
- var _ret = []; |
|
3135 |
- var keys = Object.keys(entry); |
|
3136 |
- var group_keys = keys.filter(match_function); |
|
3137 |
- keys.forEach(function (key) { |
|
3138 |
- var index = 0; |
|
3139 |
- var nkey = key; |
|
3140 |
- if (match_function(key)) { |
|
3141 |
- index = Number(key.match(/[0-9]+/)[0]).valueOf(); |
|
3142 |
- nkey = key.replace(/\.[0-9]+\./, "." + number_replace_string + "."); |
|
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; |
|
2750 |
+ }; |
|
2751 |
+ /** |
|
2752 |
+ * @override |
|
2753 |
+ * @author fenris |
|
2754 |
+ */ |
|
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()); |
|
3143 | 2760 |
} |
3144 |
- if (!ret[index]) { |
|
3145 |
- ret[index] = {}; |
|
2761 |
+ if ((this.max != null) && (value > this.max)) { |
|
2762 |
+ messages.push("value is over maximum of " + this.max.toString()); |
|
3146 | 2763 |
} |
3147 |
- ret[index][nkey] = entry[key]; |
|
3148 |
- }); |
|
3149 |
- keys = Object.keys(ret).sort(); |
|
3150 |
- _ret.push(ret[0]); |
|
3151 |
- for (var index = 1; index < keys.length; index++) { |
|
3152 |
- _ret.push(fab_function(ret[keys[index]], entry)); |
|
3153 | 2764 |
} |
3154 |
- _ret[0] = object_merge_objects(_ret[0], ret[0]); |
|
3155 |
- return _ret; |
|
2765 |
+ return messages; |
|
3156 | 2766 |
}; |
3157 |
-// TODO: move to exporter, it's to specific |
|
3158 |
-// to normalize the objects convert paths of a tree-like structure to a |
|
3159 |
-// key-value list with complete paths as key |
|
3160 |
-// the info object is passed to the next function as it is |
|
3161 |
-// and a flat_object (key : value) |
|
3162 |
-/*export*/ var object_make_flat_async = function (data, callback, on_progress) { |
|
3163 |
- setTimeout((function (_obj, _cb, _info) { |
|
3164 |
- return (function () { |
|
3165 |
- var ret = _obj.map(function (o) { return object_make_flat(o); }); |
|
3166 |
- _cb({ "flat_object": ret, "objects": ret, "info": _info }); |
|
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 |
|
2778 |
+ } |
|
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 |
+ })); |
|
3167 | 2790 |
}); |
3168 |
- })((typeof (data.processed.objects) === "undefined") ? data.processed.source_object : data.processed.objects, callback, data.processed.info), 0); |
|
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 |
+ } |
|
2815 |
+ /** |
|
2816 |
+ * @desc [accessor] [getter] |
|
2817 |
+ * @author fenris |
|
2818 |
+ */ |
|
2819 |
+ class_shape_float.prototype.min_get = function () { |
|
2820 |
+ return this.min; |
|
3169 | 2821 |
}; |
3170 |
-var object_flatten = function (object, paths, prefix) { |
|
3171 |
- if (prefix === void 0) { prefix = ""; } |
|
3172 |
- var ret = {}; |
|
3173 |
- var paths_ = paths.reduce(function (prev, current) { |
|
3174 |
- if (current.split(".").some(function (x) { return (x === "%d"); })) { |
|
3175 |
- var path = current.split(".%d").shift(); |
|
3176 |
- var len = object_path_read(object, path).length; |
|
3177 |
- for (var i = 0; i < len; i++) { |
|
3178 |
- prev.push(sprintf(current, [i])); |
|
2822 |
+ /** |
|
2823 |
+ * @desc [accessor] [getter] |
|
2824 |
+ * @author fenris |
|
2825 |
+ */ |
|
2826 |
+ class_shape_float.prototype.max_get = function () { |
|
2827 |
+ return this.max; |
|
2828 |
+ }; |
|
2829 |
+ /** |
|
2830 |
+ * @override |
|
2831 |
+ * @author fenris |
|
2832 |
+ */ |
|
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()); |
|
3179 | 2838 |
} |
2839 |
+ if ((this.max != null) && (value > this.max)) { |
|
2840 |
+ messages.push("value is over maximum of " + this.max.toString()); |
|
3180 | 2841 |
} |
3181 |
- else { |
|
3182 |
- prev.push(current); |
|
3183 | 2842 |
} |
3184 |
- return prev; |
|
3185 |
- }, []); |
|
3186 |
- for (var _i = 0, paths_1 = paths_; _i < paths_1.length; _i++) { |
|
3187 |
- var path = paths_1[_i]; |
|
3188 |
- var tmp = object_path_read(object, path, true); |
|
3189 |
- if ((tmp != undefined) && (tmp.toFlat != undefined)) { |
|
3190 |
- var tmp_ = tmp.toFlat([path, "."].join("")); |
|
3191 |
- for (var key in tmp_) { |
|
3192 |
- ret[key] = tmp_[key]; |
|
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 |
|
3193 | 2856 |
} |
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; |
|
3194 | 2888 |
} |
3195 |
- else { |
|
3196 |
- ret[prefix + path] = tmp; |
|
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 |
|
2898 |
+ } |
|
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; |
|
3197 | 2928 |
} |
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 |
|
3198 | 2938 |
} |
3199 |
- return ret; |
|
2939 |
+ }; |
|
3200 | 2940 |
}; |
3201 | 2941 |
/** |
3202 |
- * parse |
|
3203 |
- * @param {String} value |
|
3204 |
- * @returns {Object} |
|
2942 |
+ * @desc [implementation] |
|
2943 |
+ * @author fenris |
|
3205 | 2944 |
*/ |
3206 |
-var object_parse = function (value) { |
|
3207 |
- var content = JSON.parse(value); |
|
3208 |
- var m = { "root": content }; |
|
3209 |
- (new Mapper()).mapClasses(m); |
|
3210 |
- return m["root"]; |
|
2945 |
+ class_shape_email.prototype._show = function () { |
|
2946 |
+ var str = "email"; |
|
2947 |
+ return str; |
|
3211 | 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) { |
|
3212 | 2960 |
/** |
3213 |
- * stringify |
|
3214 |
- * |
|
3215 |
- * @description stringify object as JSON |
|
2961 |
+ * @author fenris |
|
3216 | 2962 |
*/ |
3217 |
-var object_stringify = function (object, readable) { |
|
3218 |
- if (readable === void 0) { readable = false; } |
|
3219 |
- return (JSON.stringify(object, function (key, value) { |
|
3220 |
- if ((key == "parents") && (value !== null)) { |
|
3221 |
- return null; |
|
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; |
|
3222 | 2977 |
} |
3223 |
- if (key == "changeActions") { |
|
3224 |
- return undefined; |
|
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"); |
|
3225 | 2995 |
} |
3226 |
- if (key == "observer") { |
|
3227 |
- return undefined; |
|
2996 |
+ 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 |
+ }); |
|
3228 | 3001 |
} |
3229 |
- if (key == "isMapped") { |
|
3230 |
- return undefined; |
|
3231 | 3002 |
} |
3232 |
- /* |
|
3233 |
- if (value === null) { |
|
3234 |
- return undefined; |
|
3003 |
+ return messages; |
|
3004 |
+ }; |
|
3005 |
+ /** |
|
3006 |
+ * @override |
|
3007 |
+ * @author fenris |
|
3008 |
+ */ |
|
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 |
|
3235 | 3015 |
} |
3016 |
+ }; |
|
3017 |
+ }; |
|
3018 |
+ /** |
|
3019 |
+ * @desc [implementation] |
|
3020 |
+ * @author fenris |
|
3236 | 3021 |
*/ |
3237 |
- return value; |
|
3238 |
- }, readable ? 1 : 0)); |
|
3022 |
+ class_shape_array.prototype._show = function () { |
|
3023 |
+ var str = "array"; |
|
3024 |
+ str += "<" + instance_show(this.shape_element) + ">"; |
|
3025 |
+ return str; |
|
3239 | 3026 |
}; |
3240 |
-var lib_object; |
|
3241 |
-(function (lib_object) { |
|
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 |
+ })); |
|
3037 |
+ }); |
|
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) { |
|
3242 | 3042 |
/** |
3243 |
- * @author frac |
|
3043 |
+ * @author fenris |
|
3244 | 3044 |
*/ |
3245 |
- var class_relation = (function () { |
|
3045 |
+ var class_shape_object = (function (_super) { |
|
3046 |
+ __extends(class_shape_object, _super); |
|
3246 | 3047 |
/** |
3247 |
- * @author frac |
|
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(); |
|
3057 |
+ }); |
|
3058 |
+ } |
|
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 |
+ } |
|
3068 |
+ /** |
|
3069 |
+ * @desc [accessor] [getter] |
|
3070 |
+ * @author fenris |
|
3071 |
+ */ |
|
3072 |
+ class_shape_object.prototype.fields_get = function () { |
|
3073 |
+ return this.fields; |
|
3074 |
+ }; |
|
3075 |
+ /** |
|
3076 |
+ * @override |
|
3077 |
+ * @author fenris |
|
3078 |
+ * @todo check for superfluous fields? |
|
3079 |
+ */ |
|
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; |
|
3089 |
+ }; |
|
3090 |
+ /** |
|
3091 |
+ * @override |
|
3092 |
+ * @author fenris |
|
3093 |
+ */ |
|
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 |
+ }) |
|
3106 |
+ } |
|
3107 |
+ }; |
|
3108 |
+ }; |
|
3109 |
+ /** |
|
3110 |
+ * @desc [implementation] |
|
3111 |
+ * @author fenris |
|
3248 | 3112 |
*/ |
3249 |
- /*protected*/ function class_relation(id, parameters) { |
|
3250 |
- this.id = id; |
|
3251 |
- this.symbol = lib_object.fetch(parameters, "symbol", null, 1); |
|
3252 |
- this.name = lib_object.fetch(parameters, "name", null, 1); |
|
3253 |
- this.predicate = lib_object.fetch(parameters, "predicate", null, 2); |
|
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; |
|
3118 |
+ }; |
|
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 |
|
3134 |
+ }; |
|
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 = {})); |
|
3141 |
+var lib_meta; |
|
3142 |
+(function (lib_meta) { |
|
3143 |
+ /** |
|
3144 |
+ * @author fenris |
|
3145 |
+ */ |
|
3146 |
+ var class_shape_date = (function (_super) { |
|
3147 |
+ __extends(class_shape_date, _super); |
|
3148 |
+ /** |
|
3149 |
+ * @author fenris |
|
3150 |
+ */ |
|
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; |
|
3158 |
+ } |
|
3159 |
+ /** |
|
3160 |
+ * @override |
|
3161 |
+ * @author fenris |
|
3162 |
+ */ |
|
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"); |
|
3168 |
+ } |
|
3169 |
+ } |
|
3170 |
+ return messages; |
|
3171 |
+ }; |
|
3172 |
+ /** |
|
3173 |
+ * @override |
|
3174 |
+ * @author fenris |
|
3175 |
+ */ |
|
3176 |
+ class_shape_date.prototype.to_raw = function () { |
|
3177 |
+ return { |
|
3178 |
+ "id": "date", |
|
3179 |
+ "parameters": { |
|
3180 |
+ "soft": this.soft |
|
3181 |
+ } |
|
3182 |
+ }; |
|
3183 |
+ }; |
|
3184 |
+ /** |
|
3185 |
+ * @desc [implementation] |
|
3186 |
+ * @author fenris |
|
3187 |
+ */ |
|
3188 |
+ class_shape_date.prototype._show = function () { |
|
3189 |
+ var str = "date"; |
|
3190 |
+ return str; |
|
3191 |
+ }; |
|
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 |
+ })); |
|
3199 |
+ }); |
|
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")); |
|
3221 |
+ } |
|
3222 |
+ else { |
|
3223 |
+ defaultvalue = options[0].value; |
|
3224 |
+ } |
|
3225 |
+ } |
|
3226 |
+ } |
|
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 |
+ } |
|
3236 |
+ /** |
|
3237 |
+ * @desc [accessor] [getter] |
|
3238 |
+ * @author fenris |
|
3239 |
+ */ |
|
3240 |
+ class_shape_enumeration.prototype.shape_option_get = function () { |
|
3241 |
+ return this.shape_option; |
|
3242 |
+ }; |
|
3243 |
+ /** |
|
3244 |
+ * @desc [accessor] [getter] |
|
3245 |
+ * @author fenris |
|
3246 |
+ */ |
|
3247 |
+ class_shape_enumeration.prototype.options_get = function () { |
|
3248 |
+ return this.options; |
|
3249 |
+ }; |
|
3250 |
+ /** |
|
3251 |
+ * @override |
|
3252 |
+ * @author fenris |
|
3253 |
+ */ |
|
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 |
+ } |
|
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"); |
|
3264 |
+ } |
|
3265 |
+ } |
|
3266 |
+ } |
|
3267 |
+ return messages; |
|
3268 |
+ }; |
|
3269 |
+ /** |
|
3270 |
+ * @override |
|
3271 |
+ * @author fenris |
|
3272 |
+ */ |
|
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 |
+ }; |
|
3288 |
+ /** |
|
3289 |
+ * @desc [implementation] |
|
3290 |
+ * @author fenris |
|
3291 |
+ */ |
|
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_ + "]"; |
|
3300 |
+ } |
|
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) { |
|
3319 |
+ /** |
|
3320 |
+ * @author fenris |
|
3321 |
+ */ |
|
3322 |
+ var class_shape_map = (function (_super) { |
|
3323 |
+ __extends(class_shape_map, _super); |
|
3324 |
+ /** |
|
3325 |
+ * @author fenris |
|
3326 |
+ */ |
|
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; |
|
3336 |
+ return _this; |
|
3337 |
+ } |
|
3338 |
+ /** |
|
3339 |
+ * @desc [accessor] [getter] |
|
3340 |
+ * @author fenris |
|
3341 |
+ */ |
|
3342 |
+ class_shape_map.prototype.shape_key_get = function () { |
|
3343 |
+ return this.shape_key; |
|
3344 |
+ }; |
|
3345 |
+ /** |
|
3346 |
+ * @desc [accessor] [getter] |
|
3347 |
+ * @author fenris |
|
3348 |
+ */ |
|
3349 |
+ class_shape_map.prototype.shape_value_get = function () { |
|
3350 |
+ return this.shape_value; |
|
3351 |
+ }; |
|
3352 |
+ /** |
|
3353 |
+ * @override |
|
3354 |
+ * @author fenris |
|
3355 |
+ */ |
|
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 |
+ } |
|
3370 |
+ } |
|
3371 |
+ return messages; |
|
3372 |
+ }; |
|
3373 |
+ /** |
|
3374 |
+ * @override |
|
3375 |
+ * @author fenris |
|
3376 |
+ */ |
|
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 |
+ }; |
|
3386 |
+ }; |
|
3387 |
+ /** |
|
3388 |
+ * @desc [implementation] |
|
3389 |
+ * @author fenris |
|
3390 |
+ */ |
|
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) { |
|
3413 |
+ /** |
|
3414 |
+ * @author fenris |
|
3415 |
+ * @todo use a treemap-function (but first make one :P) |
|
3416 |
+ */ |
|
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 |
+ } |
|
3460 |
+ } |
|
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 |
+/** |
|
3470 |
+ * @desc makes a valid |
|
3471 |
+ */ |
|
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 |
+ })); |
|
3594 |
+ }; |
|
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 |
+ })); |
|
3606 |
+ }; |
|
3607 |
+ return exports; |
|
3608 |
+})(); |
|
3609 |
+///<reference path="../../base/build/logic-decl.d.ts"/> |
|
3610 |
+var lib_string; |
|
3611 |
+(function (lib_string) { |
|
3612 |
+ /** |
|
3613 |
+ * @author frac |
|
3614 |
+ */ |
|
3615 |
+ var hexdigits = 4; |
|
3616 |
+ /** |
|
3617 |
+ * @author frac |
|
3618 |
+ */ |
|
3619 |
+ var index_max = 1 << (4 * hexdigits); |
|
3620 |
+ /** |
|
3621 |
+ * @author frac |
|
3622 |
+ */ |
|
3623 |
+ var index_is = 0; |
|
3624 |
+ /** |
|
3625 |
+ * @author neuc,frac |
|
3626 |
+ */ |
|
3627 |
+ function empty(str) { |
|
3628 |
+ var tmp = str.trim(); |
|
3629 |
+ return (tmp === ""); |
|
3630 |
+ } |
|
3631 |
+ lib_string.empty = empty; |
|
3632 |
+ /** |
|
3633 |
+ * @desc returns a unique string |
|
3634 |
+ * @param {string} prefix an optional prefix for the generated string |
|
3635 |
+ * @return {string} |
|
3636 |
+ * @author frac |
|
3637 |
+ */ |
|
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 |
+ } |
|
3646 |
+ } |
|
3647 |
+ lib_string.generate = generate; |
|
3648 |
+ /** |
|
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 |
|
3654 |
+ */ |
|
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; |
|
3665 |
+ /** |
|
3666 |
+ * @desc concats a given word with itself n times |
|
3667 |
+ * @param {string} word |
|
3668 |
+ * @param {int} |
|
3669 |
+ * @return {string} |
|
3670 |
+ * @author frac |
|
3671 |
+ */ |
|
3672 |
+ function repeat(word, count) { |
|
3673 |
+ return ((count == 0) ? "" : (word + repeat(word, count - 1))); |
|
3674 |
+ } |
|
3675 |
+ lib_string.repeat = repeat; |
|
3676 |
+ /** |
|
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 |
|
3684 |
+ */ |
|
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; |
|
3699 |
+ /** |
|
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 |
|
3705 |
+ */ |
|
3706 |
+ function contains(chain, part) { |
|
3707 |
+ if (typeof (chain) !== "string") |
|
3708 |
+ return false; |
|
3709 |
+ return (chain.indexOf(part) >= 0); |
|
3710 |
+ } |
|
3711 |
+ lib_string.contains = contains; |
|
3712 |
+ /** |
|
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 |
|
3718 |
+ */ |
|
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; |
|
3738 |
+ /** |
|
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 |
|
3744 |
+ */ |
|
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))); |
|
3760 |
+ } |
|
3761 |
+ } |
|
3762 |
+ })(chain.length, part.length)); |
|
3763 |
+ } |
|
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 |
+ } |
|
3779 |
+ } while (pos >= 0); |
|
3780 |
+ return cnt - 1; |
|
3781 |
+ } |
|
3782 |
+ lib_string.count_occourrences = count_occourrences; |
|
3783 |
+ ; |
|
3784 |
+ /** |
|
3785 |
+ * @author fenris |
|
3786 |
+ */ |
|
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; |
|
3794 |
+ } |
|
3795 |
+ lib_string.stance = stance; |
|
3796 |
+})(lib_string || (lib_string = {})); |
|
3797 |
+/** |
|
3798 |
+ * @desc adapters for old syntax |
|
3799 |
+ */ |
|
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 |
|
3822 |
+ }; |
|
3823 |
+ } |
|
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; |
|
3831 |
+ } |
|
3832 |
+ return true; |
|
3833 |
+ } |
|
3834 |
+ function string_fill(str, char, len, left) { |
|
3835 |
+ while (str.length < len) { |
|
3836 |
+ if (left) { |
|
3837 |
+ str += char; |
|
3838 |
+ } |
|
3839 |
+ else { |
|
3840 |
+ str = char + str; |
|
3841 |
+ } |
|
3842 |
+ } |
|
3843 |
+ return str; |
|
3844 |
+ } |
|
3845 |
+ /** |
|
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 {{}} |
|
3873 |
+ */ |
|
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; |
|
3900 |
+ }; |
|
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; |
|
3915 |
+ }; |
|
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; |
|
3930 |
+ }; |
|
3931 |
+ known_params["E"] = function (format, arg) { |
|
3932 |
+ return known_params["e"](format, arg).toUpperCase(); |
|
3933 |
+ }; |
|
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; |
|
3941 |
+ } |
|
3942 |
+ else { |
|
3943 |
+ return tmpe; |
|
3944 |
+ } |
|
3945 |
+ }; |
|
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)); |
|
3961 |
+ }; |
|
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)); |
|
3967 |
+ }; |
|
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(); |
|
3973 |
+ }; |
|
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]; |
|
3982 |
+ } |
|
3983 |
+ else { |
|
3984 |
+ console.warn(make_err(format, arg, "number|string") + " and if string it needs to have the length of 1!"); |
|
3985 |
+ } |
|
3986 |
+ return known_params["s"](format, tmp); |
|
3987 |
+ }; |
|
3988 |
+ known_params["n"] = function () { |
|
3989 |
+ return ""; |
|
3990 |
+ }; |
|
3991 |
+ var decompose = function (chain, regexp) { |
|
3992 |
+ var result = regexp.exec(chain); |
|
3993 |
+ if (result == null) { |
|
3994 |
+ return null; |
|
3995 |
+ } |
|
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 }; |
|
4000 |
+ } |
|
4001 |
+ }; |
|
4002 |
+ /** |
|
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} |
|
4007 |
+ */ |
|
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; |
|
4019 |
+ } |
|
4020 |
+ else { |
|
4021 |
+ var arg; |
|
4022 |
+ var rest; |
|
4023 |
+ if (args.length > 0) { |
|
4024 |
+ arg = args[0]; |
|
4025 |
+ rest = args.slice(1); |
|
4026 |
+ } |
|
4027 |
+ else { |
|
4028 |
+ console.warn("[sprintf] out of arguments while formatting '" + original + "'"); |
|
4029 |
+ arg = null; |
|
4030 |
+ rest = []; |
|
4031 |
+ return input; |
|
4032 |
+ } |
|
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)); |
|
4037 |
+ } |
|
4038 |
+ }; |
|
4039 |
+ /** |
|
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} |
|
4044 |
+ */ |
|
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; |
|
4052 |
+/** |
|
4053 |
+ * @author neuc |
|
4054 |
+ */ |
|
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; |
|
4096 |
+ } |
|
4097 |
+ return nr; |
|
4098 |
+ } |
|
4099 |
+ function set_currentDate(date) { |
|
4100 |
+ currentDate = date; |
|
4101 |
+ } |
|
4102 |
+ strftime.set_currentDate = set_currentDate; |
|
4103 |
+ function parse(format, date) { |
|
4104 |
+ if (!date) { |
|
4105 |
+ date = currentDate; |
|
4106 |
+ } |
|
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)); |
|
4112 |
+ } |
|
4113 |
+ return ret; |
|
4114 |
+ } |
|
4115 |
+ strftime.parse = parse; |
|
4116 |
+ function parse_segment(segment, date) { |
|
4117 |
+ if (!date) { |
|
4118 |
+ date = currentDate; |
|
4119 |
+ } |
|
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 |
+ }, |
|
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 + "'"; |
|
4165 |
+ } |
|
4166 |
+ return hm_segments[segment](); |
|
4167 |
+ } |
|
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 |
+ } |
|
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 "Ø"; |
|
4184 |
+ } |
|
4185 |
+ } |
|
4186 |
+ } |
|
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(); |
|
4193 |
+ } |
|
4194 |
+ else { |
|
4195 |
+ return strftime.parse(conf.format_string, date); |
|
4196 |
+ } |
|
4197 |
+} |
|
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 |
+ }); |
|
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); |
|
4227 |
+ } |
|
4228 |
+ }; |
|
4229 |
+ _loggers[prefix] = { |
|
4230 |
+ "logger": logger, |
|
4231 |
+ "log": log |
|
4232 |
+ }; |
|
4233 |
+ return logger; |
|
4234 |
+ }; |
|
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); |
|
4243 |
+ }); |
|
4244 |
+ return logs.map(function (x, i, a) { |
|
4245 |
+ return x.message; |
|
4246 |
+ }); |
|
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]); |
|
4256 |
+ } |
|
4257 |
+ else { |
|
4258 |
+ msg.push(JSON.stringify(arguments[i])); |
|
4259 |
+ } |
|
4260 |
+ } |
|
4261 |
+ var obj = { |
|
4262 |
+ txt: msg.join("\t"), |
|
4263 |
+ arg: arguments |
|
4264 |
+ }; |
|
4265 |
+ log(obj, lvl); |
|
4266 |
+ next(); |
|
4267 |
+ }; |
|
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); |
|
4284 |
+ */ |
|
4285 |
+ } |
|
4286 |
+ /* |
|
4287 |
+ { |
|
4288 |
+ make_logger["send_log"] = function(){ |
|
4289 |
+ eml_log( |
|
4290 |
+ function () { |
|
4291 |
+ alert("fehlerbericht wurde gesendet!"); |
|
3254 | 4292 |
} |
3255 |
- /** |
|
3256 |
- * @author frac |
|
3257 |
- */ |
|
3258 |
- class_relation.prototype.check = function (value, reference) { |
|
3259 |
- return this.predicate(value, reference); |
|
4293 |
+ ); |
|
3260 | 4294 |
}; |
3261 |
- /** |
|
3262 |
- * @author frac |
|
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 |
+ } |
|
4303 |
+ if (global_config.report_error) { |
|
4304 |
+ make_logger["send_log"](); |
|
4305 |
+ } |
|
4306 |
+ } |
|
4307 |
+ ); |
|
4308 |
+ } |
|
3263 | 4309 |
*/ |
3264 |
- class_relation.prototype.id_get = function () { |
|
3265 |
- return this.id; |
|
4310 |
+ } |
|
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 __()); |
|
3266 | 4321 |
}; |
4322 |
+})(); |
|
4323 |
+///<reference path="../../base/build/logic-decl.d.ts"/> |
|
4324 |
+///<reference path="../../string/build/logic-decl.d.ts"/> |
|
3267 | 4325 |
/** |
3268 |
- * @author frac |
|
4326 |
+ * @author fenris |
|
3269 | 4327 |
*/ |
3270 |
- class_relation.prototype.symbol_get = function () { |
|
3271 |
- return this.symbol; |
|
3272 |
- }; |
|
4328 |
+var lib_xml; |
|
4329 |
+(function (lib_xml) { |
|
3273 | 4330 |
/** |
3274 |
- * @author frac |
|
4331 |
+ * @author fenris |
|
3275 | 4332 |
*/ |
3276 |
- class_relation.prototype.name_get = function () { |
|
3277 |
- return this.name; |
|
3278 |
- }; |
|
4333 |
+ var class_node = (function () { |
|
4334 |
+ function class_node() { |
|
4335 |
+ } |
|
4336 |
+ return class_node; |
|
4337 |
+ }()); |
|
4338 |
+ lib_xml.class_node = class_node; |
|
3279 | 4339 |
/** |
3280 |
- * @author frac |
|
4340 |
+ * @author fenris |
|
3281 | 4341 |
*/ |
3282 |
- class_relation.pool = function () { |
|
3283 |
- return { |
|
3284 |
- "eq": { |
|
3285 |
- "symbol": "=", |
|
3286 |
- "name": "gleich", |
|
3287 |
- "predicate": function (value, reference) { return (value == reference); } |
|
3288 |
- }, |
|
3289 |
- "ne": { |
|
3290 |
- "symbol": "≠", |
|
3291 |
- "name": "ungleich", |
|
3292 |
- "predicate": function (value, reference) { return (value != reference); } |
|
3293 |
- }, |
|
3294 |
- "gt": { |
|
3295 |
- "symbol": ">", |
|
3296 |
- "name": "größer", |
|
3297 |
- "predicate": function (value, reference) { return (value > reference); } |
|
3298 |
- }, |
|
3299 |
- "ge": { |
|
3300 |
- "symbol": "≥", |
|
3301 |
- "name": "größer oder gleich", |
|
3302 |
- "predicate": function (value, reference) { return (value >= reference); } |
|
3303 |
- }, |
|
3304 |
- "lt": { |
|
3305 |
- "symbol": "<", |
|
3306 |
- "name": "kleiner", |
|
3307 |
- "predicate": function (value, reference) { return (value < reference); } |
|
3308 |
- }, |
|
3309 |
- "le": { |
|
3310 |
- "symbol": "≤", |
|
3311 |
- "name": "kleiner oder gleich", |
|
3312 |
- "predicate": function (value, reference) { return (value <= reference); } |
|
3313 |
- } |
|
3314 |
- }; |
|
3315 |
- }; |
|
4342 |
+ var class_node_text = (function (_super) { |
|
4343 |
+ __extends(class_node_text, _super); |
|
3316 | 4344 |
/** |
3317 |
- * @author frac |
|
4345 |
+ * @author fenris |
|
3318 | 4346 |
*/ |
3319 |
- class_relation.get = function (id) { |
|
3320 |
- var parameters = lib_object.fetch(this.pool(), id, null, 2); |
|
3321 |
- return (new class_relation(id, parameters)); |
|
3322 |
- }; |
|
4347 |
+ function class_node_text(content) { |
|
4348 |
+ var _this = _super.call(this) || this; |
|
4349 |
+ _this.content = content; |
|
4350 |
+ return _this; |
|
4351 |
+ } |
|
3323 | 4352 |
/** |
3324 |
- * @author frac |
|
4353 |
+ * @author fenris |
|
3325 | 4354 |
*/ |
3326 |
- class_relation.available = function () { |
|
3327 |
- return Object.keys(this.pool()); |
|
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"); |
|
3328 | 4358 |
}; |
3329 |
- return class_relation; |
|
3330 |
- }()); |
|
3331 |
- lib_object.class_relation = class_relation; |
|
4359 |
+ return class_node_text; |
|
4360 |
+ }(class_node)); |
|
4361 |
+ lib_xml.class_node_text = class_node_text; |
|
3332 | 4362 |
/** |
3333 |
- * @author frac |
|
4363 |
+ * @author fenris |
|
3334 | 4364 |
*/ |
3335 |
- var class_filtrationitem = (function () { |
|
4365 |
+ var class_node_comment = (function (_super) { |
|
4366 |
+ __extends(class_node_comment, _super); |
|
3336 | 4367 |
/** |
3337 |
- * @author frac |
|
4368 |
+ * @author fenris |
|
3338 | 4369 |
*/ |
3339 |
- function class_filtrationitem(parameters) { |
|
3340 |
- this.extract = lib_object.fetch(parameters, "extract", null, 2); |
|
3341 |
- this.relation = lib_object.fetch(parameters, "relation", null, 2); |
|
3342 |
- this.reference = lib_object.fetch(parameters, "reference", null, 2); |
|
4370 |
+ function class_node_comment(content) { |
|
4371 |
+ var _this = _super.call(this) || this; |
|
4372 |
+ _this.content = content; |
|
4373 |
+ return _this; |
|
3343 | 4374 |
} |
3344 | 4375 |
/** |
3345 |
- * @author frac |
|
4376 |
+ * @author fenris |
|
3346 | 4377 |
*/ |
3347 |
- class_filtrationitem.prototype.check = function (dataset) { |
|
3348 |
- var value = this.extract(dataset); |
|
3349 |
- return this.relation.check(value, this.reference); |
|
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"); |
|
3350 | 4381 |
}; |
3351 |
- return class_filtrationitem; |
|
3352 |
- }()); |
|
3353 |
- lib_object.class_filtrationitem = class_filtrationitem; |
|
4382 |
+ return class_node_comment; |
|
4383 |
+ }(class_node)); |
|
4384 |
+ lib_xml.class_node_comment = class_node_comment; |
|
3354 | 4385 |
/** |
3355 |
- * @author frac |
|
4386 |
+ * @author fenris |
|
3356 | 4387 |
*/ |
3357 |
- var class_filtration = (function () { |
|
4388 |
+ var class_node_complex = (function (_super) { |
|
4389 |
+ __extends(class_node_complex, _super); |
|
3358 | 4390 |
/** |
3359 |
- * @author frac |
|
4391 |
+ * @author fenris |
|
3360 | 4392 |
*/ |
3361 |
- function class_filtration(clauses) { |
|
3362 |
- this.clauses = clauses; |
|
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; |
|
3363 | 4401 |
} |
3364 | 4402 |
/** |
3365 |
- * @author frac |
|
3366 |
- */ |
|
3367 |
- class_filtration.prototype.check = function (dataset) { |
|
3368 |
- return (this.clauses.some(function (clause) { return clause.every(function (literal) { return literal.check(dataset); }); })); |
|
3369 |
- }; |
|
3370 |
- /** |
|
3371 |
- * @author frac |
|
4403 |
+ * @author fenris |
|
3372 | 4404 |
*/ |
3373 |
- class_filtration.prototype.use = function (datasets) { |
|
4405 |
+ class_node_complex.prototype.compile = function (depth) { |
|
3374 | 4406 |
var _this = this; |
3375 |
- return datasets.filter(function (dataset) { return _this.check(dataset); }); |
|
3376 |
- }; |
|
3377 |
- /** |
|
3378 |
- * @author frac |
|
3379 |
- */ |
|
3380 |
- class_filtration.test = function () { |
|
3381 |
- var filtration = new class_filtration([ |
|
3382 |
- [ |
|
3383 |
- new class_filtrationitem({ |
|
3384 |
- "extract": function (dataset) { return dataset["qux"]; }, |
|
3385 |
- "relation": class_relation.get("eq"), |
|
3386 |
- "reference": "a" |
|
3387 |
- }), |
|
3388 |
- ], |
|
3389 |
- [ |
|
3390 |
- new class_filtrationitem({ |
|
3391 |
- "extract": function (dataset) { return dataset["qux"]; }, |
|
3392 |
- "relation": class_relation.get("eq"), |
|
3393 |
- "reference": "c" |
|
3394 |
- }), |
|
3395 |
- ], |
|
3396 |
- ]); |
|
3397 |
- var datasets = pivot_demo_data0; |
|
3398 |
- var datasets_ = filtration.use(datasets); |
|
3399 |
- console.info(datasets); |
|
3400 |
- console.info(datasets_); |
|
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"); |
|
4413 |
+ return output; |
|
3401 | 4414 |
}; |
3402 |
- return class_filtration; |
|
3403 |
- }()); |
|
3404 |
- lib_object.class_filtration = class_filtration; |
|
3405 |
-})(lib_object || (lib_object = {})); |
|
4415 |
+ return class_node_complex; |
|
4416 |
+ }(class_node)); |
|
4417 |
+ lib_xml.class_node_complex = class_node_complex; |
|
4418 |
+})(lib_xml || (lib_xml = {})); |
|
3406 | 4419 |
var __extends = (this && this.__extends) || function (d, b) { |
3407 | 4420 |
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; |
3408 | 4421 |
function __() { this.constructor = d; } |
... | ... |
@@ -3425,7 +4438,7 @@ var lib_path; |
3425 | 4438 |
var class_step_stay = (function (_super) { |
3426 | 4439 |
__extends(class_step_stay, _super); |
3427 | 4440 |
function class_step_stay() { |
3428 |
- _super.apply(this, arguments); |
|
4441 |
+ return _super !== null && _super.apply(this, arguments) || this; |
|
3429 | 4442 |
} |
3430 | 4443 |
/** |
3431 | 4444 |
* @author fenris |
... | ... |
@@ -3448,7 +4461,7 @@ var lib_path; |
3448 | 4461 |
var class_step_back = (function (_super) { |
3449 | 4462 |
__extends(class_step_back, _super); |
3450 | 4463 |
function class_step_back() { |
3451 |
- _super.apply(this, arguments); |
|
4464 |
+ return _super !== null && _super.apply(this, arguments) || this; |
|
3452 | 4465 |
} |
3453 | 4466 |
/** |
3454 | 4467 |
* @author fenris |
... | ... |
@@ -3474,8 +4487,9 @@ var lib_path; |
3474 | 4487 |
* @author fenris |
3475 | 4488 |
*/ |
3476 | 4489 |
function class_step_regular(name) { |
3477 |
- _super.call(this); |
|
3478 |
- this.name = name; |
|
4490 |
+ var _this = _super.call(this) || this; |
|
4491 |
+ _this.name = name; |
|
4492 |
+ return _this; |
|
3479 | 4493 |
} |
3480 | 4494 |
/** |
3481 | 4495 |
* @author fenris |
... | ... |
@@ -3510,7 +4524,7 @@ var lib_path; |
3510 | 4524 |
} |
3511 | 4525 |
lib_path.step_read = step_read; |
3512 | 4526 |
})(lib_path || (lib_path = {})); |
3513 |
-///<reference path="../../../plankton/object/build/logic.d.ts"/> |
|
4527 |
+///<reference path="../../../plankton/object/build/logic-decl.d.ts"/> |
|
3514 | 4528 |
var lib_path; |
3515 | 4529 |
(function (lib_path) { |
3516 | 4530 |
/** |
... | ... |
@@ -3528,9 +4542,10 @@ var lib_path; |
3528 | 4542 |
* @author fenris |
3529 | 4543 |
*/ |
3530 | 4544 |
class_chain.splitter = function (system) { |
3531 |
- if (system === void 0) { system = "unix"; } |
|
4545 |
+ if (system === void 0) { system = "linux"; } |
|
3532 | 4546 |
return (object_fetch({ |
3533 |
- "unix": "/", |
|
4547 |
+ "linux": "/", |
|
4548 |
+ "bsd": "/", |
|
3534 | 4549 |
"win": "\\" |
3535 | 4550 |
}, system, "/", 2)); |
3536 | 4551 |
}; |
... | ... |
@@ -3569,7 +4584,8 @@ var lib_path; |
3569 | 4584 |
}; |
3570 | 4585 |
while (true) { |
3571 | 4586 |
var state_1 = _loop_1(); |
3572 |
- if (state_1 === "break") break; |
|
4587 |
+ if (state_1 === "break") |
|
4588 |
+ break; |
|
3573 | 4589 |
} |
3574 | 4590 |
} |
3575 | 4591 |
return (new class_chain(steps)); |
... | ... |
@@ -3596,7 +4612,7 @@ var lib_path; |
3596 | 4612 |
* @author fenris |
3597 | 4613 |
*/ |
3598 | 4614 |
class_chain.prototype.as_string = function (system) { |
3599 |
- if (system === void 0) { system = "unix"; } |
|
4615 |
+ if (system === void 0) { system = "linux"; } |
|
3600 | 4616 |
var splitter = class_chain.splitter(system); |
3601 | 4617 |
return ((this.steps.length == 0) ? ("." + splitter) : this.steps.map(function (step) { return (step.toString() + splitter); }).join("")); |
3602 | 4618 |
}; |
... | ... |
@@ -3613,7 +4629,7 @@ var lib_path; |
3613 | 4629 |
* @author fenris |
3614 | 4630 |
*/ |
3615 | 4631 |
function chain_read(str, system) { |
3616 |
- if (system === void 0) { system = "unix"; } |
|
4632 |
+ if (system === void 0) { system = "linux"; } |
|
3617 | 4633 |
var splitter = class_chain.splitter(system); |
3618 | 4634 |
var parts = str.split(splitter); |
3619 | 4635 |
if (parts[parts.length - 1] == "") |
... | ... |
@@ -3622,7 +4638,7 @@ var lib_path; |
3622 | 4638 |
} |
3623 | 4639 |
lib_path.chain_read = chain_read; |
3624 | 4640 |
})(lib_path || (lib_path = {})); |
3625 |
-///<reference path="../../../plankton/object/build/logic.d.ts"/> |
|
4641 |
+///<reference path="../../../plankton/object/build/logic-decl.d.ts"/> |
|
3626 | 4642 |
var lib_path; |
3627 | 4643 |
(function (lib_path) { |
3628 | 4644 |
/** |
... | ... |
@@ -3640,12 +4656,20 @@ var lib_path; |
3640 | 4656 |
* @author fenris |
3641 | 4657 |
*/ |
3642 | 4658 |
class_location.anchorpattern = function (system) { |
3643 |
- if (system === void 0) { system = "unix"; } |
|
4659 |
+ if (system === void 0) { system = "linux"; } |
|
3644 | 4660 |
return (object_fetch({ |
3645 |
- "unix": new RegExp("/"), |
|
4661 |
+ "linux": new RegExp("/"), |
|
4662 |
+ "bsd": new RegExp("/"), |
|
3646 | 4663 |
"win": new RegExp("[A-Z]:\\\\>") |
3647 | 4664 |
}, system, new RegExp("/"), 1)); |
3648 | 4665 |
}; |
4666 |
+ /** |
|
4667 |
+ * @desc [accessor] |
|
4668 |
+ * @author fenris |
|
4669 |
+ */ |
|
4670 |
+ class_location.prototype.is_absolute = function () { |
|
4671 |
+ return (this.anchor != null); |
|
4672 |
+ }; |
|
3649 | 4673 |
/** |
3650 | 4674 |
* @author fenris |
3651 | 4675 |
*/ |
... | ... |
@@ -3658,6 +4682,18 @@ var lib_path; |
3658 | 4682 |
class_location.prototype.extend = function (chain) { |
3659 | 4683 |
return (new class_location(this.anchor, this.chain.extend(chain))); |
3660 | 4684 |
}; |
4685 |
+ /** |
|
4686 |
+ * @desc [accessor] |
|
4687 |
+ * @author fenris |
|
4688 |
+ */ |
|
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 |
+ } |
|
4696 |
+ }; |
|
3661 | 4697 |
/** |
3662 | 4698 |
* @author fenris |
3663 | 4699 |
*/ |
... | ... |
@@ -3686,7 +4722,7 @@ var lib_path; |
3686 | 4722 |
* @author fenris |
3687 | 4723 |
*/ |
3688 | 4724 |
class_location.prototype.as_string = function (system) { |
3689 |
- if (system === void 0) { system = "unix"; } |
|
4725 |
+ if (system === void 0) { system = "linux"; } |
|
3690 | 4726 |
return (((this.anchor != null) ? this.anchor : "") + this.chain.as_string(system)); |
3691 | 4727 |
}; |
3692 | 4728 |
/** |
... | ... |
@@ -3706,9 +4742,10 @@ var lib_path; |
3706 | 4742 |
* @author fenris |
3707 | 4743 |
*/ |
3708 | 4744 |
class_location.tempfolder = function (system) { |
3709 |
- if (system === void 0) { system = "unix"; } |
|
4745 |
+ if (system === void 0) { system = "linux"; } |
|
3710 | 4746 |
return (object_fetch({ |
3711 |
- "unix": new class_location("/", new lib_path.class_chain([new lib_path.class_step_regular("tmp")])), |
|
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")])), |
|
3712 | 4749 |
"win": new class_location(null, new lib_path.class_chain([new lib_path.class_step_regular("%TEMP%")])) |
3713 | 4750 |
}, system, null, 2)); |
3714 | 4751 |
}; |
... | ... |
@@ -3719,7 +4756,7 @@ var lib_path; |
3719 | 4756 |
* @author fenris |
3720 | 4757 |
*/ |
3721 | 4758 |
function location_read(str, system) { |
3722 |
- if (system === void 0) { system = "unix"; } |
|
4759 |
+ if (system === void 0) { system = "linux"; } |
|
3723 | 4760 |
var regexp = class_location.anchorpattern(system); |
3724 | 4761 |
var matching = regexp.exec(str); |
3725 | 4762 |
if ((matching == null) || (matching.index > 0)) { |
... | ... |
@@ -3756,11 +4793,18 @@ var lib_path; |
3756 | 4793 |
class_filepointer.prototype.foo = function (filepointer) { |
3757 | 4794 |
return (new class_filepointer(this.location.extend(filepointer.location.chain), filepointer.filename)); |
3758 | 4795 |
}; |
4796 |
+ /** |
|
4797 |
+ * @desc [accessor] |
|
4798 |
+ * @author fenris |
|
4799 |
+ */ |
|
4800 |
+ class_filepointer.prototype.relocate = function (location) { |
|
4801 |
+ return (new class_filepointer(this.location.relocate(location), this.filename)); |
|
4802 |
+ }; |
|
3759 | 4803 |
/** |
3760 | 4804 |
* @author fenris |
3761 | 4805 |
*/ |
3762 | 4806 |
class_filepointer.prototype.as_string = function (system) { |
3763 |
- if (system === void 0) { system = "unix"; } |
|
4807 |
+ if (system === void 0) { system = "linux"; } |
|
3764 | 4808 |
return (this.location.as_string(system) /* + "/"*/ + ((this.filename == null) ? "" : this.filename)); |
3765 | 4809 |
}; |
3766 | 4810 |
/** |
... | ... |
@@ -3776,7 +4820,7 @@ var lib_path; |
3776 | 4820 |
* @author fenris |
3777 | 4821 |
*/ |
3778 | 4822 |
function filepointer_read(str, system) { |
3779 |
- if (system === void 0) { system = "unix"; } |
|
4823 |
+ if (system === void 0) { system = "linux"; } |
|
3780 | 4824 |
var splitter = lib_path.class_chain.splitter(system); |
3781 | 4825 |
var parts = str.split(splitter); |
3782 | 4826 |
var last = parts[parts.length - 1]; |
... | ... |
@@ -3789,41 +4833,66 @@ var lib_path; |
3789 | 4833 |
} |
3790 | 4834 |
lib_path.filepointer_read = filepointer_read; |
3791 | 4835 |
})(lib_path || (lib_path = {})); |
3792 |
-///<reference path="../../base/build/logic.d.ts"/> |
|
3793 |
-///<reference path="../../call/build/logic.d.ts"/> |
|
4836 |
+///<reference path="../../call/build/logic-decl.d.ts"/> |
|
3794 | 4837 |
var lib_file; |
3795 | 4838 |
(function (lib_file) { |
3796 | 4839 |
/** |
3797 | 4840 |
* @author fenris |
3798 |
- * @todo move to a dedicated lib (e.g. "http", "transport", etc.) |
|
3799 | 4841 |
*/ |
3800 |
- function ajax(_a) { |
|
3801 |
- var target = _a["target"], _b = _a["data"], data /*: {[key : string] : string}*/ = _b === void 0 ? null : _b, _c = _a["method"], method /* : string*/ = _c === void 0 ? "GET" : _c; |
|
3802 |
- method = method.toLowerCase(); |
|
3803 |
- return (function (resolve, reject) { |
|
3804 |
- var datastring = ((data == null) ? null : Object.keys(data).map(function (key) { return (key + "=" + data[key]); }).join("&")); |
|
3805 |
- var suffix = ((method == "get") ? ("?" + datastring) : ""); |
|
3806 |
- var sending = ((method == "get") ? null : datastring); |
|
3807 |
- var request = new XMLHttpRequest(); |
|
3808 |
- request.open(method.toUpperCase(), target + suffix, true); |
|
3809 |
- request.onreadystatechange = function () { |
|
3810 |
- if (request.readyState === 4) { |
|
3811 |
- if (request.status === 200) { |
|
3812 |
- resolve(request.responseText); |
|
4842 |
+ class class_file_abstract { |
|
4843 |
+ /** |
|
4844 |
+ * @desc reads a json file |
|
4845 |
+ * @author fenris |
|
4846 |
+ */ |
|
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; |
|
3813 | 4861 |
} |
3814 |
- else { |
|
3815 |
- reject(new Error("XMLHttpRequest failed")); |
|
4862 |
+ catch (exception) { |
|
4863 |
+ error = new class_error("invalid json '" + path + "'", [exception]); |
|
4864 |
+ } |
|
4865 |
+ if (error == null) { |
|
4866 |
+ resolve_(state); |
|
3816 | 4867 |
} |
4868 |
+ else { |
|
4869 |
+ reject_(error); |
|
3817 | 4870 |
} |
3818 |
- }; |
|
3819 |
- request.send(sending); |
|
4871 |
+ }, |
|
4872 |
+ ])(state => resolve(state.data), reject); |
|
3820 | 4873 |
}); |
3821 | 4874 |
} |
3822 |
- lib_file.ajax = ajax; |
|
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")); |
|
4881 |
+ } |
|
4882 |
+ } |
|
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) { |
|
4888 |
+ /** |
|
4889 |
+ * @author fenris |
|
4890 |
+ */ |
|
4891 |
+ class class_file_node extends lib_file.class_file_abstract { |
|
3823 | 4892 |
/** |
3824 | 4893 |
* @author maspr |
3825 | 4894 |
*/ |
3826 |
- function determine_handler(path) { |
|
4895 |
+ determine_handler(path) { |
|
3827 | 4896 |
if (/^https?:\/\//.test(path)) { |
3828 | 4897 |
return "http"; |
3829 | 4898 |
} |
... | ... |
@@ -3832,32 +4901,20 @@ var lib_file; |
3832 | 4901 |
} |
3833 | 4902 |
} |
3834 | 4903 |
/** |
3835 |
- * @desc reads a file |
|
3836 |
- * @author fenris |
|
4904 |
+ * @override |
|
4905 |
+ * @author fenris,maspr |
|
4906 |
+ * @todo clear up if http(s)-handling belongs here or not |
|
3837 | 4907 |
*/ |
3838 |
- function read(path, skip_error) { |
|
3839 |
- if (skip_error === void 0) { skip_error = false; } |
|
3840 |
- var environment = lib_base.environment(); |
|
3841 |
- switch (environment) { |
|
3842 |
- case "web": { |
|
3843 |
- return (function (resolve, reject) { |
|
3844 |
- ajax({ |
|
3845 |
- "target": path, |
|
3846 |
- "method": "GET", |
|
3847 |
- })(resolve, function (reason) { return (skip_error ? resolve(null) : reject(reason)); }); |
|
3848 |
- }); |
|
3849 |
- break; |
|
3850 |
- } |
|
3851 |
- case "node": { |
|
3852 |
- switch (determine_handler(path)) { |
|
4908 |
+ read(path, skip_error = false) { |
|
4909 |
+ switch (this.determine_handler(path)) { |
|
3853 | 4910 |
case "file": |
3854 | 4911 |
{ |
3855 |
- var _fs_1 = require("fs"); |
|
3856 |
- return (function (resolve, reject) { |
|
3857 |
- _fs_1.readFile(path, { |
|
4912 |
+ let nm_fs = require("fs"); |
|
4913 |
+ return ((resolve, reject) => { |
|
4914 |
+ nm_fs.readFile(path, { |
|
3858 | 4915 |
"encoding": "utf8", |
3859 | 4916 |
"flag": "r", |
3860 |
- }, function (error, content) { |
|
4917 |
+ }, (error, content) => { |
|
3861 | 4918 |
if (error == null) { |
3862 | 4919 |
resolve(content); |
3863 | 4920 |
} |
... | ... |
@@ -3870,124 +4927,202 @@ var lib_file; |
3870 | 4927 |
break; |
3871 | 4928 |
case "http": |
3872 | 4929 |
{ |
3873 |
- return function (resolve, reject) { |
|
3874 |
- var _http = require("http"); |
|
3875 |
- var _https = require("https"); |
|
3876 |
- var _url = require("url"); |
|
3877 |
- var parsed_url = _url.parse(path, false, true); |
|
3878 |
- var client = (parsed_url.protocol == "https:") ? _https : _http; |
|
3879 |
- var default_port = (parsed_url.protocol == "https:") ? 443 : 80; |
|
3880 |
- var options = { |
|
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 = { |
|
3881 | 4938 |
hostname: parsed_url.hostname, |
3882 | 4939 |
port: parsed_url.port || default_port, |
3883 | 4940 |
path: parsed_url.path, |
3884 | 4941 |
method: "GET" |
3885 | 4942 |
}; |
3886 |
- var req = client.request(options, function (res) { |
|
3887 |
- var data = ""; // @todo |
|
3888 |
- res.on("data", function (chunk) { |
|
4943 |
+ let req = client.request(options, (res) => { |
|
4944 |
+ let data = ""; // @todo |
|
4945 |
+ res.on("data", (chunk) => { |
|
3889 | 4946 |
data += chunk; |
3890 | 4947 |
}); |
3891 |
- res.on("end", function () { |
|
4948 |
+ res.on("end", () => { |
|
3892 | 4949 |
resolve(data); |
3893 | 4950 |
}); |
3894 | 4951 |
}); |
3895 | 4952 |
req.end(); |
3896 |
- req.on("error", function (error) { |
|
4953 |
+ req.on("error", (error) => { |
|
3897 | 4954 |
reject(error); |
3898 | 4955 |
}); |
3899 | 4956 |
}; |
3900 | 4957 |
} |
3901 | 4958 |
break; |
3902 | 4959 |
default: { |
3903 |
- return (function (resolve, reject) { return reject(new Error("unhandled protocol")); }); |
|
4960 |
+ return ((resolve, reject) => reject(new Error("unhandled protocol"))); |
|
3904 | 4961 |
} |
3905 | 4962 |
} |
3906 |
- break; |
|
3907 | 4963 |
} |
3908 |
- default: { |
|
3909 |
- return (function (resolve, reject) { return reject(new Error("unhandled environment")); }); |
|
3910 |
- break; |
|
4964 |
+ /** |
|
4965 |
+ * @override |
|
4966 |
+ * @author fenris |
|
4967 |
+ */ |
|
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); |
|
3911 | 4980 |
} |
4981 |
+ }); |
|
4982 |
+ }); |
|
3912 | 4983 |
} |
3913 | 4984 |
} |
3914 |
- lib_file.read = read; |
|
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) { |
|
3915 | 4990 |
/** |
3916 |
- * @desc reads a json file |
|
3917 | 4991 |
* @author fenris |
4992 |
+ * @todo move to a dedicated lib (e.g. "http", "transport", etc.) |
|
3918 | 4993 |
*/ |
3919 |
- function read_json(path) { |
|
3920 |
- return (function (resolve, reject) { |
|
3921 |
- lib_call.executor_chain({}, [ |
|
3922 |
- function (state) { return function (resolve_, reject_) { |
|
3923 |
- read(path)(function (content) { |
|
3924 |
- state.content = content; |
|
3925 |
- resolve_(state); |
|
3926 |
- }, reject_); |
|
3927 |
- }; }, |
|
3928 |
- function (state) { return function (resolve_, reject_) { |
|
3929 |
- var error; |
|
3930 |
- try { |
|
3931 |
- state.data = JSON.parse(state.content); |
|
3932 |
- error = null; |
|
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); |
|
3933 | 5006 |
} |
3934 |
- catch (exception) { |
|
3935 |
- error = new class_error("invalid json", [exception]); |
|
5007 |
+ else { |
|
5008 |
+ reject(new Error("XMLHttpRequest failed")); |
|
3936 | 5009 |
} |
3937 |
- if (error == null) { |
|
3938 |
- resolve_(state); |
|
3939 | 5010 |
} |
3940 |
- else { |
|
3941 |
- reject_(error); |
|
5011 |
+ }; |
|
5012 |
+ request.send(sending); |
|
5013 |
+ }); |
|
3942 | 5014 |
} |
3943 |
- }; }, |
|
3944 |
- ])(function (state) { return resolve(state.data); }, reject); |
|
5015 |
+ /** |
|
5016 |
+ * @author fenris |
|
5017 |
+ */ |
|
5018 |
+ class class_file_web extends lib_file.class_file_abstract { |
|
5019 |
+ /** |
|
5020 |
+ * @override |
|
5021 |
+ * @author fenris |
|
5022 |
+ */ |
|
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 |
+ } |
|
5031 |
+ /** |
|
5032 |
+ * @override |
|
5033 |
+ * @author fenris |
|
5034 |
+ */ |
|
5035 |
+ write(path, content) { |
|
5036 |
+ return ((resolve, reject) => { |
|
5037 |
+ reject(new Error("not implemented / not possible")); |
|
3945 | 5038 |
}); |
3946 | 5039 |
} |
3947 |
- lib_file.read_json = read_json; |
|
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) { |
|
3948 | 5047 |
/** |
3949 |
- * @desc writes a file |
|
5048 |
+ * @desc selects the implementation which fits for the detected environment |
|
3950 | 5049 |
* @author fenris |
3951 | 5050 |
*/ |
3952 |
- function write(path, content) { |
|
3953 |
- var environment = lib_base.environment(); |
|
5051 |
+ function auto() { |
|
5052 |
+ let environment = lib_base.environment(); |
|
3954 | 5053 |
switch (environment) { |
3955 |
- case "web": { |
|
3956 |
- return (function (resolve, reject) { |
|
3957 |
- reject(new Error("not implemented / not possible")); |
|
3958 |
- }); |
|
3959 |
- break; |
|
3960 |
- } |
|
3961 | 5054 |
case "node": { |
3962 |
- var _fs_2 = require("fs"); |
|
3963 |
- return (function (resolve, reject) { |
|
3964 |
- _fs_2.writeFile(path, content, { |
|
3965 |
- "encoding": "utf8", |
|
3966 |
- "flag": "w", |
|
3967 |
- }, function (error) { |
|
3968 |
- if (error == null) { |
|
3969 |
- resolve(undefined); |
|
3970 |
- } |
|
3971 |
- else { |
|
3972 |
- reject(error); |
|
5055 |
+ return (new lib_file.class_file_node()); |
|
5056 |
+ break; |
|
3973 | 5057 |
} |
3974 |
- }); |
|
3975 |
- }); |
|
5058 |
+ case "web": { |
|
5059 |
+ return (new lib_file.class_file_web()); |
|
3976 | 5060 |
break; |
3977 | 5061 |
} |
3978 | 5062 |
default: { |
3979 |
- return (function (resolve, reject) { return reject(new Error("unhandled environment")); }); |
|
5063 |
+ throw (new Error(`no implementation for environment '${environment}'`)); |
|
3980 | 5064 |
break; |
3981 | 5065 |
} |
3982 | 5066 |
} |
3983 | 5067 |
} |
5068 |
+ lib_file.auto = auto; |
|
5069 |
+ /** |
|
5070 |
+ * @author fenris |
|
5071 |
+ */ |
|
5072 |
+ class class_file extends lib_file.class_file_abstract { |
|
5073 |
+ /** |
|
5074 |
+ * @author fenris |
|
5075 |
+ */ |
|
5076 |
+ constructor() { |
|
5077 |
+ super(); |
|
5078 |
+ this.core = auto(); |
|
5079 |
+ } |
|
5080 |
+ /** |
|
5081 |
+ * @override |
|
5082 |
+ * @author fenris |
|
5083 |
+ */ |
|
5084 |
+ read(path, skip_error = false) { |
|
5085 |
+ return this.core.read(path, skip_error); |
|
5086 |
+ } |
|
5087 |
+ /** |
|
5088 |
+ * @override |
|
5089 |
+ * @author fenris |
|
5090 |
+ */ |
|
5091 |
+ write(path, content) { |
|
5092 |
+ return this.core.write(path, content); |
|
5093 |
+ } |
|
5094 |
+ } |
|
5095 |
+ lib_file.class_file = class_file; |
|
5096 |
+ /** |
|
5097 |
+ * @author fenris |
|
5098 |
+ */ |
|
5099 |
+ var instance = auto(); |
|
5100 |
+ /** |
|
5101 |
+ * @author fenris |
|
5102 |
+ */ |
|
5103 |
+ function read(path, skip_error = false) { |
|
5104 |
+ return instance.read(path, skip_error); |
|
5105 |
+ } |
|
5106 |
+ lib_file.read = read; |
|
5107 |
+ /** |
|
5108 |
+ * @author fenris |
|
5109 |
+ */ |
|
5110 |
+ function write(path, content) { |
|
5111 |
+ return instance.write(path, content); |
|
5112 |
+ } |
|
3984 | 5113 |
lib_file.write = write; |
3985 | 5114 |
/** |
3986 |
- * @desc writes a json file |
|
5115 |
+ * @author fenris |
|
5116 |
+ */ |
|
5117 |
+ function read_json(path) { |
|
5118 |
+ return instance.read_json(path); |
|
5119 |
+ } |
|
5120 |
+ lib_file.read_json = read_json; |
|
5121 |
+ /** |
|
3987 | 5122 |
* @author fenris |
3988 | 5123 |
*/ |
3989 | 5124 |
function write_json(path, data) { |
3990 |
- return write(path, JSON.stringify(data, undefined, "\t")); |
|
5125 |
+ return instance.write_json(path, data); |
|
3991 | 5126 |
} |
3992 | 5127 |
lib_file.write_json = write_json; |
3993 | 5128 |
})(lib_file || (lib_file = {})); |
... | ... |
@@ -4190,7 +5325,7 @@ var lib_args; |
4190 | 5325 |
}()); |
4191 | 5326 |
lib_args.class_argument = class_argument; |
4192 | 5327 |
})(lib_args || (lib_args = {})); |
4193 |
-///<reference path="../../base/build/logic.d.ts"/> |
|
5328 |
+///<reference path="../../base/build/logic-decl.d.ts"/> |
|
4194 | 5329 |
var lib_args; |
4195 | 5330 |
(function (lib_args) { |
4196 | 5331 |
/** |
... | ... |
@@ -4268,7 +5403,10 @@ var lib_args; |
4268 | 5403 |
pattern_to += settings["environment"][environment]["symbols"]["delimiter"]; |
4269 | 5404 |
pattern_to += settings["environment"][environment]["symbols"]["prefix"]; |
4270 | 5405 |
pattern_to += argument.indicator_main(); |
4271 |
- if (argument.type_get() != "boolean") { |
|
5406 |
+ if (argument.type_get() == "boolean") { |
|
5407 |
+ pattern_to += settings["environment"][environment]["symbols"]["delimiter"]; |
|
5408 |
+ } |
|
5409 |
+ else { |
|
4272 | 5410 |
pattern_to += settings["environment"][environment]["symbols"]["assignment"]; |
4273 | 5411 |
} |
4274 | 5412 |
} |
... | ... |
@@ -4538,30 +5676,66 @@ var lib_args; |
4538 | 5676 |
}()); |
4539 | 5677 |
lib_args.class_handler = class_handler; |
4540 | 5678 |
})(lib_args || (lib_args = {})); |
4541 |
-var __extends = (this && this.__extends) || function (d, b) { |
|
4542 |
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; |
|
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); |
|
4543 | 5686 |
function __() { this.constructor = d; } |
4544 | 5687 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
4545 | 5688 |
}; |
4546 |
-var _child_process = require("child_process"); |
|
4547 |
-var _fs = require("fs"); |
|
4548 |
-var configuration = { |
|
4549 |
- "invocation": { |
|
4550 |
- "interpreter": null, |
|
4551 |
- "path": "koralle", |
|
4552 |
- }, |
|
4553 |
- "version": "0.0.7", |
|
4554 |
- "tempfolder": null, |
|
4555 |
- "path_source": "source", |
|
4556 |
- "path_build": "build", |
|
4557 |
- "system": "unix", |
|
4558 |
- "raw": false, |
|
4559 |
- "execute": false, |
|
4560 |
- "output": "gnumake", |
|
4561 |
- "file": null, |
|
4562 |
- "path": "project.json", |
|
4563 |
- "showgraph": false, |
|
5689 |
+})(); |
|
5690 |
+var nm_child_process = require("child_process"); |
|
5691 |
+var nm_fs = require("fs"); |
|
5692 |
+/** |
|
5693 |
+ * @author fenris |
|
5694 |
+ */ |
|
5695 |
+var globalvars = { |
|
5696 |
+ "configuration": {}, |
|
4564 | 5697 |
}; |
5698 |
+/** |
|
5699 |
+ * @author fenris |
|
5700 |
+ */ |
|
5701 |
+function name_mark(name) { |
|
5702 |
+ return (globalvars.configuration.name_prefix + name); |
|
5703 |
+} |
|
5704 |
+/** |
|
5705 |
+ * @author fenris |
|
5706 |
+ */ |
|
5707 |
+function dirwrap(location, core) { |
|
5708 |
+ if (location == null) { |
|
5709 |
+ return core; |
|
5710 |
+ } |
|
5711 |
+ else { |
|
5712 |
+ return "cd " + location.as_string(globalvars.configuration.system) + " > /dev/null && " + core + " ; cd - > /dev/null"; |
|
5713 |
+ } |
|
5714 |
+} |
|
5715 |
+/** |
|
5716 |
+ * @author fenris |
|
5717 |
+ */ |
|
5718 |
+function filepointer_adjust(filepointer, location) { |
|
5719 |
+ return ((location == null) ? filepointer : filepointer.relocate(location)); |
|
5720 |
+} |
|
5721 |
+/** |
|
5722 |
+ * @author fenris |
|
5723 |
+ */ |
|
5724 |
+function path_augment(path, step, aggregate) { |
|
5725 |
+ if (aggregate === void 0) { aggregate = true; } |
|
5726 |
+ if (aggregate) { |
|
5727 |
+ return path.concat([step]); |
|
5728 |
+ } |
|
5729 |
+ else { |
|
5730 |
+ return [step]; |
|
5731 |
+ } |
|
5732 |
+} |
|
5733 |
+/** |
|
5734 |
+ * @author fenris |
|
5735 |
+ */ |
|
5736 |
+function path_dump(path) { |
|
5737 |
+ return path.join(globalvars.configuration.name_splitter); |
|
5738 |
+} |
|
4565 | 5739 |
/** |
4566 | 5740 |
* @author fenris |
4567 | 5741 |
*/ |
... | ... |
@@ -4587,7 +5761,6 @@ var class_message = (function () { |
4587 | 5761 |
class_message.prototype.generate = function (with_type) { |
4588 | 5762 |
if (with_type === void 0) { with_type = true; } |
4589 | 5763 |
var output = ""; |
4590 |
- output += lib_string.repeat("\t", this.depth); |
|
4591 | 5764 |
if (with_type) { |
4592 | 5765 |
if (this.type != null) { |
4593 | 5766 |
output += ("[" + this.type + "]" + " "); |
... | ... |
@@ -4596,6 +5769,7 @@ var class_message = (function () { |
4596 | 5769 |
if (this.prefix != null) { |
4597 | 5770 |
output += ("<" + this.prefix + ">" + " "); |
4598 | 5771 |
} |
5772 |
+ output += lib_string.repeat("\t", this.depth); |
|
4599 | 5773 |
output += this.content; |
4600 | 5774 |
if (this.linebreak) { |
4601 | 5775 |
output += "\n"; |
... | ... |
@@ -4830,9 +6004,10 @@ var lib_gnumake; |
4830 | 6004 |
* @author fenris |
4831 | 6005 |
*/ |
4832 | 6006 |
function macro_command(_a) { |
4833 |
- 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 ? "unix" : _e; |
|
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; |
|
4834 | 6008 |
switch (system) { |
4835 |
- case "unix": { |
|
6009 |
+ case "bsd": |
|
6010 |
+ case "linux": { |
|
4836 | 6011 |
var command = path; |
4837 | 6012 |
{ |
4838 | 6013 |
if (interpreter != null) { |
... | ... |
@@ -4990,9 +6165,10 @@ var lib_ant; |
4990 | 6165 |
* @author fenris |
4991 | 6166 |
*/ |
4992 | 6167 |
class_action.macro_exec = function (_a) { |
4993 |
- 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 ? "unix" : _e; |
|
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; |
|
4994 | 6169 |
switch (system) { |
4995 |
- case "unix": { |
|
6170 |
+ case "linux": |
|
6171 |
+ case "bsd": { |
|
4996 | 6172 |
var attributes = {}; |
4997 | 6173 |
var args_ = []; |
4998 | 6174 |
if (interpreter == null) { |
... | ... |
@@ -5125,7 +6301,7 @@ var class_action_adhoc = (function (_super) { |
5125 | 6301 |
* @author fenris |
5126 | 6302 |
*/ |
5127 | 6303 |
function class_action_adhoc() { |
5128 |
- _super.call(this); |
|
6304 |
+ return _super.call(this) || this; |
|
5129 | 6305 |
} |
5130 | 6306 |
return class_action_adhoc; |
5131 | 6307 |
}(class_action)); |
... | ... |
@@ -5139,12 +6315,13 @@ var class_action_exec = (function (_super) { |
5139 | 6315 |
*/ |
5140 | 6316 |
function class_action_exec(_a) { |
5141 | 6317 |
var inputs = _a["inputs"], outputs = _a["outputs"], path = _a["path"], interpreter = _a["interpreter"], workdir = _a["workdir"]; |
5142 |
- _super.call(this); |
|
5143 |
- this.paths_input = inputs; |
|
5144 |
- this.paths_output = outputs; |
|
5145 |
- this.path_script = path; |
|
5146 |
- this.path_interpreter = interpreter; |
|
5147 |
- this.workdir = 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; |
|
5148 | 6325 |
} |
5149 | 6326 |
/** |
5150 | 6327 |
* @desc for defining directly how the action is to be converted into a target-piece |
... | ... |
@@ -5153,24 +6330,26 @@ var class_action_exec = (function (_super) { |
5153 | 6330 |
class_action_exec.prototype.compilation = function (output_identifier) { |
5154 | 6331 |
switch (output_identifier) { |
5155 | 6332 |
case "gnumake": { |
5156 |
- switch (configuration.system) { |
|
5157 |
- case "unix": |
|
6333 |
+ switch (globalvars.configuration.system) { |
|
6334 |
+ case "linux": |
|
6335 |
+ case "bsd": |
|
5158 | 6336 |
case "win": { |
5159 | 6337 |
var command = ""; |
5160 | 6338 |
{ |
5161 | 6339 |
command = lib_gnumake.macro_command({ |
5162 |
- "interpreter": ((this.path_interpreter != null) ? this.path_interpreter.as_string(configuration.system) : null), |
|
5163 |
- "path": this.path_script.as_string(configuration.system), |
|
6340 |
+ "interpreter": ((this.path_interpreter != null) ? this.path_interpreter.as_string(globalvars.configuration.system) : null), |
|
6341 |
+ "path": this.path_script.as_string(globalvars.configuration.system), |
|
5164 | 6342 |
"args": [ |
5165 |
- ("'" + this.paths_input.map(function (filepointer) { return filepointer.as_string(configuration.system); }).join(",") + "'"), |
|
5166 |
- ("'" + this.paths_output.map(function (filepointer) { return filepointer.as_string(configuration.system); }).join(",") + "'"), |
|
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(",") + "'"), |
|
5167 | 6345 |
], |
5168 |
- "system": configuration.system, |
|
6346 |
+ "system": globalvars.configuration.system, |
|
5169 | 6347 |
}); |
5170 | 6348 |
} |
5171 | 6349 |
{ |
5172 | 6350 |
if (this.workdir != null) { |
5173 |
- command = "pushd " + this.workdir.as_string(configuration.system) + " && " + command + " ; popd"; |
|
6351 |
+ // command = `pushd ${this.workdir.as_string(globalvars.configuration.system)} && ${command} ; popd` |
|
6352 |
+ command = "cd " + this.workdir.as_string(globalvars.configuration.system) + " && " + command + " ; cd -"; |
|
5174 | 6353 |
} |
5175 | 6354 |
} |
5176 | 6355 |
return command; |
... | ... |
@@ -5185,13 +6364,13 @@ var class_action_exec = (function (_super) { |
5185 | 6364 |
} |
5186 | 6365 |
case "ant": { |
5187 | 6366 |
return (lib_ant.class_action.macro_exec({ |
5188 |
- "interpreter": ((this.path_interpreter != null) ? this.path_interpreter.as_string(configuration.system) : null), |
|
5189 |
- "path": this.path_script.as_string("unix"), |
|
6367 |
+ "interpreter": ((this.path_interpreter != null) ? this.path_interpreter.as_string(globalvars.configuration.system) : null), |
|
6368 |
+ "path": this.path_script.as_string("linux"), |
|
5190 | 6369 |
"args": [ |
5191 |
- ("'" + this.paths_input.map(function (filepointer) { return filepointer.as_string("unix"); }).join(",") + "'"), |
|
5192 |
- ("'" + this.paths_output.map(function (filepointer) { return filepointer.as_string("unix"); }).join(",") + "'"), |
|
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(",") + "'"), |
|
5193 | 6372 |
], |
5194 |
- "system": configuration.system, |
|
6373 |
+ "system": globalvars.configuration.system, |
|
5195 | 6374 |
})); |
5196 | 6375 |
break; |
5197 | 6376 |
} |
... | ... |
@@ -5211,296 +6390,38 @@ var class_action_echo = (function (_super) { |
5211 | 6390 |
/** |
5212 | 6391 |
* @author fenris |
5213 | 6392 |
*/ |
5214 |
- function class_action_echo(message) { |
|
5215 |
- _super.call(this); |
|
5216 |
- this.message = message; |
|
5217 |
- } |
|
5218 |
- /** |
|
5219 |
- * @desc for defining directly how the action is to be converted into a target-piece |
|
5220 |
- * @todo escape message |
|
5221 |
- * @author fenris |
|
5222 |
- */ |
|
5223 |
- class_action_echo.prototype.compilation = function (target_identifier) { |
|
5224 |
- switch (target_identifier) { |
|
5225 |
- case "gnumake": { |
|
5226 |
- switch (configuration["system"]) { |
|
5227 |
- case "unix": |
|
5228 |
- case "win": { |
|
5229 |
- var parts = []; |
|
5230 |
- parts.push("echo"); |
|
5231 |
- parts.push("\"" + this.message + "\""); |
|
5232 |
- return parts.join(" "); |
|
5233 |
- break; |
|
5234 |
- } |
|
5235 |
- default: { |
|
5236 |
- throw (new Error("not implemented")); |
|
5237 |
- break; |
|
5238 |
- } |
|
5239 |
- } |
|
5240 |
- break; |
|
5241 |
- } |
|
5242 |
- case "ant": { |
|
5243 |
- return (new lib_ant.class_action(new lib_xml.class_node_complex("echo", { "message": this.message }))); |
|
5244 |
- break; |
|
5245 |
- } |
|
5246 |
- default: { |
|
5247 |
- throw (new Error("unhandled target '" + target_identifier + "'")); |
|
5248 |
- break; |
|
5249 |
- } |
|
5250 |
- } |
|
5251 |
- }; |
|
5252 |
- return class_action_echo; |
|
5253 |
-}(class_action_adhoc)); |
|
5254 |
-/** |
|
5255 |
- * @author fenris |
|
5256 |
- */ |
|
5257 |
-var class_action_koralle = (function (_super) { |
|
5258 |
- __extends(class_action_koralle, _super); |
|
5259 |
- /** |
|
5260 |
- * @author fenris |
|
5261 |
- */ |
|
5262 |
- function class_action_koralle(_a) { |
|
5263 |
- var filepointer_in = _a["filepointer_in"], filepointer_out = _a["filepointer_out"], output = _a["output"], raw = _a["raw"]; |
|
5264 |
- _super.call(this); |
|
5265 |
- this.filepointer_in = filepointer_in; |
|
5266 |
- this.filepointer_out = filepointer_out; |
|
5267 |
- this.output = output; |
|
5268 |
- this.raw = raw; |
|
5269 |
- } |
|
5270 |
- /** |
|
5271 |
- * @desc for defining directly how the action is to be converted into an output-piece |
|
5272 |
- * @author fenris |
|
5273 |
- */ |
|
5274 |
- class_action_koralle.prototype.compilation = function (output_identifier) { |
|
5275 |
- switch (output_identifier) { |
|
5276 |
- case "gnumake": { |
|
5277 |
- switch (configuration.system) { |
|
5278 |
- case "unix": |
|
5279 |
- case "win": { |
|
5280 |
- var parts = []; |
|
5281 |
- if (configuration.invocation.interpreter != null) { |
|
5282 |
- parts.push(configuration.invocation.interpreter); |
|
5283 |
- } |
|
5284 |
- parts.push(configuration.invocation.path); |
|
5285 |
- parts.push(this.filepointer_in.as_string(configuration.system)); |
|
5286 |
- parts.push("--output=" + this.output); |
|
5287 |
- parts.push("--system=" + configuration.system); |
|
5288 |
- if (this.raw) { |
|
5289 |
- parts.push("--raw"); |
|
5290 |
- } |
|
5291 |
- parts.push("--file=" + this.filepointer_out.as_string(configuration.system)); |
|
5292 |
- return (parts.join(" ")); |
|
5293 |
- break; |
|
5294 |
- } |
|
5295 |
- default: { |
|
5296 |
- throw (new Error("not implemented")); |
|
5297 |
- break; |
|
5298 |
- } |
|
5299 |
- } |
|
5300 |
- break; |
|
5301 |
- } |
|
5302 |
- case "ant": { |
|
5303 |
- switch (configuration.system) { |
|
5304 |
- case "unix": |
|
5305 |
- case "win": { |
|
5306 |
- var args = []; |
|
5307 |
- args.push(this.filepointer_in.as_string("unix")); |
|
5308 |
- args.push("--output=" + this.output); |
|
5309 |
- args.push("--system=" + configuration.system); |
|
5310 |
- if (this.raw) { |
|
5311 |
- args.push("--raw"); |
|
5312 |
- } |
|
5313 |
- args.push("--file=" + this.filepointer_out.as_string(configuration.system)); |
|
5314 |
- return (lib_ant.class_action.macro_exec({ |
|
5315 |
- "path": configuration.invocation.path, |
|
5316 |
- "interpreter": configuration.invocation.interpreter, |
|
5317 |
- "args": args, |
|
5318 |
- })); |
|
5319 |
- break; |
|
5320 |
- } |
|
5321 |
- default: { |
|
5322 |
- throw (new Error("not implemented")); |
|
5323 |
- break; |
|
5324 |
- } |
|
5325 |
- } |
|
5326 |
- break; |
|
5327 |
- } |
|
5328 |
- default: { |
|
5329 |
- throw (new Error("unhandled output '" + output_identifier + "'")); |
|
5330 |
- break; |
|
5331 |
- } |
|
5332 |
- } |
|
5333 |
- }; |
|
5334 |
- return class_action_koralle; |
|
5335 |
-}(class_action_adhoc)); |
|
5336 |
-/** |
|
5337 |
- * @author fenris |
|
5338 |
- */ |
|
5339 |
-var class_action_build = (function (_super) { |
|
5340 |
- __extends(class_action_build, _super); |
|
5341 |
- /** |
|
5342 |
- * @author fenris |
|
5343 |
- */ |
|
5344 |
- function class_action_build(filepointer, workdir) { |
|
5345 |
- _super.call(this); |
|
5346 |
- this.filepointer = filepointer; |
|
5347 |
- this.workdir = workdir; |
|
5348 |
- } |
|
5349 |
- return class_action_build; |
|
5350 |
-}(class_action_adhoc)); |
|
5351 |
-/** |
|
5352 |
- * @author fenris |
|
5353 |
- */ |
|
5354 |
-var class_action_gnumake = (function (_super) { |
|
5355 |
- __extends(class_action_gnumake, _super); |
|
5356 |
- /** |
|
5357 |
- * @author fenris |
|
5358 |
- */ |
|
5359 |
- function class_action_gnumake(filepointer, workdir) { |
|
5360 |
- _super.call(this, filepointer, workdir); |
|
5361 |
- } |
|
5362 |
- /** |
|
5363 |
- * @desc for defining directly how the action is to be converted into a target-piece |
|
5364 |
- * @author fenris |
|
5365 |
- */ |
|
5366 |
- class_action_gnumake.prototype.compilation = function (output_identifier) { |
|
5367 |
- switch (output_identifier) { |
|
5368 |
- case "gnumake": { |
|
5369 |
- switch (configuration.system) { |
|
5370 |
- case "unix": |
|
5371 |
- case "win": { |
|
5372 |
- // cmd_cd1 |
|
5373 |
- var cmd_cd1 = void 0; |
|
5374 |
- { |
|
5375 |
- var parts = []; |
|
5376 |
- parts.push("pushd"); |
|
5377 |
- parts.push(this.workdir.as_string(configuration.system)); |
|
5378 |
- if (configuration.system == "unix") { |
|
5379 |
- parts.push("> /dev/null"); |
|
5380 |
- } |
|
5381 |
- cmd_cd1 = parts.join(" "); |
|
5382 |
- } |
|
5383 |
- // cmd_cd2 |
|
5384 |
- var cmd_cd2 = void 0; |
|
5385 |
- { |
|
5386 |
- var parts = []; |
|
5387 |
- parts.push("popd"); |
|
5388 |
- if (configuration.system == "unix") { |
|
5389 |
- parts.push("> /dev/null"); |
|
5390 |
- } |
|
5391 |
- cmd_cd2 = parts.join(" "); |
|
5392 |
- } |
|
5393 |
- // cmd_make |
|
5394 |
- var cmd_make = void 0; |
|
5395 |
- { |
|
5396 |
- var parts = []; |
|
5397 |
- parts.push("make"); |
|
5398 |
- parts.push("--no-print-directory"); |
|
5399 |
- parts.push("--directory=" + this.workdir.as_string(configuration.system)); |
|
5400 |
- parts.push("--file=" + this.filepointer.as_string(configuration.system)); |
|
5401 |
- cmd_make = parts.join(" "); |
|
5402 |
- } |
|
5403 |
- // return ((this.workdir == null) ? [cmd_make] : [cmd_cd1, cmd_make, cmd_cd2]).join(" && "); |
|
5404 |
- return [cmd_make]; |
|
5405 |
- break; |
|
5406 |
- } |
|
5407 |
- default: { |
|
5408 |
- throw (new Error("not implemented")); |
|
5409 |
- break; |
|
5410 |
- } |
|
5411 |
- } |
|
5412 |
- break; |
|
5413 |
- } |
|
5414 |
- case "ant": { |
|
5415 |
- return (new lib_ant.class_action((this.workdir == null) |
|
5416 |
- ? |
|
5417 |
- new lib_xml.class_node_complex("exec", { |
|
5418 |
- "executable": "make", |
|
5419 |
- }, [ |
|
5420 |
- new lib_xml.class_node_complex("arg", { "value": "--no-print-directory" }), |
|
5421 |
- new lib_xml.class_node_complex("arg", { "value": "--file=" + this.filepointer.as_string("unix") }), |
|
5422 |
- ]) |
|
5423 |
- : |
|
5424 |
- new lib_xml.class_node_complex("exec", { |
|
5425 |
- "executable": "make", |
|
5426 |
- "dir": this.workdir.as_string("unix"), |
|
5427 |
- }, [ |
|
5428 |
- new lib_xml.class_node_complex("arg", { "value": "--no-print-directory" }), |
|
5429 |
- new lib_xml.class_node_complex("arg", { "value": "--file=" + this.filepointer.as_string("unix") }), |
|
5430 |
- ]))); |
|
5431 |
- break; |
|
5432 |
- } |
|
5433 |
- default: { |
|
5434 |
- throw (new Error("unhandled target '" + output_identifier + "'")); |
|
5435 |
- break; |
|
5436 |
- } |
|
5437 |
- } |
|
5438 |
- }; |
|
5439 |
- return class_action_gnumake; |
|
5440 |
-}(class_action_build)); |
|
5441 |
-/** |
|
5442 |
- * @author fenris |
|
5443 |
- */ |
|
5444 |
-var class_action_ant = (function (_super) { |
|
5445 |
- __extends(class_action_ant, _super); |
|
5446 |
- /** |
|
5447 |
- * @author fenris |
|
5448 |
- */ |
|
5449 |
- function class_action_ant(filepointer, workdir) { |
|
5450 |
- _super.call(this, filepointer, workdir); |
|
6393 |
+ function class_action_echo(message) { |
|
6394 |
+ var _this = _super.call(this) || this; |
|
6395 |
+ _this.message = message; |
|
6396 |
+ return _this; |
|
5451 | 6397 |
} |
5452 | 6398 |
/** |
5453 | 6399 |
* @desc for defining directly how the action is to be converted into a target-piece |
6400 |
+ * @todo escape message |
|
5454 | 6401 |
* @author fenris |
5455 | 6402 |
*/ |
5456 |
- class_action_ant.prototype.compilation = function (target_identifier) { |
|
6403 |
+ class_action_echo.prototype.compilation = function (target_identifier) { |
|
5457 | 6404 |
switch (target_identifier) { |
5458 | 6405 |
case "gnumake": { |
5459 |
- switch (configuration["system"]) { |
|
5460 |
- case "unix": { |
|
5461 |
- // cmd_cd1 |
|
5462 |
- var cmd_cd1 = void 0; |
|
5463 |
- { |
|
5464 |
- var parts = []; |
|
5465 |
- parts.push("cd"); |
|
5466 |
- parts.push(this.workdir.toString()); |
|
5467 |
- cmd_cd1 = parts.join(" "); |
|
5468 |
- } |
|
5469 |
- // cmd_cd2 |
|
5470 |
- var cmd_cd2 = void 0; |
|
5471 |
- { |
|
5472 |
- var parts = []; |
|
5473 |
- parts.push("cd"); |
|
5474 |
- parts.push("-"); |
|
5475 |
- cmd_cd2 = parts.join(" ") + " > /dev/null"; |
|
5476 |
- } |
|
5477 |
- // cmd_ant |
|
5478 |
- var cmd_ant = void 0; |
|
5479 |
- { |
|
5480 |
- var parts = []; |
|
5481 |
- parts.push("ant"); |
|
5482 |
- parts.push(this.filepointer.toString()); |
|
5483 |
- cmd_ant = parts.join(" "); |
|
5484 |
- } |
|
5485 |
- return ((this.workdir == null) ? [cmd_ant] : [cmd_cd1, cmd_ant, cmd_cd2]).join(" && "); |
|
6406 |
+ switch (globalvars.configuration["system"]) { |
|
6407 |
+ case "linux": |
|
6408 |
+ case "bsd": |
|
6409 |
+ case "win": { |
|
6410 |
+ return (lib_gnumake.macro_command({ |
|
6411 |
+ "path": "echo", |
|
6412 |
+ "args": ["\"" + this.message + "\""], |
|
6413 |
+ })); |
|
6414 |
+ break; |
|
5486 | 6415 |
} |
5487 | 6416 |
default: { |
5488 | 6417 |
throw (new Error("not implemented")); |
6418 |
+ break; |
|
5489 | 6419 |
} |
5490 | 6420 |
} |
5491 | 6421 |
break; |
5492 | 6422 |
} |
5493 | 6423 |
case "ant": { |
5494 |
- return (new lib_ant.class_action((this.workdir == null) |
|
5495 |
- ? |
|
5496 |
- new lib_xml.class_node_complex("ant", { |
|
5497 |
- "antfile": this.filepointer.toString(), |
|
5498 |
- }) |
|
5499 |
- : |
|
5500 |
- new lib_xml.class_node_complex("ant", { |
|
5501 |
- "antfile": this.filepointer.toString(), |
|
5502 |
- "dir": this.workdir.toString(), |
|
5503 |
- }))); |
|
6424 |
+ return (new lib_ant.class_action(new lib_xml.class_node_complex("echo", { "message": this.message }))); |
|
5504 | 6425 |
break; |
5505 | 6426 |
} |
5506 | 6427 |
default: { |
... | ... |
@@ -5509,8 +6430,8 @@ var class_action_ant = (function (_super) { |
5509 | 6430 |
} |
5510 | 6431 |
} |
5511 | 6432 |
}; |
5512 |
- return class_action_ant; |
|
5513 |
-}(class_action_build)); |
|
6433 |
+ return class_action_echo; |
|
6434 |
+}(class_action_adhoc)); |
|
5514 | 6435 |
/** |
5515 | 6436 |
* @author fenris |
5516 | 6437 |
*/ |
... | ... |
@@ -5520,8 +6441,9 @@ var class_action_mkdir = (function (_super) { |
5520 | 6441 |
* @author fenris |
5521 | 6442 |
*/ |
5522 | 6443 |
function class_action_mkdir(location) { |
5523 |
- _super.call(this); |
|
5524 |
- this.location = location; |
|
6444 |
+ var _this = _super.call(this) || this; |
|
6445 |
+ _this.location = location; |
|
6446 |
+ return _this; |
|
5525 | 6447 |
} |
5526 | 6448 |
/** |
5527 | 6449 |
* @desc for defining directly how the action is to be converted into a target-piece |
... | ... |
@@ -5532,9 +6454,12 @@ var class_action_mkdir = (function (_super) { |
5532 | 6454 |
case "gnumake": { |
5533 | 6455 |
var parts = []; |
5534 | 6456 |
parts.push("mkdir"); |
5535 |
- switch (configuration["system"]) { |
|
5536 |
- case "unix": { |
|
5537 |
- // parts.push("--parents"); |
|
6457 |
+ switch (globalvars.configuration["system"]) { |
|
6458 |
+ case "linux": { |
|
6459 |
+ parts.push("--parents"); |
|
6460 |
+ break; |
|
6461 |
+ } |
|
6462 |
+ case "bsd": { |
|
5538 | 6463 |
parts.push("-p"); |
5539 | 6464 |
break; |
5540 | 6465 |
} |
... | ... |
@@ -5546,14 +6471,17 @@ var class_action_mkdir = (function (_super) { |
5546 | 6471 |
break; |
5547 | 6472 |
} |
5548 | 6473 |
} |
5549 |
- parts.push(this.location.as_string(configuration["system"])); |
|
6474 |
+ parts.push(this.location.as_string(globalvars.configuration["system"])); |
|
5550 | 6475 |
return parts.join(" "); |
6476 |
+ // break; |
|
5551 | 6477 |
} |
5552 | 6478 |
case "ant": { |
5553 |
- return (new lib_ant.class_action(new lib_xml.class_node_complex("mkdir", { "dir": this.location.as_string("unix") }))); |
|
6479 |
+ return (new lib_ant.class_action(new lib_xml.class_node_complex("mkdir", { "dir": this.location.as_string("linux") }))); |
|
6480 |
+ // break; |
|
5554 | 6481 |
} |
5555 | 6482 |
default: { |
5556 | 6483 |
throw (new Error("unhandled target '" + target_identifier + "'")); |
6484 |
+ // break; |
|
5557 | 6485 |
} |
5558 | 6486 |
} |
5559 | 6487 |
}; |
... | ... |
@@ -5568,8 +6496,9 @@ var class_action_touch = (function (_super) { |
5568 | 6496 |
* @author fenris |
5569 | 6497 |
*/ |
5570 | 6498 |
function class_action_touch(filepointer) { |
5571 |
- _super.call(this); |
|
5572 |
- this.filepointer = filepointer; |
|
6499 |
+ var _this = _super.call(this) || this; |
|
6500 |
+ _this.filepointer = filepointer; |
|
6501 |
+ return _this; |
|
5573 | 6502 |
} |
5574 | 6503 |
/** |
5575 | 6504 |
* @desc for defining directly how the action is to be converted into a target-piece |
... | ... |
@@ -5578,12 +6507,14 @@ var class_action_touch = (function (_super) { |
5578 | 6507 |
class_action_touch.prototype.compilation = function (target_identifier) { |
5579 | 6508 |
switch (target_identifier) { |
5580 | 6509 |
case "gnumake": { |
5581 |
- switch (configuration["system"]) { |
|
5582 |
- case "unix": { |
|
6510 |
+ switch (globalvars.configuration["system"]) { |
|
6511 |
+ case "bsd": |
|
6512 |
+ case "linux": { |
|
5583 | 6513 |
var parts = []; |
5584 | 6514 |
parts.push("touch"); |
5585 | 6515 |
parts.push(this.filepointer.toString()); |
5586 | 6516 |
return parts.join(" "); |
6517 |
+ // break; |
|
5587 | 6518 |
} |
5588 | 6519 |
case "win": { |
5589 | 6520 |
var parts = []; |
... | ... |
@@ -5591,14 +6522,18 @@ var class_action_touch = (function (_super) { |
5591 | 6522 |
parts.push(">"); |
5592 | 6523 |
parts.push(this.filepointer.toString()); |
5593 | 6524 |
return parts.join(" "); |
6525 |
+ // break; |
|
5594 | 6526 |
} |
5595 | 6527 |
default: { |
5596 | 6528 |
throw (new Error("not implemented")); |
6529 |
+ // break; |
|
5597 | 6530 |
} |
5598 | 6531 |
} |
6532 |
+ // break; |
|
5599 | 6533 |
} |
5600 | 6534 |
case "ant": { |
5601 | 6535 |
return (new lib_ant.class_action(new lib_xml.class_node_complex("touch", { "file": this.filepointer.toString() }))); |
6536 |
+ // break; |
|
5602 | 6537 |
} |
5603 | 6538 |
default: { |
5604 | 6539 |
throw (new Error("unhandled target '" + target_identifier + "'")); |
... | ... |
@@ -5617,10 +6552,11 @@ var class_action_copy = (function (_super) { |
5617 | 6552 |
* @author fenris |
5618 | 6553 |
*/ |
5619 | 6554 |
function class_action_copy(filepointer_from, filepointer_to, folder) { |
5620 |
- _super.call(this); |
|
5621 |
- this.filepointer_from = filepointer_from; |
|
5622 |
- this.filepointer_to = filepointer_to; |
|
5623 |
- this.folder = 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; |
|
5624 | 6560 |
} |
5625 | 6561 |
/** |
5626 | 6562 |
* @desc for defining directly how the action is to be converted into a target-piece |
... | ... |
@@ -5629,22 +6565,45 @@ var class_action_copy = (function (_super) { |
5629 | 6565 |
class_action_copy.prototype.compilation = function (target_identifier) { |
5630 | 6566 |
switch (target_identifier) { |
5631 | 6567 |
case "gnumake": { |
5632 |
- switch (configuration.system) { |
|
5633 |
- case "unix": |
|
5634 |
- case "win": { |
|
5635 |
- var parts = []; |
|
5636 |
- parts.push("cp"); |
|
6568 |
+ switch (globalvars.configuration.system) { |
|
6569 |
+ case "linux": { |
|
6570 |
+ var args = []; |
|
5637 | 6571 |
if (this.folder) { |
5638 |
- parts.push("--recursive"); |
|
5639 |
- parts.push("--update"); |
|
5640 |
- parts.push("--verbose"); |
|
5641 |
- parts.push((new lib_path.class_filepointer(this.filepointer_from.location, "*")).as_string(configuration.system)); |
|
6572 |
+ args.push("--recursive"); |
|
6573 |
+ args.push("--update"); |
|
6574 |
+ args.push("--verbose"); |
|
6575 |
+ args.push((new lib_path.class_filepointer(this.filepointer_from.location, "*")).as_string(globalvars.configuration.system)); |
|
5642 | 6576 |
} |
5643 | 6577 |
else { |
5644 |
- parts.push(this.filepointer_from.as_string(configuration.system)); |
|
6578 |
+ args.push(this.filepointer_from.as_string(globalvars.configuration.system)); |
|
5645 | 6579 |
} |
5646 |
- parts.push(this.filepointer_to.as_string(configuration.system)); |
|
5647 |
- return parts.join(" "); |
|
6580 |
+ args.push(this.filepointer_to.as_string(globalvars.configuration.system)); |
|
6581 |
+ return (lib_gnumake.macro_command({ |
|
6582 |
+ "path": "cp", |
|
6583 |
+ "args": args, |
|
6584 |
+ })); |
|
6585 |
+ break; |
|
6586 |
+ } |
|
6587 |
+ case "bsd": { |
|
6588 |
+ var args = []; |
|
6589 |
+ if (this.folder) { |
|
6590 |
+ args.push("-r"); |
|
6591 |
+ // args.push("-u"); |
|
6592 |
+ args.push("-v"); |
|
6593 |
+ args.push((new lib_path.class_filepointer(this.filepointer_from.location, "*")).as_string(globalvars.configuration.system)); |
|
6594 |
+ } |
|
6595 |
+ else { |
|
6596 |
+ args.push(this.filepointer_from.as_string(globalvars.configuration.system)); |
|
6597 |
+ } |
|
6598 |
+ args.push(this.filepointer_to.as_string(globalvars.configuration.system)); |
|
6599 |
+ return (lib_gnumake.macro_command({ |
|
6600 |
+ "path": "cp", |
|
6601 |
+ "args": args, |
|
6602 |
+ })); |
|
6603 |
+ break; |
|
6604 |
+ } |
|
6605 |
+ case "win": { |
|
6606 |
+ throw (new Error("not implemented")); |
|
5648 | 6607 |
break; |
5649 | 6608 |
} |
5650 | 6609 |
default: { |
... | ... |
@@ -5657,16 +6616,16 @@ var class_action_copy = (function (_super) { |
5657 | 6616 |
case "ant": { |
5658 | 6617 |
if (!this.folder) { |
5659 | 6618 |
return (new lib_ant.class_action(new lib_xml.class_node_complex("copy", { |
5660 |
- "file": this.filepointer_from.as_string("unix"), |
|
5661 |
- "tofile": this.filepointer_to.as_string("unix"), |
|
6619 |
+ "file": this.filepointer_from.as_string("linux"), |
|
6620 |
+ "tofile": this.filepointer_to.as_string("linux"), |
|
5662 | 6621 |
}))); |
5663 | 6622 |
} |
5664 | 6623 |
else { |
5665 | 6624 |
return (new lib_ant.class_action(new lib_xml.class_node_complex("copy", { |
5666 |
- "todir": this.filepointer_to.as_string("unix"), |
|
6625 |
+ "todir": this.filepointer_to.as_string("linux"), |
|
5667 | 6626 |
}, [ |
5668 | 6627 |
new lib_xml.class_node_complex("fileset", { |
5669 |
- "dir": this.filepointer_from.as_string("unix"), |
|
6628 |
+ "dir": this.filepointer_from.as_string("linux"), |
|
5670 | 6629 |
}) |
5671 | 6630 |
]))); |
5672 | 6631 |
} |
... | ... |
@@ -5690,9 +6649,10 @@ var class_action_move = (function (_super) { |
5690 | 6649 |
*/ |
5691 | 6650 |
function class_action_move(_a) { |
5692 | 6651 |
var from = _a["from"], to = _a["to"]; |
5693 |
- _super.call(this); |
|
5694 |
- this.from = from; |
|
5695 |
- this.to = to; |
|
6652 |
+ var _this = _super.call(this) || this; |
|
6653 |
+ _this.from = from; |
|
6654 |
+ _this.to = to; |
|
6655 |
+ return _this; |
|
5696 | 6656 |
} |
5697 | 6657 |
/** |
5698 | 6658 |
* @desc for defining directly how the action is to be converted into a target-piece |
... | ... |
@@ -5701,17 +6661,19 @@ var class_action_move = (function (_super) { |
5701 | 6661 |
class_action_move.prototype.compilation = function (output_identifier) { |
5702 | 6662 |
switch (output_identifier) { |
5703 | 6663 |
case "gnumake": { |
5704 |
- switch (configuration.system) { |
|
5705 |
- case "unix": |
|
6664 |
+ switch (globalvars.configuration.system) { |
|
6665 |
+ case "linux": |
|
6666 |
+ case "bsd": |
|
5706 | 6667 |
case "win": { |
5707 |
- var from = this.from.as_string(configuration.system); |
|
5708 |
- var to = this.to.as_string(configuration.system); |
|
6668 |
+ var from = this.from.as_string(globalvars.configuration.system); |
|
6669 |
+ var to = this.to.as_string(globalvars.configuration.system); |
|
5709 | 6670 |
var command = ""; |
5710 | 6671 |
{ |
5711 | 6672 |
command = lib_gnumake.macro_command({ |
5712 | 6673 |
"path": "mv", |
5713 |
- "args": ["--verbose", from, to], |
|
5714 |
- "system": configuration.system, |
|
6674 |
+ // "args": ["--verbose", from, to], |
|
6675 |
+ "args": [from, to], |
|
6676 |
+ "system": globalvars.configuration.system, |
|
5715 | 6677 |
}); |
5716 | 6678 |
} |
5717 | 6679 |
{ |
... | ... |
@@ -5729,8 +6691,8 @@ var class_action_move = (function (_super) { |
5729 | 6691 |
} |
5730 | 6692 |
case "ant": { |
5731 | 6693 |
return (new lib_ant.class_action(new lib_xml.class_node_complex("move", { |
5732 |
- "file": this.from.as_string("unix"), |
|
5733 |
- "tofile": this.to.as_string("unix"), |
|
6694 |
+ "file": this.from.as_string("linux"), |
|
6695 |
+ "tofile": this.to.as_string("linux"), |
|
5734 | 6696 |
}))); |
5735 | 6697 |
break; |
5736 | 6698 |
} |
... | ... |
@@ -5750,10 +6712,13 @@ var class_action_concat = (function (_super) { |
5750 | 6712 |
/** |
5751 | 6713 |
* @author fenris |
5752 | 6714 |
*/ |
5753 |
- function class_action_concat(sources, destination) { |
|
5754 |
- _super.call(this); |
|
5755 |
- this.sources = sources; |
|
5756 |
- this.destination = destination; |
|
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; |
|
5757 | 6722 |
} |
5758 | 6723 |
/** |
5759 | 6724 |
* @desc for defining directly how the action is to be converted into a target-piece |
... | ... |
@@ -5765,30 +6730,33 @@ var class_action_concat = (function (_super) { |
5765 | 6730 |
if (this.sources.length > 0) { |
5766 | 6731 |
return (lib_gnumake.macro_command({ |
5767 | 6732 |
"path": { |
5768 |
- "unix": "cat", |
|
6733 |
+ "linux": "cat", |
|
6734 |
+ "bsd": "cat", |
|
5769 | 6735 |
"win": "type", |
5770 |
- }[configuration.system], |
|
5771 |
- "args": this.sources.map(function (source) { return source.as_string(configuration.system); }), |
|
5772 |
- "output": this.destination.as_string(configuration.system), |
|
6736 |
+ }[globalvars.configuration.system], |
|
6737 |
+ "args": this.sources.map(function (source) { return source.as_string(globalvars.configuration.system); }), |
|
6738 |
+ "output": this.destination.as_string(globalvars.configuration.system), |
|
5773 | 6739 |
})); |
5774 | 6740 |
} |
5775 | 6741 |
else { |
5776 | 6742 |
return (lib_gnumake.macro_command({ |
5777 | 6743 |
"path": "touch", |
5778 |
- "output": this.destination.as_string(configuration.system), |
|
6744 |
+ "output": this.destination.as_string(globalvars.configuration.system), |
|
5779 | 6745 |
})); |
5780 | 6746 |
} |
5781 | 6747 |
break; |
5782 | 6748 |
} |
5783 | 6749 |
case "ant": { |
5784 |
- return (new lib_ant.class_action(new lib_xml.class_node_complex("concat", { "destfile": this.destination.as_string("unix") }, [ |
|
6750 |
+ return (new lib_ant.class_action(new lib_xml.class_node_complex("concat", { "destfile": this.destination.as_string("linux") }, [ |
|
5785 | 6751 |
new lib_xml.class_node_complex("filelist", { "dir": "." }, this.sources.map(function (source) { |
5786 |
- return (new lib_xml.class_node_complex("file", { "name": source.as_string("unix") })); |
|
6752 |
+ return (new lib_xml.class_node_complex("file", { "name": source.as_string("linux") })); |
|
5787 | 6753 |
})) |
5788 | 6754 |
]))); |
6755 |
+ break; |
|
5789 | 6756 |
} |
5790 | 6757 |
default: { |
5791 | 6758 |
throw (new Error("unhandled output '" + output_identifier + "'")); |
6759 |
+ break; |
|
5792 | 6760 |
} |
5793 | 6761 |
} |
5794 | 6762 |
}; |
... | ... |
@@ -5803,57 +6771,30 @@ var class_action_lessc = (function (_super) { |
5803 | 6771 |
* @author fenris |
5804 | 6772 |
*/ |
5805 | 6773 |
function class_action_lessc(filepointer_from, filepointer_to) { |
5806 |
- _super.call(this); |
|
5807 |
- this.filepointer_from = filepointer_from; |
|
5808 |
- this.filepointer_to = filepointer_to; |
|
6774 |
+ var _this = _super.call(this) || this; |
|
6775 |
+ _this.filepointer_from = filepointer_from; |
|
6776 |
+ _this.filepointer_to = filepointer_to; |
|
6777 |
+ return _this; |
|
5809 | 6778 |
} |
5810 | 6779 |
/** |
6780 |
+ * @override |
|
5811 | 6781 |
* @author fenris |
5812 | 6782 |
*/ |
5813 | 6783 |
class_action_lessc.prototype.compilation = function (target_identifier) { |
6784 |
+ var args = []; |
|
6785 |
+ args.push(this.filepointer_from.as_string(globalvars.configuration.system)); |
|
6786 |
+ var cmdparams = { |
|
6787 |
+ "path": "lessc", |
|
6788 |
+ "args": args, |
|
6789 |
+ "output": this.filepointer_to.as_string(globalvars.configuration.system), |
|
6790 |
+ }; |
|
5814 | 6791 |
switch (target_identifier) { |
5815 | 6792 |
case "gnumake": { |
5816 |
- switch (configuration["system"]) { |
|
5817 |
- case "unix": |
|
5818 |
- case "win": { |
|
5819 |
- var parts = []; |
|
5820 |
- parts.push("lessc"); |
|
5821 |
- parts.push(this.filepointer_from.toString()); |
|
5822 |
- parts.push(this.filepointer_to.toString()); |
|
5823 |
- return parts.join(" "); |
|
5824 |
- break; |
|
5825 |
- } |
|
5826 |
- default: { |
|
5827 |
- throw (new Error("not implemented")); |
|
5828 |
- break; |
|
5829 |
- } |
|
5830 |
- } |
|
6793 |
+ return lib_gnumake.macro_command(cmdparams); |
|
5831 | 6794 |
break; |
5832 | 6795 |
} |
5833 | 6796 |
case "ant": { |
5834 |
- switch (configuration["system"]) { |
|
5835 |
- case "unix": { |
|
5836 |
- return (new lib_ant.class_action(new lib_xml.class_node_complex("exec", { |
|
5837 |
- "executable": "lessc", |
|
5838 |
- "output": this.filepointer_to.toString(), |
|
5839 |
- }, [ |
|
5840 |
- new lib_xml.class_node_complex("arg", { "value": this.filepointer_from.toString() }), |
|
5841 |
- ]))); |
|
5842 |
- } |
|
5843 |
- case "win": { |
|
5844 |
- return (new lib_ant.class_action(new lib_xml.class_node_complex("exec", { |
|
5845 |
- "executable": "cmd", |
|
5846 |
- "output": this.filepointer_to.toString(), |
|
5847 |
- }, [ |
|
5848 |
- new lib_xml.class_node_complex("arg", { "value": "/c" }), |
|
5849 |
- new lib_xml.class_node_complex("arg", { "value": "lessc" }), |
|
5850 |
- new lib_xml.class_node_complex("arg", { "value": this.filepointer_from.toString() }), |
|
5851 |
- ]))); |
|
5852 |
- } |
|
5853 |
- default: { |
|
5854 |
- throw (new Error("not implemented")); |
|
5855 |
- } |
|
5856 |
- } |
|
6797 |
+ return lib_ant.class_action.macro_command(cmdparams); |
|
5857 | 6798 |
break; |
5858 | 6799 |
} |
5859 | 6800 |
default: { |
... | ... |
@@ -5873,33 +6814,28 @@ var class_action_babel = (function (_super) { |
5873 | 6814 |
* @author neu3no |
5874 | 6815 |
*/ |
5875 | 6816 |
function class_action_babel(filepointers_from, filepointer_to, preset, minify) { |
5876 |
- _super.call(this); |
|
5877 |
- this.filepointers_from = filepointers_from; |
|
5878 |
- this.filepointer_to = filepointer_to; |
|
5879 |
- this.preset = preset; |
|
5880 |
- this.minify = 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; |
|
5881 | 6823 |
} |
5882 | 6824 |
/** |
5883 |
- * @desc for defining directly how the action is to be converted into a target-piece |
|
5884 |
- * @author neu3no |
|
6825 |
+ * @override |
|
6826 |
+ * @author neu3no,fenris |
|
5885 | 6827 |
*/ |
5886 | 6828 |
class_action_babel.prototype.compilation = function (target_identifier) { |
5887 |
- switch (target_identifier) { |
|
5888 |
- case "gnumake": { |
|
5889 |
- var parts_3 = []; |
|
5890 |
- switch (configuration["system"]) { |
|
5891 |
- case "unix": |
|
5892 |
- case "win": |
|
5893 |
- parts_3.push("babel"); |
|
5894 |
- parts_3.push("--no-babelrc"); |
|
6829 |
+ var args = []; |
|
6830 |
+ args.push("--no-babelrc"); |
|
5895 | 6831 |
// input |
5896 | 6832 |
{ |
5897 |
- this.filepointers_from.forEach(function (filepointer) { return parts_3.push(filepointer.as_string(configuration["system"])); }); |
|
6833 |
+ this.filepointers_from.forEach(function (filepointer) { return args.push(filepointer.as_string(globalvars.configuration.system)); }); |
|
5898 | 6834 |
} |
5899 | 6835 |
// output |
5900 | 6836 |
{ |
5901 |
- parts_3.push("--out-file"); |
|
5902 |
- parts_3.push(this.filepointer_to.as_string(configuration["system"])); |
|
6837 |
+ args.push("--out-file"); |
|
6838 |
+ args.push(this.filepointer_to.as_string(globalvars.configuration.system)); |
|
5903 | 6839 |
} |
5904 | 6840 |
// presets |
5905 | 6841 |
{ |
... | ... |
@@ -5908,23 +6844,30 @@ var class_action_babel = (function (_super) { |
5908 | 6844 |
presets.push(this.preset); |
5909 | 6845 |
} |
5910 | 6846 |
if (this.minify) { |
5911 |
- parts_3.push("--minified"); |
|
6847 |
+ args.push("--minified"); |
|
5912 | 6848 |
} |
5913 | 6849 |
if (presets.length > 0) { |
5914 |
- parts_3.push("--presets"); |
|
5915 |
- parts_3.push(presets.join(",")); |
|
6850 |
+ args.push("--presets"); |
|
6851 |
+ args.push(presets.join(",")); |
|
5916 | 6852 |
} |
5917 | 6853 |
} |
5918 |
- return parts_3.join(" "); |
|
6854 |
+ var cmdparams = { |
|
6855 |
+ "path": "babel", |
|
6856 |
+ "args": args, |
|
6857 |
+ "output": this.filepointer_to.as_string(globalvars.configuration.system), |
|
6858 |
+ }; |
|
6859 |
+ switch (target_identifier) { |
|
6860 |
+ case "gnumake": { |
|
6861 |
+ return lib_gnumake.macro_command(cmdparams); |
|
5919 | 6862 |
break; |
5920 |
- default: { |
|
5921 |
- throw (new Error("not implemented")); |
|
5922 |
- } |
|
5923 | 6863 |
} |
6864 |
+ case "ant": { |
|
6865 |
+ return lib_ant.class_action.macro_command(cmdparams); |
|
5924 | 6866 |
break; |
5925 | 6867 |
} |
5926 | 6868 |
default: { |
5927 | 6869 |
throw (new Error("unhandled target '" + target_identifier + "'")); |
6870 |
+ break; |
|
5928 | 6871 |
} |
5929 | 6872 |
} |
5930 | 6873 |
}; |
... | ... |
@@ -5939,12 +6882,13 @@ var class_action_tsc = (function (_super) { |
5939 | 6882 |
* @author fenris |
5940 | 6883 |
*/ |
5941 | 6884 |
function class_action_tsc(paths_input, path_output, target, allowUnreachableCode, declaration) { |
5942 |
- _super.call(this); |
|
5943 |
- this.paths_input = paths_input; |
|
5944 |
- this.path_output = path_output; |
|
5945 |
- this.target = target; |
|
5946 |
- this.allowUnreachableCode = allowUnreachableCode; |
|
5947 |
- this.declaration = 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; |
|
5948 | 6892 |
} |
5949 | 6893 |
/** |
5950 | 6894 |
* @author fenris |
... | ... |
@@ -5957,11 +6901,6 @@ var class_action_tsc = (function (_super) { |
5957 | 6901 |
args.push("--allowUnreachableCode"); |
5958 | 6902 |
} |
5959 | 6903 |
} |
5960 |
- { |
|
5961 |
- if (this.declaration != null) { |
|
5962 |
- args.push("--declaration"); |
|
5963 |
- } |
|
5964 |
- } |
|
5965 | 6904 |
{ |
5966 | 6905 |
if (this.target != null) { |
5967 | 6906 |
args.push("--target"); |
... | ... |
@@ -5969,16 +6908,21 @@ var class_action_tsc = (function (_super) { |
5969 | 6908 |
} |
5970 | 6909 |
} |
5971 | 6910 |
{ |
5972 |
- this.paths_input.forEach(function (filepointer) { return args.push(filepointer.as_string(configuration.system)); }); |
|
6911 |
+ this.paths_input.forEach(function (filepointer) { return args.push(filepointer.as_string(globalvars.configuration.system)); }); |
|
6912 |
+ } |
|
6913 |
+ { |
|
6914 |
+ if (this.declaration != null) { |
|
6915 |
+ args.push("--declaration"); |
|
6916 |
+ } |
|
5973 | 6917 |
} |
5974 | 6918 |
{ |
5975 | 6919 |
args.push("--outFile"); |
5976 |
- args.push(this.path_output.as_string(configuration.system)); |
|
6920 |
+ args.push(this.path_output.as_string(globalvars.configuration.system)); |
|
5977 | 6921 |
} |
5978 | 6922 |
var cmdparams = { |
5979 | 6923 |
"path": "tsc", |
5980 | 6924 |
"args": args, |
5981 |
- "system": configuration.system, |
|
6925 |
+ "system": globalvars.configuration.system, |
|
5982 | 6926 |
}; |
5983 | 6927 |
switch (output_identifier) { |
5984 | 6928 |
case "gnumake": { |
... | ... |
@@ -6006,11 +6950,12 @@ var class_action_php = (function (_super) { |
6006 | 6950 |
* @author fenris |
6007 | 6951 |
*/ |
6008 | 6952 |
function class_action_php(filepointers_from, filepointer_to, only_first, only_last) { |
6009 |
- _super.call(this); |
|
6010 |
- this.filepointers_from = filepointers_from; |
|
6011 |
- this.filepointer_to = filepointer_to; |
|
6012 |
- this.only_first = only_first; |
|
6013 |
- this.only_last = 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; |
|
6014 | 6959 |
} |
6015 | 6960 |
/** |
6016 | 6961 |
* @desc for defining directly how the action is to be converted into a target-piece |
... | ... |
@@ -6019,24 +6964,25 @@ var class_action_php = (function (_super) { |
6019 | 6964 |
class_action_php.prototype.compilation = function (target_identifier) { |
6020 | 6965 |
switch (target_identifier) { |
6021 | 6966 |
case "gnumake": { |
6022 |
- switch (configuration.system) { |
|
6023 |
- case "unix": { |
|
6024 |
- var parts_4 = []; |
|
6025 |
- parts_4.push("php"); |
|
6967 |
+ switch (globalvars.configuration.system) { |
|
6968 |
+ case "bsd": |
|
6969 |
+ case "linux": { |
|
6970 |
+ var parts_3 = []; |
|
6971 |
+ parts_3.push("php"); |
|
6026 | 6972 |
if (this.only_last) { |
6027 |
- parts_4.push(this.filepointers_from.slice(-1)[0].toString()); |
|
6973 |
+ parts_3.push(this.filepointers_from.slice(-1)[0].toString()); |
|
6028 | 6974 |
} |
6029 | 6975 |
else { |
6030 | 6976 |
if (this.only_first) { |
6031 |
- parts_4.push(this.filepointers_from[0].toString()); |
|
6977 |
+ parts_3.push(this.filepointers_from[0].toString()); |
|
6032 | 6978 |
} |
6033 | 6979 |
else { |
6034 |
- this.filepointers_from.forEach(function (filepointer) { return parts_4.push(filepointer.toString()); }); |
|
6980 |
+ this.filepointers_from.forEach(function (filepointer) { return parts_3.push(filepointer.toString()); }); |
|
6035 | 6981 |
} |
6036 | 6982 |
} |
6037 |
- parts_4.push(">"); |
|
6038 |
- parts_4.push(this.filepointer_to.toString()); |
|
6039 |
- return parts_4.join(" "); |
|
6983 |
+ parts_3.push(">"); |
|
6984 |
+ parts_3.push(this.filepointer_to.toString()); |
|
6985 |
+ return parts_3.join(" "); |
|
6040 | 6986 |
break; |
6041 | 6987 |
} |
6042 | 6988 |
default: { |
... | ... |
@@ -6067,8 +7013,9 @@ var class_action_gitpull = (function (_super) { |
6067 | 7013 |
* @author fenris |
6068 | 7014 |
*/ |
6069 | 7015 |
function class_action_gitpull(url) { |
6070 |
- _super.call(this); |
|
6071 |
- this.url = url; |
|
7016 |
+ var _this = _super.call(this) || this; |
|
7017 |
+ _this.url = url; |
|
7018 |
+ return _this; |
|
6072 | 7019 |
} |
6073 | 7020 |
/** |
6074 | 7021 |
* @desc for defining directly how the action is to be converted into a target-piece |
... | ... |
@@ -6078,8 +7025,8 @@ var class_action_gitpull = (function (_super) { |
6078 | 7025 |
class_action_gitpull.prototype.compilation = function (target_identifier) { |
6079 | 7026 |
switch (target_identifier) { |
6080 | 7027 |
case "gnumake": { |
6081 |
- switch (configuration["system"]) { |
|
6082 |
- case "unix": |
|
7028 |
+ switch (globalvars.configuration["system"]) { |
|
7029 |
+ case "linux": |
|
6083 | 7030 |
case "win": { |
6084 | 7031 |
var parts = []; |
6085 | 7032 |
parts.push("git pull"); |
... | ... |
@@ -6115,6 +7062,86 @@ var class_action_gitpull = (function (_super) { |
6115 | 7062 |
}; |
6116 | 7063 |
return class_action_gitpull; |
6117 | 7064 |
}(class_action_adhoc)); |
7065 |
+/** |
|
7066 |
+ * @author fenris |
|
7067 |
+ */ |
|
7068 |
+var class_action_schwamm = (function (_super) { |
|
7069 |
+ __extends(class_action_schwamm, _super); |
|
7070 |
+ /** |
|
7071 |
+ * @author fenris |
|
7072 |
+ */ |
|
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; |
|
7089 |
+ } |
|
7090 |
+ /** |
|
7091 |
+ * @desc for defining directly how the action is to be converted into a target-piece |
|
7092 |
+ * @author fenris |
|
7093 |
+ */ |
|
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"])); |
|
7098 |
+ }); |
|
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); |
|
7103 |
+ }); |
|
7104 |
+ }); |
|
7105 |
+ // args.push(`--file=${this.output.as_string(globalvars.configuration["system"])}`); |
|
7106 |
+ // args.push(`--dir=${((this.dir != null) ? this.dir : this.output.location).as_string("system")}`); |
|
7107 |
+ var target; |
|
7108 |
+ if (this.save != undefined) { |
|
7109 |
+ args.push("--output=native"); |
|
7110 |
+ target = this.save; |
|
7111 |
+ } |
|
7112 |
+ else if (this.dump_group != null) { |
|
7113 |
+ args.push("--output=dump:" + this.dump_group); |
|
7114 |
+ target = this.dump_filepointer; |
|
7115 |
+ } |
|
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 |
+ else { |
|
7121 |
+ console.warn("output missing?"); |
|
7122 |
+ } |
|
7123 |
+ var cmdparams = { |
|
7124 |
+ "path": "schwamm", |
|
7125 |
+ "args": args, |
|
7126 |
+ "output": target.as_string(globalvars.configuration["system"]), |
|
7127 |
+ }; |
|
7128 |
+ switch (target_identifier) { |
|
7129 |
+ case "gnumake": { |
|
7130 |
+ return lib_gnumake.macro_command(cmdparams); |
|
7131 |
+ break; |
|
7132 |
+ } |
|
7133 |
+ case "ant": { |
|
7134 |
+ return lib_ant.class_action.macro_command(cmdparams); |
|
7135 |
+ break; |
|
7136 |
+ } |
|
7137 |
+ default: { |
|
7138 |
+ throw (new Error("unhandled target '" + target_identifier + "'")); |
|
7139 |
+ break; |
|
7140 |
+ } |
|
7141 |
+ } |
|
7142 |
+ }; |
|
7143 |
+ return class_action_schwamm; |
|
7144 |
+}(class_action_adhoc)); |
|
6118 | 7145 |
/** |
6119 | 7146 |
* @author fenris |
6120 | 7147 |
*/ |
... | ... |
@@ -6124,11 +7151,12 @@ var class_action_schwamm_create = (function (_super) { |
6124 | 7151 |
* @author fenris |
6125 | 7152 |
*/ |
6126 | 7153 |
function class_action_schwamm_create(includes, adhoc, output, dir) { |
6127 |
- _super.call(this); |
|
6128 |
- this.includes = includes; |
|
6129 |
- this.adhoc = adhoc; |
|
6130 |
- this.output = output; |
|
6131 |
- this.dir = 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; |
|
6132 | 7160 |
} |
6133 | 7161 |
/** |
6134 | 7162 |
* @desc for defining directly how the action is to be converted into a target-piece |
... | ... |
@@ -6137,22 +7165,22 @@ var class_action_schwamm_create = (function (_super) { |
6137 | 7165 |
class_action_schwamm_create.prototype.compilation = function (target_identifier) { |
6138 | 7166 |
var _this = this; |
6139 | 7167 |
var args = []; |
6140 |
- args.push("create"); |
|
6141 | 7168 |
this.includes.forEach(function (include) { |
6142 |
- args.push("--include=" + include.as_string(configuration["unix"])); |
|
7169 |
+ args.push("--include=" + include.as_string(globalvars.configuration["system"])); |
|
6143 | 7170 |
}); |
6144 | 7171 |
Object.keys(this.adhoc).forEach(function (group) { |
6145 | 7172 |
_this.adhoc[group].forEach(function (member) { |
6146 | 7173 |
var filepointer = member; |
6147 |
- args.push("--adhoc=" + group + ":" + filepointer.as_string(configuration["unix"])); |
|
7174 |
+ args.push("--input=" + filepointer.as_string(globalvars.configuration["system"]) + ":" + group); |
|
6148 | 7175 |
}); |
6149 | 7176 |
}); |
6150 |
- // args.push(`--file=${this.output.as_string(configuration["system"])}`); |
|
6151 |
- args.push("--dir=" + ((this.dir != null) ? this.dir : this.output.location).as_string("unix")); |
|
7177 |
+ args.push("--output=native"); |
|
7178 |
+ // args.push(`--file=${this.output.as_string(globalvars.configuration["system"])}`); |
|
7179 |
+ // args.push(`--dir=${((this.dir != null) ? this.dir : this.output.location).as_string("linux")}`); |
|
6152 | 7180 |
var cmdparams = { |
6153 | 7181 |
"path": "schwamm", |
6154 | 7182 |
"args": args, |
6155 |
- "output": this.output.as_string(configuration["unix"]), |
|
7183 |
+ "output": this.output.as_string(globalvars.configuration["system"]), |
|
6156 | 7184 |
}; |
6157 | 7185 |
switch (target_identifier) { |
6158 | 7186 |
case "gnumake": { |
... | ... |
@@ -6179,27 +7207,26 @@ var class_action_schwamm_apply = (function (_super) { |
6179 | 7207 |
/** |
6180 | 7208 |
* @author fenris |
6181 | 7209 |
*/ |
6182 |
- function class_action_schwamm_apply(path, outputs) { |
|
6183 |
- _super.call(this); |
|
6184 |
- this.path = path; |
|
6185 |
- this.outputs = outputs; |
|
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; |
|
6186 | 7216 |
} |
6187 | 7217 |
/** |
6188 | 7218 |
* @desc for defining directly how the action is to be converted into a target-piece |
6189 | 7219 |
* @author fenris |
6190 | 7220 |
*/ |
6191 | 7221 |
class_action_schwamm_apply.prototype.compilation = function (target_identifier) { |
6192 |
- var _this = this; |
|
6193 | 7222 |
var args = []; |
6194 |
- args.push("apply"); |
|
6195 |
- args.push("--file=" + this.path.as_string(configuration["system"])); |
|
6196 |
- Object.keys(this.outputs).forEach(function (groupname) { |
|
6197 |
- var filepointer = lib_path.filepointer_read(configuration["path"]).foo(_this.outputs[groupname]); |
|
6198 |
- args.push("--output=" + groupname + ":" + filepointer.as_string(configuration["system"])); |
|
6199 |
- }); |
|
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); |
|
6200 | 7226 |
var cmdparams = { |
6201 | 7227 |
"path": "schwamm", |
6202 | 7228 |
"args": args, |
7229 |
+ "output": filepointer.as_string(globalvars.configuration["system"]), |
|
6203 | 7230 |
}; |
6204 | 7231 |
switch (target_identifier) { |
6205 | 7232 |
case "gnumake": { |
... | ... |
@@ -6284,31 +7311,50 @@ var class_task = (function () { |
6284 | 7311 |
this._outputs = _outputs; |
6285 | 7312 |
this._actions = _actions; |
6286 | 7313 |
// this.parameters = parameters; |
7314 |
+ this.context = null; |
|
6287 | 7315 |
} |
6288 | 7316 |
/** |
7317 |
+ * @desc [accessor] [getter] |
|
6289 | 7318 |
* @author fenris |
6290 | 7319 |
*/ |
6291 | 7320 |
class_task.prototype.identifier_get = function () { |
6292 | 7321 |
return this.identifier; |
6293 | 7322 |
}; |
6294 | 7323 |
/** |
7324 |
+ * @desc [accessor] [getter] |
|
6295 | 7325 |
* @author fenris |
6296 | 7326 |
*/ |
6297 | 7327 |
class_task.prototype.name_get = function () { |
6298 | 7328 |
return this.name; |
6299 | 7329 |
}; |
6300 | 7330 |
/** |
7331 |
+ * @desc [accessor] [getter] |
|
6301 | 7332 |
* @author fenris |
6302 | 7333 |
*/ |
6303 | 7334 |
class_task.prototype.sub_get = function () { |
6304 | 7335 |
return this.sub; |
6305 | 7336 |
}; |
6306 | 7337 |
/** |
7338 |
+ * @desc [accessor] [getter] |
|
6307 | 7339 |
* @author fenris |
6308 | 7340 |
*/ |
6309 | 7341 |
class_task.prototype.active_get = function () { |
6310 | 7342 |
return this.active; |
6311 | 7343 |
}; |
7344 |
+ /** |
|
7345 |
+ * @desc [mutator] [setter] |
|
7346 |
+ * @author fenris |
|
7347 |
+ */ |
|
7348 |
+ class_task.prototype.context_set = function (context) { |
|
7349 |
+ this.context = context; |
|
7350 |
+ }; |
|
7351 |
+ /** |
|
7352 |
+ * @desc [accessor] [getter] |
|
7353 |
+ * @author fenris |
|
7354 |
+ */ |
|
7355 |
+ class_task.prototype.context_get = function () { |
|
7356 |
+ return this.context; |
|
7357 |
+ }; |
|
6312 | 7358 |
/** |
6313 | 7359 |
* @returns the subgraph of all active tasks |
6314 | 7360 |
* @author fenris |
... | ... |
@@ -6324,32 +7370,41 @@ var class_task = (function () { |
6324 | 7370 |
} |
6325 | 7371 |
}; |
6326 | 7372 |
/** |
7373 |
+ * @desc [accessor] [getter] |
|
6327 | 7374 |
* @author fenris |
6328 | 7375 |
*/ |
6329 | 7376 |
class_task.prototype.values = function (raw) { |
6330 | 7377 |
return null; |
6331 | 7378 |
}; |
6332 | 7379 |
/** |
6333 |
- * @desc a list of paths which represent input-files of the task |
|
7380 |
+ * @desc [accessor] [getter] a list of paths which represent input-files of the task |
|
6334 | 7381 |
* @author fenris |
6335 | 7382 |
*/ |
6336 | 7383 |
class_task.prototype.inputs = function () { |
6337 | 7384 |
return this._inputs; |
6338 | 7385 |
}; |
6339 | 7386 |
/** |
6340 |
- * @desc a list of paths which represent output-files of the task |
|
7387 |
+ * @desc [accessor] [getter] a list of paths which represent output-files of the task |
|
6341 | 7388 |
* @author fenris |
6342 | 7389 |
*/ |
6343 | 7390 |
class_task.prototype.outputs = function () { |
6344 | 7391 |
return this._outputs; |
6345 | 7392 |
}; |
6346 | 7393 |
/** |
6347 |
- * @desc generates all actions which have to be executed in order to fulfil the task |
|
7394 |
+ * @desc [accessor] [getter] generates all actions which have to be executed in order to fulfil the task |
|
6348 | 7395 |
* @author fenris |
6349 | 7396 |
*/ |
6350 | 7397 |
class_task.prototype.actions = function () { |
6351 | 7398 |
return this._actions; |
6352 | 7399 |
}; |
7400 |
+ /** |
|
7401 |
+ * @author fenris |
|
7402 |
+ */ |
|
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 |
+ }; |
|
6353 | 7408 |
/** |
6354 | 7409 |
* @author fenris |
6355 | 7410 |
*/ |
... | ... |
@@ -6379,83 +7434,57 @@ var class_task = (function () { |
6379 | 7434 |
class_task.errormessage_mandatoryparamater = function (type, name, fieldname) { |
6380 | 7435 |
return "mandatory paramater '" + fieldname + "' missing in " + type + "-task '" + name + "'"; |
6381 | 7436 |
}; |
7437 |
+ return class_task; |
|
7438 |
+}()); |
|
6382 | 7439 |
/** |
6383 | 7440 |
* @author fenris |
6384 | 7441 |
*/ |
6385 | 7442 |
class_task.pool = {}; |
6386 |
- return class_task; |
|
6387 |
-}()); |
|
6388 | 7443 |
/** |
6389 | 7444 |
* @author fenris |
6390 | 7445 |
*/ |
6391 |
-var class_task_group = (function (_super) { |
|
6392 |
- __extends(class_task_group, _super); |
|
7446 |
+var class_task_empty = (function (_super) { |
|
7447 |
+ __extends(class_task_empty, _super); |
|
6393 | 7448 |
/** |
6394 | 7449 |
* @author fenris |
6395 | 7450 |
*/ |
6396 |
- function class_task_group(_a) { |
|
6397 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"]; |
|
6398 |
- _super.call(this, name, sub, active, [], [], []); |
|
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"))); |
|
6399 | 7456 |
} |
6400 |
- return class_task_group; |
|
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 |
+ } |
|
7464 |
+ return class_task_empty; |
|
6401 | 7465 |
}(class_task)); |
6402 |
-class_task.register("group", function (name, sub, active, parameters) { return new class_task_group({ |
|
7466 |
+class_task.register("empty", function (name, sub, active, parameters) { return new class_task_empty({ |
|
6403 | 7467 |
"name": name, "sub": sub, "active": active, |
6404 | 7468 |
"parameters": parameters, |
6405 | 7469 |
}); }); |
6406 | 7470 |
/** |
6407 | 7471 |
* @author fenris |
6408 | 7472 |
*/ |
6409 |
-var class_task_dependency = (function (_super) { |
|
6410 |
- __extends(class_task_dependency, _super); |
|
7473 |
+var class_task_group = (function (_super) { |
|
7474 |
+ __extends(class_task_group, _super); |
|
6411 | 7475 |
/** |
6412 | 7476 |
* @author fenris |
6413 | 7477 |
*/ |
6414 |
- function class_task_dependency(_a) { |
|
6415 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"], _c = _b["path"], path_raw = _c === void 0 ? null : _c, _d = _b["output"], output = _d === void 0 ? configuration["target"] : _d, _e = _b["raw"], raw = _e === void 0 ? true : _e, _f = _b["workdir"], workdir_raw = _f === void 0 ? null : _f; |
|
6416 |
- if (path_raw == undefined) { |
|
6417 |
- throw (new Error(class_task.errormessage_mandatoryparamater("dependency", name, "path"))); |
|
6418 |
- } |
|
6419 |
- var path = lib_call.use(path_raw, function (x) { return ((x == null) ? null : lib_path.filepointer_read(x)); }); |
|
6420 |
- var workdir = lib_call.use(workdir_raw, function (x) { return ((x == null) ? path.location : lib_path.location_read(x)); }); |
|
6421 |
- var actions = (function () { |
|
6422 |
- switch (output) { |
|
6423 |
- case "gnumake": { |
|
6424 |
- var filepointer_buildfile = new lib_path.class_filepointer(lib_path.location_read(configuration.tempfolder, configuration.system), "makefile"); |
|
6425 |
- return [ |
|
6426 |
- new class_action_koralle({ |
|
6427 |
- "filepointer_in": path, |
|
6428 |
- "filepointer_out": filepointer_buildfile, |
|
6429 |
- "output": output, |
|
6430 |
- "raw": raw, |
|
6431 |
- }), |
|
6432 |
- new class_action_gnumake(filepointer_buildfile, workdir), |
|
6433 |
- ]; |
|
6434 |
- break; |
|
6435 |
- } |
|
6436 |
- case "ant": { |
|
6437 |
- var filepointer_buildfile = new lib_path.class_filepointer(lib_path.location_read(configuration.tempfolder, configuration.system), "build.xml"); |
|
6438 |
- return [ |
|
6439 |
- new class_action_koralle({ |
|
6440 |
- "filepointer_in": path, |
|
6441 |
- "filepointer_out": filepointer_buildfile, |
|
6442 |
- "output": output, |
|
6443 |
- "raw": raw, |
|
6444 |
- }), |
|
6445 |
- new class_action_ant(filepointer_buildfile, workdir), |
|
6446 |
- ]; |
|
6447 |
- break; |
|
6448 |
- } |
|
6449 |
- default: { |
|
6450 |
- throw (new Error("unhandled target '${target}'")); |
|
6451 |
- break; |
|
6452 |
- } |
|
6453 |
- } |
|
6454 |
- })(); |
|
6455 |
- _super.call(this, name, sub, active, [path], [], actions); |
|
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; |
|
6456 | 7481 |
} |
6457 |
- return class_task_dependency; |
|
7482 |
+ return class_task_group; |
|
6458 | 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 |
+}); }); |
|
6459 | 7488 |
/** |
6460 | 7489 |
* @author fenris |
6461 | 7490 |
*/ |
... | ... |
@@ -6466,6 +7495,7 @@ var class_task_script = (function (_super) { |
6466 | 7495 |
*/ |
6467 | 7496 |
function class_task_script(_a) { |
6468 | 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; |
|
6469 | 7499 |
if (path_raw == undefined) { |
6470 | 7500 |
throw (new Error(class_task.errormessage_mandatoryparamater("script", name, "path"))); |
6471 | 7501 |
} |
... | ... |
@@ -6474,46 +7504,22 @@ var class_task_script = (function (_super) { |
6474 | 7504 |
var interpreter = lib_call.use(interpreter_raw, function (x) { return ((x == null) ? null : lib_path.filepointer_read(x)); }); |
6475 | 7505 |
var inputs = lib_call.use(inputs_raw, function (x) { return x.map(function (y) { return lib_path.filepointer_read(y); }); }); |
6476 | 7506 |
var outputs = lib_call.use(outputs_raw, function (x) { return x.map(function (y) { return lib_path.filepointer_read(y); }); }); |
6477 |
- _super.call(this, name, sub, active, inputs, outputs, ([] |
|
6478 |
- .concat(outputs.map(function (output) { return new class_action_mkdir(output.location); })) |
|
6479 |
- .concat([ |
|
6480 |
- new class_action_exec({ |
|
6481 |
- "inputs": inputs, |
|
6482 |
- "outputs": outputs, |
|
6483 |
- "path": path, |
|
6484 |
- "interpreter": interpreter, |
|
6485 |
- "workdir": workdir, |
|
6486 |
- }), |
|
6487 |
- ]))); |
|
6488 |
- } |
|
6489 |
- return class_task_script; |
|
6490 |
-}(class_task)); |
|
6491 |
-class_task.register("script", function (name, sub, active, parameters) { return new class_task_script({ |
|
6492 |
- "name": name, "sub": sub, "active": active, |
|
6493 |
- "parameters": parameters, |
|
6494 |
-}); }); |
|
6495 |
-/** |
|
6496 |
- * @author fenris |
|
6497 |
- */ |
|
6498 |
-var class_task_empty = (function (_super) { |
|
6499 |
- __extends(class_task_empty, _super); |
|
6500 |
- /** |
|
6501 |
- * @author fenris |
|
6502 |
- */ |
|
6503 |
- function class_task_empty(_a) { |
|
6504 |
- var name = _a["name"], sub = _a["sub"], active = _a["active"], _b = _a["parameters"]["output"], output_raw = _b === void 0 ? undefined : _b; |
|
6505 |
- if (output_raw == undefined) { |
|
6506 |
- throw (new Error(class_task.errormessage_mandatoryparamater("empty", name, "output"))); |
|
6507 |
- } |
|
6508 |
- var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
|
6509 |
- _super.call(this, name, sub, active, [], [output], [ |
|
6510 |
- new class_action_mkdir(output.location), |
|
6511 |
- new class_action_touch(output), |
|
6512 |
- ]); |
|
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; |
|
6513 | 7519 |
} |
6514 |
- return class_task_empty; |
|
7520 |
+ return class_task_script; |
|
6515 | 7521 |
}(class_task)); |
6516 |
-class_task.register("empty", function (name, sub, active, parameters) { return new class_task_empty({ |
|
7522 |
+class_task.register("script", function (name, sub, active, parameters) { return new class_task_script({ |
|
6517 | 7523 |
"name": name, "sub": sub, "active": active, |
6518 | 7524 |
"parameters": parameters, |
6519 | 7525 |
}); }); |
... | ... |
@@ -6527,6 +7533,7 @@ var class_task_copy = (function (_super) { |
6527 | 7533 |
*/ |
6528 | 7534 |
function class_task_copy(_a) { |
6529 | 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; |
|
6530 | 7537 |
if (input_raw == undefined) { |
6531 | 7538 |
throw (new Error(class_task.errormessage_mandatoryparamater("copy", name, "input"))); |
6532 | 7539 |
} |
... | ... |
@@ -6535,10 +7542,11 @@ var class_task_copy = (function (_super) { |
6535 | 7542 |
throw (new Error(class_task.errormessage_mandatoryparamater("copy", name, "output"))); |
6536 | 7543 |
} |
6537 | 7544 |
var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
6538 |
- _super.call(this, name, sub, active, folder ? [] : [input], folder ? [] : [output], [ |
|
7545 |
+ _this = _super.call(this, name, sub, active, folder ? [] : [input], folder ? [] : [output], [ |
|
6539 | 7546 |
new class_action_mkdir(output.location), |
6540 | 7547 |
new class_action_copy(input, output, folder), |
6541 |
- ]); |
|
7548 |
+ ]) || this; |
|
7549 |
+ return _this; |
|
6542 | 7550 |
} |
6543 | 7551 |
return class_task_copy; |
6544 | 7552 |
}(class_task)); |
... | ... |
@@ -6555,19 +7563,31 @@ var class_task_concat = (function (_super) { |
6555 | 7563 |
* @author fenris |
6556 | 7564 |
*/ |
6557 | 7565 |
function class_task_concat(_a) { |
6558 |
- 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; |
|
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; |
|
6559 | 7568 |
if (inputs_raw == undefined) { |
6560 | 7569 |
throw (new Error(class_task.errormessage_mandatoryparamater("concat", name, "inputs"))); |
6561 | 7570 |
} |
6562 | 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 |
+ }); |
|
6563 | 7578 |
if (output_raw == undefined) { |
6564 | 7579 |
throw (new Error(class_task.errormessage_mandatoryparamater("concat", name, "output"))); |
6565 | 7580 |
} |
6566 | 7581 |
var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
6567 |
- _super.call(this, name, sub, active, inputs, [output], [ |
|
7582 |
+ _this = _super.call(this, name, sub, active, ([] |
|
7583 |
+ .concat(inputs) |
|
7584 |
+ .concat((schwamminput == null) |
|
7585 |
+ ? [] |
|
7586 |
+ : [schwamminput.path])), [output], [ |
|
6568 | 7587 |
new class_action_mkdir(output.location), |
6569 | 7588 |
new class_action_concat(inputs, output), |
6570 |
- ]); |
|
7589 |
+ ]) || this; |
|
7590 |
+ return _this; |
|
6571 | 7591 |
} |
6572 | 7592 |
return class_task_concat; |
6573 | 7593 |
}(class_task)); |
... | ... |
@@ -6585,6 +7605,7 @@ var class_task_lesscss = (function (_super) { |
6585 | 7605 |
*/ |
6586 | 7606 |
function class_task_lesscss(_a) { |
6587 | 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; |
|
6588 | 7609 |
if (inputs_raw == undefined) { |
6589 | 7610 |
throw (new Error(class_task.errormessage_mandatoryparamater("lesscss", name, "inputs"))); |
6590 | 7611 |
} |
... | ... |
@@ -6593,12 +7614,13 @@ var class_task_lesscss = (function (_super) { |
6593 | 7614 |
throw (new Error(class_task.errormessage_mandatoryparamater("lesscss", name, "output"))); |
6594 | 7615 |
} |
6595 | 7616 |
var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
6596 |
- var filepointer_temp = new lib_path.class_filepointer(lib_path.location_read(configuration["tempfolder"]), "_.less"); |
|
6597 |
- _super.call(this, name, sub, active, inputs, [output], [ |
|
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], [ |
|
6598 | 7619 |
new class_action_mkdir(output.location), |
6599 | 7620 |
new class_action_concat(inputs, filepointer_temp), |
6600 | 7621 |
new class_action_lessc(filepointer_temp, output), |
6601 |
- ]); |
|
7622 |
+ ]) || this; |
|
7623 |
+ return _this; |
|
6602 | 7624 |
} |
6603 | 7625 |
return class_task_lesscss; |
6604 | 7626 |
}(class_task)); |
... | ... |
@@ -6614,52 +7636,29 @@ var class_task_babel = (function (_super) { |
6614 | 7636 |
/** |
6615 | 7637 |
* @author neu3no |
6616 | 7638 |
*/ |
6617 |
- function class_task_babel(name, sub, active, inputs_, output_, preset, minify) { |
|
6618 |
- if (name === void 0) { name = null; } |
|
6619 |
- if (sub === void 0) { sub = []; } |
|
6620 |
- if (active === void 0) { active = true; } |
|
6621 |
- if (inputs_ === void 0) { inputs_ = []; } |
|
6622 |
- if (output_ === void 0) { output_ = null; } |
|
6623 |
- if (preset === void 0) { preset = null; } |
|
6624 |
- if (minify === void 0) { minify = null; } |
|
6625 |
- _super.call(this, name, sub, active); |
|
6626 |
- this.inputs_ = inputs_; |
|
6627 |
- this.output_ = output_; |
|
6628 |
- this.preset = preset; |
|
6629 |
- this.minify = minify; |
|
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; |
|
6630 | 7655 |
} |
6631 |
- /** |
|
6632 |
- * @author neu3no |
|
6633 |
- */ |
|
6634 |
- class_task_babel.create = function (name, sub, active, parameters) { |
|
6635 |
- return (new class_task_babel(name, sub, active, object_fetch(parameters, "inputs", null, 2).map(function (x) { return lib_path.filepointer_read(x); }), lib_path.filepointer_read(object_fetch(parameters, "output", null, 2)), object_fetch(parameters, "preset", null, 0), object_fetch(parameters, "minify", false, 0))); |
|
6636 |
- }; |
|
6637 |
- /** |
|
6638 |
- * @override |
|
6639 |
- * @author neu3no |
|
6640 |
- */ |
|
6641 |
- class_task_babel.prototype.inputs = function () { |
|
6642 |
- return this.inputs_; |
|
6643 |
- }; |
|
6644 |
- /** |
|
6645 |
- * @override |
|
6646 |
- * @author neu3no |
|
6647 |
- */ |
|
6648 |
- class_task_babel.prototype.outputs = function () { |
|
6649 |
- return [this.output_]; |
|
6650 |
- }; |
|
6651 |
- /** |
|
6652 |
- * @author neu3no |
|
6653 |
- */ |
|
6654 |
- class_task_babel.prototype.actions = function () { |
|
6655 |
- return [ |
|
6656 |
- new class_action_mkdir(this.output_.location), |
|
6657 |
- new class_action_babel(this.inputs_, this.output_, this.preset, this.minify), |
|
6658 |
- ]; |
|
6659 |
- }; |
|
6660 | 7656 |
return class_task_babel; |
6661 | 7657 |
}(class_task)); |
6662 |
-class_task.register("babel", /*(name, sub, active, parameters) => */ class_task_babel.create /*(name, sub, active, parameters)*/); |
|
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 |
+}); }); |
|
6663 | 7662 |
/** |
6664 | 7663 |
* @author fenris |
6665 | 7664 |
*/ |
... | ... |
@@ -6670,6 +7669,7 @@ var class_task_typescript = (function (_super) { |
6670 | 7669 |
*/ |
6671 | 7670 |
function class_task_typescript(_a) { |
6672 | 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; |
|
6673 | 7673 |
/* |
6674 | 7674 |
[ |
6675 | 7675 |
new class_taskparameter<Array<string>, Array<lib_path.class_filepointer>>( |
... | ... |
@@ -6750,7 +7750,7 @@ var class_task_typescript = (function (_super) { |
6750 | 7750 |
var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
6751 | 7751 |
var declaration = lib_call.use(declaration_raw, function (x) { return ((x == null) ? null : lib_path.filepointer_read(x)); }); |
6752 | 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); })); |
6753 |
- _super.call(this, name, sub, active, inputs, ([] |
|
7753 |
+ _this = _super.call(this, name, sub, active, inputs, ([] |
|
6754 | 7754 |
.concat([output]) |
6755 | 7755 |
.concat((declaration == null) |
6756 | 7756 |
? [] |
... | ... |
@@ -6769,7 +7769,8 @@ var class_task_typescript = (function (_super) { |
6769 | 7769 |
"from": original, |
6770 | 7770 |
"to": declaration, |
6771 | 7771 |
}), |
6772 |
- ]))); |
|
7772 |
+ ]))) || this; |
|
7773 |
+ return _this; |
|
6773 | 7774 |
} |
6774 | 7775 |
return class_task_typescript; |
6775 | 7776 |
}(class_task)); |
... | ... |
@@ -6787,15 +7788,17 @@ var class_task_php = (function (_super) { |
6787 | 7788 |
*/ |
6788 | 7789 |
function class_task_php(_a) { |
6789 | 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; |
|
6790 | 7792 |
var inputs = lib_call.use(inputs_raw, function (x) { return x.map(function (y) { return lib_path.filepointer_read(y); }); }); |
6791 | 7793 |
if (output_raw == undefined) { |
6792 | 7794 |
throw (new Error(class_task.errormessage_mandatoryparamater("php", name, "output"))); |
6793 | 7795 |
} |
6794 | 7796 |
var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
6795 |
- _super.call(this, name, sub, active, inputs, [output], [ |
|
7797 |
+ _this = _super.call(this, name, sub, active, inputs, [output], [ |
|
6796 | 7798 |
new class_action_mkdir(output.location), |
6797 | 7799 |
new class_action_php(inputs, output, only_first, only_last), |
6798 |
- ]); |
|
7800 |
+ ]) || this; |
|
7801 |
+ return _this; |
|
6799 | 7802 |
} |
6800 | 7803 |
return class_task_php; |
6801 | 7804 |
}(class_task)); |
... | ... |
@@ -6803,6 +7806,60 @@ class_task.register("php", function (name, sub, active, parameters) { return new |
6803 | 7806 |
"name": name, "sub": sub, "active": active, |
6804 | 7807 |
"parameters": parameters, |
6805 | 7808 |
}); }); |
7809 |
+/** |
|
7810 |
+ * @author fenris |
|
7811 |
+ */ |
|
7812 |
+var class_task_schwamm = (function (_super) { |
|
7813 |
+ __extends(class_task_schwamm, _super); |
|
7814 |
+ /** |
|
7815 |
+ * @author fenris |
|
7816 |
+ */ |
|
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), |
|
7840 |
+ ]) |
|
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; |
|
7856 |
+ } |
|
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 |
+}); }); |
|
6806 | 7863 |
/** |
6807 | 7864 |
* @author fenris |
6808 | 7865 |
*/ |
... | ... |
@@ -6813,14 +7870,19 @@ var class_task_schwamm_create = (function (_super) { |
6813 | 7870 |
*/ |
6814 | 7871 |
function class_task_schwamm_create(_a) { |
6815 | 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; |
|
6816 | 7874 |
var includes = lib_call.use(includes_raw, function (x) { return x.map(function (y) { return lib_path.filepointer_read(y); }); }); |
6817 | 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 |
+ } |
|
6818 | 7879 |
var output = lib_call.use(output_raw, function (x) { return lib_path.filepointer_read(x); }); |
6819 | 7880 |
var dir = lib_call.use(dir_raw, function (x) { return ((x == null) ? null : lib_path.location_read(x)); }); |
6820 |
- _super.call(this, name, sub, active, includes.concat(lib_object.values(adhoc).reduce(function (x, y) { return x.concat(y); }, [])), [output], [ |
|
7881 |
+ _this = _super.call(this, name, sub, active, includes.concat(lib_object.values(adhoc).reduce(function (x, y) { return x.concat(y); }, [])), [output], [ |
|
6821 | 7882 |
new class_action_mkdir(output.location), |
6822 | 7883 |
new class_action_schwamm_create(includes, adhoc, output, dir), |
6823 |
- ]); |
|
7884 |
+ ]) || this; |
|
7885 |
+ return _this; |
|
6824 | 7886 |
} |
6825 | 7887 |
return class_task_schwamm_create; |
6826 | 7888 |
}(class_task)); |
... | ... |
@@ -6838,6 +7900,7 @@ var class_task_schwamm_apply = (function (_super) { |
6838 | 7900 |
*/ |
6839 | 7901 |
function class_task_schwamm_apply(_a) { |
6840 | 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; |
|
6841 | 7904 |
if (path_raw == undefined) { |
6842 | 7905 |
throw (new Error(class_task.errormessage_mandatoryparamater("schamm-apply", name, "path"))); |
6843 | 7906 |
} |
... | ... |
@@ -6846,11 +7909,12 @@ var class_task_schwamm_apply = (function (_super) { |
6846 | 7909 |
throw (new Error(class_task.errormessage_mandatoryparamater("schamm-apply", name, "outputs"))); |
6847 | 7910 |
} |
6848 | 7911 |
var outputs = lib_call.use(outputs_raw, function (x) { return lib_object.map(x, function (output) { return lib_path.filepointer_read(output); }); }); |
6849 |
- _super.call(this, name, sub, active, [path], lib_object.to_array(outputs).map(function (x) { return x.value; }), ([] |
|
6850 |
- .concat(lib_object.to_array(outputs).map(function (pair) { return new class_action_mkdir(pair.value.location); })) |
|
6851 |
- .concat([ |
|
6852 |
- new class_action_schwamm_apply(path, outputs), |
|
6853 |
- ]))); |
|
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; |
|
6854 | 7918 |
} |
6855 | 7919 |
return class_task_schwamm_apply; |
6856 | 7920 |
}(class_task)); |
... | ... |
@@ -6878,8 +7942,9 @@ var class_target_regular = (function (_super) { |
6878 | 7942 |
* @author fenris |
6879 | 7943 |
*/ |
6880 | 7944 |
function class_target_regular(identifier) { |
6881 |
- _super.call(this); |
|
6882 |
- this.identifier = identifier; |
|
7945 |
+ var _this = _super.call(this) || this; |
|
7946 |
+ _this.identifier = identifier; |
|
7947 |
+ return _this; |
|
6883 | 7948 |
} |
6884 | 7949 |
/** |
6885 | 7950 |
* @author fenris |
... | ... |
@@ -6904,15 +7969,19 @@ var class_target_ant = (function (_super) { |
6904 | 7969 |
* @author fenris |
6905 | 7970 |
*/ |
6906 | 7971 |
function class_target_ant() { |
6907 |
- _super.call(this, "ant"); |
|
7972 |
+ return _super.call(this, "ant") || this; |
|
6908 | 7973 |
} |
6909 | 7974 |
/** |
6910 | 7975 |
* @override |
6911 | 7976 |
* @author fenris |
6912 | 7977 |
*/ |
6913 | 7978 |
class_target_ant.prototype.tempfolder = function () { |
6914 |
- switch (configuration.system) { |
|
6915 |
- case "unix": { |
|
7979 |
+ switch (globalvars.configuration.system) { |
|
7980 |
+ case "linux": { |
|
7981 |
+ return "/tmp/"; |
|
7982 |
+ break; |
|
7983 |
+ } |
|
7984 |
+ case "bsd": { |
|
6916 | 7985 |
return "/tmp/"; |
6917 | 7986 |
break; |
6918 | 7987 |
} |
... | ... |
@@ -6921,7 +7990,7 @@ var class_target_ant = (function (_super) { |
6921 | 7990 |
break; |
6922 | 7991 |
} |
6923 | 7992 |
default: { |
6924 |
- throw (new Error("invalid system '" + configuration.system + "'")); |
|
7993 |
+ throw (new Error("invalid system '" + globalvars.configuration.system + "'")); |
|
6925 | 7994 |
break; |
6926 | 7995 |
} |
6927 | 7996 |
} |
... | ... |
@@ -6929,62 +7998,65 @@ var class_target_ant = (function (_super) { |
6929 | 7998 |
/** |
6930 | 7999 |
* @author fenris |
6931 | 8000 |
*/ |
6932 |
- class_target_ant.prototype.compile_task = function (task, path) { |
|
8001 |
+ class_target_ant.prototype.compile_task = function (_a) { |
|
6933 | 8002 |
var _this = this; |
6934 |
- if (path === void 0) { path = []; } |
|
6935 |
- var path_ = [task.name_get()]; |
|
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); |
|
6936 | 8006 |
var targets_core = [ |
6937 | 8007 |
new lib_ant.class_target({ |
6938 |
- "name": path_.join("-"), |
|
8008 |
+ "name": path_dump(path_), |
|
6939 | 8009 |
"dependencies": (task.sub_get() |
6940 | 8010 |
.filter(function (task_) { return task_.active_get(); }) |
6941 |
- .map(function (task_) { return [task_.name_get()] /*)*/.join("-"); })), |
|
8011 |
+ .map(function (task_) { return path_dump(path_augment(path_, task_.name_get(), aggregate)); })), |
|
6942 | 8012 |
"actions": ([] |
6943 |
- .concat([new class_action_echo(task.name_get())]) |
|
6944 |
- .concat(task.actions()) |
|
6945 |
- .map(function (action) { return _this.compile_action(action); })) |
|
8013 |
+ .concat((context == null) |
|
8014 |
+ ? ([] |
|
8015 |
+ .concat(task.actions() |
|
8016 |
+ .map(function (action) { return _this.compile_action(action); }))) |
|
8017 |
+ : [ |
|
8018 |
+ new lib_ant.class_action(new lib_xml.class_node_complex("ant", { |
|
8019 |
+ "antfile": "${ant.file}", |
|
8020 |
+ "dir": context.as_string("linux"), |
|
8021 |
+ "target": path_dump(path_augment(path_, name_mark("inner"))), |
|
8022 |
+ "inheritAll": String(true), |
|
8023 |
+ "inheritRefs": String(true), |
|
8024 |
+ })), |
|
8025 |
+ ])) |
|
6946 | 8026 |
}) |
6947 | 8027 |
]; |
6948 |
- var targets_sub = task.sub_get() |
|
6949 |
- .map(function (task_) { return _this.compile_task(task_, path_); }) |
|
6950 |
- .reduce(function (x, y) { return x.concat(y); }, []); |
|
8028 |
+ var targets_sub = [] |
|
8029 |
+ .concat((context == null) |
|
8030 |
+ ? [] |
|
8031 |
+ : [ |
|
8032 |
+ new lib_ant.class_target({ |
|
8033 |
+ "name": path_dump(path_augment(path_, name_mark("inner"))), |
|
8034 |
+ "dependencies": [], |
|
8035 |
+ "actions": (task.actions() |
|
8036 |
+ .map(function (action) { return _this.compile_action(action); })), |
|
8037 |
+ }) |
|
8038 |
+ ]) |
|
8039 |
+ .concat(task.sub_get() |
|
8040 |
+ .map(function (task_) { return _this.compile_task({ |
|
8041 |
+ "task": task_, |
|
8042 |
+ "path": path_, |
|
8043 |
+ "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); }, [])); |
|
6951 | 8046 |
return [].concat(targets_core).concat(targets_sub); |
6952 | 8047 |
}; |
6953 | 8048 |
/** |
6954 | 8049 |
* @author fenris |
6955 | 8050 |
*/ |
6956 |
- class_target_ant.prototype.compile_project = function (project, without_dependencies) { |
|
6957 |
- var _this = this; |
|
6958 |
- if (without_dependencies === void 0) { without_dependencies = false; } |
|
8051 |
+ class_target_ant.prototype.compile_project = function (project) { |
|
6959 | 8052 |
var comments = [ |
6960 |
- ("Project \"" + project.name_get() + "\""), |
|
6961 |
- ("This build script was generated by Koralle " + configuration.version), |
|
8053 |
+ "Project \"" + project.name_get() + "\"", |
|
8054 |
+ "This build script was generated by Koralle " + globalvars.configuration.version, |
|
6962 | 8055 |
].map(function (x) { return new lib_ant.class_comment(x); }); |
6963 |
- var dependencies = project.dependencytasks(this.identifier); |
|
6964 |
- var targets = [] |
|
6965 |
- .concat([ |
|
6966 |
- new lib_ant.class_target({ |
|
6967 |
- "name": "__root", |
|
6968 |
- "dependencies": ["__dependencies", "__core"], |
|
6969 |
- }) |
|
6970 |
- ]) |
|
6971 |
- .concat([ |
|
6972 |
- new lib_ant.class_target({ |
|
6973 |
- "name": "__dependencies", |
|
6974 |
- "dependencies": without_dependencies ? [] : dependencies.map(function (dependency) { return dependency.name_get(); }), |
|
6975 |
- }) |
|
6976 |
- ]) |
|
6977 |
- .concat(dependencies.map(function (dependency) { return _this.compile_task(dependency); }).reduce(function (x, y) { return x.concat(y); }, [])) |
|
6978 |
- .concat([ |
|
6979 |
- new lib_ant.class_target({ |
|
6980 |
- "name": "__core", |
|
6981 |
- "dependencies": [project.roottask_get().name_get()], |
|
6982 |
- }) |
|
6983 |
- ]) |
|
6984 |
- .concat(this.compile_task(project.roottask_get())); |
|
8056 |
+ var targets = this.compile_task({ "task": project.roottask_get() }); |
|
6985 | 8057 |
return (new lib_ant.class_project({ |
6986 | 8058 |
"name": project.name_get(), |
6987 |
- "default": "__root", |
|
8059 |
+ "default": name_mark("root"), |
|
6988 | 8060 |
"comments": comments, |
6989 | 8061 |
"targets": targets, |
6990 | 8062 |
})); |
... | ... |
@@ -7003,16 +8075,19 @@ var class_target_ant = (function (_super) { |
7003 | 8075 |
class_target_ant.prototype.execute = function (filepointer, workdir) { |
7004 | 8076 |
if (workdir === void 0) { workdir = "."; } |
7005 | 8077 |
return (function (resolve, reject) { |
7006 |
- var command = [ |
|
7007 |
- "ant", |
|
7008 |
- "-file " + filepointer.toString(), |
|
7009 |
- ].join(" "); |
|
7010 |
- _child_process.exec(command, {}, function (stdout, stderr, error) { |
|
7011 |
- if (error == null) { |
|
8078 |
+ var cp = nm_child_process.spawn("ant", [ |
|
8079 |
+ "-f", |
|
8080 |
+ "" + filepointer.as_string(globalvars.configuration.system), |
|
8081 |
+ ], {}); |
|
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) { |
|
8086 |
+ if (code == 0) { |
|
7012 | 8087 |
resolve(undefined); |
7013 | 8088 |
} |
7014 | 8089 |
else { |
7015 |
- reject(error); |
|
8090 |
+ reject(new Error("unknown error while subprocess execution")); |
|
7016 | 8091 |
} |
7017 | 8092 |
}); |
7018 | 8093 |
}); |
... | ... |
@@ -7028,15 +8103,19 @@ var class_target_gnumake = (function (_super) { |
7028 | 8103 |
* @author fenris |
7029 | 8104 |
*/ |
7030 | 8105 |
function class_target_gnumake() { |
7031 |
- _super.call(this, "gnumake"); |
|
8106 |
+ return _super.call(this, "gnumake") || this; |
|
7032 | 8107 |
} |
7033 | 8108 |
/** |
7034 | 8109 |
* @override |
7035 | 8110 |
* @author fenris |
7036 | 8111 |
*/ |
7037 | 8112 |
class_target_gnumake.prototype.tempfolder = function () { |
7038 |
- switch (configuration.system) { |
|
7039 |
- case "unix": { |
|
8113 |
+ switch (globalvars.configuration.system) { |
|
8114 |
+ case "linux": { |
|
8115 |
+ return "/tmp/"; |
|
8116 |
+ break; |
|
8117 |
+ } |
|
8118 |
+ case "bsd": { |
|
7040 | 8119 |
return "/tmp/"; |
7041 | 8120 |
break; |
7042 | 8121 |
} |
... | ... |
@@ -7045,7 +8124,7 @@ var class_target_gnumake = (function (_super) { |
7045 | 8124 |
break; |
7046 | 8125 |
} |
7047 | 8126 |
default: { |
7048 |
- throw (new Error("invalid system '" + configuration.system + "'")); |
|
8127 |
+ throw (new Error("invalid system '" + globalvars.configuration.system + "'")); |
|
7049 | 8128 |
break; |
7050 | 8129 |
} |
7051 | 8130 |
} |
... | ... |
@@ -7053,42 +8132,52 @@ var class_target_gnumake = (function (_super) { |
7053 | 8132 |
/** |
7054 | 8133 |
* @author fenris |
7055 | 8134 |
*/ |
7056 |
- class_target_gnumake.prototype.compile_task = function (task, branch, depth, prefix) { |
|
8135 |
+ class_target_gnumake.prototype.compile_task = function (_a) { |
|
7057 | 8136 |
var _this = this; |
7058 |
- if (branch === void 0) { branch = []; } |
|
7059 |
- if (depth === void 0) { depth = 0; } |
|
7060 |
- if (prefix === void 0) { prefix = null; } |
|
7061 |
- var branch_ = [task.name_get()]; |
|
7062 |
- var logging_begin = new class_action_echo((new class_message("processing '" + branch_.join("-") + "' ...", { "type": "log", "depth": depth, "prefix": prefix })).generate()); |
|
7063 |
- var logging_end = new class_action_echo((new class_message("... finished '" + branch_.join("-") + "'", { "type": "log", "depth": depth, "prefix": prefix })).generate()); |
|
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()); |
|
7064 | 8144 |
var rules_core = []; |
7065 | 8145 |
{ |
7066 | 8146 |
// meta rule |
7067 | 8147 |
rules_core.push(new lib_gnumake.class_rule({ |
7068 |
- "name": branch_.join("-"), |
|
8148 |
+ "name": path_dump(branch_), |
|
7069 | 8149 |
"dependencies": ([] |
7070 |
- .concat(["__logging_" + branch_.join("-")]) |
|
8150 |
+ .concat(log_begin |
|
8151 |
+ ? [path_dump(path_augment(branch_, name_mark("logging"), true))] |
|
8152 |
+ : []) |
|
7071 | 8153 |
.concat(task.sub_get() |
7072 | 8154 |
.filter(function (task_) { return task_.active_get(); }) |
7073 |
- .map(function (task_) { return [task_.name_get()] /*)*/.join("-"); })) |
|
7074 |
- .concat(task.outputs().map(function (filepointer) { return filepointer.as_string(configuration.system); }))), |
|
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); }))), |
|
7075 | 8157 |
"actions": ([] |
7076 |
- .concat((task.outputs().length == 0) ? task.actions() : []) |
|
7077 |
- .map(function (action) { return _this.compile_action(action); })), |
|
8158 |
+ .concat((task.outputs().length == 0) |
|
8159 |
+ ? task.actions().map(function (action) { return dirwrap(context, _this.compile_action(action)); }) |
|
8160 |
+ : []) |
|
8161 |
+ .concat((log_end |
|
8162 |
+ ? [logging_end] |
|
8163 |
+ : []) |
|
8164 |
+ .map(function (action) { return _this.compile_action(action); }))), |
|
7078 | 8165 |
"phony": true, |
7079 | 8166 |
})); |
7080 | 8167 |
// logging |
8168 |
+ if (log_begin) { |
|
7081 | 8169 |
rules_core.push(new lib_gnumake.class_rule({ |
7082 |
- "name": ("__logging_" + branch_.join("-")), |
|
8170 |
+ "name": path_dump(path_augment(branch_, name_mark("logging"), true)), |
|
7083 | 8171 |
"actions": [logging_begin].map(function (action) { return _this.compile_action(action); }), |
7084 | 8172 |
"phony": true, |
7085 | 8173 |
})); |
8174 |
+ } |
|
7086 | 8175 |
// actual rule |
7087 | 8176 |
if (task.outputs().length > 0) { |
7088 | 8177 |
rules_core.push(new lib_gnumake.class_rule({ |
7089 |
- "name": task.outputs().map(function (filepointer) { return filepointer.as_string(configuration.system); }).join(" "), |
|
7090 |
- "dependencies": task.inputs().map(function (filepointer) { return filepointer.as_string(configuration.system); }), |
|
7091 |
- "actions": task.actions().map(function (action) { return _this.compile_action(action); }), |
|
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); }), |
|
7092 | 8181 |
"phony": false, |
7093 | 8182 |
})); |
7094 | 8183 |
} |
... | ... |
@@ -7096,7 +8185,13 @@ var class_target_gnumake = (function (_super) { |
7096 | 8185 |
var rules_sub = []; |
7097 | 8186 |
{ |
7098 | 8187 |
rules_sub = task.sub_get() |
7099 |
- .map(function (task_) { return _this.compile_task(task_, branch_, depth + 1, prefix); }) |
|
8188 |
+ .map(function (task_) { return _this.compile_task({ |
|
8189 |
+ "task": task_, |
|
8190 |
+ "branch": branch_, |
|
8191 |
+ "depth": depth + 1, |
|
8192 |
+ "context": ((context == null) ? task_.context_get() : ((task_.context_get() == null) ? context : context.relocate(task_.context_get()))), |
|
8193 |
+ "prefix": prefix, |
|
8194 |
+ }); }) |
|
7100 | 8195 |
.reduce(function (x, y) { return x.concat(y); }, []); |
7101 | 8196 |
} |
7102 | 8197 |
return [].concat(rules_core).concat(rules_sub); |
... | ... |
@@ -7104,55 +8199,23 @@ var class_target_gnumake = (function (_super) { |
7104 | 8199 |
/** |
7105 | 8200 |
* @author fenris |
7106 | 8201 |
*/ |
7107 |
- class_target_gnumake.prototype.compile_project = function (project, without_dependencies) { |
|
7108 |
- var _this = this; |
|
7109 |
- if (without_dependencies === void 0) { without_dependencies = false; } |
|
8202 |
+ class_target_gnumake.prototype.compile_project = function (project) { |
|
7110 | 8203 |
var comments = [ |
7111 |
- ("Project \"" + project.name_get() + "\""), |
|
7112 |
- ("This makefile was generated by Koralle " + configuration.version), |
|
8204 |
+ "Project \"" + project.name_get() + "\"", |
|
8205 |
+ "This makefile was generated by Koralle " + globalvars.configuration.version, |
|
7113 | 8206 |
].map(function (x) { return x; }); |
7114 |
- var dependencies = project.dependencytasks(this.identifier); |
|
7115 |
- var rules = [] |
|
7116 |
- .concat([ |
|
7117 |
- new lib_gnumake.class_rule({ |
|
7118 |
- "name": "__default", |
|
7119 |
- "dependencies": ["__root"], |
|
7120 |
- "actions": [], |
|
7121 |
- "phony": true, |
|
7122 |
- }) |
|
7123 |
- ]) |
|
7124 |
- .concat([ |
|
7125 |
- new lib_gnumake.class_rule({ |
|
7126 |
- "name": "__root", |
|
7127 |
- "dependencies": ["__dependencies", "__core"], |
|
7128 |
- "phony": true, |
|
7129 |
- }) |
|
7130 |
- ]) |
|
7131 |
- .concat([ |
|
7132 |
- new lib_gnumake.class_rule({ |
|
7133 |
- "name": "__dependencies", |
|
7134 |
- "dependencies": without_dependencies ? [] : dependencies.map(function (dependency) { return dependency.name_get(); }), |
|
7135 |
- "phony": true, |
|
7136 |
- }) |
|
7137 |
- ]) |
|
7138 |
- .concat(dependencies.map(function (dependency) { return _this.compile_task(dependency); }).reduce(function (x, y) { return x.concat(y); }, [])) |
|
7139 |
- .concat([ |
|
7140 |
- new lib_gnumake.class_rule({ |
|
7141 |
- "name": "__core", |
|
7142 |
- "dependencies": [project.roottask_get().name_get()], |
|
7143 |
- "phony": true, |
|
7144 |
- }) |
|
7145 |
- ]) |
|
7146 |
- .concat(this.compile_task(project.roottask_get(), undefined, undefined, project.name_get())); |
|
8207 |
+ var rules = this.compile_task({ |
|
8208 |
+ "task": project.roottask_get(), |
|
8209 |
+ "prefix": project.name_get(), |
|
8210 |
+ }); |
|
7147 | 8211 |
return (new lib_gnumake.class_sheet(rules, comments)); |
7148 | 8212 |
}; |
7149 | 8213 |
/** |
7150 | 8214 |
* @override |
7151 | 8215 |
* @author fenris |
7152 | 8216 |
*/ |
7153 |
- class_target_gnumake.prototype.compile_project_string = function (project, without_dependencies) { |
|
7154 |
- if (without_dependencies === void 0) { without_dependencies = false; } |
|
7155 |
- return (this.compile_project(project, without_dependencies).compile(true)); |
|
8217 |
+ class_target_gnumake.prototype.compile_project_string = function (project) { |
|
8218 |
+ return (this.compile_project(project).compile(true)); |
|
7156 | 8219 |
}; |
7157 | 8220 |
/** |
7158 | 8221 |
* @override |
... | ... |
@@ -7161,9 +8224,11 @@ var class_target_gnumake = (function (_super) { |
7161 | 8224 |
class_target_gnumake.prototype.execute = function (filepointer, workdir) { |
7162 | 8225 |
if (workdir === void 0) { workdir = process.cwd(); } |
7163 | 8226 |
return (function (resolve, reject) { |
7164 |
- var cp = _child_process.spawn("make", [ |
|
8227 |
+ var cp = nm_child_process.spawn("make", [ |
|
7165 | 8228 |
// `--directory=${workdir}`, |
7166 |
- ("--file=" + filepointer.as_string(configuration.system)), |
|
8229 |
+ // `--file=${filepointer.as_string(globalvars.configuration.system)}`, |
|
8230 |
+ "-f", |
|
8231 |
+ "" + filepointer.as_string(globalvars.configuration.system), |
|
7167 | 8232 |
], {}); |
7168 | 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)); |
7169 | 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)); |
... | ... |
@@ -7180,6 +8245,51 @@ var class_target_gnumake = (function (_super) { |
7180 | 8245 |
}; |
7181 | 8246 |
return class_target_gnumake; |
7182 | 8247 |
}(class_target_regular)); |
8248 |
+/** |
|
8249 |
+ * 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 |
|
8251 |
+ * @author fenris |
|
8252 |
+ */ |
|
8253 |
+function scan(node, graph, depth) { |
|
8254 |
+ if (graph === void 0) { graph = null; } |
|
8255 |
+ if (depth === void 0) { depth = 0; } |
|
8256 |
+ 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 }; |
|
8260 |
+ return node; |
|
8261 |
+ }; |
|
8262 |
+ if (graph == null) { |
|
8263 |
+ 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); |
|
8266 |
+ } |
|
8267 |
+ return (function (resolve, reject) { |
|
8268 |
+ log("reading description file", 4); |
|
8269 |
+ lib_file.read_json(node.filepointer.toString())(function (data) { |
|
8270 |
+ log("got data", 4); |
|
8271 |
+ 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_) { |
|
8273 |
+ 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); |
|
8277 |
+ if (graph.has(node_)) { |
|
8278 |
+ // return lib_call.executor_resolve<class_graph<type_depgraphnode>, Error>(graph); |
|
8279 |
+ resolve_(graph_); |
|
8280 |
+ } |
|
8281 |
+ else { |
|
8282 |
+ graph.nodes.push(node_); |
|
8283 |
+ scan(node_, graph_, depth + 1)(function (graph_) { |
|
8284 |
+ resolve_(graph_ /*.hasse()*/); |
|
8285 |
+ }, reject_); |
|
8286 |
+ } |
|
8287 |
+ }; }; }))(resolve, reject); |
|
8288 |
+ }, function (reason) { |
|
8289 |
+ reject(reason); |
|
8290 |
+ }); |
|
8291 |
+ }); |
|
8292 |
+} |
|
7183 | 8293 |
/** |
7184 | 8294 |
* @author fenris |
7185 | 8295 |
*/ |
... | ... |
@@ -7187,12 +8297,11 @@ var class_project = (function () { |
7187 | 8297 |
/** |
7188 | 8298 |
* @author fenris |
7189 | 8299 |
*/ |
7190 |
- function class_project(name, version, dependencies_listed, roottask) { |
|
8300 |
+ function class_project(name, version, task) { |
|
7191 | 8301 |
this.name = name; |
7192 | 8302 |
this.version = version; |
7193 |
- this.dependencies_listed = dependencies_listed; |
|
7194 |
- this.dependencies_all = null; |
|
7195 |
- this.roottask = roottask; |
|
8303 |
+ this.task = task; |
|
8304 |
+ this.graph = null; |
|
7196 | 8305 |
} |
7197 | 8306 |
/** |
7198 | 8307 |
* @author fenris |
... | ... |
@@ -7203,92 +8312,139 @@ var class_project = (function () { |
7203 | 8312 |
/** |
7204 | 8313 |
* @author fenris |
7205 | 8314 |
*/ |
7206 |
- class_project.prototype.dependencies_set = function (dependencies_all) { |
|
7207 |
- this.dependencies_all = dependencies_all; |
|
7208 |
- }; |
|
7209 |
- /** |
|
7210 |
- * @author fenris |
|
7211 |
- */ |
|
7212 |
- class_project.prototype.dependencies_get = function () { |
|
7213 |
- return this.dependencies_all; |
|
8315 |
+ class_project.prototype.roottask_get = function () { |
|
8316 |
+ return this.task; |
|
7214 | 8317 |
}; |
7215 | 8318 |
/** |
8319 |
+ * @desc [mutator] [setter] |
|
7216 | 8320 |
* @author fenris |
7217 | 8321 |
*/ |
7218 |
- class_project.prototype.roottask_get = function () { |
|
7219 |
- return this.roottask; |
|
8322 |
+ class_project.prototype.graph_set = function (graph) { |
|
8323 |
+ this.graph = graph; |
|
7220 | 8324 |
}; |
7221 | 8325 |
/** |
8326 |
+ * @desc [accessor] [getter] |
|
7222 | 8327 |
* @author fenris |
7223 | 8328 |
*/ |
7224 |
- class_project.create_task = function (raw) { |
|
7225 |
- var type = object_fetch(raw, "type", null, 2); |
|
7226 |
- return (class_task.get(type)(object_fetch(raw, "name", null, 1), object_fetch(raw, "sub", [], 0).map(function (raw) { return class_project.create_task(raw); }), object_fetch(raw, "active", true, 0), object_fetch(raw, "parameters", {}, 0))); |
|
8329 |
+ class_project.prototype.graph_get = function () { |
|
8330 |
+ return this.graph; |
|
7227 | 8331 |
}; |
7228 | 8332 |
/** |
7229 | 8333 |
* @author fenris |
7230 | 8334 |
*/ |
7231 |
- class_project.prototype.dependencytasks = function (output) { |
|
7232 |
- return (this.dependencies_all.map(function (path, index) { |
|
7233 |
- return (new class_task_dependency({ |
|
7234 |
- "name": "__dependency_" + index.toString(), |
|
8335 |
+ /* |
|
8336 |
+ public dependencytasks(output : string) : Array<class_task> { |
|
8337 |
+ return ( |
|
8338 |
+ this.dependencies_all.map( |
|
8339 |
+ function (path : string, index : int) : class_task_dependency { |
|
8340 |
+ return ( |
|
8341 |
+ new class_task_dependency( |
|
8342 |
+ { |
|
8343 |
+ "name": `__dependency_${index.toString()}`, |
|
7235 | 8344 |
"parameters": { |
7236 | 8345 |
"path": path, |
7237 | 8346 |
"output": output, |
7238 | 8347 |
"raw": true, |
7239 | 8348 |
}, |
7240 |
- })); |
|
7241 |
- })); |
|
7242 |
- }; |
|
8349 |
+ } |
|
8350 |
+ ) |
|
8351 |
+ ); |
|
8352 |
+ } |
|
8353 |
+ ) |
|
8354 |
+ ); |
|
8355 |
+ } |
|
8356 |
+ */ |
|
7243 | 8357 |
/** |
7244 | 8358 |
* @author fenris |
7245 | 8359 |
*/ |
7246 |
- class_project.create = function (project_raw) { |
|
7247 |
- var name = object_fetch(project_raw, "name", "(nameless project)", 1); |
|
7248 |
- var version = object_fetch(project_raw, "version", "0.0.0", 1); |
|
7249 |
- var dependencies = object_fetch(project_raw, "dependencies", [], 0); |
|
7250 |
- var roottask = class_project.create_task(object_fetch(project_raw, "roottask", null, 2)); |
|
7251 |
- // roottask.clean(); |
|
7252 |
- return (new class_project(name, version, dependencies, roottask)); |
|
7253 |
- }; |
|
7254 |
- return class_project; |
|
7255 |
-}()); |
|
7256 |
-function scan(filepointer, data, graph, depth) { |
|
7257 |
- if (graph === void 0) { graph = null; } |
|
7258 |
- if (depth === void 0) { depth = 0; } |
|
7259 |
- if (graph == null) { |
|
7260 |
- graph = new class_graph(function (x, y) { return (x.filepointer.toString() == y.filepointer.toString()); }); |
|
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 }; |
|
8364 |
+ log("scanning dependencies", 3); |
|
8365 |
+ scan(node)(function (graph) { |
|
8366 |
+ log("got dependency graph", 3); |
|
8367 |
+ var dependencynodes = null; |
|
8368 |
+ var error = null; |
|
8369 |
+ try { |
|
8370 |
+ log("applying topsort", 3); |
|
8371 |
+ dependencynodes = graph |
|
8372 |
+ .topsort() |
|
8373 |
+ .filter(function (node) { return (node.filepointer.toString() != filepointer.toString()); }); |
|
8374 |
+ error = null; |
|
7261 | 8375 |
} |
7262 |
- function make_node(filepointer, data) { |
|
7263 |
- var name = lib_object.fetch(data, "name", filepointer.toString(), 1); |
|
7264 |
- var node = { "filepointer": filepointer, "label": name }; |
|
7265 |
- return node; |
|
8376 |
+ catch (exception) { |
|
8377 |
+ error = new class_error("could not sort dependencies; probably circular structure", [exception]); |
|
7266 | 8378 |
} |
7267 |
- var node = make_node(filepointer, data); |
|
7268 |
- if (graph.has(node)) { |
|
7269 |
- return lib_call.executor_resolve(graph); |
|
8379 |
+ if (error == null) { |
|
8380 |
+ log("creating core task", 3); |
|
8381 |
+ var core = class_task.create(node.rawproject.roottask); |
|
8382 |
+ 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()))); |
|
8385 |
+ task.context_set(node.filepointer.location); |
|
8386 |
+ return task; |
|
8387 |
+ }); |
|
8388 |
+ log("creating root task", 3); |
|
8389 |
+ var task = new class_task_group({ |
|
8390 |
+ "name": name_mark("root"), |
|
8391 |
+ "sub": [ |
|
8392 |
+ new class_task_group({ |
|
8393 |
+ "name": name_mark("dependencies"), |
|
8394 |
+ "sub": dependencies, |
|
8395 |
+ }), |
|
8396 |
+ new class_task_group({ |
|
8397 |
+ "name": name_mark("core"), |
|
8398 |
+ "sub": [core], |
|
8399 |
+ }), |
|
8400 |
+ ] |
|
8401 |
+ }); |
|
8402 |
+ log("creating project", 3); |
|
8403 |
+ var project = new class_project(node.rawproject.name || "(nameless project)", node.rawproject.version || "0.0.0", task); |
|
8404 |
+ project.graph = graph; |
|
8405 |
+ resolve(project); |
|
7270 | 8406 |
} |
7271 | 8407 |
else { |
7272 |
- graph.nodes.push(node); |
|
7273 |
- return (lib_call.executor_chain(graph, lib_object.fetch(data, "dependencies", [], 0).map(function (path) { return function (graph_) { return function (resolve__, reject__) { |
|
7274 |
- var filepointer_ = filepointer.foo(lib_path.filepointer_read(path)); |
|
7275 |
- lib_file.read_json(filepointer_.toString())(function (data_) { |
|
7276 |
- scan(filepointer_, data_, graph_, depth + 1)(function (graph_) { |
|
7277 |
- var node_ = make_node(filepointer_, data_); |
|
7278 |
- var edge = { "from": node_, "to": node }; |
|
7279 |
- graph_.edges.push(edge); |
|
7280 |
- resolve__(graph_ /*.hasse()*/); |
|
7281 |
- }, reject__); |
|
7282 |
- }, function (reason) { |
|
7283 |
- reject__(reason); |
|
8408 |
+ reject(error); |
|
8409 |
+ } |
|
8410 |
+ }, function (reason) { return reject(new class_error("scanning dependencies failed", [reason])); }); |
|
7284 | 8411 |
}); |
7285 |
- }; }; }))); |
|
8412 |
+ }; |
|
8413 |
+ return class_project; |
|
8414 |
+}()); |
|
8415 |
+globalvars.invocation = { |
|
8416 |
+ "interpreter": null, |
|
8417 |
+ "path": "koralle", |
|
8418 |
+}; |
|
8419 |
+globalvars.configuration = { |
|
8420 |
+ "version": "0.1.1", |
|
8421 |
+ "tempfolder": null, |
|
8422 |
+ "path_source": "source", |
|
8423 |
+ "path_build": "build", |
|
8424 |
+ "system": "linux", |
|
8425 |
+ "execute": false, |
|
8426 |
+ "output": "gnumake", |
|
8427 |
+ "file": null, |
|
8428 |
+ "path": "project.json", |
|
8429 |
+ "showgraph": false, |
|
8430 |
+ "verbosity": 0, |
|
8431 |
+ "name_splitter": "_", |
|
8432 |
+ "name_prefix": "~", |
|
8433 |
+}; |
|
8434 |
+/** |
|
8435 |
+ * @author fenris |
|
8436 |
+ */ |
|
8437 |
+function log(message, level) { |
|
8438 |
+ if (level === void 0) { level = 0; } |
|
8439 |
+ if (level <= globalvars.configuration.verbosity) { |
|
8440 |
+ (new class_message(message, { "type": "log", "prefix": "koralle" })).stderr(); |
|
7286 | 8441 |
} |
7287 | 8442 |
} |
7288 | 8443 |
/** |
7289 | 8444 |
* @author fenris |
7290 | 8445 |
*/ |
7291 | 8446 |
function main(args) { |
8447 |
+ log("starting", 2); |
|
7292 | 8448 |
var arghandler = new lib_args.class_handler([ |
7293 | 8449 |
new lib_args.class_argument({ |
7294 | 8450 |
"name": "path", |
... | ... |
@@ -7298,6 +8454,16 @@ function main(args) { |
7298 | 8454 |
"kind": "positional", |
7299 | 8455 |
"parameters": {}, |
7300 | 8456 |
}), |
8457 |
+ new lib_args.class_argument({ |
|
8458 |
+ "name": "verbosity", |
|
8459 |
+ "type": "int", |
|
8460 |
+ "info": "how much informational output shall be given", |
|
8461 |
+ "kind": "volatile", |
|
8462 |
+ "parameters": { |
|
8463 |
+ "indicators_long": ["verbosity"], |
|
8464 |
+ "indicators_short": ["b"], |
|
8465 |
+ }, |
|
8466 |
+ }), |
|
7301 | 8467 |
new lib_args.class_argument({ |
7302 | 8468 |
"name": "help", |
7303 | 8469 |
"type": "boolean", |
... | ... |
@@ -7342,8 +8508,8 @@ function main(args) { |
7342 | 8508 |
new lib_args.class_argument({ |
7343 | 8509 |
"name": "system", |
7344 | 8510 |
"type": "string", |
7345 |
- "default": "unix", |
|
7346 |
- "info": "the target platform; valid values are 'unix', 'win'; default is 'unix'", |
|
8511 |
+ "default": "linux", |
|
8512 |
+ "info": "the target platform; valid values are 'linux', 'bsd', 'win'", |
|
7347 | 8513 |
"kind": "volatile", |
7348 | 8514 |
"parameters": { |
7349 | 8515 |
"indicators_long": ["system"], |
... | ... |
@@ -7361,16 +8527,6 @@ function main(args) { |
7361 | 8527 |
"indicators_short": ["f"], |
7362 | 8528 |
}, |
7363 | 8529 |
}), |
7364 |
- new lib_args.class_argument({ |
|
7365 |
- "name": "raw", |
|
7366 |
- "type": "boolean", |
|
7367 |
- "info": "if set, depedencies are ignored/excluded from the output", |
|
7368 |
- "kind": "volatile", |
|
7369 |
- "parameters": { |
|
7370 |
- "indicators_long": ["raw"], |
|
7371 |
- "indicators_short": ["r"], |
|
7372 |
- }, |
|
7373 |
- }), |
|
7374 | 8530 |
new lib_args.class_argument({ |
7375 | 8531 |
"name": "execute", |
7376 | 8532 |
"type": "boolean", |
... | ... |
@@ -7393,6 +8549,7 @@ function main(args) { |
7393 | 8549 |
}), |
7394 | 8550 |
]); |
7395 | 8551 |
// lib_args.verbosity = 5; |
8552 |
+ log("reading command line arguments", 2); |
|
7396 | 8553 |
var argdata = arghandler.read("cli", args.join(" ")); |
7397 | 8554 |
var procede = true; |
7398 | 8555 |
if (argdata["help"]) { |
... | ... |
@@ -7405,42 +8562,44 @@ function main(args) { |
7405 | 8562 |
procede = false; |
7406 | 8563 |
} |
7407 | 8564 |
else if (argdata["version"]) { |
7408 |
- (new class_message(configuration.version.toString())).stdout(); |
|
8565 |
+ (new class_message(globalvars.configuration.version.toString())).stdout(); |
|
7409 | 8566 |
procede = false; |
7410 | 8567 |
} |
7411 | 8568 |
else if (argdata["tasklist"]) { |
7412 |
- new class_message(class_task.list().map(function (entry) { return ("\t" + entry + "\n"); }).join("")).stdout(); |
|
8569 |
+ new class_message(class_task.list().map(function (entry) { return "\t" + entry + "\n"; }).join("")).stdout(); |
|
7413 | 8570 |
procede = false; |
7414 | 8571 |
} |
7415 | 8572 |
else { |
7416 |
- configuration.path = argdata["path"]; |
|
7417 |
- configuration.system = argdata["system"]; |
|
7418 |
- configuration.output = argdata["output"]; |
|
7419 |
- configuration.raw = argdata["raw"]; |
|
7420 |
- configuration.execute = argdata["execute"]; |
|
7421 |
- configuration.showgraph = argdata["showgraph"]; |
|
7422 |
- configuration.file = argdata["file"]; |
|
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"]; |
|
7423 | 8580 |
procede = true; |
7424 | 8581 |
} |
7425 | 8582 |
if (procede) { |
7426 | 8583 |
lib_call.executor_chain({}, [ |
7427 | 8584 |
// environment |
7428 | 8585 |
function (state) { return function (resolve, reject) { |
7429 |
- var filepointer = lib_path.filepointer_read(configuration.path); |
|
8586 |
+ log("setting up environment", 2); |
|
8587 |
+ var filepointer = lib_path.filepointer_read(globalvars.configuration.path); |
|
7430 | 8588 |
filepointer.location.go_thither(); |
7431 | 8589 |
state.filepointer = filepointer; |
7432 | 8590 |
resolve(state); |
7433 | 8591 |
}; }, |
7434 | 8592 |
// setup output |
7435 | 8593 |
function (state) { return function (resolve, reject) { |
8594 |
+ log("setting up output", 2); |
|
7436 | 8595 |
var mapping = { |
7437 | 8596 |
"ant": new class_target_ant(), |
7438 | 8597 |
"gnumake": new class_target_gnumake(), |
7439 | 8598 |
"make": new class_target_gnumake(), |
7440 | 8599 |
}; |
7441 |
- var output = lib_object.fetch(mapping, configuration.output, null, 0); |
|
8600 |
+ var output = lib_object.fetch(mapping, globalvars.configuration.output, null, 0); |
|
7442 | 8601 |
if (output == null) { |
7443 |
- reject(new class_error("no implementation found for output '" + configuration.output + "'")); |
|
8602 |
+ reject(new class_error("no implementation found for output '" + globalvars.configuration.output + "'")); |
|
7444 | 8603 |
} |
7445 | 8604 |
else { |
7446 | 8605 |
state.output = output; |
... | ... |
@@ -7449,56 +8608,39 @@ function main(args) { |
7449 | 8608 |
}; }, |
7450 | 8609 |
// setup temp-folder |
7451 | 8610 |
function (state) { return function (resolve, reject) { |
8611 |
+ log("setting up temp-folder", 2); |
|
7452 | 8612 |
try { |
7453 |
- configuration.tempfolder = state.output.tempfolder(); |
|
8613 |
+ globalvars.configuration.tempfolder = state.output.tempfolder(); |
|
7454 | 8614 |
resolve(state); |
7455 | 8615 |
} |
7456 | 8616 |
catch (exception) { |
7457 | 8617 |
reject(new class_error("couldn't setup temp folder", [exception])); |
7458 | 8618 |
} |
7459 | 8619 |
}; }, |
7460 |
- // get jsondata |
|
8620 |
+ // setup project |
|
7461 | 8621 |
function (state) { return function (resolve, reject) { |
7462 |
- lib_file.read_json(state.filepointer.filename)(function (data) { state.project_raw = data; resolve(state); }, function (reason) { return reject(new class_error("project description file '" + state.filepointer.toString() + "' couldn't be read", [reason])); }); |
|
8622 |
+ log("setting up project", 2); |
|
8623 |
+ class_project.create(state.filepointer)(function (project) { |
|
8624 |
+ state.project = project; |
|
8625 |
+ resolve(state); |
|
8626 |
+ }, reject); |
|
7463 | 8627 |
}; }, |
7464 |
- // scan dependencies |
|
8628 |
+ // show graph |
|
7465 | 8629 |
function (state) { return function (resolve, reject) { |
7466 |
- if (configuration.raw) { |
|
7467 |
- state.order = []; |
|
7468 |
- resolve(state); |
|
7469 |
- } |
|
7470 |
- else { |
|
7471 |
- scan(state.filepointer, state.project_raw)(function (graph) { |
|
7472 |
- if (configuration.showgraph) { |
|
7473 |
- var output = graph |
|
8630 |
+ log("showing graph?", 2); |
|
8631 |
+ if (globalvars.configuration.showgraph) { |
|
8632 |
+ var output = state.project.graph_get() |
|
7474 | 8633 |
.hasse() |
7475 |
- .output_graphviz(function (node) { return node.label; }); |
|
8634 |
+ .output_graphviz(function (node) { return node.rawproject.name || node.filepointer.toString(); }); |
|
7476 | 8635 |
(new class_message(output)).stderr(); |
7477 | 8636 |
} |
7478 |
- try { |
|
7479 |
- var order = graph |
|
7480 |
- .topsort() |
|
7481 |
- .map(function (x) { return x.filepointer.toString(); }) |
|
7482 |
- .filter(function (path) { return (path != state.filepointer.toString()); }); |
|
7483 |
- state.order = order; |
|
7484 |
- resolve(state); |
|
7485 |
- } |
|
7486 |
- catch (exception) { |
|
7487 |
- reject((exception)); |
|
7488 |
- } |
|
7489 |
- }, function (reason) { return reject(new class_error("scanning dependencies failed", [reason])); }); |
|
7490 |
- } |
|
7491 |
- }; }, |
|
7492 |
- // setup project |
|
7493 |
- function (state) { return function (resolve, reject) { |
|
7494 |
- state.project = class_project.create(state.project_raw); |
|
7495 | 8637 |
resolve(state); |
7496 | 8638 |
}; }, |
7497 | 8639 |
// generate |
7498 | 8640 |
function (state) { return function (resolve, reject) { |
7499 |
- state.project.dependencies_set(state.order); |
|
8641 |
+ log("generating output", 2); |
|
7500 | 8642 |
try { |
7501 |
- var script = state.output.compile_project_string(state.project, configuration.raw); |
|
8643 |
+ var script = state.output.compile_project_string(state.project); |
|
7502 | 8644 |
state.script = script; |
7503 | 8645 |
resolve(state); |
7504 | 8646 |
} |
... | ... |
@@ -7508,19 +8650,22 @@ function main(args) { |
7508 | 8650 |
}; }, |
7509 | 8651 |
// write |
7510 | 8652 |
function (state) { return function (resolve, reject) { |
8653 |
+ log("writing to file", 2); |
|
7511 | 8654 |
var filepointer; |
7512 |
- if (configuration.file == null) { |
|
7513 |
- if (!configuration.execute) { |
|
8655 |
+ if (globalvars.configuration.file == null) { |
|
8656 |
+ if (!globalvars.configuration.execute) { |
|
7514 | 8657 |
filepointer = null; |
7515 | 8658 |
} |
7516 | 8659 |
else { |
7517 | 8660 |
filepointer = new lib_path.class_filepointer( |
7518 | 8661 |
// new lib_path.class_location(null, new lib_path.class_path(["."])), |
7519 |
- lib_path.location_read(configuration.tempfolder, configuration.system), "_koralle_"); |
|
8662 |
+ lib_path.location_read(globalvars.configuration.tempfolder, globalvars.configuration.system), |
|
8663 |
+ // lib_path.class_location.tempfolder(globalvars.configuration.system), |
|
8664 |
+ "__koralle"); |
|
7520 | 8665 |
} |
7521 | 8666 |
} |
7522 | 8667 |
else { |
7523 |
- filepointer = lib_path.filepointer_read(configuration.file); |
|
8668 |
+ filepointer = lib_path.filepointer_read(globalvars.configuration.file); |
|
7524 | 8669 |
} |
7525 | 8670 |
state.file = filepointer; |
7526 | 8671 |
if (filepointer == null) { |
... | ... |
@@ -7528,7 +8673,7 @@ function main(args) { |
7528 | 8673 |
resolve(state); |
7529 | 8674 |
} |
7530 | 8675 |
else { |
7531 |
- _fs.writeFile(filepointer.toString(), state.script, function (error) { |
|
8676 |
+ nm_fs.writeFile(filepointer.toString(), state.script, function (error) { |
|
7532 | 8677 |
if (error == null) { |
7533 | 8678 |
resolve(state); |
7534 | 8679 |
} |
... | ... |
@@ -7540,7 +8685,8 @@ function main(args) { |
7540 | 8685 |
}; }, |
7541 | 8686 |
// execute |
7542 | 8687 |
function (state) { return function (resolve, reject) { |
7543 |
- if (!configuration.execute) { |
|
8688 |
+ log("executing", 2); |
|
8689 |
+ if (!globalvars.configuration.execute) { |
|
7544 | 8690 |
resolve(state); |
7545 | 8691 |
} |
7546 | 8692 |
else { |
... | ... |
@@ -7552,13 +8698,14 @@ function main(args) { |
7552 | 8698 |
process.exit(0); |
7553 | 8699 |
}, function (reason) { |
7554 | 8700 |
// throw reason; |
7555 |
- // console.error(reason); |
|
8701 |
+ console.error(reason); |
|
7556 | 8702 |
(new class_message("the following error occured: '" + reason.toString() + "'", { "type": "error", "prefix": "koralle" })).stderr(); |
7557 | 8703 |
process.exit(-1); |
7558 | 8704 |
}); |
7559 | 8705 |
} |
7560 | 8706 |
} |
7561 |
-configuration.invocation = { |
|
8707 |
+log("intro", 2); |
|
8708 |
+globalvars.invocation = { |
|
7562 | 8709 |
"interpreter": process.argv[0], |
7563 | 8710 |
"path": process.argv[1], |
7564 | 8711 |
}; |