@torpor/build 0.1.33 → 0.1.34
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/CHANGELOG.md +8 -0
- package/package.json +3 -3
- package/src/site/clientEntry.ts +21 -25
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@torpor/build",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"description": "A framework for building sites and apps with Torpor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"dotenv": "^16.5.0",
|
|
56
56
|
"vite": "^7.0.0",
|
|
57
57
|
"vite-tsconfig-paths": "^5.1.4",
|
|
58
|
-
"@torpor/
|
|
59
|
-
"@torpor/
|
|
58
|
+
"@torpor/unplugin": "^0.1.16",
|
|
59
|
+
"@torpor/view": "^0.1.11"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
package/src/site/clientEntry.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import manifest from "@torpor/build/manifest";
|
|
2
2
|
// @ts-ignore This errors in the Cloudflare build?
|
|
3
3
|
import { $page } from "@torpor/build/state";
|
|
4
|
-
import { clearLayoutSlot,
|
|
4
|
+
import { clearLayoutSlot, fillLayoutSlot, hydrate } from "@torpor/view";
|
|
5
5
|
import { type Component, type SlotRender } from "@torpor/view";
|
|
6
6
|
import { mount } from "@torpor/view";
|
|
7
7
|
import type PageEndPoint from "../types/PageEndPoint.ts";
|
|
@@ -161,17 +161,15 @@ async function navigate(url: URL, firstTime = false): Promise<boolean> {
|
|
|
161
161
|
let slotFunctions: SlotRender[] = [];
|
|
162
162
|
// The last slot function will render the client component
|
|
163
163
|
slotFunctions[handler.layouts.length] = function clientComponent(parent, anchor, _, $context) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
);
|
|
174
|
-
}
|
|
164
|
+
let i = layoutStack.length - 1;
|
|
165
|
+
layoutStack[i].slotRange = fillLayoutSlot(
|
|
166
|
+
clientEndPoint.component!,
|
|
167
|
+
slotFunctions[i + 1],
|
|
168
|
+
parent,
|
|
169
|
+
anchor,
|
|
170
|
+
$props,
|
|
171
|
+
$context,
|
|
172
|
+
);
|
|
175
173
|
};
|
|
176
174
|
|
|
177
175
|
// Each earlier slot function will render a layout
|
|
@@ -192,16 +190,14 @@ async function navigate(url: URL, firstTime = false): Promise<boolean> {
|
|
|
192
190
|
slots = { _: slotFunctions[i + 1] };
|
|
193
191
|
} else {
|
|
194
192
|
slotFunctions[i] = function layoutComponent(parent, anchor, _, $context) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
);
|
|
204
|
-
}
|
|
193
|
+
layoutStack[i - 1].slotRange = fillLayoutSlot(
|
|
194
|
+
layoutEndPoint.component!,
|
|
195
|
+
slotFunctions[i + 1],
|
|
196
|
+
parent,
|
|
197
|
+
anchor,
|
|
198
|
+
$props,
|
|
199
|
+
$context,
|
|
200
|
+
);
|
|
205
201
|
};
|
|
206
202
|
}
|
|
207
203
|
}
|
|
@@ -239,6 +235,9 @@ async function loadData(
|
|
|
239
235
|
if (handler.layouts) {
|
|
240
236
|
for (let [i, layout] of handler.layouts.entries()) {
|
|
241
237
|
let layoutPath = layout.path;
|
|
238
|
+
for (let key in params) {
|
|
239
|
+
layoutPath = layoutPath.replace(`[${key}]`, params[key]);
|
|
240
|
+
}
|
|
242
241
|
if (layoutStack.at(i)?.path === layoutPath) {
|
|
243
242
|
// We've already loaded this layout, we can just re-use its data and UI
|
|
244
243
|
if (!prefetch) {
|
|
@@ -248,9 +247,6 @@ async function loadData(
|
|
|
248
247
|
Object.assign(data, layoutStack[i].data);
|
|
249
248
|
} else {
|
|
250
249
|
const stackLayout = { path: layoutPath, data: {}, reuse: false, slotRange: null };
|
|
251
|
-
for (let key in params) {
|
|
252
|
-
layoutPath = layoutPath.replace(`[${key}]`, params[key]);
|
|
253
|
-
}
|
|
254
250
|
const layoutEndPoint: PageEndPoint | undefined = (await layout.endPoint())?.default;
|
|
255
251
|
const layoutServerEndPoint: PageServerEndPoint | undefined =
|
|
256
252
|
layout.serverEndPoint && (await layout.serverEndPoint())?.default;
|