@sima-land/isomorph 11.0.0-alpha.0 → 11.0.0-alpha.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 (213) hide show
  1. package/{dist/cache → cache}/types.d.ts +0 -0
  2. package/{dist/utils/webpack/module-federation → cache}/types.js +0 -0
  3. package/{dist/cache → cache}/types.js.map +0 -0
  4. package/{dist/config → config}/browser.d.ts +0 -0
  5. package/{dist/config → config}/browser.js +0 -0
  6. package/{dist/config → config}/browser.js.map +0 -0
  7. package/{dist/config → config}/index.d.ts +0 -0
  8. package/{dist/config → config}/index.js +0 -0
  9. package/{dist/config → config}/index.js.map +0 -0
  10. package/{dist/config → config}/node.d.ts +0 -0
  11. package/{dist/config → config}/node.js +0 -0
  12. package/{dist/config → config}/node.js.map +0 -0
  13. package/{dist/config → config}/types.d.ts +0 -0
  14. package/{dist/tracer → config}/types.js +0 -0
  15. package/{dist/config → config}/types.js.map +0 -0
  16. package/{dist/config → config}/utils.d.ts +0 -0
  17. package/{dist/config → config}/utils.js +0 -0
  18. package/{dist/config → config}/utils.js.map +0 -0
  19. package/{dist/container → container}/application.d.ts +0 -0
  20. package/{dist/container → container}/application.js +0 -0
  21. package/{dist/container → container}/application.js.map +0 -0
  22. package/{dist/container → container}/index.d.ts +0 -0
  23. package/{dist/container → container}/index.js +0 -0
  24. package/{dist/container → container}/index.js.map +0 -0
  25. package/{dist/container → container}/types.d.ts +0 -0
  26. package/{dist/saga-runner → container}/types.js +0 -0
  27. package/{dist/container → container}/types.js.map +0 -0
  28. package/{dist/error-tracker → error-tracker}/browser.d.ts +0 -0
  29. package/{dist/error-tracker → error-tracker}/browser.js +0 -0
  30. package/{dist/error-tracker → error-tracker}/browser.js.map +0 -0
  31. package/{dist/error-tracker → error-tracker}/node.d.ts +0 -0
  32. package/{dist/error-tracker → error-tracker}/node.js +0 -0
  33. package/{dist/error-tracker → error-tracker}/node.js.map +0 -0
  34. package/{dist/error-tracker → error-tracker}/types.d.ts +0 -0
  35. package/{dist/preset → error-tracker}/types.js +0 -0
  36. package/{dist/error-tracker → error-tracker}/types.js.map +0 -0
  37. package/{dist/error-tracker → error-tracker}/utils.d.ts +0 -0
  38. package/{dist/error-tracker → error-tracker}/utils.js +0 -0
  39. package/{dist/error-tracker → error-tracker}/utils.js.map +0 -0
  40. package/{dist/http-client → http-client}/middleware/cookie.d.ts +0 -0
  41. package/{dist/http-client → http-client}/middleware/cookie.js +0 -0
  42. package/{dist/http-client → http-client}/middleware/cookie.js.map +0 -0
  43. package/{dist/http-client → http-client}/middleware/tracing.d.ts +0 -0
  44. package/{dist/http-client → http-client}/middleware/tracing.js +0 -0
  45. package/{dist/http-client → http-client}/middleware/tracing.js.map +0 -0
  46. package/{dist/http-client → http-client}/types.d.ts +0 -0
  47. package/{dist/logger → http-client}/types.js +0 -0
  48. package/{dist/http-client → http-client}/types.js.map +0 -0
  49. package/{dist/http-client → http-client}/utils.d.ts +0 -0
  50. package/{dist/http-client → http-client}/utils.js +0 -0
  51. package/{dist/http-client → http-client}/utils.js.map +0 -0
  52. package/{dist/http-server → http-server}/constants.d.ts +0 -0
  53. package/{dist/http-server → http-server}/constants.js +0 -0
  54. package/{dist/http-server → http-server}/constants.js.map +0 -0
  55. package/{dist/http-server → http-server}/handler/health-check.d.ts +0 -0
  56. package/{dist/http-server → http-server}/handler/health-check.js +0 -0
  57. package/{dist/http-server → http-server}/handler/health-check.js.map +0 -0
  58. package/{dist/http-server → http-server}/middleware/logging.d.ts +0 -0
  59. package/{dist/http-server → http-server}/middleware/logging.js +0 -0
  60. package/{dist/http-server → http-server}/middleware/logging.js.map +0 -0
  61. package/{dist/http-server → http-server}/middleware/metrics.d.ts +0 -0
  62. package/{dist/http-server → http-server}/middleware/metrics.js +0 -0
  63. package/{dist/http-server → http-server}/middleware/metrics.js.map +0 -0
  64. package/{dist/http-server → http-server}/middleware/tracing.d.ts +0 -0
  65. package/{dist/http-server → http-server}/middleware/tracing.js +0 -0
  66. package/{dist/http-server → http-server}/middleware/tracing.js.map +0 -0
  67. package/http-server/template/index.d.ts +1 -0
  68. package/http-server/template/index.js +36 -0
  69. package/http-server/template/index.js.map +1 -0
  70. package/{dist/http-server → http-server}/types.d.ts +8 -0
  71. package/{dist/http-server → http-server}/types.js +0 -0
  72. package/{dist/http-server → http-server}/types.js.map +0 -0
  73. package/{dist/http-server → http-server}/utils.d.ts +5 -1
  74. package/{dist/http-server → http-server}/utils.js +16 -4
  75. package/http-server/utils.js.map +1 -0
  76. package/{dist/logger → logger}/handler/console.d.ts +0 -0
  77. package/{dist/logger → logger}/handler/console.js +0 -0
  78. package/{dist/logger → logger}/handler/console.js.map +0 -0
  79. package/{dist/logger → logger}/handler/sentry.d.ts +0 -0
  80. package/{dist/logger → logger}/handler/sentry.js +0 -0
  81. package/{dist/logger → logger}/handler/sentry.js.map +0 -0
  82. package/{dist/logger → logger}/index.d.ts +0 -0
  83. package/{dist/logger → logger}/index.js +0 -0
  84. package/{dist/logger → logger}/index.js.map +0 -0
  85. package/{dist/logger → logger}/types.d.ts +0 -0
  86. package/{dist/http-client → logger}/types.js +0 -0
  87. package/{dist/logger → logger}/types.js.map +0 -0
  88. package/{dist/metrics → metrics}/constants.d.ts +0 -0
  89. package/{dist/metrics → metrics}/constants.js +0 -0
  90. package/{dist/metrics → metrics}/constants.js.map +0 -0
  91. package/{dist/metrics → metrics}/node.d.ts +0 -0
  92. package/{dist/metrics → metrics}/node.js +0 -0
  93. package/{dist/metrics → metrics}/node.js.map +0 -0
  94. package/package.json +5 -10
  95. package/{dist/preset → preset}/index.d.ts +0 -0
  96. package/{dist/preset → preset}/index.js +5 -3
  97. package/preset/index.js.map +1 -0
  98. package/{dist/preset → preset}/node/index.d.ts +0 -0
  99. package/{dist/preset → preset}/node/index.js +0 -0
  100. package/{dist/preset → preset}/node/index.js.map +0 -0
  101. package/{dist/preset → preset}/node/response.d.ts +6 -1
  102. package/{dist/preset → preset}/node/response.js +28 -2
  103. package/preset/node/response.js.map +1 -0
  104. package/{dist/preset → preset}/types.d.ts +2 -2
  105. package/{dist/error-tracker → preset}/types.js +0 -0
  106. package/{dist/preset → preset}/types.js.map +0 -0
  107. package/{dist/saga-runner → saga-runner}/index.d.ts +0 -0
  108. package/{dist/saga-runner → saga-runner}/index.js +3 -1
  109. package/saga-runner/index.js.map +1 -0
  110. package/{dist/saga-runner → saga-runner}/types.d.ts +0 -0
  111. package/{dist/container → saga-runner}/types.js +0 -0
  112. package/{dist/saga-runner → saga-runner}/types.js.map +0 -0
  113. package/{dist/tokens.d.ts → tokens.d.ts} +2 -1
  114. package/{dist/tokens.js → tokens.js} +1 -0
  115. package/{dist/tokens.js.map → tokens.js.map} +1 -1
  116. package/{dist/tracer → tracer}/node.d.ts +0 -0
  117. package/{dist/tracer → tracer}/node.js +0 -0
  118. package/{dist/tracer → tracer}/node.js.map +0 -0
  119. package/{dist/tracer → tracer}/types.d.ts +0 -0
  120. package/{dist/config → tracer}/types.js +0 -0
  121. package/{dist/tracer → tracer}/types.js.map +0 -0
  122. package/{dist/utils → utils}/browser/analytics/data-layer.d.ts +0 -0
  123. package/{dist/utils → utils}/browser/analytics/data-layer.js +0 -0
  124. package/{dist/utils → utils}/browser/analytics/data-layer.js.map +0 -0
  125. package/{dist/utils → utils}/browser/analytics/oko.d.ts +0 -0
  126. package/{dist/utils → utils}/browser/analytics/oko.js +0 -0
  127. package/{dist/utils → utils}/browser/analytics/oko.js.map +0 -0
  128. package/{dist/utils → utils}/browser/storage/index.d.ts +0 -0
  129. package/{dist/utils → utils}/browser/storage/index.js +0 -0
  130. package/{dist/utils → utils}/browser/storage/index.js.map +0 -0
  131. package/{dist/utils → utils}/number.d.ts +0 -0
  132. package/{dist/utils → utils}/number.js +0 -0
  133. package/{dist/utils → utils}/number.js.map +0 -0
  134. package/{dist/utils → utils}/react/error-handlers/index.d.ts +0 -0
  135. package/{dist/utils → utils}/react/error-handlers/index.js +0 -0
  136. package/{dist/utils → utils}/react/error-handlers/index.js.map +0 -0
  137. package/{dist/utils → utils}/redux/remote-data.d.ts +0 -0
  138. package/{dist/utils → utils}/redux/remote-data.js +0 -0
  139. package/{dist/utils → utils}/redux/remote-data.js.map +0 -0
  140. package/{dist/utils → utils}/redux-saga/take-chain.d.ts +0 -0
  141. package/{dist/utils → utils}/redux-saga/take-chain.js +0 -0
  142. package/{dist/utils → utils}/redux-saga/take-chain.js.map +0 -0
  143. package/{dist/utils → utils}/webpack/module-federation/index.d.ts +0 -0
  144. package/{dist/utils → utils}/webpack/module-federation/index.js +0 -0
  145. package/{dist/utils → utils}/webpack/module-federation/index.js.map +0 -0
  146. package/{dist/utils → utils}/webpack/module-federation/types.d.ts +0 -0
  147. package/{dist/cache → utils/webpack/module-federation}/types.js +0 -0
  148. package/{dist/utils → utils}/webpack/module-federation/types.js.map +0 -0
  149. package/{dist/utils → utils}/webpack/module-federation/utils.d.ts +0 -0
  150. package/{dist/utils → utils}/webpack/module-federation/utils.js +0 -0
  151. package/{dist/utils → utils}/webpack/module-federation/utils.js.map +0 -0
  152. package/LICENSE +0 -201
  153. package/dist/http-server/utils.js.map +0 -1
  154. package/dist/preset/index.js.map +0 -1
  155. package/dist/preset/node/response.js.map +0 -1
  156. package/dist/saga-runner/index.js.map +0 -1
  157. package/readme.md +0 -23
  158. package/src/cache/types.ts +0 -7
  159. package/src/config/browser.ts +0 -10
  160. package/src/config/index.ts +0 -18
  161. package/src/config/node.ts +0 -18
  162. package/src/config/types.ts +0 -9
  163. package/src/config/utils.ts +0 -7
  164. package/src/container/application.ts +0 -91
  165. package/src/container/index.ts +0 -79
  166. package/src/container/types.ts +0 -17
  167. package/src/error-tracker/browser.ts +0 -14
  168. package/src/error-tracker/node.ts +0 -14
  169. package/src/error-tracker/types.ts +0 -22
  170. package/src/error-tracker/utils.ts +0 -18
  171. package/src/http-client/middleware/cookie.ts +0 -73
  172. package/src/http-client/middleware/tracing.ts +0 -79
  173. package/src/http-client/types.ts +0 -8
  174. package/src/http-client/utils.ts +0 -76
  175. package/src/http-server/constants.ts +0 -4
  176. package/src/http-server/handler/health-check.ts +0 -13
  177. package/src/http-server/middleware/logging.ts +0 -34
  178. package/src/http-server/middleware/metrics.ts +0 -87
  179. package/src/http-server/middleware/tracing.ts +0 -35
  180. package/src/http-server/types.ts +0 -29
  181. package/src/http-server/utils.ts +0 -105
  182. package/src/logger/handler/console.ts +0 -35
  183. package/src/logger/handler/sentry.ts +0 -38
  184. package/src/logger/index.ts +0 -31
  185. package/src/logger/types.ts +0 -28
  186. package/src/metrics/constants.ts +0 -4
  187. package/src/metrics/node.ts +0 -54
  188. package/src/preset/index.ts +0 -24
  189. package/src/preset/node/index.ts +0 -101
  190. package/src/preset/node/response.ts +0 -57
  191. package/src/preset/types.ts +0 -9
  192. package/src/saga-runner/index.ts +0 -59
  193. package/src/saga-runner/types.ts +0 -13
  194. package/src/tokens.ts +0 -54
  195. package/src/tracer/node.ts +0 -40
  196. package/src/tracer/types.ts +0 -3
  197. package/src/utils/browser/analytics/__test__/data-layer.test.ts +0 -50
  198. package/src/utils/browser/analytics/__test__/oko.test.tsx +0 -143
  199. package/src/utils/browser/analytics/data-layer.ts +0 -12
  200. package/src/utils/browser/analytics/oko.ts +0 -44
  201. package/src/utils/browser/storage/index.ts +0 -75
  202. package/src/utils/number.ts +0 -8
  203. package/src/utils/react/error-handlers/__test__/__snapshots__/index.test.tsx.snap +0 -27
  204. package/src/utils/react/error-handlers/__test__/index.test.tsx +0 -64
  205. package/src/utils/react/error-handlers/index.tsx +0 -62
  206. package/src/utils/redux/__test__/remote-data.test.ts +0 -50
  207. package/src/utils/redux/remote-data.ts +0 -34
  208. package/src/utils/redux-saga/__test__/take-chain.test.ts +0 -141
  209. package/src/utils/redux-saga/take-chain.ts +0 -65
  210. package/src/utils/webpack/module-federation/__test__/index.test.ts +0 -246
  211. package/src/utils/webpack/module-federation/index.ts +0 -92
  212. package/src/utils/webpack/module-federation/types.ts +0 -44
  213. package/src/utils/webpack/module-federation/utils.ts +0 -43
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ export declare const pageTemplate: import("ejs").TemplateFunction;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pageTemplate = void 0;
4
+ const ejs_1 = require("ejs");
5
+ exports.pageTemplate = (0, ejs_1.compile)(`
6
+ <!DOCTYPE html>
7
+ <html lang="ru">
8
+ <head>
9
+ <meta charset="UTF-8">
10
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
11
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
12
+ <title><%= title %></title>
13
+ <style>
14
+ * {
15
+ margin: 0;
16
+ padding: 0;
17
+ border: 0;
18
+ outline: 0;
19
+ box-sizing: border-box;
20
+ font: inherit;
21
+ line-height: inherit;
22
+ }
23
+ </style>
24
+ <% if (assets.css) { %>
25
+ <link rel="stylesheet" href="<%= assets.css %>">
26
+ <% } %>
27
+ </head>
28
+ <body>
29
+ <%- markup %>
30
+ <% if (assets.js) { %>
31
+ <script src="<%= assets.js %>"></script>
32
+ <% } %>
33
+ </body>
34
+ </html>
35
+ `);
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/http-server/template/index.ts"],"names":[],"mappings":";;;AAAA,6BAA8B;AAEjB,QAAA,YAAY,GAAG,IAAA,aAAO,EAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BnC,CAAC,CAAC"}
@@ -8,6 +8,14 @@ export interface PageAssets {
8
8
  js: string;
9
9
  css: string;
10
10
  }
11
+ export interface PageTemplateData {
12
+ markup: string;
13
+ assets: PageAssets;
14
+ type: 'json' | 'html';
15
+ }
16
+ export interface PageTemplate {
17
+ (data: PageTemplateData): string;
18
+ }
11
19
  export interface ConventionalJson {
12
20
  markup: string;
13
21
  bundle_js: string;
File without changes
File without changes
@@ -1,4 +1,5 @@
1
1
  import type { Request, Response } from 'express';
2
+ import type { PageTemplate, PageTemplateData } from './types';
2
3
  /**
3
4
  * Определяет IP входящего запроса.
4
5
  * @param req Входящий запрос.
@@ -15,12 +16,15 @@ export declare class PageResponse {
15
16
  private type;
16
17
  private html;
17
18
  private assets;
19
+ private _template;
18
20
  static create(): PageResponse;
19
21
  static defineFormat(req: Request): PageResponse['type'];
22
+ static defaultTemplate({ markup }: PageTemplateData): string;
20
23
  constructor();
21
24
  markup(html: string): this;
22
25
  script(url: string): this;
23
- style(url: string): this;
26
+ styles(url: string): this;
24
27
  format(type: PageResponse['type']): this;
28
+ template(template: PageTemplate): this;
25
29
  send(res: Response): void;
26
30
  }
@@ -33,6 +33,7 @@ class PageResponse {
33
33
  this.type = 'html';
34
34
  this.html = '';
35
35
  this.assets = { js: '', css: '' };
36
+ this._template = PageResponse.defaultTemplate;
36
37
  }
37
38
  static create() {
38
39
  return new PageResponse();
@@ -44,6 +45,9 @@ class PageResponse {
44
45
  }
45
46
  return result;
46
47
  }
48
+ static defaultTemplate({ markup }) {
49
+ return markup;
50
+ }
47
51
  markup(html) {
48
52
  this.html = html;
49
53
  return this;
@@ -52,7 +56,7 @@ class PageResponse {
52
56
  this.assets.js = url;
53
57
  return this;
54
58
  }
55
- style(url) {
59
+ styles(url) {
56
60
  this.assets.css = url;
57
61
  return this;
58
62
  }
@@ -60,11 +64,20 @@ class PageResponse {
60
64
  this.type = type;
61
65
  return this;
62
66
  }
67
+ template(template) {
68
+ this._template = template;
69
+ return this;
70
+ }
63
71
  send(res) {
72
+ const templateData = {
73
+ type: this.type,
74
+ markup: this.html,
75
+ assets: this.assets,
76
+ };
64
77
  switch (this.type) {
65
78
  case 'json': {
66
79
  const result = {
67
- markup: this.html,
80
+ markup: this._template(templateData),
68
81
  bundle_js: this.assets.js,
69
82
  bundle_css: this.assets.css,
70
83
  };
@@ -74,8 +87,7 @@ class PageResponse {
74
87
  case 'html': {
75
88
  res.setHeader('simaland-bundle-js', this.assets.js);
76
89
  res.setHeader('simaland-bundle-css', this.assets.css);
77
- // @todo dev-шаблон?
78
- res.send(this.html);
90
+ res.send(this._template(templateData));
79
91
  break;
80
92
  }
81
93
  default:
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/http-server/utils.ts"],"names":[],"mappings":";;;AAEA,6BAA2B;AAE3B;;;;GAIG;AACH,SAAgB,YAAY,CAAC,GAAY;IACvC,MAAM,WAAW,GACf,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC;IAEzF,OAAO,IAAA,UAAI,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9C,CAAC;AALD,oCAKC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,GAAY;IAC5C,MAAM,MAAM,GAAuC,EAAE,CAAC;IAEtD,KAAK,MAAM,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QAC/C,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;YAChD,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SAC/B;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAVD,8CAUC;AAED,uDAAuD;AACvD,MAAa,YAAY;IAwBvB;QACE,IAAI,CAAC,IAAI,GAAG,MAAM,C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AE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,IAAI;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;QAEF,QAAQ,IAAI,CAAC,IAAI,EAAE;YACjB,KAAK,MAAM,CAAC,CAAC;gBACX,MAAM,MAAM,GAAqB;oBAC/B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;oBACpC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE;oBACzB,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG;iBAC5B,CAAC;gBAEF,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACjB,MAAM;aACP;YACD,KAAK,MAAM,CAAC,CAAC;gBACX,GAAG,CAAC,SAAS,CAAC,oBAAoB,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBACpD,GAAG,CAAC,SAAS,CAAC,qBAAqB,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAEtD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;gBACvC,MAAM;aACP;YACD;gBACE,MAAM,KAAK,CAAC,2BAA2B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAC/D;IACH,CAAC;CACF;AArFD,oCAqFC;AACD,sDAAsD"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,23 +1,16 @@
1
1
  {
2
2
  "name": "@sima-land/isomorph",
3
- "version": "11.0.0-alpha.0",
3
+ "version": "11.0.0-alpha.1",
4
4
  "description": "Tiny framework for fast start frontend microservices",
5
5
  "author": "www.sima-land.ru team",
6
6
  "license": "Apache-2.0",
7
- "files": [
8
- "src",
9
- "dist",
10
- "readme.md"
11
- ],
12
- "exports": {
13
- "./": "./dist/"
14
- },
15
7
  "scripts": {
16
8
  "prepare": "",
17
9
  "type-check": "tsc -p . --noEmit",
18
10
  "build:before": "rm -rf dist",
19
11
  "build:main": "tsc --project tsconfig.build.json",
20
- "build": "npm run build:before && npm run build:main",
12
+ "build:after": "cp package.json dist/package.json",
13
+ "build": "npm run build:before && npm run build:main && npm run build:after",
21
14
  "lint": "eslint --cache ./src --ext .js,.jsx,.ts,.tsx",
22
15
  "test": "jest",
23
16
  "test:coverage": "jest --clearCache && jest --coverage"
@@ -26,6 +19,7 @@
26
19
  "@sima-land/linters": "^2.1.2",
27
20
  "@swc/jest": "^0.2.20",
28
21
  "@testing-library/react": "^12.1.3",
22
+ "@types/ejs": "^3.1.1",
29
23
  "@types/express": "^4.17.13",
30
24
  "@types/jest": "^27.4.1",
31
25
  "@types/lodash": "^4.14.182",
@@ -50,6 +44,7 @@
50
44
  "@sentry/browser": "^6.19.3",
51
45
  "@sentry/node": "^6.19.3",
52
46
  "dotenv": "^16.0.0",
47
+ "ejs": "^3.1.8",
53
48
  "express": "^4.17.3",
54
49
  "middleware-axios": "^2.1.2",
55
50
  "pino": "^7.9.1",
File without changes
@@ -8,16 +8,18 @@ exports.createPreset = void 0;
8
8
  */
9
9
  function createPreset(defaults) {
10
10
  const registry = new Map(defaults);
11
- return {
11
+ const preset = {
12
12
  override: (token, provider) => {
13
13
  registry.set(token, provider);
14
+ return preset;
14
15
  },
15
- apply: (container) => {
16
+ apply: (app) => {
16
17
  for (const [token, provider] of registry) {
17
- container.bind(token).toProvider(provider);
18
+ app.bind(token).toProvider(provider);
18
19
  }
19
20
  },
20
21
  };
22
+ return preset;
21
23
  }
22
24
  exports.createPreset = createPreset;
23
25
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/preset/index.ts"],"names":[],"mappings":";;;AAIA;;;;GAIG;AACH,SAAgB,YAAY,CAAC,QAAuB;IAClD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAA4B,QAAQ,CAAC,CAAC;IAE9D,MAAM,MAAM,GAAG;QACb,QAAQ,EAAE,CAAI,KAAe,EAAE,QAAqB,EAAE,EAAE;YACtD,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAC9B,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,KAAK,EAAE,CAAC,GAAgB,EAAE,EAAE;YAC1B,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,QAAQ,EAAE;gBACxC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;aACtC;QACH,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAjBD,oCAiBC"}
File without changes
File without changes
File without changes
@@ -1,7 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import type { Preset } from '../types';
3
- import type { Provider } from '../../container/types';
3
+ import type { Provider, Resolve } from '../../container/types';
4
4
  import type { SagaRunner } from '../../saga-runner/types';
5
+ import type { PageTemplate } from '../../http-server/types';
6
+ import type { Handler } from 'express';
7
+ import { Application } from '../../container/application';
5
8
  /**
6
9
  * Возвращает preset с зависимостями по умолчанию для работы в рамках ответа на http-запрос.
7
10
  * @return Preset.
@@ -9,4 +12,6 @@ import type { SagaRunner } from '../../saga-runner/types';
9
12
  export declare function PresetResponse(): Preset;
10
13
  export declare const provideSagaRunner: Provider<SagaRunner>;
11
14
  export declare const provideRender: Provider<(el: JSX.Element) => string | Promise<string>>;
15
+ export declare const provideTemplate: Provider<PageTemplate>;
12
16
  export declare const provideMain: Provider<() => void>;
17
+ export declare function HandlerProvider(appFactory: () => Application): (resolve: Resolve) => Handler;
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.provideMain = exports.provideRender = exports.provideSagaRunner = exports.PresetResponse = void 0;
3
+ exports.HandlerProvider = exports.provideMain = exports.provideTemplate = exports.provideRender = exports.provideSagaRunner = exports.PresetResponse = void 0;
4
+ const application_1 = require("../../container/application");
4
5
  const tokens_1 = require("../../tokens");
5
6
  const __1 = require("..");
6
7
  const server_1 = require("react-dom/server");
7
8
  const saga_runner_1 = require("../../saga-runner");
8
9
  const constants_1 = require("../../http-server/constants");
10
+ const template_1 = require("../../http-server/template");
9
11
  const utils_1 = require("../../http-server/utils");
10
12
  /**
11
13
  * Возвращает preset с зависимостями по умолчанию для работы в рамках ответа на http-запрос.
@@ -15,6 +17,7 @@ function PresetResponse() {
15
17
  return (0, __1.createPreset)([
16
18
  [tokens_1.KnownToken.Response.sagaRunner, exports.provideSagaRunner],
17
19
  [tokens_1.KnownToken.Response.render, exports.provideRender],
20
+ [tokens_1.KnownToken.Response.template, exports.provideTemplate],
18
21
  [tokens_1.KnownToken.Response.main, exports.provideMain],
19
22
  ]);
20
23
  }
@@ -34,19 +37,42 @@ const provideRender = resolve => {
34
37
  };
35
38
  };
36
39
  exports.provideRender = provideRender;
40
+ const provideTemplate = resolve => {
41
+ const config = resolve(tokens_1.KnownToken.Config.base);
42
+ return function template(data) {
43
+ return data.type === 'html'
44
+ ? (0, template_1.pageTemplate)({ ...data, title: `[dev] ${config.appName}` })
45
+ : data.markup;
46
+ };
47
+ };
48
+ exports.provideTemplate = provideTemplate;
37
49
  const provideMain = resolve => {
38
50
  const context = resolve(tokens_1.KnownToken.Response.context);
39
51
  const assets = resolve(tokens_1.KnownToken.Response.assets);
40
52
  const prepare = resolve(tokens_1.KnownToken.Response.prepare);
41
53
  const render = resolve(tokens_1.KnownToken.Response.render);
54
+ const template = resolve(tokens_1.KnownToken.Response.template);
42
55
  return async function main() {
43
56
  utils_1.PageResponse.create()
44
57
  .markup(await render(await prepare()))
45
58
  .script(assets.js)
46
- .style(assets.css)
59
+ .styles(assets.css)
47
60
  .format(utils_1.PageResponse.defineFormat(context.req))
61
+ .template(template)
48
62
  .send(context.res);
49
63
  };
50
64
  };
51
65
  exports.provideMain = provideMain;
66
+ function HandlerProvider(appFactory) {
67
+ return function provider(resolve) {
68
+ const parent = resolve(application_1.Application.self);
69
+ return function handler(req, res, next) {
70
+ const app = appFactory();
71
+ app.attach(parent);
72
+ app.bind(tokens_1.KnownToken.Response.context).toValue({ req, res, next });
73
+ app.get(tokens_1.KnownToken.Response.main)();
74
+ };
75
+ };
76
+ }
77
+ exports.HandlerProvider = HandlerProvider;
52
78
  //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/preset/node/response.ts"],"names":[],"mappings":";;;AAMA,6DAA0D;AAC1D,yCAA0C;AAC1C,0BAAkC;AAClC,6CAAkD;AAClD,mDAAqD;AACrD,2DAA6D;AAC7D,yDAA0D;AAC1D,mDAAuD;AAEvD;;;GAGG;AACH,SAAgB,cAAc;IAC5B,OAAO,IAAA,gBAAY,EAAC;QAClB,CAAC,mBAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,yBAAiB,CAAC;QACnD,CAAC,mBAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,qBAAa,CAAC;QAC3C,CAAC,mBAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,uBAAe,CAAC;QAC/C,CAAC,mBAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,mBAAW,CAAC;KACxC,CAAC,CAAC;AACL,CAAC;AAPD,wCAOC;AAEM,MAAM,iBAAiB,GAAyB,OAAO,CAAC,EAAE;IAC/D,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAU,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,IAAA,8BAAgB,EAAC,MAAM,CAAC,CAAC;AAClC,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B;AAEK,MAAM,aAAa,GAA4D,OAAO,CAAC,EAAE;IAC9F,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,mBAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;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AAC,MAAM,EAAE;aAClB,MAAM,CAAC,MAAM,MAAM,CAAC,MAAM,OAAO,EAAE,CAAC,CAAC;aACrC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;aACjB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;aAClB,MAAM,CAAC,oBAAY,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;aAC9C,QAAQ,CAAC,QAAQ,CAAC;aAClB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,WAAW,eAgBtB;AAEF,SAAgB,eAAe,CAAC,UAA6B;IAC3D,OAAO,SAAS,QAAQ,CAAC,OAAgB;QACvC,MAAM,MAAM,GAAG,OAAO,CAAC,yBAAW,CAAC,IAAI,CAAC,CAAC;QAEzC,OAAO,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI;YACpC,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;YAEzB,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACnB,GAAG,CAAC,IAAI,CAAC,mBAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;YAClE,GAAG,CAAC,GAAG,CAAC,mBAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAZD,0CAYC"}
@@ -2,6 +2,6 @@ import type { Application } from '../container/application';
2
2
  import type { Token, Provider } from '../container/types';
3
3
  export declare type PresetEntry<T = any> = [Token<T>, Provider<T>];
4
4
  export interface Preset {
5
- override: <T>(token: Token<T>, provider: Provider<T>) => void;
6
- apply: (application: Application) => void;
5
+ override: <T>(token: Token<T>, provider: Provider<T>) => this;
6
+ apply: (app: Application) => void;
7
7
  }
File without changes
File without changes
File without changes
@@ -34,7 +34,9 @@ const utils_1 = require("../error-tracker/utils");
34
34
  function createSagaRunner(logger) {
35
35
  const middleware = (0, redux_saga_1.default)({
36
36
  onError: (error, { sagaStack }) => {
37
- logger.error(new utils_1.SentryError(error.message, {
37
+ logger.error(
38
+ // @todo убрать отсюда упоминание sentry, вынести в провайдер, возможно заменить аргумент logger на onError
39
+ new utils_1.SentryError(error.message, {
38
40
  extra: { key: 'Saga stack', data: sagaStack },
39
41
  }));
40
42
  },
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/saga-runner/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,yDAA6D;AAC7D,kDAAqD;AAErD;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,MAAc;IAC7C,MAAM,UAAU,GAAG,IAAA,oBAAoB,EAAC;QACtC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;YAChC,MAAM,CAAC,KAAK;YACV,2GAA2G;YAC3G,IAAI,mBAAW,CAAC,KAAK,CAAC,OAAO,EAAE;gBAC7B,KAAK,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE;aAC9C,CAAC,CACH,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,UAAU;QAEV,8DAA8D;QAC9D,OAAO,CAAC,KAAY,EAAE,EAAE,OAAO,KAA2B,EAAE;YAC1D,OAAO;gBACL,8DAA8D;gBAC9D,KAAK,CAAC,GAAG,CAAiB,IAAO,EAAE,GAAG,IAAmB;oBACvD,IAAI,KAAK,GAAG,KAAK,CAAC;oBAElB,MAAM,OAAO,CAAC,IAAI,CAAC;wBACjB,4BAA4B;wBAC5B,UAAU;6BACP,GAAG,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC;6BAClB,SAAS,EAAE;6BACX,IAAI,CAAC,GAAG,EAAE;4BACT,KAAK,GAAG,IAAI,CAAC;wBACf,CAAC,CAAC;wBAEJ,2DAA2D;wBAC3D,OAAO,OAAO,KAAK,QAAQ;4BACzB,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;4BACxB,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE;gCAC1B,UAAU,CAAC,GAAG,EAAE;oCACd,IAAI,CAAC,KAAK,EAAE;wCACV,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;wCACjD,KAAK,CAAC,QAAQ,CAAC,gBAAG,CAAC,CAAC;qCACrB;oCACD,OAAO,EAAE,CAAC;gCACZ,CAAC,EAAE,OAAO,CAAC,CAAC;4BACd,CAAC,CAAC;qBACL,CAAC,CAAC;gBACL,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAhDD,4CAgDC"}
File without changes
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { Application } from 'express';
3
- import type { DefaultMiddleware, PageAssets, ResponseContext } from './http-server/types';
3
+ import type { DefaultMiddleware, PageAssets, PageTemplate, ResponseContext } from './http-server/types';
4
4
  import type { SagaRunner } from './saga-runner/types';
5
5
  import type { Logger } from './logger/types';
6
6
  import type { HttpClientFactory } from './http-client/types';
@@ -30,6 +30,7 @@ export declare const KnownToken: {
30
30
  };
31
31
  };
32
32
  readonly Response: {
33
+ readonly template: import("./container/types").Token<PageTemplate>;
33
34
  readonly context: import("./container/types").Token<ResponseContext>;
34
35
  readonly assets: import("./container/types").Token<PageAssets>;
35
36
  readonly prepare: import("./container/types").Token<() => JSX.Element | Promise<JSX.Element>>;
@@ -32,6 +32,7 @@ exports.KnownToken = {
32
32
  },
33
33
  // scope: page response
34
34
  Response: {
35
+ template: (0, container_1.createToken)('response/template'),
35
36
  context: (0, container_1.createToken)('response/context'),
36
37
  assets: (0, container_1.createToken)('response/assets'),
37
38
  prepare: (0, container_1.createToken)('response/prepare'),