@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.
- 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 +164 -369
- package/lib/compile/codegen.js.map +1 -1
- package/lib/compile/codegen.ts +644 -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 +8 -6
- package/lib/compile/transform.js +46 -18
- package/lib/compile/transform.js.map +1 -1
- package/lib/compile/transform.ts +139 -116
- package/lib/{dom.d.ts → dom/index.d.ts} +8 -2
- package/lib/{dom.js → dom/index.js} +84 -66
- 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 +12 -6
- package/lib/parse/ast.js +68 -58
- package/lib/parse/ast.js.map +1 -1
- package/lib/parse/ast.ts +400 -482
- 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 +103 -0
- package/lib/view/frame.js +206 -0
- package/lib/view/frame.js.map +1 -0
- package/lib/view/frame.ts +249 -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 +97 -0
- package/package.json +4 -3
- package/lib/dom.js.map +0 -1
- package/lib/dom.ts +0 -475
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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.
|
|
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() {
|
|
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":";;;
|
|
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 {
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
|
24
|
+
export type WMLId = string;
|
|
47
25
|
|
|
48
26
|
/**
|
|
49
|
-
*
|
|
27
|
+
* Content is what is actually intended to be rendered on a web page.
|
|
50
28
|
*/
|
|
51
|
-
export type
|
|
29
|
+
export type Content = Node | Element | HTMLElement;
|
|
52
30
|
|
|
53
31
|
/**
|
|
54
|
-
*
|
|
32
|
+
* HTMLAttributeValue
|
|
55
33
|
*/
|
|
56
|
-
export
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
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(
|
|
23
|
+
version: require("../package.json").version,
|
|
24
24
|
});
|
|
25
25
|
const defaultOptions = {
|
|
26
26
|
debug: false,
|
|
27
|
-
main:
|
|
28
|
-
module:
|
|
29
|
-
dom:
|
|
30
|
-
inputExtension:
|
|
31
|
-
outputExtension:
|
|
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[
|
|
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[
|
|
43
|
-
o.main = args[
|
|
44
|
-
if (args[
|
|
45
|
-
o.outputExtension = args[
|
|
46
|
-
if (args[
|
|
47
|
-
o.inputExtension = args[
|
|
48
|
-
if (args[
|
|
49
|
-
o.module = args[
|
|
50
|
-
if (args[
|
|
51
|
-
o.dom = args[
|
|
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;
|
|
53
53
|
};
|
|
54
54
|
const onErr = (e) => {
|
package/lib/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":";;;AAEA,iCAAiC;AAEjC,+BAA+B;AAE/B,wDAAoD;AACpD,kDAAsD;AAEtD,+BAAuE;AACvE,iEAA0E;AAE1E,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":";;;AAEA,iCAAiC;AAEjC,+BAA+B;AAE/B,wDAAoD;AACpD,kDAAsD;AAEtD,+BAAuE;AACvE,iEAA0E;AAE1E,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CACxB;;;;;;;;;;;;CAYD,EACC;IACE,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO;CAC5C,CACF,CAAC;AAEF,MAAM,cAAc,GAAe;IACjC,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,YAAY;IACpB,GAAG,EAAE,oBAAoB;IACzB,cAAc,EAAE,KAAK;IACrB,eAAe,EAAE,IAAI;CACtB,CAAC;AAEF,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,IAAe,EAAE,EAAE,CAC5C,IAAA,iBAAQ,EAAM,QAAQ,CAAC;IACrB,IAAI,IAAI,GAAG,IAAA,cAAO,EAAC,GAAG,EAAU,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChD,IAAI,IAAI,GAAG,IAAA,cAAK,EAAC,cAAc,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,IAAI,MAAM,GAAG,MAAM,IAAA,kBAAW,EAAC,IAAI,CAAC,CAAC;IAErC,MAAM,MAAM,CAAC,CAAC,CAAC,IAAA,gBAAU,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAW,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAChE,OAAO,iBAAQ,CAAC;AAClB,CAAC,CAAC,CAAC;AAEL,MAAM,UAAU,GAAG,CAAC,IAAe,EAAuB,EAAE;IAC1D,IAAI,CAAC,GAAwB,EAAE,CAAC;IAEhC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI;QAAE,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEpD,IAAI,IAAI,CAAC,mBAAmB,CAAC,IAAI,IAAI;QACnC,CAAC,CAAC,eAAe,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAEhD,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,IAAI;QAClC,CAAC,CAAC,cAAc,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAE9C,IAAI,IAAI,CAAC,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
|
|
3
|
+
import * as docopt from "docopt";
|
|
4
4
|
|
|
5
|
-
import { resolve } from
|
|
5
|
+
import { resolve } from "path";
|
|
6
6
|
|
|
7
|
-
import { merge } from
|
|
8
|
-
import { isDirectory } from
|
|
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
|
|
11
|
-
import { doFuture, voidPure } from
|
|
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
|
-
|
|
27
|
-
|
|
26
|
+
`,
|
|
27
|
+
{
|
|
28
|
+
version: require("../package.json").version,
|
|
29
|
+
},
|
|
30
|
+
);
|
|
28
31
|
|
|
29
32
|
const defaultOptions: CLIOptions = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
54
|
+
if (args["--main"] != null) o.main = args["--main"];
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
if (args["--outputExtension"] != null)
|
|
57
|
+
o.outputExtension = args["--outputExtension"];
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
if (args["--inputExtension"] != null)
|
|
60
|
+
o.inputExtension = args["--inputExtension"];
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
o.inputExtension = args['--inputExtension'];
|
|
62
|
+
if (args["--module"] != null) o.module = args["--module"];
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
o.module = args['--module'];
|
|
64
|
+
if (args["--dom"] != null) o.dom = args["--dom"];
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return o;
|
|
70
|
-
|
|
71
|
-
}
|
|
66
|
+
return o;
|
|
67
|
+
};
|
|
72
68
|
|
|
73
69
|
const onErr = (e: Error) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|