@marko/translator-default 5.30.1 → 5.31.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cdata/index[html].js +5 -5
- package/dist/cdata/index[vdom].js +2 -2
- package/dist/class.js +21 -21
- package/dist/comment/index[html].js +2 -2
- package/dist/declaration/index[html].js +2 -2
- package/dist/document-type/index[html].js +2 -2
- package/dist/index.js +165 -165
- package/dist/placeholder/index[html].js +17 -17
- package/dist/placeholder/index[vdom].js +5 -5
- package/dist/tag/attribute/directives/class.js +12 -12
- package/dist/tag/attribute/directives/no-update.js +8 -8
- package/dist/tag/attribute/directives/style.js +12 -12
- package/dist/tag/attribute/index.js +15 -15
- package/dist/tag/attribute/modifiers/scoped.js +11 -11
- package/dist/tag/attribute-tag.js +67 -67
- package/dist/tag/custom-tag.js +37 -37
- package/dist/tag/dynamic-tag.js +29 -29
- package/dist/tag/index.js +9 -9
- package/dist/tag/native-tag[html]/attributes.js +41 -41
- package/dist/tag/native-tag[html]/index.js +67 -67
- package/dist/tag/native-tag[vdom]/attributes.js +34 -34
- package/dist/tag/native-tag[vdom]/index.js +59 -59
- package/dist/tag/util.js +42 -42
- package/dist/taglib/core/conditional/translate-else-if.js +2 -2
- package/dist/taglib/core/conditional/translate-else.js +2 -2
- package/dist/taglib/core/conditional/util.js +5 -5
- package/dist/taglib/core/macro/translate.js +9 -9
- package/dist/taglib/core/parse-class.js +2 -2
- package/dist/taglib/core/transform-style.js +6 -6
- package/dist/taglib/core/translate-await.js +11 -11
- package/dist/taglib/core/translate-body.js +5 -5
- package/dist/taglib/core/translate-for.js +65 -65
- package/dist/taglib/core/translate-include-content.js +9 -9
- package/dist/taglib/core/translate-while.js +10 -10
- package/dist/taglib/migrate/all-templates.js +32 -5
- package/dist/text/index[html].js +2 -2
- package/dist/text/index[vdom].js +9 -9
- package/dist/util/add-dependencies.js +50 -39
- package/dist/util/get-component-files.js +2 -2
- package/dist/util/html-out-write.js +5 -5
- package/dist/util/key-manager.js +27 -27
- package/dist/util/optimize-vdom-create.js +31 -31
- package/dist/util/vdom-out-write.js +5 -5
- package/package.json +3 -3
@@ -9,7 +9,7 @@ var _babelUtils = require("@marko/babel-utils");var _default =
|
|
9
9
|
|
10
10
|
|
11
11
|
(entryFile, isHydrate) => {
|
12
|
-
const { resolveVirtualDependency, hydrateIncludeImports } =
|
12
|
+
const { resolveVirtualDependency, hydrateIncludeImports, hydrateInit } =
|
13
13
|
entryFile.markoOpts;
|
14
14
|
const hydratedFiles = new Set();
|
15
15
|
const program = entryFile.path;
|
@@ -32,26 +32,33 @@ 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
|
-
|
36
|
-
|
35
|
+
resolvePath(entryFile, "marko/src/runtime/components/index.js")
|
36
|
+
);
|
37
37
|
if (splitComponentIndex) {
|
38
38
|
markoComponentsImport.specifiers.push(
|
39
|
-
|
40
|
-
|
39
|
+
_compiler.types.importSpecifier(_compiler.types.identifier("register"), _compiler.types.identifier("register"))
|
40
|
+
);
|
41
41
|
}
|
42
|
-
markoComponentsImport.specifiers.push(_compiler.types.importSpecifier(initId, initId));
|
43
|
-
program.unshiftContainer("body", markoComponentsImport);
|
44
|
-
program.pushContainer(
|
45
|
-
"body",
|
46
|
-
_compiler.types.expressionStatement(
|
47
|
-
_compiler.types.callExpression(
|
48
|
-
initId,
|
49
|
-
entryFile.markoOpts.runtimeId ?
|
50
|
-
[_compiler.types.stringLiteral(entryFile.markoOpts.runtimeId)] :
|
51
|
-
[])));
|
52
42
|
|
43
|
+
if (hydrateInit) {
|
44
|
+
markoComponentsImport.specifiers.push(_compiler.types.importSpecifier(initId, initId));
|
45
|
+
}
|
53
46
|
|
47
|
+
program.unshiftContainer("body", markoComponentsImport);
|
54
48
|
|
49
|
+
if (hydrateInit) {
|
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
|
+
);
|
61
|
+
}
|
55
62
|
}
|
56
63
|
|
57
64
|
function addHydrateDeps(file) {
|
@@ -105,24 +112,24 @@ var _babelUtils = require("@marko/babel-utils");var _default =
|
|
105
112
|
if (meta.component) {
|
106
113
|
// Split component
|
107
114
|
const splitComponentId = _compiler.types.identifier(
|
108
|
-
|
109
|
-
|
115
|
+
`component_${splitComponentIndex++}`
|
116
|
+
);
|
110
117
|
const splitComponentImport = importPath(
|
111
|
-
|
112
|
-
|
118
|
+
resolvePath(file, meta.component)
|
119
|
+
);
|
113
120
|
splitComponentImport.specifiers.push(
|
114
|
-
|
115
|
-
|
121
|
+
_compiler.types.importDefaultSpecifier(splitComponentId)
|
122
|
+
);
|
116
123
|
program.pushContainer("body", splitComponentImport);
|
117
124
|
program.pushContainer(
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
+
);
|
126
133
|
}
|
127
134
|
}
|
128
135
|
|
@@ -159,6 +166,10 @@ var _babelUtils = require("@marko/babel-utils");var _default =
|
|
159
166
|
code,
|
160
167
|
virtualPath
|
161
168
|
});
|
169
|
+
|
170
|
+
if (!dep) {
|
171
|
+
continue;
|
172
|
+
}
|
162
173
|
} else if (dep.startsWith("package:")) {
|
163
174
|
continue;
|
164
175
|
}
|
@@ -171,9 +182,9 @@ var _babelUtils = require("@marko/babel-utils");var _default =
|
|
171
182
|
return file === entryFile ?
|
172
183
|
(0, _babelUtils.resolveRelativePath)(file, req) :
|
173
184
|
(0, _babelUtils.resolveRelativePath)(
|
174
|
-
|
175
|
-
|
176
|
-
|
185
|
+
entryFile,
|
186
|
+
_path.default.join(file.opts.filename, "..", req)
|
187
|
+
);
|
177
188
|
}
|
178
189
|
|
179
190
|
function importPath(path) {
|
@@ -183,17 +194,17 @@ var _babelUtils = require("@marko/babel-utils");var _default =
|
|
183
194
|
|
184
195
|
function tryGetTemplateImports(file, rendererRelativePath) {
|
185
196
|
const resolvedRendererPath = _path.default.join(
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
197
|
+
file.opts.filename,
|
198
|
+
"..",
|
199
|
+
rendererRelativePath
|
200
|
+
);
|
190
201
|
let templateImports;
|
191
202
|
|
192
203
|
try {
|
193
204
|
for (const statement of (0, _babelUtils.parseStatements)(
|
194
|
-
|
195
|
-
|
196
|
-
{
|
205
|
+
file,
|
206
|
+
file.markoOpts.fileSystem.readFileSync(resolvedRendererPath, "utf-8")
|
207
|
+
)) {
|
197
208
|
if (statement.type === "ImportDeclaration") {
|
198
209
|
addImport(statement.source.value);
|
199
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
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
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
|
}
|
package/dist/util/key-manager.js
CHANGED
@@ -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
|
-
|
53
|
-
|
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
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
-
|
123
|
-
|
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
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
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
|
-
|
27
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
46
|
-
|
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
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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
|
-
|
6
|
-
|
7
|
-
|
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.
|
3
|
+
"version": "5.31.1",
|
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.
|
39
|
-
"marko": "^5.
|
38
|
+
"@marko/compiler": "^5.33.1",
|
39
|
+
"marko": "^5.31.4"
|
40
40
|
},
|
41
41
|
"peerDependencies": {
|
42
42
|
"@marko/compiler": "^5.16.1",
|