@torpor/build 0.1.32 → 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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @torpor/build
2
2
 
3
+ ## 0.1.34
4
+
5
+ ### Patch Changes
6
+
7
+ - 1221923: Fix: updating layouts in [parameter] routes
8
+ - Updated dependencies [741a289]
9
+ - @torpor/view@0.1.11
10
+
11
+ ## 0.1.33
12
+
13
+ ### Patch Changes
14
+
15
+ - 74bf42d: Fix: store (and clear) the right layout slot ranges
16
+ - Updated dependencies [74bf42d]
17
+ - @torpor/view@0.1.10
18
+
3
19
  ## 0.1.32
4
20
 
5
21
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torpor/build",
3
- "version": "0.1.32",
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/view": "^0.1.6",
59
- "@torpor/unplugin": "^0.1.16"
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",
@@ -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, hydrate, runLayoutSlot } from "@torpor/view";
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
- if (clientEndPoint.component) {
165
- let i = layoutStack.length - 1;
166
- layoutStack[i].slotRange = runLayoutSlot(
167
- clientEndPoint.component,
168
- slotFunctions[i + 1],
169
- parent,
170
- anchor,
171
- $props,
172
- $context,
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
- if (layoutEndPoint.component) {
196
- layoutStack[i].slotRange = runLayoutSlot(
197
- layoutEndPoint.component,
198
- slotFunctions[i + 1],
199
- parent,
200
- anchor,
201
- $props,
202
- $context,
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;
@@ -291,10 +287,8 @@ async function loadClientAndServerData(
291
287
  ): Promise<Response | void> {
292
288
  if (clientEndPoint?.load) {
293
289
  if (prefetchedData[location]) {
294
- //console.log("CLIENT DATA ALREADY LOADED", location);
295
290
  Object.assign(data, prefetchedData[location]);
296
291
  } else {
297
- //console.log("CLIENT DATA LOADING", location);
298
292
  const clientUrl = new URL(document.location.href);
299
293
  const clientParams = buildClientParams(clientUrl, params, data);
300
294
  const clientResponse = await clientEndPoint.load(clientParams);
@@ -315,10 +309,8 @@ async function loadClientAndServerData(
315
309
  const serverUrl = location.replace(/\/$/, "") + "/~server";
316
310
 
317
311
  if (prefetchedData[serverUrl]) {
318
- //console.log("SERVER DATA ALREADY LOADED", serverUrl);
319
312
  Object.assign(data, prefetchedData[serverUrl]);
320
313
  } else {
321
- //console.log("SERVER DATA LOADING", serverUrl);
322
314
  const serverResponse = await fetch(serverUrl);
323
315
  if (serverResponse) {
324
316
  if (serverResponse.ok) {