@marko/translator-default 5.31.0 → 5.31.2

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.
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
@@ -32,12 +32,12 @@ var _babelUtils = require("@marko/babel-utils");var _default =
32
32
  if (hasComponents) {
33
33
  const initId = _compiler.types.identifier("init");
34
34
  const markoComponentsImport = importPath(
35
- resolvePath(entryFile, "marko/src/runtime/components/index.js"));
36
-
35
+ resolvePath(entryFile, "marko/src/runtime/components/index.js")
36
+ );
37
37
  if (splitComponentIndex) {
38
38
  markoComponentsImport.specifiers.push(
39
- _compiler.types.importSpecifier(_compiler.types.identifier("register"), _compiler.types.identifier("register")));
40
-
39
+ _compiler.types.importSpecifier(_compiler.types.identifier("register"), _compiler.types.identifier("register"))
40
+ );
41
41
  }
42
42
 
43
43
  if (hydrateInit) {
@@ -48,16 +48,16 @@ var _babelUtils = require("@marko/babel-utils");var _default =
48
48
 
49
49
  if (hydrateInit) {
50
50
  program.pushContainer(
51
- "body",
52
- _compiler.types.expressionStatement(
53
- _compiler.types.callExpression(
54
- initId,
55
- entryFile.markoOpts.runtimeId ?
56
- [_compiler.types.stringLiteral(entryFile.markoOpts.runtimeId)] :
57
- [])));
58
-
59
-
60
-
51
+ "body",
52
+ _compiler.types.expressionStatement(
53
+ _compiler.types.callExpression(
54
+ initId,
55
+ entryFile.markoOpts.runtimeId ?
56
+ [_compiler.types.stringLiteral(entryFile.markoOpts.runtimeId)] :
57
+ []
58
+ )
59
+ )
60
+ );
61
61
  }
62
62
  }
63
63
 
@@ -112,24 +112,24 @@ var _babelUtils = require("@marko/babel-utils");var _default =
112
112
  if (meta.component) {
113
113
  // Split component
114
114
  const splitComponentId = _compiler.types.identifier(
115
- `component_${splitComponentIndex++}`);
116
-
115
+ `component_${splitComponentIndex++}`
116
+ );
117
117
  const splitComponentImport = importPath(
118
- resolvePath(file, meta.component));
119
-
118
+ resolvePath(file, meta.component)
119
+ );
120
120
  splitComponentImport.specifiers.push(
121
- _compiler.types.importDefaultSpecifier(splitComponentId));
122
-
121
+ _compiler.types.importDefaultSpecifier(splitComponentId)
122
+ );
123
123
  program.pushContainer("body", splitComponentImport);
124
124
  program.pushContainer(
125
- "body",
126
- _compiler.types.expressionStatement(
127
- _compiler.types.callExpression(_compiler.types.identifier("register"), [
128
- _compiler.types.stringLiteral(meta.id),
129
- splitComponentId])));
130
-
131
-
132
-
125
+ "body",
126
+ _compiler.types.expressionStatement(
127
+ _compiler.types.callExpression(_compiler.types.identifier("register"), [
128
+ _compiler.types.stringLiteral(meta.id),
129
+ splitComponentId]
130
+ )
131
+ )
132
+ );
133
133
  }
134
134
  }
135
135
 
@@ -182,9 +182,9 @@ var _babelUtils = require("@marko/babel-utils");var _default =
182
182
  return file === entryFile ?
183
183
  (0, _babelUtils.resolveRelativePath)(file, req) :
184
184
  (0, _babelUtils.resolveRelativePath)(
185
- entryFile,
186
- _path.default.join(file.opts.filename, "..", req));
187
-
185
+ entryFile,
186
+ _path.default.join(file.opts.filename, "..", req)
187
+ );
188
188
  }
189
189
 
190
190
  function importPath(path) {
@@ -194,17 +194,17 @@ var _babelUtils = require("@marko/babel-utils");var _default =
194
194
 
195
195
  function tryGetTemplateImports(file, rendererRelativePath) {
196
196
  const resolvedRendererPath = _path.default.join(
197
- file.opts.filename,
198
- "..",
199
- rendererRelativePath);
200
-
197
+ file.opts.filename,
198
+ "..",
199
+ rendererRelativePath
200
+ );
201
201
  let templateImports;
202
202
 
203
203
  try {
204
204
  for (const statement of (0, _babelUtils.parseStatements)(
205
- file,
206
- file.markoOpts.fileSystem.readFileSync(resolvedRendererPath, "utf-8")))
207
- {
205
+ file,
206
+ file.markoOpts.fileSystem.readFileSync(resolvedRendererPath, "utf-8")
207
+ )) {
208
208
  if (statement.type === "ImportDeclaration") {
209
209
  addImport(statement.source.value);
210
210
  } else {
@@ -20,8 +20,8 @@ function getComponentFiles({ hub: { file } }) {
20
20
  const styleMatch = new RegExp(`^${fileMatch}style\\.\\w+$`);
21
21
  const componentMatch = new RegExp(`^${fileMatch}component\\.\\w+$`);
22
22
  const splitComponentMatch = new RegExp(
23
- `^${fileMatch}component-browser\\.\\w+$`);
24
-
23
+ `^${fileMatch}component-browser\\.\\w+$`
24
+ );
25
25
  const packageMatch = new RegExp(`^${fileMatch}browser\\.\\json$`);
26
26
  let styleFile;
27
27
  let packageFile;
@@ -6,10 +6,10 @@ function write(strings, ...expressions) {
6
6
 
7
7
  if (template) {
8
8
  return _compiler.types.expressionStatement(
9
- _compiler.types.callExpression(
10
- _compiler.types.memberExpression(_compiler.types.identifier("out"), _compiler.types.identifier("w")),
11
- [template]));
12
-
13
-
9
+ _compiler.types.callExpression(
10
+ _compiler.types.memberExpression(_compiler.types.identifier("out"), _compiler.types.identifier("w")),
11
+ [template]
12
+ )
13
+ );
14
14
  }
15
15
  }
@@ -49,10 +49,10 @@ class KeyManager {
49
49
  const keyValueIdentifier = path.scope.generateUidIdentifier("keyValue");
50
50
  firstChildTag.set("key", keyValueIdentifier);
51
51
  firstChildTag.insertBefore(
52
- _compiler.types.variableDeclaration("const", [
53
- _compiler.types.variableDeclarator(keyValueIdentifier, firstChildKey)]));
54
-
55
-
52
+ _compiler.types.variableDeclaration("const", [
53
+ _compiler.types.variableDeclarator(keyValueIdentifier, firstChildKey)]
54
+ )
55
+ );
56
56
 
57
57
  path.set("keyValue", keyValueIdentifier);
58
58
  path.get("body").scope.crawl();
@@ -71,11 +71,11 @@ class KeyManager {
71
71
  const parentKeyScope = getParentKeyScope(path);
72
72
  const autoKey = path.get("key").node || this.nextKey();
73
73
  path.set(
74
- "key",
75
- parentKeyScope ?
76
- _compiler.types.binaryExpression("+", autoKey, parentKeyScope) :
77
- autoKey);
78
-
74
+ "key",
75
+ parentKeyScope ?
76
+ _compiler.types.binaryExpression("+", autoKey, parentKeyScope) :
77
+ autoKey
78
+ );
79
79
  }
80
80
  }
81
81
 
@@ -99,12 +99,12 @@ function getKeyScope(path) {
99
99
  scope.getOwnBinding(firstChildKeyValue.name).path;
100
100
  const declarationPath = valuePath.parentPath;
101
101
  declarationPath.pushContainer(
102
- "declarations",
103
- _compiler.types.variableDeclarator(
104
- keyScopeIdentifier,
105
- (0, _babelUtils.normalizeTemplateString)`[${firstChildKeyValue}]`));
106
-
107
-
102
+ "declarations",
103
+ _compiler.types.variableDeclarator(
104
+ keyScopeIdentifier,
105
+ (0, _babelUtils.normalizeTemplateString)`[${firstChildKeyValue}]`
106
+ )
107
+ );
108
108
  } else {
109
109
  let keyValue;
110
110
 
@@ -119,10 +119,10 @@ function getKeyScope(path) {
119
119
  if (!keyValue) {
120
120
  const keyValueIdentifier = path.scope.generateUidIdentifier("keyValue");
121
121
  path.insertBefore(
122
- _compiler.types.variableDeclaration("let", [
123
- _compiler.types.variableDeclarator(keyValueIdentifier, _compiler.types.numericLiteral(0))]));
124
-
125
-
122
+ _compiler.types.variableDeclaration("let", [
123
+ _compiler.types.variableDeclarator(keyValueIdentifier, _compiler.types.numericLiteral(0))]
124
+ )
125
+ );
126
126
 
127
127
  keyValue = _compiler.types.updateExpression("++", keyValueIdentifier);
128
128
  }
@@ -135,14 +135,14 @@ function getKeyScope(path) {
135
135
  path.
136
136
  get("body").
137
137
  unshiftContainer(
138
- "body",
139
- _compiler.types.variableDeclaration("const", [
140
- _compiler.types.variableDeclarator(
141
- keyScopeIdentifier,
142
- (0, _babelUtils.normalizeTemplateString)`[${keyValue}]`)]));
143
-
144
-
145
-
138
+ "body",
139
+ _compiler.types.variableDeclaration("const", [
140
+ _compiler.types.variableDeclarator(
141
+ keyScopeIdentifier,
142
+ (0, _babelUtils.normalizeTemplateString)`[${keyValue}]`
143
+ )]
144
+ )
145
+ );
146
146
  }
147
147
 
148
148
  path.set("keyScope", keyScopeIdentifier);
@@ -15,36 +15,36 @@ const skipDirectives = new Set([
15
15
  "no-update",
16
16
  "no-update-if",
17
17
  "no-update-body",
18
- "no-update-body-if"]);
19
-
18
+ "no-update-body-if"]
19
+ );
20
20
  const staticNodes = new WeakSet();
21
21
 
22
22
  const mergeStaticCreateVisitor = {
23
23
  MarkoText(path, state) {
24
24
  const { node } = path;
25
25
  state.currentRoot = _compiler.types.callExpression(
26
- _compiler.types.memberExpression(state.currentRoot, _compiler.types.identifier("t")),
27
- [_compiler.types.stringLiteral((0, _he.decode)(node.value))]);
28
-
26
+ _compiler.types.memberExpression(state.currentRoot, _compiler.types.identifier("t")),
27
+ [_compiler.types.stringLiteral((0, _he.decode)(node.value))]
28
+ );
29
29
  },
30
30
  MarkoPlaceholder(path, state) {
31
31
  const computed = (0, _babelUtils.computeNode)(path.node.value);
32
32
  state.currentRoot = _compiler.types.callExpression(
33
- _compiler.types.memberExpression(state.currentRoot, _compiler.types.identifier("t")),
34
- [
35
- _compiler.types.stringLiteral(
36
- computed && computed.value != null ? `${computed.value}` : "")]);
37
-
38
-
33
+ _compiler.types.memberExpression(state.currentRoot, _compiler.types.identifier("t")),
34
+ [
35
+ _compiler.types.stringLiteral(
36
+ computed && computed.value != null ? `${computed.value}` : ""
37
+ )]
39
38
 
39
+ );
40
40
  },
41
41
  MarkoTag(path, state) {
42
42
  (0, _keyManager.getKeyManager)(path).resolveKey(path);
43
43
  const writeArgs = (0, _nativeTagVdom.tagArguments)(path, true);
44
44
  state.currentRoot = _compiler.types.callExpression(
45
- _compiler.types.memberExpression(state.currentRoot, _compiler.types.identifier("e")),
46
- writeArgs);
47
-
45
+ _compiler.types.memberExpression(state.currentRoot, _compiler.types.identifier("e")),
46
+ writeArgs
47
+ );
48
48
  }
49
49
  };
50
50
 
@@ -81,15 +81,15 @@ const analyzeStaticVisitor = {
81
81
  path.
82
82
  get("attributes").
83
83
  every(
84
- (attr) =>
85
- _compiler.types.isMarkoAttribute(attr) &&
86
- !(
87
- attr.node.arguments ||
88
- attr.node.modifier ||
89
- skipDirectives.has(attr.node.name) ||
90
- !(0, _babelUtils.computeNode)(attr.node.value)));
91
-
84
+ (attr) =>
85
+ _compiler.types.isMarkoAttribute(attr) &&
86
+ !(
87
+ attr.node.arguments ||
88
+ attr.node.modifier ||
89
+ skipDirectives.has(attr.node.name) ||
90
+ !(0, _babelUtils.computeNode)(attr.node.value))
92
91
 
92
+ );
93
93
 
94
94
  // check children
95
95
  isStatic =
@@ -121,20 +121,20 @@ function optimizeStaticVDOM(path) {
121
121
  const writeArgs = (0, _nativeTagVdom.tagArguments)(path, true);
122
122
  const state = {
123
123
  currentRoot: _compiler.types.callExpression(
124
- (0, _babelUtils.importDefault)(
125
- file,
126
- "marko/src/runtime/vdom/helpers/v-element.js",
127
- "marko_createElement"),
128
-
129
- writeArgs)
130
-
124
+ (0, _babelUtils.importDefault)(
125
+ file,
126
+ "marko/src/runtime/vdom/helpers/v-element.js",
127
+ "marko_createElement"
128
+ ),
129
+ writeArgs
130
+ )
131
131
  };
132
132
 
133
133
  path.traverse(mergeStaticCreateVisitor, state);
134
134
 
135
135
  const d = _compiler.types.variableDeclaration("const", [
136
- _compiler.types.variableDeclarator(identifier, state.currentRoot)]);
137
-
136
+ _compiler.types.variableDeclarator(identifier, state.currentRoot)]
137
+ );
138
138
  file.path.node.body.push(d);
139
139
  path.replaceWith((0, _vdomOutWrite.default)("n", identifier, file._componentInstanceIdentifier));
140
140
  path.skip();
@@ -2,9 +2,9 @@
2
2
 
3
3
  function write(method, ...args) {
4
4
  return _compiler.types.expressionStatement(
5
- _compiler.types.callExpression(
6
- _compiler.types.memberExpression(_compiler.types.identifier("out"), _compiler.types.identifier(method)),
7
- args));
8
-
9
-
5
+ _compiler.types.callExpression(
6
+ _compiler.types.memberExpression(_compiler.types.identifier("out"), _compiler.types.identifier(method)),
7
+ args
8
+ )
9
+ );
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/translator-default",
3
- "version": "5.31.0",
3
+ "version": "5.31.2",
4
4
  "description": "Translates Marko templates to the default Marko runtime.",
5
5
  "keywords": [
6
6
  "babel",
@@ -35,8 +35,8 @@
35
35
  "self-closing-tags": "^1.0.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@marko/compiler": "^5.33.0",
39
- "marko": "^5.31.0"
38
+ "@marko/compiler": "^5.33.1",
39
+ "marko": "^5.31.7"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@marko/compiler": "^5.16.1",