marko 5.32.15 → 5.33.1
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/markoc +1 -1
- package/dist/node_modules/@internal/components-entry/index.js +5 -7
- package/dist/runtime/helpers/dynamic-tag.js +5 -1
- package/dist/runtime/helpers/tags-compat-dom.js +265 -0
- package/dist/runtime/helpers/tags-compat-html.js +167 -0
- package/dist/runtime/html/AsyncStream.js +96 -13
- 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 +52 -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 +31 -31
- 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/docs/compiler.md +1 -1
- package/index.d.ts +4 -6
- package/package.json +83 -83
- package/src/node_modules/@internal/components-entry/index.js +5 -7
- package/src/runtime/helpers/dynamic-tag.js +5 -1
- package/src/runtime/helpers/tags-compat-dom.js +265 -0
- package/src/runtime/helpers/tags-compat-html.js +167 -0
- package/src/runtime/html/AsyncStream.js +87 -4
- package/src/runtime/renderable.js +49 -0
@@ -39,6 +39,16 @@ function escapeEndingComment(text) {
|
|
39
39
|
return text.replace(/(--!?)>/g, "$1>");
|
40
40
|
}
|
41
41
|
|
42
|
+
function deferred() {
|
43
|
+
let resolve;
|
44
|
+
let reject;
|
45
|
+
const promise = new Promise((res, rej) => {
|
46
|
+
resolve = res;
|
47
|
+
reject = rej;
|
48
|
+
});
|
49
|
+
return { promise, resolve, reject };
|
50
|
+
}
|
51
|
+
|
42
52
|
function AsyncStream(global, writer, parentOut) {
|
43
53
|
if (parentOut === null) {
|
44
54
|
throw new Error("illegal state");
|
@@ -117,6 +127,77 @@ var proto = (AsyncStream.prototype = {
|
|
117
127
|
___host: typeof document === "object" && document,
|
118
128
|
___isOut: true,
|
119
129
|
|
130
|
+
[Symbol.asyncIterator]() {
|
131
|
+
if (this.___iterator) {
|
132
|
+
return this.___iterator;
|
133
|
+
}
|
134
|
+
|
135
|
+
const originalWriter = this._state.writer;
|
136
|
+
let buffer = "";
|
137
|
+
let iteratorNextFn;
|
138
|
+
|
139
|
+
if (!originalWriter.stream) {
|
140
|
+
// Writing has finished completely so we can use a simple iterator
|
141
|
+
buffer = this.toString();
|
142
|
+
iteratorNextFn = () => {
|
143
|
+
const value = buffer;
|
144
|
+
buffer = "";
|
145
|
+
return { value, done: !value };
|
146
|
+
};
|
147
|
+
} else {
|
148
|
+
let done = false;
|
149
|
+
let pending = deferred();
|
150
|
+
const stream = {
|
151
|
+
write(data) {
|
152
|
+
buffer += data;
|
153
|
+
},
|
154
|
+
end() {
|
155
|
+
done = true;
|
156
|
+
pending.resolve({
|
157
|
+
value: "",
|
158
|
+
done,
|
159
|
+
});
|
160
|
+
},
|
161
|
+
flush() {
|
162
|
+
pending.resolve({
|
163
|
+
value: buffer,
|
164
|
+
done: false,
|
165
|
+
});
|
166
|
+
buffer = "";
|
167
|
+
pending = deferred();
|
168
|
+
},
|
169
|
+
};
|
170
|
+
|
171
|
+
this.on("error", pending.reject);
|
172
|
+
|
173
|
+
const writer = new BufferedWriter(stream);
|
174
|
+
writer.stream = originalWriter.stream;
|
175
|
+
writer.stream.writer = writer;
|
176
|
+
writer.next = originalWriter.next;
|
177
|
+
writer.state = this._state;
|
178
|
+
writer.merge(originalWriter);
|
179
|
+
|
180
|
+
this._state.stream = stream;
|
181
|
+
this._state.writer = writer;
|
182
|
+
|
183
|
+
iteratorNextFn = async () => {
|
184
|
+
if (buffer || done) {
|
185
|
+
const value = buffer;
|
186
|
+
buffer = "";
|
187
|
+
return { value, done };
|
188
|
+
}
|
189
|
+
return pending.promise;
|
190
|
+
};
|
191
|
+
}
|
192
|
+
|
193
|
+
return (this.___iterator = {
|
194
|
+
next: iteratorNextFn,
|
195
|
+
[Symbol.asyncIterator]() {
|
196
|
+
return this;
|
197
|
+
},
|
198
|
+
});
|
199
|
+
},
|
200
|
+
|
120
201
|
sync: function () {
|
121
202
|
this._sync = true;
|
122
203
|
},
|
@@ -637,20 +718,22 @@ var proto = (AsyncStream.prototype = {
|
|
637
718
|
|
638
719
|
then: function (fn, fnErr) {
|
639
720
|
var out = this;
|
640
|
-
|
721
|
+
return new Promise(function (resolve, reject) {
|
641
722
|
out.on("error", reject);
|
642
723
|
out.on("finish", function (result) {
|
643
724
|
resolve(result);
|
644
725
|
});
|
645
|
-
});
|
646
|
-
|
647
|
-
return Promise.resolve(promise).then(fn, fnErr);
|
726
|
+
}).then(fn, fnErr);
|
648
727
|
},
|
649
728
|
|
650
729
|
catch: function (fnErr) {
|
651
730
|
return this.then(undefined, fnErr);
|
652
731
|
},
|
653
732
|
|
733
|
+
finally: function (fn) {
|
734
|
+
return this.then(undefined, undefined).finally(fn);
|
735
|
+
},
|
736
|
+
|
654
737
|
c: function (componentDef, key, customEvents) {
|
655
738
|
this.___assignedComponentDef = componentDef;
|
656
739
|
this.___assignedKey = key;
|
@@ -76,6 +76,55 @@ module.exports = function (target, renderer) {
|
|
76
76
|
return out.___getResult();
|
77
77
|
},
|
78
78
|
|
79
|
+
/**
|
80
|
+
* Renders a template to nodes and inserts them into the DOM relative
|
81
|
+
* to the provided reference based on the optional position parameter.
|
82
|
+
*
|
83
|
+
* Supported signatures:
|
84
|
+
*
|
85
|
+
* mount(data, reference)
|
86
|
+
* mount(data, reference, position)
|
87
|
+
*
|
88
|
+
* @param {Object} data The view model data for the template
|
89
|
+
* @param {Node} reference DOM node to insert the rendered node(s) relative to
|
90
|
+
* @param {string} [position] A string representing the position relative to the `reference`; must match (case-insensitively) one of the following strings:
|
91
|
+
* 'beforebegin': Before the targetElement itself.
|
92
|
+
* 'afterbegin': Just inside the targetElement, before its first child.
|
93
|
+
* 'beforeend': Just inside the targetElement, after its last child.
|
94
|
+
* 'afterend': After the targetElement itself.
|
95
|
+
* @return {TemplateInstance} Object with `update` and `dispose` methods
|
96
|
+
*/
|
97
|
+
mount: function (data, reference, position) {
|
98
|
+
const result = this.renderSync(data);
|
99
|
+
|
100
|
+
switch (position) {
|
101
|
+
case "afterbegin":
|
102
|
+
result.prependTo(reference);
|
103
|
+
break;
|
104
|
+
case "afterend":
|
105
|
+
result.insertAfter(reference);
|
106
|
+
break;
|
107
|
+
case "beforebegin":
|
108
|
+
result.insertBefore(reference);
|
109
|
+
break;
|
110
|
+
default:
|
111
|
+
result.appendTo(reference);
|
112
|
+
break;
|
113
|
+
}
|
114
|
+
|
115
|
+
const component = result.getComponent();
|
116
|
+
|
117
|
+
return {
|
118
|
+
update(input) {
|
119
|
+
component.input = input;
|
120
|
+
component.update();
|
121
|
+
},
|
122
|
+
destroy() {
|
123
|
+
component.destroy();
|
124
|
+
},
|
125
|
+
};
|
126
|
+
},
|
127
|
+
|
79
128
|
/**
|
80
129
|
* Renders a template to either a stream (if the last
|
81
130
|
* argument is a Stream instance) or
|