marko 6.0.0-next.3.58 → 6.0.0-next.3.60
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/common/types.d.ts +7 -1
- package/dist/debug/dom.js +472 -314
- package/dist/debug/dom.mjs +472 -314
- package/dist/debug/html.js +118 -42
- package/dist/debug/html.mjs +118 -42
- package/dist/dom/control-flow.d.ts +5 -0
- package/dist/dom/queue.d.ts +2 -1
- package/dist/dom/resume.d.ts +1 -1
- package/dist/dom/scope.d.ts +1 -0
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +352 -226
- package/dist/dom.mjs +352 -226
- package/dist/html/dynamic-tag.d.ts +3 -4
- package/dist/html/serializer.d.ts +2 -1
- package/dist/html/writer.d.ts +2 -3
- package/dist/html.js +104 -36
- package/dist/html.mjs +104 -36
- package/dist/translator/core/await.d.ts +7 -0
- package/dist/translator/core/try.d.ts +7 -0
- package/dist/translator/index.js +140 -27
- package/package.json +1 -1
@@ -5,10 +5,9 @@ interface BodyContentObject {
|
|
5
5
|
content: ServerRenderer;
|
6
6
|
}
|
7
7
|
export declare function dynamicTagId(tagName: unknown): string | ServerRenderer | undefined;
|
8
|
-
export declare
|
9
|
-
export declare
|
8
|
+
export declare let dynamicTagInput: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject, input: Record<string, unknown>, content?: () => void) => undefined;
|
9
|
+
export declare let dynamicTagArgs: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject, args: unknown[]) => undefined;
|
10
10
|
export declare function createContent(id: string, fn: ServerRenderer): ServerRenderer;
|
11
11
|
export declare function registerContent(id: string, fn: ServerRenderer, scopeId?: number): ServerRenderer;
|
12
|
-
declare
|
13
|
-
export declare function patchDynamicTag(newGetDynamicRenderer: typeof getDynamicRenderer): void;
|
12
|
+
export declare function patchDynamicTag(patch: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject) => unknown): void;
|
14
13
|
export {};
|
@@ -6,7 +6,8 @@ export declare class Serializer {
|
|
6
6
|
stringify(val: unknown, boundary: Boundary): string;
|
7
7
|
nextId(): string;
|
8
8
|
symbol(id: string): symbol;
|
9
|
-
writeCall(value: unknown, object: unknown,
|
9
|
+
writeCall(value: unknown, object: unknown, property?: string, spread?: boolean): void;
|
10
|
+
writeAssign(value: unknown, object: unknown, property: string): void;
|
10
11
|
}
|
11
12
|
export declare function register<T extends WeakKey>(id: string, val: T, scope?: unknown): T;
|
12
13
|
export declare function registerGetter<T extends WeakKey>(accessor: string, val: T, scope?: unknown): T;
|
package/dist/html/writer.d.ts
CHANGED
@@ -46,9 +46,8 @@ export declare function $global(): $Global & {
|
|
46
46
|
renderId: string;
|
47
47
|
runtimeId: string;
|
48
48
|
};
|
49
|
-
export declare function fork<T>(promise: Promise<T> | T, content: (value: T) => void): void;
|
50
|
-
export declare function tryContent(input: {
|
51
|
-
content?(): void;
|
49
|
+
export declare function fork<T>(scopeId: number, accessor: Accessor, promise: Promise<T> | T, content: (value: T) => void): void;
|
50
|
+
export declare function tryContent(scopeId: number, accessor: Accessor, content: () => void, input: {
|
52
51
|
placeholder?: {
|
53
52
|
content?(): void;
|
54
53
|
};
|
package/dist/html.js
CHANGED
@@ -183,7 +183,8 @@ var WALKER_RUNTIME_CODE = '(e=>self[e]=self[e]||(l=>{let t,d={},s=[],f=document,
|
|
183
183
|
// src/html/serializer.ts
|
184
184
|
var { hasOwnProperty } = {}, Generator = function* () {
|
185
185
|
}().constructor, AsyncGenerator = async function* () {
|
186
|
-
}().constructor
|
186
|
+
}().constructor;
|
187
|
+
var REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
187
188
|
let KNOWN_SYMBOLS2 = /* @__PURE__ */ new Map();
|
188
189
|
for (let name of Object.getOwnPropertyNames(Symbol)) {
|
189
190
|
let symbol = Symbol[name];
|
@@ -427,7 +428,7 @@ var { hasOwnProperty } = {}, Generator = function* () {
|
|
427
428
|
refs = /* @__PURE__ */ new WeakMap();
|
428
429
|
assigned = /* @__PURE__ */ new Set();
|
429
430
|
boundary = void 0;
|
430
|
-
|
431
|
+
mutations = [];
|
431
432
|
}, Reference = class {
|
432
433
|
constructor(parent, accessor, flush, pos = null, id = null) {
|
433
434
|
this.parent = parent;
|
@@ -459,9 +460,24 @@ var Serializer = class {
|
|
459
460
|
let symbol = Symbol();
|
460
461
|
return this.#state.refs.set(symbol, new Reference(null, null, 0, null, id)), symbol;
|
461
462
|
}
|
462
|
-
writeCall(value, object,
|
463
|
+
writeCall(value, object, property, spread) {
|
463
464
|
let state = this.#state;
|
464
|
-
state.
|
465
|
+
state.mutations.push({
|
466
|
+
type: 0 /* call */,
|
467
|
+
value,
|
468
|
+
object,
|
469
|
+
property,
|
470
|
+
spread
|
471
|
+
}), state.flushed = !0;
|
472
|
+
}
|
473
|
+
writeAssign(value, object, property) {
|
474
|
+
let state = this.#state;
|
475
|
+
state.mutations.push({
|
476
|
+
type: 1 /* assign */,
|
477
|
+
value,
|
478
|
+
object,
|
479
|
+
property
|
480
|
+
}), state.flushed = !0;
|
465
481
|
}
|
466
482
|
};
|
467
483
|
function register(id, val, scope) {
|
@@ -481,12 +497,12 @@ function getRegistered(val) {
|
|
481
497
|
};
|
482
498
|
}
|
483
499
|
function writeRoot(state, root) {
|
484
|
-
let { buf, assigned,
|
500
|
+
let { buf, assigned, mutations } = state, hadBuf = buf.length !== 0, result = "";
|
485
501
|
if (hadBuf && buf.push(","), writeProp(state, root, null, "")) {
|
486
502
|
let rootRef = state.refs.get(root);
|
487
503
|
if (rootRef) {
|
488
504
|
let rootId = ensureId(state, rootRef);
|
489
|
-
(assigned.size ||
|
505
|
+
(assigned.size || mutations.length) && (assigned.delete(rootRef), writeAssigned(state), buf.push(
|
490
506
|
"," + (rootRef.assigns ? assignsToString(rootRef.assigns, rootId) : rootId)
|
491
507
|
));
|
492
508
|
}
|
@@ -505,27 +521,27 @@ function writeAssigned(state) {
|
|
505
521
|
) : state.buf.push("," + valueRef.init), valueRef.init = "") : valueRef.assigns && state.buf.push("," + assignsToString(valueRef.assigns, valueRef.id));
|
506
522
|
state.assigned = /* @__PURE__ */ new Set();
|
507
523
|
}
|
508
|
-
if (state.
|
509
|
-
for (let
|
524
|
+
if (state.mutations.length) {
|
525
|
+
for (let mutation of state.mutations) {
|
510
526
|
let objectStartIndex = state.buf.push(
|
511
527
|
state.buf.length === 0 ? "(" : ",("
|
512
528
|
);
|
513
|
-
if (writeProp(state, object, null, "")) {
|
514
|
-
let objectRef = state.refs.get(object);
|
529
|
+
if (writeProp(state, mutation.object, null, "")) {
|
530
|
+
let objectRef = state.refs.get(mutation.object);
|
515
531
|
objectRef && !objectRef.id && (objectRef.id = nextRefAccess(state), state.buf[objectStartIndex] = objectRef.id + "=" + state.buf[objectStartIndex]);
|
516
532
|
} else
|
517
533
|
state.buf.push("void 0");
|
518
534
|
let valueStartIndex = state.buf.push(
|
519
|
-
")" + (
|
535
|
+
mutation.type === 0 /* call */ ? ")" + (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "="
|
520
536
|
);
|
521
|
-
if (writeProp(state, value, null, "")) {
|
522
|
-
let valueRef = state.refs.get(value);
|
537
|
+
if (writeProp(state, mutation.value, null, "")) {
|
538
|
+
let valueRef = state.refs.get(mutation.value);
|
523
539
|
valueRef && !valueRef.id && (valueRef.id = nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
|
524
540
|
} else
|
525
541
|
state.buf.push("void 0");
|
526
542
|
state.buf.push(")");
|
527
543
|
}
|
528
|
-
state.
|
544
|
+
state.mutations = [], state.assigned.size && writeAssigned(state);
|
529
545
|
}
|
530
546
|
}
|
531
547
|
function writeProp(state, val, parent, accessor) {
|
@@ -1234,30 +1250,69 @@ function ensureScopeWithId(scopeId) {
|
|
1234
1250
|
function $global() {
|
1235
1251
|
return $chunk.boundary.state.$global;
|
1236
1252
|
}
|
1237
|
-
function fork(promise, content) {
|
1253
|
+
function fork(scopeId, accessor, promise, content) {
|
1238
1254
|
if (!isPromise(promise)) {
|
1239
|
-
|
1255
|
+
let branchId = peekNextScopeId();
|
1256
|
+
$chunk.writeHTML(
|
1257
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1258
|
+
), content(promise), writeScope(scopeId, {
|
1259
|
+
[accessor + "!" /* ConditionalScope */]: writeScope(branchId, {})
|
1260
|
+
}), $chunk.writeHTML(
|
1261
|
+
$chunk.boundary.state.mark(
|
1262
|
+
"]" /* BranchEnd */,
|
1263
|
+
scopeId + " " + accessor
|
1264
|
+
)
|
1265
|
+
);
|
1240
1266
|
return;
|
1241
1267
|
}
|
1242
1268
|
let chunk = $chunk, { boundary } = chunk;
|
1243
1269
|
chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context), chunk.async = !0, chunk.context?.[kPendingContexts] && (chunk.context = { ...chunk.context, [kPendingContexts]: 0 }), boundary.startAsync(), promise.then(
|
1244
1270
|
(value) => {
|
1245
|
-
chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(
|
1271
|
+
chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(() => {
|
1272
|
+
let branchId = peekNextScopeId();
|
1273
|
+
$chunk.writeHTML(
|
1274
|
+
$chunk.boundary.state.mark(
|
1275
|
+
"[" /* BranchStart */,
|
1276
|
+
branchId + ""
|
1277
|
+
)
|
1278
|
+
), content(value), boundary.state.serializer.writeAssign(
|
1279
|
+
writeScope(branchId, {}),
|
1280
|
+
ensureScopeWithId(scopeId),
|
1281
|
+
accessor + "!" /* ConditionalScope */
|
1282
|
+
), $chunk.writeHTML(
|
1283
|
+
$chunk.boundary.state.mark(
|
1284
|
+
"]" /* BranchEnd */,
|
1285
|
+
scopeId + " " + accessor
|
1286
|
+
)
|
1287
|
+
);
|
1288
|
+
}), boundary.endAsync(chunk)));
|
1246
1289
|
},
|
1247
1290
|
(err) => {
|
1248
1291
|
chunk.async = !1, boundary.abort(err);
|
1249
1292
|
}
|
1250
1293
|
);
|
1251
1294
|
}
|
1252
|
-
function tryContent(input) {
|
1253
|
-
let
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1295
|
+
function tryContent(scopeId, accessor, content, input) {
|
1296
|
+
let branchId = peekNextScopeId();
|
1297
|
+
$chunk.writeHTML(
|
1298
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1299
|
+
);
|
1300
|
+
let catchContent = normalizeDynamicRenderer(input.catch), placeholderContent = normalizeDynamicRenderer(input.placeholder);
|
1301
|
+
catchContent ? tryCatch(
|
1302
|
+
placeholderContent ? () => tryPlaceholder(content, placeholderContent) : content,
|
1303
|
+
catchContent
|
1304
|
+
) : placeholderContent ? tryPlaceholder(content, placeholderContent) : content(), writeScope(branchId, {
|
1305
|
+
"*": accessor,
|
1306
|
+
"^": catchContent,
|
1307
|
+
"%": placeholderContent
|
1308
|
+
}), writeScope(scopeId, {
|
1309
|
+
[accessor + "!" /* ConditionalScope */]: getScopeById(branchId)
|
1310
|
+
}), $chunk.writeHTML(
|
1311
|
+
$chunk.boundary.state.mark(
|
1312
|
+
"]" /* BranchEnd */,
|
1313
|
+
scopeId + " " + accessor
|
1314
|
+
)
|
1315
|
+
);
|
1261
1316
|
}
|
1262
1317
|
function tryPlaceholder(content, placeholder) {
|
1263
1318
|
let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context);
|
@@ -1428,7 +1483,7 @@ function prepareChunk(chunk) {
|
|
1428
1483
|
WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
|
1429
1484
|
));
|
1430
1485
|
let resumes = "";
|
1431
|
-
if ((state.writeScopes || serializer.flushed) && (resumes = state.serializer.stringify(state.writeScopes || {}, boundary), state.writeScopes = null), effects && (hasWalk = !0, resumes = resumes ? resumes + "," + effects : effects),
|
1486
|
+
if ((state.writeScopes || serializer.flushed) && (resumes = state.serializer.stringify(state.writeScopes || {}, boundary), state.writeScopes = null), effects && (hasWalk = !0, resumes = resumes ? resumes + "," + effects : effects), resumes && (state.hasWrittenResume ? scripts = concatScripts(
|
1432
1487
|
scripts,
|
1433
1488
|
runtimePrefix + ".r.push(" + resumes + ")"
|
1434
1489
|
) : (state.hasWrittenResume = !0, scripts = concatScripts(
|
@@ -1721,7 +1776,7 @@ function dynamicTagId(tagName) {
|
|
1721
1776
|
let normalizedRenderer = normalizeDynamicRenderer(tagName);
|
1722
1777
|
return normalizedRenderer?.a || normalizedRenderer;
|
1723
1778
|
}
|
1724
|
-
|
1779
|
+
var dynamicTagInput = (scopeId, accessor, tag, input, content) => {
|
1725
1780
|
if (!tag && !content) {
|
1726
1781
|
nextScopeId();
|
1727
1782
|
return;
|
@@ -1753,7 +1808,9 @@ function dynamicTagInput(scopeId, accessor, tag, input, content) {
|
|
1753
1808
|
);
|
1754
1809
|
return;
|
1755
1810
|
}
|
1756
|
-
let renderer =
|
1811
|
+
let renderer = normalizeDynamicRenderer(
|
1812
|
+
tag
|
1813
|
+
), result;
|
1757
1814
|
return resumeConditional(
|
1758
1815
|
() => {
|
1759
1816
|
result = renderer(content ? { ...input, content } : input);
|
@@ -1761,8 +1818,7 @@ function dynamicTagInput(scopeId, accessor, tag, input, content) {
|
|
1761
1818
|
scopeId,
|
1762
1819
|
accessor
|
1763
1820
|
), result;
|
1764
|
-
}
|
1765
|
-
function dynamicTagArgs(scopeId, accessor, tag, args) {
|
1821
|
+
}, dynamicTagArgs = (scopeId, accessor, tag, args) => {
|
1766
1822
|
if (!tag) {
|
1767
1823
|
nextScopeId();
|
1768
1824
|
return;
|
@@ -1779,7 +1835,9 @@ function dynamicTagArgs(scopeId, accessor, tag, args) {
|
|
1779
1835
|
);
|
1780
1836
|
return;
|
1781
1837
|
}
|
1782
|
-
let renderer =
|
1838
|
+
let renderer = normalizeDynamicRenderer(
|
1839
|
+
tag
|
1840
|
+
), result;
|
1783
1841
|
return resumeConditional(
|
1784
1842
|
() => {
|
1785
1843
|
result = renderer(...args);
|
@@ -1787,16 +1845,26 @@ function dynamicTagArgs(scopeId, accessor, tag, args) {
|
|
1787
1845
|
scopeId,
|
1788
1846
|
accessor
|
1789
1847
|
), result;
|
1790
|
-
}
|
1848
|
+
};
|
1791
1849
|
function createContent(id, fn) {
|
1792
1850
|
return fn.a = id, fn;
|
1793
1851
|
}
|
1794
1852
|
function registerContent(id, fn, scopeId) {
|
1795
1853
|
return register2(createContent(id, fn), id, scopeId);
|
1796
1854
|
}
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1855
|
+
function patchDynamicTag(patch) {
|
1856
|
+
dynamicTagInput = /* @__PURE__ */ ((originalDynamicTagInput) => (scopeId, accessor, tag, input, content) => originalDynamicTagInput(
|
1857
|
+
scopeId,
|
1858
|
+
accessor,
|
1859
|
+
patch(scopeId, accessor, tag),
|
1860
|
+
input,
|
1861
|
+
content
|
1862
|
+
))(dynamicTagInput), dynamicTagArgs = /* @__PURE__ */ ((originalDynamicTagArgs) => (scopeId, accessor, tag, args) => originalDynamicTagArgs(
|
1863
|
+
scopeId,
|
1864
|
+
accessor,
|
1865
|
+
patch(scopeId, accessor, tag),
|
1866
|
+
args
|
1867
|
+
))(dynamicTagArgs);
|
1800
1868
|
}
|
1801
1869
|
|
1802
1870
|
// src/html/compat.ts
|
package/dist/html.mjs
CHANGED
@@ -102,7 +102,8 @@ var WALKER_RUNTIME_CODE = '(e=>self[e]=self[e]||(l=>{let t,d={},s=[],f=document,
|
|
102
102
|
// src/html/serializer.ts
|
103
103
|
var { hasOwnProperty } = {}, Generator = function* () {
|
104
104
|
}().constructor, AsyncGenerator = async function* () {
|
105
|
-
}().constructor
|
105
|
+
}().constructor;
|
106
|
+
var REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
106
107
|
let KNOWN_SYMBOLS2 = /* @__PURE__ */ new Map();
|
107
108
|
for (let name of Object.getOwnPropertyNames(Symbol)) {
|
108
109
|
let symbol = Symbol[name];
|
@@ -346,7 +347,7 @@ var { hasOwnProperty } = {}, Generator = function* () {
|
|
346
347
|
refs = /* @__PURE__ */ new WeakMap();
|
347
348
|
assigned = /* @__PURE__ */ new Set();
|
348
349
|
boundary = void 0;
|
349
|
-
|
350
|
+
mutations = [];
|
350
351
|
}, Reference = class {
|
351
352
|
constructor(parent, accessor, flush, pos = null, id = null) {
|
352
353
|
this.parent = parent;
|
@@ -378,9 +379,24 @@ var Serializer = class {
|
|
378
379
|
let symbol = Symbol();
|
379
380
|
return this.#state.refs.set(symbol, new Reference(null, null, 0, null, id)), symbol;
|
380
381
|
}
|
381
|
-
writeCall(value, object,
|
382
|
+
writeCall(value, object, property, spread) {
|
382
383
|
let state = this.#state;
|
383
|
-
state.
|
384
|
+
state.mutations.push({
|
385
|
+
type: 0 /* call */,
|
386
|
+
value,
|
387
|
+
object,
|
388
|
+
property,
|
389
|
+
spread
|
390
|
+
}), state.flushed = !0;
|
391
|
+
}
|
392
|
+
writeAssign(value, object, property) {
|
393
|
+
let state = this.#state;
|
394
|
+
state.mutations.push({
|
395
|
+
type: 1 /* assign */,
|
396
|
+
value,
|
397
|
+
object,
|
398
|
+
property
|
399
|
+
}), state.flushed = !0;
|
384
400
|
}
|
385
401
|
};
|
386
402
|
function register(id, val, scope) {
|
@@ -400,12 +416,12 @@ function getRegistered(val) {
|
|
400
416
|
};
|
401
417
|
}
|
402
418
|
function writeRoot(state, root) {
|
403
|
-
let { buf, assigned,
|
419
|
+
let { buf, assigned, mutations } = state, hadBuf = buf.length !== 0, result = "";
|
404
420
|
if (hadBuf && buf.push(","), writeProp(state, root, null, "")) {
|
405
421
|
let rootRef = state.refs.get(root);
|
406
422
|
if (rootRef) {
|
407
423
|
let rootId = ensureId(state, rootRef);
|
408
|
-
(assigned.size ||
|
424
|
+
(assigned.size || mutations.length) && (assigned.delete(rootRef), writeAssigned(state), buf.push(
|
409
425
|
"," + (rootRef.assigns ? assignsToString(rootRef.assigns, rootId) : rootId)
|
410
426
|
));
|
411
427
|
}
|
@@ -424,27 +440,27 @@ function writeAssigned(state) {
|
|
424
440
|
) : state.buf.push("," + valueRef.init), valueRef.init = "") : valueRef.assigns && state.buf.push("," + assignsToString(valueRef.assigns, valueRef.id));
|
425
441
|
state.assigned = /* @__PURE__ */ new Set();
|
426
442
|
}
|
427
|
-
if (state.
|
428
|
-
for (let
|
443
|
+
if (state.mutations.length) {
|
444
|
+
for (let mutation of state.mutations) {
|
429
445
|
let objectStartIndex = state.buf.push(
|
430
446
|
state.buf.length === 0 ? "(" : ",("
|
431
447
|
);
|
432
|
-
if (writeProp(state, object, null, "")) {
|
433
|
-
let objectRef = state.refs.get(object);
|
448
|
+
if (writeProp(state, mutation.object, null, "")) {
|
449
|
+
let objectRef = state.refs.get(mutation.object);
|
434
450
|
objectRef && !objectRef.id && (objectRef.id = nextRefAccess(state), state.buf[objectStartIndex] = objectRef.id + "=" + state.buf[objectStartIndex]);
|
435
451
|
} else
|
436
452
|
state.buf.push("void 0");
|
437
453
|
let valueStartIndex = state.buf.push(
|
438
|
-
")" + (
|
454
|
+
mutation.type === 0 /* call */ ? ")" + (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "="
|
439
455
|
);
|
440
|
-
if (writeProp(state, value, null, "")) {
|
441
|
-
let valueRef = state.refs.get(value);
|
456
|
+
if (writeProp(state, mutation.value, null, "")) {
|
457
|
+
let valueRef = state.refs.get(mutation.value);
|
442
458
|
valueRef && !valueRef.id && (valueRef.id = nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
|
443
459
|
} else
|
444
460
|
state.buf.push("void 0");
|
445
461
|
state.buf.push(")");
|
446
462
|
}
|
447
|
-
state.
|
463
|
+
state.mutations = [], state.assigned.size && writeAssigned(state);
|
448
464
|
}
|
449
465
|
}
|
450
466
|
function writeProp(state, val, parent, accessor) {
|
@@ -1153,30 +1169,69 @@ function ensureScopeWithId(scopeId) {
|
|
1153
1169
|
function $global() {
|
1154
1170
|
return $chunk.boundary.state.$global;
|
1155
1171
|
}
|
1156
|
-
function fork(promise, content) {
|
1172
|
+
function fork(scopeId, accessor, promise, content) {
|
1157
1173
|
if (!isPromise(promise)) {
|
1158
|
-
|
1174
|
+
let branchId = peekNextScopeId();
|
1175
|
+
$chunk.writeHTML(
|
1176
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1177
|
+
), content(promise), writeScope(scopeId, {
|
1178
|
+
[accessor + "!" /* ConditionalScope */]: writeScope(branchId, {})
|
1179
|
+
}), $chunk.writeHTML(
|
1180
|
+
$chunk.boundary.state.mark(
|
1181
|
+
"]" /* BranchEnd */,
|
1182
|
+
scopeId + " " + accessor
|
1183
|
+
)
|
1184
|
+
);
|
1159
1185
|
return;
|
1160
1186
|
}
|
1161
1187
|
let chunk = $chunk, { boundary } = chunk;
|
1162
1188
|
chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context), chunk.async = !0, chunk.context?.[kPendingContexts] && (chunk.context = { ...chunk.context, [kPendingContexts]: 0 }), boundary.startAsync(), promise.then(
|
1163
1189
|
(value) => {
|
1164
|
-
chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(
|
1190
|
+
chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(() => {
|
1191
|
+
let branchId = peekNextScopeId();
|
1192
|
+
$chunk.writeHTML(
|
1193
|
+
$chunk.boundary.state.mark(
|
1194
|
+
"[" /* BranchStart */,
|
1195
|
+
branchId + ""
|
1196
|
+
)
|
1197
|
+
), content(value), boundary.state.serializer.writeAssign(
|
1198
|
+
writeScope(branchId, {}),
|
1199
|
+
ensureScopeWithId(scopeId),
|
1200
|
+
accessor + "!" /* ConditionalScope */
|
1201
|
+
), $chunk.writeHTML(
|
1202
|
+
$chunk.boundary.state.mark(
|
1203
|
+
"]" /* BranchEnd */,
|
1204
|
+
scopeId + " " + accessor
|
1205
|
+
)
|
1206
|
+
);
|
1207
|
+
}), boundary.endAsync(chunk)));
|
1165
1208
|
},
|
1166
1209
|
(err) => {
|
1167
1210
|
chunk.async = !1, boundary.abort(err);
|
1168
1211
|
}
|
1169
1212
|
);
|
1170
1213
|
}
|
1171
|
-
function tryContent(input) {
|
1172
|
-
let
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1214
|
+
function tryContent(scopeId, accessor, content, input) {
|
1215
|
+
let branchId = peekNextScopeId();
|
1216
|
+
$chunk.writeHTML(
|
1217
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1218
|
+
);
|
1219
|
+
let catchContent = normalizeDynamicRenderer(input.catch), placeholderContent = normalizeDynamicRenderer(input.placeholder);
|
1220
|
+
catchContent ? tryCatch(
|
1221
|
+
placeholderContent ? () => tryPlaceholder(content, placeholderContent) : content,
|
1222
|
+
catchContent
|
1223
|
+
) : placeholderContent ? tryPlaceholder(content, placeholderContent) : content(), writeScope(branchId, {
|
1224
|
+
"*": accessor,
|
1225
|
+
"^": catchContent,
|
1226
|
+
"%": placeholderContent
|
1227
|
+
}), writeScope(scopeId, {
|
1228
|
+
[accessor + "!" /* ConditionalScope */]: getScopeById(branchId)
|
1229
|
+
}), $chunk.writeHTML(
|
1230
|
+
$chunk.boundary.state.mark(
|
1231
|
+
"]" /* BranchEnd */,
|
1232
|
+
scopeId + " " + accessor
|
1233
|
+
)
|
1234
|
+
);
|
1180
1235
|
}
|
1181
1236
|
function tryPlaceholder(content, placeholder) {
|
1182
1237
|
let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context);
|
@@ -1347,7 +1402,7 @@ function prepareChunk(chunk) {
|
|
1347
1402
|
WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
|
1348
1403
|
));
|
1349
1404
|
let resumes = "";
|
1350
|
-
if ((state.writeScopes || serializer.flushed) && (resumes = state.serializer.stringify(state.writeScopes || {}, boundary), state.writeScopes = null), effects && (hasWalk = !0, resumes = resumes ? resumes + "," + effects : effects),
|
1405
|
+
if ((state.writeScopes || serializer.flushed) && (resumes = state.serializer.stringify(state.writeScopes || {}, boundary), state.writeScopes = null), effects && (hasWalk = !0, resumes = resumes ? resumes + "," + effects : effects), resumes && (state.hasWrittenResume ? scripts = concatScripts(
|
1351
1406
|
scripts,
|
1352
1407
|
runtimePrefix + ".r.push(" + resumes + ")"
|
1353
1408
|
) : (state.hasWrittenResume = !0, scripts = concatScripts(
|
@@ -1640,7 +1695,7 @@ function dynamicTagId(tagName) {
|
|
1640
1695
|
let normalizedRenderer = normalizeDynamicRenderer(tagName);
|
1641
1696
|
return normalizedRenderer?.a || normalizedRenderer;
|
1642
1697
|
}
|
1643
|
-
|
1698
|
+
var dynamicTagInput = (scopeId, accessor, tag, input, content) => {
|
1644
1699
|
if (!tag && !content) {
|
1645
1700
|
nextScopeId();
|
1646
1701
|
return;
|
@@ -1672,7 +1727,9 @@ function dynamicTagInput(scopeId, accessor, tag, input, content) {
|
|
1672
1727
|
);
|
1673
1728
|
return;
|
1674
1729
|
}
|
1675
|
-
let renderer =
|
1730
|
+
let renderer = normalizeDynamicRenderer(
|
1731
|
+
tag
|
1732
|
+
), result;
|
1676
1733
|
return resumeConditional(
|
1677
1734
|
() => {
|
1678
1735
|
result = renderer(content ? { ...input, content } : input);
|
@@ -1680,8 +1737,7 @@ function dynamicTagInput(scopeId, accessor, tag, input, content) {
|
|
1680
1737
|
scopeId,
|
1681
1738
|
accessor
|
1682
1739
|
), result;
|
1683
|
-
}
|
1684
|
-
function dynamicTagArgs(scopeId, accessor, tag, args) {
|
1740
|
+
}, dynamicTagArgs = (scopeId, accessor, tag, args) => {
|
1685
1741
|
if (!tag) {
|
1686
1742
|
nextScopeId();
|
1687
1743
|
return;
|
@@ -1698,7 +1754,9 @@ function dynamicTagArgs(scopeId, accessor, tag, args) {
|
|
1698
1754
|
);
|
1699
1755
|
return;
|
1700
1756
|
}
|
1701
|
-
let renderer =
|
1757
|
+
let renderer = normalizeDynamicRenderer(
|
1758
|
+
tag
|
1759
|
+
), result;
|
1702
1760
|
return resumeConditional(
|
1703
1761
|
() => {
|
1704
1762
|
result = renderer(...args);
|
@@ -1706,16 +1764,26 @@ function dynamicTagArgs(scopeId, accessor, tag, args) {
|
|
1706
1764
|
scopeId,
|
1707
1765
|
accessor
|
1708
1766
|
), result;
|
1709
|
-
}
|
1767
|
+
};
|
1710
1768
|
function createContent(id, fn) {
|
1711
1769
|
return fn.a = id, fn;
|
1712
1770
|
}
|
1713
1771
|
function registerContent(id, fn, scopeId) {
|
1714
1772
|
return register2(createContent(id, fn), id, scopeId);
|
1715
1773
|
}
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1774
|
+
function patchDynamicTag(patch) {
|
1775
|
+
dynamicTagInput = /* @__PURE__ */ ((originalDynamicTagInput) => (scopeId, accessor, tag, input, content) => originalDynamicTagInput(
|
1776
|
+
scopeId,
|
1777
|
+
accessor,
|
1778
|
+
patch(scopeId, accessor, tag),
|
1779
|
+
input,
|
1780
|
+
content
|
1781
|
+
))(dynamicTagInput), dynamicTagArgs = /* @__PURE__ */ ((originalDynamicTagArgs) => (scopeId, accessor, tag, args) => originalDynamicTagArgs(
|
1782
|
+
scopeId,
|
1783
|
+
accessor,
|
1784
|
+
patch(scopeId, accessor, tag),
|
1785
|
+
args
|
1786
|
+
))(dynamicTagArgs);
|
1719
1787
|
}
|
1720
1788
|
|
1721
1789
|
// src/html/compat.ts
|
@@ -1,3 +1,10 @@
|
|
1
1
|
import { type Tag } from "@marko/compiler/babel-utils";
|
2
|
+
import { type Binding } from "../util/references";
|
3
|
+
declare const kDOMBinding: unique symbol;
|
4
|
+
declare module "@marko/compiler/dist/types" {
|
5
|
+
interface MarkoTagExtra {
|
6
|
+
[kDOMBinding]?: Binding;
|
7
|
+
}
|
8
|
+
}
|
2
9
|
declare const _default: Tag;
|
3
10
|
export default _default;
|
@@ -1,3 +1,10 @@
|
|
1
1
|
import { type Tag } from "@marko/compiler/babel-utils";
|
2
|
+
import { type Binding } from "../util/references";
|
3
|
+
declare const kDOMBinding: unique symbol;
|
4
|
+
declare module "@marko/compiler/dist/types" {
|
5
|
+
interface MarkoTagExtra {
|
6
|
+
[kDOMBinding]?: Binding;
|
7
|
+
}
|
8
|
+
}
|
2
9
|
declare const _default: Tag;
|
3
10
|
export default _default;
|