Skip to content

Commit 51288c0

Browse files
committed
fix(): collect processors from route context
1 parent 2c7d021 commit 51288c0

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

packages/runtime/src/internal/Renderer.spec.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,16 @@ describe("renderRoutes", () => {
184184
const rendererContext = new RendererContext("page");
185185
const route = {
186186
path: "${APP.homepage}/:objectId",
187-
context: [{ name: "objectId", value: "<% PATH.objectId %>" }],
187+
context: [
188+
{ name: "objectId", value: "<% PATH.objectId %>" },
189+
{
190+
name: "fromProcessor",
191+
onChange: {
192+
action: "console.log",
193+
args: ["<% PROCESSORS.route.context() %>"],
194+
},
195+
},
196+
],
188197
bricks: [{ brick: "div" }],
189198
menu: {
190199
menuId: "my-menu",
@@ -227,6 +236,12 @@ describe("renderRoutes", () => {
227236
);
228237
expect(runtimeContext.pendingPermissionsPreCheck.length).toBe(2);
229238
expect(loadBricksImperatively).toBeCalledWith(["my-pre-load-brick"], []);
239+
expect(loadProcessorsImperatively).toBeCalledTimes(1);
240+
expect(loadProcessorsImperatively).toHaveBeenNthCalledWith(
241+
1,
242+
new Set(["route.context"]),
243+
[]
244+
);
230245
await ctxStore.waitForAll();
231246
expect(ctxStore.getValue("objectId")).toBe("HOST");
232247
});

packages/runtime/src/internal/Renderer.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,22 @@ export async function renderRoutes(
189189
rendererContext.memoizeMenuRequestNode(routes, menuRequestNode);
190190
}
191191

192+
const usedProcessors = strictCollectMemberUsage(
193+
route.context,
194+
"PROCESSORS",
195+
2
196+
);
197+
if (usedProcessors.size > 0) {
198+
output.blockingList.push(
199+
catchLoad(
200+
loadProcessorsImperatively(usedProcessors, getBrickPackages()),
201+
"processors",
202+
[...usedProcessors].join(", "),
203+
rendererContext.unknownBricks
204+
)
205+
);
206+
}
207+
192208
let newOutput: RenderOutput;
193209
if (route.type === "routes") {
194210
newOutput = await renderRoutes(

0 commit comments

Comments
 (0)