@quenk/wml 2.13.11 → 2.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli.d.ts +8 -8
- package/lib/cli.js +1 -3
- package/lib/cli.js.map +1 -1
- package/lib/cli.ts +48 -60
- package/lib/compile/codegen.d.ts +4 -9
- package/lib/compile/codegen.js +161 -367
- package/lib/compile/codegen.js.map +1 -1
- package/lib/compile/codegen.ts +643 -952
- package/lib/compile/index.d.ts +2 -2
- package/lib/compile/index.js +4 -4
- package/lib/compile/index.js.map +1 -1
- package/lib/compile/index.ts +14 -17
- package/lib/compile/transform.d.ts +1 -1
- package/lib/compile/transform.js +9 -11
- package/lib/compile/transform.js.map +1 -1
- package/lib/compile/transform.ts +136 -143
- package/lib/{dom.d.ts → dom/index.d.ts} +8 -2
- package/lib/{dom.js → dom/index.js} +84 -70
- package/lib/dom/index.js.map +1 -0
- package/lib/dom/index.ts +425 -0
- package/lib/dom/monitor.d.ts +33 -0
- package/lib/dom/monitor.js +60 -0
- package/lib/dom/monitor.js.map +1 -0
- package/lib/dom/monitor.ts +75 -0
- package/lib/index.d.ts +10 -95
- package/lib/index.js +10 -10
- package/lib/index.js.map +1 -1
- package/lib/index.ts +57 -182
- package/lib/main.js +17 -17
- package/lib/main.js.map +1 -1
- package/lib/main.ts +38 -44
- package/lib/parse/ast.d.ts +2 -2
- package/lib/parse/ast.js +52 -53
- package/lib/parse/ast.js.map +1 -1
- package/lib/parse/ast.ts +396 -483
- package/lib/parse/generated.d.ts +3 -5
- package/lib/parse/generated.js +9504 -9264
- package/lib/parse/index.d.ts +2 -3
- package/lib/parse/index.js.map +1 -1
- package/lib/parse/index.ts +7 -9
- package/lib/parse/test.js +194 -192
- package/lib/parse/test.js.map +1 -1
- package/lib/parse/test.ts +294 -404
- package/lib/parse/wml.y +4 -0
- package/lib/tsconfig.json +19 -20
- package/lib/util.d.ts +10 -0
- package/lib/util.js +21 -0
- package/lib/util.js.map +1 -0
- package/lib/util.ts +39 -0
- package/lib/view/frame.d.ts +127 -0
- package/lib/view/frame.js +214 -0
- package/lib/view/frame.js.map +1 -0
- package/lib/view/frame.ts +295 -0
- package/lib/view/index.d.ts +58 -0
- package/lib/view/index.js +48 -0
- package/lib/view/index.js.map +1 -0
- package/lib/view/index.ts +98 -0
- package/package.json +3 -3
- package/lib/dom.js.map +0 -1
- package/lib/dom.ts +0 -479
package/lib/parse/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { Except } from '@quenk/noni/lib/control/error';
|
|
1
|
+
import * as nodes from "./ast";
|
|
2
|
+
import { Except } from "@quenk/noni/lib/control/error";
|
|
4
3
|
/**
|
|
5
4
|
* parse a string containing WML returning the resulting AST.
|
|
6
5
|
*/
|
package/lib/parse/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;AAEvC,sCAAsC;AACtC,+BAA+B;AAE/B,yDAAgE;AAEhE;;GAEG;AACI,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,MAAW,KAAK,EAAwB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;AAEvC,sCAAsC;AACtC,+BAA+B;AAE/B,yDAAgE;AAEhE;;GAEG;AACI,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,MAAW,KAAK,EAAwB,EAAE,CAC3E,IAAA,eAAO,EAAC,GAAG,EAAE;IACX,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAE3B,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC;AALQ,QAAA,KAAK,SAKb"}
|
package/lib/parse/index.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/// <reference path='generated.d.ts' />
|
|
2
2
|
|
|
3
|
-
import * as parser from
|
|
4
|
-
import * as nodes from
|
|
3
|
+
import * as parser from "./generated";
|
|
4
|
+
import * as nodes from "./ast";
|
|
5
5
|
|
|
6
|
-
import { Except, attempt } from
|
|
6
|
+
import { Except, attempt } from "@quenk/noni/lib/control/error";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* parse a string containing WML returning the resulting AST.
|
|
10
10
|
*/
|
|
11
11
|
export const parse = (str: string, ast: any = nodes): Except<nodes.Module> =>
|
|
12
|
-
|
|
12
|
+
attempt(() => {
|
|
13
|
+
parser.parser.yy = { ast };
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return parser.parser.parse(str);
|
|
17
|
-
|
|
18
|
-
});
|
|
15
|
+
return parser.parser.parse(str);
|
|
16
|
+
});
|
package/lib/parse/test.js
CHANGED
|
@@ -2,105 +2,105 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tests = void 0;
|
|
4
4
|
exports.tests = {
|
|
5
|
-
|
|
6
|
-
input: `{% import * as lib from "path/to/libs" %}
|
|
5
|
+
"should parse qualified import": {
|
|
6
|
+
input: `{% import * as lib from "path/to/libs" %}`,
|
|
7
7
|
},
|
|
8
|
-
|
|
9
|
-
input: `{% import (B) from "path/to/a/b" %}
|
|
8
|
+
"should parse named import": {
|
|
9
|
+
input: `{% import (B) from "path/to/a/b" %}`,
|
|
10
10
|
},
|
|
11
|
-
|
|
12
|
-
input: `{% import (A) from "b" %} {% import (A) from "b" %}
|
|
11
|
+
"should detect exact duplicate imports": {
|
|
12
|
+
input: `{% import (A) from "b" %} {% import (A) from "b" %}`,
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
input:
|
|
14
|
+
"should parse a self closing tag": {
|
|
15
|
+
input: "<simple/>",
|
|
16
16
|
},
|
|
17
|
-
|
|
17
|
+
"should parse a self closing tag with attributes 0": {
|
|
18
18
|
input: '<user name="xyaa aaz" position={{4|x(20)}} wml:val="test"/>',
|
|
19
19
|
},
|
|
20
|
-
|
|
21
|
-
input:
|
|
20
|
+
"should parse a self closing tag with attributes 1": {
|
|
21
|
+
input: "<user app:enabled id=24 />",
|
|
22
22
|
},
|
|
23
|
-
|
|
23
|
+
"should parse a self closing tag with attributes 2": {
|
|
24
24
|
input: '<user name="xyaa aaz" id="24" align="left"/>',
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
input:
|
|
26
|
+
"should parse a parent tag": {
|
|
27
|
+
input: "<panel> \n\n\n\n\n\n\n\n\n </panel>",
|
|
28
28
|
},
|
|
29
|
-
|
|
30
|
-
input: '<panel type="default" size="40" align="left"> </panel>'
|
|
29
|
+
"should parse a parent tag with attributes": {
|
|
30
|
+
input: '<panel type="default" size="40" align="left"> </panel>',
|
|
31
31
|
},
|
|
32
|
-
|
|
33
|
-
input:
|
|
32
|
+
"should parse parent tags with mixed children": {
|
|
33
|
+
input: "<panel> This is my offsprings.<a>Link</a>Hey now! <Input/></panel>",
|
|
34
34
|
},
|
|
35
|
-
|
|
36
|
-
input:
|
|
35
|
+
"should parse parent tags with tag children (L1)": {
|
|
36
|
+
input: "<panel><a></a></panel>",
|
|
37
37
|
},
|
|
38
|
-
|
|
38
|
+
"should parse parent tags with tag children (L2)": {
|
|
39
39
|
input: '<panel><a href="link" onclick={{@someting.invoke()}}>' +
|
|
40
|
-
|
|
40
|
+
"Click Here</a><table/></panel>",
|
|
41
41
|
},
|
|
42
|
-
|
|
42
|
+
"should parse parent tags with tag children (L3)": {
|
|
43
43
|
input: '<panel><a href="link">Click Here</a><table/>' +
|
|
44
|
-
'<panel c="22"></panel></panel>'
|
|
44
|
+
'<panel c="22"></panel></panel>',
|
|
45
45
|
},
|
|
46
|
-
|
|
46
|
+
"should do it all together now": {
|
|
47
47
|
input: '<modal name="mymodal" x="1" y="2">' +
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
"<modal-header>My Modal</modal-header>" +
|
|
49
|
+
"<modal-body>" +
|
|
50
|
+
"Creativxity is inhibxited by greed and corruption." +
|
|
51
|
+
"<vote-button/>" +
|
|
52
|
+
"<vote-count source={{@}}/> Votes" +
|
|
53
53
|
'<textarea wml:id="ta" disabled size=32 onchange={{@setText}}>' +
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
input:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
input:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
|
|
54
|
+
" Various text" +
|
|
55
|
+
"</textarea>" +
|
|
56
|
+
"</modal-body>" +
|
|
57
|
+
"</modal>",
|
|
58
|
+
},
|
|
59
|
+
"should parse for in statements": {
|
|
60
|
+
input: "<root>" +
|
|
61
|
+
"{% for value,key in [] %}" +
|
|
62
|
+
"<stem>{{value}}</stem>" +
|
|
63
|
+
"{% endfor %}" +
|
|
64
|
+
"</root>",
|
|
65
|
+
},
|
|
66
|
+
"should parse for of statements": {
|
|
67
|
+
input: "<root>" +
|
|
68
|
+
"{% for value,key of {} %}" +
|
|
69
|
+
"<stem>{{key}} ~ {{value}}</stem>" +
|
|
70
|
+
"{% endfor %}" +
|
|
71
|
+
"</root>",
|
|
72
|
+
},
|
|
73
|
+
"should parse for from statements": {
|
|
74
74
|
input: `
|
|
75
75
|
<root>
|
|
76
76
|
{% for value=1 to 30 %}
|
|
77
77
|
<b>{{value}}</b>
|
|
78
78
|
{% endfor %}
|
|
79
79
|
</root>
|
|
80
|
-
|
|
80
|
+
`,
|
|
81
81
|
},
|
|
82
|
-
|
|
83
|
-
input:
|
|
82
|
+
"should parse if then expressions": {
|
|
83
|
+
input: "<Html id={{@id}}>{{ if @check() then a else b }}</Html>",
|
|
84
84
|
},
|
|
85
|
-
|
|
86
|
-
input:
|
|
85
|
+
"should parse function expressions": {
|
|
86
|
+
input: "<button onclick={{e -> call(e)}}/>",
|
|
87
87
|
},
|
|
88
|
-
|
|
89
|
-
input:
|
|
88
|
+
"should parse function expressions (no args)": {
|
|
89
|
+
input: "<button onclick={{ -> call()}}/>",
|
|
90
90
|
},
|
|
91
|
-
|
|
92
|
-
input:
|
|
91
|
+
"should parse calls": {
|
|
92
|
+
input: "<tr>{% for x,i in y %} {{ f(x, i) }} {% endfor %} </tr>",
|
|
93
93
|
},
|
|
94
|
-
|
|
95
|
-
input:
|
|
94
|
+
"should parse negative numbers": {
|
|
95
|
+
input: "<tag n={{ ( -0.5 + 3) }} m={{(4 + -2)}} g={{ (10 --5) }}/>",
|
|
96
96
|
},
|
|
97
|
-
|
|
98
|
-
input:
|
|
97
|
+
"should allow filter chaining": {
|
|
98
|
+
input: "<p>{{ @value | f1 | f2(2) | f3(@value) }}</p>",
|
|
99
99
|
},
|
|
100
|
-
|
|
101
|
-
input:
|
|
100
|
+
"should parse if else statements": {
|
|
101
|
+
input: "<Tag>{% if value %}<text>Text</text>{% else %}<text>else</text>{% endif %}</Tag>",
|
|
102
102
|
},
|
|
103
|
-
|
|
103
|
+
"should parse if else if statements": {
|
|
104
104
|
input: `
|
|
105
105
|
<Tag>
|
|
106
106
|
{% if value %}
|
|
@@ -110,93 +110,95 @@ exports.tests = {
|
|
|
110
110
|
{% else %}
|
|
111
111
|
no
|
|
112
112
|
{% endif %}
|
|
113
|
-
</Tag
|
|
113
|
+
</Tag>`,
|
|
114
114
|
},
|
|
115
|
-
|
|
116
|
-
input:
|
|
115
|
+
"should parse short fun statements": {
|
|
116
|
+
input: "{% fun vue () = <View/> %}",
|
|
117
117
|
},
|
|
118
|
-
|
|
119
|
-
input:
|
|
120
|
-
|
|
118
|
+
"should parse short fun statements with arguments": {
|
|
119
|
+
input: "{% fun vue (a:String, b:String, c:String) = " +
|
|
120
|
+
"<View a={{a}} b={{b}} c={{c}}/> %}",
|
|
121
121
|
},
|
|
122
|
-
|
|
123
|
-
input:
|
|
124
|
-
'{{ (a + b) + c }} %}'
|
|
122
|
+
"should parse short fun statements with type parameters": {
|
|
123
|
+
input: "{% fun vue [A,B:C,C] (a:A, b:B) = " + "{{ (a + b) + c }} %}",
|
|
125
124
|
},
|
|
126
|
-
|
|
127
|
-
input:
|
|
125
|
+
"should parse extended fun statements": {
|
|
126
|
+
input: "{% fun vue () %} <View/> {% endfun %}",
|
|
128
127
|
},
|
|
129
|
-
|
|
130
|
-
input:
|
|
131
|
-
|
|
128
|
+
"should parse extended fun statements with arguments": {
|
|
129
|
+
input: "{% fun vue (a:String, b:String, c:String) %}" +
|
|
130
|
+
"<View a={{a}} b={{b}} c={{c}}/> {% endfun %}",
|
|
132
131
|
},
|
|
133
|
-
|
|
134
|
-
input:
|
|
132
|
+
"should parse extended fun statements with type parameters": {
|
|
133
|
+
input: "{% fun vue [A,B:C,C] (a:A, b:B) %} {{ ((a + b) + c) }} {% endfun %}",
|
|
135
134
|
},
|
|
136
|
-
|
|
137
|
-
input:
|
|
135
|
+
"should parse binary expressions": {
|
|
136
|
+
input: "<p>{{(Styles.A + Styles.B)}}</p>",
|
|
138
137
|
},
|
|
139
|
-
|
|
140
|
-
input: '<div class={{((Styles.A + " ") + Style.B)}}/>'
|
|
138
|
+
"should parse complicated expressions": {
|
|
139
|
+
input: '<div class={{((Styles.A + " ") + Style.B)}}/>',
|
|
141
140
|
},
|
|
142
|
-
|
|
143
|
-
input:
|
|
141
|
+
"should allow for statement as child of fun": {
|
|
142
|
+
input: "{% fun sven () %} {% for a in b %} {{b}} {% endfor %} {% endfun %}",
|
|
144
143
|
},
|
|
145
|
-
|
|
146
|
-
input:
|
|
147
|
-
|
|
144
|
+
"should allow if statement as child of fun": {
|
|
145
|
+
input: "{% fun ate (o:Object) %} {% if a %} {{a}} {% else %} {{a}} " +
|
|
146
|
+
"{% endif %} {% endfun %}",
|
|
148
147
|
},
|
|
149
|
-
|
|
150
|
-
input:
|
|
148
|
+
"should allow for booleans in interpolations": {
|
|
149
|
+
input: "<bool active={{true}}>{{if fun() then false else true}}</bool>",
|
|
151
150
|
},
|
|
152
|
-
|
|
153
|
-
input:
|
|
151
|
+
"should allow calls on expressions": {
|
|
152
|
+
input: "<div>{{(content() || bar)(foo)}}</div>",
|
|
154
153
|
},
|
|
155
|
-
|
|
156
|
-
input:
|
|
154
|
+
"should allow boolean attribute values": {
|
|
155
|
+
input: "<tag on=true off=false/>",
|
|
157
156
|
},
|
|
158
|
-
|
|
159
|
-
input:
|
|
157
|
+
"[view] should parse typed views": {
|
|
158
|
+
input: "{% view Main (Context[String]) %} <p>{{@value}}</p>",
|
|
160
159
|
},
|
|
161
|
-
|
|
162
|
-
input:
|
|
160
|
+
"[view] should parse typed views with type parameters": {
|
|
161
|
+
input: "{% view Main [A,B] (Context[A,B]) %} <p>{{@values}}</p>",
|
|
163
162
|
},
|
|
164
|
-
|
|
163
|
+
"[view] should allow the where syntax": `
|
|
165
164
|
|
|
166
165
|
{% view HeadView where title: String %}
|
|
167
166
|
<title>{{@title}}</title>
|
|
168
167
|
`,
|
|
169
|
-
|
|
170
|
-
input:
|
|
168
|
+
"should parse context variables": {
|
|
169
|
+
input: "<Input name={{@level.name}}/>",
|
|
171
170
|
},
|
|
172
|
-
|
|
173
|
-
input: '{% view MyView (Context from "./") %} <div>{{@text}}</div>'
|
|
171
|
+
"[view] should allow inline context import": {
|
|
172
|
+
input: '{% view MyView (Context from "./") %} <div>{{@text}}</div>',
|
|
174
173
|
},
|
|
175
|
-
|
|
174
|
+
"[view] should allow multiple inline context imports": {
|
|
176
175
|
input: `
|
|
177
176
|
{% view MyView (Context from "./") %} <div>{{@text}}</div>
|
|
178
177
|
{% view YourView (Context from "./") %} <div/>
|
|
179
|
-
|
|
178
|
+
`,
|
|
180
179
|
},
|
|
181
|
-
|
|
182
|
-
input:
|
|
180
|
+
"[view] should allow without context type": {
|
|
181
|
+
input: `{% view TestView %}<b>Test</b>`,
|
|
183
182
|
},
|
|
184
|
-
|
|
185
|
-
input:
|
|
183
|
+
"should allow construct expression": {
|
|
184
|
+
input: "<TextView android:thing={value=1}>{{Person(@value)}}</TextView>",
|
|
186
185
|
},
|
|
187
|
-
|
|
188
|
-
input:
|
|
186
|
+
"should allow view construction": {
|
|
187
|
+
input: "<p>{{ <Panel(@)> }}</p>",
|
|
189
188
|
},
|
|
190
|
-
|
|
191
|
-
input:
|
|
189
|
+
"should allow fun application": {
|
|
190
|
+
input: "<p>{{ <panel(1, 2, 3)> }}</p>",
|
|
192
191
|
},
|
|
193
|
-
|
|
194
|
-
input:
|
|
192
|
+
"should allow fun application with context": {
|
|
193
|
+
input: "<div>{{ <panel(@,12)> }}</div>",
|
|
195
194
|
},
|
|
196
|
-
|
|
197
|
-
input:
|
|
195
|
+
"should parse list types": {
|
|
196
|
+
input: "{% fun action [A] (s: String[], a:A[]) = {{ '${s}${a}' }} %}",
|
|
198
197
|
},
|
|
199
|
-
|
|
198
|
+
"should allow context properties as fun application": {
|
|
199
|
+
input: "<div>{{ <@action()> }}</div>",
|
|
200
|
+
},
|
|
201
|
+
"should allow view statements after short fun": {
|
|
200
202
|
input: `
|
|
201
203
|
|
|
202
204
|
{% fun template [A] (d: Date[A], o:A, _:String, __:A[]) = {{String(o)}} %}
|
|
@@ -215,9 +217,9 @@ exports.tests = {
|
|
|
215
217
|
|
|
216
218
|
{% endfor %}
|
|
217
219
|
|
|
218
|
-
</ul
|
|
220
|
+
</ul>`,
|
|
219
221
|
},
|
|
220
|
-
|
|
222
|
+
"should allow actual code": {
|
|
221
223
|
input: `
|
|
222
224
|
{% import (Table) from "@quenk/wml-widgets/lib/data/table" %}
|
|
223
225
|
{% import (TextField) from "@quenk/wml-widgets/lib/control/text-field" %}
|
|
@@ -268,23 +270,23 @@ exports.tests = {
|
|
|
268
270
|
|
|
269
271
|
{{@children}}
|
|
270
272
|
|
|
271
|
-
</Panel
|
|
273
|
+
</Panel>`,
|
|
272
274
|
},
|
|
273
|
-
|
|
274
|
-
input:
|
|
275
|
+
"should recognize type parameters": {
|
|
276
|
+
input: "{% fun test[A:String] (a:A) %} {{a}} {% endfun %}",
|
|
275
277
|
},
|
|
276
|
-
|
|
277
|
-
input:
|
|
278
|
-
|
|
278
|
+
"should allow ifs without elses": {
|
|
279
|
+
input: "{% view Test (Object) %}" +
|
|
280
|
+
"<div> {% if (value == true) %} <span/> {% endif %} </div>",
|
|
279
281
|
},
|
|
280
|
-
|
|
281
|
-
input:
|
|
282
|
+
"should allow else if as final branch": {
|
|
283
|
+
input: "{% view Test(Object) %} <div> " +
|
|
282
284
|
'{% if ( show == "span" ) %} <span/> {% else if (show == "div" ) %}' +
|
|
283
|
-
|
|
285
|
+
"<div/> {% endif %} </div>",
|
|
284
286
|
},
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
287
|
+
"[context] should parse constructors": "{% context Test where name: String %}",
|
|
288
|
+
"[context] should parse generic constructors": "{% context Test where table.name: Text[A] %}",
|
|
289
|
+
"[context] should parse record types": `{% context Test[A] where
|
|
288
290
|
|
|
289
291
|
table.data.record: {
|
|
290
292
|
|
|
@@ -293,35 +295,35 @@ exports.tests = {
|
|
|
293
295
|
table.data.list: A[]
|
|
294
296
|
}
|
|
295
297
|
%}`,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
298
|
+
"[context] should parse list types": `{% context Test[A] where table.data.list: A[] %}`,
|
|
299
|
+
"[context] should parse 2d list types": `{% context Test[A,B] where table.data.list2: A[][] %}`,
|
|
300
|
+
"[context] should parse 3d list types": `{% context Test[A, B, C] where table.data.list3: A[][][] %}`,
|
|
301
|
+
"[context] should parse func with no args or parens": `{% context Test where value: Test -> Number %}`,
|
|
302
|
+
"[context] should parse func with no args": `{% context Test where value: () -> Number %}`,
|
|
303
|
+
"[context] should parse no-parens func with constructor": `{% context Test where value: String -> String %}`,
|
|
304
|
+
"[context] should parse no-parens func with generic constructor": `{% context Test where value: Text[A] -> Text[A] %}`,
|
|
305
|
+
"[context] should parse no-parens func with record arg": `{% context Test where value: {} -> { } %}`,
|
|
306
|
+
"[context] should parse no-parens func with list arg": `{% context Test where value: String[] -> String[] %}`,
|
|
307
|
+
"[context] should parse func with cons arg": `{% context Test where value: (String) -> String %}`,
|
|
308
|
+
"[context] should parse func with 2 cons args": `{% context Test where value: (String, String) -> String %}`,
|
|
309
|
+
"[context] should parse func with 3 cons args": `{% context Test where value: (String, String, String) -> String %}`,
|
|
310
|
+
"[context] should parse func with generic cons arg": `{% context Test[A] where value: (Text[A]) -> Text[A] %}`,
|
|
311
|
+
"[context] should parse func with 2 generic cons args": `{% context Test[A] where value: (Text[A], Text[A]) -> Text[A] %}`,
|
|
312
|
+
"[context] should parse func with 3 generic cons args": `{% context Test[A] where value: (Text[A], Text[A], Text[A]) -> Text[A] %}`,
|
|
313
|
+
"[context] should parse func with record arg": `{% context Test where value: ({ }) -> { } %}`,
|
|
314
|
+
"[context] should parse func with 2 record args": `{% context Test where value: ({ }, { name: String }) -> { } %}`,
|
|
315
|
+
"[context] should parse func with 3 record args": `{% context Test where value: ({ }, { name: String }, { value: A[]}) -> { } %}`,
|
|
316
|
+
"[context] should parse func with list arg": `{% context Test where value: (String[]) -> String[] %}`,
|
|
317
|
+
"[context] should parse func with 2 list args": `{% context Test where value: (String[], String[]) -> String[] %}`,
|
|
318
|
+
"[context] should parse func with 3 list args": `{% context Test where value: (String[], String[], String[]) -> String[] %}`,
|
|
319
|
+
"[context] should parse func with func arg": `{% context Test where value: (String -> String) -> String %}`,
|
|
320
|
+
"[context] should parse func with 2 func args": `{% context Test where value: ((String -> String), (String -> String)) -> String %}`,
|
|
321
|
+
"[context] should parse func with 3 func args": `{% context Test where
|
|
320
322
|
value: ((String -> String), (String -> String), (String -> String)) -> String
|
|
321
323
|
%}`,
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
324
|
+
"[context] should parse func that return array of generic type": `{% context Test[A] where value: Number -> Text[A][] %}`,
|
|
325
|
+
"[context] should parse funct that return array of array": `{% context Test where value: String -> Number[][] %}`,
|
|
326
|
+
"[context] should parse context definitions": {
|
|
325
327
|
input: `{% context Manager[A] where
|
|
326
328
|
|
|
327
329
|
name: String,
|
|
@@ -385,9 +387,9 @@ exports.tests = {
|
|
|
385
387
|
funcRetMultiArray: String -> Number[][]
|
|
386
388
|
|
|
387
389
|
|
|
388
|
-
%}
|
|
390
|
+
%} `,
|
|
389
391
|
},
|
|
390
|
-
|
|
392
|
+
"[context] should allow optional properties": {
|
|
391
393
|
input: `{% context AContract where
|
|
392
394
|
|
|
393
395
|
id?: Number,
|
|
@@ -398,9 +400,9 @@ exports.tests = {
|
|
|
398
400
|
|
|
399
401
|
name.last?: String
|
|
400
402
|
|
|
401
|
-
%}
|
|
403
|
+
%}`,
|
|
402
404
|
},
|
|
403
|
-
|
|
405
|
+
"[context] should allow extending": {
|
|
404
406
|
input: `{% context AContract where :BContract %}
|
|
405
407
|
{% context CContract where :AContract, :BContract %}
|
|
406
408
|
{% context DContract[Type] where :CContract, member: Type %}
|
|
@@ -412,14 +414,14 @@ exports.tests = {
|
|
|
412
414
|
member1: B,
|
|
413
415
|
member2: C
|
|
414
416
|
%}
|
|
415
|
-
{% context DContract where :AContract, member: DType %}
|
|
416
|
-
},
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
417
|
+
{% context DContract where :AContract, member: DType %}`,
|
|
418
|
+
},
|
|
419
|
+
"[context] should mark nested properties as optional if all are": `{% context Paper where object."type"?: String %}`,
|
|
420
|
+
"should parse type statements": `{% type Type = String | Number | Boolean | Type[] | Type -> Type %}`,
|
|
421
|
+
"should parse tupe types": `{% type Tuple = [Number, String, Number] %}`,
|
|
422
|
+
"should parse type assertion": "<Panel onClick={{ \e -> foo(e) as User }} />",
|
|
423
|
+
"should parse partial application in expression": "<Link ww:text={{truncate(50)(@text)}} />",
|
|
424
|
+
"should transform special primitives": `<div>
|
|
423
425
|
{% for kind in [
|
|
424
426
|
String,
|
|
425
427
|
Boolean,
|
|
@@ -433,51 +435,51 @@ exports.tests = {
|
|
|
433
435
|
{{ kind | text }}
|
|
434
436
|
{% endfor %}
|
|
435
437
|
</div>`,
|
|
436
|
-
|
|
438
|
+
"should allow casting": `
|
|
437
439
|
{% view Test (Object) %}
|
|
438
440
|
<Widget
|
|
439
441
|
val1={{String(@value)}}
|
|
440
442
|
val2={{Number(@value)}}
|
|
441
443
|
val3={{Boolean(@value)}} />
|
|
442
444
|
`,
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
445
|
+
"should parse nullish operator": `<div>{% if value ?? true %}<b>True</b>{% else %}<b>False</b>{% endif %}</div>`,
|
|
446
|
+
"should parse optional chain operator": `<div>{% if (value?.val) ?? 1 %}<b>True</b>{% else %}<b>False</b>{% endif %}</div>`,
|
|
447
|
+
"[let] should parse let statements": `{% let head:HeadCtx = {title = "Foo"} %}
|
|
446
448
|
{% let head2:HeadCtx = {title = "My Title"} %}
|
|
447
449
|
`,
|
|
448
|
-
|
|
450
|
+
"[let] should be usable in a view": `
|
|
449
451
|
{% view MyView(Object) %}
|
|
450
452
|
{% let head:HeadViewContext = {title = "My Title"} %}
|
|
451
453
|
<h1>{{<HeadView(head)>}}</h1>
|
|
452
454
|
`,
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
455
|
+
"[comment] should parse html comments": `<!-- This is an html comment. -->`,
|
|
456
|
+
"[comment] should parse wml comments": `{# This is a wml comment #}`,
|
|
457
|
+
"[comment] should parse wml comments in statements": `{% view Name {# This is a comment! #} (Object) %} <div/> %}`,
|
|
458
|
+
"[fun] should parse multi dimensional array parameters": `
|
|
457
459
|
{% fun test (value:List[][]) %}<p/>{% endfun %}`,
|
|
458
|
-
|
|
460
|
+
"should allow index access on context properties": `{% view Test (Object) %}
|
|
459
461
|
<div>
|
|
460
462
|
{% if @["type"] == 1 %}
|
|
461
463
|
<div/>
|
|
462
464
|
{% endif %}
|
|
463
465
|
</div>`,
|
|
464
|
-
|
|
466
|
+
"should allow paths to use brackets": `
|
|
465
467
|
{% view Test (Object) %}
|
|
466
468
|
<div>
|
|
467
469
|
{% if @values.controls["@type"] %} value {% endif %}
|
|
468
470
|
{% if @values.controls["@type"].value %} value {% endif %}
|
|
469
471
|
</div>`,
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
472
|
+
"should allow 2nd level bracket access": `<div>{% for item in our."items" %} <div/>{% endfor %}</div> `,
|
|
473
|
+
"should allow type to be used in if statement expression": `<div>{% if item."type" == 1 %}<p/>{% endif %}</div>`,
|
|
474
|
+
"should support the special wml:attrs attribute": `<Panel wml:attrs={{@panelAttrs}}><div wml:attrs={{divAttrs}}/></Panel>`,
|
|
475
|
+
"should parse widgets with type arguments": `<div>
|
|
474
476
|
<Panel[Text]>
|
|
475
477
|
<PanelHeader[Text] wml:id="header"/>
|
|
476
478
|
<PanelBody/>
|
|
477
479
|
</Panel>
|
|
478
480
|
</div>`,
|
|
479
|
-
|
|
480
|
-
|
|
481
|
+
"should parse view construction with type arguments": `<div>{{<Panel[Text](@)>}}</div>`,
|
|
482
|
+
"should use createElementNS() recursively for xmlns attribute": `{% view TestView (Object) %}
|
|
481
483
|
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
482
484
|
<path
|
|
483
485
|
fill="none"
|
|
@@ -493,6 +495,6 @@ exports.tests = {
|
|
|
493
495
|
m-20,10 h 10
|
|
494
496
|
m-20,10 h 10
|
|
495
497
|
m-20,10 h 10" />
|
|
496
|
-
</svg
|
|
498
|
+
</svg>`,
|
|
497
499
|
};
|
|
498
500
|
//# sourceMappingURL=test.js.map
|