From 4473bc84f242a73ff393eb1ea8da98ae99c2dd40 Mon Sep 17 00:00:00 2001 From: Bill Min Date: Thu, 28 Sep 2023 16:38:09 -0400 Subject: [PATCH] feat: allow slot reorder after first chunk (#26) * feat: allow slot reorder after first chunk --- .../micro-frame-slot/marko-tag.json | 3 +- src/components/micro-frame-sse/README.md | 8 ++ .../renders.expected/loading.0.html | 16 ++++ .../renders.expected/loading.1.html | 44 +++++++++++ .../renders.expected/loading.2.html | 40 ++++++++++ .../renders.expected/loading.3.html | 54 ++++++++++++++ .../renders.expected/loading.4.html | 50 +++++++++++++ .../renders.expected/loading.5.html | 74 +++++++++++++++++++ .../renders.expected/loading.6.html | 60 +++++++++++++++ .../ssr-reorder-after-first-chunk/embed.marko | 25 +++++++ .../ssr-reorder-after-first-chunk/index.marko | 20 +++++ .../ssr-reorder-after-first-chunk/slot_1.html | 1 + .../ssr-reorder-after-first-chunk/slot_2.html | 1 + .../micro-frame-sse/__tests__/server.test.ts | 5 ++ .../micro-frame-slot-component/node.marko | 6 +- 15 files changed, 402 insertions(+), 5 deletions(-) create mode 100644 src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.0.html create mode 100644 src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.1.html create mode 100644 src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.2.html create mode 100644 src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.3.html create mode 100644 src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.4.html create mode 100644 src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.5.html create mode 100644 src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.6.html create mode 100644 src/components/micro-frame-sse/__tests__/fixtures/ssr-reorder-after-first-chunk/embed.marko create mode 100644 src/components/micro-frame-sse/__tests__/fixtures/ssr-reorder-after-first-chunk/index.marko create mode 100644 src/components/micro-frame-sse/__tests__/fixtures/ssr-reorder-after-first-chunk/slot_1.html create mode 100644 src/components/micro-frame-sse/__tests__/fixtures/ssr-reorder-after-first-chunk/slot_2.html diff --git a/src/components/micro-frame-slot/marko-tag.json b/src/components/micro-frame-slot/marko-tag.json index e259d7f..ce5d990 100644 --- a/src/components/micro-frame-slot/marko-tag.json +++ b/src/components/micro-frame-slot/marko-tag.json @@ -17,10 +17,9 @@ ] }, "@client-reorder": { - "type": "boolean", "autocomplete": [ { - "description": "See client-reorder in ", + "description": "See client-reorder in . Also support additional 'after-first-chunk' value.", "descriptionMoreURL": "https://markojs.com/docs/core-tags/#await" } ] diff --git a/src/components/micro-frame-sse/README.md b/src/components/micro-frame-sse/README.md index baa8aeb..c2c6d71 100644 --- a/src/components/micro-frame-sse/README.md +++ b/src/components/micro-frame-sse/README.md @@ -189,6 +189,14 @@ Flag indicate if the slot need to be streamed out-of-order. Please refer to [cli ``` +### `client-reorder="after-first-chunk"` + +There is an additional value supported here which is `after-first-chunk`. When set, the slot will be rendered in-order before first chunk and will convert to out-of-order while streaming. This is useful when loading indicator is controlled inside stream. + +```marko + +``` + ## `timeout` in slot A timeout in `ms` (defaults to 30s) that will prematurely abort the slot. This will trigger the `<@catch>` if provided. diff --git a/src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.0.html b/src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.0.html new file mode 100644 index 0000000..fa43e92 --- /dev/null +++ b/src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.0.html @@ -0,0 +1,16 @@ +
+ Host app +
+
+
+
\ No newline at end of file diff --git a/src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.1.html b/src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.1.html new file mode 100644 index 0000000..09091ab --- /dev/null +++ b/src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.1.html @@ -0,0 +1,44 @@ +
+ Host app +
+
+
+
+

+ test_html for slot_1 +

+
+
+
+non-reorder data + + \ No newline at end of file diff --git a/src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.2.html b/src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.2.html new file mode 100644 index 0000000..085f796 --- /dev/null +++ b/src/components/micro-frame-sse/__tests__/__snapshots__/micro-frame-sse/ssr-reorder-after-first-chunk/renders.expected/loading.2.html @@ -0,0 +1,40 @@ +
+ Host app +
+
+
+
+

+ test_html for slot_1 +

+
+
+
+non-reorder data +