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