@httpland/compression-middleware 1.0.0-beta.2 → 1.1.0-beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/negotiation.js +1 -0
  3. package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/content_type.js +1 -0
  4. package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/extension.js +1 -0
  5. package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/extensions_by_type.js +1 -0
  6. package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/format_media_type.js +1 -0
  7. package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/get_charset.js +1 -0
  8. package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/parse_media_type.js +1 -0
  9. package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/type_by_extension.js +1 -0
  10. package/esm/deps.js +5 -4
  11. package/esm/utils.js +2 -0
  12. package/package.json +9 -7
  13. package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/negotiation.js +1 -0
  14. package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/content_type.js +2 -1
  15. package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/extension.js +2 -1
  16. package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/extensions_by_type.js +2 -1
  17. package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/format_media_type.js +2 -1
  18. package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/get_charset.js +2 -1
  19. package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/parse_media_type.js +2 -1
  20. package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/type_by_extension.js +2 -1
  21. package/script/deps.js +11 -10
  22. package/script/utils.js +2 -0
  23. package/types/deps.d.ts +5 -4
  24. package/types/utils.d.ts +1 -0
  25. /package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/_negotiation/common.js +0 -0
  26. /package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/_negotiation/encoding.js +0 -0
  27. /package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/_negotiation/language.js +0 -0
  28. /package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/_negotiation/media_type.js +0 -0
  29. /package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/_db.js +0 -0
  30. /package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/_util.js +0 -0
  31. /package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/mod.js +0 -0
  32. /package/esm/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/vendor/mime-db.v1.52.0.js +0 -0
  33. /package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/_negotiation/common.js +0 -0
  34. /package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/_negotiation/encoding.js +0 -0
  35. /package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/_negotiation/language.js +0 -0
  36. /package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/_negotiation/media_type.js +0 -0
  37. /package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/_db.js +0 -0
  38. /package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/_util.js +0 -0
  39. /package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/mod.js +0 -0
  40. /package/script/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/vendor/mime-db.v1.52.0.js +0 -0
  41. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/_negotiation/common.d.ts +0 -0
  42. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/_negotiation/encoding.d.ts +0 -0
  43. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/_negotiation/language.d.ts +0 -0
  44. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/_negotiation/media_type.d.ts +0 -0
  45. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/http/negotiation.d.ts +0 -0
  46. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/_db.d.ts +0 -0
  47. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/_util.d.ts +0 -0
  48. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/content_type.d.ts +0 -0
  49. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/extension.d.ts +0 -0
  50. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/extensions_by_type.d.ts +0 -0
  51. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/format_media_type.d.ts +0 -0
  52. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/get_charset.d.ts +0 -0
  53. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/mod.d.ts +0 -0
  54. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/parse_media_type.d.ts +0 -0
  55. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/type_by_extension.d.ts +0 -0
  56. /package/types/deps/deno.land/{std@0.180.0 → std@0.181.0}/media_types/vendor/mime-db.v1.52.0.d.ts +0 -0
package/README.md CHANGED
@@ -29,7 +29,7 @@ For a definition of Universal HTTP middleware, see the
29
29
  Middleware convert message body and adds the `Content-Encoding` header to the
30
30
  response.
31
31
 
32
- Also, safely add `Accept-Encoding` to the `vary` header in response.
32
+ Also, safely add `Accept-Encoding` to the `Vary` header in response.
33
33
 
34
34
  ```ts
35
35
  import { compression } from "https://deno.land/x/compression_middleware@$VERSION/mod.ts";
@@ -1,4 +1,5 @@
1
1
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
2
3
  /**
3
4
  * Contains the functions {@linkcode accepts}, {@linkcode acceptsEncodings}, and
4
5
  * {@linkcode acceptsLanguages} to provide content negotiation capabilities.
@@ -1,4 +1,5 @@
1
1
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
2
3
  import { parseMediaType } from "./parse_media_type.js";
3
4
  import { typeByExtension } from "./type_by_extension.js";
4
5
  import { getCharset } from "./get_charset.js";
@@ -1,4 +1,5 @@
1
1
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
2
3
  import { extensionsByType } from "./extensions_by_type.js";
3
4
  /**
4
5
  * For a given media type, return the most relevant extension, or `undefined`
@@ -1,4 +1,5 @@
1
1
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
2
3
  import { parseMediaType } from "./parse_media_type.js";
3
4
  import { extensions } from "./_util.js";
4
5
  export { extensions };
@@ -1,4 +1,5 @@
1
1
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
2
3
  import { isIterator, isToken, needsEncoding } from "./_util.js";
3
4
  /** Serializes the media type and the optional parameters as a media type
4
5
  * conforming to RFC 2045 and RFC 2616.
@@ -1,4 +1,5 @@
1
1
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
2
3
  import { parseMediaType } from "./parse_media_type.js";
3
4
  import { db } from "./_db.js";
4
5
  /**
@@ -1,4 +1,5 @@
1
1
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
2
3
  import { consumeMediaParam, decode2331Encoding } from "./_util.js";
3
4
  /**
4
5
  * Parses the media type and any optional parameters, per
@@ -1,4 +1,5 @@
1
1
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
2
3
  import { types } from "./_db.js";
3
4
  /**
4
5
  * Returns the media type associated with the file extension. Values are
package/esm/deps.js CHANGED
@@ -1,8 +1,9 @@
1
1
  // Copyright 2023-latest the httpland authors. All rights reserved. MIT license.
2
2
  // This module is browser compatible.
3
- export { CachingHeader, ContentNegotiationHeader, RepresentationHeader, } from "@httpland/http-utils";
4
- export { acceptsEncodings } from "./deps/deno.land/std@0.180.0/http/negotiation.js";
5
- export { parseMediaType } from "./deps/deno.land/std@0.180.0/media_types/mod.js";
6
- export { isIterable, isNull, } from "isxx";
3
+ export { CachingHeader, ContentNegotiationHeader, RepresentationHeader, } from "@httpland/http-utils/header.js";
4
+ export { acceptsEncodings } from "./deps/deno.land/std@0.181.0/http/negotiation.js";
5
+ export { parseMediaType } from "./deps/deno.land/std@0.181.0/media_types/mod.js";
6
+ export { isNull } from "@miyauci/isx/is_null";
7
+ export { isIterable } from "@miyauci/isx/is_iterable";
7
8
  export { default as compressible } from "compressible";
8
9
  export { vary } from "./deps/deno.land/x/vary@1.0.0/mod.js";
package/esm/utils.js CHANGED
@@ -1,10 +1,12 @@
1
1
  // Copyright 2023-latest the httpland authors. All rights reserved. MIT license.
2
2
  // This module is browser compatible.
3
3
  import { RepresentationHeader } from "./deps.js";
4
+ // TODO(miayuci): add strict parsing.
4
5
  const ReNoTransform = /(?:^|,)\s*?no-transform\s*?(?:,|$)/;
5
6
  export function isNoTransform(input) {
6
7
  return ReNoTransform.test(input);
7
8
  }
9
+ /** Return new `Response` if the response include `Content-Length` header and readable. */
8
10
  export async function reCalcContentLength(response) {
9
11
  if (response.bodyUsed ||
10
12
  !response.headers.has(RepresentationHeader.ContentLength))
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "./script/mod.js",
4
4
  "types": "./types/mod.d.ts",
5
5
  "name": "@httpland/compression-middleware",
6
- "version": "1.0.0-beta.2",
6
+ "version": "1.1.0-beta.1",
7
7
  "description": "HTTP compression middleware",
8
8
  "keywords": [
9
9
  "http",
@@ -34,6 +34,14 @@
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
+ "dependencies": {
38
+ "@httpland/http-middleware": "1.0.0",
39
+ "@httpland/http-utils": "1.0.0",
40
+ "@miyauci/isx": "1.1.1",
41
+ "compressible": "2.0.18",
42
+ "@types/compressible": "2.0.0",
43
+ "@types/node": "^18"
44
+ },
37
45
  "exports": {
38
46
  ".": {
39
47
  "import": {
@@ -45,11 +53,5 @@
45
53
  "default": "./script/mod.js"
46
54
  }
47
55
  }
48
- },
49
- "dependencies": {
50
- "@httpland/http-middleware": "1.0.0",
51
- "@httpland/http-utils": "1.0.0-beta.13",
52
- "compressible": "2.0.18",
53
- "isxx": "1.0.0-beta.24"
54
56
  }
55
57
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
3
4
  Object.defineProperty(exports, "__esModule", { value: true });
4
5
  exports.acceptsLanguages = exports.acceptsEncodings = exports.accepts = void 0;
5
6
  /**
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
5
  exports.contentType = void 0;
4
- // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
6
  const parse_media_type_js_1 = require("./parse_media_type.js");
6
7
  const type_by_extension_js_1 = require("./type_by_extension.js");
7
8
  const get_charset_js_1 = require("./get_charset.js");
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
5
  exports.extension = void 0;
4
- // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
6
  const extensions_by_type_js_1 = require("./extensions_by_type.js");
6
7
  /**
7
8
  * For a given media type, return the most relevant extension, or `undefined`
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
5
  exports.extensionsByType = exports.extensions = void 0;
4
- // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
6
  const parse_media_type_js_1 = require("./parse_media_type.js");
6
7
  const _util_js_1 = require("./_util.js");
7
8
  Object.defineProperty(exports, "extensions", { enumerable: true, get: function () { return _util_js_1.extensions; } });
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
5
  exports.formatMediaType = void 0;
4
- // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
6
  const _util_js_1 = require("./_util.js");
6
7
  /** Serializes the media type and the optional parameters as a media type
7
8
  * conforming to RFC 2045 and RFC 2616.
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
5
  exports.getCharset = void 0;
4
- // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
6
  const parse_media_type_js_1 = require("./parse_media_type.js");
6
7
  const _db_js_1 = require("./_db.js");
7
8
  /**
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
5
  exports.parseMediaType = void 0;
4
- // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
6
  const _util_js_1 = require("./_util.js");
6
7
  /**
7
8
  * Parses the media type and any optional parameters, per
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
5
  exports.typeByExtension = void 0;
4
- // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
6
  const _db_js_1 = require("./_db.js");
6
7
  /**
7
8
  * Returns the media type associated with the file extension. Values are
package/script/deps.js CHANGED
@@ -5,18 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  return (mod && mod.__esModule) ? mod : { "default": mod };
6
6
  };
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.vary = exports.compressible = exports.isNull = exports.isIterable = exports.parseMediaType = exports.acceptsEncodings = exports.RepresentationHeader = exports.ContentNegotiationHeader = exports.CachingHeader = void 0;
9
- var http_utils_1 = require("@httpland/http-utils");
10
- Object.defineProperty(exports, "CachingHeader", { enumerable: true, get: function () { return http_utils_1.CachingHeader; } });
11
- Object.defineProperty(exports, "ContentNegotiationHeader", { enumerable: true, get: function () { return http_utils_1.ContentNegotiationHeader; } });
12
- Object.defineProperty(exports, "RepresentationHeader", { enumerable: true, get: function () { return http_utils_1.RepresentationHeader; } });
13
- var negotiation_js_1 = require("./deps/deno.land/std@0.180.0/http/negotiation.js");
8
+ exports.vary = exports.compressible = exports.isIterable = exports.isNull = exports.parseMediaType = exports.acceptsEncodings = exports.RepresentationHeader = exports.ContentNegotiationHeader = exports.CachingHeader = void 0;
9
+ var header_js_1 = require("@httpland/http-utils/header.js");
10
+ Object.defineProperty(exports, "CachingHeader", { enumerable: true, get: function () { return header_js_1.CachingHeader; } });
11
+ Object.defineProperty(exports, "ContentNegotiationHeader", { enumerable: true, get: function () { return header_js_1.ContentNegotiationHeader; } });
12
+ Object.defineProperty(exports, "RepresentationHeader", { enumerable: true, get: function () { return header_js_1.RepresentationHeader; } });
13
+ var negotiation_js_1 = require("./deps/deno.land/std@0.181.0/http/negotiation.js");
14
14
  Object.defineProperty(exports, "acceptsEncodings", { enumerable: true, get: function () { return negotiation_js_1.acceptsEncodings; } });
15
- var mod_js_1 = require("./deps/deno.land/std@0.180.0/media_types/mod.js");
15
+ var mod_js_1 = require("./deps/deno.land/std@0.181.0/media_types/mod.js");
16
16
  Object.defineProperty(exports, "parseMediaType", { enumerable: true, get: function () { return mod_js_1.parseMediaType; } });
17
- var isxx_1 = require("isxx");
18
- Object.defineProperty(exports, "isIterable", { enumerable: true, get: function () { return isxx_1.isIterable; } });
19
- Object.defineProperty(exports, "isNull", { enumerable: true, get: function () { return isxx_1.isNull; } });
17
+ var is_null_1 = require("@miyauci/isx/is_null");
18
+ Object.defineProperty(exports, "isNull", { enumerable: true, get: function () { return is_null_1.isNull; } });
19
+ var is_iterable_1 = require("@miyauci/isx/is_iterable");
20
+ Object.defineProperty(exports, "isIterable", { enumerable: true, get: function () { return is_iterable_1.isIterable; } });
20
21
  var compressible_1 = require("compressible");
21
22
  Object.defineProperty(exports, "compressible", { enumerable: true, get: function () { return __importDefault(compressible_1).default; } });
22
23
  var mod_js_2 = require("./deps/deno.land/x/vary@1.0.0/mod.js");
package/script/utils.js CHANGED
@@ -4,11 +4,13 @@
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.reCalcContentLength = exports.isNoTransform = void 0;
6
6
  const deps_js_1 = require("./deps.js");
7
+ // TODO(miayuci): add strict parsing.
7
8
  const ReNoTransform = /(?:^|,)\s*?no-transform\s*?(?:,|$)/;
8
9
  function isNoTransform(input) {
9
10
  return ReNoTransform.test(input);
10
11
  }
11
12
  exports.isNoTransform = isNoTransform;
13
+ /** Return new `Response` if the response include `Content-Length` header and readable. */
12
14
  async function reCalcContentLength(response) {
13
15
  if (response.bodyUsed ||
14
16
  !response.headers.has(deps_js_1.RepresentationHeader.ContentLength))
package/types/deps.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export { type Handler, type Middleware, } from "@httpland/http-middleware";
2
- export { CachingHeader, ContentNegotiationHeader, RepresentationHeader, } from "@httpland/http-utils";
3
- export { acceptsEncodings } from "./deps/deno.land/std@0.180.0/http/negotiation.js";
4
- export { parseMediaType } from "./deps/deno.land/std@0.180.0/media_types/mod.js";
5
- export { isIterable, isNull, } from "isxx";
2
+ export { CachingHeader, ContentNegotiationHeader, RepresentationHeader, } from "@httpland/http-utils/header.js";
3
+ export { acceptsEncodings } from "./deps/deno.land/std@0.181.0/http/negotiation.js";
4
+ export { parseMediaType } from "./deps/deno.land/std@0.181.0/media_types/mod.js";
5
+ export { isNull } from "@miyauci/isx/is_null";
6
+ export { isIterable } from "@miyauci/isx/is_iterable";
6
7
  export { default as compressible } from "compressible";
7
8
  export { vary } from "./deps/deno.land/x/vary@1.0.0/mod.js";
package/types/utils.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export declare function isNoTransform(input: string): boolean;
2
+ /** Return new `Response` if the response include `Content-Length` header and readable. */
2
3
  export declare function reCalcContentLength(response: Response): Promise<Response>;