marko 5.37.49 → 5.37.50
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/runtime/helpers/tags-compat/runtime-dom.js +1 -1
- package/dist/runtime/helpers/tags-compat/runtime-html.js +15 -13
- package/dist/translator/index.js +35 -23
- package/dist/translator/util/add-dependencies.js +19 -8
- package/package.json +1 -1
- package/src/runtime/helpers/tags-compat/runtime-dom.js +1 -1
- package/src/runtime/helpers/tags-compat/runtime-html.js +9 -7
- package/src/translator/index.js +35 -23
- package/src/translator/util/add-dependencies.js +19 -8
@@ -50,7 +50,7 @@ exports.p = function (domCompat) {
|
|
50
50
|
const TagsCompat = createRenderer(
|
51
51
|
function (_, out, componentDef, component) {
|
52
52
|
const input = Array.isArray(_.i) ? _.i : [_.i];
|
53
|
-
const tagsRenderer = domCompat.resolveRegistered(_.r, global);
|
53
|
+
const tagsRenderer = domCompat.resolveRegistered(_.r, out.global);
|
54
54
|
const newNode = domCompat.render(out, component, tagsRenderer, input);
|
55
55
|
|
56
56
|
out.bf("1", component, !newNode);
|
@@ -70,17 +70,19 @@ exports.p = function (htmlCompat) {
|
|
70
70
|
return tagsRenderer;
|
71
71
|
}
|
72
72
|
|
73
|
-
|
74
|
-
renderBody
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
73
|
+
return (input, out) => {
|
74
|
+
if (!tagsRenderer && renderBody) {
|
75
|
+
renderBody.toJSON = htmlCompat.toJSON(
|
76
|
+
htmlCompat.ensureState(out.global)
|
77
|
+
);
|
78
|
+
}
|
79
|
+
TagsCompat(
|
80
|
+
args ?
|
81
|
+
{ i: args, r: (args) => (tagsRenderer || renderBody)(...args) } :
|
82
|
+
{ i: input, r: tagsRenderer || renderBody },
|
83
|
+
out
|
84
|
+
);
|
85
|
+
};
|
84
86
|
};
|
85
87
|
|
86
88
|
const TagsCompatId = "tags-compat";
|
@@ -147,7 +149,7 @@ exports.p = function (htmlCompat) {
|
|
147
149
|
return (input, ...args) => {
|
148
150
|
// tags to class
|
149
151
|
const $global = htmlCompat.$global();
|
150
|
-
htmlCompat.ensureState($global);
|
152
|
+
const state = htmlCompat.ensureState($global);
|
151
153
|
let writers = writersByGlobal.get($global);
|
152
154
|
if (!writers) {
|
153
155
|
writersByGlobal.set($global, writers = { classAPI: [], tagsAPI: [] });
|
@@ -169,7 +171,7 @@ exports.p = function (htmlCompat) {
|
|
169
171
|
key[2] === "-" ? key.slice(3) : key.slice(2).toLowerCase(),
|
170
172
|
value]
|
171
173
|
);
|
172
|
-
value.toJSON = htmlCompat.toJSON;
|
174
|
+
value.toJSON = htmlCompat.toJSON(state);
|
173
175
|
}
|
174
176
|
} else {
|
175
177
|
input[key === "content" ? "renderBody" : key] = value;
|
package/dist/translator/index.js
CHANGED
@@ -428,32 +428,44 @@ const translate = exports.translate = {
|
|
428
428
|
);
|
429
429
|
}
|
430
430
|
|
431
|
-
|
432
|
-
"
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
),
|
450
|
-
_compiler.types.objectExpression(templateRenderOptionsProps),
|
451
|
-
componentIdentifier]
|
452
|
-
)
|
453
|
-
)
|
431
|
+
let rendererAssignment = _compiler.types.assignmentExpression(
|
432
|
+
"=",
|
433
|
+
templateRendererMember,
|
434
|
+
_compiler.types.callExpression(rendererIdentifier, [
|
435
|
+
_compiler.types.functionExpression(
|
436
|
+
null,
|
437
|
+
[
|
438
|
+
_compiler.types.identifier("input"),
|
439
|
+
_compiler.types.identifier("out"),
|
440
|
+
file._componentDefIdentifier,
|
441
|
+
file._componentInstanceIdentifier,
|
442
|
+
_compiler.types.identifier("state"),
|
443
|
+
_compiler.types.identifier("$global")],
|
444
|
+
|
445
|
+
renderBlock.node
|
446
|
+
),
|
447
|
+
_compiler.types.objectExpression(templateRenderOptionsProps),
|
448
|
+
componentIdentifier]
|
454
449
|
)
|
455
450
|
);
|
456
451
|
|
452
|
+
if (!isHTML && componentBrowserFile && !meta.implicitSplitComponent) {
|
453
|
+
rendererAssignment = _compiler.types.assignmentExpression(
|
454
|
+
"=",
|
455
|
+
_compiler.types.memberExpression(
|
456
|
+
(0, _babelUtils.importDefault)(
|
457
|
+
file,
|
458
|
+
(0, _babelUtils.resolveRelativePath)(file, componentBrowserFile),
|
459
|
+
"marko_split_component"
|
460
|
+
),
|
461
|
+
_compiler.types.identifier("renderer")
|
462
|
+
),
|
463
|
+
rendererAssignment
|
464
|
+
);
|
465
|
+
}
|
466
|
+
|
467
|
+
path.pushContainer("body", _compiler.types.expressionStatement(rendererAssignment));
|
468
|
+
|
457
469
|
if (meta.implicitSplitComponent && isHTML) {
|
458
470
|
renderBlock.unshiftContainer(
|
459
471
|
"body",
|
@@ -43,7 +43,7 @@ const lassoDepPrefix = "package: ";var _default =
|
|
43
43
|
};exports.default = _default;
|
44
44
|
|
45
45
|
const entryBuilder = exports.entryBuilder = {
|
46
|
-
build(entryFile) {
|
46
|
+
build(entryFile, exportInit) {
|
47
47
|
const state = entryFile[kEntryState];
|
48
48
|
if (!state) {
|
49
49
|
throw entryFile.path.buildCodeFrameError(
|
@@ -53,6 +53,7 @@ const entryBuilder = exports.entryBuilder = {
|
|
53
53
|
const { markoOpts } = entryFile;
|
54
54
|
const entryMarkoMeta = entryFile.metadata.marko;
|
55
55
|
const { body } = state;
|
56
|
+
let didExportInit = false;
|
56
57
|
entryMarkoMeta.watchFiles = [...state.watchFiles];
|
57
58
|
entryMarkoMeta.deps = [...state.lassoDeps];
|
58
59
|
|
@@ -69,19 +70,29 @@ const entryBuilder = exports.entryBuilder = {
|
|
69
70
|
|
70
71
|
body.unshift(markoComponentsImport);
|
71
72
|
|
72
|
-
if (markoOpts.hydrateInit) {
|
73
|
+
if (markoOpts.hydrateInit || exportInit) {
|
74
|
+
const initExpression = _compiler.types.callExpression(
|
75
|
+
initId,
|
76
|
+
markoOpts.runtimeId ? [_compiler.types.stringLiteral(markoOpts.runtimeId)] : []
|
77
|
+
);
|
73
78
|
markoComponentsImport.specifiers.push(
|
74
79
|
_compiler.types.importSpecifier(initId, initId)
|
75
80
|
);
|
81
|
+
|
76
82
|
body.push(
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
)
|
83
|
+
exportInit ?
|
84
|
+
_compiler.types.exportDefaultDeclaration(
|
85
|
+
_compiler.types.arrowFunctionExpression([], initExpression)
|
86
|
+
) :
|
87
|
+
_compiler.types.expressionStatement(initExpression)
|
83
88
|
);
|
84
89
|
}
|
90
|
+
} else if (exportInit) {
|
91
|
+
body.push(
|
92
|
+
_compiler.types.exportDefaultDeclaration(
|
93
|
+
_compiler.types.arrowFunctionExpression([], _compiler.types.blockStatement([]))
|
94
|
+
)
|
95
|
+
);
|
85
96
|
}
|
86
97
|
|
87
98
|
return body;
|
package/package.json
CHANGED
@@ -50,7 +50,7 @@ exports.p = function (domCompat) {
|
|
50
50
|
const TagsCompat = createRenderer(
|
51
51
|
function (_, out, componentDef, component) {
|
52
52
|
const input = Array.isArray(_.i) ? _.i : [_.i];
|
53
|
-
const tagsRenderer = domCompat.resolveRegistered(_.r, global);
|
53
|
+
const tagsRenderer = domCompat.resolveRegistered(_.r, out.global);
|
54
54
|
const newNode = domCompat.render(out, component, tagsRenderer, input);
|
55
55
|
|
56
56
|
out.bf("1", component, !newNode);
|
@@ -70,17 +70,19 @@ exports.p = function (htmlCompat) {
|
|
70
70
|
return tagsRenderer;
|
71
71
|
}
|
72
72
|
|
73
|
-
|
74
|
-
renderBody
|
75
|
-
|
76
|
-
|
77
|
-
|
73
|
+
return (input, out) => {
|
74
|
+
if (!tagsRenderer && renderBody) {
|
75
|
+
renderBody.toJSON = htmlCompat.toJSON(
|
76
|
+
htmlCompat.ensureState(out.global),
|
77
|
+
);
|
78
|
+
}
|
78
79
|
TagsCompat(
|
79
80
|
args
|
80
81
|
? { i: args, r: (args) => (tagsRenderer || renderBody)(...args) }
|
81
82
|
: { i: input, r: tagsRenderer || renderBody },
|
82
83
|
out,
|
83
84
|
);
|
85
|
+
};
|
84
86
|
};
|
85
87
|
|
86
88
|
const TagsCompatId = "tags-compat";
|
@@ -147,7 +149,7 @@ exports.p = function (htmlCompat) {
|
|
147
149
|
return (input, ...args) => {
|
148
150
|
// tags to class
|
149
151
|
const $global = htmlCompat.$global();
|
150
|
-
htmlCompat.ensureState($global);
|
152
|
+
const state = htmlCompat.ensureState($global);
|
151
153
|
let writers = writersByGlobal.get($global);
|
152
154
|
if (!writers) {
|
153
155
|
writersByGlobal.set($global, (writers = { classAPI: [], tagsAPI: [] }));
|
@@ -169,7 +171,7 @@ exports.p = function (htmlCompat) {
|
|
169
171
|
key[2] === "-" ? key.slice(3) : key.slice(2).toLowerCase(),
|
170
172
|
value,
|
171
173
|
]);
|
172
|
-
value.toJSON = htmlCompat.toJSON;
|
174
|
+
value.toJSON = htmlCompat.toJSON(state);
|
173
175
|
}
|
174
176
|
} else {
|
175
177
|
input[key === "content" ? "renderBody" : key] = value;
|
package/src/translator/index.js
CHANGED
@@ -428,32 +428,44 @@ export const translate = {
|
|
428
428
|
);
|
429
429
|
}
|
430
430
|
|
431
|
-
|
432
|
-
"
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
t.
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
t.identifier("$global"),
|
447
|
-
],
|
448
|
-
renderBlock.node,
|
449
|
-
),
|
450
|
-
t.objectExpression(templateRenderOptionsProps),
|
451
|
-
componentIdentifier,
|
452
|
-
]),
|
431
|
+
let rendererAssignment = t.assignmentExpression(
|
432
|
+
"=",
|
433
|
+
templateRendererMember,
|
434
|
+
t.callExpression(rendererIdentifier, [
|
435
|
+
t.functionExpression(
|
436
|
+
null,
|
437
|
+
[
|
438
|
+
t.identifier("input"),
|
439
|
+
t.identifier("out"),
|
440
|
+
file._componentDefIdentifier,
|
441
|
+
file._componentInstanceIdentifier,
|
442
|
+
t.identifier("state"),
|
443
|
+
t.identifier("$global"),
|
444
|
+
],
|
445
|
+
renderBlock.node,
|
453
446
|
),
|
454
|
-
|
447
|
+
t.objectExpression(templateRenderOptionsProps),
|
448
|
+
componentIdentifier,
|
449
|
+
]),
|
455
450
|
);
|
456
451
|
|
452
|
+
if (!isHTML && componentBrowserFile && !meta.implicitSplitComponent) {
|
453
|
+
rendererAssignment = t.assignmentExpression(
|
454
|
+
"=",
|
455
|
+
t.memberExpression(
|
456
|
+
importDefault(
|
457
|
+
file,
|
458
|
+
resolveRelativePath(file, componentBrowserFile),
|
459
|
+
"marko_split_component",
|
460
|
+
),
|
461
|
+
t.identifier("renderer"),
|
462
|
+
),
|
463
|
+
rendererAssignment,
|
464
|
+
);
|
465
|
+
}
|
466
|
+
|
467
|
+
path.pushContainer("body", t.expressionStatement(rendererAssignment));
|
468
|
+
|
457
469
|
if (meta.implicitSplitComponent && isHTML) {
|
458
470
|
renderBlock.unshiftContainer(
|
459
471
|
"body",
|
@@ -43,7 +43,7 @@ export default (entryFile, isHydrate) => {
|
|
43
43
|
};
|
44
44
|
|
45
45
|
export const entryBuilder = {
|
46
|
-
build(entryFile) {
|
46
|
+
build(entryFile, exportInit) {
|
47
47
|
const state = entryFile[kEntryState];
|
48
48
|
if (!state) {
|
49
49
|
throw entryFile.path.buildCodeFrameError(
|
@@ -53,6 +53,7 @@ export const entryBuilder = {
|
|
53
53
|
const { markoOpts } = entryFile;
|
54
54
|
const entryMarkoMeta = entryFile.metadata.marko;
|
55
55
|
const { body } = state;
|
56
|
+
let didExportInit = false;
|
56
57
|
entryMarkoMeta.watchFiles = [...state.watchFiles];
|
57
58
|
entryMarkoMeta.deps = [...state.lassoDeps];
|
58
59
|
|
@@ -69,19 +70,29 @@ export const entryBuilder = {
|
|
69
70
|
|
70
71
|
body.unshift(markoComponentsImport);
|
71
72
|
|
72
|
-
if (markoOpts.hydrateInit) {
|
73
|
+
if (markoOpts.hydrateInit || exportInit) {
|
74
|
+
const initExpression = t.callExpression(
|
75
|
+
initId,
|
76
|
+
markoOpts.runtimeId ? [t.stringLiteral(markoOpts.runtimeId)] : [],
|
77
|
+
);
|
73
78
|
markoComponentsImport.specifiers.push(
|
74
79
|
t.importSpecifier(initId, initId),
|
75
80
|
);
|
81
|
+
|
76
82
|
body.push(
|
77
|
-
|
78
|
-
t.
|
79
|
-
|
80
|
-
|
81
|
-
),
|
82
|
-
),
|
83
|
+
exportInit
|
84
|
+
? t.exportDefaultDeclaration(
|
85
|
+
t.arrowFunctionExpression([], initExpression),
|
86
|
+
)
|
87
|
+
: t.expressionStatement(initExpression),
|
83
88
|
);
|
84
89
|
}
|
90
|
+
} else if (exportInit) {
|
91
|
+
body.push(
|
92
|
+
t.exportDefaultDeclaration(
|
93
|
+
t.arrowFunctionExpression([], t.blockStatement([])),
|
94
|
+
),
|
95
|
+
);
|
85
96
|
}
|
86
97
|
|
87
98
|
return body;
|