@marko/compiler 5.38.3 → 5.38.5

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.
@@ -1,4 +1,4 @@
1
- "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = void 0;exports.getMarkoFile = getMarkoFile;var _traverse = require("@babel/traverse");
1
+ "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = void 0;exports.getMarkoFile = getMarkoFile;var _traverse = _interopRequireDefault(require("@babel/traverse"));
2
2
  var _babelUtils = require("@marko/babel-utils");
3
3
  var _crypto = require("crypto");
4
4
  var _path = _interopRequireDefault(require("path"));
@@ -358,27 +358,23 @@ function mergeVisitors(all) {
358
358
  if (all.length === 1) {
359
359
  all = all[0];
360
360
  } else {
361
- return _traverse.visitors.merge(all);
361
+ return _traverse.default.visitors.merge(all);
362
362
  }
363
363
  }
364
364
 
365
- return _traverse.visitors.explode(all);
365
+ return _traverse.default.visitors.explode(all);
366
366
  }
367
367
 
368
368
  function traverseAll(file, visitors) {
369
369
  const program = file.path;
370
- const { Program, ...mergedVisitors } = mergeVisitors(visitors);
371
- program.state = {};
372
-
373
- // Traverse only walks into children by default
374
- // This manually traverses into the Program node as well.
375
- if (!(Program && Program.enter && program._call(Program.enter))) {
376
- program.traverse(mergedVisitors, program.state);
377
-
378
- if (Program && Program.exit) {
379
- program._call(Program.exit);
380
- }
381
- }
370
+ (0, _traverse.default)(
371
+ program.node,
372
+ mergeVisitors(visitors),
373
+ program.scope,
374
+ program.state = {},
375
+ program,
376
+ true
377
+ );
382
378
  }
383
379
 
384
380
  function addPlugin(meta, arr, plugin) {
@@ -136,12 +136,13 @@ Object.assign(_printer.default.prototype, {
136
136
  }
137
137
  },
138
138
  MarkoTagBody(node) {
139
- this.printSequence(node.body, { indent: true });
139
+ this.printSequence(node.body, true);
140
140
  },
141
141
  MarkoTag(node) {
142
142
  const isDynamicTag = !t.isStringLiteral(node.name);
143
143
  const tagName = !isDynamicTag && node.name.value;
144
144
  const rawValue = node.rawValue;
145
+ let bodyOverride;
145
146
 
146
147
  if (
147
148
  tagName === "style" &&
@@ -199,28 +200,37 @@ Object.assign(_printer.default.prototype, {
199
200
  this.token("|");
200
201
  }
201
202
 
202
- if (node.attributes.length) {
203
- if (
204
- !(node.attributes && node.attributes[0] && node.attributes[0].default))
205
- {
203
+ let { attributes } = node;
204
+ if (attributes.length) {
205
+ if (tagName === "script") {
206
+ for (let i = attributes.length; i--;) {
207
+ if (attributes[i].value.fromBody) {
208
+ bodyOverride = attributes[i].value.body.body;
209
+ attributes = toSpliced(attributes, i);
210
+ break;
211
+ }
212
+ }
213
+ }
214
+
215
+ if (!(attributes && attributes[0] && attributes[0].default)) {
206
216
  this.token(" ");
207
217
  }
208
218
 
209
- this.printJoin(node.attributes, { separator: spaceSeparator });
219
+ this.printJoin(attributes, undefined, undefined, spaceSeparator);
210
220
  }
211
221
  }
212
222
 
213
223
  if (_selfClosingTags.default.voidElements.includes(tagName)) {
214
224
  this.token(">");
215
225
  } else if (
216
- !(node.body.body.length || node.attributeTags.length) ||
226
+ !(bodyOverride || node.body.body.length || node.attributeTags.length) ||
217
227
  _selfClosingTags.default.svgElements.includes(tagName))
218
228
  {
219
229
  this.token("/>");
220
230
  } else {
221
231
  this.token(">");
222
232
  this.newline();
223
- this.printSequence(zipAttributeTagsAndBody(node), { indent: true });
233
+ this.printSequence(bodyOverride || zipAttributeTagsAndBody(node), true);
224
234
  this.token("</");
225
235
  if (!isDynamicTag) {
226
236
  this.token(tagName);
@@ -331,4 +341,20 @@ function compareStartLoc(a, b) {
331
341
  a.loc.start.line - b.loc.start.line ||
332
342
  a.loc.start.column - b.loc.start.column);
333
343
 
344
+ }
345
+
346
+ function toSpliced(arr, index) {
347
+ const len = arr.length;
348
+ const result = new Array(len - 1);
349
+ let i = 0;
350
+
351
+ for (; i < index; i++) {
352
+ result[i] = arr[i];
353
+ }
354
+
355
+ for (i++; i < len; i++) {
356
+ result[i - 1] = arr[i];
357
+ }
358
+
359
+ return result;
334
360
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/compiler",
3
- "version": "5.38.3",
3
+ "version": "5.38.5",
4
4
  "description": "Marko template to JS compiler.",
5
5
  "keywords": [
6
6
  "babel",
@@ -57,20 +57,20 @@
57
57
  "dependencies": {
58
58
  "@babel/code-frame": "^7.26.2",
59
59
  "@babel/core": "^7.26.0",
60
- "@babel/generator": "^7.26.2",
61
- "@babel/parser": "^7.26.2",
60
+ "@babel/generator": "^7.26.3",
61
+ "@babel/parser": "^7.26.3",
62
62
  "@babel/plugin-syntax-typescript": "^7.25.9",
63
- "@babel/plugin-transform-modules-commonjs": "^7.25.9",
64
- "@babel/plugin-transform-typescript": "^7.25.9",
63
+ "@babel/plugin-transform-modules-commonjs": "^7.26.3",
64
+ "@babel/plugin-transform-typescript": "^7.26.3",
65
65
  "@babel/runtime": "^7.26.0",
66
- "@babel/traverse": "^7.25.9",
67
- "@babel/types": "^7.26.0",
66
+ "@babel/traverse": "^7.26.4",
67
+ "@babel/types": "^7.26.3",
68
68
  "@luxass/strip-json-comments": "^1.3.2",
69
- "@marko/babel-utils": "^6.6.1",
69
+ "@marko/babel-utils": "^6.6.3",
70
70
  "complain": "^1.6.1",
71
71
  "he": "^1.2.0",
72
- "htmljs-parser": "^5.5.2",
73
- "jsesc": "^3.0.2",
72
+ "htmljs-parser": "^5.5.3",
73
+ "jsesc": "^3.1.0",
74
74
  "kleur": "^4.1.5",
75
75
  "lasso-package-root": "^1.0.1",
76
76
  "raptor-regexp": "^1.0.1",
@@ -80,7 +80,7 @@
80
80
  "source-map-support": "^0.5.21"
81
81
  },
82
82
  "devDependencies": {
83
- "@marko/translator-default": "^6.1.2"
83
+ "@marko/translator-default": "^6.1.3"
84
84
  },
85
85
  "publishConfig": {
86
86
  "access": "public"