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