htmx-router 2.1.1 → 2.1.3

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/dist/cli/index.js CHANGED
File without changes
@@ -65,7 +65,7 @@ export class HtmxRouterServer {
65
65
  return;
66
66
  }
67
67
  async transform(ctx, res) {
68
- if (this.#binding.transform.length < 0)
68
+ if (this.#binding.transform.length < 1)
69
69
  return res;
70
70
  ctx.timer.checkpoint("transform");
71
71
  for (const process of this.#binding.transform) {
package/dist/response.js CHANGED
@@ -97,6 +97,7 @@ export function refresh(init) {
97
97
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/ETag | ETag - MDN Web Docs }
98
98
  */
99
99
  export function AssertETagStale(request, headers, etag, options) {
100
+ headers.delete("Cache-Control"); // clear any defaults
100
101
  if (options) {
101
102
  // default to private, because it's the slightly less worse of the two potential foot guns
102
103
  if (options.public)
@@ -107,7 +108,7 @@ export function AssertETagStale(request, headers, etag, options) {
107
108
  headers.append("Cache-Control", `max-age=${options.revalidate}`);
108
109
  }
109
110
  headers.append("Cache-Control", "must-revalidate");
110
- headers.set("ETag", `"${etag}"`);
111
+ headers.set("ETag", `"${encodeURIComponent(etag.trim())}"`);
111
112
  const client = request.headers.get("if-none-match");
112
113
  if (client !== etag)
113
114
  return;
package/dist/router.js CHANGED
@@ -189,7 +189,6 @@ class RouteLeaf {
189
189
  return null;
190
190
  if (jsx instanceof Response)
191
191
  return jsx;
192
- ctx.timer.checkpoint("render");
193
192
  const res = ctx.render(jsx);
194
193
  return html(res, { headers: ctx.headers });
195
194
  }
@@ -200,10 +199,8 @@ class RouteLeaf {
200
199
  let caught;
201
200
  if (jsx instanceof Response)
202
201
  caught = jsx;
203
- else {
204
- ctx.timer.checkpoint("render");
202
+ else
205
203
  caught = ctx.render(jsx);
206
- }
207
204
  if (caught instanceof Response) {
208
205
  caught.headers.set("X-Caught", "true");
209
206
  return caught;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "htmx-router",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "A lightweight SSR framework with server+client islands",
5
5
  "keywords": [ "htmx", "router", "client islands", "ssr", "vite" ],
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "build": "tsc"
9
9
  },
10
- "main": "./index.js",
10
+ "main": "./dist/index.js",
11
11
  "exports": {
12
12
  ".": "./dist/index.js",
13
13
  "./cookies": "./dist/cookies.js",
@@ -30,7 +30,7 @@
30
30
  "./internal/mount": "./dist/internal/mount.js"
31
31
  },
32
32
  "bin": {
33
- "htmx-router": "cli/index.js"
33
+ "htmx-router": "dist/cli/index.js"
34
34
  },
35
35
  "repository": {
36
36
  "type": "git",