marko 5.34.2 → 5.34.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.
@@ -106,6 +106,7 @@ module.exports = function awaitTag(input, out) {
106
106
  };
107
107
 
108
108
  if (clientReorder) {
109
+ awaitInfo.parent = out;
109
110
  awaitInfo.after = input.showAfter;
110
111
 
111
112
  clientReorderContext =
@@ -50,9 +50,27 @@ module.exports = function (input, out) {
50
50
  }
51
51
 
52
52
  function handleAwait(awaitInfo) {
53
+ let flushedScript = false;
54
+ let flushedContent = false;
55
+ let flushedPlaceholder = false;
56
+ awaitInfo.parent.on("c_", () => {
57
+ flushedPlaceholder = true;
58
+ if (!flushedScript && flushedContent) {
59
+ flushedScript = true;
60
+ asyncOut.script(
61
+ `$${reorderFunctionId}(` + (
62
+ typeof awaitInfo.id === "number" ?
63
+ awaitInfo.id :
64
+ '"' + awaitInfo.id + '"') + (
65
+ awaitInfo.after ? ',"' + awaitInfo.after + '"' : "") +
66
+ ")"
67
+ );
68
+ }
69
+ });
53
70
  awaitInfo.out.
54
71
  on("c_", out.emit.bind(out, "c_")).
55
72
  on("finish", function (result) {
73
+ flushedContent = true;
56
74
  if (!global._afRuntime) {
57
75
  // Minified version of ./client-reorder-runtime.js
58
76
  asyncOut.script(
@@ -86,14 +104,17 @@ module.exports = function (input, out) {
86
104
  );
87
105
  }
88
106
 
89
- asyncOut.script(
90
- `$${reorderFunctionId}(` + (
91
- typeof awaitInfo.id === "number" ?
92
- awaitInfo.id :
93
- '"' + awaitInfo.id + '"') + (
94
- awaitInfo.after ? ',"' + awaitInfo.after + '"' : "") +
95
- ")"
96
- );
107
+ if (!flushedScript && flushedPlaceholder) {
108
+ flushedScript = true;
109
+ asyncOut.script(
110
+ `$${reorderFunctionId}(` + (
111
+ typeof awaitInfo.id === "number" ?
112
+ awaitInfo.id :
113
+ '"' + awaitInfo.id + '"') + (
114
+ awaitInfo.after ? ',"' + awaitInfo.after + '"' : "") +
115
+ ")"
116
+ );
117
+ }
97
118
 
98
119
  awaitInfo.out.writer = asyncOut.writer;
99
120
 
package/index.d.ts CHANGED
@@ -324,7 +324,7 @@ declare global {
324
324
  Return extends Element,
325
325
  > {
326
326
  input: Input;
327
- return: () => Return;
327
+ return: { value: () => Return };
328
328
  }
329
329
  export interface NativeTags {
330
330
  [name: string]: NativeTag<Record<string, any>, Element>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.34.2",
3
+ "version": "5.34.4",
4
4
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
5
5
  "keywords": [
6
6
  "front-end",
@@ -106,6 +106,7 @@ module.exports = function awaitTag(input, out) {
106
106
  };
107
107
 
108
108
  if (clientReorder) {
109
+ awaitInfo.parent = out;
109
110
  awaitInfo.after = input.showAfter;
110
111
 
111
112
  clientReorderContext =
@@ -50,9 +50,27 @@ module.exports = function (input, out) {
50
50
  }
51
51
 
52
52
  function handleAwait(awaitInfo) {
53
+ let flushedScript = false;
54
+ let flushedContent = false;
55
+ let flushedPlaceholder = false;
56
+ awaitInfo.parent.on("___toString", () => {
57
+ flushedPlaceholder = true;
58
+ if (!flushedScript && flushedContent) {
59
+ flushedScript = true;
60
+ asyncOut.script(
61
+ `$${reorderFunctionId}(` +
62
+ (typeof awaitInfo.id === "number"
63
+ ? awaitInfo.id
64
+ : '"' + awaitInfo.id + '"') +
65
+ (awaitInfo.after ? ',"' + awaitInfo.after + '"' : "") +
66
+ ")",
67
+ );
68
+ }
69
+ });
53
70
  awaitInfo.out
54
71
  .on("___toString", out.emit.bind(out, "___toString"))
55
72
  .on("finish", function (result) {
73
+ flushedContent = true;
56
74
  if (!global._afRuntime) {
57
75
  // Minified version of ./client-reorder-runtime.js
58
76
  asyncOut.script(
@@ -86,14 +104,17 @@ module.exports = function (input, out) {
86
104
  );
87
105
  }
88
106
 
89
- asyncOut.script(
90
- `$${reorderFunctionId}(` +
91
- (typeof awaitInfo.id === "number"
92
- ? awaitInfo.id
93
- : '"' + awaitInfo.id + '"') +
94
- (awaitInfo.after ? ',"' + awaitInfo.after + '"' : "") +
95
- ")",
96
- );
107
+ if (!flushedScript && flushedPlaceholder) {
108
+ flushedScript = true;
109
+ asyncOut.script(
110
+ `$${reorderFunctionId}(` +
111
+ (typeof awaitInfo.id === "number"
112
+ ? awaitInfo.id
113
+ : '"' + awaitInfo.id + '"') +
114
+ (awaitInfo.after ? ',"' + awaitInfo.after + '"' : "") +
115
+ ")",
116
+ );
117
+ }
97
118
 
98
119
  awaitInfo.out.writer = asyncOut.writer;
99
120