@quenk/wml 2.13.10 → 2.14.0

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.
Files changed (60) hide show
  1. package/lib/cli.d.ts +8 -8
  2. package/lib/cli.js +1 -3
  3. package/lib/cli.js.map +1 -1
  4. package/lib/cli.ts +48 -60
  5. package/lib/compile/codegen.d.ts +4 -9
  6. package/lib/compile/codegen.js +164 -369
  7. package/lib/compile/codegen.js.map +1 -1
  8. package/lib/compile/codegen.ts +644 -952
  9. package/lib/compile/index.d.ts +2 -2
  10. package/lib/compile/index.js +4 -4
  11. package/lib/compile/index.js.map +1 -1
  12. package/lib/compile/index.ts +14 -17
  13. package/lib/compile/transform.d.ts +8 -6
  14. package/lib/compile/transform.js +46 -18
  15. package/lib/compile/transform.js.map +1 -1
  16. package/lib/compile/transform.ts +139 -116
  17. package/lib/{dom.d.ts → dom/index.d.ts} +8 -2
  18. package/lib/{dom.js → dom/index.js} +84 -66
  19. package/lib/dom/index.js.map +1 -0
  20. package/lib/dom/index.ts +425 -0
  21. package/lib/dom/monitor.d.ts +33 -0
  22. package/lib/dom/monitor.js +60 -0
  23. package/lib/dom/monitor.js.map +1 -0
  24. package/lib/dom/monitor.ts +75 -0
  25. package/lib/index.d.ts +10 -95
  26. package/lib/index.js +10 -10
  27. package/lib/index.js.map +1 -1
  28. package/lib/index.ts +57 -182
  29. package/lib/main.js +17 -17
  30. package/lib/main.js.map +1 -1
  31. package/lib/main.ts +38 -44
  32. package/lib/parse/ast.d.ts +12 -6
  33. package/lib/parse/ast.js +68 -58
  34. package/lib/parse/ast.js.map +1 -1
  35. package/lib/parse/ast.ts +400 -482
  36. package/lib/parse/generated.d.ts +3 -5
  37. package/lib/parse/generated.js +9504 -9264
  38. package/lib/parse/index.d.ts +2 -3
  39. package/lib/parse/index.js.map +1 -1
  40. package/lib/parse/index.ts +7 -9
  41. package/lib/parse/test.js +194 -192
  42. package/lib/parse/test.js.map +1 -1
  43. package/lib/parse/test.ts +294 -404
  44. package/lib/parse/wml.y +4 -0
  45. package/lib/tsconfig.json +19 -20
  46. package/lib/util.d.ts +10 -0
  47. package/lib/util.js +21 -0
  48. package/lib/util.js.map +1 -0
  49. package/lib/util.ts +39 -0
  50. package/lib/view/frame.d.ts +103 -0
  51. package/lib/view/frame.js +206 -0
  52. package/lib/view/frame.js.map +1 -0
  53. package/lib/view/frame.ts +249 -0
  54. package/lib/view/index.d.ts +58 -0
  55. package/lib/view/index.js +48 -0
  56. package/lib/view/index.js.map +1 -0
  57. package/lib/view/index.ts +97 -0
  58. package/package.json +4 -3
  59. package/lib/dom.js.map +0 -1
  60. package/lib/dom.ts +0 -475
@@ -1,6 +1,5 @@
1
- /// <reference path="generated.d.ts" />
2
- import * as nodes from './ast';
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
  */
@@ -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,CACzE,IAAA,eAAO,EAAC,GAAG,EAAE;IAET,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAE3B,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAEpC,CAAC,CAAC,CAAC;AAPM,QAAA,KAAK,SAOX"}
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"}
@@ -1,18 +1,16 @@
1
1
  /// <reference path='generated.d.ts' />
2
2
 
3
- import * as parser from './generated';
4
- import * as nodes from './ast';
3
+ import * as parser from "./generated";
4
+ import * as nodes from "./ast";
5
5
 
6
- import { Except, attempt } from '@quenk/noni/lib/control/error';
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
- attempt(() => {
12
+ attempt(() => {
13
+ parser.parser.yy = { ast };
13
14
 
14
- parser.parser.yy = { ast };
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
- 'should parse qualified import': {
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
- 'should parse named import': {
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
- 'should detect exact duplicate imports': {
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
- 'should parse a self closing tag': {
15
- input: '<simple/>'
14
+ "should parse a self closing tag": {
15
+ input: "<simple/>",
16
16
  },
17
- 'should parse a self closing tag with attributes 0': {
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
- 'should parse a self closing tag with attributes 1': {
21
- input: '<user app:enabled id=24 />',
20
+ "should parse a self closing tag with attributes 1": {
21
+ input: "<user app:enabled id=24 />",
22
22
  },
23
- 'should parse a self closing tag with attributes 2': {
23
+ "should parse a self closing tag with attributes 2": {
24
24
  input: '<user name="xyaa aaz" id="24" align="left"/>',
25
25
  },
26
- 'should parse a parent tag': {
27
- input: '<panel> \n\n\n\n\n\n\n\n\n </panel>'
26
+ "should parse a parent tag": {
27
+ input: "<panel> \n\n\n\n\n\n\n\n\n </panel>",
28
28
  },
29
- 'should parse a parent tag with attributes': {
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
- 'should parse parent tags with mixed children': {
33
- input: '<panel> This is my offsprings.<a>Link</a>Hey now! <Input/></panel>'
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
- 'should parse parent tags with tag children (L1)': {
36
- input: '<panel><a></a></panel>'
35
+ "should parse parent tags with tag children (L1)": {
36
+ input: "<panel><a></a></panel>",
37
37
  },
38
- 'should parse parent tags with tag children (L2)': {
38
+ "should parse parent tags with tag children (L2)": {
39
39
  input: '<panel><a href="link" onclick={{@someting.invoke()}}>' +
40
- 'Click Here</a><table/></panel>'
40
+ "Click Here</a><table/></panel>",
41
41
  },
42
- 'should parse parent tags with tag children (L3)': {
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
- 'should do it all together now': {
46
+ "should do it all together now": {
47
47
  input: '<modal name="mymodal" x="1" y="2">' +
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' +
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
- ' 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': {
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
- 'should parse if then expressions': {
83
- input: '<Html id={{@id}}>{{ if @check() then a else b }}</Html>'
82
+ "should parse if then expressions": {
83
+ input: "<Html id={{@id}}>{{ if @check() then a else b }}</Html>",
84
84
  },
85
- 'should parse function expressions': {
86
- input: '<button onclick={{e -> call(e)}}/>'
85
+ "should parse function expressions": {
86
+ input: "<button onclick={{e -> call(e)}}/>",
87
87
  },
88
- 'should parse function expressions (no args)': {
89
- input: '<button onclick={{ -> call()}}/>'
88
+ "should parse function expressions (no args)": {
89
+ input: "<button onclick={{ -> call()}}/>",
90
90
  },
91
- 'should parse calls': {
92
- input: '<tr>{% for x,i in y %} {{ f(x, i) }} {% endfor %} </tr>'
91
+ "should parse calls": {
92
+ input: "<tr>{% for x,i in y %} {{ f(x, i) }} {% endfor %} </tr>",
93
93
  },
94
- 'should parse negative numbers': {
95
- input: '<tag n={{ ( -0.5 + 3) }} m={{(4 + -2)}} g={{ (10 --5) }}/>'
94
+ "should parse negative numbers": {
95
+ input: "<tag n={{ ( -0.5 + 3) }} m={{(4 + -2)}} g={{ (10 --5) }}/>",
96
96
  },
97
- 'should allow filter chaining': {
98
- input: '<p>{{ @value | f1 | f2(2) | f3(@value) }}</p>'
97
+ "should allow filter chaining": {
98
+ input: "<p>{{ @value | f1 | f2(2) | f3(@value) }}</p>",
99
99
  },
100
- 'should parse if else statements': {
101
- input: '<Tag>{% if value %}<text>Text</text>{% else %}<text>else</text>{% endif %}</Tag>'
100
+ "should parse if else statements": {
101
+ input: "<Tag>{% if value %}<text>Text</text>{% else %}<text>else</text>{% endif %}</Tag>",
102
102
  },
103
- 'should parse if else if statements': {
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
- 'should parse short fun statements': {
116
- input: '{% fun vue () = <View/> %}'
115
+ "should parse short fun statements": {
116
+ input: "{% fun vue () = <View/> %}",
117
117
  },
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}}/> %}'
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
- 'should parse short fun statements with type parameters': {
123
- input: '{% fun vue [A,B:C,C] (a:A, b:B) = ' +
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
- 'should parse extended fun statements': {
127
- input: '{% fun vue () %} <View/> {% endfun %}'
125
+ "should parse extended fun statements": {
126
+ input: "{% fun vue () %} <View/> {% endfun %}",
128
127
  },
129
- 'should parse extended fun statements with arguments': {
130
- input: '{% fun vue (a:String, b:String, c:String) %}' +
131
- '<View a={{a}} b={{b}} c={{c}}/> {% endfun %}'
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
- 'should parse extended fun statements with type parameters': {
134
- input: '{% fun vue [A,B:C,C] (a:A, b:B) %} {{ ((a + b) + c) }} {% endfun %}'
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
- 'should parse binary expressions': {
137
- input: '<p>{{(Styles.A + Styles.B)}}</p>'
135
+ "should parse binary expressions": {
136
+ input: "<p>{{(Styles.A + Styles.B)}}</p>",
138
137
  },
139
- 'should parse complicated expressions': {
140
- input: '<div class={{((Styles.A + " ") + Style.B)}}/>'
138
+ "should parse complicated expressions": {
139
+ input: '<div class={{((Styles.A + " ") + Style.B)}}/>',
141
140
  },
142
- 'should allow for statement as child of fun': {
143
- input: '{% fun sven () %} {% for a in b %} {{b}} {% endfor %} {% endfun %}'
141
+ "should allow for statement as child of fun": {
142
+ input: "{% fun sven () %} {% for a in b %} {{b}} {% endfor %} {% endfun %}",
144
143
  },
145
- 'should allow if statement as child of fun': {
146
- input: '{% fun ate (o:Object) %} {% if a %} {{a}} {% else %} {{a}} ' +
147
- '{% endif %} {% endfun %}'
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
- 'should allow for booleans in interpolations': {
150
- input: '<bool active={{true}}>{{if fun() then false else true}}</bool>'
148
+ "should allow for booleans in interpolations": {
149
+ input: "<bool active={{true}}>{{if fun() then false else true}}</bool>",
151
150
  },
152
- 'should allow calls on expressions': {
153
- input: '<div>{{(content() || bar)(foo)}}</div>'
151
+ "should allow calls on expressions": {
152
+ input: "<div>{{(content() || bar)(foo)}}</div>",
154
153
  },
155
- 'should allow boolean attribute values': {
156
- input: '<tag on=true off=false/>'
154
+ "should allow boolean attribute values": {
155
+ input: "<tag on=true off=false/>",
157
156
  },
158
- '[view] should parse typed views': {
159
- input: '{% view Main (Context[String]) %} <p>{{@value}}</p>'
157
+ "[view] should parse typed views": {
158
+ input: "{% view Main (Context[String]) %} <p>{{@value}}</p>",
160
159
  },
161
- '[view] should parse typed views with type parameters': {
162
- input: '{% view Main [A,B] (Context[A,B]) %} <p>{{@values}}</p>'
160
+ "[view] should parse typed views with type parameters": {
161
+ input: "{% view Main [A,B] (Context[A,B]) %} <p>{{@values}}</p>",
163
162
  },
164
- '[view] should allow the where syntax': `
163
+ "[view] should allow the where syntax": `
165
164
 
166
165
  {% view HeadView where title: String %}
167
166
  <title>{{@title}}</title>
168
167
  `,
169
- 'should parse context variables': {
170
- input: '<Input name={{@level.name}}/>'
168
+ "should parse context variables": {
169
+ input: "<Input name={{@level.name}}/>",
171
170
  },
172
- '[view] should allow inline context import': {
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
- '[view] should allow multiple inline context imports': {
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
- 'should allow construct expression': {
182
- input: '<TextView android:thing={value=1}>{{Person(@value)}}</TextView>'
180
+ "[view] should allow without context type": {
181
+ input: `{% view TestView %}<b>Test</b>`,
183
182
  },
184
- 'should allow view construction': {
185
- input: '<p>{{ <Panel(@)> }}</p>'
183
+ "should allow construct expression": {
184
+ input: "<TextView android:thing={value=1}>{{Person(@value)}}</TextView>",
186
185
  },
187
- 'should allow fun application': {
188
- input: '<p>{{ <panel(1, 2, 3)> }}</p>'
186
+ "should allow view construction": {
187
+ input: "<p>{{ <Panel(@)> }}</p>",
189
188
  },
190
- 'should allow fun application with context': {
191
- input: '<div>{{ <panel(@,12)> }}</div>'
189
+ "should allow fun application": {
190
+ input: "<p>{{ <panel(1, 2, 3)> }}</p>",
192
191
  },
193
- 'should parse list types': {
194
- input: '{% fun action [A] (s: String[], a:A[]) = {{ \'${s}${a}\' }} %}'
192
+ "should allow fun application with context": {
193
+ input: "<div>{{ <panel(@,12)> }}</div>",
195
194
  },
196
- 'should allow context properties as fun application': {
197
- input: '<div>{{ <@action()> }}</div>'
195
+ "should parse list types": {
196
+ input: "{% fun action [A] (s: String[], a:A[]) = {{ '${s}${a}' }} %}",
198
197
  },
199
- 'should allow view statements after short fun': {
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
- 'should allow actual code': {
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
- 'should recognize type parameters': {
274
- input: '{% fun test[A:String] (a:A) %} {{a}} {% endfun %}'
275
+ "should recognize type parameters": {
276
+ input: "{% fun test[A:String] (a:A) %} {{a}} {% endfun %}",
275
277
  },
276
- 'should allow ifs without elses': {
277
- input: '{% view Test (Object) %}' +
278
- '<div> {% if (value == true) %} <span/> {% endif %} </div>'
278
+ "should allow ifs without elses": {
279
+ input: "{% view Test (Object) %}" +
280
+ "<div> {% if (value == true) %} <span/> {% endif %} </div>",
279
281
  },
280
- 'should allow else if as final branch': {
281
- input: '{% view Test(Object) %} <div> ' +
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
- '<div/> {% endif %} </div>'
285
+ "<div/> {% endif %} </div>",
284
286
  },
285
- '[context] should parse constructors': '{% context Test where name: String %}',
286
- '[context] should parse generic constructors': '{% context Test where table.name: Text[A] %}',
287
- '[context] should parse record types': `{% context Test[A] where
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
- '[context] should parse list types': `{% context Test[A] where table.data.list: A[] %}`,
297
- '[context] should parse 2d list types': `{% context Test[A,B] where table.data.list2: A[][] %}`,
298
- '[context] should parse 3d list types': `{% context Test[A, B, C] where table.data.list3: A[][][] %}`,
299
- '[context] should parse func with no args or parens': `{% context Test where value: Test -> Number %}`,
300
- '[context] should parse func with no args': `{% context Test where value: () -> Number %}`,
301
- '[context] should parse no-parens func with constructor': `{% context Test where value: String -> String %}`,
302
- '[context] should parse no-parens func with generic constructor': `{% context Test where value: Text[A] -> Text[A] %}`,
303
- '[context] should parse no-parens func with record arg': `{% context Test where value: {} -> { } %}`,
304
- '[context] should parse no-parens func with list arg': `{% context Test where value: String[] -> String[] %}`,
305
- '[context] should parse func with cons arg': `{% context Test where value: (String) -> String %}`,
306
- '[context] should parse func with 2 cons args': `{% context Test where value: (String, String) -> String %}`,
307
- '[context] should parse func with 3 cons args': `{% context Test where value: (String, String, String) -> String %}`,
308
- '[context] should parse func with generic cons arg': `{% context Test[A] where value: (Text[A]) -> Text[A] %}`,
309
- '[context] should parse func with 2 generic cons args': `{% context Test[A] where value: (Text[A], Text[A]) -> Text[A] %}`,
310
- '[context] should parse func with 3 generic cons args': `{% context Test[A] where value: (Text[A], Text[A], Text[A]) -> Text[A] %}`,
311
- '[context] should parse func with record arg': `{% context Test where value: ({ }) -> { } %}`,
312
- '[context] should parse func with 2 record args': `{% context Test where value: ({ }, { name: String }) -> { } %}`,
313
- '[context] should parse func with 3 record args': `{% context Test where value: ({ }, { name: String }, { value: A[]}) -> { } %}`,
314
- '[context] should parse func with list arg': `{% context Test where value: (String[]) -> String[] %}`,
315
- '[context] should parse func with 2 list args': `{% context Test where value: (String[], String[]) -> String[] %}`,
316
- '[context] should parse func with 3 list args': `{% context Test where value: (String[], String[], String[]) -> String[] %}`,
317
- '[context] should parse func with func arg': `{% context Test where value: (String -> String) -> String %}`,
318
- '[context] should parse func with 2 func args': `{% context Test where value: ((String -> String), (String -> String)) -> String %}`,
319
- '[context] should parse func with 3 func args': `{% context Test where
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
- '[context] should parse func that return array of generic type': `{% context Test[A] where value: Number -> Text[A][] %}`,
323
- '[context] should parse funct that return array of array': `{% context Test where value: String -> Number[][] %}`,
324
- '[context] should parse context definitions': {
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
- '[context] should allow optional properties': {
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
- '[context] should allow extending': {
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
- '[context] should mark nested properties as optional if all are': `{% context Paper where object."type"?: String %}`,
418
- 'should parse type statements': `{% type Type = String | Number | Boolean | Type[] | Type -> Type %}`,
419
- 'should parse tupe types': `{% type Tuple = [Number, String, Number] %}`,
420
- 'should parse type assertion': '<Panel onClick={{ \e -> foo(e) as User }} />',
421
- 'should parse partial application in expression': '<Link ww:text={{truncate(50)(@text)}} />',
422
- 'should transform special primitives': `<div>
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
- 'should allow casting': `
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
- 'should parse nullish operator': `<div>{% if value ?? true %}<b>True</b>{% else %}<b>False</b>{% endif %}</div>`,
444
- 'should parse optional chain operator': `<div>{% if (value?.val) ?? 1 %}<b>True</b>{% else %}<b>False</b>{% endif %}</div>`,
445
- '[let] should parse let statements': `{% let head:HeadCtx = {title = "Foo"} %}
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
- '[let] should be usable in a view': `
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
- '[comment] should parse html comments': `<!-- This is an html comment. -->`,
454
- '[comment] should parse wml comments': `{# This is a wml comment #}`,
455
- '[comment] should parse wml comments in statements': `{% view Name {# This is a comment! #} (Object) %} <div/> %}`,
456
- '[fun] should parse multi dimensional array parameters': `
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
- 'should allow index access on context properties': `{% view Test (Object) %}
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
- 'should allow paths to use brackets': `
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
- 'should allow 2nd level bracket access': `<div>{% for item in our."items" %} <div/>{% endfor %}</div> `,
471
- 'should allow type to be used in if statement expression': `<div>{% if item."type" == 1 %}<p/>{% endif %}</div>`,
472
- 'should support the special wml:attrs attribute': `<Panel wml:attrs={{@panelAttrs}}><div wml:attrs={{divAttrs}}/></Panel>`,
473
- 'should parse widgets with type arguments': `<div>
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
- 'should parse view construction with type arguments': `<div>{{<Panel[Text](@)>}}</div>`,
480
- 'should use createElementNS() recursively for xmlns attribute': `{% view TestView (Object) %}
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