@quenk/wml 2.13.11 → 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 +162 -367
  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 +1 -1
  14. package/lib/compile/transform.js +9 -11
  15. package/lib/compile/transform.js.map +1 -1
  16. package/lib/compile/transform.ts +136 -143
  17. package/lib/{dom.d.ts → dom/index.d.ts} +8 -2
  18. package/lib/{dom.js → dom/index.js} +84 -70
  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 +2 -2
  33. package/lib/parse/ast.js +52 -53
  34. package/lib/parse/ast.js.map +1 -1
  35. package/lib/parse/ast.ts +396 -483
  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 +3 -3
  59. package/lib/dom.js.map +0 -1
  60. package/lib/dom.ts +0 -479
package/lib/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- import { Maybe } from '@quenk/noni/lib/data/maybe';
2
- export { Maybe };
1
+ import { DOMEventCallbacks } from "./dom/monitor";
2
+ import { View, BaseView } from "./view";
3
+ export { Maybe } from "@quenk/noni/lib/data/maybe";
4
+ export { ViewFrame } from "./view/frame";
5
+ export { View, BaseView };
3
6
  /**
4
7
  * WidgetConstructor
5
8
  */
@@ -8,6 +11,10 @@ export type WidgetConstructor<A extends Attrs> = new (attributes: A, children: C
8
11
  * WMLElement can be DOM content or a user defined widget.
9
12
  */
10
13
  export type WMLElement = Content | Widget;
14
+ /**
15
+ * WMLId is a string used to identify a WML element or group within a view.
16
+ */
17
+ export type WMLId = string;
11
18
  /**
12
19
  * Content is what is actually intended to be rendered on a web page.
13
20
  */
@@ -16,37 +23,6 @@ export type Content = Node | Element | HTMLElement;
16
23
  * HTMLAttributeValue
17
24
  */
18
25
  export type HTMLAttributeValue = string | number | boolean | null | undefined | Function;
19
- /**
20
- * Template is a function that given a View (Registry)
21
- * will provide DOM content as well as performing
22
- * the side-effects of adding ids etc.
23
- */
24
- export type Template = (r: Registry) => Content;
25
- /**
26
- * Fun corresponds to the compiled signature of fun statements.
27
- */
28
- export type Fun = (r: Registry) => Content[];
29
- /**
30
- * Registry keeps track of the WMLElements in a view.
31
- */
32
- export interface Registry {
33
- /**
34
- * registerView
35
- */
36
- registerView(v: View): View;
37
- /**
38
- * register an element.
39
- */
40
- register<A extends Attrs>(e: WMLElement, attrs: A): WMLElement;
41
- /**
42
- * node registers a Node.
43
- */
44
- node(tag: string, attrs: Attrs, children: Content[]): Content;
45
- /**
46
- * widget registers a Widget.
47
- */
48
- widget(w: Widget, attrs: Attrs): Content;
49
- }
50
26
  /**
51
27
  * Renderable is an interface implemented by objects in a WML tree that can
52
28
  * produce [[Content]] objects.
@@ -57,56 +33,13 @@ export interface Registry {
57
33
  export interface Renderable {
58
34
  render(): Content;
59
35
  }
60
- /**
61
- * View instances are compiled from wml template files.
62
- *
63
- * They provide an api for rendering user interfaces and
64
- * querying individual objects(WMLElement) it is made of.
65
- */
66
- export interface View extends Renderable {
67
- /**
68
- * invalidate this View causing the DOM to be re-rendered.
69
- *
70
- * Re-rendering is done by finding the parentNode of the root
71
- * of the View's Content and replacing it with a new version.
72
- * If the view has not yet been added to the DOM, this will fail.
73
- */
74
- invalidate(): void;
75
- /**
76
- * findById retrives a WMLElement that has been assigned a `wml:id`
77
- * attribute matching id.
78
- */
79
- findById<E extends WMLElement>(id: string): Maybe<E>;
80
- /**
81
- * findGroupById retrives an array of WMLElements that have a `wml:group`
82
- * attribute matching name.
83
- */
84
- findGroupById<E extends WMLElement>(name: string): E[];
85
- }
86
36
  /**
87
37
  * Widget is the user land api of custom Renderable objects
88
38
  * that provide desired functionality.
89
39
  *
90
40
  * It has two lifecycle methods that are recognized by View.
91
41
  */
92
- export interface Widget extends Renderable {
93
- /**
94
- * rendered is called after the Widget has been added to a DOM tree.
95
- */
96
- rendered(): void;
97
- /**
98
- * removed is only called after the View has been invalidated.
99
- *
100
- * That means it is NOT called if the Widget is removed from the DOM
101
- * in some other way.
102
- */
103
- removed(): void;
104
- }
105
- /**
106
- * ContentProvider is the type of the function fun statements return.
107
- */
108
- export interface ContentProvider {
109
- (view: View): Content;
42
+ export interface Widget extends Renderable, DOMEventCallbacks {
110
43
  }
111
44
  /**
112
45
  * Component is an abstract Widget implementation
@@ -151,21 +84,3 @@ export interface Attrs {
151
84
  ns?: string;
152
85
  };
153
86
  }
154
- /**
155
- * Ids is a map of WMLElements that have been given an id.
156
- */
157
- export interface Ids {
158
- [key: string]: WMLElement;
159
- }
160
- /**
161
- * Groups is a map of elements groupped together by the `wml:group` attributes.
162
- */
163
- export interface Groups {
164
- [key: string]: WMLElement[];
165
- }
166
- /**
167
- * renderAsNode content from a Renderable.
168
- *
169
- * This function unsafely assumes the Renderable always returns DOM content.
170
- */
171
- export declare const renderAsNode: (r: Renderable) => Node;
package/lib/index.js CHANGED
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderAsNode = exports.Component = void 0;
3
+ exports.Component = exports.BaseView = exports.ViewFrame = exports.Maybe = void 0;
4
+ const view_1 = require("./view");
5
+ Object.defineProperty(exports, "BaseView", { enumerable: true, get: function () { return view_1.BaseView; } });
6
+ var maybe_1 = require("@quenk/noni/lib/data/maybe");
7
+ Object.defineProperty(exports, "Maybe", { enumerable: true, get: function () { return maybe_1.Maybe; } });
8
+ var frame_1 = require("./view/frame");
9
+ Object.defineProperty(exports, "ViewFrame", { enumerable: true, get: function () { return frame_1.ViewFrame; } });
4
10
  /**
5
11
  * Component is an abstract Widget implementation
6
12
  * that can be used instead of manually implementing the whole interface.
@@ -16,15 +22,9 @@ class Component {
16
22
  }
17
23
  rendered() { }
18
24
  removed() { }
19
- render() { return this.view.render(); }
25
+ render() {
26
+ return this.view.render();
27
+ }
20
28
  }
21
29
  exports.Component = Component;
22
- ;
23
- /**
24
- * renderAsNode content from a Renderable.
25
- *
26
- * This function unsafely assumes the Renderable always returns DOM content.
27
- */
28
- const renderAsNode = (r) => r.render();
29
- exports.renderAsNode = renderAsNode;
30
30
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AA4JA;;;GAGG;AACH,MAAsB,SAAS;IAS3B;;;OAGG;IACH,YAAmB,KAAQ,EAAS,QAAmB;QAApC,UAAK,GAAL,KAAK,CAAG;QAAS,aAAQ,GAAR,QAAQ,CAAW;IAAI,CAAC;IAE5D,QAAQ,KAAW,CAAC;IAEpB,OAAO,KAAW,CAAC;IAEnB,MAAM,KAAc,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;CAEnD;AArBD,8BAqBC;AAAA,CAAC;AAmDF;;;;GAIG;AACI,MAAM,YAAY,GAAG,CAAC,CAAa,EAAQ,EAAE,CAC1C,CAAC,CAAC,MAAM,EAAE,CAAC;AADR,QAAA,YAAY,gBACJ"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AACA,iCAAwC;AAIzB,yFAJA,eAAQ,OAIA;AAFvB,oDAAmD;AAA1C,8FAAA,KAAK,OAAA;AACd,sCAAyC;AAAhC,kGAAA,SAAS,OAAA;AAwDlB;;;GAGG;AACH,MAAsB,SAAS;IAQ7B;;;OAGG;IACH,YACS,KAAQ,EACR,QAAmB;QADnB,UAAK,GAAL,KAAK,CAAG;QACR,aAAQ,GAAR,QAAQ,CAAW;IACzB,CAAC;IAEJ,QAAQ,KAAU,CAAC;IAEnB,OAAO,KAAU,CAAC;IAElB,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF;AAxBD,8BAwBC"}
package/lib/index.ts CHANGED
@@ -1,125 +1,53 @@
1
- import { Maybe } from '@quenk/noni/lib/data/maybe';
1
+ import { DOMEventCallbacks } from "./dom/monitor";
2
+ import { View, BaseView } from "./view";
2
3
 
3
- export { Maybe }
4
+ export { Maybe } from "@quenk/noni/lib/data/maybe";
5
+ export { ViewFrame } from "./view/frame";
6
+ export { View, BaseView };
4
7
 
5
8
  /**
6
9
  * WidgetConstructor
7
10
  */
8
- export type WidgetConstructor<A extends Attrs>
9
- = new (attributes: A, children: Content[]) => Widget
10
- ;
11
+ export type WidgetConstructor<A extends Attrs> = new (
12
+ attributes: A,
13
+ children: Content[],
14
+ ) => Widget;
11
15
 
12
16
  /**
13
- * WMLElement can be DOM content or a user defined widget.
17
+ * WMLElement can be DOM content or a user defined widget.
14
18
  */
15
- export type WMLElement
16
- = Content
17
- | Widget
18
- ;
19
+ export type WMLElement = Content | Widget;
19
20
 
20
21
  /**
21
- * Content is what is actually intended to be rendered on a web page.
22
- */
23
- export type Content
24
- = Node
25
- | Element
26
- | HTMLElement
27
- ;
28
-
29
- /**
30
- * HTMLAttributeValue
31
- */
32
- export type HTMLAttributeValue
33
- = string
34
- | number
35
- | boolean
36
- | null
37
- | undefined
38
- | Function
39
- ;
40
-
41
- /**
42
- * Template is a function that given a View (Registry)
43
- * will provide DOM content as well as performing
44
- * the side-effects of adding ids etc.
22
+ * WMLId is a string used to identify a WML element or group within a view.
45
23
  */
46
- export type Template = (r: Registry) => Content;
24
+ export type WMLId = string;
47
25
 
48
26
  /**
49
- * Fun corresponds to the compiled signature of fun statements.
27
+ * Content is what is actually intended to be rendered on a web page.
50
28
  */
51
- export type Fun = (r: Registry) => Content[];
29
+ export type Content = Node | Element | HTMLElement;
52
30
 
53
31
  /**
54
- * Registry keeps track of the WMLElements in a view.
32
+ * HTMLAttributeValue
55
33
  */
56
- export interface Registry {
57
-
58
- /**
59
- * registerView
60
- */
61
- registerView(v: View): View;
62
-
63
- /**
64
- * register an element.
65
- */
66
- register<A extends Attrs>(e: WMLElement, attrs: A): WMLElement
67
-
68
- /**
69
- * node registers a Node.
70
- */
71
- node(tag: string, attrs: Attrs, children: Content[])
72
- : Content
73
-
74
- /**
75
- * widget registers a Widget.
76
- */
77
- widget(w: Widget, attrs: Attrs): Content
78
-
79
- }
34
+ export type HTMLAttributeValue =
35
+ | string
36
+ | number
37
+ | boolean
38
+ | null
39
+ | undefined
40
+ | Function;
80
41
 
81
42
  /**
82
- * Renderable is an interface implemented by objects in a WML tree that can
43
+ * Renderable is an interface implemented by objects in a WML tree that can
83
44
  * produce [[Content]] objects.
84
45
  *
85
- * This interface exists separate from the View interface for use in places
46
+ * This interface exists separate from the View interface for use in places
86
47
  * where only the render() method is desired.
87
48
  */
88
49
  export interface Renderable {
89
-
90
- render(): Content
91
-
92
- }
93
-
94
- /**
95
- * View instances are compiled from wml template files.
96
- *
97
- * They provide an api for rendering user interfaces and
98
- * querying individual objects(WMLElement) it is made of.
99
- */
100
- export interface View extends Renderable {
101
-
102
- /**
103
- * invalidate this View causing the DOM to be re-rendered.
104
- *
105
- * Re-rendering is done by finding the parentNode of the root
106
- * of the View's Content and replacing it with a new version.
107
- * If the view has not yet been added to the DOM, this will fail.
108
- */
109
- invalidate(): void;
110
-
111
- /**
112
- * findById retrives a WMLElement that has been assigned a `wml:id`
113
- * attribute matching id.
114
- */
115
- findById<E extends WMLElement>(id: string): Maybe<E>;
116
-
117
- /**
118
- * findGroupById retrives an array of WMLElements that have a `wml:group`
119
- * attribute matching name.
120
- */
121
- findGroupById<E extends WMLElement>(name: string): E[];
122
-
50
+ render(): Content;
123
51
  }
124
52
 
125
53
  /**
@@ -128,67 +56,44 @@ export interface View extends Renderable {
128
56
  *
129
57
  * It has two lifecycle methods that are recognized by View.
130
58
  */
131
- export interface Widget extends Renderable {
132
-
133
- /**
134
- * rendered is called after the Widget has been added to a DOM tree.
135
- */
136
- rendered(): void;
137
-
138
- /**
139
- * removed is only called after the View has been invalidated.
140
- *
141
- * That means it is NOT called if the Widget is removed from the DOM
142
- * in some other way.
143
- */
144
- removed(): void;
145
-
146
- }
147
-
148
- /**
149
- * ContentProvider is the type of the function fun statements return.
150
- */
151
- export interface ContentProvider {
152
-
153
- (view: View): Content
154
-
155
- }
59
+ export interface Widget extends Renderable, DOMEventCallbacks {}
156
60
 
157
61
  /**
158
62
  * Component is an abstract Widget implementation
159
63
  * that can be used instead of manually implementing the whole interface.
160
64
  */
161
65
  export abstract class Component<A extends Attrs> implements Widget {
162
-
163
- /**
164
- * view for this Component.
165
- *
166
- * The render method by default returns the render result of this View.
167
- */
168
- abstract view: View;
169
-
170
- /**
171
- * @param {A} attrs is the attributes this Component excepts.
172
- * @param {Content[]} children is an array of content for Component.
173
- */
174
- constructor(public attrs: A, public children: Content[]) { }
175
-
176
- rendered(): void { }
177
-
178
- removed(): void { }
179
-
180
- render(): Content { return this.view.render(); }
181
-
182
- };
66
+ /**
67
+ * view for this Component.
68
+ *
69
+ * The render method by default returns the render result of this View.
70
+ */
71
+ abstract view: View;
72
+
73
+ /**
74
+ * @param {A} attrs is the attributes this Component excepts.
75
+ * @param {Content[]} children is an array of content for Component.
76
+ */
77
+ constructor(
78
+ public attrs: A,
79
+ public children: Content[],
80
+ ) {}
81
+
82
+ rendered(): void {}
83
+
84
+ removed(): void {}
85
+
86
+ render(): Content {
87
+ return this.view.render();
88
+ }
89
+ }
183
90
 
184
91
  /**
185
92
  * Attributes is a map of values suitable for attributes on
186
93
  * a DOM Node.
187
94
  */
188
95
  export interface Attributes<V> {
189
-
190
- [key: string]: V
191
-
96
+ [key: string]: V;
192
97
  }
193
98
 
194
99
  /**
@@ -199,41 +104,11 @@ export interface Attributes<V> {
199
104
  * can be passed in a type safe way.
200
105
  */
201
106
  export interface Attrs {
107
+ wml?: {
108
+ id?: string;
202
109
 
203
- wml?: {
204
-
205
- id?: string,
206
-
207
- group?: string,
208
-
209
- ns?: string
210
-
211
- }
110
+ group?: string;
212
111
 
112
+ ns?: string;
113
+ };
213
114
  }
214
-
215
- /**
216
- * Ids is a map of WMLElements that have been given an id.
217
- */
218
- export interface Ids {
219
-
220
- [key: string]: WMLElement
221
-
222
- }
223
-
224
- /**
225
- * Groups is a map of elements groupped together by the `wml:group` attributes.
226
- */
227
- export interface Groups {
228
-
229
- [key: string]: WMLElement[]
230
-
231
- }
232
-
233
- /**
234
- * renderAsNode content from a Renderable.
235
- *
236
- * This function unsafely assumes the Renderable always returns DOM content.
237
- */
238
- export const renderAsNode = (r: Renderable): Node =>
239
- <Node>r.render();
package/lib/main.js CHANGED
@@ -20,18 +20,18 @@ Options:
20
20
  --dom path The module to resolve the DOM functions from.
21
21
  --version Show version.
22
22
  `, {
23
- version: require('../package.json').version
23
+ version: require("../package.json").version,
24
24
  });
25
25
  const defaultOptions = {
26
26
  debug: false,
27
- main: 'Main',
28
- module: '@quenk/wml',
29
- dom: '@quenk/wml/lib/dom',
30
- inputExtension: 'wml',
31
- outputExtension: 'ts'
27
+ main: "Main",
28
+ module: "@quenk/wml",
29
+ dom: "@quenk/wml/lib/dom",
30
+ inputExtension: "wml",
31
+ outputExtension: "ts",
32
32
  };
33
33
  const main = (cwd, args) => (0, future_1.doFuture)(function* () {
34
- let path = (0, path_1.resolve)(cwd, args['<path>']);
34
+ let path = (0, path_1.resolve)(cwd, args["<path>"]);
35
35
  let opts = (0, record_1.merge)(defaultOptions, getOptions(args));
36
36
  let result = yield (0, file_1.isDirectory)(path);
37
37
  yield result ? (0, cli_1.compileDir)(path, opts) : (0, cli_1.compileFile)(path, opts);
@@ -39,16 +39,16 @@ const main = (cwd, args) => (0, future_1.doFuture)(function* () {
39
39
  });
40
40
  const getOptions = (args) => {
41
41
  let o = {};
42
- if (args['--main'] != null)
43
- o.main = args['--main'];
44
- if (args['--outputExtension'] != null)
45
- o.outputExtension = args['--outputExtension'];
46
- if (args['--inputExtension'] != null)
47
- o.inputExtension = args['--inputExtension'];
48
- if (args['--module'] != null)
49
- o.module = args['--module'];
50
- if (args['--dom'] != null)
51
- o.dom = args['--dom'];
42
+ if (args["--main"] != null)
43
+ o.main = args["--main"];
44
+ if (args["--outputExtension"] != null)
45
+ o.outputExtension = args["--outputExtension"];
46
+ if (args["--inputExtension"] != null)
47
+ o.inputExtension = args["--inputExtension"];
48
+ if (args["--module"] != null)
49
+ o.module = args["--module"];
50
+ if (args["--dom"] != null)
51
+ o.dom = args["--dom"];
52
52
  return o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AAC,UAAU,CAAC,IAAI,IAAI;QAAE,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;IAE1D,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI;QAAE,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAEjD,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,CAAQ,EAAE,EAAE;IACzB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAErC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC"}
package/lib/main.ts CHANGED
@@ -1,16 +1,17 @@
1
1
  #! /usr/bin/env node
2
2
 
3
- import * as docopt from 'docopt';
3
+ import * as docopt from "docopt";
4
4
 
5
- import { resolve } from 'path';
5
+ import { resolve } from "path";
6
6
 
7
- import { merge } from '@quenk/noni/lib/data/record';
8
- import { isDirectory } from '@quenk/noni/lib/io/file';
7
+ import { merge } from "@quenk/noni/lib/data/record";
8
+ import { isDirectory } from "@quenk/noni/lib/io/file";
9
9
 
10
- import { CLIOptions, Arguments, compileDir, compileFile } from './cli';
11
- import { doFuture, voidPure } from '@quenk/noni/lib/control/monad/future';
10
+ import { CLIOptions, Arguments, compileDir, compileFile } from "./cli";
11
+ import { doFuture, voidPure } from "@quenk/noni/lib/control/monad/future";
12
12
 
13
- const args = docopt.docopt(`
13
+ const args = docopt.docopt(
14
+ `
14
15
 
15
16
  Usage:
16
17
  wml [options] <path>
@@ -22,60 +23,53 @@ Options:
22
23
  --module path The module name or path to get wml symbols from.
23
24
  --dom path The module to resolve the DOM functions from.
24
25
  --version Show version.
25
- `, {
26
- version: require('../package.json').version
27
- });
26
+ `,
27
+ {
28
+ version: require("../package.json").version,
29
+ },
30
+ );
28
31
 
29
32
  const defaultOptions: CLIOptions = {
30
- debug: false,
31
- main: 'Main',
32
- module: '@quenk/wml',
33
- dom: '@quenk/wml/lib/dom',
34
- inputExtension: 'wml',
35
- outputExtension: 'ts'
36
- }
37
-
38
-
39
- const main = (cwd: string, args: Arguments) => doFuture<any>(function*() {
40
-
41
- let path = resolve(cwd, <string>args['<path>']);
33
+ debug: false,
34
+ main: "Main",
35
+ module: "@quenk/wml",
36
+ dom: "@quenk/wml/lib/dom",
37
+ inputExtension: "wml",
38
+ outputExtension: "ts",
39
+ };
40
+
41
+ const main = (cwd: string, args: Arguments) =>
42
+ doFuture<any>(function* () {
43
+ let path = resolve(cwd, <string>args["<path>"]);
42
44
  let opts = merge(defaultOptions, getOptions(args));
43
45
  let result = yield isDirectory(path);
44
46
 
45
47
  yield result ? compileDir(path, opts) : compileFile(path, opts);
46
48
  return voidPure;
47
-
48
- });
49
+ });
49
50
 
50
51
  const getOptions = (args: Arguments): Partial<CLIOptions> => {
52
+ let o: Partial<CLIOptions> = {};
51
53
 
52
- let o: Partial<CLIOptions> = {};
54
+ if (args["--main"] != null) o.main = args["--main"];
53
55
 
54
- if (args['--main'] != null)
55
- o.main = args['--main'];
56
+ if (args["--outputExtension"] != null)
57
+ o.outputExtension = args["--outputExtension"];
56
58
 
57
- if (args['--outputExtension'] != null)
58
- o.outputExtension = args['--outputExtension'];
59
+ if (args["--inputExtension"] != null)
60
+ o.inputExtension = args["--inputExtension"];
59
61
 
60
- if (args['--inputExtension'] != null)
61
- o.inputExtension = args['--inputExtension'];
62
+ if (args["--module"] != null) o.module = args["--module"];
62
63
 
63
- if (args['--module'] != null)
64
- o.module = args['--module'];
64
+ if (args["--dom"] != null) o.dom = args["--dom"];
65
65
 
66
- if (args['--dom'] != null)
67
- o.dom = args['--dom'];
68
-
69
- return o;
70
-
71
- }
66
+ return o;
67
+ };
72
68
 
73
69
  const onErr = (e: Error) => {
74
-
75
- console.error(e.stack ? e.stack : e);
76
- return process.exit(255);
77
-
78
- }
70
+ console.error(e.stack ? e.stack : e);
71
+ return process.exit(255);
72
+ };
79
73
 
80
74
  const onDone = () => process.exit(0);
81
75
 
@@ -141,12 +141,12 @@ export declare class ContextFromStatement {
141
141
  export declare class ViewStatement {
142
142
  id: UnqualifiedConstructor;
143
143
  typeParameters: TypeParameter[];
144
- context: ContextTypeIndicator;
144
+ context: ContextTypeIndicator | undefined;
145
145
  directives: LetStatement[];
146
146
  root: Tag;
147
147
  location: Location;
148
148
  type: string;
149
- constructor(id: UnqualifiedConstructor, typeParameters: TypeParameter[], context: ContextTypeIndicator, directives: LetStatement[], root: Tag, location: Location);
149
+ constructor(id: UnqualifiedConstructor, typeParameters: TypeParameter[], context: ContextTypeIndicator | undefined, directives: LetStatement[], root: Tag, location: Location);
150
150
  }
151
151
  export declare class FunStatement {
152
152
  id: UnqualifiedIdentifier;