@marko/translator-default 5.31.0 → 5.31.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. package/dist/cdata/index[html].js +5 -5
  2. package/dist/cdata/index[vdom].js +2 -2
  3. package/dist/class.js +21 -21
  4. package/dist/comment/index[html].js +2 -2
  5. package/dist/declaration/index[html].js +2 -2
  6. package/dist/document-type/index[html].js +2 -2
  7. package/dist/index.js +165 -165
  8. package/dist/placeholder/index[html].js +17 -17
  9. package/dist/placeholder/index[vdom].js +5 -5
  10. package/dist/tag/attribute/directives/class.js +12 -12
  11. package/dist/tag/attribute/directives/no-update.js +8 -8
  12. package/dist/tag/attribute/directives/style.js +12 -12
  13. package/dist/tag/attribute/index.js +15 -15
  14. package/dist/tag/attribute/modifiers/scoped.js +11 -11
  15. package/dist/tag/attribute-tag.js +67 -67
  16. package/dist/tag/custom-tag.js +37 -37
  17. package/dist/tag/dynamic-tag.js +29 -29
  18. package/dist/tag/index.js +9 -9
  19. package/dist/tag/native-tag[html]/attributes.js +41 -41
  20. package/dist/tag/native-tag[html]/index.js +67 -67
  21. package/dist/tag/native-tag[vdom]/attributes.js +34 -34
  22. package/dist/tag/native-tag[vdom]/index.js +59 -59
  23. package/dist/tag/util.js +42 -42
  24. package/dist/taglib/core/conditional/translate-else-if.js +2 -2
  25. package/dist/taglib/core/conditional/translate-else.js +2 -2
  26. package/dist/taglib/core/conditional/util.js +5 -5
  27. package/dist/taglib/core/macro/translate.js +9 -9
  28. package/dist/taglib/core/parse-class.js +2 -2
  29. package/dist/taglib/core/transform-style.js +6 -6
  30. package/dist/taglib/core/translate-await.js +11 -11
  31. package/dist/taglib/core/translate-body.js +5 -5
  32. package/dist/taglib/core/translate-for.js +65 -65
  33. package/dist/taglib/core/translate-include-content.js +9 -9
  34. package/dist/taglib/core/translate-while.js +10 -10
  35. package/dist/taglib/migrate/all-templates.js +8 -8
  36. package/dist/text/index[html].js +2 -2
  37. package/dist/text/index[vdom].js +9 -9
  38. package/dist/util/add-dependencies.js +38 -38
  39. package/dist/util/get-component-files.js +2 -2
  40. package/dist/util/html-out-write.js +5 -5
  41. package/dist/util/key-manager.js +27 -27
  42. package/dist/util/optimize-vdom-create.js +31 -31
  43. package/dist/util/vdom-out-write.js +5 -5
  44. package/package.json +3 -3
@@ -10,21 +10,21 @@ const EMPTY_OBJECT = {};var _default =
10
10
  attr.remove();
11
11
  const { node } = tag;
12
12
  const replacement = _compiler.types.markoTag(
13
- _compiler.types.stringLiteral("_preserve"),
14
- [],
15
- opts.bodyOnly ? node.body : _compiler.types.markoTagBody([node]));
16
-
13
+ _compiler.types.stringLiteral("_preserve"),
14
+ [],
15
+ opts.bodyOnly ? node.body : _compiler.types.markoTagBody([node])
16
+ );
17
17
 
18
18
  if ((0, _babelUtils.isNativeTag)(tag)) {
19
19
  replacement.key = node.key;
20
20
  replacement.attributes.push(
21
- _compiler.types.markoAttribute("n", _compiler.types.booleanLiteral(true)));
22
-
21
+ _compiler.types.markoAttribute("n", _compiler.types.booleanLiteral(true))
22
+ );
23
23
 
24
24
  if (opts.bodyOnly) {
25
25
  replacement.attributes.push(
26
- _compiler.types.markoAttribute("b", _compiler.types.booleanLiteral(true)));
27
-
26
+ _compiler.types.markoAttribute("b", _compiler.types.booleanLiteral(true))
27
+ );
28
28
  }
29
29
  } else {
30
30
  replacement.key = (0, _babelUtils.normalizeTemplateString)`p_${node.key}`;
@@ -20,18 +20,18 @@ var _withPreviousLocation = _interopRequireDefault(require("../../../util/with-p
20
20
  }
21
21
  } else {
22
22
  value.replaceWith(
23
- (0, _withPreviousLocation.default)(
24
- _compiler.types.callExpression(
25
- (0, _babelUtils.importDefault)(
26
- file,
27
- "marko/src/runtime/helpers/style-value.js",
28
- "marko_style_merge"),
29
-
30
- [value.node]),
31
-
32
- value.node));
33
-
34
-
23
+ (0, _withPreviousLocation.default)(
24
+ _compiler.types.callExpression(
25
+ (0, _babelUtils.importDefault)(
26
+ file,
27
+ "marko/src/runtime/helpers/style-value.js",
28
+ "marko_style_merge"
29
+ ),
30
+ [value.node]
31
+ ),
32
+ value.node
33
+ )
34
+ );
35
35
  }
36
36
  }
37
37
  };exports.default = _default;
@@ -30,8 +30,8 @@ const attachedDetachedLoaded = new WeakSet();var _default =
30
30
 
31
31
  if (!value.isBooleanLiteral(true)) {
32
32
  throw value.buildCodeFrameError(
33
- `"${name}(handler, ...args)" does not accept a value.`);
34
-
33
+ `"${name}(handler, ...args)" does not accept a value.`
34
+ );
35
35
  }
36
36
 
37
37
  if (!isDash) {
@@ -51,8 +51,8 @@ const attachedDetachedLoaded = new WeakSet();var _default =
51
51
  const handlers = tag.node.handlers = tag.node.handlers || {};
52
52
  if (handlers[eventName]) {
53
53
  throw attr.buildCodeFrameError(
54
- "Duplicate event handlers are not supported.");
55
-
54
+ "Duplicate event handlers are not supported."
55
+ );
56
56
  }
57
57
 
58
58
  handlers[eventName] = {
@@ -66,9 +66,9 @@ const attachedDetachedLoaded = new WeakSet();var _default =
66
66
  // Pull in helper for element attach/detach;
67
67
  attachedDetachedLoaded.add(file);
68
68
  (0, _babelUtils.importDefault)(
69
- file,
70
- "marko/src/runtime/components/attach-detach.js");
71
-
69
+ file,
70
+ "marko/src/runtime/components/attach-detach.js"
71
+ );
72
72
  }
73
73
  }
74
74
  }
@@ -91,23 +91,23 @@ const attachedDetachedLoaded = new WeakSet();var _default =
91
91
  if (tagDef) {
92
92
  if (!tagDef.html && !tagDef.getAttribute(name)) {
93
93
  throw attr.buildCodeFrameError(
94
- `<${
95
- tag.get("name.value").node
96
- }> does not support the "${name}" attribute.`);
97
-
94
+ `<${
95
+ tag.get("name.value").node
96
+ }> does not support the "${name}" attribute.`
97
+ );
98
98
  }
99
99
  }
100
100
 
101
101
  if (args && args.length) {
102
102
  throw attr.buildCodeFrameError(
103
- `Unsupported arguments on the "${name}" attribute.`);
104
-
103
+ `Unsupported arguments on the "${name}" attribute.`
104
+ );
105
105
  }
106
106
 
107
107
  if (attr.node.bound) {
108
108
  throw attr.buildCodeFrameError(
109
- `The binding syntax (:=) is only supported when using the "Tags API".`);
110
-
109
+ `The binding syntax (:=) is only supported when using the "Tags API".`
110
+ );
111
111
  }
112
112
  }
113
113
  };exports.default = _default;
@@ -7,16 +7,16 @@ var _withPreviousLocation = _interopRequireDefault(require("../../../util/with-p
7
7
  hub: { file }
8
8
  } = tag;
9
9
  value.replaceWith(
10
- (0, _withPreviousLocation.default)(
11
- _compiler.types.callExpression(
12
- _compiler.types.memberExpression(
13
- file._componentDefIdentifier,
14
- _compiler.types.identifier("elId")),
15
-
16
- [value.node]),
17
-
18
- value.node));
19
-
20
-
10
+ (0, _withPreviousLocation.default)(
11
+ _compiler.types.callExpression(
12
+ _compiler.types.memberExpression(
13
+ file._componentDefIdentifier,
14
+ _compiler.types.identifier("elId")
15
+ ),
16
+ [value.node]
17
+ ),
18
+ value.node
19
+ )
20
+ );
21
21
  }
22
22
  };exports.default = _default;
@@ -25,8 +25,8 @@ function _default(tag) {
25
25
 
26
26
  if (!parentPath) {
27
27
  throw namePath.buildCodeFrameError(
28
- "@tags must be nested within another element.");
29
-
28
+ "@tags must be nested within another element."
29
+ );
30
30
  }
31
31
 
32
32
  const parentAttributes = parentPath.get("attributes");
@@ -51,36 +51,36 @@ function _default(tag) {
51
51
  }
52
52
  } else {
53
53
  const previousAttr = parentAttributes.find(
54
- (attr) => attr.get("name").node === targetProperty);
55
-
54
+ (attr) => attr.get("name").node === targetProperty
55
+ );
56
56
 
57
57
  if (previousAttr) {
58
58
  const previousValue = previousAttr.get("value").node;
59
59
  if (_compiler.types.isObjectExpression(previousValue)) {
60
60
  previousAttr.set(
61
- "value",
62
- _compiler.types.arrayExpression([previousValue, getAttrTagObject(tag)]));
63
-
61
+ "value",
62
+ _compiler.types.arrayExpression([previousValue, getAttrTagObject(tag)])
63
+ );
64
64
  } else if (_compiler.types.isArrayExpression(previousAttr)) {
65
65
  previousAttr.elements.push(getAttrTagObject(tag));
66
66
  } else {
67
67
  previousAttr.set(
68
- "value",
69
- _compiler.types.callExpression(
70
- (0, _babelUtils.importDefault)(
71
- tag.hub.file,
72
- "marko/src/runtime/helpers/repeatable.js",
73
- "marko_repeatable"),
74
-
75
- [previousValue, getAttrTagObject(tag)]));
76
-
77
-
68
+ "value",
69
+ _compiler.types.callExpression(
70
+ (0, _babelUtils.importDefault)(
71
+ tag.hub.file,
72
+ "marko/src/runtime/helpers/repeatable.js",
73
+ "marko_repeatable"
74
+ ),
75
+ [previousValue, getAttrTagObject(tag)]
76
+ )
77
+ );
78
78
  }
79
79
  } else {
80
80
  parentPath.pushContainer(
81
- "attributes",
82
- _compiler.types.markoAttribute(targetProperty, getAttrTagObject(tag)));
83
-
81
+ "attributes",
82
+ _compiler.types.markoAttribute(targetProperty, getAttrTagObject(tag))
83
+ );
84
84
  }
85
85
 
86
86
  tag.remove();
@@ -101,66 +101,66 @@ function _default(tag) {
101
101
  parentPath.
102
102
  get("body").
103
103
  unshiftContainer(
104
- "body",
105
- _compiler.types.variableDeclaration(isRepeated ? "const" : "let", [
106
- _compiler.types.variableDeclarator(
107
- identifier,
108
- isRepeated ? _compiler.types.arrayExpression([]) : _compiler.types.nullLiteral())]));
109
-
110
-
111
-
104
+ "body",
105
+ _compiler.types.variableDeclaration(isRepeated ? "const" : "let", [
106
+ _compiler.types.variableDeclarator(
107
+ identifier,
108
+ isRepeated ? _compiler.types.arrayExpression([]) : _compiler.types.nullLiteral()
109
+ )]
110
+ )
111
+ );
112
112
  parentPath.pushContainer(
113
- "attributes",
114
- _compiler.types.markoAttribute(targetProperty, identifier));
115
-
113
+ "attributes",
114
+ _compiler.types.markoAttribute(targetProperty, identifier)
115
+ );
116
116
  }
117
117
 
118
118
  if (isRepeated) {
119
119
  tag.replaceWith(
120
- (0, _withPreviousLocation.default)(
121
- _compiler.types.expressionStatement(
122
- _compiler.types.callExpression(
123
- _compiler.types.memberExpression(identifier, _compiler.types.identifier("push")),
124
- [getAttrTagObject(tag)])),
125
-
126
-
127
- node));
128
-
129
-
120
+ (0, _withPreviousLocation.default)(
121
+ _compiler.types.expressionStatement(
122
+ _compiler.types.callExpression(
123
+ _compiler.types.memberExpression(identifier, _compiler.types.identifier("push")),
124
+ [getAttrTagObject(tag)]
125
+ )
126
+ ),
127
+ node
128
+ )
129
+ );
130
130
  } else {
131
131
  tag.replaceWith(
132
- (0, _withPreviousLocation.default)(
133
- _compiler.types.expressionStatement(
134
- _compiler.types.assignmentExpression(
135
- "=",
136
- identifier,
137
- _compiler.types.callExpression(
138
- (0, _babelUtils.importDefault)(
139
- tag.hub.file,
140
- "marko/src/runtime/helpers/repeatable.js",
141
- "marko_repeatable"),
142
-
143
- [identifier, getAttrTagObject(tag)]))),
144
-
145
-
146
-
147
- node));
148
-
149
-
132
+ (0, _withPreviousLocation.default)(
133
+ _compiler.types.expressionStatement(
134
+ _compiler.types.assignmentExpression(
135
+ "=",
136
+ identifier,
137
+ _compiler.types.callExpression(
138
+ (0, _babelUtils.importDefault)(
139
+ tag.hub.file,
140
+ "marko/src/runtime/helpers/repeatable.js",
141
+ "marko_repeatable"
142
+ ),
143
+ [identifier, getAttrTagObject(tag)]
144
+ )
145
+ )
146
+ ),
147
+ node
148
+ )
149
+ );
150
150
  }
151
151
  }
152
152
 
153
153
  function getAttrTagObject(tag) {
154
154
  const attrs = (0, _util.getAttrs)(tag);
155
155
  const iteratorProp = _compiler.types.objectProperty(
156
- _compiler.types.memberExpression(_compiler.types.identifier("Symbol"), _compiler.types.identifier("iterator")),
157
- (0, _babelUtils.importDefault)(
158
- tag.hub.file,
159
- "marko/src/runtime/helpers/self-iterator.js",
160
- "marko_self_iterator"),
161
-
162
- true);
163
-
156
+ _compiler.types.memberExpression(_compiler.types.identifier("Symbol"), _compiler.types.identifier("iterator")),
157
+ (0, _babelUtils.importDefault)(
158
+ tag.hub.file,
159
+ "marko/src/runtime/helpers/self-iterator.js",
160
+ "marko_self_iterator"
161
+ ),
162
+ true
163
+ );
164
164
 
165
165
  if (_compiler.types.isNullLiteral(attrs)) {
166
166
  return _compiler.types.objectExpression([iteratorProp]);
@@ -64,8 +64,8 @@ function _default(path, isNullable) {
64
64
  throw path.
65
65
  get("name").
66
66
  buildCodeFrameError(
67
- `Unable to find entry point for custom tag <${tagName}>.`);
68
-
67
+ `Unable to find entry point for custom tag <${tagName}>.`
68
+ );
69
69
  }
70
70
  } else {
71
71
  tagIdentifier = name;
@@ -73,56 +73,56 @@ function _default(path, isNullable) {
73
73
 
74
74
  const foundAttrs = (0, _util.getAttrs)(path);
75
75
  const customTagRenderCall = (0, _withPreviousLocation.default)(
76
- _compiler.types.expressionStatement(
77
- _compiler.types.callExpression(
78
- (0, _babelUtils.importDefault)(
79
- file,
80
- "marko/src/runtime/helpers/render-tag.js",
81
- "marko_tag"),
82
-
83
- [
84
- tagIdentifier,
85
- // TODO: this could be left as null if we froze input mutations and used a default object in the runtime.
86
- _compiler.types.isNullLiteral(foundAttrs) ? _compiler.types.objectExpression([]) : foundAttrs,
87
- _compiler.types.identifier("out"),
88
- file._componentDefIdentifier,
89
- key,
90
- ...(0, _util.buildEventHandlerArray)(path)])),
91
-
92
-
93
-
94
- node);
95
-
76
+ _compiler.types.expressionStatement(
77
+ _compiler.types.callExpression(
78
+ (0, _babelUtils.importDefault)(
79
+ file,
80
+ "marko/src/runtime/helpers/render-tag.js",
81
+ "marko_tag"
82
+ ),
83
+ [
84
+ tagIdentifier,
85
+ // TODO: this could be left as null if we froze input mutations and used a default object in the runtime.
86
+ _compiler.types.isNullLiteral(foundAttrs) ? _compiler.types.objectExpression([]) : foundAttrs,
87
+ _compiler.types.identifier("out"),
88
+ file._componentDefIdentifier,
89
+ key,
90
+ ...(0, _util.buildEventHandlerArray)(path)]
91
+
92
+ )
93
+ ),
94
+ node
95
+ );
96
96
 
97
97
  if (isNullable) {
98
98
  let renderBodyIdentifier;
99
99
  const renderBodyProp =
100
100
  _compiler.types.isObjectExpression(foundAttrs) &&
101
101
  foundAttrs.properties.find(
102
- (prop) => prop.key && prop.key.value === "renderBody");
103
-
102
+ (prop) => prop.key && prop.key.value === "renderBody"
103
+ );
104
104
 
105
105
  if (renderBodyProp) {
106
106
  renderBodyIdentifier = path.scope.generateUidIdentifier("renderBody");
107
107
  path.insertBefore(
108
- _compiler.types.variableDeclaration("const", [
109
- _compiler.types.variableDeclarator(renderBodyIdentifier, renderBodyProp.value)]));
110
-
111
-
108
+ _compiler.types.variableDeclaration("const", [
109
+ _compiler.types.variableDeclarator(renderBodyIdentifier, renderBodyProp.value)]
110
+ )
111
+ );
112
112
 
113
113
  renderBodyProp.value = renderBodyIdentifier;
114
114
  }
115
115
 
116
116
  path.replaceWith(
117
- _compiler.types.ifStatement(
118
- name,
119
- customTagRenderCall,
120
- renderBodyIdentifier &&
121
- _compiler.types.expressionStatement(
122
- _compiler.types.callExpression(renderBodyIdentifier, [_compiler.types.identifier("out")]))));
123
-
124
-
125
-
117
+ _compiler.types.ifStatement(
118
+ name,
119
+ customTagRenderCall,
120
+ renderBodyIdentifier &&
121
+ _compiler.types.expressionStatement(
122
+ _compiler.types.callExpression(renderBodyIdentifier, [_compiler.types.identifier("out")])
123
+ )
124
+ )
125
+ );
126
126
  } else {
127
127
  path.replaceWith(customTagRenderCall);
128
128
  }
@@ -16,19 +16,19 @@ function _default(path) {
16
16
 
17
17
  if (node.preserveAttrs) {
18
18
  tagProperties.push(
19
- _compiler.types.objectProperty(
20
- _compiler.types.identifier("pa"),
21
- _compiler.types.arrayExpression(
22
- node.preserveAttrs.map((name) => _compiler.types.stringLiteral(name)))));
23
-
24
-
25
-
19
+ _compiler.types.objectProperty(
20
+ _compiler.types.identifier("pa"),
21
+ _compiler.types.arrayExpression(
22
+ node.preserveAttrs.map((name) => _compiler.types.stringLiteral(name))
23
+ )
24
+ )
25
+ );
26
26
  }
27
27
 
28
28
  if (_compiler.types.isObjectExpression(foundAttrs)) {
29
29
  const renderBodyIndex = foundAttrs.properties.findIndex(
30
- (prop) => prop.key && prop.key.value === "renderBody");
31
-
30
+ (prop) => prop.key && prop.key.value === "renderBody"
31
+ );
32
32
 
33
33
  attrsLen = foundAttrs.properties.length;
34
34
 
@@ -40,27 +40,27 @@ function _default(path) {
40
40
  }
41
41
 
42
42
  const dynamicTagRenderCall = _compiler.types.expressionStatement(
43
- _compiler.types.callExpression(
44
- (0, _babelUtils.importDefault)(
45
- file,
46
- `marko/src/runtime/helpers/dynamic-tag.js`,
47
- "marko_dynamic_tag"),
48
-
49
- [
50
- _compiler.types.identifier("out"),
51
- node.name,
52
- attrsLen ? _compiler.types.arrowFunctionExpression([], foundAttrs) : _compiler.types.nullLiteral(),
53
- renderBodyProp ? renderBodyProp.value : _compiler.types.nullLiteral(),
54
- args && args.length ? _compiler.types.arrayExpression(args) : _compiler.types.nullLiteral(),
55
- tagProperties.length ?
56
- _compiler.types.objectExpression(tagProperties) :
57
- _compiler.types.nullLiteral(),
58
- file._componentDefIdentifier,
59
- key,
60
- ...(0, _util.buildEventHandlerArray)(path)]));
61
-
62
-
43
+ _compiler.types.callExpression(
44
+ (0, _babelUtils.importDefault)(
45
+ file,
46
+ `marko/src/runtime/helpers/dynamic-tag.js`,
47
+ "marko_dynamic_tag"
48
+ ),
49
+ [
50
+ _compiler.types.identifier("out"),
51
+ node.name,
52
+ attrsLen ? _compiler.types.arrowFunctionExpression([], foundAttrs) : _compiler.types.nullLiteral(),
53
+ renderBodyProp ? renderBodyProp.value : _compiler.types.nullLiteral(),
54
+ args && args.length ? _compiler.types.arrayExpression(args) : _compiler.types.nullLiteral(),
55
+ tagProperties.length ?
56
+ _compiler.types.objectExpression(tagProperties) :
57
+ _compiler.types.nullLiteral(),
58
+ file._componentDefIdentifier,
59
+ key,
60
+ ...(0, _util.buildEventHandlerArray)(path)]
63
61
 
62
+ )
63
+ );
64
64
 
65
65
  path.replaceWith((0, _withPreviousLocation.default)(dynamicTagRenderCall, node));
66
66
  }
package/dist/tag/index.js CHANGED
@@ -47,9 +47,9 @@ var _optimizeVdomCreate = require("../util/optimize-vdom-create");var _default =
47
47
  if (path.hub.file.markoOpts.ignoreUnrecognizedTags && !tagDef) {
48
48
  (0, _babelUtils.findAttributeTags)(path).forEach((child) => {
49
49
  child.set(
50
- "name",
51
- _compiler.types.stringLiteral(`at_${child.get("name.value").node.slice(1)}`));
52
-
50
+ "name",
51
+ _compiler.types.stringLiteral(`at_${child.get("name.value").node.slice(1)}`)
52
+ );
53
53
  });
54
54
  }
55
55
 
@@ -70,10 +70,10 @@ var _optimizeVdomCreate = require("../util/optimize-vdom-create");var _default =
70
70
  if (!name.isIdentifier()) {
71
71
  const tagIdentifier = path.scope.generateUidIdentifier(`tagName`);
72
72
  path.insertBefore(
73
- _compiler.types.variableDeclaration("const", [
74
- _compiler.types.variableDeclarator(tagIdentifier, name.node)]));
75
-
76
-
73
+ _compiler.types.variableDeclaration("const", [
74
+ _compiler.types.variableDeclarator(tagIdentifier, name.node)]
75
+ )
76
+ );
77
77
 
78
78
  name.replaceWith(tagIdentifier);
79
79
  }
@@ -224,8 +224,8 @@ function findDynamicTagTypes(root) {
224
224
  break;
225
225
 
226
226
  default:
227
- return false;}
228
-
227
+ return false;
228
+ }
229
229
  }
230
230
 
231
231
  return types;