@opra/common 0.15.0 → 0.16.1

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 (284) hide show
  1. package/cjs/document/factory/import-resource-class.js +1 -0
  2. package/cjs/document/factory/import-type-class.js +9 -2
  3. package/cjs/document/resource/collection.js +9 -9
  4. package/cjs/document/resource/singleton.js +4 -4
  5. package/cjs/url/opra-url.js +7 -7
  6. package/esm/document/api-document.js +37 -33
  7. package/esm/document/constants.js +6 -3
  8. package/esm/document/data-type/api-field.js +15 -12
  9. package/esm/document/data-type/builtin/any.type.js +8 -5
  10. package/esm/document/data-type/builtin/base64.type.js +8 -5
  11. package/esm/document/data-type/builtin/bigint.type.js +8 -5
  12. package/esm/document/data-type/builtin/boolean.type.js +11 -8
  13. package/esm/document/data-type/builtin/date.type.js +10 -7
  14. package/esm/document/data-type/builtin/guid.type.js +12 -9
  15. package/esm/document/data-type/builtin/index.js +13 -10
  16. package/esm/document/data-type/builtin/integer.type.js +13 -10
  17. package/esm/document/data-type/builtin/number.type.js +10 -7
  18. package/esm/document/data-type/builtin/object.type.js +8 -5
  19. package/esm/document/data-type/builtin/string.type.js +11 -8
  20. package/esm/document/data-type/builtin/time.type.js +10 -7
  21. package/esm/document/data-type/builtin/timestamp.type.js +12 -9
  22. package/esm/document/data-type/complex-type.js +34 -30
  23. package/esm/document/data-type/data-type.js +12 -9
  24. package/esm/document/data-type/enum-type.js +19 -15
  25. package/esm/document/data-type/mapped-type.js +29 -24
  26. package/esm/document/data-type/simple-type.js +21 -17
  27. package/esm/document/data-type/union-type.js +29 -26
  28. package/esm/document/factory/add-references.js +7 -3
  29. package/esm/document/factory/create-document.js +16 -10
  30. package/esm/document/factory/factory.js +37 -33
  31. package/esm/document/factory/import-resource-class.js +22 -15
  32. package/esm/document/factory/import-type-class.js +43 -26
  33. package/esm/document/factory/index.js +4 -1
  34. package/esm/document/factory/process-resources.js +16 -10
  35. package/esm/document/factory/process-types.js +37 -31
  36. package/esm/document/index.js +17 -14
  37. package/esm/document/resource/collection.js +50 -46
  38. package/esm/document/resource/resource.js +12 -9
  39. package/esm/document/resource/singleton.js +29 -25
  40. package/esm/document/utils/inspect.util.js +7 -4
  41. package/esm/document/utils/string-compare.util.js +5 -1
  42. package/esm/exception/enums/issue-severity.enum.js +5 -2
  43. package/esm/exception/error-issue.js +2 -1
  44. package/esm/exception/http-errors/bad-request.error.js +8 -4
  45. package/esm/exception/http-errors/failed-dependency.error.js +8 -4
  46. package/esm/exception/http-errors/forbidden.error.js +8 -4
  47. package/esm/exception/http-errors/internal-server.error.js +8 -4
  48. package/esm/exception/http-errors/method-not-allowed.error.js +8 -4
  49. package/esm/exception/http-errors/not-acceptable.error.js +8 -4
  50. package/esm/exception/http-errors/not-found.error.js +8 -4
  51. package/esm/exception/http-errors/unauthorized.error.js +8 -4
  52. package/esm/exception/http-errors/unprocessable-entity.error.js +8 -4
  53. package/esm/exception/index.js +18 -15
  54. package/esm/exception/opra-exception.js +7 -3
  55. package/esm/exception/resource-errors/resource-conflict.error.js +8 -4
  56. package/esm/exception/resource-errors/resource-not-found.error.js +8 -4
  57. package/esm/exception/wrap-exception.js +24 -20
  58. package/esm/filter/antlr/OpraFilterLexer.js +9 -6
  59. package/esm/filter/antlr/OpraFilterListener.js +5 -2
  60. package/esm/filter/antlr/OpraFilterParser.js +126 -79
  61. package/esm/filter/antlr/OpraFilterVisitor.js +5 -2
  62. package/esm/filter/ast/abstract/ast.js +5 -1
  63. package/esm/filter/ast/abstract/expression.js +6 -2
  64. package/esm/filter/ast/abstract/literal.js +6 -2
  65. package/esm/filter/ast/abstract/term.js +6 -2
  66. package/esm/filter/ast/expressions/arithmetic-expression.js +8 -3
  67. package/esm/filter/ast/expressions/array-expression.js +6 -2
  68. package/esm/filter/ast/expressions/comparison-expression.js +6 -2
  69. package/esm/filter/ast/expressions/logical-expression.js +6 -2
  70. package/esm/filter/ast/expressions/parentheses-expression.js +6 -2
  71. package/esm/filter/ast/index.js +19 -16
  72. package/esm/filter/ast/terms/boolean-literal.js +6 -2
  73. package/esm/filter/ast/terms/date-literal.js +12 -8
  74. package/esm/filter/ast/terms/external-constant.js +6 -2
  75. package/esm/filter/ast/terms/null-literal.js +6 -2
  76. package/esm/filter/ast/terms/number-literal.js +8 -4
  77. package/esm/filter/ast/terms/qualified-identifier.js +6 -2
  78. package/esm/filter/ast/terms/string-literal.js +8 -4
  79. package/esm/filter/ast/terms/time-literal.js +10 -6
  80. package/esm/filter/build.js +69 -45
  81. package/esm/filter/errors.js +9 -3
  82. package/esm/filter/filter-tree-visitor.js +31 -26
  83. package/esm/filter/index.js +8 -5
  84. package/esm/filter/opra-error-listener.js +8 -4
  85. package/esm/filter/parse.js +19 -14
  86. package/esm/filter/utils.js +7 -2
  87. package/esm/helpers/function-utils.js +14 -8
  88. package/esm/helpers/get-stack-filename.js +5 -1
  89. package/esm/helpers/index.js +11 -8
  90. package/esm/helpers/is-url.js +5 -1
  91. package/esm/helpers/mixin-utils.js +7 -2
  92. package/esm/helpers/object-utils.js +12 -6
  93. package/esm/helpers/path-to-object-tree.js +5 -1
  94. package/esm/helpers/responsive-map.js +5 -1
  95. package/esm/helpers/type-guards.js +17 -7
  96. package/esm/http/codecs/boolean-codec.js +5 -1
  97. package/esm/http/codecs/date-codec.js +5 -1
  98. package/esm/http/codecs/filter-codec.js +9 -5
  99. package/esm/http/codecs/integer-codec.js +6 -2
  100. package/esm/http/codecs/number-codec.js +5 -1
  101. package/esm/http/codecs/string-codec.js +5 -1
  102. package/esm/http/enums/http-headers-codes.enum.js +5 -2
  103. package/esm/http/enums/http-status-codes.enum.js +5 -2
  104. package/esm/http/enums/http-status-messages.js +4 -1
  105. package/esm/http/http-headers.js +9 -5
  106. package/esm/http/http-message.host.js +18 -13
  107. package/esm/http/http-params.js +25 -20
  108. package/esm/http/http-request-message.js +22 -18
  109. package/esm/http/http-response-message.js +28 -23
  110. package/esm/http/index.js +17 -14
  111. package/esm/http/interfaces/client-http-headers.interface.js +2 -1
  112. package/esm/http/interfaces/cookie-options.interface.js +2 -1
  113. package/esm/http/interfaces/server-http-headers.interface.js +2 -1
  114. package/esm/i18n/i18n.js +28 -23
  115. package/esm/i18n/index.js +9 -5
  116. package/esm/i18n/string-utils.js +7 -2
  117. package/esm/i18n/translate.js +7 -3
  118. package/esm/index.js +16 -11
  119. package/esm/schema/constants.js +4 -1
  120. package/esm/schema/data-type/complex-type.interface.js +5 -2
  121. package/esm/schema/data-type/data-type.interface.js +2 -1
  122. package/esm/schema/data-type/enum-type.interface.js +5 -2
  123. package/esm/schema/data-type/field.interface.js +2 -1
  124. package/esm/schema/data-type/mapped-type.interface.js +5 -2
  125. package/esm/schema/data-type/simple-type.interface.js +5 -2
  126. package/esm/schema/data-type/union-type.interface.js +5 -2
  127. package/esm/schema/document.interface.js +2 -1
  128. package/esm/schema/index.js +34 -31
  129. package/esm/schema/resource/collection.interface.js +5 -2
  130. package/esm/schema/resource/container.interface.js +5 -2
  131. package/esm/schema/resource/endpoint.interface.js +2 -1
  132. package/esm/schema/resource/resource.interface.js +2 -1
  133. package/esm/schema/resource/singleton.interface.js +5 -2
  134. package/esm/schema/type-guards.js +53 -40
  135. package/esm/types.js +2 -1
  136. package/esm/url/index.js +8 -5
  137. package/esm/url/opra-url-path-component.js +7 -3
  138. package/esm/url/opra-url-path.js +18 -14
  139. package/esm/url/opra-url.js +25 -21
  140. package/esm/url/utils/decode-path-component.js +8 -4
  141. package/esm/url/utils/encode-path-component.js +8 -3
  142. package/esm/utils/path-utils.js +7 -2
  143. package/package.json +5 -4
  144. package/{esm → types}/document/factory/import-resource-class.d.ts +1 -0
  145. package/{esm → types}/document/resource/collection.d.ts +10 -10
  146. package/{esm → types}/document/resource/singleton.d.ts +4 -4
  147. package/{esm → types}/schema/resource/collection.interface.d.ts +6 -6
  148. package/{esm → types}/url/opra-url.d.ts +3 -3
  149. package/{esm → types}/document/api-document.d.ts +0 -0
  150. package/{esm → types}/document/constants.d.ts +0 -0
  151. package/{esm → types}/document/data-type/api-field.d.ts +0 -0
  152. package/{esm → types}/document/data-type/builtin/any.type.d.ts +0 -0
  153. package/{esm → types}/document/data-type/builtin/base64.type.d.ts +0 -0
  154. package/{esm → types}/document/data-type/builtin/bigint.type.d.ts +0 -0
  155. package/{esm → types}/document/data-type/builtin/boolean.type.d.ts +0 -0
  156. package/{esm → types}/document/data-type/builtin/date.type.d.ts +0 -0
  157. package/{esm → types}/document/data-type/builtin/guid.type.d.ts +0 -0
  158. package/{esm → types}/document/data-type/builtin/index.d.ts +0 -0
  159. package/{esm → types}/document/data-type/builtin/integer.type.d.ts +0 -0
  160. package/{esm → types}/document/data-type/builtin/number.type.d.ts +0 -0
  161. package/{esm → types}/document/data-type/builtin/object.type.d.ts +0 -0
  162. package/{esm → types}/document/data-type/builtin/string.type.d.ts +0 -0
  163. package/{esm → types}/document/data-type/builtin/time.type.d.ts +0 -0
  164. package/{esm → types}/document/data-type/builtin/timestamp.type.d.ts +0 -0
  165. package/{esm → types}/document/data-type/complex-type.d.ts +0 -0
  166. package/{esm → types}/document/data-type/data-type.d.ts +0 -0
  167. package/{esm → types}/document/data-type/enum-type.d.ts +0 -0
  168. package/{esm → types}/document/data-type/mapped-type.d.ts +0 -0
  169. package/{esm → types}/document/data-type/simple-type.d.ts +0 -0
  170. package/{esm → types}/document/data-type/union-type.d.ts +0 -0
  171. package/{esm → types}/document/factory/add-references.d.ts +0 -0
  172. package/{esm → types}/document/factory/create-document.d.ts +0 -0
  173. package/{esm → types}/document/factory/factory.d.ts +0 -0
  174. package/{esm → types}/document/factory/import-type-class.d.ts +0 -0
  175. package/{esm → types}/document/factory/index.d.ts +0 -0
  176. package/{esm → types}/document/factory/process-resources.d.ts +0 -0
  177. package/{esm → types}/document/factory/process-types.d.ts +0 -0
  178. package/{esm → types}/document/index.d.ts +0 -0
  179. package/{esm → types}/document/resource/resource.d.ts +0 -0
  180. package/{esm → types}/document/utils/inspect.util.d.ts +0 -0
  181. package/{esm → types}/document/utils/string-compare.util.d.ts +0 -0
  182. package/{esm → types}/exception/enums/issue-severity.enum.d.ts +0 -0
  183. package/{esm → types}/exception/error-issue.d.ts +0 -0
  184. package/{esm → types}/exception/http-errors/bad-request.error.d.ts +0 -0
  185. package/{esm → types}/exception/http-errors/failed-dependency.error.d.ts +0 -0
  186. package/{esm → types}/exception/http-errors/forbidden.error.d.ts +0 -0
  187. package/{esm → types}/exception/http-errors/internal-server.error.d.ts +0 -0
  188. package/{esm → types}/exception/http-errors/method-not-allowed.error.d.ts +0 -0
  189. package/{esm → types}/exception/http-errors/not-acceptable.error.d.ts +0 -0
  190. package/{esm → types}/exception/http-errors/not-found.error.d.ts +0 -0
  191. package/{esm → types}/exception/http-errors/unauthorized.error.d.ts +0 -0
  192. package/{esm → types}/exception/http-errors/unprocessable-entity.error.d.ts +0 -0
  193. package/{esm → types}/exception/index.d.ts +0 -0
  194. package/{esm → types}/exception/opra-exception.d.ts +0 -0
  195. package/{esm → types}/exception/resource-errors/resource-conflict.error.d.ts +0 -0
  196. package/{esm → types}/exception/resource-errors/resource-not-found.error.d.ts +0 -0
  197. package/{esm → types}/exception/wrap-exception.d.ts +0 -0
  198. package/{esm → types}/filter/antlr/OpraFilterLexer.d.ts +0 -0
  199. package/{esm → types}/filter/antlr/OpraFilterListener.d.ts +0 -0
  200. package/{esm → types}/filter/antlr/OpraFilterParser.d.ts +0 -0
  201. package/{esm → types}/filter/antlr/OpraFilterVisitor.d.ts +0 -0
  202. package/{esm → types}/filter/ast/abstract/ast.d.ts +0 -0
  203. package/{esm → types}/filter/ast/abstract/expression.d.ts +0 -0
  204. package/{esm → types}/filter/ast/abstract/literal.d.ts +0 -0
  205. package/{esm → types}/filter/ast/abstract/term.d.ts +0 -0
  206. package/{esm → types}/filter/ast/expressions/arithmetic-expression.d.ts +0 -0
  207. package/{esm → types}/filter/ast/expressions/array-expression.d.ts +0 -0
  208. package/{esm → types}/filter/ast/expressions/comparison-expression.d.ts +0 -0
  209. package/{esm → types}/filter/ast/expressions/logical-expression.d.ts +0 -0
  210. package/{esm → types}/filter/ast/expressions/parentheses-expression.d.ts +0 -0
  211. package/{esm → types}/filter/ast/index.d.ts +0 -0
  212. package/{esm → types}/filter/ast/terms/boolean-literal.d.ts +0 -0
  213. package/{esm → types}/filter/ast/terms/date-literal.d.ts +0 -0
  214. package/{esm → types}/filter/ast/terms/external-constant.d.ts +0 -0
  215. package/{esm → types}/filter/ast/terms/null-literal.d.ts +0 -0
  216. package/{esm → types}/filter/ast/terms/number-literal.d.ts +0 -0
  217. package/{esm → types}/filter/ast/terms/qualified-identifier.d.ts +0 -0
  218. package/{esm → types}/filter/ast/terms/string-literal.d.ts +0 -0
  219. package/{esm → types}/filter/ast/terms/time-literal.d.ts +0 -0
  220. package/{esm → types}/filter/build.d.ts +0 -0
  221. package/{esm → types}/filter/errors.d.ts +0 -0
  222. package/{esm → types}/filter/filter-tree-visitor.d.ts +0 -0
  223. package/{esm → types}/filter/index.d.ts +0 -0
  224. package/{esm → types}/filter/opra-error-listener.d.ts +0 -0
  225. package/{esm → types}/filter/parse.d.ts +0 -0
  226. package/{esm → types}/filter/utils.d.ts +0 -0
  227. package/{esm → types}/helpers/function-utils.d.ts +0 -0
  228. package/{esm → types}/helpers/get-stack-filename.d.ts +0 -0
  229. package/{esm → types}/helpers/index.d.ts +0 -0
  230. package/{esm → types}/helpers/is-url.d.ts +0 -0
  231. package/{esm → types}/helpers/mixin-utils.d.ts +0 -0
  232. package/{esm → types}/helpers/object-utils.d.ts +0 -0
  233. package/{esm → types}/helpers/path-to-object-tree.d.ts +0 -0
  234. package/{esm → types}/helpers/responsive-map.d.ts +0 -0
  235. package/{esm → types}/helpers/type-guards.d.ts +0 -0
  236. package/{esm → types}/http/codecs/boolean-codec.d.ts +0 -0
  237. package/{esm → types}/http/codecs/date-codec.d.ts +0 -0
  238. package/{esm → types}/http/codecs/filter-codec.d.ts +0 -0
  239. package/{esm → types}/http/codecs/integer-codec.d.ts +0 -0
  240. package/{esm → types}/http/codecs/number-codec.d.ts +0 -0
  241. package/{esm → types}/http/codecs/string-codec.d.ts +0 -0
  242. package/{esm → types}/http/enums/http-headers-codes.enum.d.ts +0 -0
  243. package/{esm → types}/http/enums/http-status-codes.enum.d.ts +0 -0
  244. package/{esm → types}/http/enums/http-status-messages.d.ts +0 -0
  245. package/{esm → types}/http/http-headers.d.ts +0 -0
  246. package/{esm → types}/http/http-message.host.d.ts +0 -0
  247. package/{esm → types}/http/http-params.d.ts +0 -0
  248. package/{esm → types}/http/http-request-message.d.ts +0 -0
  249. package/{esm → types}/http/http-response-message.d.ts +0 -0
  250. package/{esm → types}/http/index.d.ts +0 -0
  251. package/{esm → types}/http/interfaces/client-http-headers.interface.d.ts +0 -0
  252. package/{esm → types}/http/interfaces/cookie-options.interface.d.ts +0 -0
  253. package/{esm → types}/http/interfaces/server-http-headers.interface.d.ts +0 -0
  254. package/{esm → types}/http/multipart/batch-multipart.d.ts +0 -0
  255. package/{esm → types}/http/multipart/http-request-content.d.ts +0 -0
  256. package/{esm → types}/http/multipart/http-response-content.d.ts +0 -0
  257. package/{esm → types}/http/multipart/index.d.ts +0 -0
  258. package/{esm → types}/i18n/i18n.d.ts +0 -0
  259. package/{esm → types}/i18n/index.d.ts +0 -0
  260. package/{esm → types}/i18n/string-utils.d.ts +0 -0
  261. package/{esm → types}/i18n/translate.d.ts +0 -0
  262. package/{esm → types}/index.d.ts +0 -0
  263. package/{esm → types}/schema/constants.d.ts +0 -0
  264. package/{esm → types}/schema/data-type/complex-type.interface.d.ts +0 -0
  265. package/{esm → types}/schema/data-type/data-type.interface.d.ts +0 -0
  266. package/{esm → types}/schema/data-type/enum-type.interface.d.ts +0 -0
  267. package/{esm → types}/schema/data-type/field.interface.d.ts +0 -0
  268. package/{esm → types}/schema/data-type/mapped-type.interface.d.ts +0 -0
  269. package/{esm → types}/schema/data-type/simple-type.interface.d.ts +0 -0
  270. package/{esm → types}/schema/data-type/union-type.interface.d.ts +0 -0
  271. package/{esm → types}/schema/document.interface.d.ts +0 -0
  272. package/{esm → types}/schema/index.d.ts +0 -0
  273. package/{esm → types}/schema/resource/container.interface.d.ts +0 -0
  274. package/{esm → types}/schema/resource/endpoint.interface.d.ts +0 -0
  275. package/{esm → types}/schema/resource/resource.interface.d.ts +0 -0
  276. package/{esm → types}/schema/resource/singleton.interface.d.ts +2 -2
  277. /package/{esm → types}/schema/type-guards.d.ts +0 -0
  278. /package/{esm → types}/types.d.ts +0 -0
  279. /package/{esm → types}/url/index.d.ts +0 -0
  280. /package/{esm → types}/url/opra-url-path-component.d.ts +0 -0
  281. /package/{esm → types}/url/opra-url-path.d.ts +0 -0
  282. /package/{esm → types}/url/utils/decode-path-component.d.ts +0 -0
  283. /package/{esm → types}/url/utils/encode-path-component.d.ts +0 -0
  284. /package/{esm → types}/utils/path-utils.d.ts +0 -0
@@ -1,7 +1,10 @@
1
+ "use strict";
1
2
  var _a;
2
- import { ResponsiveMap } from '../helpers/index.js';
3
- import { HttpHeaderCodes } from './enums/http-headers-codes.enum.js';
4
- const knownKeys = Object.values(HttpHeaderCodes);
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.HttpHeaders = void 0;
5
+ const index_js_1 = require("../helpers/index.js");
6
+ const http_headers_codes_enum_js_1 = require("./enums/http-headers-codes.enum.js");
7
+ const knownKeys = Object.values(http_headers_codes_enum_js_1.HttpHeaderCodes);
5
8
  const knownKeysLower = knownKeys.map(x => x.toLowerCase());
6
9
  const nodeInspectCustom = Symbol.for('nodejs.util.inspect.custom');
7
10
  const kEntries = Symbol('kEntries');
@@ -10,9 +13,9 @@ const kOptions = Symbol('kOptions');
10
13
  *
11
14
  * @class HttpHeaders
12
15
  */
13
- export class HttpHeaders {
16
+ class HttpHeaders {
14
17
  constructor(init, options) {
15
- this[_a] = new ResponsiveMap();
18
+ this[_a] = new index_js_1.ResponsiveMap();
16
19
  this[kOptions] = { ...options, onChange: undefined };
17
20
  if (init) {
18
21
  if (typeof init === 'string')
@@ -198,6 +201,7 @@ export class HttpHeaders {
198
201
  this[kOptions].onChange();
199
202
  }
200
203
  }
204
+ exports.HttpHeaders = HttpHeaders;
201
205
  HttpHeaders.kEntries = kEntries;
202
206
  HttpHeaders.kOptions = kOptions;
203
207
  HttpHeaders.NON_DELIMITED_HEADERS = {
@@ -1,6 +1,10 @@
1
- import { HTTPParser } from 'http-parser-js';
2
- import stream from 'stream';
3
- import { HttpHeaders } from './http-headers.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpMessageHost = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const http_parser_js_1 = require("http-parser-js");
6
+ const stream_1 = tslib_1.__importDefault(require("stream"));
7
+ const http_headers_js_1 = require("./http-headers.js");
4
8
  const kHeaders = Symbol('kHeaders');
5
9
  const kHeadersProxy = Symbol('kHeadersProxy');
6
10
  const kTrailers = Symbol('kTrailers');
@@ -11,14 +15,14 @@ const kOnBodyChunk = Symbol('kOnBodyChunk');
11
15
  const kOnReadComplete = Symbol('kOnReadComplete');
12
16
  const crlfBuffer = Buffer.from('\r\n');
13
17
  const HTTP_VERSION_PATTERN = /^(\d)\.(\d)$/;
14
- export class HttpMessageHost {
18
+ class HttpMessageHost {
15
19
  constructor() {
16
20
  this.complete = false;
17
- stream.Duplex.apply(this);
18
- this[kHeaders] = new HttpHeaders(undefined, {
21
+ stream_1.default.Duplex.apply(this);
22
+ this[kHeaders] = new http_headers_js_1.HttpHeaders(undefined, {
19
23
  onChange: () => this._headersChanged = true
20
24
  });
21
- this[kTrailers] = new HttpHeaders(undefined, {
25
+ this[kTrailers] = new http_headers_js_1.HttpHeaders(undefined, {
22
26
  onChange: () => this._trailersChanged = true
23
27
  });
24
28
  }
@@ -144,11 +148,11 @@ export class HttpMessageHost {
144
148
  this.body = args.body;
145
149
  }
146
150
  _parseBuffer(buf, parserType) {
147
- const parser = new HTTPParser(parserType);
148
- parser[HTTPParser.kOnHeadersComplete] = this[kOnHeaderReceived].bind(this);
149
- parser[HTTPParser.kOnBody] = this[kOnBodyChunk].bind(this);
150
- parser[HTTPParser.kOnHeaders] = this[kOnTrailersReceived].bind(this);
151
- parser[HTTPParser.kOnMessageComplete] = this[kOnReadComplete].bind(this);
151
+ const parser = new http_parser_js_1.HTTPParser(parserType);
152
+ parser[http_parser_js_1.HTTPParser.kOnHeadersComplete] = this[kOnHeaderReceived].bind(this);
153
+ parser[http_parser_js_1.HTTPParser.kOnBody] = this[kOnBodyChunk].bind(this);
154
+ parser[http_parser_js_1.HTTPParser.kOnHeaders] = this[kOnTrailersReceived].bind(this);
155
+ parser[http_parser_js_1.HTTPParser.kOnMessageComplete] = this[kOnReadComplete].bind(this);
152
156
  const buffer = Buffer.from(buf);
153
157
  let x = parser.execute(buffer);
154
158
  if (typeof x === 'object')
@@ -234,6 +238,7 @@ export class HttpMessageHost {
234
238
  }
235
239
  }
236
240
  }
241
+ exports.HttpMessageHost = HttpMessageHost;
237
242
  HttpMessageHost.kHeaders = kHeaders;
238
243
  HttpMessageHost.kHeadersProxy = kHeadersProxy;
239
244
  HttpMessageHost.kTrailers = kTrailers;
@@ -243,4 +248,4 @@ HttpMessageHost.kOnTrailersReceived = kOnTrailersReceived;
243
248
  HttpMessageHost.kOnBodyChunk = kOnBodyChunk;
244
249
  HttpMessageHost.kOnReadComplete = kOnReadComplete;
245
250
  // Mixin with Duplex
246
- Object.assign(HttpMessageHost.prototype, stream.Duplex.prototype);
251
+ Object.assign(HttpMessageHost.prototype, stream_1.default.Duplex.prototype);
@@ -1,19 +1,22 @@
1
+ "use strict";
1
2
  var _a, _b, _c;
2
- import { splitString, tokenize } from 'fast-tokenizer';
3
- import { ResponsiveMap } from '../helpers/index.js';
4
- import { BooleanCodec } from './codecs/boolean-codec.js';
5
- import { DateCodec } from './codecs/date-codec.js';
6
- import { FilterCodec } from './codecs/filter-codec.js';
7
- import { IntegerCodec } from './codecs/integer-codec.js';
8
- import { NumberCodec } from './codecs/number-codec.js';
9
- import { StringCodec } from './codecs/string-codec.js';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.encodeURIParam = exports.HttpParams = void 0;
5
+ const fast_tokenizer_1 = require("fast-tokenizer");
6
+ const index_js_1 = require("../helpers/index.js");
7
+ const boolean_codec_js_1 = require("./codecs/boolean-codec.js");
8
+ const date_codec_js_1 = require("./codecs/date-codec.js");
9
+ const filter_codec_js_1 = require("./codecs/filter-codec.js");
10
+ const integer_codec_js_1 = require("./codecs/integer-codec.js");
11
+ const number_codec_js_1 = require("./codecs/number-codec.js");
12
+ const string_codec_js_1 = require("./codecs/string-codec.js");
10
13
  const kEntries = Symbol('kEntries');
11
14
  const kSize = Symbol('kSize');
12
15
  const kParamDefs = Symbol('kParamDefs');
13
16
  const kOptions = Symbol('kOptions');
14
- export class HttpParams {
17
+ class HttpParams {
15
18
  constructor(init, options) {
16
- this[_a] = new ResponsiveMap();
19
+ this[_a] = new index_js_1.ResponsiveMap();
17
20
  this[_b] = 0;
18
21
  this[_c] = new Map();
19
22
  this[kOptions] = { ...options, onChange: undefined };
@@ -42,11 +45,11 @@ export class HttpParams {
42
45
  input = input.substring(1);
43
46
  if (!input)
44
47
  return this;
45
- const tokenizer = tokenize(input, { delimiters: '&', quotes: true, brackets: true });
48
+ const tokenizer = (0, fast_tokenizer_1.tokenize)(input, { delimiters: '&', quotes: true, brackets: true });
46
49
  for (const token of tokenizer) {
47
50
  if (!token)
48
51
  continue;
49
- const itemTokenizer = tokenize(token, {
52
+ const itemTokenizer = (0, fast_tokenizer_1.tokenize)(token, {
50
53
  delimiters: '=',
51
54
  quotes: true,
52
55
  brackets: true
@@ -240,7 +243,7 @@ export class HttpParams {
240
243
  let val = value;
241
244
  if (prmDef) {
242
245
  if (prmDef.array) {
243
- val = splitString(value, {
246
+ val = (0, fast_tokenizer_1.splitString)(value, {
244
247
  delimiters: prmDef.arrayDelimiter || ',',
245
248
  brackets: true,
246
249
  quotes: true,
@@ -318,17 +321,18 @@ export class HttpParams {
318
321
  return 'HttpParams';
319
322
  }
320
323
  }
324
+ exports.HttpParams = HttpParams;
321
325
  HttpParams.kEntries = kEntries;
322
326
  HttpParams.kSize = kSize;
323
327
  HttpParams.kParamDefs = kParamDefs;
324
328
  HttpParams.kOptions = kOptions;
325
329
  HttpParams.codecs = {
326
- 'boolean': new BooleanCodec(),
327
- 'date': new DateCodec(),
328
- 'filter': new FilterCodec(),
329
- 'integer': new IntegerCodec(),
330
- 'number': new NumberCodec(),
331
- 'string': new StringCodec()
330
+ 'boolean': new boolean_codec_js_1.BooleanCodec(),
331
+ 'date': new date_codec_js_1.DateCodec(),
332
+ 'filter': new filter_codec_js_1.FilterCodec(),
333
+ 'integer': new integer_codec_js_1.IntegerCodec(),
334
+ 'number': new number_codec_js_1.NumberCodec(),
335
+ 'string': new string_codec_js_1.StringCodec()
332
336
  };
333
337
  /**
334
338
  * Encode input string with standard encodeURIComponent and then un-encode specific characters.
@@ -344,6 +348,7 @@ const ENCODING_REPLACEMENTS = {
344
348
  '3F': '?',
345
349
  '40': '@'
346
350
  };
347
- export function encodeURIParam(v) {
351
+ function encodeURIParam(v) {
348
352
  return encodeURIComponent(v).replace(ENCODING_REGEX, (s, t) => ENCODING_REPLACEMENTS[t] ?? s);
349
353
  }
354
+ exports.encodeURIParam = encodeURIParam;
@@ -1,10 +1,14 @@
1
- import accepts from 'accepts';
2
- import { HTTPParser } from 'http-parser-js';
3
- import typeIs from 'type-is';
4
- import { HttpMessageHost } from './http-message.host.js';
5
- import { HttpParams } from './http-params.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpRequestMessage = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const accepts_1 = tslib_1.__importDefault(require("accepts"));
6
+ const http_parser_js_1 = require("http-parser-js");
7
+ const type_is_1 = tslib_1.__importDefault(require("type-is"));
8
+ const http_message_host_js_1 = require("./http-message.host.js");
9
+ const http_params_js_1 = require("./http-params.js");
6
10
  const HTTP_VERSION_PATTERN = /^(\d)\.(\d)$/;
7
- export var HttpRequestMessage;
11
+ var HttpRequestMessage;
8
12
  (function (HttpRequestMessage) {
9
13
  function create(init) {
10
14
  return HttpRequestMessageHost.create(init);
@@ -18,19 +22,19 @@ export var HttpRequestMessage;
18
22
  return HttpRequestMessageHost.fromStream(readable);
19
23
  }
20
24
  HttpRequestMessage.fromStream = fromStream;
21
- })(HttpRequestMessage || (HttpRequestMessage = {}));
25
+ })(HttpRequestMessage = exports.HttpRequestMessage || (exports.HttpRequestMessage = {}));
22
26
  const kQuery = Symbol('kQuery');
23
27
  const kQueryProxy = Symbol('kQueryProxy');
24
28
  const kProtocol = Symbol('kProtocol');
25
29
  /**
26
30
  *
27
31
  */
28
- class HttpRequestMessageHost extends HttpMessageHost {
32
+ class HttpRequestMessageHost extends http_message_host_js_1.HttpMessageHost {
29
33
  constructor() {
30
34
  super();
31
35
  this.httpVersionMajor = 1;
32
36
  this.httpVersionMinor = 0;
33
- this[kQuery] = new HttpParams();
37
+ this[kQuery] = new http_params_js_1.HttpParams();
34
38
  this[kQueryProxy] = this[kQuery].getProxy();
35
39
  }
36
40
  get httpVersion() {
@@ -91,22 +95,22 @@ class HttpRequestMessageHost extends HttpMessageHost {
91
95
  return this.getHeader(name);
92
96
  }
93
97
  accepts(...type) {
94
- const accept = accepts(this);
98
+ const accept = (0, accepts_1.default)(this);
95
99
  // eslint-disable-next-line prefer-spread
96
100
  return accept.types.apply(accept, type);
97
101
  }
98
102
  acceptsCharsets(...charset) {
99
- const accept = accepts(this);
103
+ const accept = (0, accepts_1.default)(this);
100
104
  // eslint-disable-next-line prefer-spread
101
105
  return accept.charsets.apply(accept, charset);
102
106
  }
103
107
  acceptsEncodings(...encoding) {
104
- const accept = accepts(this);
108
+ const accept = (0, accepts_1.default)(this);
105
109
  // eslint-disable-next-line prefer-spread
106
110
  return accept.encodings.apply(accept, encoding);
107
111
  }
108
112
  acceptsLanguages(...lang) {
109
- const accept = accepts(this);
113
+ const accept = (0, accepts_1.default)(this);
110
114
  // eslint-disable-next-line prefer-spread
111
115
  return accept.languages.apply(accept, lang);
112
116
  }
@@ -115,7 +119,7 @@ class HttpRequestMessageHost extends HttpMessageHost {
115
119
  if (otherTypes.length)
116
120
  types.push(...otherTypes);
117
121
  const contentType = this.getHeader('content-type');
118
- return contentType ? typeIs.is(contentType, types) : null;
122
+ return contentType ? type_is_1.default.is(contentType, types) : null;
119
123
  }
120
124
  _init(init) {
121
125
  super._init(init);
@@ -124,9 +128,9 @@ class HttpRequestMessageHost extends HttpMessageHost {
124
128
  this.baseUrl = init.baseUrl || this.url;
125
129
  this.protocol = init.protocol;
126
130
  }
127
- [HttpMessageHost.kOnHeaderReceived](info) {
128
- super[HttpMessageHost.kOnHeaderReceived](info);
129
- this.method = HTTPParser.methods[info.method];
131
+ [http_message_host_js_1.HttpMessageHost.kOnHeaderReceived](info) {
132
+ super[http_message_host_js_1.HttpMessageHost.kOnHeaderReceived](info);
133
+ this.method = http_parser_js_1.HTTPParser.methods[info.method];
130
134
  this.url = info.url;
131
135
  this.baseUrl = info.url;
132
136
  }
@@ -137,7 +141,7 @@ class HttpRequestMessageHost extends HttpMessageHost {
137
141
  }
138
142
  static fromBuffer(buffer) {
139
143
  const msg = new HttpRequestMessageHost();
140
- msg._parseBuffer(buffer, HTTPParser.REQUEST);
144
+ msg._parseBuffer(buffer, http_parser_js_1.HTTPParser.REQUEST);
141
145
  return msg;
142
146
  }
143
147
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -1,16 +1,20 @@
1
- import contentDisposition from 'content-disposition';
2
- import cookie from 'cookie';
3
- import cookieSignature from 'cookie-signature';
4
- import encodeUrl from 'encodeurl';
5
- import { HTTPParser } from 'http-parser-js';
6
- import mime from 'mime-types';
7
- import path from 'path';
8
- import { HttpStatusMessages } from './enums/http-status-messages.js';
9
- import { HttpMessageHost } from './http-message.host.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpResponseMessageHost = exports.HttpResponseMessage = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const content_disposition_1 = tslib_1.__importDefault(require("content-disposition"));
6
+ const cookie_1 = tslib_1.__importDefault(require("cookie"));
7
+ const cookie_signature_1 = tslib_1.__importDefault(require("cookie-signature"));
8
+ const encodeurl_1 = tslib_1.__importDefault(require("encodeurl"));
9
+ const http_parser_js_1 = require("http-parser-js");
10
+ const mime_types_1 = tslib_1.__importDefault(require("mime-types"));
11
+ const path_1 = tslib_1.__importDefault(require("path"));
12
+ const http_status_messages_js_1 = require("./enums/http-status-messages.js");
13
+ const http_message_host_js_1 = require("./http-message.host.js");
10
14
  /**
11
15
  * @namespace HttpResponseMessage
12
16
  */
13
- export var HttpResponseMessage;
17
+ var HttpResponseMessage;
14
18
  (function (HttpResponseMessage) {
15
19
  function create(init) {
16
20
  return HttpResponseMessageHost.create(init);
@@ -24,11 +28,11 @@ export var HttpResponseMessage;
24
28
  return HttpResponseMessageHost.fromStream(readable);
25
29
  }
26
30
  HttpResponseMessage.fromStream = fromStream;
27
- })(HttpResponseMessage || (HttpResponseMessage = {}));
31
+ })(HttpResponseMessage = exports.HttpResponseMessage || (exports.HttpResponseMessage = {}));
28
32
  /**
29
33
  * @class HttpResponseMessageHost
30
34
  */
31
- export class HttpResponseMessageHost extends HttpMessageHost {
35
+ class HttpResponseMessageHost extends http_message_host_js_1.HttpMessageHost {
32
36
  constructor() {
33
37
  super();
34
38
  }
@@ -36,7 +40,7 @@ export class HttpResponseMessageHost extends HttpMessageHost {
36
40
  return this.set(arg0, arg1);
37
41
  }
38
42
  append(name, value) {
39
- this[HttpMessageHost.kHeaders].append(name, value);
43
+ this[http_message_host_js_1.HttpMessageHost.kHeaders].append(name, value);
40
44
  return this;
41
45
  }
42
46
  /**
@@ -44,8 +48,8 @@ export class HttpResponseMessageHost extends HttpMessageHost {
44
48
  */
45
49
  attachment(filename) {
46
50
  if (filename)
47
- this.type(path.extname(filename));
48
- this.set('Content-Disposition', contentDisposition(filename));
51
+ this.type(path_1.default.extname(filename));
52
+ this.set('Content-Disposition', (0, content_disposition_1.default)(filename));
49
53
  return this;
50
54
  }
51
55
  /**
@@ -68,7 +72,7 @@ export class HttpResponseMessageHost extends HttpMessageHost {
68
72
  */
69
73
  type(type) {
70
74
  const ct = type.indexOf('/') === -1
71
- ? mime.lookup(type)
75
+ ? mime_types_1.default.lookup(type)
72
76
  : type;
73
77
  if (ct)
74
78
  this.set('Content-Type', ct);
@@ -103,7 +107,7 @@ export class HttpResponseMessageHost extends HttpMessageHost {
103
107
  ? 'j:' + JSON.stringify(value)
104
108
  : String(value);
105
109
  if (signed)
106
- val = 's:' + cookieSignature.sign(val, secret);
110
+ val = 's:' + cookie_signature_1.default.sign(val, secret);
107
111
  if (opts.maxAge != null) {
108
112
  const maxAge = opts.maxAge - 0;
109
113
  if (!isNaN(maxAge)) {
@@ -119,7 +123,7 @@ export class HttpResponseMessageHost extends HttpMessageHost {
119
123
  a = a.filter(x => !x.startsWith(name + '='));
120
124
  this.set('Set-Cookie', a);
121
125
  }
122
- this.append('Set-Cookie', cookie.serialize(name, String(val), opts));
126
+ this.append('Set-Cookie', cookie_1.default.serialize(name, String(val), opts));
123
127
  return this;
124
128
  }
125
129
  /**
@@ -178,7 +182,7 @@ export class HttpResponseMessageHost extends HttpMessageHost {
178
182
  if (url === 'back')
179
183
  loc = this.req?.get('Referrer') || '/';
180
184
  // set location
181
- return this.set('Location', encodeUrl(loc));
185
+ return this.set('Location', (0, encodeurl_1.default)(loc));
182
186
  }
183
187
  /**
184
188
  * Set status `code`.
@@ -199,7 +203,7 @@ export class HttpResponseMessageHost extends HttpMessageHost {
199
203
  * res.sendStatus(500); // equivalent to res.status(500).send('Internal Server Error')
200
204
  */
201
205
  sendStatus(statusCode) {
202
- const body = HttpStatusMessages[statusCode] || String(statusCode);
206
+ const body = http_status_messages_js_1.HttpStatusMessages[statusCode] || String(statusCode);
203
207
  this.statusCode = statusCode;
204
208
  this.type('txt');
205
209
  return this.send(body);
@@ -211,8 +215,8 @@ export class HttpResponseMessageHost extends HttpMessageHost {
211
215
  this.req = init?.req;
212
216
  this.chunkedEncoding = init?.chunkedEncoding;
213
217
  }
214
- [HttpMessageHost.kOnHeaderReceived](info) {
215
- super[HttpMessageHost.kOnHeaderReceived](info);
218
+ [http_message_host_js_1.HttpMessageHost.kOnHeaderReceived](info) {
219
+ super[http_message_host_js_1.HttpMessageHost.kOnHeaderReceived](info);
216
220
  this.statusCode = info.statusCode;
217
221
  this.statusMessage = info.statusMessage;
218
222
  }
@@ -223,7 +227,7 @@ export class HttpResponseMessageHost extends HttpMessageHost {
223
227
  }
224
228
  static fromBuffer(buffer) {
225
229
  const msg = new HttpResponseMessageHost();
226
- msg._parseBuffer(buffer, HTTPParser.RESPONSE);
230
+ msg._parseBuffer(buffer, http_parser_js_1.HTTPParser.RESPONSE);
227
231
  return msg;
228
232
  }
229
233
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -231,3 +235,4 @@ export class HttpResponseMessageHost extends HttpMessageHost {
231
235
  throw new Error('fromStream is not implemented yet');
232
236
  }
233
237
  }
238
+ exports.HttpResponseMessageHost = HttpResponseMessageHost;
package/esm/http/index.js CHANGED
@@ -1,14 +1,17 @@
1
- export * from './http-headers.js';
2
- export * from './http-params.js';
3
- export * from './http-response-message.js';
4
- export * from './http-request-message.js';
5
- export * from './enums/http-headers-codes.enum.js';
6
- export * from './enums/http-status-codes.enum.js';
7
- export * from './interfaces/client-http-headers.interface.js';
8
- export * from './interfaces/server-http-headers.interface.js';
9
- export * from './codecs/date-codec.js';
10
- export * from './codecs/boolean-codec.js';
11
- export * from './codecs/filter-codec.js';
12
- export * from './codecs/integer-codec.js';
13
- export * from './codecs/number-codec.js';
14
- export * from './codecs/string-codec.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./http-headers.js"), exports);
5
+ tslib_1.__exportStar(require("./http-params.js"), exports);
6
+ tslib_1.__exportStar(require("./http-response-message.js"), exports);
7
+ tslib_1.__exportStar(require("./http-request-message.js"), exports);
8
+ tslib_1.__exportStar(require("./enums/http-headers-codes.enum.js"), exports);
9
+ tslib_1.__exportStar(require("./enums/http-status-codes.enum.js"), exports);
10
+ tslib_1.__exportStar(require("./interfaces/client-http-headers.interface.js"), exports);
11
+ tslib_1.__exportStar(require("./interfaces/server-http-headers.interface.js"), exports);
12
+ tslib_1.__exportStar(require("./codecs/date-codec.js"), exports);
13
+ tslib_1.__exportStar(require("./codecs/boolean-codec.js"), exports);
14
+ tslib_1.__exportStar(require("./codecs/filter-codec.js"), exports);
15
+ tslib_1.__exportStar(require("./codecs/integer-codec.js"), exports);
16
+ tslib_1.__exportStar(require("./codecs/number-codec.js"), exports);
17
+ tslib_1.__exportStar(require("./codecs/string-codec.js"), exports);
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/esm/i18n/i18n.js CHANGED
@@ -1,12 +1,16 @@
1
- import { splitString, tokenize } from 'fast-tokenizer';
2
- import fs from 'fs';
3
- import i18next from 'i18next';
4
- import path from 'path';
5
- import { isUrl } from '../helpers/index.js';
6
- import { unescapeString } from './string-utils.js';
7
- export const BaseI18n = Object.getPrototypeOf(i18next).constructor;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.I18n = exports.BaseI18n = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fast_tokenizer_1 = require("fast-tokenizer");
6
+ const fs_1 = tslib_1.__importDefault(require("fs"));
7
+ const i18next_1 = tslib_1.__importDefault(require("i18next"));
8
+ const path_1 = tslib_1.__importDefault(require("path"));
9
+ const index_js_1 = require("../helpers/index.js");
10
+ const string_utils_js_1 = require("./string-utils.js");
11
+ exports.BaseI18n = Object.getPrototypeOf(i18next_1.default).constructor;
8
12
  const globalLocaleDirs = [];
9
- export class I18n extends BaseI18n {
13
+ class I18n extends exports.BaseI18n {
10
14
  async init(arg0, arg1) {
11
15
  const options = typeof arg0 === 'object' ? arg0 : {};
12
16
  const callback = typeof arg0 === 'function' ? arg0 : arg1;
@@ -54,11 +58,11 @@ export class I18n extends BaseI18n {
54
58
  }
55
59
  async loadResourceBundle(lang, ns, filePath, deep, overwrite) {
56
60
  let obj;
57
- if (isUrl(filePath)) {
61
+ if ((0, index_js_1.isUrl)(filePath)) {
58
62
  obj = (await fetch(filePath, { headers: { accept: 'application/json' } })).json();
59
63
  }
60
64
  else {
61
- const content = fs.readFileSync(filePath, 'utf8');
65
+ const content = fs_1.default.readFileSync(filePath, 'utf8');
62
66
  obj = JSON.parse(content);
63
67
  }
64
68
  this.addResourceBundle(lang, ns, obj, deep, overwrite);
@@ -66,18 +70,18 @@ export class I18n extends BaseI18n {
66
70
  async loadResourceDir(dirnames, deep, overwrite) {
67
71
  for (const dirname of Array.isArray(dirnames) ? dirnames : [dirnames]) {
68
72
  /* istanbul ignore next */
69
- if (!(fs.existsSync(dirname)))
73
+ if (!(fs_1.default.existsSync(dirname)))
70
74
  continue;
71
- const languageDirs = fs.readdirSync(dirname);
75
+ const languageDirs = fs_1.default.readdirSync(dirname);
72
76
  for (const lang of languageDirs) {
73
- const langDir = path.join(dirname, lang);
74
- if ((fs.statSync(langDir)).isDirectory()) {
75
- const nsDirs = fs.readdirSync(langDir);
77
+ const langDir = path_1.default.join(dirname, lang);
78
+ if ((fs_1.default.statSync(langDir)).isDirectory()) {
79
+ const nsDirs = fs_1.default.readdirSync(langDir);
76
80
  for (const nsfile of nsDirs) {
77
- const nsFilePath = path.join(langDir, nsfile);
78
- const ext = path.extname(nsfile);
79
- if (ext === '.json' && (fs.statSync(nsFilePath)).isFile()) {
80
- const ns = path.basename(nsfile, ext);
81
+ const nsFilePath = path_1.default.join(langDir, nsfile);
82
+ const ext = path_1.default.extname(nsfile);
83
+ if (ext === '.json' && (fs_1.default.statSync(nsFilePath)).isFile()) {
84
+ const ns = path_1.default.basename(nsfile, ext);
81
85
  await this.loadResourceBundle(lang, ns, nsFilePath, deep, overwrite);
82
86
  }
83
87
  }
@@ -100,7 +104,7 @@ export class I18n extends BaseI18n {
100
104
  return objectStack.get(input);
101
105
  if (typeof input === 'string') {
102
106
  let s = '';
103
- for (let token of tokenize(input, {
107
+ for (let token of (0, fast_tokenizer_1.tokenize)(input, {
104
108
  brackets: { '$t(': ')' },
105
109
  quotes: true,
106
110
  keepQuotes: true,
@@ -109,12 +113,12 @@ export class I18n extends BaseI18n {
109
113
  })) {
110
114
  if (token.startsWith('$t(') && token.endsWith(')')) {
111
115
  token = token.substring(3, token.length - 1);
112
- const a = splitString(token, { delimiters: '?', quotes: true, brackets: { '{': '}' } });
113
- const fallback = unescapeString(token.substring((a[0] || '').length + 1));
116
+ const a = (0, fast_tokenizer_1.splitString)(token, { delimiters: '?', quotes: true, brackets: { '{': '}' } });
117
+ const fallback = (0, string_utils_js_1.unescapeString)(token.substring((a[0] || '').length + 1));
114
118
  token = a[0] || '';
115
119
  const keys = [];
116
120
  let opts = null;
117
- for (const token2 of tokenize(token, { delimiters: ',', quotes: true, brackets: { '{': '}' } })) {
121
+ for (const token2 of (0, fast_tokenizer_1.tokenize)(token, { delimiters: ',', quotes: true, brackets: { '{': '}' } })) {
118
122
  if (token2.startsWith('{')) {
119
123
  opts = JSON.parse(token2);
120
124
  continue;
@@ -163,4 +167,5 @@ export class I18n extends BaseI18n {
163
167
  return defaultInstance;
164
168
  }
165
169
  }
170
+ exports.I18n = I18n;
166
171
  const defaultInstance = I18n.createInstance();
package/esm/i18n/index.js CHANGED
@@ -1,6 +1,10 @@
1
- import { I18n } from './i18n.js';
2
- export * from './i18n.js';
3
- export * from './translate.js';
4
- const i18n = I18n.createInstance();
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.i18n = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const i18n_js_1 = require("./i18n.js");
6
+ tslib_1.__exportStar(require("./i18n.js"), exports);
7
+ tslib_1.__exportStar(require("./translate.js"), exports);
8
+ const i18n = i18n_js_1.I18n.createInstance();
9
+ exports.i18n = i18n;
5
10
  i18n.init().catch(() => void 0);
6
- export { i18n };
@@ -1,8 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unescapeString = exports.escapeString = void 0;
1
4
  const unescapeRegEx = /\\(.)/g;
2
5
  const escapeRegEx = /(\\)/g;
3
- export function escapeString(s) {
6
+ function escapeString(s) {
4
7
  return s.replace(escapeRegEx, '\\\\');
5
8
  }
6
- export function unescapeString(s) {
9
+ exports.escapeString = escapeString;
10
+ function unescapeString(s) {
7
11
  return s.replace(unescapeRegEx, '$1');
8
12
  }
13
+ exports.unescapeString = unescapeString;
@@ -1,11 +1,15 @@
1
- import { escapeString } from './string-utils.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.translate = void 0;
4
+ const string_utils_js_1 = require("./string-utils.js");
2
5
  const bracketRegEx = /(\))/g;
3
- export function translate(key, arg0, arg1) {
6
+ function translate(key, arg0, arg1) {
4
7
  const options = arg0 && typeof arg0 === 'object' ? arg0 : undefined;
5
8
  const fallback = typeof arg0 === 'string' ? arg0 : arg1;
6
9
  return '$t(' +
7
10
  key +
8
11
  (options ? ',' + JSON.stringify(options) : '') +
9
- (fallback ? '?' + escapeString(fallback).replace(bracketRegEx, '\\$1') : '') +
12
+ (fallback ? '?' + (0, string_utils_js_1.escapeString)(fallback).replace(bracketRegEx, '\\$1') : '') +
10
13
  ')';
11
14
  }
15
+ exports.translate = translate;