marko 5.37.47 → 5.37.49
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/node_modules/@internal/components-entry/index.js +17 -10
- package/dist/node_modules/@internal/components-entry-legacy/index-browser.js +3 -3
- package/dist/node_modules/@internal/components-registry/index-browser.js +33 -33
- package/dist/node_modules/@internal/components-registry/index.js +2 -2
- package/dist/node_modules/@internal/components-util/index-browser.js +16 -16
- package/dist/node_modules/@internal/components-util/index.js +4 -4
- 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 +5 -5
- package/dist/node_modules/@internal/preserve-tag/index.js +1 -1
- package/dist/node_modules/@internal/set-immediate/index-browser.js +1 -1
- package/dist/node_modules/@internal/set-immediate/index-worker.js +2 -2
- package/dist/node_modules/@internal/set-immediate/index.js +2 -2
- package/dist/runtime/RenderResult.js +3 -3
- package/dist/runtime/components/Component.js +95 -95
- package/dist/runtime/components/ComponentDef.js +18 -18
- package/dist/runtime/components/ComponentsContext.js +3 -3
- package/dist/runtime/components/GlobalComponentsContext.js +3 -3
- package/dist/runtime/components/KeySequence.js +3 -3
- package/dist/runtime/components/ServerComponent.js +1 -1
- package/dist/runtime/components/State.js +19 -19
- package/dist/runtime/components/attach-detach.js +7 -7
- package/dist/runtime/components/dom-data.js +5 -5
- package/dist/runtime/components/event-delegation.js +9 -9
- package/dist/runtime/components/legacy/defineRenderer-legacy.js +11 -11
- package/dist/runtime/components/legacy/dependencies/index.js +7 -7
- package/dist/runtime/components/legacy/renderer-legacy.js +28 -28
- package/dist/runtime/components/renderer.js +27 -27
- 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 +9 -9
- package/dist/runtime/helpers/render-tag.js +1 -1
- package/dist/runtime/helpers/serialize-noop.js +1 -1
- package/dist/runtime/helpers/style-value.js +1 -1
- package/dist/runtime/helpers/tags-compat/runtime-dom.js +23 -23
- package/dist/runtime/helpers/tags-compat/runtime-html.js +117 -29
- package/dist/runtime/html/AsyncStream.js +20 -20
- package/dist/runtime/html/BufferedWriter.js +2 -2
- package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
- package/dist/runtime/html/helpers/attr.js +2 -2
- package/dist/runtime/html/helpers/data-marko.js +1 -1
- package/dist/runtime/html/helpers/escape-xml.js +1 -1
- package/dist/runtime/html/index.js +1 -1
- package/dist/runtime/renderable.js +3 -3
- package/dist/runtime/vdom/AsyncVDOMBuilder.js +83 -83
- package/dist/runtime/vdom/VComment.js +7 -7
- package/dist/runtime/vdom/VComponent.js +4 -4
- package/dist/runtime/vdom/VDocumentFragment.js +6 -6
- package/dist/runtime/vdom/VElement.js +36 -36
- package/dist/runtime/vdom/VFragment.js +9 -9
- package/dist/runtime/vdom/VNode.js +33 -33
- package/dist/runtime/vdom/VText.js +8 -8
- package/dist/runtime/vdom/helpers/const-element.js +3 -3
- package/dist/runtime/vdom/hot-reload.js +14 -14
- package/dist/runtime/vdom/index.js +1 -1
- package/dist/runtime/vdom/morphdom/fragment.js +5 -5
- package/dist/runtime/vdom/morphdom/helpers.js +5 -5
- package/dist/runtime/vdom/morphdom/index.js +68 -68
- package/dist/runtime/vdom/vdom.js +15 -15
- package/dist/translator/util/get-component-files.js +1 -1
- package/package.json +1 -1
- package/src/node_modules/@internal/components-entry/index.js +19 -12
- package/src/runtime/helpers/tags-compat/runtime-dom.js +3 -3
- package/src/runtime/helpers/tags-compat/runtime-html.js +115 -27
@@ -12,7 +12,7 @@ var specialHtmlRegexp = /[&<]/;
|
|
12
12
|
function virtualizeChildNodes(node, vdomParent, ownerComponent) {
|
13
13
|
var curChild = node.firstChild;
|
14
14
|
while (curChild) {
|
15
|
-
vdomParent.
|
15
|
+
vdomParent.bQ_(virtualize(curChild, ownerComponent));
|
16
16
|
curChild = curChild.nextSibling;
|
17
17
|
}
|
18
18
|
}
|
@@ -20,7 +20,7 @@ function virtualizeChildNodes(node, vdomParent, ownerComponent) {
|
|
20
20
|
function virtualize(node, ownerComponent) {
|
21
21
|
switch (node.nodeType) {
|
22
22
|
case 1:
|
23
|
-
return VElement.
|
23
|
+
return VElement.cj_(node, virtualizeChildNodes, ownerComponent);
|
24
24
|
case 3:
|
25
25
|
return new VText(node.nodeValue, ownerComponent);
|
26
26
|
case 8:
|
@@ -43,7 +43,7 @@ function virtualizeHTML(html, ownerComponent) {
|
|
43
43
|
|
44
44
|
while (curChild) {
|
45
45
|
virtualized = virtualize(curChild, ownerComponent);
|
46
|
-
if (virtualized) vdomFragment.
|
46
|
+
if (virtualized) vdomFragment.bQ_(virtualized);
|
47
47
|
curChild = curChild.nextSibling;
|
48
48
|
}
|
49
49
|
|
@@ -70,19 +70,19 @@ Node_prototype.t = function (value) {
|
|
70
70
|
}
|
71
71
|
}
|
72
72
|
|
73
|
-
this.
|
74
|
-
return this.
|
73
|
+
this.bQ_(vdomNode || new VText(value.toString()));
|
74
|
+
return this.ci_();
|
75
75
|
};
|
76
76
|
|
77
|
-
Node_prototype.
|
78
|
-
return this.
|
77
|
+
Node_prototype.bV_ = function () {
|
78
|
+
return this.bQ_(new VDocumentFragment());
|
79
79
|
};
|
80
80
|
|
81
|
-
exports.
|
82
|
-
exports.
|
83
|
-
exports.
|
84
|
-
exports.
|
85
|
-
exports.
|
86
|
-
exports.
|
87
|
-
exports.
|
88
|
-
exports.
|
81
|
+
exports.bz_ = VComment;
|
82
|
+
exports.bA_ = VDocumentFragment;
|
83
|
+
exports.by_ = VElement;
|
84
|
+
exports.bB_ = VText;
|
85
|
+
exports.bC_ = VComponent;
|
86
|
+
exports.bD_ = VFragment;
|
87
|
+
exports.cj_ = virtualize;
|
88
|
+
exports.bE_ = virtualizeHTML;
|
package/package.json
CHANGED
@@ -34,7 +34,7 @@ function isNotEmpty(obj) {
|
|
34
34
|
function safeStringify(data) {
|
35
35
|
return JSON.stringify(warp10.stringifyPrepare(data)).replace(
|
36
36
|
safeJSONRegExp,
|
37
|
-
safeJSONReplacer
|
37
|
+
safeJSONReplacer,
|
38
38
|
);
|
39
39
|
}
|
40
40
|
|
@@ -76,7 +76,7 @@ function addComponentsFromContext(componentsContext, componentsToHydrate) {
|
|
76
76
|
var input = component.input || 0;
|
77
77
|
var typeName = component.typeName;
|
78
78
|
var customEvents = component.___customEvents;
|
79
|
-
var scope = component.___scope;
|
79
|
+
var scope = component.___scope || undefined;
|
80
80
|
var bubblingDomEvents = component.___bubblingDomEvents;
|
81
81
|
|
82
82
|
var needsState;
|
@@ -183,9 +183,8 @@ function addComponentsFromContext(componentsContext, componentsToHydrate) {
|
|
183
183
|
}
|
184
184
|
}
|
185
185
|
|
186
|
-
function getInitComponentsData(
|
186
|
+
function getInitComponentsData($global, componentDefs) {
|
187
187
|
const len = componentDefs.length;
|
188
|
-
const $global = out.global;
|
189
188
|
const isLast = $global.___isLastFlush;
|
190
189
|
const didSerializeComponents = $global.___didSerializeComponents;
|
191
190
|
const prefix = getRenderId($global);
|
@@ -251,7 +250,7 @@ function getInitComponentsDataFromOut(out) {
|
|
251
250
|
addComponentsFromContext(componentsContext, componentsToHydrate);
|
252
251
|
|
253
252
|
$global.___isLastFlush = true;
|
254
|
-
const data = getInitComponentsData(
|
253
|
+
const data = getInitComponentsData($global, componentsToHydrate);
|
255
254
|
$global.___isLastFlush = undefined;
|
256
255
|
|
257
256
|
if (runtimeId !== DEFAULT_RUNTIME_ID && data) {
|
@@ -267,26 +266,34 @@ function writeInitComponentsCode(out) {
|
|
267
266
|
|
268
267
|
exports.___getInitComponentsCode = function getInitComponentsCode(
|
269
268
|
out,
|
270
|
-
componentDefs
|
269
|
+
componentDefs,
|
271
270
|
) {
|
272
|
-
const
|
271
|
+
const $global = out.global;
|
272
|
+
return getInitComponentsCodeFromData(
|
273
|
+
$global,
|
273
274
|
arguments.length === 2
|
274
|
-
? getInitComponentsData(
|
275
|
-
: getInitComponentsDataFromOut(out)
|
275
|
+
? getInitComponentsData($global, componentDefs)
|
276
|
+
: getInitComponentsDataFromOut(out),
|
277
|
+
);
|
278
|
+
};
|
276
279
|
|
280
|
+
function getInitComponentsCodeFromData($global, initComponentsData) {
|
277
281
|
if (initComponentsData === undefined) {
|
278
282
|
return "";
|
279
283
|
}
|
280
284
|
|
281
|
-
const runtimeId =
|
285
|
+
const runtimeId = $global.runtimeId;
|
282
286
|
const componentGlobalKey =
|
283
287
|
runtimeId === DEFAULT_RUNTIME_ID ? "MC" : runtimeId + "_C";
|
284
288
|
|
285
289
|
return `$${componentGlobalKey}=(window.$${componentGlobalKey}||[]).concat(${safeStringify(
|
286
|
-
initComponentsData
|
290
|
+
initComponentsData,
|
287
291
|
)})`;
|
288
|
-
}
|
292
|
+
}
|
289
293
|
|
294
|
+
exports.___getInitComponentsCodeForDefs = function getInitComponentsCodeForDefs($global, defs) {
|
295
|
+
return getInitComponentsCodeFromData($global, getInitComponentsData($global, defs));
|
296
|
+
}
|
290
297
|
exports.___addComponentsFromContext = addComponentsFromContext;
|
291
298
|
exports.writeInitComponentsCode = writeInitComponentsCode;
|
292
299
|
|
@@ -53,7 +53,7 @@ exports.p = function (domCompat) {
|
|
53
53
|
const tagsRenderer = domCompat.resolveRegistered(_.r, global);
|
54
54
|
const newNode = domCompat.render(out, component, tagsRenderer, input);
|
55
55
|
|
56
|
-
out.bf(
|
56
|
+
out.bf("1", component, !newNode);
|
57
57
|
if (newNode) {
|
58
58
|
out.node({ ___actualize: () => newNode });
|
59
59
|
}
|
@@ -124,7 +124,7 @@ exports.p = function (domCompat) {
|
|
124
124
|
domCompat.init(noopRenderer);
|
125
125
|
|
126
126
|
function renderAndMorph(scope, renderer, renderBody, input) {
|
127
|
-
const out = defaultCreateOut();
|
127
|
+
const out = defaultCreateOut(scope.$global);
|
128
128
|
let host = domCompat.getStartNode(scope);
|
129
129
|
let rootNode = host.fragment;
|
130
130
|
if (!rootNode) {
|
@@ -132,7 +132,7 @@ exports.p = function (domCompat) {
|
|
132
132
|
___componentLookup[scope.m5c]);
|
133
133
|
rootNode = component.___rootNode;
|
134
134
|
host = rootNode.startNode;
|
135
|
-
domCompat.setScopeNodes(host, rootNode.endNode);
|
135
|
+
domCompat.setScopeNodes(host, rootNode.startNode, rootNode.endNode);
|
136
136
|
}
|
137
137
|
const existingComponent = scope.___marko5Component;
|
138
138
|
const componentsContext = ___getComponentsContext(out);
|
@@ -1,4 +1,7 @@
|
|
1
|
-
const
|
1
|
+
const {
|
2
|
+
___getInitComponentsCodeForDefs,
|
3
|
+
___addComponentsFromContext,
|
4
|
+
} = require("@internal/components-entry");
|
2
5
|
const {
|
3
6
|
___getComponentsContext,
|
4
7
|
} = require("../../components/ComponentsContext");
|
@@ -7,15 +10,56 @@ const defaultCreateOut = require("../../createOut");
|
|
7
10
|
const dynamicTag5 = require("../dynamic-tag");
|
8
11
|
|
9
12
|
exports.p = function (htmlCompat) {
|
13
|
+
const writersByGlobal = new WeakMap();
|
10
14
|
const isMarko6 = (fn) => htmlCompat.isTagsAPI(fn);
|
11
15
|
const isMarko5 = (fn) => !isMarko6(fn);
|
12
|
-
const
|
13
|
-
const
|
14
|
-
const writer = state.writer;
|
15
|
-
state.events.emit("___toString", writer);
|
16
|
-
htmlCompat.writeScript(writer._scripts);
|
16
|
+
const writeClassAPIResultToTagsAPI = (result) => {
|
17
|
+
const { writer } = result.out._state;
|
17
18
|
htmlCompat.write(writer._content);
|
19
|
+
htmlCompat.writeScript(writer._script);
|
20
|
+
writer._content = writer._scripts = "";
|
18
21
|
};
|
22
|
+
const flushScripts = ($global, flushDefs) => {
|
23
|
+
const writers = writersByGlobal.get($global);
|
24
|
+
if (!writers) return "";
|
25
|
+
|
26
|
+
const { classAPI, tagsAPI } = writers;
|
27
|
+
let scripts = "";
|
28
|
+
let componentDefs = flushDefs;
|
29
|
+
|
30
|
+
if (classAPI.length) {
|
31
|
+
componentDefs = flushDefs ? flushDefs.concat(classAPI) : classAPI;
|
32
|
+
writers.classAPI = [];
|
33
|
+
}
|
34
|
+
|
35
|
+
if (componentDefs) {
|
36
|
+
scripts = ___getInitComponentsCodeForDefs($global, componentDefs);
|
37
|
+
}
|
38
|
+
|
39
|
+
if (tagsAPI.length) {
|
40
|
+
const [chunk] = tagsAPI;
|
41
|
+
for (let i = 1; i < tagsAPI.length; i++) {
|
42
|
+
chunk.append(tagsAPI[i]);
|
43
|
+
}
|
44
|
+
|
45
|
+
if (!chunk.boundary.done) {
|
46
|
+
throw new Error(
|
47
|
+
"Cannot serialize promise across tags/class compat layer.",
|
48
|
+
);
|
49
|
+
}
|
50
|
+
|
51
|
+
scripts = concatScripts(chunk.flushScript().scripts, scripts);
|
52
|
+
writers.tagsAPI = [];
|
53
|
+
}
|
54
|
+
|
55
|
+
return scripts;
|
56
|
+
};
|
57
|
+
|
58
|
+
htmlCompat.onFlush((chunk) => {
|
59
|
+
chunk.render(() => {
|
60
|
+
chunk.writeScript(flushScripts(chunk.boundary.state.$global));
|
61
|
+
});
|
62
|
+
});
|
19
63
|
|
20
64
|
dynamicTag5.___runtimeCompat = function tagsToVdom(
|
21
65
|
tagsRenderer,
|
@@ -42,11 +86,33 @@ exports.p = function (htmlCompat) {
|
|
42
86
|
const TagsCompatId = "tags-compat";
|
43
87
|
const TagsCompat = createRenderer(
|
44
88
|
function (_, out, componentDef, component) {
|
89
|
+
// class to tags
|
90
|
+
const $global = out.global;
|
91
|
+
let writers = writersByGlobal.get($global);
|
92
|
+
if (!writers) {
|
93
|
+
writersByGlobal.set($global, (writers = { classAPI: [], tagsAPI: [] }));
|
94
|
+
out.prependListener("___toString", (writer) => {
|
95
|
+
const defs = writer._data?.componentDefs;
|
96
|
+
const scripts = flushScripts($global, defs);
|
97
|
+
if (scripts) {
|
98
|
+
if (defs) writer._data.componentDefs = undefined;
|
99
|
+
writer.script(scripts);
|
100
|
+
}
|
101
|
+
});
|
102
|
+
}
|
103
|
+
|
45
104
|
const input = _.i;
|
46
105
|
const tagsRenderer = _.r;
|
47
|
-
const willRerender = componentDef._wrr;
|
48
|
-
out.bf(
|
49
|
-
htmlCompat.render(
|
106
|
+
const willRerender = componentDef._wrr || htmlCompat.isInResumedBranch();
|
107
|
+
out.bf("1", component, willRerender);
|
108
|
+
htmlCompat.render(
|
109
|
+
tagsRenderer,
|
110
|
+
willRerender,
|
111
|
+
out,
|
112
|
+
component,
|
113
|
+
input,
|
114
|
+
writers.tagsAPI,
|
115
|
+
);
|
50
116
|
out.ef();
|
51
117
|
},
|
52
118
|
// eslint-disable-next-line no-constant-condition
|
@@ -64,8 +130,9 @@ exports.p = function (htmlCompat) {
|
|
64
130
|
);
|
65
131
|
|
66
132
|
htmlCompat.patchDynamicTag(function getRenderer(scopeId, accessor, tag) {
|
67
|
-
|
68
|
-
|
133
|
+
if (!tag || isMarko6(tag._ || tag.content || tag)) {
|
134
|
+
return tag;
|
135
|
+
}
|
69
136
|
|
70
137
|
const renderer5 =
|
71
138
|
tag._ ||
|
@@ -78,16 +145,24 @@ exports.p = function (htmlCompat) {
|
|
78
145
|
htmlCompat.registerRenderBody(renderBody5);
|
79
146
|
}
|
80
147
|
return (input, ...args) => {
|
81
|
-
|
82
|
-
const
|
148
|
+
// tags to class
|
149
|
+
const $global = htmlCompat.$global();
|
150
|
+
htmlCompat.ensureState($global);
|
151
|
+
let writers = writersByGlobal.get($global);
|
152
|
+
if (!writers) {
|
153
|
+
writersByGlobal.set($global, (writers = { classAPI: [], tagsAPI: [] }));
|
154
|
+
}
|
155
|
+
|
156
|
+
const out = defaultCreateOut($global);
|
157
|
+
const branchId = htmlCompat.nextScopeId();
|
83
158
|
let customEvents;
|
84
|
-
htmlCompat.nextScopeId();
|
85
159
|
|
86
160
|
if (renderer5) {
|
87
|
-
const
|
161
|
+
const originalInput = input;
|
162
|
+
input = {};
|
88
163
|
|
89
|
-
for (const key in
|
90
|
-
const value =
|
164
|
+
for (const key in originalInput) {
|
165
|
+
const value = originalInput[key];
|
91
166
|
if (/^on[-A-Z]/.test(key)) {
|
92
167
|
if (typeof value === "function") {
|
93
168
|
(customEvents || (customEvents = [])).push([
|
@@ -97,28 +172,37 @@ exports.p = function (htmlCompat) {
|
|
97
172
|
value.toJSON = htmlCompat.toJSON;
|
98
173
|
}
|
99
174
|
} else {
|
100
|
-
|
175
|
+
input[key === "content" ? "renderBody" : key] = value;
|
101
176
|
}
|
102
177
|
}
|
103
|
-
|
178
|
+
}
|
179
|
+
|
180
|
+
if (renderer5) {
|
181
|
+
renderer5(input, out);
|
104
182
|
} else {
|
105
183
|
renderBody5(out, input, ...args);
|
106
184
|
}
|
107
185
|
|
108
186
|
const componentsContext = ___getComponentsContext(out);
|
109
|
-
const
|
110
|
-
if (
|
111
|
-
|
112
|
-
|
187
|
+
const componentDef = componentsContext.___components[0];
|
188
|
+
if (componentDef) {
|
189
|
+
componentDef.___component.___customEvents = customEvents;
|
190
|
+
componentDef._wrr = true;
|
191
|
+
componentDef.___flags |= 1; // FLAG_WILL_RERENDER_IN_BROWSER
|
192
|
+
htmlCompat.writeSetScopeForComponent(branchId, componentDef.id);
|
113
193
|
}
|
114
194
|
|
115
|
-
initComponentsTag({}, out);
|
116
|
-
|
117
195
|
let async;
|
118
196
|
out.once("finish", (result) => {
|
197
|
+
if (result.out.___components) {
|
198
|
+
___addComponentsFromContext(
|
199
|
+
result.out.___components,
|
200
|
+
writers.classAPI,
|
201
|
+
);
|
202
|
+
}
|
119
203
|
if (!async) {
|
120
204
|
async = false;
|
121
|
-
|
205
|
+
writeClassAPIResultToTagsAPI(result);
|
122
206
|
}
|
123
207
|
});
|
124
208
|
|
@@ -126,10 +210,14 @@ exports.p = function (htmlCompat) {
|
|
126
210
|
|
127
211
|
if (async !== false) {
|
128
212
|
async = true;
|
129
|
-
htmlCompat.fork(scopeId, accessor, out,
|
213
|
+
htmlCompat.fork(scopeId, accessor, out, writeClassAPIResultToTagsAPI);
|
130
214
|
}
|
131
215
|
};
|
132
216
|
});
|
133
217
|
|
134
218
|
return htmlCompat.registerRenderer;
|
135
219
|
};
|
220
|
+
|
221
|
+
function concatScripts(a, b) {
|
222
|
+
return a ? (b ? a + ";" + b : a) : b;
|
223
|
+
}
|