marko 5.39.38 → 5.39.39

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 (32) hide show
  1. package/dist/runtime/html/AsyncStream.js +34 -41
  2. package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
  3. package/dist/runtime/html/helpers/attr.js +2 -2
  4. package/dist/runtime/vdom/AsyncVDOMBuilder.js +64 -64
  5. package/dist/runtime/vdom/VComment.js +6 -6
  6. package/dist/runtime/vdom/VComponent.js +3 -3
  7. package/dist/runtime/vdom/VDocumentFragment.js +5 -5
  8. package/dist/runtime/vdom/VElement.js +29 -29
  9. package/dist/runtime/vdom/VFragment.js +4 -4
  10. package/dist/runtime/vdom/VNode.js +29 -29
  11. package/dist/runtime/vdom/VText.js +7 -7
  12. package/dist/runtime/vdom/helpers/const-element.js +3 -3
  13. package/dist/runtime/vdom/hot-reload.js +2 -2
  14. package/dist/runtime/vdom/morphdom/fragment.js +3 -3
  15. package/dist/runtime/vdom/morphdom/helpers.js +1 -1
  16. package/dist/runtime/vdom/morphdom/index.js +33 -33
  17. package/dist/runtime/vdom/vdom.js +15 -15
  18. package/dist/translator/index.js +0 -3
  19. package/dist/translator/util/add-dependencies.js +0 -1
  20. package/dist/translator/util/get-component-files.js +1 -1
  21. package/package.json +4 -4
  22. package/src/runtime/html/AsyncStream.js +34 -41
  23. package/src/translator/index.js +0 -3
  24. package/src/translator/util/add-dependencies.js +0 -1
  25. package/dist/runtime/events.js +0 -2
  26. package/dist/runtime/helpers/assign.js +0 -21
  27. package/dist/runtime/helpers/merge.js +0 -13
  28. package/dist/runtime/html/helpers/props-script.js +0 -30
  29. package/src/runtime/events.js +0 -2
  30. package/src/runtime/helpers/assign.js +0 -21
  31. package/src/runtime/helpers/merge.js +0 -13
  32. package/src/runtime/html/helpers/props-script.js +0 -30
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _escapeRegexp = require("./escape-regexp");function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}
4
4
 
5
- const COMPONENT_FILES_KEY = "cw_";
5
+ const COMPONENT_FILES_KEY = "cx_";
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.39.38",
3
+ "version": "5.39.39",
4
4
  "private": false,
5
5
  "description": "UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.",
6
6
  "keywords": [
@@ -67,8 +67,8 @@
67
67
  },
68
68
  "types": "index.d.ts",
69
69
  "dependencies": {
70
- "@marko/compiler": "^5.42.3",
71
- "@marko/runtime-tags": "^6.3.46",
70
+ "@marko/compiler": "^5.42.4",
71
+ "@marko/runtime-tags": "^6.3.49",
72
72
  "app-module-path": "^2.2.0",
73
73
  "argly": "^1.2.0",
74
74
  "browser-refresh-client": "1.1.4",
@@ -84,7 +84,7 @@
84
84
  "warp10": "^2.1.0"
85
85
  },
86
86
  "devDependencies": {
87
- "marko": "5.39.38"
87
+ "marko": "5.39.39"
88
88
  },
89
89
  "engines": {
90
90
  "node": ">=22"
@@ -2,7 +2,6 @@
2
2
  var EventEmitter = require("events-light");
3
3
  var selfClosingTags = require("self-closing-tags");
4
4
  var RenderResult = require("../RenderResult");
5
- var parseHTML = require("../vdom/parse-html");
6
5
  var BufferedWriter = require("./BufferedWriter");
7
6
  var attrsHelper = require("./helpers/attrs");
8
7
  var markoAttr = require("./helpers/data-marko");
@@ -96,8 +95,6 @@ function AsyncStream(global, writer, parentOut) {
96
95
  this.name = undefined;
97
96
  this._timeoutId = undefined;
98
97
 
99
- this._node = undefined;
100
-
101
98
  this._elStack = undefined; // Array
102
99
 
103
100
  this.___components = null; // ComponentsContext
@@ -125,7 +122,6 @@ AsyncStream.enableAsyncStackTrace = function () {
125
122
 
126
123
  var proto = (AsyncStream.prototype = {
127
124
  constructor: AsyncStream,
128
- ___host: typeof document === "object" && document,
129
125
  ___isOut: true,
130
126
 
131
127
  [Symbol.asyncIterator]() {
@@ -136,6 +132,7 @@ var proto = (AsyncStream.prototype = {
136
132
  const originalWriter = this._state.writer;
137
133
  let buffer = "";
138
134
  let iteratorNextFn;
135
+ let iteratorReturnFn = defaultIteratorReturn;
139
136
 
140
137
  if (!originalWriter.stream) {
141
138
  // Writing has finished completely so we can use a simple iterator
@@ -151,7 +148,7 @@ var proto = (AsyncStream.prototype = {
151
148
  let pending;
152
149
  const stream = {
153
150
  write(data) {
154
- buffer += data;
151
+ if (!done) buffer += data;
155
152
  },
156
153
  end() {
157
154
  done = true;
@@ -220,6 +217,20 @@ var proto = (AsyncStream.prototype = {
220
217
 
221
218
  return pending.promise;
222
219
  };
220
+
221
+ // The last consumer to leave is still waiting on `pending`, which only a
222
+ // later write would settle; end the iteration instead of hanging on it.
223
+ iteratorReturnFn = (value) => {
224
+ done = true;
225
+ buffer = "";
226
+
227
+ if (pending) {
228
+ pending.resolve({ value: undefined, done: true });
229
+ pending = undefined;
230
+ }
231
+
232
+ return defaultIteratorReturn(value);
233
+ };
223
234
  }
224
235
 
225
236
  return (this.___iterator = {
@@ -234,15 +245,23 @@ var proto = (AsyncStream.prototype = {
234
245
 
235
246
  toReadable() {
236
247
  let cancelled = false;
248
+ this.___readers = (this.___readers || 0) + 1;
237
249
  return new ReadableStream({
238
250
  start: async (ctrl) => {
239
251
  const encoder = new TextEncoder();
252
+ const iterator = this[Symbol.asyncIterator]();
240
253
  try {
241
- for await (const chunk of this) {
254
+ for (;;) {
255
+ // Read by hand: `for await` would close the shared iterator on the
256
+ // way out, ending the consumers still reading it.
257
+ const result = await iterator.next();
242
258
  if (cancelled) {
243
259
  return;
244
260
  }
245
- ctrl.enqueue(encoder.encode(chunk));
261
+ if (result.done) {
262
+ break;
263
+ }
264
+ ctrl.enqueue(encoder.encode(result.value));
246
265
  }
247
266
  ctrl.close();
248
267
  } catch (err) {
@@ -251,8 +270,14 @@ var proto = (AsyncStream.prototype = {
251
270
  }
252
271
  }
253
272
  },
254
- cancel() {
273
+ cancel: () => {
255
274
  cancelled = true;
275
+
276
+ // Every consumer shares one iterator, so only the last one out may end
277
+ // it; the others are still reading.
278
+ if (!--this.___readers) {
279
+ this[Symbol.asyncIterator]().return();
280
+ }
256
281
  },
257
282
  });
258
283
  },
@@ -750,38 +775,6 @@ var proto = (AsyncStream.prototype = {
750
775
  }
751
776
  },
752
777
 
753
- ___getNode: function (host) {
754
- var node = this._node;
755
-
756
- if (!node) {
757
- var nextEl;
758
- var fragment;
759
- var html = this.___getOutput();
760
- if (!host) host = this.___host;
761
- var doc = host.ownerDocument || host;
762
-
763
- if (html) {
764
- node = parseHTML(html);
765
-
766
- if (node && node.nextSibling) {
767
- // If there are multiple nodes, turn it into a document fragment.
768
- fragment = doc.createDocumentFragment();
769
-
770
- do {
771
- nextEl = node.nextSibling;
772
- fragment.appendChild(node);
773
- } while ((node = nextEl));
774
-
775
- node = fragment;
776
- }
777
- }
778
-
779
- // if HTML is empty use empty document fragment (so that we're returning a valid DOM node)
780
- this._node = node || doc.createDocumentFragment();
781
- }
782
- return node;
783
- },
784
-
785
778
  then: function (fn, fnErr) {
786
779
  // eslint-disable-next-line @typescript-eslint/no-this-alias
787
780
  var out = this;
@@ -823,7 +816,7 @@ function getNonMarkoStack(error) {
823
816
  .join("\n");
824
817
  }
825
818
 
826
- function iteratorReturnFn(value) {
819
+ function defaultIteratorReturn(value) {
827
820
  return Promise.resolve({
828
821
  value,
829
822
  done: true,
@@ -659,12 +659,10 @@ export function getRuntimeEntryFiles(output, optimize) {
659
659
  `${base}runtime/components/renderer.js`,
660
660
  `${base}runtime/components/registry.js`,
661
661
  `${base}runtime/components/attach-detach.js`,
662
- `${base}runtime/helpers/assign.js`,
663
662
  `${base}runtime/helpers/class-value.js`,
664
663
  `${base}runtime/helpers/of-fallback.js`,
665
664
  `${base}runtime/helpers/dynamic-tag.js`,
666
665
  `${base}runtime/helpers/attr-tag.js`,
667
- `${base}runtime/helpers/merge.js`,
668
666
  `${base}runtime/helpers/render-tag.js`,
669
667
  `${base}runtime/helpers/style-value.js`,
670
668
  `${base}runtime/helpers/to-string.js`,
@@ -682,7 +680,6 @@ export function getRuntimeEntryFiles(output, optimize) {
682
680
  `${base}runtime/html/helpers/escape-style-placeholder.js`,
683
681
  `${base}runtime/html/helpers/escape-xml.js`,
684
682
  `${base}runtime/html/helpers/merge-attrs.js`,
685
- `${base}runtime/html/helpers/props-script.js`,
686
683
  `${base}runtime/html/helpers/style-attr.js`,
687
684
  `${base}core-tags/components/init-components-tag.js`,
688
685
  `${base}core-tags/components/preferred-script-location-tag.js`,
@@ -115,7 +115,6 @@ export const entryBuilder = {
115
115
 
116
116
  if (fileMeta.implicitSplitComponent) {
117
117
  state.hasComponents = true;
118
- return;
119
118
  }
120
119
 
121
120
  if (fileMeta.component) {
@@ -1,2 +0,0 @@
1
- "use strict";var EventEmitter = require("events-light");
2
- module.exports = new EventEmitter();
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- var hasOwnProperty = Object.prototype.hasOwnProperty;
4
-
5
- /**
6
- * Merges object properties
7
- */
8
- module.exports = function assign() {
9
- var into = arguments[0];
10
- for (var i = 1; i < arguments.length; i++) {
11
- var source = arguments[i];
12
- if (source != null) {
13
- for (var k in source) {
14
- if (hasOwnProperty.call(source, k)) {
15
- into[k] = source[k];
16
- }
17
- }
18
- }
19
- }
20
- return into;
21
- };
@@ -1,13 +0,0 @@
1
- "use strict";var hasOwnProperty = Object.prototype.hasOwnProperty;
2
-
3
- /**
4
- * Merges object properties
5
- */
6
- module.exports = function merge(into, source) {
7
- for (var k in source) {
8
- if (hasOwnProperty.call(source, k) && !hasOwnProperty.call(into, k)) {
9
- into[k] = source[k];
10
- }
11
- }
12
- return into;
13
- };
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- var attrAssignment = require("./attr").a;
4
- var escapeScript = require("./escape-script-placeholder");
5
- var assignPropsFunction = `
6
- function ap_(p) {
7
- var s = document.currentScript;
8
- var ps = s.previousSibling;
9
- for (var k in p) ps[k] = p[k];
10
- s.parentNode.removeChild(s);
11
- }
12
- `.
13
- replace(/\s+/g, " ").
14
- replace(/([\W]) (.)/g, "$1$2").
15
- replace(/(.) ([\W])/g, "$1$2").
16
- trim();
17
-
18
- module.exports = function propsForPreviousNode(props, out) {
19
- var cspNonce = out.global.cspNonce;
20
- var nonceAttr = cspNonce ? " nonce" + attrAssignment(cspNonce) : "";
21
-
22
- out.w("<script" + nonceAttr + ">");
23
-
24
- if (!out.global.assignPropsFunction) {
25
- out.w(assignPropsFunction);
26
- out.global.assignPropsFunction = true;
27
- }
28
-
29
- out.w("ap_(" + escapeScript(JSON.stringify(props)) + ");</script>");
30
- };
@@ -1,2 +0,0 @@
1
- var EventEmitter = require("events-light");
2
- module.exports = new EventEmitter();
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- var hasOwnProperty = Object.prototype.hasOwnProperty;
4
-
5
- /**
6
- * Merges object properties
7
- */
8
- module.exports = function assign() {
9
- var into = arguments[0];
10
- for (var i = 1; i < arguments.length; i++) {
11
- var source = arguments[i];
12
- if (source != null) {
13
- for (var k in source) {
14
- if (hasOwnProperty.call(source, k)) {
15
- into[k] = source[k];
16
- }
17
- }
18
- }
19
- }
20
- return into;
21
- };
@@ -1,13 +0,0 @@
1
- var hasOwnProperty = Object.prototype.hasOwnProperty;
2
-
3
- /**
4
- * Merges object properties
5
- */
6
- module.exports = function merge(into, source) {
7
- for (var k in source) {
8
- if (hasOwnProperty.call(source, k) && !hasOwnProperty.call(into, k)) {
9
- into[k] = source[k];
10
- }
11
- }
12
- return into;
13
- };
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- var attrAssignment = require("./attr").a;
4
- var escapeScript = require("./escape-script-placeholder");
5
- var assignPropsFunction = `
6
- function ap_(p) {
7
- var s = document.currentScript;
8
- var ps = s.previousSibling;
9
- for (var k in p) ps[k] = p[k];
10
- s.parentNode.removeChild(s);
11
- }
12
- `
13
- .replace(/\s+/g, " ")
14
- .replace(/([\W]) (.)/g, "$1$2")
15
- .replace(/(.) ([\W])/g, "$1$2")
16
- .trim();
17
-
18
- module.exports = function propsForPreviousNode(props, out) {
19
- var cspNonce = out.global.cspNonce;
20
- var nonceAttr = cspNonce ? " nonce" + attrAssignment(cspNonce) : "";
21
-
22
- out.w("<script" + nonceAttr + ">");
23
-
24
- if (!out.global.assignPropsFunction) {
25
- out.w(assignPropsFunction);
26
- out.global.assignPropsFunction = true;
27
- }
28
-
29
- out.w("ap_(" + escapeScript(JSON.stringify(props)) + ");</script>");
30
- };