marko 5.39.31 → 5.39.32

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.
@@ -178,7 +178,7 @@ exports.p = function (domCompat) {
178
178
  );
179
179
  }
180
180
  host = rootNode.startNode;
181
- domCompat.setScopeNodes(host, rootNode.startNode, rootNode.endNode);
181
+ domCompat.setScopeNodes(scope, rootNode.startNode, rootNode.endNode);
182
182
  }
183
183
  const existingComponent = scope.bs_;
184
184
  const componentsContext = T_(out);
@@ -55,31 +55,29 @@ exports.p = function (htmlCompat) {
55
55
  }
56
56
 
57
57
  if (componentDefs?.length) {
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();
58
+ // Serializing a bridged handler registers a tags scope, so it needs a chunk:
59
+ // this flush's, else the one rendering, else a new one for a direct render.
60
+ const live = chunk || htmlCompat.getChunk();
61
+ const target = live || htmlCompat.createChunk($global);
62
+ scripts = htmlCompat.withChunk(target, () =>
63
+ _h_($global, componentDefs)
64
+ );
65
65
  if (scripts) {
66
66
  htmlCompat.ensureState($global).walkOnNextFlush = true;
67
67
 
68
68
  if (!chunk) {
69
- scripts = concatScripts(htmlCompat.flushScript($global), scripts);
69
+ scripts = concatScripts(
70
+ live ?
71
+ htmlCompat.flushScript($global) :
72
+ htmlCompat.flushScript($global, target),
73
+ scripts
74
+ );
70
75
  }
71
76
  }
72
77
  }
73
78
 
74
79
  if (chunk) {
75
- chunk.boundary.flush();
76
- if (chunk.boundary.count) {
77
- throw new Error(
78
- "Cannot serialize promise across tags/class compat layer."
79
- );
80
- }
81
-
82
- scripts = concatScripts(chunk.flushScript().scripts, scripts);
80
+ scripts = concatScripts(htmlCompat.flushScript($global, chunk), scripts);
83
81
  }
84
82
 
85
83
  return scripts;
@@ -22,6 +22,26 @@ function analyzeLoadImport(importDecl, tagEntry) {
22
22
 
23
23
  if (!loadAttrPath) return;
24
24
 
25
+ const loadImport = getLoadImportConfig(loadAttrPath.get("value"));
26
+
27
+ if ((importDecl.node.importKind || "value") !== "value") {
28
+ throw importDecl.buildCodeFrameError("Invalid load import.");
29
+ }
30
+
31
+ for (const specifier of importDecl.get("specifiers")) {
32
+ if (!_compiler.types.isImportDefaultSpecifier(specifier.node)) {
33
+ throw specifier.buildCodeFrameError(
34
+ "Invalid load import, only a default specifier is allowed."
35
+ );
36
+ }
37
+ }
38
+
39
+ if (!importDecl.node.specifiers.some(_compiler.types.isImportDefaultSpecifier)) {
40
+ throw importDecl.buildCodeFrameError(
41
+ "Invalid load import, a default specifier is required."
42
+ );
43
+ }
44
+
25
45
  // Under hot reload every module is already eagerly loaded, so the lazy facade
26
46
  // buys nothing and its HMR-cached template collides with the real template's
27
47
  // `_` slot, recursing on render (see load-tag-browser.js). Without `linkAssets`
@@ -33,28 +53,13 @@ function analyzeLoadImport(importDecl, tagEntry) {
33
53
  return;
34
54
  }
35
55
 
36
- const loadAttrValuePath = loadAttrPath.get("value");
37
-
38
56
  if (!tagEntry) {
39
57
  throw importDecl.buildCodeFrameError(
40
58
  "Unable to resolve marko file for load import."
41
59
  );
42
60
  }
43
61
 
44
- if ((importDecl.node.importKind || "value") !== "value") {
45
- throw importDecl.buildCodeFrameError("Invalid load import.");
46
- }
47
-
48
- for (const specifier of importDecl.get("specifiers")) {
49
- if (!_compiler.types.isImportDefaultSpecifier(specifier.node)) {
50
- throw specifier.buildCodeFrameError(
51
- "Invalid load import, only a default specifier is allowed."
52
- );
53
- }
54
- }
55
-
56
- (importDecl.node.extra ??= {}).loadImport =
57
- getLoadImportConfig(loadAttrValuePath);
62
+ (importDecl.node.extra ??= {}).loadImport = loadImport;
58
63
  }
59
64
 
60
65
  function translateLoadTag(path, tagName, relativePath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "5.39.31",
3
+ "version": "5.39.32",
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.17",
71
- "@marko/runtime-tags": "^6.3.33",
70
+ "@marko/compiler": "^5.41.18",
71
+ "@marko/runtime-tags": "^6.3.34",
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.31"
88
+ "marko": "5.39.32"
89
89
  },
90
90
  "engines": {
91
91
  "node": ">=22"
@@ -178,7 +178,7 @@ exports.p = function (domCompat) {
178
178
  );
179
179
  }
180
180
  host = rootNode.startNode;
181
- domCompat.setScopeNodes(host, rootNode.startNode, rootNode.endNode);
181
+ domCompat.setScopeNodes(scope, rootNode.startNode, rootNode.endNode);
182
182
  }
183
183
  const existingComponent = scope.___marko5Component;
184
184
  const componentsContext = ___getComponentsContext(out);
@@ -55,31 +55,29 @@ exports.p = function (htmlCompat) {
55
55
  }
56
56
 
57
57
  if (componentDefs?.length) {
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();
58
+ // Serializing a bridged handler registers a tags scope, so it needs a chunk:
59
+ // this flush's, else the one rendering, else a new one for a direct render.
60
+ const live = chunk || htmlCompat.getChunk();
61
+ const target = live || htmlCompat.createChunk($global);
62
+ scripts = htmlCompat.withChunk(target, () =>
63
+ ___getInitComponentsCodeForDefs($global, componentDefs),
64
+ );
65
65
  if (scripts) {
66
66
  htmlCompat.ensureState($global).walkOnNextFlush = true;
67
67
 
68
68
  if (!chunk) {
69
- scripts = concatScripts(htmlCompat.flushScript($global), scripts);
69
+ scripts = concatScripts(
70
+ live
71
+ ? htmlCompat.flushScript($global)
72
+ : htmlCompat.flushScript($global, target),
73
+ scripts,
74
+ );
70
75
  }
71
76
  }
72
77
  }
73
78
 
74
79
  if (chunk) {
75
- chunk.boundary.flush();
76
- if (chunk.boundary.count) {
77
- throw new Error(
78
- "Cannot serialize promise across tags/class compat layer.",
79
- );
80
- }
81
-
82
- scripts = concatScripts(chunk.flushScript().scripts, scripts);
80
+ scripts = concatScripts(htmlCompat.flushScript($global, chunk), scripts);
83
81
  }
84
82
 
85
83
  return scripts;
@@ -22,6 +22,26 @@ export function analyzeLoadImport(importDecl, tagEntry) {
22
22
 
23
23
  if (!loadAttrPath) return;
24
24
 
25
+ const loadImport = getLoadImportConfig(loadAttrPath.get("value"));
26
+
27
+ if ((importDecl.node.importKind || "value") !== "value") {
28
+ throw importDecl.buildCodeFrameError("Invalid load import.");
29
+ }
30
+
31
+ for (const specifier of importDecl.get("specifiers")) {
32
+ if (!t.isImportDefaultSpecifier(specifier.node)) {
33
+ throw specifier.buildCodeFrameError(
34
+ "Invalid load import, only a default specifier is allowed.",
35
+ );
36
+ }
37
+ }
38
+
39
+ if (!importDecl.node.specifiers.some(t.isImportDefaultSpecifier)) {
40
+ throw importDecl.buildCodeFrameError(
41
+ "Invalid load import, a default specifier is required.",
42
+ );
43
+ }
44
+
25
45
  // Under hot reload every module is already eagerly loaded, so the lazy facade
26
46
  // buys nothing and its HMR-cached template collides with the real template's
27
47
  // `_` slot, recursing on render (see load-tag-browser.js). Without `linkAssets`
@@ -33,28 +53,13 @@ export function analyzeLoadImport(importDecl, tagEntry) {
33
53
  return;
34
54
  }
35
55
 
36
- const loadAttrValuePath = loadAttrPath.get("value");
37
-
38
56
  if (!tagEntry) {
39
57
  throw importDecl.buildCodeFrameError(
40
58
  "Unable to resolve marko file for load import.",
41
59
  );
42
60
  }
43
61
 
44
- if ((importDecl.node.importKind || "value") !== "value") {
45
- throw importDecl.buildCodeFrameError("Invalid load import.");
46
- }
47
-
48
- for (const specifier of importDecl.get("specifiers")) {
49
- if (!t.isImportDefaultSpecifier(specifier.node)) {
50
- throw specifier.buildCodeFrameError(
51
- "Invalid load import, only a default specifier is allowed.",
52
- );
53
- }
54
- }
55
-
56
- (importDecl.node.extra ??= {}).loadImport =
57
- getLoadImportConfig(loadAttrValuePath);
62
+ (importDecl.node.extra ??= {}).loadImport = loadImport;
58
63
  }
59
64
 
60
65
  export function translateLoadTag(path, tagName, relativePath) {