marko 5.33.3 → 5.33.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/runtime/helpers/tags-compat/dom-debug.js +1 -0
- package/dist/runtime/helpers/tags-compat/dom-debug.mjs +3 -0
- package/dist/runtime/helpers/tags-compat/dom.js +1 -0
- package/dist/runtime/helpers/tags-compat/dom.mjs +3 -0
- package/dist/runtime/helpers/tags-compat/html-debug.js +3 -0
- package/dist/runtime/helpers/tags-compat/html-debug.mjs +3 -0
- package/dist/runtime/helpers/tags-compat/html.js +1 -0
- package/dist/runtime/helpers/tags-compat/html.mjs +3 -0
- package/dist/runtime/helpers/tags-compat/runtime-dom.js +231 -0
- package/dist/runtime/helpers/tags-compat/runtime-html.js +171 -0
- package/dist/runtime/html/AsyncStream.js +12 -12
- package/dist/runtime/html/helpers/_dynamic-attr.js +2 -2
- package/dist/runtime/html/helpers/attr.js +3 -3
- package/dist/runtime/html/helpers/data-marko.js +1 -1
- package/dist/runtime/html/helpers/escape-quotes.js +1 -1
- package/dist/runtime/html/helpers/escape-xml.js +1 -1
- package/dist/runtime/renderable.js +3 -3
- package/dist/runtime/vdom/AsyncVDOMBuilder.js +67 -67
- package/dist/runtime/vdom/VComponent.js +3 -3
- package/dist/runtime/vdom/VDocumentFragment.js +7 -7
- package/dist/runtime/vdom/VElement.js +35 -35
- package/dist/runtime/vdom/VFragment.js +5 -5
- package/dist/runtime/vdom/VNode.js +30 -30
- 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 +2 -2
- package/dist/runtime/vdom/morphdom/fragment.js +3 -3
- package/dist/runtime/vdom/morphdom/helpers.js +1 -1
- package/dist/runtime/vdom/morphdom/index.js +31 -31
- package/dist/runtime/vdom/vdom.js +14 -14
- package/package.json +4 -4
- package/src/runtime/helpers/tags-compat/dom-debug.js +1 -0
- package/src/runtime/helpers/tags-compat/dom-debug.mjs +3 -0
- package/src/runtime/helpers/tags-compat/dom.js +1 -0
- package/src/runtime/helpers/tags-compat/dom.mjs +3 -0
- package/src/runtime/helpers/tags-compat/html-debug.js +3 -0
- package/src/runtime/helpers/tags-compat/html-debug.mjs +3 -0
- package/src/runtime/helpers/tags-compat/html.js +1 -0
- package/src/runtime/helpers/tags-compat/html.mjs +3 -0
- package/src/runtime/helpers/tags-compat/runtime-dom.js +231 -0
- package/src/runtime/helpers/tags-compat/runtime-html.js +171 -0
- package/dist/runtime/helpers/tags-compat-dom.js +0 -276
- package/dist/runtime/helpers/tags-compat-html.js +0 -172
- package/src/runtime/helpers/tags-compat-dom.js +0 -276
- package/src/runtime/helpers/tags-compat-html.js +0 -172
@@ -0,0 +1,171 @@
|
|
1
|
+
const initComponentsTag = require("../../../core-tags/components/init-components-tag");
|
2
|
+
const {
|
3
|
+
___getComponentsContext,
|
4
|
+
} = require("../../components/ComponentsContext");
|
5
|
+
const createRenderer = require("../../components/renderer");
|
6
|
+
const defaultCreateOut = require("../../createOut");
|
7
|
+
const dynamicTag5 = require("../dynamic-tag");
|
8
|
+
|
9
|
+
exports.p = function (tagsAPI) {
|
10
|
+
const {
|
11
|
+
patchDynamicTag,
|
12
|
+
createRenderFn,
|
13
|
+
fork,
|
14
|
+
write,
|
15
|
+
makeSerializable,
|
16
|
+
register,
|
17
|
+
writeScope,
|
18
|
+
nextScopeId,
|
19
|
+
getRegistryInfo,
|
20
|
+
} = tagsAPI;
|
21
|
+
const FN_TO_JSON = function () {
|
22
|
+
// TODO: this should instead return an object that contains getRegistryInfo
|
23
|
+
// then in the dom-compat, handle that object to lookup the function in the registry
|
24
|
+
// (we also need to do this for events)
|
25
|
+
return getRegistryInfo(this);
|
26
|
+
};
|
27
|
+
|
28
|
+
const isMarko6 = (fn) => !!fn.___isTagsAPI;
|
29
|
+
const isMarko5 = (fn) => !fn.___isTagsAPI;
|
30
|
+
|
31
|
+
dynamicTag5.___runtimeCompat = function tagsToVdom(
|
32
|
+
tagsRenderer,
|
33
|
+
renderBody,
|
34
|
+
args,
|
35
|
+
) {
|
36
|
+
if (tagsRenderer ? isMarko5(tagsRenderer) : isMarko5(renderBody))
|
37
|
+
return tagsRenderer;
|
38
|
+
|
39
|
+
if (!tagsRenderer && renderBody) {
|
40
|
+
renderBody.toJSON = FN_TO_JSON;
|
41
|
+
}
|
42
|
+
|
43
|
+
return (input, out) =>
|
44
|
+
TagsCompat(
|
45
|
+
args
|
46
|
+
? { i: args, r: (args) => (tagsRenderer || renderBody)(...args) }
|
47
|
+
: { i: input, r: tagsRenderer || renderBody },
|
48
|
+
out,
|
49
|
+
);
|
50
|
+
};
|
51
|
+
|
52
|
+
const TagsCompatId = "tags-compat";
|
53
|
+
const TagsCompat = createRenderer(
|
54
|
+
function (_, out, componentDef, component) {
|
55
|
+
const input = _.i;
|
56
|
+
const tagsRenderer = _.r;
|
57
|
+
const renderFn = createRenderFn(tagsRenderer);
|
58
|
+
const $global = out.global;
|
59
|
+
const streamData = ($global.streamData = $global.streamData || {});
|
60
|
+
|
61
|
+
$global.serializedGlobals = $global.serializedGlobals || {};
|
62
|
+
$global.serializedGlobals.componentIdToScopeId = true;
|
63
|
+
$global.componentIdToScopeId = $global.componentIdToScopeId || {};
|
64
|
+
$global.componentIdToScopeId[component.id] = streamData.scopeId || 0;
|
65
|
+
out.bf(out.___assignedKey, component, true);
|
66
|
+
renderFn(out.beginAsync(), input, {}, streamData);
|
67
|
+
out.ef();
|
68
|
+
},
|
69
|
+
// eslint-disable-next-line no-constant-condition
|
70
|
+
"MARKO_DEBUG"
|
71
|
+
? {
|
72
|
+
t: TagsCompatId,
|
73
|
+
d: true,
|
74
|
+
}
|
75
|
+
: {
|
76
|
+
t: TagsCompatId,
|
77
|
+
},
|
78
|
+
{},
|
79
|
+
);
|
80
|
+
|
81
|
+
patchDynamicTag(
|
82
|
+
function getRenderer(tag) {
|
83
|
+
const renderer = tag._ || tag.renderBody || tag;
|
84
|
+
if (isMarko6(renderer)) return renderer;
|
85
|
+
|
86
|
+
const renderer5 =
|
87
|
+
tag._ ||
|
88
|
+
tag.render ||
|
89
|
+
(tag.renderer && tag.renderer.renderer) ||
|
90
|
+
tag.renderer;
|
91
|
+
const renderBody5 = tag.renderBody || tag;
|
92
|
+
|
93
|
+
return (input, ...args) => {
|
94
|
+
const out = defaultCreateOut();
|
95
|
+
let customEvents;
|
96
|
+
|
97
|
+
out.global.streamData = tagsAPI.$_streamData;
|
98
|
+
|
99
|
+
if (renderer5) {
|
100
|
+
const normalizedInput = {};
|
101
|
+
|
102
|
+
for (const key in input) {
|
103
|
+
let value = input[key];
|
104
|
+
if (key.startsWith("on") && typeof value === "function") {
|
105
|
+
const c = key[2];
|
106
|
+
customEvents = customEvents || [];
|
107
|
+
customEvents.push([
|
108
|
+
(c === "-" ? "" : c.toLowerCase()) + key.slice(3),
|
109
|
+
value,
|
110
|
+
]);
|
111
|
+
value.toJSON = FN_TO_JSON;
|
112
|
+
} else {
|
113
|
+
normalizedInput[key] = input[key];
|
114
|
+
}
|
115
|
+
}
|
116
|
+
renderer5(normalizedInput, out);
|
117
|
+
} else {
|
118
|
+
renderBody5(out, input, ...args);
|
119
|
+
}
|
120
|
+
|
121
|
+
const componentsContext = ___getComponentsContext(out);
|
122
|
+
const component = componentsContext.___components[0];
|
123
|
+
if (component) {
|
124
|
+
component.___component.___customEvents = customEvents;
|
125
|
+
writeScope(nextScopeId(), {
|
126
|
+
m5c: component.id,
|
127
|
+
});
|
128
|
+
}
|
129
|
+
|
130
|
+
initComponentsTag({}, out);
|
131
|
+
|
132
|
+
let async;
|
133
|
+
out.once("finish", (result) => {
|
134
|
+
if (!async) {
|
135
|
+
async = false;
|
136
|
+
write(result.toString());
|
137
|
+
}
|
138
|
+
});
|
139
|
+
|
140
|
+
out.end();
|
141
|
+
|
142
|
+
if (async !== false) {
|
143
|
+
async = true;
|
144
|
+
fork(out, (result) => {
|
145
|
+
write(result.toString());
|
146
|
+
});
|
147
|
+
}
|
148
|
+
};
|
149
|
+
},
|
150
|
+
function createRenderer(renderFn) {
|
151
|
+
renderFn.___isTagsAPI = true;
|
152
|
+
return renderFn;
|
153
|
+
},
|
154
|
+
);
|
155
|
+
|
156
|
+
function dummyCreate5to6Renderer() {}
|
157
|
+
|
158
|
+
register(dummyCreate5to6Renderer, "@marko/tags-compat-5-to-6");
|
159
|
+
|
160
|
+
return function serialized5to6(renderer, id) {
|
161
|
+
const dummyRenderer = () => {};
|
162
|
+
register(dummyRenderer, id);
|
163
|
+
return makeSerializable(renderer, (s) =>
|
164
|
+
s
|
165
|
+
.value(dummyCreate5to6Renderer)
|
166
|
+
.code("(")
|
167
|
+
.value(dummyRenderer)
|
168
|
+
.code(",!0)"),
|
169
|
+
);
|
170
|
+
};
|
171
|
+
};
|
@@ -1,276 +0,0 @@
|
|
1
|
-
"use strict";const { _i_ } = require("@internal/components-util");
|
2
|
-
const { R_ } = require("../components/ComponentsContext");
|
3
|
-
|
4
|
-
const {
|
5
|
-
prepare,
|
6
|
-
runEffects,
|
7
|
-
patchConditionals,
|
8
|
-
createScopeWithRenderer,
|
9
|
-
queueEffect,
|
10
|
-
scopeLookup,
|
11
|
-
getRegisteredWithScope,
|
12
|
-
register
|
13
|
-
} = require(
|
14
|
-
// eslint-disable-next-line no-constant-condition
|
15
|
-
"@marko/runtime-tags/dom"
|
16
|
-
);
|
17
|
-
const defineComponent = require("../components/defineComponent");
|
18
|
-
const { r: registerComponent } = require("../components/registry");
|
19
|
-
const createRenderer = require("../components/renderer");
|
20
|
-
const defaultCreateOut = require("../createOut");
|
21
|
-
const morphdom = require("../vdom/morphdom");
|
22
|
-
const { _h_ } = require("../vdom/morphdom/fragment");
|
23
|
-
const dynamicTag = require("./dynamic-tag");
|
24
|
-
|
25
|
-
dynamicTag.bk_ = function tagsToVdom(
|
26
|
-
tagsRenderer,
|
27
|
-
renderBody,
|
28
|
-
args)
|
29
|
-
{
|
30
|
-
if (
|
31
|
-
tagsRenderer ?
|
32
|
-
tagsRenderer.bl_ === undefined :
|
33
|
-
!Array.isArray(renderBody) && renderBody?.bl_ === undefined)
|
34
|
-
|
35
|
-
return tagsRenderer;
|
36
|
-
|
37
|
-
return (input, out) =>
|
38
|
-
TagsCompat({ i: args ? args : input, r: tagsRenderer || renderBody }, out);
|
39
|
-
};
|
40
|
-
|
41
|
-
const TagsCompatId = "tags-compat";
|
42
|
-
const TagsCompat = createRenderer(
|
43
|
-
function (_, out, componentDef, component) {
|
44
|
-
let existing = false;
|
45
|
-
const isHydrate =
|
46
|
-
R_(out).o_._W_;
|
47
|
-
const input = Array.isArray(_.i) ? _.i : [_.i];
|
48
|
-
const tagsRenderer = resolveRegistered(_.r);
|
49
|
-
const args = tagsRenderer.bm_;
|
50
|
-
|
51
|
-
component.effects = prepare(() => {
|
52
|
-
if (isHydrate) {
|
53
|
-
const scopeId = out.global.componentIdToScopeId[component.id];
|
54
|
-
component.scope = scopeLookup[scopeId];
|
55
|
-
}
|
56
|
-
if (!component.scope) {
|
57
|
-
component.scope = createScopeWithRenderer(
|
58
|
-
tagsRenderer /* out.global as context */
|
59
|
-
);
|
60
|
-
for (const signal of tagsRenderer.bn_) {
|
61
|
-
signal(component.scope, true);
|
62
|
-
}
|
63
|
-
} else {
|
64
|
-
args && args(component.scope, input, 1);
|
65
|
-
existing = true;
|
66
|
-
}
|
67
|
-
args && args(component.scope, input);
|
68
|
-
});
|
69
|
-
out.bf(out._Y_, component, existing);
|
70
|
-
if (!existing) {
|
71
|
-
out.node({
|
72
|
-
bo_: () =>
|
73
|
-
component.scope.bp_ === component.scope.bq_ ?
|
74
|
-
component.scope.bp_ :
|
75
|
-
component.scope.bp_.parentNode
|
76
|
-
});
|
77
|
-
}
|
78
|
-
out.ef();
|
79
|
-
},
|
80
|
-
// eslint-disable-next-line no-constant-condition
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
{
|
87
|
-
t: TagsCompatId
|
88
|
-
},
|
89
|
-
{}
|
90
|
-
);
|
91
|
-
|
92
|
-
registerComponent(TagsCompatId, () => ({
|
93
|
-
_: TagsCompat,
|
94
|
-
Component: defineComponent(
|
95
|
-
{
|
96
|
-
onMount() {
|
97
|
-
runEffects(this.effects);
|
98
|
-
},
|
99
|
-
onUpdate() {
|
100
|
-
runEffects(this.effects);
|
101
|
-
}
|
102
|
-
},
|
103
|
-
TagsCompat
|
104
|
-
)
|
105
|
-
}));
|
106
|
-
|
107
|
-
// (
|
108
|
-
// nodeAccessor: Accessor,
|
109
|
-
// dynamicTagAttrs?: IntersectionSignal,
|
110
|
-
// intersection?: IntersectionSignal,
|
111
|
-
// valueWithIntersection?: ValueSignal
|
112
|
-
// )
|
113
|
-
|
114
|
-
const rendererCache = new WeakMap();
|
115
|
-
|
116
|
-
patchConditionals((conditional) => (...args) => {
|
117
|
-
const signal = conditional(...args);
|
118
|
-
const hasAttrs = args.length > 1;
|
119
|
-
return (scope, renderer, clean) => {
|
120
|
-
return signal(scope, create5to6Renderer(renderer, hasAttrs), clean);
|
121
|
-
};
|
122
|
-
});
|
123
|
-
|
124
|
-
function create5to6Renderer(renderer, hasAttrs) {
|
125
|
-
let newRenderer = renderer;
|
126
|
-
if (renderer) {
|
127
|
-
const rendererFromAnywhere =
|
128
|
-
renderer._ ||
|
129
|
-
renderer.render ||
|
130
|
-
renderer.renderer && renderer.renderer.renderer ||
|
131
|
-
renderer.renderer;
|
132
|
-
const isMarko6 = rendererFromAnywhere ?
|
133
|
-
rendererFromAnywhere.bl_ :
|
134
|
-
renderer.bl_;
|
135
|
-
|
136
|
-
if (typeof renderer !== "string" && !isMarko6) {
|
137
|
-
newRenderer = rendererCache.get(renderer);
|
138
|
-
if (!newRenderer) {
|
139
|
-
const { Component } = renderer;
|
140
|
-
if (Component) {
|
141
|
-
const setCustomEvents = Component.prototype.aB_;
|
142
|
-
Component.prototype.aB_ = function (
|
143
|
-
customEvents,
|
144
|
-
scopeId)
|
145
|
-
{
|
146
|
-
for (const customEvent of customEvents) {
|
147
|
-
customEvent[1] = resolveRegistered(customEvent[1]);
|
148
|
-
}
|
149
|
-
|
150
|
-
setCustomEvents.call(this, customEvents, scopeId);
|
151
|
-
};
|
152
|
-
}
|
153
|
-
newRenderer = {
|
154
|
-
br_(scope) {
|
155
|
-
if (!hasAttrs) {
|
156
|
-
renderAndMorph(scope, rendererFromAnywhere, renderer, {});
|
157
|
-
}
|
158
|
-
},
|
159
|
-
bl_() {
|
160
|
-
const realFragment = document.createDocumentFragment();
|
161
|
-
_h_(null, null, realFragment);
|
162
|
-
return realFragment;
|
163
|
-
},
|
164
|
-
bs_: 1,
|
165
|
-
bm_(scope, input, clean) {
|
166
|
-
if (clean) return;
|
167
|
-
renderAndMorph(scope, rendererFromAnywhere, renderer, input);
|
168
|
-
}
|
169
|
-
};
|
170
|
-
rendererCache.set(renderer, newRenderer);
|
171
|
-
}
|
172
|
-
}
|
173
|
-
}
|
174
|
-
return newRenderer;
|
175
|
-
}
|
176
|
-
|
177
|
-
register("@marko/tags-compat-5-to-6", create5to6Renderer);
|
178
|
-
|
179
|
-
function renderAndMorph(scope, renderer, renderBody, input) {
|
180
|
-
const out = defaultCreateOut();
|
181
|
-
let rootNode = scope.bp_.fragment;
|
182
|
-
if (!rootNode) {
|
183
|
-
const component = scope.marko5Component = _i_[scope.m5c];
|
184
|
-
rootNode = component._A_;
|
185
|
-
scope.bp_ = rootNode.startNode;
|
186
|
-
scope.bq_ = rootNode.endNode;
|
187
|
-
}
|
188
|
-
const host = scope.bp_;
|
189
|
-
const existingComponent = scope.marko5Component;
|
190
|
-
const componentsContext = R_(out);
|
191
|
-
const globalComponentsContext = componentsContext.o_;
|
192
|
-
let customEvents;
|
193
|
-
globalComponentsContext.ax_ = existingComponent;
|
194
|
-
out.sync();
|
195
|
-
if (renderer) {
|
196
|
-
const [rawInput] = input;
|
197
|
-
const normalizedInput = {};
|
198
|
-
|
199
|
-
for (const key in rawInput) {
|
200
|
-
let value = rawInput[key];
|
201
|
-
if (key.startsWith("on")) {
|
202
|
-
const c = key[2];
|
203
|
-
customEvents = customEvents || {};
|
204
|
-
customEvents[(c === "-" ? "" : c.toLowerCase()) + key.slice(3)] = [
|
205
|
-
value];
|
206
|
-
|
207
|
-
} else {
|
208
|
-
normalizedInput[key] = rawInput[key];
|
209
|
-
}
|
210
|
-
}
|
211
|
-
|
212
|
-
renderer(normalizedInput, out);
|
213
|
-
} else {
|
214
|
-
RenderBodyComponent({ renderBody, args: input }, out);
|
215
|
-
}
|
216
|
-
|
217
|
-
queueEffect(scope, () => {
|
218
|
-
const targetNode = out.af_().ay_;
|
219
|
-
morphdom(rootNode, targetNode, host, componentsContext);
|
220
|
-
const componentDefs = componentsContext.ad_(
|
221
|
-
getRootNode(host)
|
222
|
-
);
|
223
|
-
const component = componentDefs[0].r_;
|
224
|
-
component._A_ = rootNode;
|
225
|
-
component.N_ = input[0];
|
226
|
-
component.U_ = customEvents;
|
227
|
-
scope.marko5Component = component;
|
228
|
-
});
|
229
|
-
}
|
230
|
-
|
231
|
-
function getRootNode(el) {
|
232
|
-
var cur = el;
|
233
|
-
while (cur.parentNode) cur = cur.parentNode;
|
234
|
-
return cur;
|
235
|
-
}
|
236
|
-
|
237
|
-
const RenderBodyComponentId = "renderbody-renderer";
|
238
|
-
const RenderBodyComponent = createRenderer(
|
239
|
-
function (input, out, _componentDef) {
|
240
|
-
dynamicTag(
|
241
|
-
out,
|
242
|
-
input.renderBody,
|
243
|
-
null,
|
244
|
-
null,
|
245
|
-
input.args,
|
246
|
-
null,
|
247
|
-
_componentDef,
|
248
|
-
"0"
|
249
|
-
);
|
250
|
-
},
|
251
|
-
// eslint-disable-next-line no-constant-condition
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
{
|
259
|
-
t: RenderBodyComponentId,
|
260
|
-
i: true
|
261
|
-
},
|
262
|
-
{}
|
263
|
-
);
|
264
|
-
|
265
|
-
registerComponent(RenderBodyComponentId, () => ({
|
266
|
-
_: RenderBodyComponent,
|
267
|
-
Component: defineComponent({}, RenderBodyComponent)
|
268
|
-
}));
|
269
|
-
|
270
|
-
function resolveRegistered(renderer) {
|
271
|
-
if (!Array.isArray(renderer)) return renderer;
|
272
|
-
|
273
|
-
const [registerId, scopeId] = renderer;
|
274
|
-
const scope = scopeLookup[scopeId];
|
275
|
-
return getRegisteredWithScope(registerId, scope);
|
276
|
-
}
|
@@ -1,172 +0,0 @@
|
|
1
|
-
"use strict";const initComponentsTag = require("../../core-tags/components/init-components-tag");
|
2
|
-
const { R_ } = require("../components/ComponentsContext");
|
3
|
-
|
4
|
-
const tagsAPI = require(
|
5
|
-
// eslint-disable-next-line no-constant-condition
|
6
|
-
"@marko/runtime-tags/html"
|
7
|
-
);
|
8
|
-
const createRenderer = require("../components/renderer");
|
9
|
-
const defaultCreateOut = require("../createOut");
|
10
|
-
const dynamicTag5 = require("./dynamic-tag");
|
11
|
-
const {
|
12
|
-
patchDynamicTag,
|
13
|
-
createRenderFn,
|
14
|
-
fork,
|
15
|
-
write,
|
16
|
-
makeSerializable,
|
17
|
-
register,
|
18
|
-
writeScope,
|
19
|
-
nextScopeId,
|
20
|
-
getRegistryInfo
|
21
|
-
} = tagsAPI;
|
22
|
-
|
23
|
-
const FN_TO_JSON = function () {
|
24
|
-
// TODO: this should instead return an object that contains getRegistryInfo
|
25
|
-
// then in the dom-compat, handle that object to lookup the function in the registry
|
26
|
-
// (we also need to do this for events)
|
27
|
-
return getRegistryInfo(this);
|
28
|
-
};
|
29
|
-
|
30
|
-
const isMarko6 = (fn) => !!fn.bt_;
|
31
|
-
const isMarko5 = (fn) => !fn.bt_;
|
32
|
-
|
33
|
-
dynamicTag5.bk_ = function tagsToVdom(
|
34
|
-
tagsRenderer,
|
35
|
-
renderBody,
|
36
|
-
args)
|
37
|
-
{
|
38
|
-
if (tagsRenderer ? isMarko5(tagsRenderer) : isMarko5(renderBody))
|
39
|
-
return tagsRenderer;
|
40
|
-
|
41
|
-
if (!tagsRenderer && renderBody) {
|
42
|
-
renderBody.toJSON = FN_TO_JSON;
|
43
|
-
}
|
44
|
-
|
45
|
-
return (input, out) =>
|
46
|
-
TagsCompat(
|
47
|
-
args ?
|
48
|
-
{ i: args, r: (args) => (tagsRenderer || renderBody)(...args) } :
|
49
|
-
{ i: input, r: tagsRenderer || renderBody },
|
50
|
-
out
|
51
|
-
);
|
52
|
-
};
|
53
|
-
|
54
|
-
const TagsCompatId = "tags-compat";
|
55
|
-
const TagsCompat = createRenderer(
|
56
|
-
function (_, out, componentDef, component) {
|
57
|
-
const input = _.i;
|
58
|
-
const tagsRenderer = _.r;
|
59
|
-
const renderFn = createRenderFn(tagsRenderer);
|
60
|
-
const $global = out.global;
|
61
|
-
const streamData = $global.streamData = $global.streamData || {};
|
62
|
-
|
63
|
-
$global.serializedGlobals = $global.serializedGlobals || {};
|
64
|
-
$global.serializedGlobals.componentIdToScopeId = true;
|
65
|
-
$global.componentIdToScopeId = $global.componentIdToScopeId || {};
|
66
|
-
$global.componentIdToScopeId[component.id] = streamData.scopeId || 0;
|
67
|
-
out.bf(out._Y_, component, true);
|
68
|
-
renderFn(out.beginAsync(), input, {}, streamData);
|
69
|
-
out.ef();
|
70
|
-
},
|
71
|
-
// eslint-disable-next-line no-constant-condition
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
{
|
78
|
-
t: TagsCompatId
|
79
|
-
},
|
80
|
-
{}
|
81
|
-
);
|
82
|
-
|
83
|
-
patchDynamicTag(
|
84
|
-
function getRenderer(tag) {
|
85
|
-
const renderer = tag._ || tag.renderBody || tag;
|
86
|
-
if (isMarko6(renderer)) return renderer;
|
87
|
-
|
88
|
-
const renderer5 =
|
89
|
-
tag._ ||
|
90
|
-
tag.render ||
|
91
|
-
tag.renderer && tag.renderer.renderer ||
|
92
|
-
tag.renderer;
|
93
|
-
const renderBody5 = tag.renderBody || tag;
|
94
|
-
|
95
|
-
return (input, ...args) => {
|
96
|
-
const out = defaultCreateOut();
|
97
|
-
let customEvents;
|
98
|
-
|
99
|
-
out.global.streamData = tagsAPI.$_streamData;
|
100
|
-
|
101
|
-
if (renderer5) {
|
102
|
-
const normalizedInput = {};
|
103
|
-
|
104
|
-
for (const key in input) {
|
105
|
-
let value = input[key];
|
106
|
-
if (key.startsWith("on") && typeof value === "function") {
|
107
|
-
const c = key[2];
|
108
|
-
customEvents = customEvents || [];
|
109
|
-
customEvents.push([
|
110
|
-
(c === "-" ? "" : c.toLowerCase()) + key.slice(3),
|
111
|
-
value]
|
112
|
-
);
|
113
|
-
value.toJSON = FN_TO_JSON;
|
114
|
-
} else {
|
115
|
-
normalizedInput[key] = input[key];
|
116
|
-
}
|
117
|
-
}
|
118
|
-
renderer5(normalizedInput, out);
|
119
|
-
} else {
|
120
|
-
renderBody5(out, input, ...args);
|
121
|
-
}
|
122
|
-
|
123
|
-
const componentsContext = R_(out);
|
124
|
-
const component = componentsContext.b_[0];
|
125
|
-
if (component) {
|
126
|
-
component.r_.U_ = customEvents;
|
127
|
-
writeScope(nextScopeId(), {
|
128
|
-
m5c: component.id
|
129
|
-
});
|
130
|
-
}
|
131
|
-
|
132
|
-
initComponentsTag({}, out);
|
133
|
-
|
134
|
-
let async;
|
135
|
-
out.once("finish", (result) => {
|
136
|
-
if (!async) {
|
137
|
-
async = false;
|
138
|
-
write(result.toString());
|
139
|
-
}
|
140
|
-
});
|
141
|
-
|
142
|
-
out.end();
|
143
|
-
|
144
|
-
if (async !== false) {
|
145
|
-
async = true;
|
146
|
-
fork(out, (result) => {
|
147
|
-
write(result.toString());
|
148
|
-
});
|
149
|
-
}
|
150
|
-
};
|
151
|
-
},
|
152
|
-
function createRenderer(renderFn) {
|
153
|
-
renderFn.bt_ = true;
|
154
|
-
return renderFn;
|
155
|
-
}
|
156
|
-
);
|
157
|
-
|
158
|
-
function dummyCreate5to6Renderer() {}
|
159
|
-
|
160
|
-
register(dummyCreate5to6Renderer, "@marko/tags-compat-5-to-6");
|
161
|
-
|
162
|
-
exports.serialized5to6 = function serialized5to6(renderer, id) {
|
163
|
-
const dummyRenderer = () => {};
|
164
|
-
register(dummyRenderer, id);
|
165
|
-
return makeSerializable(renderer, (s) =>
|
166
|
-
s.
|
167
|
-
value(dummyCreate5to6Renderer).
|
168
|
-
code("(").
|
169
|
-
value(dummyRenderer).
|
170
|
-
code(",!0)")
|
171
|
-
);
|
172
|
-
};
|