marko 6.0.0-next.3.18 → 6.0.0-next.3.19
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/debug/html.js +56 -41
- package/dist/debug/html.mjs +55 -39
- package/dist/html/writer.d.ts +9 -2
- package/dist/html.d.ts +1 -1
- package/dist/html.js +25 -12
- package/dist/html.mjs +24 -10
- package/dist/translator/core/await.d.ts +3 -0
- package/dist/translator/core/index.d.ts +2 -0
- package/dist/translator/core/try.d.ts +3 -0
- package/dist/translator/index.d.ts +2 -0
- package/dist/translator/index.js +4214 -4034
- package/package.json +1 -1
- package/tag-types/await.d.marko +8 -0
- package/tag-types/try.d.marko +7 -0
package/dist/debug/html.js
CHANGED
@@ -64,8 +64,7 @@ __export(html_exports, {
|
|
64
64
|
register: () => register2,
|
65
65
|
styleAttr: () => styleAttr,
|
66
66
|
toString: () => toString,
|
67
|
-
|
68
|
-
tryPlaceholder: () => tryPlaceholder,
|
67
|
+
tryContent: () => tryContent,
|
69
68
|
write: () => write,
|
70
69
|
writeEffect: () => writeEffect,
|
71
70
|
writeExistingScope: () => writeExistingScope,
|
@@ -181,12 +180,14 @@ function escapeStyle(val) {
|
|
181
180
|
}
|
182
181
|
|
183
182
|
// src/html/inlined-runtimes.ts
|
184
|
-
var WALKER_RUNTIME_CODE = true ?
|
183
|
+
var WALKER_RUNTIME_CODE = true ? (
|
184
|
+
/* js */
|
185
|
+
`((runtimeId) =>
|
185
186
|
(self[runtimeId] =
|
186
187
|
self[runtimeId] ||
|
187
188
|
((renderId) => {
|
188
189
|
let id,
|
189
|
-
|
190
|
+
lookup = {},
|
190
191
|
visits = [],
|
191
192
|
doc = document,
|
192
193
|
walker = doc.createTreeWalker(
|
@@ -196,7 +197,7 @@ var WALKER_RUNTIME_CODE = true ? `((runtimeId) =>
|
|
196
197
|
op = (self[runtimeId][renderId] = {
|
197
198
|
i: (renderId = runtimeId + renderId),
|
198
199
|
d: doc,
|
199
|
-
l:
|
200
|
+
l: lookup,
|
200
201
|
v: visits,
|
201
202
|
x() {},
|
202
203
|
w(node) {
|
@@ -205,7 +206,7 @@ var WALKER_RUNTIME_CODE = true ? `((runtimeId) =>
|
|
205
206
|
(op =
|
206
207
|
(op = node.data) &&
|
207
208
|
!op.indexOf(renderId) &&
|
208
|
-
((
|
209
|
+
((lookup[(id = op.slice(prefix + 1))] = node), op[prefix])),
|
209
210
|
id,
|
210
211
|
node,
|
211
212
|
);
|
@@ -217,12 +218,14 @@ var WALKER_RUNTIME_CODE = true ? `((runtimeId) =>
|
|
217
218
|
},
|
218
219
|
}),
|
219
220
|
prefix = renderId.length;
|
220
|
-
})))`
|
221
|
-
|
222
|
-
|
221
|
+
})))`
|
222
|
+
) : `(e=>self[e]=self[e]||(l=>{let t,d={},s=[],f=document,i=f.createTreeWalker(f,129),n=self[e][l]={i:l=e+l,d:f,l:d,v:s,x(){},w(e){for(;e=i.nextNode();)this.x(n=(n=e.data)&&!n.indexOf(l)&&(d[t=n.slice(x+1)]=e,n[x]),t,e),n>"#"&&s.push(e)}},x=l.length}))`;
|
223
|
+
var REORDER_RUNTIME_CODE = true ? (
|
224
|
+
/* js */
|
225
|
+
`((runtime) => {
|
226
|
+
let onNextSibling,
|
223
227
|
placeholder,
|
224
228
|
nextSibling,
|
225
|
-
previousSibling,
|
226
229
|
placeholders = {},
|
227
230
|
replace = (marker, container) => {
|
228
231
|
marker.replaceWith(...container.childNodes);
|
@@ -233,21 +236,19 @@ runtime.d.head.append(
|
|
233
236
|
);
|
234
237
|
runtime.j = {};
|
235
238
|
runtime.x = (op, id, node, start, placeholderCallback) => {
|
236
|
-
// "node" and "end" are all closed over and can't be repurposed. "start" is too but only in the new placeholder case
|
237
|
-
|
238
239
|
if (op == "#") {
|
239
240
|
(placeholders[id] = placeholder).i++;
|
240
241
|
} else if (node == nextSibling) {
|
241
|
-
|
242
|
+
onNextSibling();
|
242
243
|
}
|
243
244
|
|
244
245
|
if (node.tagName == "T" && (id = node.getAttribute(runtime.i))) {
|
245
246
|
start = runtime.l["^" + id];
|
246
247
|
|
247
248
|
if (start) {
|
248
|
-
|
249
|
-
i:
|
250
|
-
c(end = runtime.l[id] ||
|
249
|
+
placeholders[id] = {
|
250
|
+
i: 1,
|
251
|
+
c(end = runtime.l[id] || node) {
|
251
252
|
while (end.parentNode !== start.parentNode) {
|
252
253
|
end = end.parentNode;
|
253
254
|
}
|
@@ -260,29 +261,26 @@ runtime.x = (op, id, node, start, placeholderCallback) => {
|
|
260
261
|
replace(start, node);
|
261
262
|
},
|
262
263
|
};
|
263
|
-
} else {
|
264
|
-
insertOne = () => {
|
265
|
-
previousSibling = node.previousSibling;
|
266
|
-
replace(runtime.l[id], node);
|
267
|
-
if (!--start.i) {
|
268
|
-
start.c();
|
269
|
-
}
|
270
|
-
};
|
271
|
-
|
272
|
-
// repurpose "start" to hold this placeholder
|
273
|
-
start = placeholder = placeholders[id];
|
274
|
-
nextSibling = node.nextElementSibling || insertOne();
|
275
264
|
}
|
276
265
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
266
|
+
nextSibling = node.nextSibling;
|
267
|
+
placeholder = placeholders[id];
|
268
|
+
onNextSibling = () => {
|
269
|
+
start || replace(runtime.l[id], node);
|
270
|
+
if (!--placeholder.i) {
|
271
|
+
placeholder.c();
|
272
|
+
}
|
273
|
+
};
|
281
274
|
|
282
|
-
|
275
|
+
// repurpose "op" for callbacks ...carefully
|
276
|
+
if (op = runtime.j[id]) {
|
277
|
+
placeholderCallback = placeholder.c;
|
278
|
+
placeholder.c = () => placeholderCallback() + op(runtime);
|
279
|
+
}
|
283
280
|
}
|
284
281
|
};
|
285
|
-
})`
|
282
|
+
})`
|
283
|
+
) : `(e=>{let i,t,r,l={},o=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(d,n,a,c,p)=>{"#"==d?(l[n]=t).i++:a==r&&i(),"T"==a.tagName&&(n=a.getAttribute(e.i))&&((c=e.l["^"+n])&&(l[n]={i:1,c(i=e.l[n]||a){for(;i.parentNode!==c.parentNode;)i=i.parentNode;for(;i!=r;(r=c.nextSibling).remove());o(c,a)}}),r=a.nextSibling,t=l[n],i=()=>{c||o(e.l[n],a),--t.i||t.c()},(d=e.j[n])&&(p=t.c,t.c=()=>p()+d(e)))}})`;
|
286
284
|
|
287
285
|
// src/html/serializer.ts
|
288
286
|
var { hasOwnProperty } = {};
|
@@ -1577,6 +1575,23 @@ function fork(promise, content) {
|
|
1577
1575
|
}
|
1578
1576
|
);
|
1579
1577
|
}
|
1578
|
+
function tryContent(input) {
|
1579
|
+
const content = input.content;
|
1580
|
+
if (content) {
|
1581
|
+
const catchContent = input.catch?.content;
|
1582
|
+
const placeholderContent = input.placeholder?.content;
|
1583
|
+
if (catchContent) {
|
1584
|
+
tryCatch(
|
1585
|
+
placeholderContent ? () => tryPlaceholder(content, placeholderContent) : content,
|
1586
|
+
catchContent
|
1587
|
+
);
|
1588
|
+
} else if (placeholderContent) {
|
1589
|
+
tryPlaceholder(content, placeholderContent);
|
1590
|
+
} else {
|
1591
|
+
content();
|
1592
|
+
}
|
1593
|
+
}
|
1594
|
+
}
|
1580
1595
|
function tryPlaceholder(content, placeholder) {
|
1581
1596
|
const chunk = $chunk;
|
1582
1597
|
const { boundary } = chunk;
|
@@ -1885,14 +1900,15 @@ function prepareChunk(chunk) {
|
|
1885
1900
|
}
|
1886
1901
|
for (const reorderedChunk of state.writeReorders) {
|
1887
1902
|
const { reorderId } = reorderedChunk;
|
1888
|
-
let isSync = true;
|
1889
1903
|
let reorderHTML = "";
|
1890
1904
|
let reorderEffects = "";
|
1891
1905
|
let reorderScripts = "";
|
1892
1906
|
let cur = reorderedChunk;
|
1893
1907
|
reorderedChunk.reorderId = null;
|
1894
1908
|
for (; ; ) {
|
1909
|
+
const { next } = cur;
|
1895
1910
|
cur.flushPlaceholder();
|
1911
|
+
cur.consumed = true;
|
1896
1912
|
reorderHTML += cur.html;
|
1897
1913
|
reorderEffects = concatEffects(reorderEffects, cur.effects);
|
1898
1914
|
reorderScripts = concatScripts(reorderScripts, cur.scripts);
|
@@ -1902,10 +1918,10 @@ function prepareChunk(chunk) {
|
|
1902
1918
|
cur.reorderId = state.nextReorderId()
|
1903
1919
|
);
|
1904
1920
|
cur.html = cur.effects = cur.scripts = "";
|
1905
|
-
|
1921
|
+
cur.next = null;
|
1906
1922
|
}
|
1907
|
-
if (
|
1908
|
-
cur =
|
1923
|
+
if (next) {
|
1924
|
+
cur = next;
|
1909
1925
|
} else {
|
1910
1926
|
break;
|
1911
1927
|
}
|
@@ -1927,7 +1943,7 @@ function prepareChunk(chunk) {
|
|
1927
1943
|
scripts,
|
1928
1944
|
reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
|
1929
1945
|
);
|
1930
|
-
html += "<t " +
|
1946
|
+
html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
1931
1947
|
}
|
1932
1948
|
state.writeReorders = null;
|
1933
1949
|
}
|
@@ -2735,8 +2751,7 @@ var ServerRenderResult = class {
|
|
2735
2751
|
register,
|
2736
2752
|
styleAttr,
|
2737
2753
|
toString,
|
2738
|
-
|
2739
|
-
tryPlaceholder,
|
2754
|
+
tryContent,
|
2740
2755
|
write,
|
2741
2756
|
writeEffect,
|
2742
2757
|
writeExistingScope,
|
package/dist/debug/html.mjs
CHANGED
@@ -105,12 +105,14 @@ function escapeStyle(val) {
|
|
105
105
|
}
|
106
106
|
|
107
107
|
// src/html/inlined-runtimes.ts
|
108
|
-
var WALKER_RUNTIME_CODE = true ?
|
108
|
+
var WALKER_RUNTIME_CODE = true ? (
|
109
|
+
/* js */
|
110
|
+
`((runtimeId) =>
|
109
111
|
(self[runtimeId] =
|
110
112
|
self[runtimeId] ||
|
111
113
|
((renderId) => {
|
112
114
|
let id,
|
113
|
-
|
115
|
+
lookup = {},
|
114
116
|
visits = [],
|
115
117
|
doc = document,
|
116
118
|
walker = doc.createTreeWalker(
|
@@ -120,7 +122,7 @@ var WALKER_RUNTIME_CODE = true ? `((runtimeId) =>
|
|
120
122
|
op = (self[runtimeId][renderId] = {
|
121
123
|
i: (renderId = runtimeId + renderId),
|
122
124
|
d: doc,
|
123
|
-
l:
|
125
|
+
l: lookup,
|
124
126
|
v: visits,
|
125
127
|
x() {},
|
126
128
|
w(node) {
|
@@ -129,7 +131,7 @@ var WALKER_RUNTIME_CODE = true ? `((runtimeId) =>
|
|
129
131
|
(op =
|
130
132
|
(op = node.data) &&
|
131
133
|
!op.indexOf(renderId) &&
|
132
|
-
((
|
134
|
+
((lookup[(id = op.slice(prefix + 1))] = node), op[prefix])),
|
133
135
|
id,
|
134
136
|
node,
|
135
137
|
);
|
@@ -141,12 +143,14 @@ var WALKER_RUNTIME_CODE = true ? `((runtimeId) =>
|
|
141
143
|
},
|
142
144
|
}),
|
143
145
|
prefix = renderId.length;
|
144
|
-
})))`
|
145
|
-
|
146
|
-
|
146
|
+
})))`
|
147
|
+
) : `(e=>self[e]=self[e]||(l=>{let t,d={},s=[],f=document,i=f.createTreeWalker(f,129),n=self[e][l]={i:l=e+l,d:f,l:d,v:s,x(){},w(e){for(;e=i.nextNode();)this.x(n=(n=e.data)&&!n.indexOf(l)&&(d[t=n.slice(x+1)]=e,n[x]),t,e),n>"#"&&s.push(e)}},x=l.length}))`;
|
148
|
+
var REORDER_RUNTIME_CODE = true ? (
|
149
|
+
/* js */
|
150
|
+
`((runtime) => {
|
151
|
+
let onNextSibling,
|
147
152
|
placeholder,
|
148
153
|
nextSibling,
|
149
|
-
previousSibling,
|
150
154
|
placeholders = {},
|
151
155
|
replace = (marker, container) => {
|
152
156
|
marker.replaceWith(...container.childNodes);
|
@@ -157,21 +161,19 @@ runtime.d.head.append(
|
|
157
161
|
);
|
158
162
|
runtime.j = {};
|
159
163
|
runtime.x = (op, id, node, start, placeholderCallback) => {
|
160
|
-
// "node" and "end" are all closed over and can't be repurposed. "start" is too but only in the new placeholder case
|
161
|
-
|
162
164
|
if (op == "#") {
|
163
165
|
(placeholders[id] = placeholder).i++;
|
164
166
|
} else if (node == nextSibling) {
|
165
|
-
|
167
|
+
onNextSibling();
|
166
168
|
}
|
167
169
|
|
168
170
|
if (node.tagName == "T" && (id = node.getAttribute(runtime.i))) {
|
169
171
|
start = runtime.l["^" + id];
|
170
172
|
|
171
173
|
if (start) {
|
172
|
-
|
173
|
-
i:
|
174
|
-
c(end = runtime.l[id] ||
|
174
|
+
placeholders[id] = {
|
175
|
+
i: 1,
|
176
|
+
c(end = runtime.l[id] || node) {
|
175
177
|
while (end.parentNode !== start.parentNode) {
|
176
178
|
end = end.parentNode;
|
177
179
|
}
|
@@ -184,29 +186,26 @@ runtime.x = (op, id, node, start, placeholderCallback) => {
|
|
184
186
|
replace(start, node);
|
185
187
|
},
|
186
188
|
};
|
187
|
-
} else {
|
188
|
-
insertOne = () => {
|
189
|
-
previousSibling = node.previousSibling;
|
190
|
-
replace(runtime.l[id], node);
|
191
|
-
if (!--start.i) {
|
192
|
-
start.c();
|
193
|
-
}
|
194
|
-
};
|
195
|
-
|
196
|
-
// repurpose "start" to hold this placeholder
|
197
|
-
start = placeholder = placeholders[id];
|
198
|
-
nextSibling = node.nextElementSibling || insertOne();
|
199
189
|
}
|
200
190
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
191
|
+
nextSibling = node.nextSibling;
|
192
|
+
placeholder = placeholders[id];
|
193
|
+
onNextSibling = () => {
|
194
|
+
start || replace(runtime.l[id], node);
|
195
|
+
if (!--placeholder.i) {
|
196
|
+
placeholder.c();
|
197
|
+
}
|
198
|
+
};
|
205
199
|
|
206
|
-
|
200
|
+
// repurpose "op" for callbacks ...carefully
|
201
|
+
if (op = runtime.j[id]) {
|
202
|
+
placeholderCallback = placeholder.c;
|
203
|
+
placeholder.c = () => placeholderCallback() + op(runtime);
|
204
|
+
}
|
207
205
|
}
|
208
206
|
};
|
209
|
-
})`
|
207
|
+
})`
|
208
|
+
) : `(e=>{let i,t,r,l={},o=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(d,n,a,c,p)=>{"#"==d?(l[n]=t).i++:a==r&&i(),"T"==a.tagName&&(n=a.getAttribute(e.i))&&((c=e.l["^"+n])&&(l[n]={i:1,c(i=e.l[n]||a){for(;i.parentNode!==c.parentNode;)i=i.parentNode;for(;i!=r;(r=c.nextSibling).remove());o(c,a)}}),r=a.nextSibling,t=l[n],i=()=>{c||o(e.l[n],a),--t.i||t.c()},(d=e.j[n])&&(p=t.c,t.c=()=>p()+d(e)))}})`;
|
210
209
|
|
211
210
|
// src/html/serializer.ts
|
212
211
|
var { hasOwnProperty } = {};
|
@@ -1501,6 +1500,23 @@ function fork(promise, content) {
|
|
1501
1500
|
}
|
1502
1501
|
);
|
1503
1502
|
}
|
1503
|
+
function tryContent(input) {
|
1504
|
+
const content = input.content;
|
1505
|
+
if (content) {
|
1506
|
+
const catchContent = input.catch?.content;
|
1507
|
+
const placeholderContent = input.placeholder?.content;
|
1508
|
+
if (catchContent) {
|
1509
|
+
tryCatch(
|
1510
|
+
placeholderContent ? () => tryPlaceholder(content, placeholderContent) : content,
|
1511
|
+
catchContent
|
1512
|
+
);
|
1513
|
+
} else if (placeholderContent) {
|
1514
|
+
tryPlaceholder(content, placeholderContent);
|
1515
|
+
} else {
|
1516
|
+
content();
|
1517
|
+
}
|
1518
|
+
}
|
1519
|
+
}
|
1504
1520
|
function tryPlaceholder(content, placeholder) {
|
1505
1521
|
const chunk = $chunk;
|
1506
1522
|
const { boundary } = chunk;
|
@@ -1809,14 +1825,15 @@ function prepareChunk(chunk) {
|
|
1809
1825
|
}
|
1810
1826
|
for (const reorderedChunk of state.writeReorders) {
|
1811
1827
|
const { reorderId } = reorderedChunk;
|
1812
|
-
let isSync = true;
|
1813
1828
|
let reorderHTML = "";
|
1814
1829
|
let reorderEffects = "";
|
1815
1830
|
let reorderScripts = "";
|
1816
1831
|
let cur = reorderedChunk;
|
1817
1832
|
reorderedChunk.reorderId = null;
|
1818
1833
|
for (; ; ) {
|
1834
|
+
const { next } = cur;
|
1819
1835
|
cur.flushPlaceholder();
|
1836
|
+
cur.consumed = true;
|
1820
1837
|
reorderHTML += cur.html;
|
1821
1838
|
reorderEffects = concatEffects(reorderEffects, cur.effects);
|
1822
1839
|
reorderScripts = concatScripts(reorderScripts, cur.scripts);
|
@@ -1826,10 +1843,10 @@ function prepareChunk(chunk) {
|
|
1826
1843
|
cur.reorderId = state.nextReorderId()
|
1827
1844
|
);
|
1828
1845
|
cur.html = cur.effects = cur.scripts = "";
|
1829
|
-
|
1846
|
+
cur.next = null;
|
1830
1847
|
}
|
1831
|
-
if (
|
1832
|
-
cur =
|
1848
|
+
if (next) {
|
1849
|
+
cur = next;
|
1833
1850
|
} else {
|
1834
1851
|
break;
|
1835
1852
|
}
|
@@ -1851,7 +1868,7 @@ function prepareChunk(chunk) {
|
|
1851
1868
|
scripts,
|
1852
1869
|
reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
|
1853
1870
|
);
|
1854
|
-
html += "<t " +
|
1871
|
+
html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
1855
1872
|
}
|
1856
1873
|
state.writeReorders = null;
|
1857
1874
|
}
|
@@ -2658,8 +2675,7 @@ export {
|
|
2658
2675
|
register2 as register,
|
2659
2676
|
styleAttr,
|
2660
2677
|
toString,
|
2661
|
-
|
2662
|
-
tryPlaceholder,
|
2678
|
+
tryContent,
|
2663
2679
|
write,
|
2664
2680
|
writeEffect,
|
2665
2681
|
writeExistingScope,
|
package/dist/html/writer.d.ts
CHANGED
@@ -41,8 +41,15 @@ export declare function $global(): $Global & {
|
|
41
41
|
runtimeId: string;
|
42
42
|
};
|
43
43
|
export declare function fork<T>(promise: Promise<T> | T, content: (value: T) => void): void;
|
44
|
-
export declare function
|
45
|
-
|
44
|
+
export declare function tryContent(input: {
|
45
|
+
content?(): void;
|
46
|
+
placeholder?: {
|
47
|
+
content?(): void;
|
48
|
+
};
|
49
|
+
catch?: {
|
50
|
+
content?(err: unknown): void;
|
51
|
+
};
|
52
|
+
}): void;
|
46
53
|
export declare class State {
|
47
54
|
$global: $Global & {
|
48
55
|
renderId: string;
|
package/dist/html.d.ts
CHANGED
@@ -6,4 +6,4 @@ export { escapeScript, escapeStyle, escapeXML, toString } from "./html/content";
|
|
6
6
|
export { createRenderer, dynamicTagArgs, dynamicTagInput, } from "./html/dynamic-tag";
|
7
7
|
export { forIn, forInBy, forOf, forOfBy, forTo, forToBy } from "./html/for";
|
8
8
|
export { createTemplate } from "./html/template";
|
9
|
-
export { $global, ensureScopeWithId, fork, getScopeById, markResumeCleanup, markResumeControlEnd, markResumeControlSingleNodeEnd, markResumeNode, markResumeScopeStart, nextScopeId, nextTagId, nodeRef, peekNextScope, register,
|
9
|
+
export { $global, ensureScopeWithId, fork, getScopeById, markResumeCleanup, markResumeControlEnd, markResumeControlSingleNodeEnd, markResumeNode, markResumeScopeStart, nextScopeId, nextTagId, nodeRef, peekNextScope, register, tryContent, write, writeEffect, writeExistingScope, writeScope, writeTrailers, } from "./html/writer";
|
package/dist/html.js
CHANGED
@@ -61,8 +61,7 @@ __export(html_exports, {
|
|
61
61
|
register: () => register2,
|
62
62
|
styleAttr: () => styleAttr,
|
63
63
|
toString: () => toString,
|
64
|
-
|
65
|
-
tryPlaceholder: () => tryPlaceholder,
|
64
|
+
tryContent: () => tryContent,
|
66
65
|
write: () => write,
|
67
66
|
writeEffect: () => writeEffect,
|
68
67
|
writeExistingScope: () => writeExistingScope,
|
@@ -153,7 +152,7 @@ function escapeStyle(val) {
|
|
153
152
|
}
|
154
153
|
|
155
154
|
// src/html/inlined-runtimes.ts
|
156
|
-
var WALKER_RUNTIME_CODE = '(e=>self[e]=self[e]||(l=>{let t,d={},
|
155
|
+
var WALKER_RUNTIME_CODE = '(e=>self[e]=self[e]||(l=>{let t,d={},s=[],f=document,i=f.createTreeWalker(f,129),n=self[e][l]={i:l=e+l,d:f,l:d,v:s,x(){},w(e){for(;e=i.nextNode();)this.x(n=(n=e.data)&&!n.indexOf(l)&&(d[t=n.slice(x+1)]=e,n[x]),t,e),n>"#"&&s.push(e)}},x=l.length}))', REORDER_RUNTIME_CODE = '(e=>{let i,t,r,l={},o=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(d,n,a,c,p)=>{"#"==d?(l[n]=t).i++:a==r&&i(),"T"==a.tagName&&(n=a.getAttribute(e.i))&&((c=e.l["^"+n])&&(l[n]={i:1,c(i=e.l[n]||a){for(;i.parentNode!==c.parentNode;)i=i.parentNode;for(;i!=r;(r=c.nextSibling).remove());o(c,a)}}),r=a.nextSibling,t=l[n],i=()=>{c||o(e.l[n],a),--t.i||t.c()},(d=e.j[n])&&(p=t.c,t.c=()=>p()+d(e)))}})';
|
157
156
|
|
158
157
|
// src/html/serializer.ts
|
159
158
|
var { hasOwnProperty } = {}, Generator = function* () {
|
@@ -1058,6 +1057,16 @@ function fork(promise, content) {
|
|
1058
1057
|
}
|
1059
1058
|
);
|
1060
1059
|
}
|
1060
|
+
function tryContent(input) {
|
1061
|
+
let content = input.content;
|
1062
|
+
if (content) {
|
1063
|
+
let catchContent = input.catch?.content, placeholderContent = input.placeholder?.content;
|
1064
|
+
catchContent ? tryCatch(
|
1065
|
+
placeholderContent ? () => tryPlaceholder(content, placeholderContent) : content,
|
1066
|
+
catchContent
|
1067
|
+
) : placeholderContent ? tryPlaceholder(content, placeholderContent) : content();
|
1068
|
+
}
|
1069
|
+
}
|
1061
1070
|
function tryPlaceholder(content, placeholder) {
|
1062
1071
|
let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context);
|
1063
1072
|
if (body === body.render(content)) {
|
@@ -1239,12 +1248,17 @@ function prepareChunk(chunk) {
|
|
1239
1248
|
REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")"
|
1240
1249
|
));
|
1241
1250
|
for (let reorderedChunk of state.writeReorders) {
|
1242
|
-
let { reorderId } = reorderedChunk,
|
1243
|
-
for (reorderedChunk.reorderId = null;
|
1244
|
-
|
1245
|
-
cur.
|
1246
|
-
|
1247
|
-
|
1251
|
+
let { reorderId } = reorderedChunk, reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
|
1252
|
+
for (reorderedChunk.reorderId = null; ; ) {
|
1253
|
+
let { next } = cur;
|
1254
|
+
if (cur.flushPlaceholder(), cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark(
|
1255
|
+
"#" /* ReorderMarker */,
|
1256
|
+
cur.reorderId = state.nextReorderId()
|
1257
|
+
), cur.html = cur.effects = cur.scripts = "", cur.next = null), next)
|
1258
|
+
cur = next;
|
1259
|
+
else
|
1260
|
+
break;
|
1261
|
+
}
|
1248
1262
|
reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(
|
1249
1263
|
scripts,
|
1250
1264
|
runtimePrefix + ".r=[]"
|
@@ -1254,7 +1268,7 @@ function prepareChunk(chunk) {
|
|
1254
1268
|
)), scripts = concatScripts(
|
1255
1269
|
scripts,
|
1256
1270
|
reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
|
1257
|
-
), html += "<t " +
|
1271
|
+
), html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
1258
1272
|
}
|
1259
1273
|
state.writeReorders = null;
|
1260
1274
|
}
|
@@ -1813,8 +1827,7 @@ var ServerRenderResult = class {
|
|
1813
1827
|
register,
|
1814
1828
|
styleAttr,
|
1815
1829
|
toString,
|
1816
|
-
|
1817
|
-
tryPlaceholder,
|
1830
|
+
tryContent,
|
1818
1831
|
write,
|
1819
1832
|
writeEffect,
|
1820
1833
|
writeExistingScope,
|
package/dist/html.mjs
CHANGED
@@ -80,7 +80,7 @@ function escapeStyle(val) {
|
|
80
80
|
}
|
81
81
|
|
82
82
|
// src/html/inlined-runtimes.ts
|
83
|
-
var WALKER_RUNTIME_CODE = '(e=>self[e]=self[e]||(l=>{let t,d={},
|
83
|
+
var WALKER_RUNTIME_CODE = '(e=>self[e]=self[e]||(l=>{let t,d={},s=[],f=document,i=f.createTreeWalker(f,129),n=self[e][l]={i:l=e+l,d:f,l:d,v:s,x(){},w(e){for(;e=i.nextNode();)this.x(n=(n=e.data)&&!n.indexOf(l)&&(d[t=n.slice(x+1)]=e,n[x]),t,e),n>"#"&&s.push(e)}},x=l.length}))', REORDER_RUNTIME_CODE = '(e=>{let i,t,r,l={},o=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(d,n,a,c,p)=>{"#"==d?(l[n]=t).i++:a==r&&i(),"T"==a.tagName&&(n=a.getAttribute(e.i))&&((c=e.l["^"+n])&&(l[n]={i:1,c(i=e.l[n]||a){for(;i.parentNode!==c.parentNode;)i=i.parentNode;for(;i!=r;(r=c.nextSibling).remove());o(c,a)}}),r=a.nextSibling,t=l[n],i=()=>{c||o(e.l[n],a),--t.i||t.c()},(d=e.j[n])&&(p=t.c,t.c=()=>p()+d(e)))}})';
|
84
84
|
|
85
85
|
// src/html/serializer.ts
|
86
86
|
var { hasOwnProperty } = {}, Generator = function* () {
|
@@ -985,6 +985,16 @@ function fork(promise, content) {
|
|
985
985
|
}
|
986
986
|
);
|
987
987
|
}
|
988
|
+
function tryContent(input) {
|
989
|
+
let content = input.content;
|
990
|
+
if (content) {
|
991
|
+
let catchContent = input.catch?.content, placeholderContent = input.placeholder?.content;
|
992
|
+
catchContent ? tryCatch(
|
993
|
+
placeholderContent ? () => tryPlaceholder(content, placeholderContent) : content,
|
994
|
+
catchContent
|
995
|
+
) : placeholderContent ? tryPlaceholder(content, placeholderContent) : content();
|
996
|
+
}
|
997
|
+
}
|
988
998
|
function tryPlaceholder(content, placeholder) {
|
989
999
|
let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context);
|
990
1000
|
if (body === body.render(content)) {
|
@@ -1166,12 +1176,17 @@ function prepareChunk(chunk) {
|
|
1166
1176
|
REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")"
|
1167
1177
|
));
|
1168
1178
|
for (let reorderedChunk of state.writeReorders) {
|
1169
|
-
let { reorderId } = reorderedChunk,
|
1170
|
-
for (reorderedChunk.reorderId = null;
|
1171
|
-
|
1172
|
-
cur.
|
1173
|
-
|
1174
|
-
|
1179
|
+
let { reorderId } = reorderedChunk, reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
|
1180
|
+
for (reorderedChunk.reorderId = null; ; ) {
|
1181
|
+
let { next } = cur;
|
1182
|
+
if (cur.flushPlaceholder(), cur.consumed = !0, reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark(
|
1183
|
+
"#" /* ReorderMarker */,
|
1184
|
+
cur.reorderId = state.nextReorderId()
|
1185
|
+
), cur.html = cur.effects = cur.scripts = "", cur.next = null), next)
|
1186
|
+
cur = next;
|
1187
|
+
else
|
1188
|
+
break;
|
1189
|
+
}
|
1175
1190
|
reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(
|
1176
1191
|
scripts,
|
1177
1192
|
runtimePrefix + ".r=[]"
|
@@ -1181,7 +1196,7 @@ function prepareChunk(chunk) {
|
|
1181
1196
|
)), scripts = concatScripts(
|
1182
1197
|
scripts,
|
1183
1198
|
reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
|
1184
|
-
), html += "<t " +
|
1199
|
+
), html += "<t " + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
|
1185
1200
|
}
|
1186
1201
|
state.writeReorders = null;
|
1187
1202
|
}
|
@@ -1739,8 +1754,7 @@ export {
|
|
1739
1754
|
register2 as register,
|
1740
1755
|
styleAttr,
|
1741
1756
|
toString,
|
1742
|
-
|
1743
|
-
tryPlaceholder,
|
1757
|
+
tryContent,
|
1744
1758
|
write,
|
1745
1759
|
writeEffect,
|
1746
1760
|
writeExistingScope,
|
@@ -1,6 +1,7 @@
|
|
1
1
|
declare const _default: {
|
2
2
|
taglibId: string;
|
3
3
|
"<attrs>": import("@marko/compiler/babel-utils").Tag;
|
4
|
+
"<await>": import("@marko/compiler/babel-utils").Tag;
|
4
5
|
"<client>": {
|
5
6
|
parse(tag: import("@marko/compiler/babel-types").NodePath<import("@marko/compiler/babel-types").MarkoTag>): void;
|
6
7
|
parseOptions: {
|
@@ -148,5 +149,6 @@ declare const _default: {
|
|
148
149
|
}[];
|
149
150
|
};
|
150
151
|
"<style>": import("@marko/compiler/babel-utils").Tag;
|
152
|
+
"<try>": import("@marko/compiler/babel-utils").Tag;
|
151
153
|
};
|
152
154
|
export default _default;
|
@@ -7,6 +7,7 @@ export declare const taglibs: (string | {
|
|
7
7
|
migrate: import("@marko/compiler/babel-types").Visitor<unknown>;
|
8
8
|
taglibId: string;
|
9
9
|
"<attrs>": import("@marko/compiler/babel-utils").Tag;
|
10
|
+
"<await>": import("@marko/compiler/babel-utils").Tag;
|
10
11
|
"<client>": {
|
11
12
|
parse(tag: import("@marko/compiler/babel-types").NodePath<import("@marko/compiler/babel-types").MarkoTag>): void;
|
12
13
|
parseOptions: {
|
@@ -154,6 +155,7 @@ export declare const taglibs: (string | {
|
|
154
155
|
}[];
|
155
156
|
};
|
156
157
|
"<style>": import("@marko/compiler/babel-utils").Tag;
|
158
|
+
"<try>": import("@marko/compiler/babel-utils").Tag;
|
157
159
|
})[][];
|
158
160
|
export declare function getRuntimeEntryFiles(output: Config["output"], optimize: boolean): string[];
|
159
161
|
declare module "@marko/compiler/dist/types" {
|