@marko/translator-default 6.0.11 → 6.0.13

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.
package/dist/index.js CHANGED
@@ -61,18 +61,20 @@ const analyze = exports.analyze = {
61
61
  meta.deps.unshift(styleFile);
62
62
  }
63
63
 
64
- if (meta.hasComponentBrowser) {
65
- meta.component = componentBrowserFile;
66
- } else if (
67
- meta.hasComponent ||
68
- meta.hasStatefulTagParams ||
69
- meta.hasFunctionEventHandlers)
70
- {
71
- meta.component = file.opts.filename;
72
- } else if (meta.hasStringEventHandlers) {
73
- meta.component = componentFiles.componentBrowserFile =
74
- "marko/src/runtime/helpers/empty-component.js";
75
- meta.hasComponentBrowser = true;
64
+ if (!meta.widgetBind) {
65
+ if (meta.hasComponentBrowser) {
66
+ meta.component = componentBrowserFile;
67
+ } else if (
68
+ meta.hasComponent ||
69
+ meta.hasStatefulTagParams ||
70
+ meta.hasFunctionEventHandlers)
71
+ {
72
+ meta.component = file.opts.filename;
73
+ } else if (meta.hasStringEventHandlers) {
74
+ meta.component = componentFiles.componentBrowserFile =
75
+ "marko/src/runtime/helpers/empty-component.js";
76
+ meta.hasComponentBrowser = true;
77
+ }
76
78
  }
77
79
 
78
80
  meta.component =
@@ -123,7 +125,7 @@ const analyze = exports.analyze = {
123
125
  }
124
126
  }
125
127
 
126
- if (!meta.hasFunctionEventHandlers || !meta.hasStringEventHandlers) {
128
+ if (!(meta.hasFunctionEventHandlers || meta.hasStringEventHandlers)) {
127
129
  for (const attr of tag.node.attributes) {
128
130
  if (
129
131
  _compiler.types.isMarkoAttribute(attr) &&
@@ -3,8 +3,11 @@
3
3
 
4
4
 
5
5
 
6
+ var _compiler = require("@marko/compiler");
6
7
 
7
8
  var _htmlOutWrite = _interopRequireDefault(require("../../util/html-out-write"));
9
+ var _vdomOutWrite = _interopRequireDefault(require("../../util/vdom-out-write"));
10
+ var _withPreviousLocation = _interopRequireDefault(require("../../util/with-previous-location"));
8
11
 
9
12
  function enter(path) {
10
13
  (0, _babelUtils.assertNoArgs)(path);
@@ -12,8 +15,38 @@ function enter(path) {
12
15
  (0, _babelUtils.assertNoAttributes)(path);
13
16
 
14
17
  if (path.hub.file.markoOpts.output === "html") {
15
- path.replaceWithMultiple([(0, _htmlOutWrite.default)`<!--`, ...path.node.body.body, (0, _htmlOutWrite.default)`-->`]);
18
+ path.replaceWithMultiple([
19
+ (0, _htmlOutWrite.default)`<!--`,
20
+ ...path.node.body.body,
21
+ (0, _htmlOutWrite.default)`-->`]
22
+ );
16
23
  } else {
17
- path.remove();
24
+ const templateQuasis = [];
25
+ const templateExpressions = [];
26
+ let currentQuasi = "";
27
+ for (const child of path.node.body.body) {
28
+ if (_compiler.types.isMarkoText(child)) {
29
+ currentQuasi += child.value;
30
+ } else if (_compiler.types.isMarkoPlaceholder(child)) {
31
+ templateQuasis.push(_compiler.types.templateElement({ raw: currentQuasi }));
32
+ templateExpressions.push(child.value);
33
+ currentQuasi = "";
34
+ }
35
+ }
36
+
37
+ let value;
38
+ if (templateExpressions.length === 0) {
39
+ value = _compiler.types.stringLiteral(currentQuasi);
40
+ } else {
41
+ templateQuasis.push(_compiler.types.templateElement({ raw: currentQuasi }));
42
+ value = _compiler.types.templateLiteral(templateQuasis, templateExpressions);
43
+ }
44
+
45
+ path.replaceWith(
46
+ (0, _withPreviousLocation.default)(
47
+ (0, _vdomOutWrite.default)("comment", value, path.hub.file._componentInstanceIdentifier),
48
+ path.node
49
+ )
50
+ );
18
51
  }
19
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/translator-default",
3
- "version": "6.0.11",
3
+ "version": "6.0.13",
4
4
  "description": "Translates Marko templates to the default Marko runtime.",
5
5
  "keywords": [
6
6
  "babel",
@@ -29,13 +29,13 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.25.0",
32
- "@marko/babel-utils": "^6.5.5",
32
+ "@marko/babel-utils": "^6.5.6",
33
33
  "magic-string": "^0.30.11",
34
34
  "self-closing-tags": "^1.0.1"
35
35
  },
36
36
  "devDependencies": {
37
- "@marko/compiler": "^5.37.9",
38
- "marko": "^5.35.13"
37
+ "@marko/compiler": "^5.37.11",
38
+ "marko": "^5.35.16"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@marko/compiler": "^5.16.1",