@mtkruto/node 0.1.124 → 0.1.125

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.
Files changed (97) hide show
  1. package/esm/0_deps.d.ts +1 -0
  2. package/esm/0_deps.js +1 -0
  3. package/esm/1_utilities.d.ts +1 -1
  4. package/esm/1_utilities.js +1 -1
  5. package/esm/4_constants.d.ts +1 -1
  6. package/esm/4_constants.js +1 -1
  7. package/esm/client/1_client_abstract.d.ts +1 -1
  8. package/esm/client/3_types.d.ts +56 -0
  9. package/esm/client/5_client.d.ts +17 -1
  10. package/esm/client/5_client.js +152 -49
  11. package/esm/connection/0_connection.d.ts +4 -0
  12. package/esm/connection/0_connection.js +6 -0
  13. package/esm/deps/deno.land/std@0.208.0/media_types/_db.d.ts +5 -0
  14. package/esm/deps/deno.land/std@0.208.0/media_types/_db.js +33 -0
  15. package/esm/deps/deno.land/std@0.208.0/media_types/_util.d.ts +21 -0
  16. package/esm/deps/deno.land/std@0.208.0/media_types/_util.js +122 -0
  17. package/esm/deps/deno.land/std@0.208.0/media_types/content_type.d.ts +38 -0
  18. package/esm/deps/deno.land/std@0.208.0/media_types/content_type.js +60 -0
  19. package/esm/deps/deno.land/std@0.208.0/media_types/format_media_type.d.ts +16 -0
  20. package/esm/deps/deno.land/std@0.208.0/media_types/format_media_type.js +61 -0
  21. package/esm/deps/deno.land/std@0.208.0/media_types/get_charset.d.ts +15 -0
  22. package/esm/deps/deno.land/std@0.208.0/media_types/get_charset.js +37 -0
  23. package/esm/deps/deno.land/std@0.208.0/media_types/parse_media_type.d.ts +37 -0
  24. package/esm/deps/deno.land/std@0.208.0/media_types/parse_media_type.js +122 -0
  25. package/esm/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.d.ts +8518 -0
  26. package/esm/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.js +8555 -0
  27. package/esm/storage/0_storage.d.ts +1 -0
  28. package/esm/storage/1_storage_indexed_db.d.ts +4 -3
  29. package/esm/storage/1_storage_indexed_db.js +17 -8
  30. package/esm/storage/1_storage_local_storage.d.ts +2 -2
  31. package/esm/storage/1_storage_local_storage.js +3 -0
  32. package/esm/storage/1_storage_memory.d.ts +1 -0
  33. package/esm/storage/1_storage_memory.js +3 -0
  34. package/esm/storage/1_storage_session_storage.d.ts +1 -0
  35. package/esm/storage/1_storage_session_storage.js +3 -0
  36. package/esm/transport/0_transport.d.ts +1 -1
  37. package/esm/transport/0_transport.js +0 -6
  38. package/esm/transport/1_transport_abridged.d.ts +1 -0
  39. package/esm/transport/1_transport_abridged.js +9 -5
  40. package/esm/transport/1_transport_intermediate.d.ts +1 -0
  41. package/esm/transport/1_transport_intermediate.js +8 -4
  42. package/esm/types/1_chat.d.ts +2 -15
  43. package/esm/types/1_chat.js +3 -14
  44. package/esm/types/1_user.js +4 -2
  45. package/esm/types/3_message.d.ts +2 -2
  46. package/esm/types/3_message.js +6 -6
  47. package/esm/utilities/{0_base64.js → 1_base64.js} +2 -1
  48. package/package.json +1 -1
  49. package/script/0_deps.d.ts +1 -0
  50. package/script/0_deps.js +3 -1
  51. package/script/1_utilities.d.ts +1 -1
  52. package/script/1_utilities.js +1 -1
  53. package/script/4_constants.d.ts +1 -1
  54. package/script/4_constants.js +1 -1
  55. package/script/client/1_client_abstract.d.ts +1 -1
  56. package/script/client/3_types.d.ts +56 -0
  57. package/script/client/5_client.d.ts +17 -1
  58. package/script/client/5_client.js +151 -48
  59. package/script/connection/0_connection.d.ts +4 -0
  60. package/script/connection/0_connection.js +6 -0
  61. package/script/deps/deno.land/std@0.208.0/media_types/_db.d.ts +5 -0
  62. package/script/deps/deno.land/std@0.208.0/media_types/_db.js +39 -0
  63. package/script/deps/deno.land/std@0.208.0/media_types/_util.d.ts +21 -0
  64. package/script/deps/deno.land/std@0.208.0/media_types/_util.js +132 -0
  65. package/script/deps/deno.land/std@0.208.0/media_types/content_type.d.ts +38 -0
  66. package/script/deps/deno.land/std@0.208.0/media_types/content_type.js +64 -0
  67. package/script/deps/deno.land/std@0.208.0/media_types/format_media_type.d.ts +16 -0
  68. package/script/deps/deno.land/std@0.208.0/media_types/format_media_type.js +65 -0
  69. package/script/deps/deno.land/std@0.208.0/media_types/get_charset.d.ts +15 -0
  70. package/script/deps/deno.land/std@0.208.0/media_types/get_charset.js +41 -0
  71. package/script/deps/deno.land/std@0.208.0/media_types/parse_media_type.d.ts +37 -0
  72. package/script/deps/deno.land/std@0.208.0/media_types/parse_media_type.js +126 -0
  73. package/script/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.d.ts +8518 -0
  74. package/script/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.js +8557 -0
  75. package/script/storage/0_storage.d.ts +1 -0
  76. package/script/storage/1_storage_indexed_db.d.ts +4 -3
  77. package/script/storage/1_storage_indexed_db.js +17 -8
  78. package/script/storage/1_storage_local_storage.d.ts +2 -2
  79. package/script/storage/1_storage_local_storage.js +3 -0
  80. package/script/storage/1_storage_memory.d.ts +1 -0
  81. package/script/storage/1_storage_memory.js +3 -0
  82. package/script/storage/1_storage_session_storage.d.ts +1 -0
  83. package/script/storage/1_storage_session_storage.js +3 -0
  84. package/script/transport/0_transport.d.ts +1 -1
  85. package/script/transport/0_transport.js +0 -6
  86. package/script/transport/1_transport_abridged.d.ts +1 -0
  87. package/script/transport/1_transport_abridged.js +9 -5
  88. package/script/transport/1_transport_intermediate.d.ts +1 -0
  89. package/script/transport/1_transport_intermediate.js +8 -4
  90. package/script/types/1_chat.d.ts +2 -15
  91. package/script/types/1_chat.js +3 -14
  92. package/script/types/1_user.js +4 -2
  93. package/script/types/3_message.d.ts +2 -2
  94. package/script/types/3_message.js +6 -6
  95. package/script/utilities/{0_base64.js → 1_base64.js} +2 -1
  96. /package/esm/utilities/{0_base64.d.ts → 1_base64.d.ts} +0 -0
  97. /package/script/utilities/{0_base64.d.ts → 1_base64.d.ts} +0 -0
@@ -0,0 +1,37 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { parseMediaType } from "./parse_media_type.js";
4
+ import { db } from "./_db.js";
5
+ /**
6
+ * Given a media type or header value, identify the encoding charset. If the
7
+ * charset cannot be determined, the function returns `undefined`.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { getCharset } from "https://deno.land/std@$STD_VERSION/media_types/get_charset.ts";
12
+ *
13
+ * getCharset("text/plain"); // `UTF-8`
14
+ * getCharset("application/foo"); // undefined
15
+ * getCharset("application/news-checkgroups"); // `US-ASCII`
16
+ * getCharset("application/news-checkgroups; charset=UTF-8"); // `UTF-8`
17
+ * ```
18
+ */
19
+ export function getCharset(type) {
20
+ try {
21
+ const [mediaType, params] = parseMediaType(type);
22
+ if (params && params["charset"]) {
23
+ return params["charset"];
24
+ }
25
+ const entry = db[mediaType];
26
+ if (entry && entry.charset) {
27
+ return entry.charset;
28
+ }
29
+ if (mediaType.startsWith("text/")) {
30
+ return "UTF-8";
31
+ }
32
+ }
33
+ catch {
34
+ // just swallow errors, returning undefined
35
+ }
36
+ return undefined;
37
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Parses the media type and any optional parameters, per
3
+ * [RFC 1521](https://datatracker.ietf.org/doc/html/rfc1521). Media types are
4
+ * the values in `Content-Type` and `Content-Disposition` headers. On success
5
+ * the function returns a tuple where the first element is the media type and
6
+ * the second element is the optional parameters or `undefined` if there are
7
+ * none.
8
+ *
9
+ * The function will throw if the parsed value is invalid.
10
+ *
11
+ * The returned media type will be normalized to be lower case, and returned
12
+ * params keys will be normalized to lower case, but preserves the casing of
13
+ * the value.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { parseMediaType } from "https://deno.land/std@$STD_VERSION/media_types/parse_media_type.ts";
18
+ * import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_equals.ts";
19
+ *
20
+ * assertEquals(
21
+ * parseMediaType("application/JSON"),
22
+ * [
23
+ * "application/json",
24
+ * undefined
25
+ * ]
26
+ * );
27
+ *
28
+ * assertEquals(
29
+ * parseMediaType("text/html; charset=UTF-8"),
30
+ * [
31
+ * "text/html",
32
+ * { charset: "UTF-8" },
33
+ * ]
34
+ * );
35
+ * ```
36
+ */
37
+ export declare function parseMediaType(v: string): [mediaType: string, params: Record<string, string> | undefined];
@@ -0,0 +1,122 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { consumeMediaParam, decode2331Encoding } from "./_util.js";
4
+ /**
5
+ * Parses the media type and any optional parameters, per
6
+ * [RFC 1521](https://datatracker.ietf.org/doc/html/rfc1521). Media types are
7
+ * the values in `Content-Type` and `Content-Disposition` headers. On success
8
+ * the function returns a tuple where the first element is the media type and
9
+ * the second element is the optional parameters or `undefined` if there are
10
+ * none.
11
+ *
12
+ * The function will throw if the parsed value is invalid.
13
+ *
14
+ * The returned media type will be normalized to be lower case, and returned
15
+ * params keys will be normalized to lower case, but preserves the casing of
16
+ * the value.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { parseMediaType } from "https://deno.land/std@$STD_VERSION/media_types/parse_media_type.ts";
21
+ * import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_equals.ts";
22
+ *
23
+ * assertEquals(
24
+ * parseMediaType("application/JSON"),
25
+ * [
26
+ * "application/json",
27
+ * undefined
28
+ * ]
29
+ * );
30
+ *
31
+ * assertEquals(
32
+ * parseMediaType("text/html; charset=UTF-8"),
33
+ * [
34
+ * "text/html",
35
+ * { charset: "UTF-8" },
36
+ * ]
37
+ * );
38
+ * ```
39
+ */
40
+ export function parseMediaType(v) {
41
+ const [base] = v.split(";");
42
+ const mediaType = base.toLowerCase().trim();
43
+ const params = {};
44
+ // Map of base parameter name -> parameter name -> value
45
+ // for parameters containing a '*' character.
46
+ const continuation = new Map();
47
+ v = v.slice(base.length);
48
+ while (v.length) {
49
+ v = v.trimStart();
50
+ if (v.length === 0) {
51
+ break;
52
+ }
53
+ const [key, value, rest] = consumeMediaParam(v);
54
+ if (!key) {
55
+ if (rest.trim() === ";") {
56
+ // ignore trailing semicolons
57
+ break;
58
+ }
59
+ throw new TypeError("Invalid media parameter.");
60
+ }
61
+ let pmap = params;
62
+ const [baseName, rest2] = key.split("*");
63
+ if (baseName && rest2 !== undefined) {
64
+ if (!continuation.has(baseName)) {
65
+ continuation.set(baseName, {});
66
+ }
67
+ pmap = continuation.get(baseName);
68
+ }
69
+ if (key in pmap) {
70
+ throw new TypeError("Duplicate key parsed.");
71
+ }
72
+ pmap[key] = value;
73
+ v = rest;
74
+ }
75
+ // Stitch together any continuations or things with stars
76
+ // (i.e. RFC 2231 things with stars: "foo*0" or "foo*")
77
+ let str = "";
78
+ for (const [key, pieceMap] of continuation) {
79
+ const singlePartKey = `${key}*`;
80
+ const v = pieceMap[singlePartKey];
81
+ if (v) {
82
+ const decv = decode2331Encoding(v);
83
+ if (decv) {
84
+ params[key] = decv;
85
+ }
86
+ continue;
87
+ }
88
+ str = "";
89
+ let valid = false;
90
+ for (let n = 0;; n++) {
91
+ const simplePart = `${key}*${n}`;
92
+ let v = pieceMap[simplePart];
93
+ if (v) {
94
+ valid = true;
95
+ str += v;
96
+ continue;
97
+ }
98
+ const encodedPart = `${simplePart}*`;
99
+ v = pieceMap[encodedPart];
100
+ if (!v) {
101
+ break;
102
+ }
103
+ valid = true;
104
+ if (n === 0) {
105
+ const decv = decode2331Encoding(v);
106
+ if (decv) {
107
+ str += decv;
108
+ }
109
+ }
110
+ else {
111
+ const decv = decodeURI(v);
112
+ str += decv;
113
+ }
114
+ }
115
+ if (valid) {
116
+ params[key] = str;
117
+ }
118
+ }
119
+ return Object.keys(params).length
120
+ ? [mediaType, params]
121
+ : [mediaType, undefined];
122
+ }