marko 5.39.30 → 5.39.31

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.
@@ -39,29 +39,39 @@ exports.p = function (htmlCompat) {
39
39
  const { classAPI, tagsAPI } = writers;
40
40
  let scripts = "";
41
41
  let componentDefs = flushDefs;
42
+ let chunk;
42
43
 
43
44
  if (classAPI.length) {
44
45
  componentDefs = flushDefs ? flushDefs.concat(classAPI) : classAPI;
45
46
  writers.classAPI = [];
46
47
  }
47
48
 
49
+ if (tagsAPI.length) {
50
+ chunk = tagsAPI[0];
51
+ for (let i = 1; i < tagsAPI.length; i++) {
52
+ chunk.append(tagsAPI[i]);
53
+ }
54
+ writers.tagsAPI = [];
55
+ }
56
+
48
57
  if (componentDefs?.length) {
49
- scripts = _h_($global, componentDefs);
58
+ const initComponents = () =>
59
+ _h_($global, componentDefs);
60
+ // Serializing a bridged handler registers the tags scope it closes over,
61
+ // so it must run against the chunk carrying this flush's resume scripts.
62
+ scripts = chunk ?
63
+ htmlCompat.withChunk(chunk, initComponents) :
64
+ initComponents();
50
65
  if (scripts) {
51
66
  htmlCompat.ensureState($global).walkOnNextFlush = true;
52
67
 
53
- if (!tagsAPI.length) {
68
+ if (!chunk) {
54
69
  scripts = concatScripts(htmlCompat.flushScript($global), scripts);
55
70
  }
56
71
  }
57
72
  }
58
73
 
59
- if (tagsAPI.length) {
60
- const [chunk] = tagsAPI;
61
- for (let i = 1; i < tagsAPI.length; i++) {
62
- chunk.append(tagsAPI[i]);
63
- }
64
-
74
+ if (chunk) {
65
75
  chunk.boundary.flush();
66
76
  if (chunk.boundary.count) {
67
77
  throw new Error(
@@ -70,7 +80,6 @@ exports.p = function (htmlCompat) {
70
80
  }
71
81
 
72
82
  scripts = concatScripts(chunk.flushScript().scripts, scripts);
73
- writers.tagsAPI = [];
74
83
  }
75
84
 
76
85
  return scripts;
@@ -93,9 +102,8 @@ exports.p = function (htmlCompat) {
93
102
 
94
103
  return (input, out) => {
95
104
  if (!tagsRenderer && renderBody) {
96
- renderBody.toJSON = htmlCompat.toJSON(
97
- htmlCompat.ensureState(out.global)
98
- );
105
+ htmlCompat.ensureState(out.global);
106
+ renderBody.toJSON = htmlCompat.toJSON();
99
107
  }
100
108
  TagsCompat(
101
109
  args ?
@@ -128,6 +136,7 @@ exports.p = function (htmlCompat) {
128
136
  const tagsRenderer = _.r;
129
137
  const willRerender = componentDef._wrr || htmlCompat.isInResumedBranch();
130
138
  out.bf("1", component, willRerender);
139
+ htmlCompat.registerClassFunctions(input);
131
140
  // A split parent won't re-feed the child a live handler at hydration, so
132
141
  // register the child scope to let the resolver revive a bridged marker.
133
142
  htmlCompat.render(
@@ -173,7 +182,7 @@ exports.p = function (htmlCompat) {
173
182
  return (input, ...args) => {
174
183
  // tags to class
175
184
  const $global = htmlCompat.$global();
176
- const state = htmlCompat.ensureState($global);
185
+ htmlCompat.ensureState($global);
177
186
  const out = defaultCreateOut($global);
178
187
  const branchId = htmlCompat.nextScopeId();
179
188
  let forceBoundary = boundaryModeByRenderer.get(tag);
@@ -192,7 +201,7 @@ exports.p = function (htmlCompat) {
192
201
  value]
193
202
  );
194
203
  forceBoundary = true;
195
- value.toJSON = htmlCompat.toJSON(state);
204
+ value.toJSON = htmlCompat.toJSON();
196
205
  } else {
197
206
  input[key === "content" ? "renderBody" : key] = value;
198
207
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.39.30",
3
+ "version": "5.39.31",
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.41.10",
71
- "@marko/runtime-tags": "^6.3.26",
70
+ "@marko/compiler": "^5.41.17",
71
+ "@marko/runtime-tags": "^6.3.33",
72
72
  "app-module-path": "^2.2.0",
73
73
  "argly": "^1.2.0",
74
74
  "browser-refresh-client": "1.1.4",
@@ -85,7 +85,7 @@
85
85
  "warp10": "^2.1.0"
86
86
  },
87
87
  "devDependencies": {
88
- "marko": "5.39.30"
88
+ "marko": "5.39.31"
89
89
  },
90
90
  "engines": {
91
91
  "node": ">=22"
@@ -39,29 +39,39 @@ exports.p = function (htmlCompat) {
39
39
  const { classAPI, tagsAPI } = writers;
40
40
  let scripts = "";
41
41
  let componentDefs = flushDefs;
42
+ let chunk;
42
43
 
43
44
  if (classAPI.length) {
44
45
  componentDefs = flushDefs ? flushDefs.concat(classAPI) : classAPI;
45
46
  writers.classAPI = [];
46
47
  }
47
48
 
49
+ if (tagsAPI.length) {
50
+ chunk = tagsAPI[0];
51
+ for (let i = 1; i < tagsAPI.length; i++) {
52
+ chunk.append(tagsAPI[i]);
53
+ }
54
+ writers.tagsAPI = [];
55
+ }
56
+
48
57
  if (componentDefs?.length) {
49
- scripts = ___getInitComponentsCodeForDefs($global, componentDefs);
58
+ const initComponents = () =>
59
+ ___getInitComponentsCodeForDefs($global, componentDefs);
60
+ // Serializing a bridged handler registers the tags scope it closes over,
61
+ // so it must run against the chunk carrying this flush's resume scripts.
62
+ scripts = chunk
63
+ ? htmlCompat.withChunk(chunk, initComponents)
64
+ : initComponents();
50
65
  if (scripts) {
51
66
  htmlCompat.ensureState($global).walkOnNextFlush = true;
52
67
 
53
- if (!tagsAPI.length) {
68
+ if (!chunk) {
54
69
  scripts = concatScripts(htmlCompat.flushScript($global), scripts);
55
70
  }
56
71
  }
57
72
  }
58
73
 
59
- if (tagsAPI.length) {
60
- const [chunk] = tagsAPI;
61
- for (let i = 1; i < tagsAPI.length; i++) {
62
- chunk.append(tagsAPI[i]);
63
- }
64
-
74
+ if (chunk) {
65
75
  chunk.boundary.flush();
66
76
  if (chunk.boundary.count) {
67
77
  throw new Error(
@@ -70,7 +80,6 @@ exports.p = function (htmlCompat) {
70
80
  }
71
81
 
72
82
  scripts = concatScripts(chunk.flushScript().scripts, scripts);
73
- writers.tagsAPI = [];
74
83
  }
75
84
 
76
85
  return scripts;
@@ -93,9 +102,8 @@ exports.p = function (htmlCompat) {
93
102
 
94
103
  return (input, out) => {
95
104
  if (!tagsRenderer && renderBody) {
96
- renderBody.toJSON = htmlCompat.toJSON(
97
- htmlCompat.ensureState(out.global),
98
- );
105
+ htmlCompat.ensureState(out.global);
106
+ renderBody.toJSON = htmlCompat.toJSON();
99
107
  }
100
108
  TagsCompat(
101
109
  args
@@ -128,6 +136,7 @@ exports.p = function (htmlCompat) {
128
136
  const tagsRenderer = _.r;
129
137
  const willRerender = componentDef._wrr || htmlCompat.isInResumedBranch();
130
138
  out.bf("1", component, willRerender);
139
+ htmlCompat.registerClassFunctions(input);
131
140
  // A split parent won't re-feed the child a live handler at hydration, so
132
141
  // register the child scope to let the resolver revive a bridged marker.
133
142
  htmlCompat.render(
@@ -173,7 +182,7 @@ exports.p = function (htmlCompat) {
173
182
  return (input, ...args) => {
174
183
  // tags to class
175
184
  const $global = htmlCompat.$global();
176
- const state = htmlCompat.ensureState($global);
185
+ htmlCompat.ensureState($global);
177
186
  const out = defaultCreateOut($global);
178
187
  const branchId = htmlCompat.nextScopeId();
179
188
  let forceBoundary = boundaryModeByRenderer.get(tag);
@@ -192,7 +201,7 @@ exports.p = function (htmlCompat) {
192
201
  value,
193
202
  ]);
194
203
  forceBoundary = true;
195
- value.toJSON = htmlCompat.toJSON(state);
204
+ value.toJSON = htmlCompat.toJSON();
196
205
  } else {
197
206
  input[key === "content" ? "renderBody" : key] = value;
198
207
  }