marko 5.36.5 → 5.37.0
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/compiler/index.js +11 -11
- package/dist/core-tags/components/init-components-tag.js +4 -4
- package/dist/core-tags/components/preferred-script-location-tag.js +2 -2
- package/dist/core-tags/core/__flush_here_and_after__.js +1 -1
- package/dist/core-tags/core/await/AsyncValue.js +21 -21
- package/dist/core-tags/core/await/renderer.js +24 -24
- package/dist/core-tags/core/await/reorderer-renderer.js +6 -6
- package/dist/node-require/browser-refresh.js +18 -1
- package/dist/node-require/index.js +7 -7
- package/dist/node_modules/@internal/components-beginComponent/index-browser.js +5 -5
- package/dist/node_modules/@internal/components-beginComponent/index.js +12 -12
- package/dist/node_modules/@internal/components-define-widget-legacy/index-browser.js +99 -99
- package/dist/node_modules/@internal/components-define-widget-legacy/index.js +3 -3
- package/dist/node_modules/@internal/components-endComponent/index.js +3 -3
- package/dist/node_modules/@internal/components-entry/index-browser.js +2 -2
- package/dist/node_modules/@internal/components-entry/index.js +29 -29
- package/dist/node_modules/@internal/components-entry-legacy/index-browser.js +13 -13
- package/dist/node_modules/@internal/components-entry-legacy/index.js +1 -1
- package/dist/node_modules/@internal/components-registry/index-browser.js +102 -102
- package/dist/node_modules/@internal/components-registry/index.js +2 -2
- package/dist/node_modules/@internal/components-util/index-browser.js +20 -20
- package/dist/node_modules/@internal/components-util/index.js +24 -20
- package/dist/node_modules/@internal/create-readable/index-browser.js +1 -1
- package/dist/node_modules/@internal/create-readable/index.js +9 -9
- package/dist/node_modules/@internal/preserve-tag/index-browser.js +8 -8
- package/dist/node_modules/@internal/preserve-tag/index.js +6 -6
- package/dist/node_modules/@internal/set-immediate/index-browser.js +2 -2
- package/dist/node_modules/@internal/set-immediate/index-worker.js +3 -3
- package/dist/node_modules/@internal/set-immediate/index.js +3 -3
- package/dist/runtime/RenderResult.js +24 -24
- package/dist/runtime/components/Component.js +163 -163
- package/dist/runtime/components/ComponentDef.js +34 -34
- package/dist/runtime/components/ComponentsContext.js +20 -20
- package/dist/runtime/components/GlobalComponentsContext.js +4 -4
- package/dist/runtime/components/KeySequence.js +3 -3
- package/dist/runtime/components/ServerComponent.js +17 -17
- package/dist/runtime/components/State.js +28 -28
- package/dist/runtime/components/attach-detach.js +8 -8
- package/dist/runtime/components/defineComponent.js +5 -5
- package/dist/runtime/components/dom-data.js +6 -6
- package/dist/runtime/components/event-delegation.js +10 -10
- package/dist/runtime/components/legacy/defineComponent-legacy.js +1 -1
- package/dist/runtime/components/legacy/defineRenderer-legacy.js +25 -25
- package/dist/runtime/components/legacy/dependencies/index.js +10 -10
- package/dist/runtime/components/legacy/renderer-legacy.js +56 -56
- package/dist/runtime/components/renderer.js +45 -45
- package/dist/runtime/components/update-manager.js +4 -4
- package/dist/runtime/createOut.js +1 -1
- package/dist/runtime/dom-insert.js +5 -5
- package/dist/runtime/helpers/_change-case.js +2 -2
- package/dist/runtime/helpers/dynamic-tag.js +33 -33
- package/dist/runtime/helpers/render-tag.js +1 -1
- package/dist/runtime/helpers/serialize-noop.js +2 -2
- package/dist/runtime/helpers/style-value.js +1 -1
- package/dist/runtime/helpers/tags-compat/runtime-dom.js +35 -35
- package/dist/runtime/helpers/tags-compat/runtime-html.js +16 -16
- package/dist/runtime/html/AsyncStream.js +28 -28
- package/dist/runtime/html/BufferedWriter.js +2 -2
- package/dist/runtime/html/StringWriter.js +2 -2
- package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
- package/dist/runtime/html/helpers/attr.js +11 -11
- package/dist/runtime/html/helpers/attrs.js +6 -6
- package/dist/runtime/html/helpers/data-marko.js +6 -6
- package/dist/runtime/html/helpers/escape-quotes.js +2 -2
- package/dist/runtime/html/helpers/escape-xml.js +1 -1
- package/dist/runtime/html/helpers/merge-attrs.js +11 -11
- package/dist/runtime/html/helpers/props-script.js +1 -1
- package/dist/runtime/html/index.js +2 -2
- package/dist/runtime/renderable.js +5 -5
- package/dist/runtime/vdom/AsyncVDOMBuilder.js +100 -100
- package/dist/runtime/vdom/VComment.js +7 -7
- package/dist/runtime/vdom/VComponent.js +5 -5
- package/dist/runtime/vdom/VDocumentFragment.js +8 -8
- package/dist/runtime/vdom/VElement.js +52 -52
- package/dist/runtime/vdom/VFragment.js +9 -9
- package/dist/runtime/vdom/VNode.js +34 -34
- package/dist/runtime/vdom/VText.js +8 -8
- package/dist/runtime/vdom/helpers/attrs.js +6 -6
- package/dist/runtime/vdom/helpers/const-element.js +3 -3
- package/dist/runtime/vdom/hot-reload.js +20 -20
- package/dist/runtime/vdom/index.js +2 -2
- package/dist/runtime/vdom/morphdom/fragment.js +10 -10
- package/dist/runtime/vdom/morphdom/helpers.js +5 -5
- package/dist/runtime/vdom/morphdom/index.js +81 -81
- package/dist/runtime/vdom/vdom.js +15 -15
- package/dist/taglib/index.js +7 -7
- package/dist/translator/cdata/index.js +15 -0
- package/dist/translator/cdata/index[html].js +15 -0
- package/dist/translator/cdata/index[vdom].js +12 -0
- package/dist/translator/class.js +65 -0
- package/dist/translator/comment/index.js +15 -0
- package/dist/translator/comment/index[html].js +17 -0
- package/dist/translator/comment/index[vdom].js +3 -0
- package/dist/translator/declaration/index.js +15 -0
- package/dist/translator/declaration/index[html].js +12 -0
- package/dist/translator/declaration/index[vdom].js +3 -0
- package/dist/translator/document-type/index.js +15 -0
- package/dist/translator/document-type/index[html].js +12 -0
- package/dist/translator/document-type/index[vdom].js +3 -0
- package/dist/translator/index.js +551 -0
- package/dist/translator/placeholder/index.js +15 -0
- package/dist/translator/placeholder/index[html].js +93 -0
- package/dist/translator/placeholder/index[vdom].js +22 -0
- package/dist/translator/scriptlet.js +4 -0
- package/dist/translator/tag/attribute/directives/class.js +42 -0
- package/dist/translator/tag/attribute/directives/index.js +15 -0
- package/dist/translator/tag/attribute/directives/no-update-body-if.js +15 -0
- package/dist/translator/tag/attribute/directives/no-update-body.js +10 -0
- package/dist/translator/tag/attribute/directives/no-update-if.js +12 -0
- package/dist/translator/tag/attribute/directives/no-update.js +48 -0
- package/dist/translator/tag/attribute/directives/style.js +42 -0
- package/dist/translator/tag/attribute/index.js +150 -0
- package/dist/translator/tag/attribute/modifiers/index.js +7 -0
- package/dist/translator/tag/attribute/modifiers/no-update.js +14 -0
- package/dist/translator/tag/attribute/modifiers/scoped.js +23 -0
- package/dist/translator/tag/attribute-tag.js +149 -0
- package/dist/translator/tag/custom-tag.js +146 -0
- package/dist/translator/tag/dynamic-tag.js +74 -0
- package/dist/translator/tag/index.js +287 -0
- package/dist/translator/tag/macro-tag.js +7 -0
- package/dist/translator/tag/native-tag.js +27 -0
- package/dist/translator/tag/native-tag[html]/attributes.js +151 -0
- package/dist/translator/tag/native-tag[html]/index.js +221 -0
- package/dist/translator/tag/native-tag[vdom]/attributes.js +105 -0
- package/dist/translator/tag/native-tag[vdom]/index.js +189 -0
- package/dist/translator/tag/util.js +246 -0
- package/dist/translator/taglib/core/conditional/translate-else-if.js +20 -0
- package/dist/translator/taglib/core/conditional/translate-else.js +20 -0
- package/dist/translator/taglib/core/conditional/translate-if.js +8 -0
- package/dist/translator/taglib/core/conditional/util.js +41 -0
- package/dist/translator/taglib/core/index.js +474 -0
- package/dist/translator/taglib/core/macro/parse.js +17 -0
- package/dist/translator/taglib/core/macro/translate.js +48 -0
- package/dist/translator/taglib/core/parse-class.js +79 -0
- package/dist/translator/taglib/core/parse-export.js +14 -0
- package/dist/translator/taglib/core/parse-import.js +14 -0
- package/dist/translator/taglib/core/parse-module-code.js +18 -0
- package/dist/translator/taglib/core/parse-static.js +18 -0
- package/dist/translator/taglib/core/transform-style.js +66 -0
- package/dist/translator/taglib/core/translate-await.js +41 -0
- package/dist/translator/taglib/core/translate-body.js +17 -0
- package/dist/translator/taglib/core/translate-for.js +156 -0
- package/dist/translator/taglib/core/translate-html-comment.js +52 -0
- package/dist/translator/taglib/core/translate-include-content.js +53 -0
- package/dist/translator/taglib/core/translate-server-only.js +5 -0
- package/dist/translator/taglib/core/translate-while.js +32 -0
- package/dist/translator/taglib/index.js +6 -0
- package/dist/translator/taglib/migrate/all-templates.js +46 -0
- package/dist/translator/taglib/migrate/index.js +5 -0
- package/dist/translator/text/index.js +10 -0
- package/dist/translator/text/index[html].js +12 -0
- package/dist/translator/text/index[vdom].js +20 -0
- package/dist/translator/util/add-dependencies.js +329 -0
- package/dist/translator/util/escape-regexp.js +4 -0
- package/dist/translator/util/get-component-files.js +86 -0
- package/dist/translator/util/html-out-write.js +15 -0
- package/dist/translator/util/key-manager.js +176 -0
- package/dist/translator/util/optimize-html-writes.js +52 -0
- package/dist/translator/util/optimize-vdom-create.js +164 -0
- package/dist/translator/util/plugin-hooks.js +22 -0
- package/dist/translator/util/runtime-flags.js +3 -0
- package/dist/translator/util/vdom-out-write.js +10 -0
- package/dist/translator/util/with-previous-location.js +6 -0
- package/package.json +7 -4
- package/src/taglib/index.js +2 -2
- package/src/translator/cdata/index.js +15 -0
- package/src/translator/cdata/index[html].js +15 -0
- package/src/translator/cdata/index[vdom].js +12 -0
- package/src/translator/class.js +65 -0
- package/src/translator/comment/index.js +15 -0
- package/src/translator/comment/index[html].js +17 -0
- package/src/translator/comment/index[vdom].js +3 -0
- package/src/translator/declaration/index.js +15 -0
- package/src/translator/declaration/index[html].js +12 -0
- package/src/translator/declaration/index[vdom].js +3 -0
- package/src/translator/document-type/index.js +15 -0
- package/src/translator/document-type/index[html].js +12 -0
- package/src/translator/document-type/index[vdom].js +3 -0
- package/src/translator/index.js +551 -0
- package/src/translator/placeholder/index.js +15 -0
- package/src/translator/placeholder/index[html].js +93 -0
- package/src/translator/placeholder/index[vdom].js +22 -0
- package/src/translator/scriptlet.js +4 -0
- package/src/translator/tag/attribute/directives/class.js +42 -0
- package/src/translator/tag/attribute/directives/index.js +15 -0
- package/src/translator/tag/attribute/directives/no-update-body-if.js +15 -0
- package/src/translator/tag/attribute/directives/no-update-body.js +10 -0
- package/src/translator/tag/attribute/directives/no-update-if.js +12 -0
- package/src/translator/tag/attribute/directives/no-update.js +48 -0
- package/src/translator/tag/attribute/directives/style.js +42 -0
- package/src/translator/tag/attribute/index.js +150 -0
- package/src/translator/tag/attribute/modifiers/index.js +7 -0
- package/src/translator/tag/attribute/modifiers/no-update.js +14 -0
- package/src/translator/tag/attribute/modifiers/scoped.js +23 -0
- package/src/translator/tag/attribute-tag.js +149 -0
- package/src/translator/tag/custom-tag.js +146 -0
- package/src/translator/tag/dynamic-tag.js +74 -0
- package/src/translator/tag/index.js +287 -0
- package/src/translator/tag/macro-tag.js +7 -0
- package/src/translator/tag/native-tag.js +27 -0
- package/src/translator/tag/native-tag[html]/attributes.js +151 -0
- package/src/translator/tag/native-tag[html]/index.js +221 -0
- package/src/translator/tag/native-tag[vdom]/attributes.js +105 -0
- package/src/translator/tag/native-tag[vdom]/index.js +189 -0
- package/src/translator/tag/util.js +246 -0
- package/src/translator/taglib/core/conditional/translate-else-if.js +20 -0
- package/src/translator/taglib/core/conditional/translate-else.js +20 -0
- package/src/translator/taglib/core/conditional/translate-if.js +8 -0
- package/src/translator/taglib/core/conditional/util.js +41 -0
- package/src/translator/taglib/core/index.js +474 -0
- package/src/translator/taglib/core/macro/parse.js +17 -0
- package/src/translator/taglib/core/macro/translate.js +48 -0
- package/src/translator/taglib/core/parse-class.js +79 -0
- package/src/translator/taglib/core/parse-export.js +14 -0
- package/src/translator/taglib/core/parse-import.js +14 -0
- package/src/translator/taglib/core/parse-module-code.js +18 -0
- package/src/translator/taglib/core/parse-static.js +18 -0
- package/src/translator/taglib/core/transform-style.js +66 -0
- package/src/translator/taglib/core/translate-await.js +41 -0
- package/src/translator/taglib/core/translate-body.js +17 -0
- package/src/translator/taglib/core/translate-for.js +156 -0
- package/src/translator/taglib/core/translate-html-comment.js +52 -0
- package/src/translator/taglib/core/translate-include-content.js +53 -0
- package/src/translator/taglib/core/translate-server-only.js +5 -0
- package/src/translator/taglib/core/translate-while.js +32 -0
- package/src/translator/taglib/index.js +7 -0
- package/src/translator/taglib/migrate/all-templates.js +46 -0
- package/src/translator/taglib/migrate/index.js +5 -0
- package/src/translator/text/index.js +10 -0
- package/src/translator/text/index[html].js +12 -0
- package/src/translator/text/index[vdom].js +20 -0
- package/src/translator/util/add-dependencies.js +329 -0
- package/src/translator/util/escape-regexp.js +4 -0
- package/src/translator/util/get-component-files.js +86 -0
- package/src/translator/util/html-out-write.js +15 -0
- package/src/translator/util/key-manager.js +176 -0
- package/src/translator/util/optimize-html-writes.js +52 -0
- package/src/translator/util/optimize-vdom-create.js +164 -0
- package/src/translator/util/plugin-hooks.js +22 -0
- package/src/translator/util/runtime-flags.js +3 -0
- package/src/translator/util/vdom-out-write.js +10 -0
- package/src/translator/util/with-previous-location.js +6 -0
- package/translator/index.d.ts +7 -0
- package/translator/package.json +5 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { types as t } from "@marko/compiler";
|
|
2
|
+
import {
|
|
3
|
+
computeNode,
|
|
4
|
+
getTagDef,
|
|
5
|
+
importDefault,
|
|
6
|
+
isLoopTag,
|
|
7
|
+
isNativeTag,
|
|
8
|
+
} from "@marko/compiler/babel-utils";
|
|
9
|
+
import { decode } from "he";
|
|
10
|
+
|
|
11
|
+
import translateAttributes from "../tag/native-tag[vdom]/attributes";
|
|
12
|
+
import { getKeyManager, hasUserKey } from "./key-manager";
|
|
13
|
+
import write from "./vdom-out-write";
|
|
14
|
+
|
|
15
|
+
const skipDirectives = new Set([
|
|
16
|
+
"key",
|
|
17
|
+
"w-bind",
|
|
18
|
+
"no-update",
|
|
19
|
+
"no-update-if",
|
|
20
|
+
"no-update-body",
|
|
21
|
+
"no-update-body-if",
|
|
22
|
+
]);
|
|
23
|
+
const staticNodes = new WeakSet();
|
|
24
|
+
|
|
25
|
+
const mergeStaticCreateVisitor = {
|
|
26
|
+
MarkoText(path, state) {
|
|
27
|
+
const { node } = path;
|
|
28
|
+
state.currentRoot = t.callExpression(
|
|
29
|
+
t.memberExpression(state.currentRoot, t.identifier("t")),
|
|
30
|
+
[t.stringLiteral(decode(node.value))],
|
|
31
|
+
);
|
|
32
|
+
},
|
|
33
|
+
MarkoPlaceholder(path, state) {
|
|
34
|
+
const computed = computeNode(path.node.value);
|
|
35
|
+
state.currentRoot = t.callExpression(
|
|
36
|
+
t.memberExpression(state.currentRoot, t.identifier("t")),
|
|
37
|
+
[
|
|
38
|
+
t.stringLiteral(
|
|
39
|
+
computed && computed.value != null ? `${computed.value}` : "",
|
|
40
|
+
),
|
|
41
|
+
],
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
MarkoTag(path, state) {
|
|
45
|
+
getKeyManager(path).resolveKey(path);
|
|
46
|
+
state.currentRoot = t.callExpression(
|
|
47
|
+
t.memberExpression(state.currentRoot, t.identifier("e")),
|
|
48
|
+
getConstElementArgs(path),
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const analyzeStaticVisitor = {
|
|
54
|
+
MarkoText(path) {
|
|
55
|
+
staticNodes.add(path.node);
|
|
56
|
+
},
|
|
57
|
+
MarkoPlaceholder(path) {
|
|
58
|
+
if (path.node.escape) {
|
|
59
|
+
const computed = computeNode(path.node.value);
|
|
60
|
+
if (computed) {
|
|
61
|
+
staticNodes.add(path.node);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
MarkoTag: {
|
|
66
|
+
enter(path) {
|
|
67
|
+
// needed to handle global keys on elements that don't have specific key attributes
|
|
68
|
+
if (isLoopTag(path)) path.skip();
|
|
69
|
+
},
|
|
70
|
+
exit(path) {
|
|
71
|
+
// check name
|
|
72
|
+
let isStatic =
|
|
73
|
+
isNativeTag(path) &&
|
|
74
|
+
!path.node.attributeTags.length &&
|
|
75
|
+
!path.node.body.attributeTags &&
|
|
76
|
+
!path.node.body.params.length &&
|
|
77
|
+
!path.node.arguments &&
|
|
78
|
+
!hasUserKey(path);
|
|
79
|
+
|
|
80
|
+
const tagDef = getTagDef(path);
|
|
81
|
+
isStatic = isStatic && !tagDef.translator;
|
|
82
|
+
|
|
83
|
+
// check attributes
|
|
84
|
+
isStatic =
|
|
85
|
+
isStatic &&
|
|
86
|
+
path
|
|
87
|
+
.get("attributes")
|
|
88
|
+
.every(
|
|
89
|
+
(attr) =>
|
|
90
|
+
t.isMarkoAttribute(attr) &&
|
|
91
|
+
!(
|
|
92
|
+
attr.node.arguments ||
|
|
93
|
+
attr.node.modifier ||
|
|
94
|
+
skipDirectives.has(attr.node.name) ||
|
|
95
|
+
!computeNode(attr.node.value)
|
|
96
|
+
),
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// check children
|
|
100
|
+
isStatic =
|
|
101
|
+
isStatic &&
|
|
102
|
+
path
|
|
103
|
+
.get("body")
|
|
104
|
+
.get("body")
|
|
105
|
+
.every((t) => staticNodes.has(t.node));
|
|
106
|
+
|
|
107
|
+
if (isStatic) staticNodes.add(path.node);
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export function optimizeStaticVDOM(path) {
|
|
113
|
+
const {
|
|
114
|
+
hub: { file },
|
|
115
|
+
} = path;
|
|
116
|
+
|
|
117
|
+
if (
|
|
118
|
+
!shouldRun(file.markoOpts) ||
|
|
119
|
+
!staticNodes.has(path.node) ||
|
|
120
|
+
staticNodes.has(path.parentPath.parentPath.node)
|
|
121
|
+
) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const identifier = path.scope.generateUidIdentifier("marko_node");
|
|
126
|
+
const state = {
|
|
127
|
+
currentRoot: t.callExpression(
|
|
128
|
+
importDefault(
|
|
129
|
+
file,
|
|
130
|
+
"marko/src/runtime/vdom/helpers/const-element.js",
|
|
131
|
+
"marko_constElement",
|
|
132
|
+
),
|
|
133
|
+
getConstElementArgs(path),
|
|
134
|
+
),
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
path.traverse(mergeStaticCreateVisitor, state);
|
|
138
|
+
|
|
139
|
+
const d = t.variableDeclaration("const", [
|
|
140
|
+
t.variableDeclarator(identifier, state.currentRoot),
|
|
141
|
+
]);
|
|
142
|
+
file.path.node.body.push(d);
|
|
143
|
+
path.replaceWith(write("n", identifier, file._componentInstanceIdentifier));
|
|
144
|
+
path.skip();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function analyzeStaticVDOM(path) {
|
|
148
|
+
if (shouldRun(path.hub.file.markoOpts)) {
|
|
149
|
+
path.traverse(analyzeStaticVisitor);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function shouldRun(markoOpts) {
|
|
154
|
+
return markoOpts.optimize && markoOpts.output !== "html";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function getConstElementArgs(path) {
|
|
158
|
+
const { node } = path;
|
|
159
|
+
return [
|
|
160
|
+
node.name,
|
|
161
|
+
translateAttributes(path, path.get("attributes")),
|
|
162
|
+
t.numericLiteral(node.body.body.length),
|
|
163
|
+
];
|
|
164
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Utilities for executing multi step compiler hooks (code generators in this package).
|
|
2
|
+
|
|
3
|
+
export function enter(plugin, ...args) {
|
|
4
|
+
const fn =
|
|
5
|
+
(plugin &&
|
|
6
|
+
(plugin.enter ||
|
|
7
|
+
(plugin.default && plugin.default.enter) ||
|
|
8
|
+
plugin.default)) ||
|
|
9
|
+
plugin;
|
|
10
|
+
if (typeof fn === "function") {
|
|
11
|
+
fn(...args);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function exit(plugin, ...args) {
|
|
16
|
+
const fn =
|
|
17
|
+
plugin &&
|
|
18
|
+
(plugin.exit || (plugin.default ? plugin.default.exit : undefined));
|
|
19
|
+
if (typeof fn === "function") {
|
|
20
|
+
fn(...args);
|
|
21
|
+
}
|
|
22
|
+
}
|