marko 5.39.43 → 5.39.45

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.
Files changed (35) hide show
  1. package/dist/runtime/helpers/load-tag.js +28 -12
  2. package/dist/runtime/helpers/tags-compat/runtime-dom.js +9 -9
  3. package/dist/runtime/helpers/tags-compat/runtime-html.js +43 -28
  4. package/dist/runtime/html/AsyncStream.js +10 -10
  5. package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
  6. package/dist/runtime/html/helpers/attr.js +2 -2
  7. package/dist/runtime/html/helpers/escape-xml.js +1 -1
  8. package/dist/runtime/renderable.js +1 -1
  9. package/dist/runtime/vdom/AsyncVDOMBuilder.js +65 -65
  10. package/dist/runtime/vdom/VComment.js +7 -7
  11. package/dist/runtime/vdom/VComponent.js +3 -3
  12. package/dist/runtime/vdom/VDocumentFragment.js +7 -7
  13. package/dist/runtime/vdom/VElement.js +32 -32
  14. package/dist/runtime/vdom/VFragment.js +5 -5
  15. package/dist/runtime/vdom/VNode.js +29 -29
  16. package/dist/runtime/vdom/VText.js +8 -8
  17. package/dist/runtime/vdom/helpers/const-element.js +3 -3
  18. package/dist/runtime/vdom/hot-reload.js +2 -2
  19. package/dist/runtime/vdom/morphdom/fragment.js +3 -3
  20. package/dist/runtime/vdom/morphdom/helpers.js +1 -1
  21. package/dist/runtime/vdom/morphdom/index.js +34 -34
  22. package/dist/runtime/vdom/vdom.js +15 -15
  23. package/dist/translator/taglib/core/parse-client.js +6 -4
  24. package/dist/translator/taglib/core/parse-server.js +6 -4
  25. package/dist/translator/taglib/core/parse-static.js +6 -4
  26. package/dist/translator/util/get-component-files.js +1 -1
  27. package/dist/translator/util/load-import.js +2 -1
  28. package/docs/compiler.md +8 -5
  29. package/package.json +4 -4
  30. package/src/runtime/helpers/load-tag.js +28 -12
  31. package/src/runtime/helpers/tags-compat/runtime-html.js +42 -27
  32. package/src/translator/taglib/core/parse-client.js +7 -5
  33. package/src/translator/taglib/core/parse-server.js +7 -5
  34. package/src/translator/taglib/core/parse-static.js +7 -5
  35. package/src/translator/util/load-import.js +1 -0
@@ -9,7 +9,6 @@ var DEFAULT_RUNTIME_ID = "M";
9
9
  var kAssets = Symbol();
10
10
  var kBlockIndex = Symbol();
11
11
  var kDeferIndex = Symbol();
12
- var assetFlush;
13
12
 
14
13
  exports.withPageAssets = function withPageAssets(
15
14
  typeId,
@@ -17,7 +16,6 @@ template,
17
16
  runtime,
18
17
  runtimeId)
19
18
  {
20
- assetFlush = runtime;
21
19
  var flushBeforeInput = { renderBody: flush };
22
20
  return createFacade(template, function (input, out) {
23
21
  var g = out.global;
@@ -44,7 +42,7 @@ runtimeId)
44
42
  var key = out.ad_;
45
43
  var def = out.ac_;
46
44
  var component = def && def.s_;
47
- addAsset(g, typeId);
45
+ addAsset(g, typeId, runtime);
48
46
 
49
47
  if (hasAssets) {
50
48
  if (willRerender(def)) {
@@ -69,26 +67,44 @@ runtimeId)
69
67
  });
70
68
  };
71
69
 
72
- exports.withLoadAssets = function withLoadAssets(typeId, template, triggers) {
70
+ // Its importer passes the bundler's resolver, so it resolves on a page of either
71
+ // API, whichever page entry rendered.
72
+ exports.withLoadAssets = function withLoadAssets(
73
+ typeId,
74
+ template,
75
+ assetFlush,
76
+ triggers)
77
+ {
73
78
  return createFacade(template, function (input, out) {
74
79
  var key = out.ad_;
75
80
  var def = out.ac_;
76
- addAsset(out.global, typeId, triggers);
77
81
 
78
82
  if (willRerender(def)) {
79
83
  out.bf(key + "s", def.s_, true);
80
- flush(out);
84
+ writeLoadAsset(out, typeId, assetFlush, triggers);
81
85
  out.ef();
82
86
  out.bf(key, def.s_, true);
83
87
  template._(input, out);
84
88
  out.ef();
85
89
  } else {
86
- flush(out);
90
+ writeLoadAsset(out, typeId, assetFlush, triggers);
87
91
  template._(input, out);
88
92
  }
89
93
  });
90
94
  };
91
95
 
96
+ // Within Tags content the Tags writer places it apart from what a `@catch` drops,
97
+ // and leaves the page's own entry to the page.
98
+ function writeLoadAsset(out, typeId, assetFlush, triggers) {
99
+ var tagsCompat = exports.bs_;
100
+ if (tagsCompat && tagsCompat.getChunk()) {
101
+ tagsCompat.writeLoadAsset(typeId, assetFlush, triggers);
102
+ } else {
103
+ addAsset(out.global, typeId, assetFlush, triggers);
104
+ flush(out);
105
+ }
106
+ }
107
+
92
108
  function createFacade(template, render) {
93
109
  // Under hot reload the template's `_` is an accessor, which a normal
94
110
  // assignment through the facade's prototype chain would invoke (storing
@@ -116,12 +132,12 @@ function flush(out) {
116
132
  var di = g[kDeferIndex];
117
133
 
118
134
  for (; bi < length; bi++) {
119
- result += assetFlush(g, "block", assets[bi].id);
135
+ result += assets[bi].flush(g, "block", assets[bi].id);
120
136
  }
121
137
 
122
138
  for (; di < length; di++) {
123
139
  var asset = assets[di];
124
- var deferHTML = assetFlush(g, "defer", asset.id);
140
+ var deferHTML = asset.flush(g, "defer", asset.id);
125
141
  if (asset.triggers) {
126
142
  if (deferHTML) out.script(triggerScript(deferHTML, asset.triggers));
127
143
  } else {
@@ -134,17 +150,17 @@ function flush(out) {
134
150
  out.write(result);
135
151
  }
136
152
 
137
- function addAsset(g, id, triggers) {
153
+ function addAsset(g, id, assetFlush, triggers) {
138
154
  var assets = g[kAssets];
139
155
  if (!assets) {
140
- g[kAssets] = [{ id: id, triggers: triggers }];
156
+ g[kAssets] = [{ id: id, flush: assetFlush, triggers: triggers }];
141
157
  g[kBlockIndex] = g[kDeferIndex] = 0;
142
158
  } else if (
143
159
  !assets.find(function (a) {
144
160
  return a.id === id;
145
161
  }))
146
162
  {
147
- assets.push({ id: id, triggers: triggers });
163
+ assets.push({ id: id, flush: assetFlush, triggers: triggers });
148
164
  }
149
165
  }
150
166
 
@@ -28,7 +28,7 @@ exports.f = (id, factory) => {
28
28
  return factory(
29
29
  _n_[scope.m5h] ||
30
30
  _n_[scope.m5c] ||
31
- scope.bs_
31
+ scope.bt_
32
32
  ).apply(this, arguments);
33
33
  }
34
34
  );
@@ -65,7 +65,7 @@ exports.p = function (domCompat) {
65
65
  const extraArgs = value[3];
66
66
  return function () {
67
67
  const component =
68
- _n_[componentId] || scope.bs_;
68
+ _n_[componentId] || scope.bt_;
69
69
  const args = extraArgs ? extraArgs.slice() : [];
70
70
  for (let i = 0; i < arguments.length; i++) {
71
71
  args.push(arguments[i]);
@@ -76,7 +76,7 @@ exports.p = function (domCompat) {
76
76
  return value;
77
77
  });
78
78
 
79
- Component.prototype.bt_ =
79
+ Component.prototype.bu_ =
80
80
  Component.prototype.aG_;
81
81
  Component.prototype.aG_ = function (customEvents, scopeId) {
82
82
  for (const customEvent of customEvents) {
@@ -86,7 +86,7 @@ exports.p = function (domCompat) {
86
86
  );
87
87
  }
88
88
 
89
- this.bt_(customEvents, scopeId);
89
+ this.bu_(customEvents, scopeId);
90
90
  };
91
91
 
92
92
  const defDeserialize = ComponentDef._F_;
@@ -108,7 +108,7 @@ exports.p = function (domCompat) {
108
108
 
109
109
  out.bf("1", component, !newNode);
110
110
  if (newNode) {
111
- out.node({ bu_: () => newNode });
111
+ out.node({ bv_: () => newNode });
112
112
  }
113
113
  out.ef();
114
114
  },
@@ -184,8 +184,8 @@ exports.p = function (domCompat) {
184
184
  // An inert/server only class child has no client instance in
185
185
  // ___componentLookup; once it has been re-rendered once it is tracked on
186
186
  // the scope instead.
187
- const component = scope.bs_ =
188
- _n_[scope.m5c] || scope.bs_;
187
+ const component = scope.bt_ =
188
+ _n_[scope.m5c] || scope.bt_;
189
189
  if (component) {
190
190
  rootNode = component._G_;
191
191
  } else {
@@ -202,7 +202,7 @@ exports.p = function (domCompat) {
202
202
  host = rootNode.startNode;
203
203
  domCompat.setScopeNodes(scope, rootNode.startNode, rootNode.endNode);
204
204
  }
205
- const existingComponent = scope.bs_;
205
+ const existingComponent = scope.bt_;
206
206
  const componentsContext = T_(out);
207
207
  const globalComponentsContext = componentsContext.p_;
208
208
  let customEvents;
@@ -240,7 +240,7 @@ exports.p = function (domCompat) {
240
240
  component._G_ = rootNode;
241
241
  component.P_ = normalizedInput;
242
242
  component.X_ = customEvents;
243
- scope.bs_ = component;
243
+ scope.bt_ = component;
244
244
  });
245
245
  }
246
246
 
@@ -17,6 +17,7 @@ registerClassFunction(out.global, id, fn, component.id);
17
17
 
18
18
  exports.p = function (htmlCompat) {
19
19
  registerClassFunction = htmlCompat.registerClassFunction;
20
+ require("../load-tag").bs_ = htmlCompat;
20
21
  const writersByGlobal = new WeakMap();
21
22
  const boundaryModeByRenderer = new WeakMap();
22
23
  const isMarko6 = (fn) => typeof fn !== "function" || htmlCompat.isTagsAPI(fn);
@@ -27,6 +28,12 @@ exports.p = function (htmlCompat) {
27
28
  htmlCompat.write(writer._content);
28
29
  htmlCompat.writeScript(writer._scripts);
29
30
  writer._content = writer._scripts = "";
31
+ if (writer._data?.reorders) {
32
+ htmlCompat.deferReorders(writer._data.reorders);
33
+ }
34
+ if (writer._data?.chunks) {
35
+ htmlCompat.appendChunks(writer._data.chunks);
36
+ }
30
37
 
31
38
  if (out.b_) {
32
39
  let writers = writersByGlobal.get(out.global);
@@ -39,27 +46,28 @@ exports.p = function (htmlCompat) {
39
46
  __(out.b_, writers.classAPI);
40
47
  }
41
48
  };
42
- const flushScripts = ($global, flushDefs) => {
49
+ // Returns the html of the reorders the flush streams, for the caller to write
50
+ // ahead of the scripts that move them into place.
51
+ const flushScripts = ($global, flushDefs, chunks, reorders) => {
52
+ let html = "";
53
+ let scripts = "";
43
54
  const writers = writersByGlobal.get($global);
44
- if (!writers) return "";
55
+ if (!writers) return { html, scripts };
45
56
 
46
57
  const { classAPI, tagsAPI } = writers;
47
- let scripts = "";
48
58
  let componentDefs = flushDefs;
49
- let chunk;
50
59
 
51
60
  if (classAPI.length) {
52
61
  componentDefs = flushDefs ? flushDefs.concat(classAPI) : classAPI;
53
62
  writers.classAPI = [];
54
63
  }
55
64
 
56
- if (tagsAPI.length) {
57
- chunk = tagsAPI[0];
58
- for (let i = 1; i < tagsAPI.length; i++) {
59
- chunk.append(tagsAPI[i]);
60
- }
61
- writers.tagsAPI = [];
62
- }
65
+ // Component scopes, then the tags content in the class html this flush writes.
66
+ let chunk = htmlCompat.joinChunks(
67
+ chunks ? tagsAPI.concat(chunks) : tagsAPI
68
+ );
69
+ // Emptied in place: a render still pending holds this list to add to it.
70
+ tagsAPI.length = 0;
63
71
 
64
72
  if (componentDefs?.length) {
65
73
  // Serializing a bridged handler registers a tags scope, so it needs a chunk:
@@ -71,28 +79,26 @@ exports.p = function (htmlCompat) {
71
79
  );
72
80
  if (scripts) {
73
81
  htmlCompat.ensureState($global).walkOnNextFlush = true;
74
-
75
- if (!chunk) {
76
- scripts = concatScripts(
77
- live ?
78
- htmlCompat.flushScript($global) :
79
- htmlCompat.flushScript($global, target),
80
- scripts
81
- );
82
- }
82
+ chunk ||= live ? htmlCompat.createChunk($global) : target;
83
83
  }
84
84
  }
85
85
 
86
+ if (reorders) {
87
+ chunk ||= htmlCompat.createChunk($global);
88
+ }
89
+
86
90
  if (chunk) {
87
- scripts = concatScripts(htmlCompat.flushScript($global, chunk), scripts);
91
+ const flushed = htmlCompat.flushScript(chunk, reorders);
92
+ html = flushed.html;
93
+ scripts = concatScripts(flushed.scripts, scripts);
88
94
  }
89
95
 
90
- return scripts;
96
+ return { html, scripts };
91
97
  };
92
98
 
93
99
  htmlCompat.onFlush((chunk) => {
94
100
  chunk.render(() => {
95
- chunk.writeScript(flushScripts(chunk.boundary.state.$global));
101
+ chunk.writeScript(flushScripts(chunk.boundary.state.$global).scripts);
96
102
  });
97
103
  });
98
104
 
@@ -128,11 +134,17 @@ exports.p = function (htmlCompat) {
128
134
  if (!writers) {
129
135
  writersByGlobal.set($global, writers = { classAPI: [], tagsAPI: [] });
130
136
  out.prependListener("c_", (writer) => {
131
- const defs = writer._data?.componentDefs;
132
- const scripts = flushScripts($global, defs);
133
- if (scripts) {
137
+ const data = writer._data;
138
+ const defs = data?.componentDefs;
139
+ const chunks = data?.chunks;
140
+ // Reorders queue with the html carrying the markers they replace.
141
+ const reorders = data?.reorders;
142
+ if (data) data.chunks = data.reorders = undefined;
143
+ const flushed = flushScripts($global, defs, chunks, reorders);
144
+ writer.write(flushed.html);
145
+ if (flushed.scripts) {
134
146
  if (defs) writer._data.componentDefs = undefined;
135
- writer.script(scripts);
147
+ writer.script(flushed.scripts);
136
148
  }
137
149
  });
138
150
  }
@@ -153,7 +165,8 @@ exports.p = function (htmlCompat) {
153
165
  writers.tagsAPI,
154
166
  !willRerender && (
155
167
  hasBridgedClassEvent(input) ||
156
- htmlCompat.hasPendingClassFunctions(out.global))
168
+ htmlCompat.hasPendingClassFunctions(out.global)),
169
+ out._state.bw_
157
170
  );
158
171
  out.ef();
159
172
  },
@@ -191,6 +204,8 @@ exports.p = function (htmlCompat) {
191
204
  const $global = htmlCompat.$global();
192
205
  htmlCompat.ensureState($global);
193
206
  const out = defaultCreateOut($global);
207
+ // Class content settling later still renders within this tags content.
208
+ out._state.bw_ = htmlCompat.getChunk();
194
209
  const branchId = htmlCompat.nextScopeId();
195
210
  let forceBoundary = boundaryModeByRenderer.get(tag);
196
211
 
@@ -8,7 +8,7 @@ var markoAttr = require("./helpers/data-marko");
8
8
  var escapeXmlHelper = require("./helpers/escape-xml");
9
9
  var StringWriter = require("./StringWriter");
10
10
  var escapeXmlOrNullish = escapeXmlHelper.x;
11
- var escapeXmlString = escapeXmlHelper.bv_;
11
+ var escapeXmlString = escapeXmlHelper.bx_;
12
12
  var missingSetTimeout = typeof setTimeout !== "function";
13
13
 
14
14
  function noop() {}
@@ -104,7 +104,7 @@ function AsyncStream(global, writer, parentOut) {
104
104
  this.ac_ = null;
105
105
  this.ad_ = null;
106
106
  this.bf_ = null;
107
- this.bw_ = false;
107
+ this.by_ = false;
108
108
  }
109
109
 
110
110
  AsyncStream.DEFAULT_TIMEOUT = 10000;
@@ -124,11 +124,11 @@ AsyncStream.enableAsyncStackTrace = function () {
124
124
 
125
125
  var proto = AsyncStream.prototype = {
126
126
  constructor: AsyncStream,
127
- bx_: true,
127
+ bz_: true,
128
128
 
129
129
  [Symbol.asyncIterator]() {
130
- if (this.by_) {
131
- return this.by_;
130
+ if (this.bA_) {
131
+ return this.bA_;
132
132
  }
133
133
 
134
134
  const originalWriter = this._state.writer;
@@ -235,7 +235,7 @@ var proto = AsyncStream.prototype = {
235
235
  };
236
236
  }
237
237
 
238
- return this.by_ = {
238
+ return this.bA_ = {
239
239
  next: iteratorNextFn,
240
240
  return: iteratorReturnFn,
241
241
  throw: iteratorReturnFn,
@@ -247,7 +247,7 @@ var proto = AsyncStream.prototype = {
247
247
 
248
248
  toReadable() {
249
249
  let cancelled = false;
250
- this.bz_ = (this.bz_ || 0) + 1;
250
+ this.bB_ = (this.bB_ || 0) + 1;
251
251
  return new ReadableStream({
252
252
  start: async (ctrl) => {
253
253
  const encoder = new TextEncoder();
@@ -277,7 +277,7 @@ var proto = AsyncStream.prototype = {
277
277
 
278
278
  // Every consumer shares one iterator, so only the last one out may end
279
279
  // it; the others are still reading.
280
- if (! --this.bz_) {
280
+ if (! --this.bB_) {
281
281
  this[Symbol.asyncIterator]().return();
282
282
  }
283
283
  }
@@ -372,7 +372,7 @@ var proto = AsyncStream.prototype = {
372
372
  }
373
373
 
374
374
  this._lastCount++;
375
- newStream.bw_ = true;
375
+ newStream.by_ = true;
376
376
  }
377
377
 
378
378
  name = options.name;
@@ -492,7 +492,7 @@ var proto = AsyncStream.prototype = {
492
492
  parentOut._handleChildDone(this);
493
493
  }
494
494
  } else {
495
- if (childOut.bw_) {
495
+ if (childOut.by_) {
496
496
  this._lastCount--;
497
497
  }
498
498
 
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var attrHelper = require("./attr");
3
- var notEmptyAttr = attrHelper.bA_;
4
- var isEmptyAttrValue = attrHelper.bB_;
3
+ var notEmptyAttr = attrHelper.bC_;
4
+ var isEmptyAttrValue = attrHelper.bD_;
5
5
  var classHelper = require("./class-attr");
6
6
  var styleHelper = require("./style-attr");
7
7
 
@@ -5,8 +5,8 @@
5
5
 
6
6
  module.exports = attr;
7
7
 
8
- attr.bA_ = nonVoidAttr;
9
- attr.bB_ = isVoid;
8
+ attr.bC_ = nonVoidAttr;
9
+ attr.bD_ = isVoid;
10
10
  attr.a = attrAssignment;
11
11
  attr.d = escapeDoubleQuotedAttrValue;
12
12
  attr.s = escapeSingleQuotedAttrValue;
@@ -18,4 +18,4 @@ module.exports.x = function (value) {
18
18
  return escape(value + "");
19
19
  };
20
20
 
21
- exports.bv_ = escape;
21
+ exports.bx_ = escape;
@@ -170,7 +170,7 @@ module.exports = function (target, renderer) {
170
170
  finalData = {};
171
171
  }
172
172
 
173
- if (out && out.bx_) {
173
+ if (out && out.bz_) {
174
174
  finalOut = out;
175
175
  shouldEnd = false;
176
176
  extend(out.global, globalData);