mancha 0.9.0 → 0.9.4
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/README.md +17 -45
- package/dist/browser.d.ts +6 -5
- package/dist/browser.js +9 -38
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -1
- package/dist/core.d.ts +6 -24
- package/dist/core.js +8 -44
- package/dist/css_gen_basic.d.ts +2 -1
- package/dist/css_gen_basic.js +20 -2
- package/dist/dome.d.ts +26 -24
- package/dist/dome.js +60 -69
- package/dist/index.d.ts +3 -1
- package/dist/index.js +8 -6
- package/dist/interfaces.d.ts +1 -2
- package/dist/mancha.d.ts +3 -0
- package/dist/mancha.js +88 -1
- package/dist/plugins.js +79 -117
- package/dist/safe_browser.d.ts +7 -0
- package/dist/safe_browser.js +19 -0
- package/dist/store.d.ts +7 -9
- package/dist/store.js +39 -19
- package/dist/test_utils.d.ts +2 -0
- package/dist/test_utils.js +14 -0
- package/dist/worker.d.ts +3 -1
- package/dist/worker.js +7 -0
- package/gulpfile.js +1 -1
- package/package.json +8 -9
- package/tsconfig.json +19 -13
- package/tsec_exemptions.json +4 -0
- package/webpack.config.js +6 -4
- package/dist/css_raw_basic.css +0 -1
- package/dist/gulp_plugin.d.ts +0 -15
- package/dist/gulp_plugin.js +0 -68
- package/yarn-error.log +0 -4103
package/dist/gulp_plugin.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import * as stream from "stream";
|
|
3
|
-
import * as through from "through2";
|
|
4
|
-
import { Renderer } from "./index.js";
|
|
5
|
-
/**
|
|
6
|
-
* Main entrypoint to be used in Gulp. Usage:
|
|
7
|
-
*
|
|
8
|
-
* var mancha = require('mancha/dist/gulp')
|
|
9
|
-
* gulp.src(...).pipe(mancha({myvar: myval})).pipe(...)
|
|
10
|
-
*
|
|
11
|
-
* @param context <key, value> pairs of literal string replacements. `key` will become `{{ key }}`
|
|
12
|
-
* before replacing it with `value` in the processed files.
|
|
13
|
-
*/
|
|
14
|
-
function mancha(context = {}) {
|
|
15
|
-
const renderer = new Renderer(context);
|
|
16
|
-
return through.obj(function (file, encoding, callback) {
|
|
17
|
-
const catcher = (err) => {
|
|
18
|
-
console.log(err);
|
|
19
|
-
callback(err, file);
|
|
20
|
-
};
|
|
21
|
-
const dirpath = path.dirname(file.path);
|
|
22
|
-
if (file.isNull()) {
|
|
23
|
-
callback(null, file);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
if (file.isBuffer()) {
|
|
27
|
-
const chunk = file.contents.toString(encoding);
|
|
28
|
-
renderer
|
|
29
|
-
.preprocessString(chunk, { dirpath, rootDocument: !file.path.endsWith(".tpl.html") })
|
|
30
|
-
.then(async (fragment) => {
|
|
31
|
-
await renderer.renderNode(fragment);
|
|
32
|
-
const content = renderer.serializeHTML(fragment);
|
|
33
|
-
file.contents = Buffer.from(content, encoding);
|
|
34
|
-
callback(null, file);
|
|
35
|
-
})
|
|
36
|
-
.catch(catcher);
|
|
37
|
-
}
|
|
38
|
-
else if (file.isStream()) {
|
|
39
|
-
let docstr = "";
|
|
40
|
-
file.contents
|
|
41
|
-
.on("data", (chunk) => {
|
|
42
|
-
if (Buffer.isBuffer(chunk)) {
|
|
43
|
-
docstr += chunk.toString(encoding);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
docstr += chunk.toString();
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
.on("end", () => {
|
|
50
|
-
renderer
|
|
51
|
-
.preprocessString(docstr, { dirpath, rootDocument: !file.path.endsWith(".tpl.html") })
|
|
52
|
-
.then(async (document) => {
|
|
53
|
-
await renderer.renderNode(document);
|
|
54
|
-
const content = renderer.serializeHTML(document);
|
|
55
|
-
const readable = new stream.Readable();
|
|
56
|
-
readable._read = function () { };
|
|
57
|
-
readable.push(content);
|
|
58
|
-
readable.push(null);
|
|
59
|
-
file.contents = readable;
|
|
60
|
-
callback(null, file);
|
|
61
|
-
})
|
|
62
|
-
.catch(catcher);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
export default mancha;
|