marko 5.21.1 → 5.21.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,32 +1,44 @@
|
|
1
1
|
"use strict";const BufferedWriter = require("../../runtime/html/BufferedWriter");
|
2
2
|
|
3
3
|
module.exports = function __flushHereAndAfter__(input, out) {
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
if (out.isSync()) {
|
5
|
+
// We create an async out that we pinky promise is going to be sync in order to postpone execution of the renderBody.
|
6
|
+
out._sync = false;
|
7
|
+
const asyncOut = out.beginAsync({ last: true });
|
8
|
+
out._sync = true;
|
9
|
+
asyncOut.sync();
|
10
|
+
out.onLast(() => {
|
11
|
+
input.renderBody(asyncOut);
|
12
|
+
asyncOut.end();
|
13
|
+
});
|
14
|
+
} else {
|
15
|
+
let flushed = false;
|
16
|
+
const asyncOut = out.beginAsync({ last: true });
|
17
|
+
const nextWriter = out.writer;
|
18
|
+
|
19
|
+
out.on("c_", (writer) => {
|
20
|
+
if (writer instanceof BufferedWriter) {
|
21
|
+
if (flushed) {
|
22
|
+
const detachedOut = out.createOut();
|
23
|
+
detachedOut.sync();
|
24
|
+
input.renderBody(detachedOut);
|
25
|
+
writer._content = detachedOut.toString() + writer._content;
|
26
|
+
} else if (writer.next === nextWriter) {
|
27
|
+
asyncOut.sync();
|
28
|
+
input.renderBody(asyncOut);
|
29
|
+
asyncOut.end();
|
30
|
+
flushed = true;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
});
|
7
34
|
|
8
|
-
|
9
|
-
|
10
|
-
if (flushed) {
|
11
|
-
const detachedOut = out.createOut();
|
12
|
-
detachedOut.sync();
|
13
|
-
input.renderBody(detachedOut);
|
14
|
-
writer._content = detachedOut.toString() + writer._content;
|
15
|
-
} else if (writer.next === nextWriter) {
|
35
|
+
out.onLast(() => {
|
36
|
+
if (!flushed) {
|
16
37
|
asyncOut.sync();
|
17
38
|
input.renderBody(asyncOut);
|
18
39
|
asyncOut.end();
|
19
40
|
flushed = true;
|
20
41
|
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
|
24
|
-
out.onLast(() => {
|
25
|
-
if (!flushed) {
|
26
|
-
asyncOut.sync();
|
27
|
-
input.renderBody(asyncOut);
|
28
|
-
asyncOut.end();
|
29
|
-
flushed = true;
|
30
|
-
}
|
31
|
-
});
|
42
|
+
});
|
43
|
+
}
|
32
44
|
};
|
package/package.json
CHANGED
@@ -1,32 +1,44 @@
|
|
1
1
|
const BufferedWriter = require("../../runtime/html/BufferedWriter");
|
2
2
|
|
3
3
|
module.exports = function __flushHereAndAfter__(input, out) {
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
if (out.isSync()) {
|
5
|
+
// We create an async out that we pinky promise is going to be sync in order to postpone execution of the renderBody.
|
6
|
+
out._sync = false;
|
7
|
+
const asyncOut = out.beginAsync({ last: true });
|
8
|
+
out._sync = true;
|
9
|
+
asyncOut.sync();
|
10
|
+
out.onLast(() => {
|
11
|
+
input.renderBody(asyncOut);
|
12
|
+
asyncOut.end();
|
13
|
+
});
|
14
|
+
} else {
|
15
|
+
let flushed = false;
|
16
|
+
const asyncOut = out.beginAsync({ last: true });
|
17
|
+
const nextWriter = out.writer;
|
18
|
+
|
19
|
+
out.on("___toString", writer => {
|
20
|
+
if (writer instanceof BufferedWriter) {
|
21
|
+
if (flushed) {
|
22
|
+
const detachedOut = out.createOut();
|
23
|
+
detachedOut.sync();
|
24
|
+
input.renderBody(detachedOut);
|
25
|
+
writer._content = detachedOut.toString() + writer._content;
|
26
|
+
} else if (writer.next === nextWriter) {
|
27
|
+
asyncOut.sync();
|
28
|
+
input.renderBody(asyncOut);
|
29
|
+
asyncOut.end();
|
30
|
+
flushed = true;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
});
|
7
34
|
|
8
|
-
|
9
|
-
|
10
|
-
if (flushed) {
|
11
|
-
const detachedOut = out.createOut();
|
12
|
-
detachedOut.sync();
|
13
|
-
input.renderBody(detachedOut);
|
14
|
-
writer._content = detachedOut.toString() + writer._content;
|
15
|
-
} else if (writer.next === nextWriter) {
|
35
|
+
out.onLast(() => {
|
36
|
+
if (!flushed) {
|
16
37
|
asyncOut.sync();
|
17
38
|
input.renderBody(asyncOut);
|
18
39
|
asyncOut.end();
|
19
40
|
flushed = true;
|
20
41
|
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
|
24
|
-
out.onLast(() => {
|
25
|
-
if (!flushed) {
|
26
|
-
asyncOut.sync();
|
27
|
-
input.renderBody(asyncOut);
|
28
|
-
asyncOut.end();
|
29
|
-
flushed = true;
|
30
|
-
}
|
31
|
-
});
|
42
|
+
});
|
43
|
+
}
|
32
44
|
};
|