marko 5.32.15 → 5.33.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. package/bin/markoc +1 -1
  2. package/dist/node_modules/@internal/components-entry/index.js +5 -7
  3. package/dist/runtime/helpers/dynamic-tag.js +5 -1
  4. package/dist/runtime/helpers/tags-compat-dom.js +265 -0
  5. package/dist/runtime/helpers/tags-compat-html.js +167 -0
  6. package/dist/runtime/html/AsyncStream.js +96 -13
  7. package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
  8. package/dist/runtime/html/helpers/attr.js +3 -3
  9. package/dist/runtime/html/helpers/data-marko.js +1 -1
  10. package/dist/runtime/html/helpers/escape-quotes.js +1 -1
  11. package/dist/runtime/html/helpers/escape-xml.js +1 -1
  12. package/dist/runtime/renderable.js +52 -3
  13. package/dist/runtime/vdom/AsyncVDOMBuilder.js +67 -67
  14. package/dist/runtime/vdom/VComponent.js +3 -3
  15. package/dist/runtime/vdom/VDocumentFragment.js +7 -7
  16. package/dist/runtime/vdom/VElement.js +35 -35
  17. package/dist/runtime/vdom/VFragment.js +5 -5
  18. package/dist/runtime/vdom/VNode.js +31 -31
  19. package/dist/runtime/vdom/VText.js +8 -8
  20. package/dist/runtime/vdom/helpers/const-element.js +3 -3
  21. package/dist/runtime/vdom/hot-reload.js +2 -2
  22. package/dist/runtime/vdom/morphdom/fragment.js +3 -3
  23. package/dist/runtime/vdom/morphdom/helpers.js +1 -1
  24. package/dist/runtime/vdom/morphdom/index.js +31 -31
  25. package/dist/runtime/vdom/vdom.js +14 -14
  26. package/docs/compiler.md +1 -1
  27. package/index.d.ts +4 -6
  28. package/package.json +83 -83
  29. package/src/node_modules/@internal/components-entry/index.js +5 -7
  30. package/src/runtime/helpers/dynamic-tag.js +5 -1
  31. package/src/runtime/helpers/tags-compat-dom.js +265 -0
  32. package/src/runtime/helpers/tags-compat-html.js +167 -0
  33. package/src/runtime/html/AsyncStream.js +87 -4
  34. package/src/runtime/renderable.js +49 -0
@@ -6,16 +6,16 @@ var createFragmentNode = require("./morphdom/fragment")._h_;
6
6
  var VNode = require("./VNode");
7
7
 
8
8
  function VFragment(key, ownerComponent, preserve) {
9
- this.bQ_(null /* childCount */, ownerComponent);
10
- this.bR_ = key;
9
+ this.c__(null /* childCount */, ownerComponent);
10
+ this.ca_ = key;
11
11
  this.aa_ = preserve;
12
12
  }
13
13
 
14
14
  VFragment.prototype = {
15
- bS_: 12,
16
- bP_: function () {
15
+ cb_: 12,
16
+ bo_: function () {
17
17
  var fragment = createFragmentNode();
18
- keysByDOMNode.set(fragment, this.bR_);
18
+ keysByDOMNode.set(fragment, this.ca_);
19
19
  vElementByDOMNode.set(fragment, this);
20
20
  return fragment;
21
21
  }
@@ -2,79 +2,79 @@
2
2
  function VNode() {}
3
3
 
4
4
  VNode.prototype = {
5
- bQ_: function (finalChildCount, ownerComponent) {
6
- this.ce_ = finalChildCount;
7
- this.cf_ = 0;
8
- this.bW_ = null;
9
- this.cg_ = null;
10
- this.bT_ = null;
11
- this.bU_ = null;
5
+ c__: function (finalChildCount, ownerComponent) {
6
+ this.co_ = finalChildCount;
7
+ this.cp_ = 0;
8
+ this.cf_ = null;
9
+ this.cq_ = null;
10
+ this.cc_ = null;
11
+ this.cd_ = null;
12
12
  this._J_ = ownerComponent;
13
13
  },
14
14
 
15
15
  get ay_() {
16
- var firstChild = this.bW_;
16
+ var firstChild = this.cf_;
17
17
 
18
- if (firstChild && firstChild.bV_) {
18
+ if (firstChild && firstChild.ce_) {
19
19
  var nestedFirstChild = firstChild.ay_;
20
20
  // The first child is a DocumentFragment node.
21
21
  // If the DocumentFragment node has a first child then we will return that.
22
22
  // Otherwise, the DocumentFragment node is not *really* the first child and
23
23
  // we need to skip to its next sibling
24
- return nestedFirstChild || firstChild.ch_;
24
+ return nestedFirstChild || firstChild.cr_;
25
25
  }
26
26
 
27
27
  return firstChild;
28
28
  },
29
29
 
30
- get ch_() {
31
- var nextSibling = this.bU_;
30
+ get cr_() {
31
+ var nextSibling = this.cd_;
32
32
 
33
33
  if (nextSibling) {
34
- if (nextSibling.bV_) {
34
+ if (nextSibling.ce_) {
35
35
  var firstChild = nextSibling.ay_;
36
- return firstChild || nextSibling.ch_;
36
+ return firstChild || nextSibling.cr_;
37
37
  }
38
38
  } else {
39
- var parentNode = this.bT_;
40
- if (parentNode && parentNode.bV_) {
41
- return parentNode.ch_;
39
+ var parentNode = this.cc_;
40
+ if (parentNode && parentNode.ce_) {
41
+ return parentNode.cr_;
42
42
  }
43
43
  }
44
44
 
45
45
  return nextSibling;
46
46
  },
47
47
 
48
- bI_: function (child) {
49
- this.cf_++;
48
+ bT_: function (child) {
49
+ this.cp_++;
50
50
 
51
- if (this.bY_ === "textarea") {
52
- if (child.ci_) {
53
- var childValue = child.cj_;
54
- this.bZ_ = (this.bZ_ || "") + childValue;
51
+ if (this.ch_ === "textarea") {
52
+ if (child.cs_) {
53
+ var childValue = child.ct_;
54
+ this.ci_ = (this.ci_ || "") + childValue;
55
55
  } else {
56
56
  throw TypeError();
57
57
  }
58
58
  } else {
59
- var lastChild = this.cg_;
59
+ var lastChild = this.cq_;
60
60
 
61
- child.bT_ = this;
61
+ child.cc_ = this;
62
62
 
63
63
  if (lastChild) {
64
- lastChild.bU_ = child;
64
+ lastChild.cd_ = child;
65
65
  } else {
66
- this.bW_ = child;
66
+ this.cf_ = child;
67
67
  }
68
68
 
69
- this.cg_ = child;
69
+ this.cq_ = child;
70
70
  }
71
71
 
72
72
  return child;
73
73
  },
74
74
 
75
- ca_: function finishChild() {
76
- if (this.cf_ === this.ce_ && this.bT_) {
77
- return this.bT_.ca_();
75
+ ck_: function finishChild() {
76
+ if (this.cp_ === this.co_ && this.cc_) {
77
+ return this.cc_.ck_();
78
78
  } else {
79
79
  return this;
80
80
  }
@@ -2,21 +2,21 @@
2
2
  var VNode = require("./VNode");
3
3
 
4
4
  function VText(value, ownerComponent) {
5
- this.bQ_(-1 /* no children */, ownerComponent);
6
- this.cj_ = value;
5
+ this.c__(-1 /* no children */, ownerComponent);
6
+ this.ct_ = value;
7
7
  }
8
8
 
9
9
  VText.prototype = {
10
- ci_: true,
10
+ cs_: true,
11
11
 
12
- bS_: 3,
12
+ cb_: 3,
13
13
 
14
- bP_: function (host) {
15
- return (host.ownerDocument || host).createTextNode(this.cj_);
14
+ bo_: function (host) {
15
+ return (host.ownerDocument || host).createTextNode(this.ct_);
16
16
  },
17
17
 
18
- bJ_: function () {
19
- return new VText(this.cj_);
18
+ bU_: function () {
19
+ return new VText(this.ct_);
20
20
  }
21
21
  };
22
22
 
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var VElement = require("../vdom").br_;
3
+ var VElement = require("../vdom").bC_;
4
4
  var i = 0;
5
5
 
6
6
  module.exports = function (tagName, attrs, childCount) {
@@ -13,12 +13,12 @@ function ConstVElement(tagName, attrs, childCount) {
13
13
 
14
14
  ConstVElement.prototype = Object.create(VElement.prototype);
15
15
  ConstVElement.prototype.e = function (tagName, attrs, childCount) {
16
- var child = this.bI_(
16
+ var child = this.bT_(
17
17
  new ConstVElement(tagName, attrs, childCount)
18
18
  );
19
19
 
20
20
  if (childCount === 0) {
21
- return this.ca_();
21
+ return this.ck_();
22
22
  } else {
23
23
  return child;
24
24
  }
@@ -44,7 +44,7 @@ exports.t = runtime.t = function (typeName) {
44
44
  instance.P_(input, out);
45
45
  };
46
46
 
47
- instance.ck_ = true;
47
+ instance.cu_ = true;
48
48
  instance.am_();
49
49
  instance._t_ = false;
50
50
 
@@ -78,7 +78,7 @@ registry._C_ = function (typeName, id) {
78
78
  if (instances) {
79
79
  instances.add(instance);
80
80
  instance.once("destroy", function () {
81
- if (!instance.ck_) {
81
+ if (!instance.cu_) {
82
82
  instances.delete(instance);
83
83
  }
84
84
  });
@@ -80,8 +80,8 @@ function createFragmentNode(startNode, nextNode, parentNode) {
80
80
 
81
81
  function beginFragmentNode(startNode, parentNode) {
82
82
  var fragment = createFragmentNode(startNode, null, parentNode);
83
- fragment.cl_ = function (nextNode) {
84
- fragment.cl_ = null;
83
+ fragment.cv_ = function (nextNode) {
84
+ fragment.cv_ = null;
85
85
  insertBefore(
86
86
  fragment.endNode,
87
87
  nextNode,
@@ -92,4 +92,4 @@ function beginFragmentNode(startNode, parentNode) {
92
92
  }
93
93
 
94
94
  exports._h_ = createFragmentNode;
95
- exports.cm_ = beginFragmentNode;
95
+ exports.cw_ = beginFragmentNode;
@@ -37,6 +37,6 @@ function removeChild(node) {
37
37
 
38
38
  exports.bc_ = insertBefore;
39
39
  exports.bd_ = insertAfter;
40
- exports.ch_ = nextSibling;
40
+ exports.cr_ = nextSibling;
41
41
  exports.ay_ = firstChild;
42
42
  exports.be_ = removeChild;
@@ -8,11 +8,11 @@ var normalizeComponentKey = componentsUtil._R_;
8
8
  var domData = require("../../components/dom-data");
9
9
  var eventDelegation = require("../../components/event-delegation");
10
10
  var KeySequence = require("../../components/KeySequence");
11
- var VElement = require("../vdom").br_;
11
+ var VElement = require("../vdom").bC_;
12
12
  var fragment = require("./fragment");
13
13
  var helpers = require("./helpers");
14
- var virtualizeElement = VElement.cc_;
15
- var morphAttrs = VElement.cd_;
14
+ var virtualizeElement = VElement.cm_;
15
+ var morphAttrs = VElement.cn_;
16
16
  var keysByDOMNode = domData._G_;
17
17
  var componentByDOMNode = domData._l_;
18
18
  var vElementByDOMNode = domData._H_;
@@ -20,11 +20,11 @@ var detachedByDOMNode = domData.aT_;
20
20
 
21
21
  var insertBefore = helpers.bc_;
22
22
  var insertAfter = helpers.bd_;
23
- var nextSibling = helpers.ch_;
23
+ var nextSibling = helpers.cr_;
24
24
  var firstChild = helpers.ay_;
25
25
  var removeChild = helpers.be_;
26
26
  var createFragmentNode = fragment._h_;
27
- var beginFragmentNode = fragment.cm_;
27
+ var beginFragmentNode = fragment.cw_;
28
28
 
29
29
  var ELEMENT_NODE = 1;
30
30
  var TEXT_NODE = 3;
@@ -42,7 +42,7 @@ function isAutoKey(key) {
42
42
  }
43
43
 
44
44
  function compareNodeNames(fromEl, toEl) {
45
- return fromEl.bY_ === toEl.bY_;
45
+ return fromEl.ch_ === toEl.ch_;
46
46
  }
47
47
 
48
48
  function caseInsensitiveCompare(a, b) {
@@ -73,12 +73,12 @@ function morphdom(fromNode, toNode, host, componentsContext) {
73
73
  ownerComponent,
74
74
  parentComponent)
75
75
  {
76
- var realNode = vNode.bP_(host, parentEl.namespaceURI);
76
+ var realNode = vNode.bo_(host, parentEl.namespaceURI);
77
77
  insertBefore(realNode, referenceEl, parentEl);
78
78
 
79
79
  if (
80
- vNode.bS_ === ELEMENT_NODE ||
81
- vNode.bS_ === FRAGMENT_NODE)
80
+ vNode.cb_ === ELEMENT_NODE ||
81
+ vNode.cb_ === FRAGMENT_NODE)
82
82
  {
83
83
  if (key) {
84
84
  keysByDOMNode.set(realNode, key);
@@ -87,7 +87,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
87
87
  realNode;
88
88
  }
89
89
 
90
- if (vNode.bY_ !== "textarea") {
90
+ if (vNode.ch_ !== "textarea") {
91
91
  morphChildren(realNode, vNode, parentComponent);
92
92
  }
93
93
 
@@ -161,9 +161,9 @@ function morphdom(fromNode, toNode, host, componentsContext) {
161
161
  var fromComponent;
162
162
 
163
163
  outer: while (curToNodeChild) {
164
- toNextSibling = curToNodeChild.ch_;
165
- curToNodeType = curToNodeChild.bS_;
166
- curToNodeKey = curToNodeChild.bR_;
164
+ toNextSibling = curToNodeChild.cr_;
165
+ curToNodeType = curToNodeChild.cb_;
166
+ curToNodeKey = curToNodeChild.ca_;
167
167
 
168
168
  // Skip <!doctype>
169
169
  if (curFromNodeChild && curFromNodeChild.nodeType === DOCTYPE_NODE) {
@@ -282,7 +282,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
282
282
 
283
283
  if (
284
284
  curVFromNodeChild &&
285
- curToNodeType === curVFromNodeChild.bS_ && (
285
+ curToNodeType === curVFromNodeChild.cb_ && (
286
286
  curToNodeType !== ELEMENT_NODE ||
287
287
  compareNodeNames(curToNodeChild, curVFromNodeChild)))
288
288
  {
@@ -327,11 +327,11 @@ function morphdom(fromNode, toNode, host, componentsContext) {
327
327
  curToNodeChild.aa_ ||
328
328
  caseInsensitiveCompare(
329
329
  curFromNodeChild.nodeName,
330
- curToNodeChild.bY_ || ""
330
+ curToNodeChild.ch_ || ""
331
331
  )))
332
332
  {
333
333
  curVFromNodeChild = virtualizeElement(curFromNodeChild);
334
- curVFromNodeChild.bY_ = curToNodeChild.bY_;
334
+ curVFromNodeChild.ch_ = curToNodeChild.ch_;
335
335
  keysByDOMNode.set(curFromNodeChild, curToNodeKey);
336
336
  referenceComponent.J_[curToNodeKey] =
337
337
  curFromNodeChild;
@@ -351,7 +351,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
351
351
  curFromNodeChild = fromNextSibling;
352
352
  continue;
353
353
  } else if (
354
- curToNodeChild.bS_ === FRAGMENT_NODE &&
354
+ curToNodeChild.cb_ === FRAGMENT_NODE &&
355
355
  curFromNodeChild.nodeType === COMMENT_NODE)
356
356
  {
357
357
  var content = curFromNodeChild.nodeValue;
@@ -418,7 +418,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
418
418
 
419
419
  if (
420
420
  curVFromNodeChild &&
421
- curToNodeType === curVFromNodeChild.bS_ && (
421
+ curToNodeType === curVFromNodeChild.cb_ && (
422
422
  curToNodeType !== ELEMENT_NODE ||
423
423
  compareNodeNames(curVFromNodeChild, curToNodeChild)))
424
424
  {
@@ -436,7 +436,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
436
436
 
437
437
  if (
438
438
  toNextSibling &&
439
- toNextSibling.bR_ === curFromNodeKey)
439
+ toNextSibling.ca_ === curFromNodeKey)
440
440
  {
441
441
  // Single element swap
442
442
 
@@ -549,18 +549,18 @@ function morphdom(fromNode, toNode, host, componentsContext) {
549
549
 
550
550
  if (
551
551
  caseInsensitiveCompare(
552
- curVFromNodeChild.bY_,
553
- curToNodeChild.bY_
552
+ curVFromNodeChild.ch_,
553
+ curToNodeChild.ch_
554
554
  ))
555
555
  {
556
- curVFromNodeChild.bY_ = curToNodeChild.bY_;
556
+ curVFromNodeChild.ch_ = curToNodeChild.ch_;
557
557
  }
558
558
  } else {
559
559
  // Skip over nodes that don't look like ours...
560
560
  curFromNodeChild = fromNextSibling;
561
561
  continue;
562
562
  }
563
- } else if (curFromNodeKey = curVFromNodeChild.bR_) {
563
+ } else if (curFromNodeKey = curVFromNodeChild.ca_) {
564
564
  // We have a keyed element here but our target VDOM node
565
565
  // is not keyed so this not doesn't belong
566
566
  isCompatible = false;
@@ -587,7 +587,7 @@ function morphdom(fromNode, toNode, host, componentsContext) {
587
587
  {
588
588
  // Both nodes being compared are Text or Comment nodes
589
589
  isCompatible = true;
590
- var curToNodeValue = curToNodeChild.cj_;
590
+ var curToNodeValue = curToNodeChild.ct_;
591
591
  var curFromNodeValue = curFromNodeChild.nodeValue;
592
592
  if (curFromNodeValue !== curToNodeValue) {
593
593
  if (
@@ -638,10 +638,10 @@ function morphdom(fromNode, toNode, host, componentsContext) {
638
638
  }
639
639
 
640
640
  // We have processed all of the "to nodes".
641
- if (fromNode.cl_) {
641
+ if (fromNode.cv_) {
642
642
  // If we are in an unfinished fragment, we have reached the end of the nodes
643
643
  // we were matching up and need to end the fragment
644
- fromNode.cl_(curFromNodeChild);
644
+ fromNode.cv_(curFromNodeChild);
645
645
  } else {
646
646
  // If curFromNodeChild is non-null then we still have some from nodes
647
647
  // left over that need to be removed
@@ -681,11 +681,11 @@ function morphdom(fromNode, toNode, host, componentsContext) {
681
681
  }
682
682
 
683
683
  function morphEl(fromEl, vFromEl, toEl, parentComponent) {
684
- var nodeName = toEl.bY_;
685
- var constId = toEl.c__;
684
+ var nodeName = toEl.ch_;
685
+ var constId = toEl.cj_;
686
686
  vElementByDOMNode.set(fromEl, toEl);
687
687
 
688
- if (constId !== undefined && vFromEl.c__ === constId) {
688
+ if (constId !== undefined && vFromEl.cj_ === constId) {
689
689
  return;
690
690
  }
691
691
 
@@ -696,8 +696,8 @@ function morphdom(fromNode, toNode, host, componentsContext) {
696
696
  }
697
697
 
698
698
  if (nodeName === "textarea") {
699
- var newValue = toEl.bZ_ || "";
700
- var oldValue = vFromEl.bZ_ || "";
699
+ var newValue = toEl.ci_ || "";
700
+ var oldValue = vFromEl.ci_ || "";
701
701
  if (oldValue !== newValue) {
702
702
  fromEl.value = newValue;
703
703
  }
@@ -11,7 +11,7 @@ var specialHtmlRegexp = /[&<]/;
11
11
  function virtualizeChildNodes(node, vdomParent, ownerComponent) {
12
12
  var curChild = node.firstChild;
13
13
  while (curChild) {
14
- vdomParent.bI_(virtualize(curChild, ownerComponent));
14
+ vdomParent.bT_(virtualize(curChild, ownerComponent));
15
15
  curChild = curChild.nextSibling;
16
16
  }
17
17
  }
@@ -19,7 +19,7 @@ function virtualizeChildNodes(node, vdomParent, ownerComponent) {
19
19
  function virtualize(node, ownerComponent) {
20
20
  switch (node.nodeType) {
21
21
  case 1:
22
- return VElement.cc_(node, virtualizeChildNodes, ownerComponent);
22
+ return VElement.cm_(node, virtualizeChildNodes, ownerComponent);
23
23
  case 3:
24
24
  return new VText(node.nodeValue, ownerComponent);
25
25
  case 11:
@@ -38,7 +38,7 @@ function virtualizeHTML(html, ownerComponent) {
38
38
  var curChild = parseHTML(html);
39
39
 
40
40
  while (curChild) {
41
- vdomFragment.bI_(virtualize(curChild, ownerComponent));
41
+ vdomFragment.bT_(virtualize(curChild, ownerComponent));
42
42
  curChild = curChild.nextSibling;
43
43
  }
44
44
 
@@ -65,18 +65,18 @@ Node_prototype.t = function (value) {
65
65
  }
66
66
  }
67
67
 
68
- this.bI_(vdomNode || new VText(value.toString()));
69
- return this.ca_();
68
+ this.bT_(vdomNode || new VText(value.toString()));
69
+ return this.ck_();
70
70
  };
71
71
 
72
- Node_prototype.bN_ = function () {
73
- return this.bI_(new VDocumentFragment());
72
+ Node_prototype.bY_ = function () {
73
+ return this.bT_(new VDocumentFragment());
74
74
  };
75
75
 
76
- exports.bs_ = VDocumentFragment;
77
- exports.br_ = VElement;
78
- exports.bt_ = VText;
79
- exports.bu_ = VComponent;
80
- exports.bv_ = VFragment;
81
- exports.cc_ = virtualize;
82
- exports.bw_ = virtualizeHTML;
76
+ exports.bD_ = VDocumentFragment;
77
+ exports.bC_ = VElement;
78
+ exports.bE_ = VText;
79
+ exports.bF_ = VComponent;
80
+ exports.bG_ = VFragment;
81
+ exports.cm_ = virtualize;
82
+ exports.bH_ = virtualizeHTML;
package/docs/compiler.md CHANGED
@@ -463,4 +463,4 @@ For full definitions, view the source code for Babel and Marko:
463
463
 
464
464
  - [Babel’s Core Definitions](https://github.com/babel/babel/blob/master/packages/babel-types/src/definitions/core.js)
465
465
  - [Babel’s Extended Definitions](https://github.com/babel/babel/tree/master/packages/babel-types/src/definitions)
466
- - [Marko’s Definitions](https://github.com/marko-js/marko/blob/master/packages/compiler/src/babel-types/types/definitions.js)
466
+ - [Marko’s Definitions](https://github.com/marko-js/marko/blob/main/packages/compiler/src/babel-types/types/definitions.js)
package/index.d.ts CHANGED
@@ -95,14 +95,12 @@ declare global {
95
95
  | string;
96
96
 
97
97
  /** Extract the return tag type from a renderBody. */
98
- export type BodyReturnType<B> = B extends Body<any, infer Return>
99
- ? Return
100
- : never;
98
+ export type BodyReturnType<B> =
99
+ B extends Body<any, infer Return> ? Return : never;
101
100
 
102
101
  /** Extract the tag parameter types received by a renderBody. */
103
- export type BodyParameters<B> = B extends Body<infer Params, any>
104
- ? Params
105
- : never;
102
+ export type BodyParameters<B> =
103
+ B extends Body<infer Params, any> ? Params : never;
106
104
 
107
105
  export class Component<Input = unknown, State = unknown>
108
106
  implements Emitter