marko 5.37.47 → 5.37.48

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 (66) hide show
  1. package/dist/node_modules/@internal/components-entry/index.js +17 -10
  2. package/dist/node_modules/@internal/components-entry-legacy/index-browser.js +3 -3
  3. package/dist/node_modules/@internal/components-registry/index-browser.js +33 -33
  4. package/dist/node_modules/@internal/components-registry/index.js +2 -2
  5. package/dist/node_modules/@internal/components-util/index-browser.js +16 -16
  6. package/dist/node_modules/@internal/components-util/index.js +4 -4
  7. package/dist/node_modules/@internal/create-readable/index-browser.js +1 -1
  8. package/dist/node_modules/@internal/create-readable/index.js +9 -9
  9. package/dist/node_modules/@internal/preserve-tag/index-browser.js +5 -5
  10. package/dist/node_modules/@internal/preserve-tag/index.js +1 -1
  11. package/dist/node_modules/@internal/set-immediate/index-browser.js +1 -1
  12. package/dist/node_modules/@internal/set-immediate/index-worker.js +2 -2
  13. package/dist/node_modules/@internal/set-immediate/index.js +2 -2
  14. package/dist/runtime/RenderResult.js +3 -3
  15. package/dist/runtime/components/Component.js +95 -95
  16. package/dist/runtime/components/ComponentDef.js +18 -18
  17. package/dist/runtime/components/ComponentsContext.js +3 -3
  18. package/dist/runtime/components/GlobalComponentsContext.js +3 -3
  19. package/dist/runtime/components/KeySequence.js +3 -3
  20. package/dist/runtime/components/ServerComponent.js +1 -1
  21. package/dist/runtime/components/State.js +19 -19
  22. package/dist/runtime/components/attach-detach.js +7 -7
  23. package/dist/runtime/components/dom-data.js +5 -5
  24. package/dist/runtime/components/event-delegation.js +9 -9
  25. package/dist/runtime/components/legacy/defineRenderer-legacy.js +11 -11
  26. package/dist/runtime/components/legacy/dependencies/index.js +7 -7
  27. package/dist/runtime/components/legacy/renderer-legacy.js +28 -28
  28. package/dist/runtime/components/renderer.js +27 -27
  29. package/dist/runtime/components/update-manager.js +4 -4
  30. package/dist/runtime/createOut.js +1 -1
  31. package/dist/runtime/dom-insert.js +5 -5
  32. package/dist/runtime/helpers/_change-case.js +2 -2
  33. package/dist/runtime/helpers/dynamic-tag.js +9 -9
  34. package/dist/runtime/helpers/render-tag.js +1 -1
  35. package/dist/runtime/helpers/serialize-noop.js +1 -1
  36. package/dist/runtime/helpers/style-value.js +1 -1
  37. package/dist/runtime/helpers/tags-compat/runtime-dom.js +23 -23
  38. package/dist/runtime/helpers/tags-compat/runtime-html.js +67 -24
  39. package/dist/runtime/html/AsyncStream.js +20 -20
  40. package/dist/runtime/html/BufferedWriter.js +2 -2
  41. package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
  42. package/dist/runtime/html/helpers/attr.js +2 -2
  43. package/dist/runtime/html/helpers/data-marko.js +1 -1
  44. package/dist/runtime/html/helpers/escape-xml.js +1 -1
  45. package/dist/runtime/html/index.js +1 -1
  46. package/dist/runtime/renderable.js +3 -3
  47. package/dist/runtime/vdom/AsyncVDOMBuilder.js +83 -83
  48. package/dist/runtime/vdom/VComment.js +7 -7
  49. package/dist/runtime/vdom/VComponent.js +4 -4
  50. package/dist/runtime/vdom/VDocumentFragment.js +6 -6
  51. package/dist/runtime/vdom/VElement.js +36 -36
  52. package/dist/runtime/vdom/VFragment.js +9 -9
  53. package/dist/runtime/vdom/VNode.js +33 -33
  54. package/dist/runtime/vdom/VText.js +8 -8
  55. package/dist/runtime/vdom/helpers/const-element.js +3 -3
  56. package/dist/runtime/vdom/hot-reload.js +14 -14
  57. package/dist/runtime/vdom/index.js +1 -1
  58. package/dist/runtime/vdom/morphdom/fragment.js +5 -5
  59. package/dist/runtime/vdom/morphdom/helpers.js +5 -5
  60. package/dist/runtime/vdom/morphdom/index.js +68 -68
  61. package/dist/runtime/vdom/vdom.js +15 -15
  62. package/dist/translator/util/get-component-files.js +1 -1
  63. package/package.json +1 -1
  64. package/src/node_modules/@internal/components-entry/index.js +19 -12
  65. package/src/runtime/helpers/tags-compat/runtime-dom.js +3 -3
  66. package/src/runtime/helpers/tags-compat/runtime-html.js +66 -23
@@ -12,7 +12,7 @@ var specialHtmlRegexp = /[&<]/;
12
12
  function virtualizeChildNodes(node, vdomParent, ownerComponent) {
13
13
  var curChild = node.firstChild;
14
14
  while (curChild) {
15
- vdomParent.bP_(virtualize(curChild, ownerComponent));
15
+ vdomParent.bQ_(virtualize(curChild, ownerComponent));
16
16
  curChild = curChild.nextSibling;
17
17
  }
18
18
  }
@@ -20,7 +20,7 @@ function virtualizeChildNodes(node, vdomParent, ownerComponent) {
20
20
  function virtualize(node, ownerComponent) {
21
21
  switch (node.nodeType) {
22
22
  case 1:
23
- return VElement.ci_(node, virtualizeChildNodes, ownerComponent);
23
+ return VElement.cj_(node, virtualizeChildNodes, ownerComponent);
24
24
  case 3:
25
25
  return new VText(node.nodeValue, ownerComponent);
26
26
  case 8:
@@ -43,7 +43,7 @@ function virtualizeHTML(html, ownerComponent) {
43
43
 
44
44
  while (curChild) {
45
45
  virtualized = virtualize(curChild, ownerComponent);
46
- if (virtualized) vdomFragment.bP_(virtualized);
46
+ if (virtualized) vdomFragment.bQ_(virtualized);
47
47
  curChild = curChild.nextSibling;
48
48
  }
49
49
 
@@ -70,19 +70,19 @@ Node_prototype.t = function (value) {
70
70
  }
71
71
  }
72
72
 
73
- this.bP_(vdomNode || new VText(value.toString()));
74
- return this.ch_();
73
+ this.bQ_(vdomNode || new VText(value.toString()));
74
+ return this.ci_();
75
75
  };
76
76
 
77
- Node_prototype.bU_ = function () {
78
- return this.bP_(new VDocumentFragment());
77
+ Node_prototype.bV_ = function () {
78
+ return this.bQ_(new VDocumentFragment());
79
79
  };
80
80
 
81
- exports.by_ = VComment;
82
- exports.bz_ = VDocumentFragment;
83
- exports.bx_ = VElement;
84
- exports.bA_ = VText;
85
- exports.bB_ = VComponent;
86
- exports.bC_ = VFragment;
87
- exports.ci_ = virtualize;
88
- exports.bD_ = virtualizeHTML;
81
+ exports.bz_ = VComment;
82
+ exports.bA_ = VDocumentFragment;
83
+ exports.by_ = VElement;
84
+ exports.bB_ = VText;
85
+ exports.bC_ = VComponent;
86
+ exports.bD_ = VFragment;
87
+ exports.cj_ = virtualize;
88
+ exports.bE_ = virtualizeHTML;
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _escapeRegexp = require("./escape-regexp");
4
4
 
5
- const COMPONENT_FILES_KEY = "cs_";
5
+ const COMPONENT_FILES_KEY = "ct_";
6
6
 
7
7
  function getComponentFiles({ hub: { file } }) {
8
8
  const meta = file.metadata.marko;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.37.47",
3
+ "version": "5.37.48",
4
4
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
5
5
  "keywords": [
6
6
  "front-end",
@@ -34,7 +34,7 @@ function isNotEmpty(obj) {
34
34
  function safeStringify(data) {
35
35
  return JSON.stringify(warp10.stringifyPrepare(data)).replace(
36
36
  safeJSONRegExp,
37
- safeJSONReplacer
37
+ safeJSONReplacer,
38
38
  );
39
39
  }
40
40
 
@@ -76,7 +76,7 @@ function addComponentsFromContext(componentsContext, componentsToHydrate) {
76
76
  var input = component.input || 0;
77
77
  var typeName = component.typeName;
78
78
  var customEvents = component.___customEvents;
79
- var scope = component.___scope;
79
+ var scope = component.___scope || undefined;
80
80
  var bubblingDomEvents = component.___bubblingDomEvents;
81
81
 
82
82
  var needsState;
@@ -183,9 +183,8 @@ function addComponentsFromContext(componentsContext, componentsToHydrate) {
183
183
  }
184
184
  }
185
185
 
186
- function getInitComponentsData(out, componentDefs) {
186
+ function getInitComponentsData($global, componentDefs) {
187
187
  const len = componentDefs.length;
188
- const $global = out.global;
189
188
  const isLast = $global.___isLastFlush;
190
189
  const didSerializeComponents = $global.___didSerializeComponents;
191
190
  const prefix = getRenderId($global);
@@ -251,7 +250,7 @@ function getInitComponentsDataFromOut(out) {
251
250
  addComponentsFromContext(componentsContext, componentsToHydrate);
252
251
 
253
252
  $global.___isLastFlush = true;
254
- const data = getInitComponentsData(out, componentsToHydrate);
253
+ const data = getInitComponentsData($global, componentsToHydrate);
255
254
  $global.___isLastFlush = undefined;
256
255
 
257
256
  if (runtimeId !== DEFAULT_RUNTIME_ID && data) {
@@ -267,26 +266,34 @@ function writeInitComponentsCode(out) {
267
266
 
268
267
  exports.___getInitComponentsCode = function getInitComponentsCode(
269
268
  out,
270
- componentDefs
269
+ componentDefs,
271
270
  ) {
272
- const initComponentsData =
271
+ const $global = out.global;
272
+ return getInitComponentsCodeFromData(
273
+ $global,
273
274
  arguments.length === 2
274
- ? getInitComponentsData(out, componentDefs)
275
- : getInitComponentsDataFromOut(out);
275
+ ? getInitComponentsData($global, componentDefs)
276
+ : getInitComponentsDataFromOut(out),
277
+ );
278
+ };
276
279
 
280
+ function getInitComponentsCodeFromData($global, initComponentsData) {
277
281
  if (initComponentsData === undefined) {
278
282
  return "";
279
283
  }
280
284
 
281
- const runtimeId = out.global.runtimeId;
285
+ const runtimeId = $global.runtimeId;
282
286
  const componentGlobalKey =
283
287
  runtimeId === DEFAULT_RUNTIME_ID ? "MC" : runtimeId + "_C";
284
288
 
285
289
  return `$${componentGlobalKey}=(window.$${componentGlobalKey}||[]).concat(${safeStringify(
286
- initComponentsData
290
+ initComponentsData,
287
291
  )})`;
288
- };
292
+ }
289
293
 
294
+ exports.___getInitComponentsCodeForDefs = function getInitComponentsCodeForDefs($global, defs) {
295
+ return getInitComponentsCodeFromData($global, getInitComponentsData($global, defs));
296
+ }
290
297
  exports.___addComponentsFromContext = addComponentsFromContext;
291
298
  exports.writeInitComponentsCode = writeInitComponentsCode;
292
299
 
@@ -53,7 +53,7 @@ exports.p = function (domCompat) {
53
53
  const tagsRenderer = domCompat.resolveRegistered(_.r, global);
54
54
  const newNode = domCompat.render(out, component, tagsRenderer, input);
55
55
 
56
- out.bf(out.___assignedKey, component, !newNode);
56
+ out.bf("1", component, !newNode);
57
57
  if (newNode) {
58
58
  out.node({ ___actualize: () => newNode });
59
59
  }
@@ -124,7 +124,7 @@ exports.p = function (domCompat) {
124
124
  domCompat.init(noopRenderer);
125
125
 
126
126
  function renderAndMorph(scope, renderer, renderBody, input) {
127
- const out = defaultCreateOut();
127
+ const out = defaultCreateOut(scope.$global);
128
128
  let host = domCompat.getStartNode(scope);
129
129
  let rootNode = host.fragment;
130
130
  if (!rootNode) {
@@ -132,7 +132,7 @@ exports.p = function (domCompat) {
132
132
  ___componentLookup[scope.m5c]);
133
133
  rootNode = component.___rootNode;
134
134
  host = rootNode.startNode;
135
- domCompat.setScopeNodes(host, rootNode.endNode);
135
+ domCompat.setScopeNodes(host, rootNode.startNode, rootNode.endNode);
136
136
  }
137
137
  const existingComponent = scope.___marko5Component;
138
138
  const componentsContext = ___getComponentsContext(out);
@@ -1,4 +1,7 @@
1
- const initComponentsTag = require("../../../core-tags/components/init-components-tag");
1
+ const {
2
+ ___getInitComponentsCodeForDefs,
3
+ ___addComponentsFromContext,
4
+ } = require("@internal/components-entry");
2
5
  const {
3
6
  ___getComponentsContext,
4
7
  } = require("../../components/ComponentsContext");
@@ -7,16 +10,45 @@ const defaultCreateOut = require("../../createOut");
7
10
  const dynamicTag5 = require("../dynamic-tag");
8
11
 
9
12
  exports.p = function (htmlCompat) {
13
+ const outsByGlobal = new WeakMap();
10
14
  const isMarko6 = (fn) => htmlCompat.isTagsAPI(fn);
11
15
  const isMarko5 = (fn) => !isMarko6(fn);
12
16
  const writeHTML = (result) => {
13
- const state = result.out._state;
14
- const writer = state.writer;
15
- state.events.emit("___toString", writer);
16
- htmlCompat.writeScript(writer._scripts);
17
+ const { out } = result;
18
+ const $global = out.global;
19
+ const outs = outsByGlobal.get($global);
20
+ const writer = out._state.writer;
17
21
  htmlCompat.write(writer._content);
22
+ writer._content = "";
23
+ if (outs) {
24
+ outs.push(out);
25
+ } else {
26
+ outsByGlobal.set($global, [out]);
27
+ }
18
28
  };
19
29
 
30
+ htmlCompat.onFlush((chunk) => {
31
+ const { $global } = chunk.boundary.state;
32
+ const outs = outsByGlobal.get($global);
33
+ if (outs) {
34
+ chunk.render(() => {
35
+ const defs = [];
36
+ outsByGlobal.delete($global);
37
+ for (const out of outs) {
38
+ if (out.___components) {
39
+ ___addComponentsFromContext(out.___components, defs);
40
+ }
41
+
42
+ out._state.events.emit("___toString", out._state.writer);
43
+ chunk.writeScript(out._state.writer._content);
44
+ chunk.writeScript(out._state.writer._scripts);
45
+ }
46
+
47
+ chunk.writeScript(___getInitComponentsCodeForDefs($global, defs));
48
+ });
49
+ }
50
+ });
51
+
20
52
  dynamicTag5.___runtimeCompat = function tagsToVdom(
21
53
  tagsRenderer,
22
54
  renderBody,
@@ -44,9 +76,16 @@ exports.p = function (htmlCompat) {
44
76
  function (_, out, componentDef, component) {
45
77
  const input = _.i;
46
78
  const tagsRenderer = _.r;
47
- const willRerender = componentDef._wrr;
48
- out.bf(out.___assignedKey, component, willRerender);
49
- htmlCompat.render(tagsRenderer, willRerender, out, component, input);
79
+ const willRerender = componentDef._wrr || htmlCompat.isInResumedBranch();
80
+ out.bf("1", component, willRerender);
81
+ htmlCompat.render(
82
+ tagsRenderer,
83
+ willRerender,
84
+ out,
85
+ component,
86
+ input,
87
+ "___toString",
88
+ );
50
89
  out.ef();
51
90
  },
52
91
  // eslint-disable-next-line no-constant-condition
@@ -64,8 +103,9 @@ exports.p = function (htmlCompat) {
64
103
  );
65
104
 
66
105
  htmlCompat.patchDynamicTag(function getRenderer(scopeId, accessor, tag) {
67
- const renderer = tag._ || tag.renderBody || tag;
68
- if (isMarko6(renderer)) return renderer;
106
+ if (!tag || isMarko6(tag._ || tag.content || tag)) {
107
+ return tag;
108
+ }
69
109
 
70
110
  const renderer5 =
71
111
  tag._ ||
@@ -79,15 +119,15 @@ exports.p = function (htmlCompat) {
79
119
  }
80
120
  return (input, ...args) => {
81
121
  const out = defaultCreateOut(htmlCompat.$global());
82
- const branchId = htmlCompat.peekNextScopeId();
122
+ const branchId = htmlCompat.nextScopeId();
83
123
  let customEvents;
84
- htmlCompat.nextScopeId();
85
124
 
86
125
  if (renderer5) {
87
- const normalizedInput = {};
126
+ const originalInput = input;
127
+ input = {};
88
128
 
89
- for (const key in input) {
90
- const value = input[key];
129
+ for (const key in originalInput) {
130
+ const value = originalInput[key];
91
131
  if (/^on[-A-Z]/.test(key)) {
92
132
  if (typeof value === "function") {
93
133
  (customEvents || (customEvents = [])).push([
@@ -97,23 +137,26 @@ exports.p = function (htmlCompat) {
97
137
  value.toJSON = htmlCompat.toJSON;
98
138
  }
99
139
  } else {
100
- normalizedInput[key === "content" ? "renderBody" : key] = value;
140
+ input[key === "content" ? "renderBody" : key] = value;
101
141
  }
102
142
  }
103
- renderer5(normalizedInput, out);
143
+ }
144
+
145
+ if (renderer5) {
146
+ renderer5(input, out);
104
147
  } else {
105
148
  renderBody5(out, input, ...args);
106
149
  }
107
150
 
108
151
  const componentsContext = ___getComponentsContext(out);
109
- const component = componentsContext.___components[0];
110
- if (component) {
111
- component.___component.___customEvents = customEvents;
112
- htmlCompat.writeSetScopeForComponent(branchId, component.id);
152
+ const componentDef = componentsContext.___components[0];
153
+ if (componentDef) {
154
+ componentDef.___component.___customEvents = customEvents;
155
+ componentDef._wrr = true;
156
+ componentDef.___flags |= 1; // FLAG_WILL_RERENDER_IN_BROWSER
157
+ htmlCompat.writeSetScopeForComponent(branchId, componentDef.id);
113
158
  }
114
159
 
115
- initComponentsTag({}, out);
116
-
117
160
  let async;
118
161
  out.once("finish", (result) => {
119
162
  if (!async) {