marko 5.34.3 → 5.34.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
 
@@ -81,13 +81,13 @@ exports.p = function (domCompat) {
81
81
 
82
82
  domCompat.patchConditionals((conditional) => (...args) => {
83
83
  const signal = conditional(...args);
84
- const hasAttrs = args.length > 1;
84
+ const skipAttrs = args.length <= 1;
85
85
  return (scope, renderer, clean) => {
86
- return signal(scope, create5to6Renderer(renderer, hasAttrs), clean);
86
+ return signal(scope, create5to6Renderer(renderer, skipAttrs), clean);
87
87
  };
88
88
  });
89
89
 
90
- function create5to6Renderer(renderer, hasAttrs) {
90
+ function create5to6Renderer(renderer, skipAttrs) {
91
91
  let newRenderer = renderer;
92
92
  if (renderer && typeof renderer !== "string") {
93
93
  const rendererFromAnywhere =
@@ -115,7 +115,7 @@ exports.p = function (domCompat) {
115
115
  }
116
116
  newRenderer = domCompat.createRenderer(
117
117
  (scope) => {
118
- if (!hasAttrs) {
118
+ if (skipAttrs) {
119
119
  renderAndMorph(scope, rendererFromAnywhere, renderer, {});
120
120
  }
121
121
  },
@@ -12,8 +12,7 @@ exports.p = function (tagsAPI) {
12
12
  createRenderFn,
13
13
  fork,
14
14
  write,
15
- makeSerializable,
16
- register,
15
+ serializerRegister,
17
16
  writeScope,
18
17
  nextScopeId,
19
18
  getRegistryInfo
@@ -168,19 +167,11 @@ exports.p = function (tagsAPI) {
168
167
  }
169
168
  );
170
169
 
171
- function dummyCreate5to6Renderer() {}
172
-
173
- register(dummyCreate5to6Renderer, "@marko/tags-compat-5-to-6");
174
-
175
170
  return function serialized5to6(renderer, id) {
176
- const dummyRenderer = () => {};
177
- register(dummyRenderer, id);
178
- return makeSerializable(renderer, (s) =>
179
- s.
180
- value(dummyCreate5to6Renderer).
181
- code("(").
182
- value(dummyRenderer).
183
- code(",!0)")
171
+ return serializerRegister(
172
+ "@marko/tags-compat-5-to-6",
173
+ renderer,
174
+ serializerRegister(id, () => {})
184
175
  );
185
176
  };
186
177
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.34.3",
3
+ "version": "5.34.5",
4
4
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
5
5
  "keywords": [
6
6
  "front-end",
@@ -64,8 +64,8 @@
64
64
  "build": "babel ./src --out-dir ./dist --extensions .js --copy-files --config-file ../../babel.config.js --env-name=production"
65
65
  },
66
66
  "dependencies": {
67
- "@marko/compiler": "^5.36.1",
68
- "@marko/translator-default": "^6.0.0",
67
+ "@marko/compiler": "^5.36.2",
68
+ "@marko/translator-default": "^6.0.1",
69
69
  "app-module-path": "^2.2.0",
70
70
  "argly": "^1.2.0",
71
71
  "browser-refresh-client": "1.1.4",
@@ -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
 
@@ -81,13 +81,13 @@ exports.p = function (domCompat) {
81
81
 
82
82
  domCompat.patchConditionals((conditional) => (...args) => {
83
83
  const signal = conditional(...args);
84
- const hasAttrs = args.length > 1;
84
+ const skipAttrs = args.length <= 1;
85
85
  return (scope, renderer, clean) => {
86
- return signal(scope, create5to6Renderer(renderer, hasAttrs), clean);
86
+ return signal(scope, create5to6Renderer(renderer, skipAttrs), clean);
87
87
  };
88
88
  });
89
89
 
90
- function create5to6Renderer(renderer, hasAttrs) {
90
+ function create5to6Renderer(renderer, skipAttrs) {
91
91
  let newRenderer = renderer;
92
92
  if (renderer && typeof renderer !== "string") {
93
93
  const rendererFromAnywhere =
@@ -115,7 +115,7 @@ exports.p = function (domCompat) {
115
115
  }
116
116
  newRenderer = domCompat.createRenderer(
117
117
  (scope) => {
118
- if (!hasAttrs) {
118
+ if (skipAttrs) {
119
119
  renderAndMorph(scope, rendererFromAnywhere, renderer, {});
120
120
  }
121
121
  },
@@ -12,8 +12,7 @@ exports.p = function (tagsAPI) {
12
12
  createRenderFn,
13
13
  fork,
14
14
  write,
15
- makeSerializable,
16
- register,
15
+ serializerRegister,
17
16
  writeScope,
18
17
  nextScopeId,
19
18
  getRegistryInfo,
@@ -168,19 +167,11 @@ exports.p = function (tagsAPI) {
168
167
  },
169
168
  );
170
169
 
171
- function dummyCreate5to6Renderer() {}
172
-
173
- register(dummyCreate5to6Renderer, "@marko/tags-compat-5-to-6");
174
-
175
170
  return function serialized5to6(renderer, id) {
176
- const dummyRenderer = () => {};
177
- register(dummyRenderer, id);
178
- return makeSerializable(renderer, (s) =>
179
- s
180
- .value(dummyCreate5to6Renderer)
181
- .code("(")
182
- .value(dummyRenderer)
183
- .code(",!0)"),
171
+ return serializerRegister(
172
+ "@marko/tags-compat-5-to-6",
173
+ renderer,
174
+ serializerRegister(id, () => {}),
184
175
  );
185
176
  };
186
177
  };