@stacksjs/stx 0.2.169 → 0.2.170

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.
@@ -9,11 +9,16 @@ const COMPRESSIBLE = [
9
9
  "application/atom+xml",
10
10
  "application/manifest+json",
11
11
  "image/svg+xml"
12
+ ], NEVER_BUFFER = [
13
+ "text/event-stream",
14
+ "multipart/x-mixed-replace"
12
15
  ], MIN_BYTES = 1024;
13
16
  export function isCompressible(contentType) {
14
17
  if (!contentType)
15
18
  return !1;
16
19
  const type = contentType.toLowerCase();
20
+ if (NEVER_BUFFER.some((prefix) => type.startsWith(prefix)))
21
+ return !1;
17
22
  return COMPRESSIBLE.some((prefix) => type.startsWith(prefix));
18
23
  }
19
24
  export function negotiateEncoding(acceptEncoding) {
package/dist/index.d.ts CHANGED
@@ -129,6 +129,7 @@ export * from './custom-directives';
129
129
  // database moved to stx/database
130
130
  export * from './defer';
131
131
  export * from './deploy/index';
132
+ export * from './compression';
132
133
  export * from './dev-server';
133
134
  export * from './document-shell';
134
135
  export * from './fragment-container';
package/dist/index.js CHANGED
@@ -55,6 +55,7 @@ export * from "./csp.js";
55
55
  export * from "./custom-directives.js";
56
56
  export * from "./defer.js";
57
57
  export * from "./deploy/index.js";
58
+ export * from "./compression.js";
58
59
  export * from "./dev-server.js";
59
60
  export * from "./document-shell.js";
60
61
  export * from "./fragment-container.js";
package/dist/serve.js CHANGED
@@ -5,6 +5,7 @@ import { findSfcTemplateBlock } from "./sfc-template.js";
5
5
  import { readMarkdownFile } from "./assets.js";
6
6
  import { processDirectives } from "./process.js";
7
7
  import { extractVariables } from "./utils.js";
8
+ import { compressResponse } from "./compression.js";
8
9
  export function htmlResponse(html, status = 200, headers = {}) {
9
10
  return new Response(html, {
10
11
  status,
@@ -157,7 +158,7 @@ ${error instanceof Error ? error.stack : ""}</pre>` : "<h1>Internal Server Error
157
158
  }
158
159
  const server = bunServe({
159
160
  port,
160
- fetch: handleRequest
161
+ fetch: async (request) => compressResponse(request, await handleRequest(request))
161
162
  });
162
163
  let watcher = null;
163
164
  if (watch)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.169",
4
+ "version": "0.2.170",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -117,12 +117,12 @@
117
117
  "dependencies": {
118
118
  "@cwcss/crosswind": "^0.2.14",
119
119
  "@stacksjs/clapp": "^0.2.0",
120
- "@stacksjs/desktop": "0.2.169",
121
- "@stacksjs/sanitizer": "0.2.169",
120
+ "@stacksjs/desktop": "0.2.170",
121
+ "@stacksjs/sanitizer": "0.2.170",
122
122
  "@stacksjs/ts-i18n": "^0.1.11",
123
- "bun-plugin-stx": "0.2.169",
123
+ "bun-plugin-stx": "0.2.170",
124
124
  "bunfig": "^0.15.17",
125
- "stx-router": "0.2.169",
125
+ "stx-router": "0.2.170",
126
126
  "ts-broadcasting": "^0.0.9",
127
127
  "ts-images": "^0.1.9",
128
128
  "ts-syntax-highlighter": "^0.2.1"