diff --git a/packages/runtime-tags/src/__tests__/fixtures/assign-to-owner-closure/__snapshots__/dom.expected.1/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/assign-to-owner-closure/__snapshots__/dom.expected.1/template.hydrate.js deleted file mode 100644 index dd194e360..000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/assign-to-owner-closure/__snapshots__/dom.expected.1/template.hydrate.js +++ /dev/null @@ -1,14 +0,0 @@ -// size: 164 (min) 130 (brotli) -const $if_content__setup = _._script("a0", ($scope) => - _._on($scope[0], "click", function () { - $hide($scope._, !0); - }), - ), - $if_content = _._content_branch( - "", - " b", - $if_content__setup, - ), - $if = _._if(0, $if_content), - $hide = _._let(1, ($scope, hide) => $if($scope, hide ? 1 : 0)); -init(); diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/resume.expected.md index d4f850670..eb71446e9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/resume.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/resume.expected.md @@ -69,10 +69,3 @@ ``` - -# Mutations -``` -INSERT html/body/div/div/#text -INSERT html/body/div/#text -INSERT html/body/div/div/div/#text -``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/ssr-sanitized.expected.md index e40233bcd..aad3ded36 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/ssr-sanitized.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/ssr-sanitized.expected.md @@ -1,4 +1,40 @@ -# Render End +# Render ASYNC +```html +
+
+ LOADING... +
+
+``` + + +# Render ASYNC +```html +
+
+
+
+ LOADING... +
+
+
+
+``` + + +# Render ASYNC ```html
``` -# Render End +# Render ASYNC +```html + + + + + +
+ +
+ + + LOADING... + + +
+ +
+ + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/div +INSERT html/body/div/#comment0 +INSERT html/body/div/div +INSERT html/body/div/div/#comment0 +INSERT html/body/div/div/#comment1 +INSERT html/body/div/div/#text +INSERT html/body/div/div/#comment2 +INSERT html/body/div/div/#comment3 +INSERT html/body/div/#comment1 +INSERT html/head/style +INSERT html/head/style/#text +INSERT t +INSERT t/#comment +REMOVE html/head/style after html/body/div +INSERT html/head/style +REMOVE t after html/body/div +INSERT html/body/script +``` + +# Render ASYNC +```html + + + + + +
+ +
+ +
+ +
+ + + LOADING... + + +
+ +
+ +
+ +
+ + + + +``` + +# Mutations +``` +INSERT t +INSERT html/body/div/div/div +INSERT html/body/div/div/div/#comment0 +INSERT html/body/div/div/div/div +INSERT html/body/div/div/div/div/#comment0 +INSERT html/body/div/div/div/div/#comment1 +INSERT html/body/div/div/div/div/#text +INSERT html/body/div/div/div/div/#comment2 +INSERT html/body/div/div/div/div/#comment3 +INSERT html/body/div/div/div/#comment1 +INSERT t +INSERT t/#comment +REMOVE t after html/body/script0 +REMOVE #text after #comment +REMOVE #comment after html/body/div/div/#comment0 +REMOVE #comment after html/body/div/div/#comment0 +INSERT html/body/div/div/div +REMOVE t after html/body/script0 +INSERT html/body/script1 +``` + +# Render ASYNC ```html @@ -87,52 +252,10 @@ # Mutations ``` -INSERT html -INSERT html/head -INSERT html/body -INSERT html/body/div -INSERT html/body/div/#comment0 -INSERT html/body/div/div -INSERT html/body/div/div/#comment0 -INSERT #comment -INSERT #text -INSERT #comment -INSERT html/body/div/div/#comment1 -INSERT html/body/div/#comment1 -INSERT html/head/style -INSERT html/head/style/#text INSERT t -INSERT #comment -INSERT html/body/script0 -INSERT html/body/script0/#text -REMOVE html/head/style after html/body/div -INSERT html/head/style -REMOVE t after html/body/div -INSERT t -INSERT html/body/div/div/div -INSERT html/body/div/div/div/#comment0 -INSERT html/body/div/div/div/div -INSERT html/body/div/div/div/div/#comment0 -INSERT #comment -INSERT #text -INSERT #comment -INSERT html/body/div/div/div/div/#comment1 -INSERT html/body/div/div/div/#comment1 -INSERT t -INSERT #comment -INSERT html/body/script1 -INSERT html/body/script1/#text -REMOVE t after html/body/script0 -REMOVE #text after #comment -REMOVE #comment after html/body/div/div/#comment0 -REMOVE #comment after html/body/div/div/#comment0 -INSERT html/body/div/div/div -REMOVE t after html/body/script0 -INSERT t -INSERT html/body/script2 -INSERT html/body/script2/#text REMOVE t after html/body/script1 REMOVE #text after #comment REMOVE #comment after html/body/div/div/div/div/#comment0 REMOVE #comment after html/body/div/div/div/div/#comment0 +INSERT html/body/script2 ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/resume.expected.md index 41424b7b4..e9e357757 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/resume.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/resume.expected.md @@ -84,14 +84,6 @@ ``` -# Mutations -``` -INSERT html/body/p0/#text4 -INSERT html/body/p1/#text4 -INSERT html/body/p2/#text4 -INSERT html/body/p3/#text4 -INSERT html/body/p4/#text4 -``` # Render ```js diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/ssr-sanitized.expected.md index 0f66126e2..896849d7b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/ssr-sanitized.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/async-multi-resolve-in-order-and-update/__snapshots__/ssr-sanitized.expected.md @@ -1,4 +1,15 @@ -# Render End +# Render ASYNC +```html + +

+ 1 * 2 = +

+``` + + +# Render ASYNC ```html + +

+ 1 * + + 2 + + = + +

+ + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/button +INSERT html/body/button/#text +INSERT html/body/#comment +INSERT html/body/p +INSERT html/body/p/#text0 +INSERT html/body/p/#comment0 +INSERT html/body/p/#text1 +INSERT html/body/p/#comment1 +INSERT html/body/p/#text2 +INSERT html/body/p/script +``` + +# Render ASYNC ```html @@ -96,20 +140,6 @@ # Mutations ``` -INSERT html -INSERT html/head -INSERT html/body -INSERT html/body/button -INSERT html/body/button/#text -INSERT html/body/#comment -INSERT html/body/p0 -INSERT html/body/p0/#text0 -INSERT html/body/p0/#comment0 -INSERT html/body/p0/#text1 -INSERT html/body/p0/#comment1 -INSERT html/body/p0/#text2 -INSERT html/body/p0/script -INSERT html/body/p0/script/#text INSERT html/body/p0/#comment2 INSERT html/body/p0/#text3 INSERT html/body/p0/#comment3 @@ -155,5 +185,4 @@ INSERT html/body/p4/#text3 INSERT html/body/p4/#comment3 INSERT html/body/p4/#comment4 INSERT html/body/script -INSERT html/body/script/#text ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-nested-resolve-in-order/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/async-nested-resolve-in-order/__snapshots__/ssr-sanitized.expected.md index 2eec4fc24..5b07535ce 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-nested-resolve-in-order/__snapshots__/ssr-sanitized.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/async-nested-resolve-in-order/__snapshots__/ssr-sanitized.expected.md @@ -1,4 +1,22 @@ -# Render End +# Render ASYNC +```html +a +``` + + +# Render ASYNC +```html +ab +``` + + +# Render ASYNC +```html +abc +``` + + +# Render ASYNC ```html abcdefghijklm ``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-nested-resolve-in-order/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/async-nested-resolve-in-order/__snapshots__/ssr.expected.md index 73220305d..8aa841a26 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-nested-resolve-in-order/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/async-nested-resolve-in-order/__snapshots__/ssr.expected.md @@ -18,7 +18,55 @@ defghijklm ``` -# Render End +# Render ASYNC +```html + + + + a + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/#text +``` + +# Render ASYNC +```html + + + + ab + + +``` + +# Mutations +``` +INSERT html/body/#text1 +``` + +# Render ASYNC +```html + + + + abc + + +``` + +# Mutations +``` +INSERT html/body/#text2 +``` + +# Render ASYNC ```html @@ -30,8 +78,5 @@ # Mutations ``` -INSERT html -INSERT html/head -INSERT html/body -INSERT html/body/#text +INSERT html/body/#text3 ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-reject-then-resolve-before-and-after-isolated-boundaries/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/async-reject-then-resolve-before-and-after-isolated-boundaries/__snapshots__/resume.expected.md index 0595e887f..b1c264692 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-reject-then-resolve-before-and-after-isolated-boundaries/__snapshots__/resume.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/async-reject-then-resolve-before-and-after-isolated-boundaries/__snapshots__/resume.expected.md @@ -1,8 +1,16 @@ # Render ```html - + + + + + - - - - - - - - ``` -# Render End +# Render ASYNC ```html - - - + + + + + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/#comment0 +INSERT html/body/#comment1 +INSERT html/body/script +``` + +# Render ASYNC +```html + + + + + + + + +``` + +# Mutations +``` +INSERT html/head/style +INSERT html/head/style/#text +INSERT t +INSERT t/#text +REMOVE html/head/style after html/body/script0 +INSERT html/head/style +REMOVE t after html/body/script0 +INSERT html/body/script1 +``` + +# Render ASYNC +```html + + + + + + + + - - - - ``` -# Render End +# Render ASYNC ```html - - - + + + + + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/#comment0 +INSERT html/body/#comment1 +INSERT html/body/script +``` + +# Render ASYNC +```html + + + + + + + + +``` + +# Mutations +``` +INSERT html/head/style +INSERT html/head/style/#text +INSERT t +INSERT t/#text +REMOVE html/head/style after html/body/script0 +INSERT html/head/style +REMOVE t after html/body/script0 +INSERT html/body/script1 +``` + +# Render ASYNC +```html + + + + + + + + ``` -# Render End +# Render ASYNC ```html - + + + +
+ +
+ + + LOADING B1 + + +
+ +
+ + + + + +``` + +# Mutations +``` +INSERT t +INSERT html/body/div +INSERT html/body/div/#comment0 +INSERT html/body/div/div +INSERT html/body/div/div/#comment0 +INSERT html/body/div/div/#comment1 +INSERT html/body/div/div/#text +INSERT html/body/div/div/#comment2 +INSERT html/body/div/div/#comment3 +INSERT html/body/div/#comment1 +INSERT t +INSERT t/#comment +REMOVE t after html/body/script0 +REMOVE #text after #comment +REMOVE #comment after html/body/#comment0 +REMOVE #comment after html/body/#comment0 +INSERT html/body/div +REMOVE t after html/body/script0 +INSERT html/body/script1 +``` + +# Render ASYNC +```html + + + + + +
+ + + a + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/#text +``` + +# Render ASYNC +```html + + + + abc + + +``` + +# Mutations +``` +INSERT html/body/#text1 +``` + +# Render ASYNC ```html @@ -25,8 +58,5 @@ # Mutations ``` -INSERT html -INSERT html/head -INSERT html/body -INSERT html/body/#text +INSERT html/body/#text2 ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-resolve-out-of-order/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/async-resolve-out-of-order/__snapshots__/ssr-sanitized.expected.md index 39e6ec137..7f89e5d18 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-resolve-out-of-order/__snapshots__/ssr-sanitized.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/async-resolve-out-of-order/__snapshots__/ssr-sanitized.expected.md @@ -1,4 +1,10 @@ -# Render End +# Render ASYNC +```html +a +``` + + +# Render ASYNC ```html abcde ``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-resolve-out-of-order/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/async-resolve-out-of-order/__snapshots__/ssr.expected.md index e9c8dc4c9..31bc473e9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-resolve-out-of-order/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/async-resolve-out-of-order/__snapshots__/ssr.expected.md @@ -8,7 +8,25 @@ bcde ``` -# Render End +# Render ASYNC +```html + + + + a + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/#text +``` + +# Render ASYNC ```html @@ -20,8 +38,5 @@ # Mutations ``` -INSERT html -INSERT html/head -INSERT html/body -INSERT html/body/#text +INSERT html/body/#text1 ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/resume.expected.md index a56e3ab89..58200aae1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/resume.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/resume.expected.md @@ -46,11 +46,6 @@ ``` -# Mutations -``` -INSERT html/body/#text2 -INSERT html/body/#text1 -``` # Render ```js diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/ssr-sanitized.expected.md index 25b878946..5ad0c9e3d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/ssr-sanitized.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/async-state/__snapshots__/ssr-sanitized.expected.md @@ -1,4 +1,13 @@ -# Render End +# Render ASYNC +```html + +LOADING... +``` + + +# Render ASYNC ```html + + + + LOADING... + + + + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/button +INSERT html/body/button/#text +INSERT html/body/#comment0 +INSERT html/body/#comment1 +INSERT html/body/#comment2 +INSERT html/body/#text +INSERT html/body/#comment3 +INSERT html/body/#comment4 +INSERT html/head/style +INSERT html/head/style/#text +INSERT t +INSERT t/#comment +REMOVE html/head/style after html/body/#comment4 +INSERT html/head/style +REMOVE t after html/body/#comment4 +INSERT html/body/script +``` + +# Render ASYNC ```html @@ -58,36 +123,15 @@ # Mutations ``` -INSERT html -INSERT html/head -INSERT html/body -INSERT html/body/button -INSERT html/body/button/#text -INSERT html/body/#comment0 -INSERT html/body/#comment1 -INSERT #comment -INSERT #text -INSERT #comment -INSERT html/body/#comment5 -INSERT html/head/style -INSERT html/head/style/#text -INSERT t -INSERT #comment -INSERT html/body/script0 -INSERT html/body/script0/#text -REMOVE html/head/style after html/body/#comment5 -INSERT html/head/style -REMOVE t after html/body/#comment5 INSERT t INSERT html/body/#comment2 INSERT html/body/#text INSERT html/body/#comment3 INSERT html/body/#comment4 -INSERT html/body/script1 -INSERT html/body/script1/#text REMOVE t after html/body/script0 REMOVE #text after #comment REMOVE #comment after html/body/#comment1 REMOVE #comment after html/body/#comment1 INSERT html/body/#comment2, html/body/#text, html/body/#comment3, html/body/#comment4 +INSERT html/body/script1 ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/resume.expected.md index f247d5027..2fc5cf5e1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/resume.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/resume.expected.md @@ -59,12 +59,6 @@ ``` -# Mutations -``` -INSERT html/body/div/#text2 -INSERT html/body/div/#text5 -INSERT html/body/div/#text8 -``` # Render ```js diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr-sanitized.expected.md index e8b45921a..70a6e6335 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr-sanitized.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr-sanitized.expected.md @@ -1,4 +1,20 @@ -# Render End +# Render ASYNC +```html +
+ Got: a 0 +
+``` + + +# Render ASYNC +```html +
+ Got: a 0 +
+``` + + +# Render ASYNC ```html
Got: a 0Got: b 0Got: c 0 diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr.expected.md index 0d9cf979a..b455bf8d9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/await-tag/__snapshots__/ssr.expected.md @@ -13,7 +13,92 @@ Got: b 0Got: c 0
``` -# Render End +# Render ASYNC +```html + + + +
+ + Got: a + + 0 + + + +
+ + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/div +INSERT html/body/div/#comment0 +INSERT html/body/div/#text0 +INSERT html/body/div/#comment1 +INSERT html/body/div/#text1 +INSERT html/body/div/#comment2 +INSERT html/body/div/#comment3 +INSERT html/body/div/script +``` + +# Render ASYNC +```html + + + +
+ + Got: a + + 0 + + + + +
+ + +``` + +# Mutations +``` +INSERT html/body/div/script1 +``` + +# Render ASYNC ```html @@ -76,20 +161,6 @@ # Mutations ``` -INSERT html -INSERT html/head -INSERT html/body -INSERT html/body/div -INSERT html/body/div/#comment0 -INSERT html/body/div/#text0 -INSERT html/body/div/#comment1 -INSERT html/body/div/#text1 -INSERT html/body/div/#comment2 -INSERT html/body/div/#comment3 -INSERT html/body/div/script0 -INSERT html/body/div/script0/#text -INSERT html/body/div/script1 -INSERT html/body/div/script1/#text INSERT html/body/div/#comment4 INSERT html/body/div/#text2 INSERT html/body/div/#comment5 @@ -106,5 +177,4 @@ INSERT html/body/div/button INSERT html/body/div/button/#text INSERT html/body/div/#comment12 INSERT html/body/script -INSERT html/body/script/#text ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/resume.expected.md index aa63d5dab..d89e5e3fb 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/resume.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/resume.expected.md @@ -21,8 +21,3 @@ ``` - -# Mutations -``` -INSERT html/body/#text2 -``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/ssr-sanitized.expected.md index 420364723..cd40ad370 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/ssr-sanitized.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/ssr-sanitized.expected.md @@ -1,4 +1,10 @@ -# Render End +# Render ASYNC +```html +ab +``` + + +# Render ASYNC ```html aERROR!def ``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/ssr.expected.md index 254877409..1031a1853 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/catch-single-reject-async/__snapshots__/ssr.expected.md @@ -8,7 +8,41 @@ defERROR! ``` -# Render End +# Render ASYNC +```html + + + + a + + + b + + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/#text0 +INSERT html/body/#comment0 +INSERT html/body/#comment1 +INSERT html/body/#text1 +INSERT html/body/script +``` + +# Render ASYNC ```html @@ -34,15 +68,6 @@ # Mutations ``` -INSERT html -INSERT html/head -INSERT html/body -INSERT html/body/#text0 -INSERT html/body/#comment0 -INSERT #comment -INSERT #text -INSERT script -INSERT script/#text INSERT #comment INSERT html/body/#comment1 INSERT html/body/#text2 @@ -50,8 +75,6 @@ INSERT html/head/style INSERT html/head/style/#text INSERT t INSERT html/body/#text1 -INSERT html/body/script -INSERT html/body/script/#text REMOVE html/head/style after html/body/#text2 INSERT html/head/style REMOVE t after html/body/#text2 @@ -60,4 +83,5 @@ REMOVE #text after #comment REMOVE #comment after html/body/#comment0 REMOVE #comment after html/body/#comment0 INSERT html/body/#text1 +INSERT html/body/script ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/catch-single-success-async/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/catch-single-success-async/__snapshots__/ssr-sanitized.expected.md index 7d2db6199..10c274128 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/catch-single-success-async/__snapshots__/ssr-sanitized.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/catch-single-success-async/__snapshots__/ssr-sanitized.expected.md @@ -1,4 +1,10 @@ -# Render End +# Render ASYNC +```html +ab +``` + + +# Render ASYNC ```html abcdfgh ``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/catch-single-success-async/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/catch-single-success-async/__snapshots__/ssr.expected.md index ccc476bb2..591ae022c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/catch-single-success-async/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/catch-single-success-async/__snapshots__/ssr.expected.md @@ -8,7 +8,41 @@ cdfgh ``` -# Render End +# Render ASYNC +```html + + + + a + + + b + + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/#text0 +INSERT html/body/#comment0 +INSERT html/body/#comment1 +INSERT html/body/#text1 +INSERT html/body/script +``` + +# Render ASYNC ```html @@ -36,15 +70,6 @@ # Mutations ``` -INSERT html -INSERT html/head -INSERT html/body -INSERT html/body/#text0 -INSERT html/body/#comment0 -INSERT html/body/#comment1 -INSERT html/body/#text1 -INSERT html/body/script -INSERT html/body/script/#text INSERT html/body/#text2 INSERT html/body/#comment2 INSERT html/body/#comment3 diff --git a/packages/runtime-tags/src/__tests__/fixtures/component-attrs-import-value/__snapshots__/csr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/component-attrs-import-value/__snapshots__/csr-sanitized.expected.md deleted file mode 100644 index 9f684f8b2..000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/component-attrs-import-value/__snapshots__/csr-sanitized.expected.md +++ /dev/null @@ -1,17 +0,0 @@ -# Render -```html - -``` - - -# Render -```js -container.querySelector("button").click(); -``` -```html - -``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/component-attrs-import-value/__snapshots__/csr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/component-attrs-import-value/__snapshots__/csr.expected.md deleted file mode 100644 index d6d8ed86c..000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/component-attrs-import-value/__snapshots__/csr.expected.md +++ /dev/null @@ -1,26 +0,0 @@ -# Render -```html - -``` - -# Mutations -``` -INSERT button -``` - -# Render -```js -container.querySelector("button").click(); -``` -```html - -``` - -# Mutations -``` -UPDATE button/#text "$0.00" => "$1.00" -``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/component-attrs-static-non-registered-function/__snapshots__/dom.expected/tags/counter.js b/packages/runtime-tags/src/__tests__/fixtures/component-attrs-static-non-registered-function/__snapshots__/dom.expected/tags/counter.js deleted file mode 100644 index 95105101e..000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/component-attrs-static-non-registered-function/__snapshots__/dom.expected/tags/counter.js +++ /dev/null @@ -1,24 +0,0 @@ -export const $template = ""; -export const $walks = /* get, next(1), get, out(1) */" D l"; -import * as _$ from "@marko/runtime-tags/debug/dom"; -const $expr_input_count = /* @__PURE__ */_$.intersection(5, $scope => { - const { - input, - count - } = $scope; - _$.data($scope["#text/1"], input.format(count)); -}); -const $count_effect = _$.effect("__tests__/tags/counter.marko_0_count", ($scope, { - count -}) => _$.on($scope["#button/0"], "click", function () { - $count($scope, ++count) -})); -const $count = /* @__PURE__ */_$.state("count/4", $scope => { - $expr_input_count($scope); - $count_effect($scope); -}); -export function $setup($scope) { - $count($scope, 0); -} -export const $input = /* @__PURE__ */_$.value("input", $expr_input_count); -export default /* @__PURE__ */_$.createTemplate("__tests__/tags/counter.marko", $template, $walks, $setup, $input); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/component-attrs-static-non-registered-function/__snapshots__/html.expected/tags/counter.js b/packages/runtime-tags/src/__tests__/fixtures/component-attrs-static-non-registered-function/__snapshots__/html.expected/tags/counter.js deleted file mode 100644 index 924c46533..000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/component-attrs-static-non-registered-function/__snapshots__/html.expected/tags/counter.js +++ /dev/null @@ -1,15 +0,0 @@ -import * as _$ from "@marko/runtime-tags/debug/html"; -export default _$.createTemplate("__tests__/tags/counter.marko", input => { - const $scope0_id = _$._scope_id(); - let count = 0; - _$._html(`${_$.markResumeNode($scope0_id, "#button/0")}`); - _$._script($scope0_id, "__tests__/tags/counter.marko_0_count"); - _$._scope($scope0_id, { - input, - count - }, "__tests__/tags/counter.marko", 0, { - input: 0, - count: "1:6" - }); - _$._resume_branch($scope0_id); -}); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/cross-tag-closure/__snapshots__/dom.expected/tags/custom-tag.js b/packages/runtime-tags/src/__tests__/fixtures/cross-tag-closure/__snapshots__/dom.expected/tags/custom-tag.js deleted file mode 100644 index a4691b855..000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/cross-tag-closure/__snapshots__/dom.expected/tags/custom-tag.js +++ /dev/null @@ -1,8 +0,0 @@ -export const _template_ = "
"; -export const _walks_ = /* get, over(1) */" b"; -export const _setup_ = () => {}; -import * as _$ from "@marko/runtime-tags/debug/dom"; -export const _style_ = /* @__PURE__ */_$.value("style", (_scope, style) => _$.styleAttr(_scope["#div/0"], style)); -export const _input_ = /* @__PURE__ */_$.value("input", (_scope, input) => _style_(_scope, input.style)); -export const _params__ = /* @__PURE__ */_$.value("_params_", (_scope, _params_) => _input_(_scope, _params_[0])); -export default /* @__PURE__ */_$.createTemplate("__tests__/tags/custom-tag.marko", _template_, _walks_, _setup_, void 0, () => _params__); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/cross-tag-closure/__snapshots__/html.expected/tags/custom-tag.js b/packages/runtime-tags/src/__tests__/fixtures/cross-tag-closure/__snapshots__/html.expected/tags/custom-tag.js deleted file mode 100644 index d8eb5ab24..000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/cross-tag-closure/__snapshots__/html.expected/tags/custom-tag.js +++ /dev/null @@ -1,9 +0,0 @@ -import * as _$ from "@marko/runtime-tags/debug/html"; -const _renderer = /* @__PURE__ */_$.createRenderer((input, _tagVar) => { - const _scope0_id = _$._scope_id(); - const { - style - } = input; - _$._html(`
${_$.markResumeNode(_scope0_id, "#div/0")}`); -}); -export default /* @__PURE__ */_$.createTemplate("__tests__/tags/custom-tag.marko", _renderer); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/define-tag-render-stateful/__snapshots__/dom.expected/tags/your-tag.js b/packages/runtime-tags/src/__tests__/fixtures/define-tag-render-stateful/__snapshots__/dom.expected/tags/your-tag.js deleted file mode 100644 index e0e5cfce6..000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/define-tag-render-stateful/__snapshots__/dom.expected/tags/your-tag.js +++ /dev/null @@ -1,11 +0,0 @@ -export const $template = "
Hello
"; -export const $walks = /* next(1), over(1), replace, over(2), replace, out(1) */"Db%c%l"; -export const $setup = () => {}; -import * as _ from "@marko/runtime-tags/debug/dom"; -export const $input_name = /* @__PURE__ */_._const("input_name", ($scope, input_name) => _._text($scope["#text/0"], input_name)); -export const $input_count = /* @__PURE__ */_._const("input_count", ($scope, input_count) => _._text($scope["#text/1"], input_count)); -export const $input = /* @__PURE__ */_._const("input", ($scope, input) => { - $input_name($scope, input.name); - $input_count($scope, input.count); -}); -export default /* @__PURE__ */_._template("__tests__/tags/your-tag.marko", $template, $walks, $setup, $input); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/define-tag-render-stateful/__snapshots__/html.expected/__snapshots__/tags/your-tag.js b/packages/runtime-tags/src/__tests__/fixtures/define-tag-render-stateful/__snapshots__/html.expected/__snapshots__/tags/your-tag.js deleted file mode 100644 index f1c860047..000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/define-tag-render-stateful/__snapshots__/html.expected/__snapshots__/tags/your-tag.js +++ /dev/null @@ -1,7 +0,0 @@ -import * as _ from "@marko/runtime-tags/debug/html"; -export default _._template("__tests__/__snapshots__/tags/your-tag.marko", input => { - const $serialize = _._get_serialize_reason(); - const $scope0_id = _._scope_id(); - _._html(`
Hello ${_._sep(_._serialize_guard($serialize, /* input.name */1))}${_._escape(input.name)}${_._el_resume($scope0_id, "#text/0", _._serialize_guard($serialize, /* input.name */1))} ${_._sep(_._serialize_guard($serialize, /* input.count */2))}${_._escape(input.count)}${_._el_resume($scope0_id, "#text/1", _._serialize_guard($serialize, /* input.count */2))}
`); - _._serialize_guard($serialize, /* input.name,input.count */0) && _._scope($scope0_id, {}, "__tests__/__snapshots__/tags/your-tag.marko", 0); -}); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/define-tag-render-stateful/__snapshots__/html.expected/tags/your-tag.js b/packages/runtime-tags/src/__tests__/fixtures/define-tag-render-stateful/__snapshots__/html.expected/tags/your-tag.js deleted file mode 100644 index 02fd88422..000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/define-tag-render-stateful/__snapshots__/html.expected/tags/your-tag.js +++ /dev/null @@ -1,7 +0,0 @@ -import * as _ from "@marko/runtime-tags/debug/html"; -export default _._template("__tests__/tags/your-tag.marko", input => { - const $serialize = _._get_serialize_reason(); - const $scope0_id = _._scope_id(); - _._html(`
Hello ${_._sep(_._serialize_guard($serialize, /* input.name */1))}${_._escape(input.name)}${_._el_resume($scope0_id, "#text/0", _._serialize_guard($serialize, /* input.name */1))} ${_._sep(_._serialize_guard($serialize, /* input.count */2))}${_._escape(input.count)}${_._el_resume($scope0_id, "#text/1", _._serialize_guard($serialize, /* input.count */2))}
`); - _._serialize_guard($serialize, /* input.name,input.count */0) && _._scope($scope0_id, {}, "__tests__/tags/your-tag.marko", 0); -}); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/dynamic-tag-multiple/__snapshots__/html.expected/tags/skeleton-part.js b/packages/runtime-tags/src/__tests__/fixtures/dynamic-tag-multiple/__snapshots__/html.expected/tags/skeleton-part.js deleted file mode 100644 index 539922542..000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/dynamic-tag-multiple/__snapshots__/html.expected/tags/skeleton-part.js +++ /dev/null @@ -1,6 +0,0 @@ -import * as _$ from "@marko/runtime-tags/debug/html"; -export default _$.createTemplate("__tests__/tags/skeleton-part.marko", (input, $serialize) => { - const $scope0_id = _$._scope_id(); - _$._dynamic_tag($scope0_id, "#text/0", input.as || "div", {}, 0, 0, _$.serializeGuard($serialize, /* input.as */0)); - _$.serializeGuard($serialize, /* input.as */0) && _$._scope($scope0_id, {}, "__tests__/tags/skeleton-part.marko", 0); -}); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.hydrate.js index b801b096b..098d6f9f5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.hydrate.js @@ -1,3 +1,6 @@ -// size: 84 (min) 76 (brotli) +// size: 86 (min) 79 (brotli) const $output = _._let(2, ($scope) => _._text($scope.a, $scope.c)); -(_._script("a0", ($scope) => $output($scope, JSON.stringify(testLog))), init()); +(_._script("a0", ($scope) => { + $output($scope, JSON.stringify(testLog)); +}), + init()); diff --git a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.js index 752506c13..c64b1bd77 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.js @@ -5,7 +5,10 @@ const staticVar = "static var"; import * as _ from "@marko/runtime-tags/debug/dom"; const $tagVar = /* @__PURE__ */_._const("tagVar", $scope => console.log($scope.tagVar)); const $output = /* @__PURE__ */_._let("output/2", $scope => _._text($scope["#text/0"], $scope.output)); -const $setup__script = _._script("__tests__/template.marko_0", $scope => $output($scope, JSON.stringify(testLog))); +const $setup__script = _._script("__tests__/template.marko_0", $scope => { + debugger; + $output($scope, JSON.stringify(testLog)); +}); export function $setup($scope) { console.log("identifier"); console.log(staticVar); diff --git a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/resume-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/resume-sanitized.expected.md index 0161e2170..c7cc5c955 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/resume-sanitized.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/resume-sanitized.expected.md @@ -2,3 +2,9 @@ ```html {"identifier":true,"tag var":true,"static var":true} ``` + + +# Render ASYNC +```html +{"identifier":false,"tag var":false,"static var":false} +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/resume.expected.md index e72bcbe76..0c0c91bfb 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/resume.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/resume.expected.md @@ -18,3 +18,30 @@ ``` + + +# Render ASYNC +```html + + + + + {"identifier":false,"tag var":false,"static var":false} + + + + +``` + +# Mutations +``` +UPDATE html/body/#text "{\"identifier\":true,\"tag var\":true,\"static var\":true}" => "{\"identifier\":false,\"tag var\":false,\"static var\":false}" +``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/log-tag/template.marko b/packages/runtime-tags/src/__tests__/fixtures/log-tag/template.marko index a5831d236..909a03aed 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/log-tag/template.marko +++ b/packages/runtime-tags/src/__tests__/fixtures/log-tag/template.marko @@ -1,5 +1,4 @@ import testLog from "./test-log" - @@ -7,5 +6,5 @@ static const staticVar = "static var"; - + -- ${output} diff --git a/packages/runtime-tags/src/__tests__/fixtures/log-tag/test.ts b/packages/runtime-tags/src/__tests__/fixtures/log-tag/test.ts new file mode 100644 index 000000000..42c7eed77 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/log-tag/test.ts @@ -0,0 +1,5 @@ +import { wait } from "../../utils/resolve"; + +export const steps = [{}, wait(1)]; + +export const skip_equivalent = true; diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/resume.expected.md index ba9dd1218..60fad3546 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/resume.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/resume.expected.md @@ -32,8 +32,3 @@ ``` - -# Mutations -``` -INSERT html/body/#text4 -``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/ssr-sanitized.expected.md index 5488a6782..338a088a0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/ssr-sanitized.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/ssr-sanitized.expected.md @@ -1,4 +1,16 @@ -# Render End +# Render ASYNC +```html +a_A_e +``` + + +# Render ASYNC +```html +a_A_efg +``` + + +# Render ASYNC ```html abcdefg ``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/ssr.expected.md index 97ea8ca45..c35fdcb14 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/ssr.expected.md @@ -13,7 +13,103 @@ c ``` -# Render End +# Render ASYNC +```html + + + + + + a + + + _A_ + + + e + + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/#text0 +INSERT html/body/#comment0 +INSERT html/body/#comment1 +INSERT html/body/#text1 +INSERT html/body/#comment2 +INSERT html/body/#comment3 +INSERT html/body/#text2 +INSERT html/head/style +INSERT html/head/style/#text +INSERT t +INSERT t/#text0 +INSERT t/#comment +INSERT t/#text1 +REMOVE html/head/style after html/body/#text2 +INSERT html/head/style +REMOVE t after html/body/#text2 +INSERT html/body/script +``` + +# Render ASYNC +```html + + + + + + a + + + _A_ + + + e + + fg + + +``` + +# Mutations +``` +INSERT html/body/#text3 +``` + +# Render ASYNC ```html @@ -50,35 +146,12 @@ # Mutations ``` -INSERT html -INSERT html/head -INSERT html/body -INSERT html/body/#text0 -INSERT html/body/#comment0 -INSERT #comment -INSERT #text -INSERT #comment -INSERT html/body/#comment1 -INSERT html/body/#text4 -INSERT html/head/style -INSERT html/head/style/#text -INSERT t -INSERT html/body/#text1 -INSERT #comment -INSERT html/body/#text3 -INSERT html/body/script0 -INSERT html/body/script0/#text -REMOVE html/head/style after html/body/#text4 -INSERT html/head/style -REMOVE t after html/body/#text4 -INSERT html/body/#text5 INSERT t INSERT html/body/#text2 -INSERT html/body/script1 -INSERT html/body/script1/#text REMOVE t after html/body/#text5 REMOVE #text after #comment REMOVE #comment after html/body/#comment0 REMOVE #comment after html/body/#comment0 INSERT html/body/#text1, html/body/#text2, html/body/#text3 +INSERT html/body/script1 ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-skipped/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/placeholder-skipped/__snapshots__/ssr-sanitized.expected.md index 39e6ec137..1d3a0d1b9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholder-skipped/__snapshots__/ssr-sanitized.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-skipped/__snapshots__/ssr-sanitized.expected.md @@ -1,4 +1,10 @@ -# Render End +# Render ASYNC +```html +abc +``` + + +# Render ASYNC ```html abcde ``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-skipped/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/placeholder-skipped/__snapshots__/ssr.expected.md index c82e97a2c..270f639e7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholder-skipped/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-skipped/__snapshots__/ssr.expected.md @@ -8,7 +8,43 @@ de ``` -# Render End +# Render ASYNC +```html + + + + a + + b + + c + + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/#text0 +INSERT html/body/#comment0 +INSERT html/body/#text1 +INSERT html/body/#comment1 +INSERT html/body/#text2 +INSERT html/body/script +``` + +# Render ASYNC ```html @@ -34,15 +70,5 @@ # Mutations ``` -INSERT html -INSERT html/head -INSERT html/body -INSERT html/body/#text0 -INSERT html/body/#comment0 -INSERT html/body/#text1 -INSERT html/body/#comment1 -INSERT html/body/#text2 -INSERT html/body/script -INSERT html/body/script/#text INSERT html/body/#text3 ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/__snapshots__/resume.expected.md index bf83b150b..ce0d0de6f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/__snapshots__/resume.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/__snapshots__/resume.expected.md @@ -42,9 +42,3 @@ ``` - -# Mutations -``` -INSERT html/body/#text8 -INSERT html/body/#text7 -``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/__snapshots__/ssr-sanitized.expected.md index 2ad3c183c..cfc38bca8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/__snapshots__/ssr-sanitized.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/__snapshots__/ssr-sanitized.expected.md @@ -1,4 +1,22 @@ -# Render End +# Render ASYNC +```html +a_B_h +``` + + +# Render ASYNC +```html +a_B_hij +``` + + +# Render ASYNC +```html +abcd_A_hij +``` + + +# Render ASYNC ```html abcdefghij ``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/__snapshots__/ssr.expected.md index 78694b474..5b605a3f8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholders-nested/__snapshots__/ssr.expected.md @@ -18,7 +18,177 @@ f ``` -# Render End +# Render ASYNC +```html + + + + + + a + + + _B_ + + + h + + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/#text0 +INSERT html/body/#comment0 +INSERT html/body/#comment1 +INSERT html/body/#text1 +INSERT html/body/#comment2 +INSERT html/body/#comment3 +INSERT html/body/#text2 +INSERT html/head/style +INSERT html/head/style/#text +INSERT t +INSERT t/#text0 +INSERT t/#comment0 +INSERT t/#text1 +INSERT t/#comment1 +INSERT t/#comment2 +INSERT t/#text2 +INSERT t/#comment3 +INSERT t/#comment4 +INSERT t +INSERT t/#text0 +INSERT t/#comment +INSERT t/#text1 +REMOVE html/head/style after html/body/#text2 +INSERT html/head/style +REMOVE t after html/body/#text2 +REMOVE t after html/body/#text2 +INSERT html/body/script +``` + +# Render ASYNC +```html + + + + + + a + + + _B_ + + + h + + ij + + +``` + +# Mutations +``` +INSERT html/body/#text3 +``` + +# Render ASYNC +```html + + + + + + a + + bcd + + + _A_ + + + + h + + ij + + + +``` + +# Mutations +``` +INSERT t +INSERT html/body/#text2 +REMOVE t after html/body/#text6 +REMOVE #text after #comment +REMOVE #comment after html/body/#comment0 +REMOVE #comment after html/body/#comment0 +INSERT html/body/#text1, html/body/#text2, html/body/#text3, html/body/#comment1, html/body/#comment2, html/body/#text4, html/body/#comment3, html/body/#comment4 +INSERT html/body/script1 +``` + +# Render ASYNC ```html @@ -65,54 +235,12 @@ # Mutations ``` -INSERT html -INSERT html/head -INSERT html/body -INSERT html/body/#text0 -INSERT html/body/#comment0 -INSERT #comment -INSERT #text -INSERT #comment -INSERT html/body/#comment3 -INSERT html/body/#text7 -INSERT html/head/style -INSERT html/head/style/#text -INSERT t -INSERT html/body/#text1 -INSERT #comment -INSERT html/body/#text3 -INSERT html/body/#comment1 -INSERT #comment -INSERT #text -INSERT #comment -INSERT html/body/#comment2 -INSERT t -INSERT html/body/#text4 -INSERT #comment -INSERT html/body/#text6 -INSERT html/body/script0 -INSERT html/body/script0/#text -REMOVE html/head/style after html/body/#text7 -INSERT html/head/style -REMOVE t after html/body/#text7 -REMOVE t after html/body/#text7 -INSERT html/body/#text8 -INSERT t -INSERT html/body/#text2 -INSERT html/body/script1 -INSERT html/body/script1/#text -REMOVE t after html/body/#text8 -REMOVE #text after #comment -REMOVE #comment after html/body/#comment0 -REMOVE #comment after html/body/#comment0 -INSERT html/body/#text1, html/body/#text2, html/body/#text3, html/body/#comment1, #comment, #text, #comment, html/body/#comment2 INSERT t INSERT html/body/#text5 -INSERT html/body/script2 -INSERT html/body/script2/#text REMOVE t after html/body/script1 REMOVE #text after #comment REMOVE #comment after html/body/#comment1 REMOVE #comment after html/body/#comment1 INSERT html/body/#text4, html/body/#text5, html/body/#text6 +INSERT html/body/script2 ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/csr-sanitized.expected.1.md b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/csr-sanitized.expected.1.md deleted file mode 100644 index 2908cda78..000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/csr-sanitized.expected.1.md +++ /dev/null @@ -1,53 +0,0 @@ -# Render -```html - -
-``` - - -# Render ASYNC -```html - -
-LOADING... -``` - - -# Render ASYNC -```html - -
-Error: Element references can only be read in scripts and event handlers. -``` - - -# Render -```js -container.querySelector("button").click(); -``` -```html - -
-Error: Element references can only be read in scripts and event handlers. -``` - - -# Render -```js -container.querySelector("button").click(); -``` -```html - -
-Error: Element references can only be read in scripts and event handlers. -``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/dom.expected/template.hydrate.js index c433c9edb..2fe0c2d00 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/dom.expected/template.hydrate.js @@ -1,4 +1,4 @@ -// size: 516 (min) 289 (brotli) +// size: 514 (min) 296 (brotli) _._enable_catch(); const $await_content__value = _._const(2, ($scope) => _._text( @@ -26,9 +26,10 @@ const $try_content__await = _._await( 0, $await_content__$params, ), - $try_content__clickCount__script = _._script("a2", ($scope) => { - $scope._.b.textContent = $scope._.d; - }), + $try_content__clickCount__script = _._script( + "a2", + ($scope) => ($scope._.b.textContent = $scope._.d), + ), $try_content__clickCount = _._closure_get(3, ($scope) => { ($try_content__await($scope, resolveAfter($scope._.d, 1)), $try_content__clickCount__script($scope)); diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/dom.expected/template.js index 2ea1f2bf0..fab64ed1d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/dom.expected/template.js @@ -12,10 +12,7 @@ const $catch_content__$params = /* @__PURE__ */_._const("$params2", $scope => $c const $catch_content = _._content_resume("__tests__/template.marko_3_content", " ", /* get, over(1) */" b", 0, $catch_content__$params); const $placeholder_content = _._content_resume("__tests__/template.marko_2_content", "LOADING...", /* over(1) */"b"); const $try_content__await = /* @__PURE__ */_._await("#text/0", "Async: ", /* over(1), replace, over(1) */"b%b", 0, $await_content__$params); -const $try_content__clickCount__script = _._script("__tests__/template.marko_1_clickCount", $scope => { - debugger; - _._el_read($scope._["#div/1"]).textContent = $scope._.clickCount; -}); +const $try_content__clickCount__script = _._script("__tests__/template.marko_1_clickCount", $scope => (_._el_read($scope._["#div/1"]).textContent = $scope._.clickCount)); const $try_content__clickCount = /* @__PURE__ */_._closure_get("clickCount", $scope => { $try_content__await($scope, resolveAfter($scope._.clickCount, 1)); $try_content__clickCount__script($scope); diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/html.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/html.expected/template.js index a0036372c..00febd818 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/html.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/html.expected/template.js @@ -12,7 +12,7 @@ export default _._template("__tests__/template.marko", input => { _._html(`Async: ${_._escape(value > 1 ? (() => { throw new Error("ERROR!"); })() : value)}${_._el_resume($scope4_id, "#text/0")}`); - _._scope($scope4_id, {}, "__tests__/template.marko", "12:4"); + _._scope($scope4_id, {}, "__tests__/template.marko", "11:4"); }); _._script($scope1_id, "__tests__/template.marko_1_clickCount"); _._subscribe($clickCount__closures, _._scope($scope1_id, { @@ -26,7 +26,7 @@ export default _._template("__tests__/template.marko", input => { const $scope3_reason = _._scope_reason(); const $scope3_id = _._scope_id(); _._html(`${_._escape(err)}${_._el_resume($scope3_id, "#text/0", _._serialize_guard($scope3_reason, /* err */0))}`); - _._serialize_if($scope3_reason, /* err */0) && _._scope($scope3_id, {}, "__tests__/template.marko", "18:4"); + _._serialize_if($scope3_reason, /* err */0) && _._scope($scope3_id, {}, "__tests__/template.marko", "17:4"); }, $scope0_id) }), placeholder: _.attrTag({ diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/resume.expected.md index ddf532989..a98904674 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/resume.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/resume.expected.md @@ -62,12 +62,6 @@ ``` -# Mutations -``` -INSERT html/body/#text3 -INSERT html/body/#text2 -INSERT html/body/div/#text -``` # Render ```js diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/ssr-sanitized.expected.md index 32bbe96ec..b3c3d33b4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/ssr-sanitized.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/__snapshots__/ssr-sanitized.expected.md @@ -1,4 +1,14 @@ -# Render End +# Render ASYNC +```html + +
+LOADING... +``` + + +# Render ASYNC ```html + +
+ + + + + LOADING... + + + + + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/button +INSERT html/body/button/#text +INSERT html/body/#comment0 +INSERT html/body/div +INSERT html/body/#comment1 +INSERT html/body/#comment2 +INSERT html/body/#comment3 +INSERT html/body/#comment4 +INSERT html/body/#text +INSERT html/body/#comment5 +INSERT html/body/#comment6 +INSERT html/body/#comment7 +INSERT html/head/style +INSERT html/head/style/#text +INSERT t +INSERT t/#comment +REMOVE html/head/style after html/body/#comment7 +INSERT html/head/style +REMOVE t after html/body/#comment7 +INSERT html/body/script +``` + +# Render ASYNC ```html @@ -72,30 +153,6 @@ # Mutations ``` -INSERT html -INSERT html/head -INSERT html/body -INSERT html/body/button -INSERT html/body/button/#text -INSERT html/body/#comment0 -INSERT html/body/div -INSERT html/body/#comment1 -INSERT html/body/#comment2 -INSERT html/body/#comment3 -INSERT #comment -INSERT #text -INSERT #comment -INSERT html/body/#comment8 -INSERT html/body/#comment9 -INSERT html/head/style -INSERT html/head/style/#text -INSERT t -INSERT #comment -INSERT html/body/script0 -INSERT html/body/script0/#text -REMOVE html/head/style after html/body/#comment9 -INSERT html/head/style -REMOVE t after html/body/#comment9 INSERT t INSERT html/body/#comment4 INSERT html/body/#text0 @@ -103,11 +160,10 @@ INSERT html/body/#comment5 INSERT html/body/#text1 INSERT html/body/#comment6 INSERT html/body/#comment7 -INSERT html/body/script1 -INSERT html/body/script1/#text REMOVE t after html/body/script0 REMOVE #text after #comment REMOVE #comment after html/body/#comment3 REMOVE #comment after html/body/#comment3 INSERT html/body/#comment4, html/body/#text0, html/body/#comment5, html/body/#text1, html/body/#comment6, html/body/#comment7 +INSERT html/body/script1 ``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/template.marko b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/template.marko index 24d84906c..548c9d686 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/template.marko +++ b/packages/runtime-tags/src/__tests__/fixtures/try-effects-async/template.marko @@ -6,7 +6,6 @@ import { resolveAfter } from "../../utils/resolve";
diff --git a/packages/runtime-tags/src/__tests__/main.test.ts b/packages/runtime-tags/src/__tests__/main.test.ts index 7d521a1ae..40badba89 100644 --- a/packages/runtime-tags/src/__tests__/main.test.ts +++ b/packages/runtime-tags/src/__tests__/main.test.ts @@ -189,24 +189,41 @@ describe("runtime-tags/translator", () => { ); } }; - let ssr = () => { + + let serverRender = () => { const cached = (async () => { - const hooks: TestHooks = (() => { - try { - return require(resolve("hooks.ts")); - } catch { - return {}; - } - })(); - - hooks.before?.(); - const serverTemplate = require(manualSSR ? serverFile : templateFile) .default as Template; - let buffer = ""; - // let flushCount = 0; + const [input = {}, ...steps] = ( + typeof config.steps === "function" + ? await config.steps() + : config.steps || [] + ) as [Input, ...unknown[]]; + const chunks: string[] = []; + for await (const data of serverTemplate.render(input)) { + chunks.push(data); + } + + return { chunks, input, steps }; + })(); + serverRender = () => cached; + return cached; + }; + + const getHooks = ( + browser?: ReturnType, + ): TestHooks => { + try { + return (browser ? browser.require : require)(resolve("hooks.ts")); + } catch { + return {}; + } + }; + + let ssr = () => { + const cached = (async () => { const browser = createBrowser({ dir: __dirname, extensions: register({ @@ -215,27 +232,31 @@ describe("runtime-tags/translator", () => { extensions: {}, }), }); - const document = browser.window.document; - const [input = {}] = ( - typeof config.steps === "function" - ? await config.steps() - : config.steps || [] - ) as [Input]; + const { window } = browser; + const { document } = window; + const hooks = getHooks(); - document.open(); + hooks.before?.(); - const tracker = createMutationTracker(browser.window, document); + const { chunks } = await serverRender(); - for await (const data of serverTemplate.render(input)) { + const browserStream = browser.open(); + + const tracker = createMutationTracker(window, document); + + for (const data of chunks) { const formattedHtml = indent(stripInlineRuntime(data)); if (formattedHtml) { tracker.log(`# Write\n\`\`\`html\n${formattedHtml}\n\`\`\``); } - - buffer += data; + browserStream.write(data); } - document.write(buffer); - document.close(); + + const flushRemaining = browserStream.close(); + if (flushRemaining) { + await flushRemaining(); + } + tracker.logUpdate("End", true); tracker.cleanup(); @@ -258,13 +279,7 @@ describe("runtime-tags/translator", () => { }), }); - const hooks: TestHooks = (() => { - try { - return browser.require(resolve("hooks.ts")); - } catch { - return {}; - } - })(); + const hooks = getHooks(browser); hooks.before?.(); @@ -325,24 +340,48 @@ describe("runtime-tags/translator", () => { let resume = () => { const cached = (async () => { - const { browser } = await ssr(); + const browser = createBrowser({ + dir: __dirname, + extensions: register({ + ...domConfig, + modules: "cjs", + extensions: {}, + }), + }); const { window } = browser; const { document } = window; - const tracker = createMutationTracker(window, document); - const [input, ...steps] = - typeof config.steps === "function" - ? await config.steps() - : config.steps || []; + const serverHooks = getHooks(); + const browserHooks = getHooks(browser); - // TODO: when this is removed, the resume test will fail if run by itself... why? - await new Promise((resolve) => setTimeout(resolve, 10)); + serverHooks.before?.(); + browserHooks.before?.(); + + const { chunks, input, steps } = await serverRender(); const { run, init } = browser.require< typeof import("@marko/runtime-tags/dom") >("@marko/runtime-tags/dom"); browser.require(manualResume ? resumeFile : templateFile); - init(); + + const browserStream = browser.open(); + + let tracker: ReturnType; + + for (const data of chunks) { + browserStream.write(data); + } + + const flushRemaining = browserStream.close(); + if (flushRemaining) { + init(); + await flushRemaining(); + tracker = createMutationTracker(window, document); + } else { + tracker = createMutationTracker(window, document); + init(); + } + tracker.logUpdate(input); for (const update of steps) { @@ -363,6 +402,9 @@ describe("runtime-tags/translator", () => { tracker.cleanup(); + serverHooks.after?.(); + browserHooks.after?.(); + return { browser, tracker }; })(); resume = () => cached; diff --git a/packages/runtime-tags/src/__tests__/utils/create-browser.ts b/packages/runtime-tags/src/__tests__/utils/create-browser.ts index 2d2581415..030270c54 100644 --- a/packages/runtime-tags/src/__tests__/utils/create-browser.ts +++ b/packages/runtime-tags/src/__tests__/utils/create-browser.ts @@ -1,8 +1,15 @@ import type { DOMWindow } from "jsdom"; import { createBrowser } from "jsdom-context-require"; +import { resolveAfter } from "./resolve"; + export default function (options: Parameters[0]) { - const browser = createBrowser(options); + const browser = createBrowser(options) as ReturnType & { + open(): { + write(chunk: string): void; + close(): undefined | (() => Promise); + }; + }; const window = browser.window as unknown as DOMWindow & { MessageChannel: any; }; @@ -23,5 +30,69 @@ export default function (options: Parameters[0]) { } }; window.requestAnimationFrame = (fn) => window.setTimeout(fn) as any; + + browser.open = () => { + const doc = window.document; + let chunkCount = 0; + let buffer = ""; + + doc.open(); + + return { + write(chunk: string) { + if (buffer) { + buffer += ""; + } + buffer += chunk; + chunkCount++; + }, + close() { + if (chunkCount > 1) { + const parsed = doc.implementation.createHTMLDocument(); + parsed.write(buffer); + parsed.doctype?.remove(); + + const walker = parsed.createTreeWalker(parsed); + const targetNodes = new WeakMap([[parsed, doc]]); + let node: Node | null; + + function walkFlush() { + while ((node = walker.nextNode())) { + if ( + node.nodeType === 8 /* Node.COMMENT_NODE */ && + (node as Comment).data === "%%FLUSH%%" + ) { + return true; + } + + const isScript = (node as Element).tagName === "SCRIPT"; + const clone = doc.importNode(node, isScript); + targetNodes.set(node, clone); + (targetNodes.get(node.parentNode!) as ParentNode).appendChild( + clone, + ); + + if (isScript) { + walker.nextNode(); + } + } + doc.close(); + } + + if (walkFlush()) { + return async () => { + await resolveAfter(0, 1); + while (walkFlush()) { + await resolveAfter(0, 1); + } + }; + } + } + + doc.write(buffer); + doc.close(); + }, + }; + }; return browser; }