@quenk/wml 2.11.2 → 2.12.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.js +24 -29
- package/lib/cli.js.map +1 -1
- package/lib/cli.ts +20 -13
- package/lib/compile/codegen.d.ts +6 -10
- package/lib/compile/codegen.js +556 -633
- package/lib/compile/codegen.js.map +1 -1
- package/lib/compile/codegen.ts +58 -25
- package/lib/compile/index.js +6 -11
- package/lib/compile/index.js.map +1 -1
- package/lib/compile/transform.js +19 -25
- package/lib/compile/transform.js.map +1 -1
- package/lib/compile/transform.ts +12 -6
- package/lib/dom.js +118 -167
- package/lib/dom.js.map +1 -1
- package/lib/index.js +7 -10
- package/lib/index.js.map +1 -1
- package/lib/main.js +31 -56
- package/lib/main.js.map +1 -1
- package/lib/parse/ast.d.ts +25 -5
- package/lib/parse/ast.js +186 -214
- package/lib/parse/ast.js.map +1 -1
- package/lib/parse/ast.ts +33 -5
- package/lib/parse/generated.js +2527 -2454
- package/lib/parse/index.js +7 -10
- package/lib/parse/index.js.map +1 -1
- package/lib/parse/test.js +279 -53
- package/lib/parse/test.js.map +1 -1
- package/lib/parse/test.ts +20 -1
- package/lib/parse/wml.y +60 -50
- package/lib/tsconfig.json +1 -1
- package/package.json +1 -2
package/lib/cli.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compileFile = exports.compileDir = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const future_1 = require("@quenk/noni/lib/control/monad/future");
|
|
6
|
+
const file_1 = require("@quenk/noni/lib/io/file");
|
|
7
|
+
const compile_1 = require("./compile");
|
|
8
8
|
/**
|
|
9
9
|
* compileDir will compile each wml file found in the specified path.
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.map(function (p) { return (0, exports.compileFile)(p, opts); });
|
|
17
|
-
})
|
|
18
|
-
.chain(future_1.parallel);
|
|
19
|
-
};
|
|
11
|
+
const compileDir = (path, opts) => (0, file_1.listFilesRec)(path)
|
|
12
|
+
.map(list => list
|
|
13
|
+
.map(p => (0, path_1.resolve)(path, p))
|
|
14
|
+
.map(p => (0, exports.compileFile)(p, opts)))
|
|
15
|
+
.chain(future_1.parallel);
|
|
20
16
|
exports.compileDir = compileDir;
|
|
21
17
|
/**
|
|
22
18
|
* compileFile will compile a single wml file.
|
|
@@ -24,25 +20,24 @@ exports.compileDir = compileDir;
|
|
|
24
20
|
* If that file does not have the specified inputExtension, it will be
|
|
25
21
|
* ignored.
|
|
26
22
|
*/
|
|
27
|
-
|
|
28
|
-
if ((0, path_1.extname)(path) !==
|
|
23
|
+
const compileFile = (path, opts) => (0, future_1.doFuture)(function* () {
|
|
24
|
+
if ((0, path_1.extname)(path) !== `.${opts.inputExtension}`) {
|
|
29
25
|
return (0, future_1.pure)(undefined);
|
|
30
26
|
}
|
|
31
27
|
else {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
let p = `${getFileName(path)}.${opts.outputExtension}`;
|
|
29
|
+
let buf = yield (0, file_1.readTextFile)(path);
|
|
30
|
+
let eitherTs = (0, compile_1.compile)(buf, opts);
|
|
31
|
+
if (eitherTs.isLeft()) {
|
|
32
|
+
let msg = eitherTs.takeLeft().message;
|
|
33
|
+
return (0, future_1.raise)(new Error(`Error occurred while compiling "${path}":\n ${msg}`));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
yield (0, file_1.writeTextFile)(p, eitherTs.takeRight());
|
|
37
|
+
}
|
|
38
|
+
return future_1.voidPure;
|
|
42
39
|
}
|
|
43
|
-
};
|
|
40
|
+
});
|
|
44
41
|
exports.compileFile = compileFile;
|
|
45
|
-
|
|
46
|
-
return "".concat((0, path_1.dirname)(file), "/").concat((0, path_1.basename)(file, (0, path_1.extname)(file)));
|
|
47
|
-
};
|
|
42
|
+
const getFileName = (file) => `${(0, path_1.dirname)(file)}/${(0, path_1.basename)(file, (0, path_1.extname)(file))}`;
|
|
48
43
|
//# sourceMappingURL=cli.js.map
|
package/lib/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["cli.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["cli.ts"],"names":[],"mappings":";;;AAAA,+BAA2D;AAE3D,iEAO8C;AAC9C,kDAIiC;AAEjC,uCAA6C;AAuC7C;;GAEG;AACI,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,IAAgB,EAAE,EAAE,CACzD,IAAA,mBAAY,EAAC,IAAI,CAAC;KACb,GAAG,CAAC,IAAI,CAAC,EAAE,CACR,IAAI;KACC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,cAAO,EAAC,IAAI,EAAE,CAAC,CAAC,CAAC;KAC1B,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,mBAAW,EAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;KACvC,KAAK,CAAC,iBAAQ,CAAC,CAAC;AANZ,QAAA,UAAU,cAME;AAEzB;;;;;GAKG;AACI,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,IAAgB,EAAiB,EAAE,CAC3E,IAAA,iBAAQ,EAAC,QAAQ,CAAC;IAEhB,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE;QAE7C,OAAO,IAAA,aAAI,EAAO,SAAS,CAAC,CAAC;KAEhC;SAAM;QAEH,IAAI,CAAC,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;QAEvD,IAAI,GAAG,GAAG,MAAM,IAAA,mBAAY,EAAC,IAAI,CAAC,CAAC;QAEnC,IAAI,QAAQ,GAAG,IAAA,iBAAO,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAEpC,IAAG,QAAQ,CAAC,MAAM,EAAE,EAAE;YAEpB,IAAI,GAAG,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC;YAEtC,OAAO,IAAA,cAAK,EAAC,IAAI,KAAK,CACpB,mCAAmC,IAAI,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC;SAE1D;aAAM;YAED,MAAM,IAAA,oBAAa,EAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;SACpD;QAEC,OAAO,iBAAQ,CAAC;KAEjB;AACL,CAAC,CAAC,CAAC;AA9BU,QAAA,WAAW,eA8BrB;AAEH,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,EAAE,CACjC,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,IAAI,IAAA,eAAQ,EAAC,IAAI,EAAE,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC,EAAE,CAAC"}
|
package/lib/cli.ts
CHANGED
|
@@ -4,7 +4,9 @@ import {
|
|
|
4
4
|
Future,
|
|
5
5
|
pure,
|
|
6
6
|
raise,
|
|
7
|
-
parallel
|
|
7
|
+
parallel,
|
|
8
|
+
doFuture,
|
|
9
|
+
voidPure
|
|
8
10
|
} from '@quenk/noni/lib/control/monad/future';
|
|
9
11
|
import {
|
|
10
12
|
listFilesRec,
|
|
@@ -68,8 +70,8 @@ export const compileDir = (path: string, opts: CLIOptions) =>
|
|
|
68
70
|
* If that file does not have the specified inputExtension, it will be
|
|
69
71
|
* ignored.
|
|
70
72
|
*/
|
|
71
|
-
export const compileFile = (path: string, opts: CLIOptions)
|
|
72
|
-
|
|
73
|
+
export const compileFile = (path: string, opts: CLIOptions) : Future<void> =>
|
|
74
|
+
doFuture(function*() {
|
|
73
75
|
|
|
74
76
|
if (extname(path) !== `.${opts.inputExtension}`) {
|
|
75
77
|
|
|
@@ -79,21 +81,26 @@ export const compileFile = (path: string, opts: CLIOptions)
|
|
|
79
81
|
|
|
80
82
|
let p = `${getFileName(path)}.${opts.outputExtension}`;
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
.chain(buf => {
|
|
84
|
+
let buf = yield readTextFile(path);
|
|
84
85
|
|
|
85
|
-
|
|
86
|
+
let eitherTs = compile(buf, opts);
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
return raise<string>(eitherTs.takeLeft());
|
|
89
|
-
else
|
|
90
|
-
return pure(eitherTs.takeRight());
|
|
88
|
+
if(eitherTs.isLeft()) {
|
|
91
89
|
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
let msg = eitherTs.takeLeft().message;
|
|
91
|
+
|
|
92
|
+
return raise(new Error(
|
|
93
|
+
`Error occurred while compiling "${path}":\n ${msg}`));
|
|
94
|
+
|
|
95
|
+
} else {
|
|
96
|
+
|
|
97
|
+
yield writeTextFile(p, eitherTs.takeRight());
|
|
94
98
|
}
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
return voidPure;
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
});
|
|
97
104
|
|
|
98
105
|
const getFileName = (file: string) =>
|
|
99
106
|
`${dirname(file)}/${basename(file, extname(file))}`;
|
package/lib/compile/codegen.d.ts
CHANGED
|
@@ -244,15 +244,7 @@ export declare const attributeName2TS: (_: CodeGenerator, n: ast.Attribute) => s
|
|
|
244
244
|
/**
|
|
245
245
|
* attrs2String
|
|
246
246
|
*/
|
|
247
|
-
export declare const attrs2String: (attrs:
|
|
248
|
-
[key: string]: string | string[];
|
|
249
|
-
}) => string;
|
|
250
|
-
/**
|
|
251
|
-
* groupAttrs
|
|
252
|
-
*/
|
|
253
|
-
export declare const groupAttrs: (ctx: CodeGenerator, attrs: ast.Attribute[]) => {
|
|
254
|
-
[key: string]: string | string[];
|
|
255
|
-
};
|
|
247
|
+
export declare const attrs2String: (ctx: CodeGenerator, attrs: ast.Attribute[]) => string;
|
|
256
248
|
/**
|
|
257
249
|
* interpolation2TS
|
|
258
250
|
*/
|
|
@@ -268,7 +260,11 @@ export declare const forInStatement2TS: (ctx: CodeGenerator, n: ast.ForInStateme
|
|
|
268
260
|
/**
|
|
269
261
|
* forOfStatement2TS
|
|
270
262
|
*/
|
|
271
|
-
export declare const forOfStatement2TS: (ctx: CodeGenerator, n: ast.
|
|
263
|
+
export declare const forOfStatement2TS: (ctx: CodeGenerator, n: ast.ForOfStatement) => string;
|
|
264
|
+
/**
|
|
265
|
+
* forFromStatement2TS
|
|
266
|
+
*/
|
|
267
|
+
export declare const forFromStatement2TS: (ctx: CodeGenerator, node: ast.ForFromStatement) => string;
|
|
272
268
|
/**
|
|
273
269
|
* characters2TS converts character text to a typescript string.
|
|
274
270
|
*/
|