@celljs/mvc 3.8.0 → 3.9.0

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 (143) hide show
  1. package/esm/common/constants.d.ts +1 -0
  2. package/esm/common/constants.js +2 -0
  3. package/esm/common/constants.js.map +1 -0
  4. package/esm/common/index.d.ts +1 -0
  5. package/esm/common/index.js +2 -0
  6. package/esm/common/index.js.map +1 -0
  7. package/esm/node/annotation/body.d.ts +6 -0
  8. package/esm/node/annotation/body.js +15 -0
  9. package/esm/node/annotation/body.js.map +1 -0
  10. package/esm/node/annotation/catch.d.ts +9 -0
  11. package/esm/node/annotation/catch.js +18 -0
  12. package/esm/node/annotation/catch.js.map +1 -0
  13. package/esm/node/annotation/controller.d.ts +14 -0
  14. package/esm/node/annotation/controller.js +29 -0
  15. package/esm/node/annotation/controller.js.map +1 -0
  16. package/esm/node/annotation/cookie.d.ts +15 -0
  17. package/esm/node/annotation/cookie.js +24 -0
  18. package/esm/node/annotation/cookie.js.map +1 -0
  19. package/esm/node/annotation/file.d.ts +2 -0
  20. package/esm/node/annotation/file.js +6 -0
  21. package/esm/node/annotation/file.js.map +1 -0
  22. package/esm/node/annotation/header.d.ts +15 -0
  23. package/esm/node/annotation/header.js +24 -0
  24. package/esm/node/annotation/header.js.map +1 -0
  25. package/esm/node/annotation/html.d.ts +2 -0
  26. package/esm/node/annotation/html.js +6 -0
  27. package/esm/node/annotation/html.js.map +1 -0
  28. package/esm/node/annotation/index.d.ts +16 -0
  29. package/esm/node/annotation/index.js +17 -0
  30. package/esm/node/annotation/index.js.map +1 -0
  31. package/esm/node/annotation/json.d.ts +2 -0
  32. package/esm/node/annotation/json.js +6 -0
  33. package/esm/node/annotation/json.js.map +1 -0
  34. package/esm/node/annotation/method.d.ts +23 -0
  35. package/esm/node/annotation/method.js +42 -0
  36. package/esm/node/annotation/method.js.map +1 -0
  37. package/esm/node/annotation/param.d.ts +6 -0
  38. package/esm/node/annotation/param.js +15 -0
  39. package/esm/node/annotation/param.js.map +1 -0
  40. package/esm/node/annotation/query.d.ts +6 -0
  41. package/esm/node/annotation/query.js +15 -0
  42. package/esm/node/annotation/query.js.map +1 -0
  43. package/esm/node/annotation/req.d.ts +5 -0
  44. package/esm/node/annotation/req.js +13 -0
  45. package/esm/node/annotation/req.js.map +1 -0
  46. package/esm/node/annotation/res.d.ts +5 -0
  47. package/esm/node/annotation/res.js +13 -0
  48. package/esm/node/annotation/res.js.map +1 -0
  49. package/esm/node/annotation/session.d.ts +15 -0
  50. package/esm/node/annotation/session.js +24 -0
  51. package/esm/node/annotation/session.js.map +1 -0
  52. package/esm/node/annotation/text.d.ts +2 -0
  53. package/esm/node/annotation/text.js +6 -0
  54. package/esm/node/annotation/text.js.map +1 -0
  55. package/esm/node/annotation/view.d.ts +12 -0
  56. package/esm/node/annotation/view.js +10 -0
  57. package/esm/node/annotation/view.js.map +1 -0
  58. package/esm/node/constants.d.ts +17 -0
  59. package/esm/node/constants.js +18 -0
  60. package/esm/node/constants.js.map +1 -0
  61. package/esm/node/error/error-handler.d.ts +9 -0
  62. package/esm/node/error/error-handler.js +39 -0
  63. package/esm/node/error/error-handler.js.map +1 -0
  64. package/esm/node/error/index.d.ts +1 -0
  65. package/esm/node/error/index.js +2 -0
  66. package/esm/node/error/index.js.map +1 -0
  67. package/esm/node/handler/handler-adapter.d.ts +21 -0
  68. package/esm/node/handler/handler-adapter.js +119 -0
  69. package/esm/node/handler/handler-adapter.js.map +1 -0
  70. package/esm/node/handler/handler-protocol.d.ts +37 -0
  71. package/esm/node/handler/handler-protocol.js +4 -0
  72. package/esm/node/handler/handler-protocol.js.map +1 -0
  73. package/esm/node/handler/index.d.ts +5 -0
  74. package/esm/node/handler/index.js +6 -0
  75. package/esm/node/handler/index.js.map +1 -0
  76. package/esm/node/handler/route-builder.d.ts +28 -0
  77. package/esm/node/handler/route-builder.js +122 -0
  78. package/esm/node/handler/route-builder.js.map +1 -0
  79. package/esm/node/handler/route-metadata-matcher.d.ts +8 -0
  80. package/esm/node/handler/route-metadata-matcher.js +57 -0
  81. package/esm/node/handler/route-metadata-matcher.js.map +1 -0
  82. package/esm/node/handler/route-provider.d.ts +10 -0
  83. package/esm/node/handler/route-provider.js +41 -0
  84. package/esm/node/handler/route-provider.js.map +1 -0
  85. package/esm/node/index.d.ts +5 -0
  86. package/esm/node/index.js +6 -0
  87. package/esm/node/index.js.map +1 -0
  88. package/esm/node/module.d.ts +3 -0
  89. package/esm/node/module.js +4 -0
  90. package/esm/node/module.js.map +1 -0
  91. package/esm/node/resolver/index.d.ts +7 -0
  92. package/esm/node/resolver/index.js +8 -0
  93. package/esm/node/resolver/index.js.map +1 -0
  94. package/esm/node/resolver/method-args-resolver-provider.d.ts +7 -0
  95. package/esm/node/resolver/method-args-resolver-provider.js +32 -0
  96. package/esm/node/resolver/method-args-resolver-provider.js.map +1 -0
  97. package/esm/node/resolver/method-args-resolver.d.ts +34 -0
  98. package/esm/node/resolver/method-args-resolver.js +149 -0
  99. package/esm/node/resolver/method-args-resolver.js.map +1 -0
  100. package/esm/node/resolver/resolver-protocol.d.ts +14 -0
  101. package/esm/node/resolver/resolver-protocol.js +4 -0
  102. package/esm/node/resolver/resolver-protocol.js.map +1 -0
  103. package/esm/node/resolver/response-resolver-provider.d.ts +7 -0
  104. package/esm/node/resolver/response-resolver-provider.js +32 -0
  105. package/esm/node/resolver/response-resolver-provider.js.map +1 -0
  106. package/esm/node/resolver/response-resolver.d.ts +13 -0
  107. package/esm/node/resolver/response-resolver.js +64 -0
  108. package/esm/node/resolver/response-resolver.js.map +1 -0
  109. package/esm/node/resolver/view-resolver-provider.d.ts +7 -0
  110. package/esm/node/resolver/view-resolver-provider.js +32 -0
  111. package/esm/node/resolver/view-resolver-provider.js.map +1 -0
  112. package/esm/node/resolver/view-resolver.d.ts +7 -0
  113. package/esm/node/resolver/view-resolver.js +41 -0
  114. package/esm/node/resolver/view-resolver.js.map +1 -0
  115. package/esm/node/view/file-view.d.ts +17 -0
  116. package/esm/node/view/file-view.js +81 -0
  117. package/esm/node/view/file-view.js.map +1 -0
  118. package/esm/node/view/html-view.d.ts +10 -0
  119. package/esm/node/view/html-view.js +50 -0
  120. package/esm/node/view/html-view.js.map +1 -0
  121. package/esm/node/view/index.d.ts +6 -0
  122. package/esm/node/view/index.js +7 -0
  123. package/esm/node/view/index.js.map +1 -0
  124. package/esm/node/view/json-view-template-renderer.d.ts +5 -0
  125. package/esm/node/view/json-view-template-renderer.js +36 -0
  126. package/esm/node/view/json-view-template-renderer.js.map +1 -0
  127. package/esm/node/view/json-view.d.ts +10 -0
  128. package/esm/node/view/json-view.js +36 -0
  129. package/esm/node/view/json-view.js.map +1 -0
  130. package/esm/node/view/text-view.d.ts +9 -0
  131. package/esm/node/view/text-view.js +29 -0
  132. package/esm/node/view/text-view.js.map +1 -0
  133. package/esm/node/view/view-protocol.d.ts +11 -0
  134. package/esm/node/view/view-protocol.js +3 -0
  135. package/esm/node/view/view-protocol.js.map +1 -0
  136. package/esm/node/view/view-provider.d.ts +7 -0
  137. package/esm/node/view/view-provider.js +32 -0
  138. package/esm/node/view/view-provider.js.map +1 -0
  139. package/esm/package.json +3 -0
  140. package/lib/node/view/html-view.js +6 -3
  141. package/lib/node/view/html-view.js.map +1 -1
  142. package/package.json +61 -6
  143. package/src/node/view/html-view.ts +3 -3
@@ -0,0 +1,50 @@
1
+ import { fileURLToPath as __cellFileURLToPath } from "node:url";
2
+ import { dirname as __cellDirname } from "node:path";
3
+ const __filename = __cellFileURLToPath(import.meta.url);
4
+ const __dirname = __cellDirname(__filename);
5
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
6
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
8
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ };
11
+ var __metadata = (this && this.__metadata) || function (k, v) {
12
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
13
+ };
14
+ import { Component, Value } from '@celljs/core';
15
+ import { View } from './view-protocol.js';
16
+ import { Context } from '@celljs/web/lib/node';
17
+ import Mustache from 'mustache';
18
+ import { join } from 'path';
19
+ import __cellCjs1 from 'fs-extra';
20
+ const { readFile } = __cellCjs1;
21
+ import { HTML_VIEW_NAME } from '../annotation/html.js';
22
+ import { MediaType } from '@celljs/http';
23
+ let HtmlView = class HtmlView {
24
+ constructor() {
25
+ this.contentType = MediaType.TEXT_HTML;
26
+ this.priority = 500;
27
+ }
28
+ async render(model, { metadata }) {
29
+ const response = Context.getCurrent().response;
30
+ const { baseViewDir, cache } = this.options;
31
+ const template = await readFile(join(__dirname, baseViewDir, metadata.file), { encoding: 'utf8' });
32
+ if (cache) {
33
+ Mustache.parse(template);
34
+ }
35
+ response.body = Mustache.render(template, model);
36
+ }
37
+ support({ viewName, metadata }) {
38
+ var _a;
39
+ return Promise.resolve(viewName === HTML_VIEW_NAME && ((_a = metadata === null || metadata === void 0 ? void 0 : metadata.file) === null || _a === void 0 ? void 0 : _a.endsWith('.mustache')));
40
+ }
41
+ };
42
+ __decorate([
43
+ Value('cell.mustache'),
44
+ __metadata("design:type", Object)
45
+ ], HtmlView.prototype, "options", void 0);
46
+ HtmlView = __decorate([
47
+ Component(View)
48
+ ], HtmlView);
49
+ export { HtmlView };
50
+ //# sourceMappingURL=html-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-view.js","sourceRoot":"","sources":["../../../src/node/view/html-view.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;A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,CAAC,eAAe,CAAC;;yCACS;AAPvB,QAAQ;IADpB,SAAS,CAAC,IAAI,CAAC;GACH,QAAQ,CAsBpB"}
@@ -0,0 +1,6 @@
1
+ export * from './json-view.js';
2
+ export * from './text-view.js';
3
+ export * from './view-provider.js';
4
+ export * from './html-view.js';
5
+ export * from './file-view.js';
6
+ export * from './json-view-template-renderer.js';
@@ -0,0 +1,7 @@
1
+ export * from './json-view.js';
2
+ export * from './text-view.js';
3
+ export * from './view-provider.js';
4
+ export * from './html-view.js';
5
+ export * from './file-view.js';
6
+ export * from './json-view-template-renderer.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/view/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,+BAA+B,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { JsonViewTemplateRenderer } from './view-protocol.js';
2
+ export declare class JsonViewTemplateRendererImpl implements JsonViewTemplateRenderer {
3
+ protected readonly jsonViewTemplate?: string;
4
+ render(model?: any, error?: Error): Promise<string>;
5
+ }
@@ -0,0 +1,36 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Component, Value } from '@celljs/core';
11
+ import { JsonViewTemplateRenderer } from './view-protocol.js';
12
+ let JsonViewTemplateRendererImpl = class JsonViewTemplateRendererImpl {
13
+ async render(model, error) {
14
+ var _a, _b, _c;
15
+ if (this.jsonViewTemplate) {
16
+ return this.jsonViewTemplate
17
+ .replace('{{model}}', JSON.stringify(model))
18
+ .replace('{{error}}', (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '')
19
+ .replace('{{success}}', error ? 'false' : 'true')
20
+ .replace('{{code}}', (_c = (_b = error === null || error === void 0 ? void 0 : error.code) !== null && _b !== void 0 ? _b : error === null || error === void 0 ? void 0 : error.statusCode) !== null && _c !== void 0 ? _c : '');
21
+ }
22
+ if (error) {
23
+ throw error;
24
+ }
25
+ return JSON.stringify(model);
26
+ }
27
+ };
28
+ __decorate([
29
+ Value('cell.mvc.jsonView.template'),
30
+ __metadata("design:type", String)
31
+ ], JsonViewTemplateRendererImpl.prototype, "jsonViewTemplate", void 0);
32
+ JsonViewTemplateRendererImpl = __decorate([
33
+ Component(JsonViewTemplateRenderer)
34
+ ], JsonViewTemplateRendererImpl);
35
+ export { JsonViewTemplateRendererImpl };
36
+ //# sourceMappingURL=json-view-template-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-view-template-renderer.js","sourceRoot":"","sources":["../../../src/node/view/json-view-template-renderer.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAKrC,KAAK,CAAC,MAAM,CAAC,KAAW,EAAE,KAAa;;QACnC,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,gBAAgB;iBACvB,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;iBAC3C,OAAO,CAAC,WAAW,QAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,EAAE,CAAC;iBAC1C,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;iBAChD,OAAO,CAAC,UAAU,cAAG,KAAa,aAAb,KAAK,uBAAL,KAAK,CAAU,IAAI,mCAAK,KAAa,aAAb,KAAK,uBAAL,KAAK,CAAU,UAAU,mCAAI,EAAE,CAAC,CAAC;QACvF,CAAC;QACD,IAAI,KAAK,EAAE,CAAC;YACR,MAAM,KAAK,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;CACJ,CAAA;AAfsB;IADlB,KAAK,CAAC,4BAA4B,CAAC;;sEACS;AAHpC,4BAA4B;IADxC,SAAS,CAAC,wBAAwB,CAAC;GACvB,4BAA4B,CAkBxC"}
@@ -0,0 +1,10 @@
1
+ import { JsonViewTemplateRenderer, View } from './view-protocol.js';
2
+ import { ViewMetadata } from '../annotation/view.js';
3
+ import { MediaType } from '@celljs/http';
4
+ export declare class JsonView implements View {
5
+ readonly contentType = MediaType.APPLICATION_JSON_UTF8;
6
+ readonly priority = 500;
7
+ protected readonly jsonViewTemplateRenderer: JsonViewTemplateRenderer;
8
+ render(model: any, metadata: ViewMetadata): Promise<void>;
9
+ support({ viewName }: ViewMetadata): Promise<boolean>;
10
+ }
@@ -0,0 +1,36 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Autowired, Component } from '@celljs/core';
11
+ import { JsonViewTemplateRenderer, View } from './view-protocol.js';
12
+ import { Context } from '@celljs/web/lib/node';
13
+ import { JSON_VIEW_NAME } from '../annotation/json.js';
14
+ import { MediaType } from '@celljs/http';
15
+ let JsonView = class JsonView {
16
+ constructor() {
17
+ this.contentType = MediaType.APPLICATION_JSON_UTF8;
18
+ this.priority = 500;
19
+ }
20
+ async render(model, metadata) {
21
+ const response = Context.getCurrent().response;
22
+ response.body = await this.jsonViewTemplateRenderer.render(model);
23
+ }
24
+ support({ viewName }) {
25
+ return Promise.resolve(viewName === JSON_VIEW_NAME);
26
+ }
27
+ };
28
+ __decorate([
29
+ Autowired(JsonViewTemplateRenderer),
30
+ __metadata("design:type", Object)
31
+ ], JsonView.prototype, "jsonViewTemplateRenderer", void 0);
32
+ JsonView = __decorate([
33
+ Component(View)
34
+ ], JsonView);
35
+ export { JsonView };
36
+ //# sourceMappingURL=json-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-view.js","sourceRoot":"","sources":["../../../src/node/view/json-view.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGlC,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAAd;QAEM,gBAAW,GAAG,SAAS,CAAC,qBAAqB,CAAC;QAE9C,aAAQ,GAAG,GAAG,CAAC;IAa5B,CAAC;IARG,KAAK,CAAC,MAAM,CAAC,KAAU,EAAE,QAAsB;QAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC;QAC/C,QAAQ,CAAC,IAAI,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,CAAC,EAAE,QAAQ,EAAgB;QAC9B,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,cAAc,CAAC,CAAC;IACxD,CAAC;CACJ,CAAA;AAVsB;IADlB,SAAS,CAAC,wBAAwB,CAAC;;0DACkC;AAP7D,QAAQ;IADpB,SAAS,CAAC,IAAI,CAAC;GACH,QAAQ,CAiBpB"}
@@ -0,0 +1,9 @@
1
+ import { View } from './view-protocol.js';
2
+ import { ViewMetadata } from '../annotation/view.js';
3
+ import { MediaType } from '@celljs/http';
4
+ export declare class TextView implements View {
5
+ readonly contentType = MediaType.TEXT_PLAIN;
6
+ readonly priority = 600;
7
+ render(model: any, metadata: ViewMetadata): Promise<void>;
8
+ support({ viewName }: ViewMetadata): Promise<boolean>;
9
+ }
@@ -0,0 +1,29 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Component } from '@celljs/core';
8
+ import { View } from './view-protocol.js';
9
+ import { Context } from '@celljs/web/lib/node';
10
+ import { TEXT_VIEW_NAME } from '../annotation/text.js';
11
+ import { MediaType } from '@celljs/http';
12
+ let TextView = class TextView {
13
+ constructor() {
14
+ this.contentType = MediaType.TEXT_PLAIN;
15
+ this.priority = 600;
16
+ }
17
+ async render(model, metadata) {
18
+ const response = Context.getCurrent().response;
19
+ response.body = model;
20
+ }
21
+ support({ viewName }) {
22
+ return Promise.resolve(viewName === TEXT_VIEW_NAME);
23
+ }
24
+ };
25
+ TextView = __decorate([
26
+ Component(View)
27
+ ], TextView);
28
+ export { TextView };
29
+ //# sourceMappingURL=text-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-view.js","sourceRoot":"","sources":["../../../src/node/view/text-view.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGlC,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAAd;QAEM,gBAAW,GAAG,SAAS,CAAC,UAAU,CAAC;QAEnC,aAAQ,GAAG,GAAG,CAAC;IAU5B,CAAC;IARG,KAAK,CAAC,MAAM,CAAC,KAAU,EAAE,QAAsB;QAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC;QAC/C,QAAQ,CAAC,IAAI,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED,OAAO,CAAC,EAAE,QAAQ,EAAgB;QAC9B,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,cAAc,CAAC,CAAC;IACxD,CAAC;CACJ,CAAA;AAdY,QAAQ;IADpB,SAAS,CAAC,IAAI,CAAC;GACH,QAAQ,CAcpB"}
@@ -0,0 +1,11 @@
1
+ import { ViewMetadata } from '../annotation/view.js';
2
+ export declare const View: unique symbol;
3
+ export declare const JsonViewTemplateRenderer: unique symbol;
4
+ export interface View {
5
+ readonly contentType: string;
6
+ render(model: any, metadata: ViewMetadata): Promise<void>;
7
+ support(metadata: ViewMetadata): Promise<boolean>;
8
+ }
9
+ export interface JsonViewTemplateRenderer {
10
+ render(model?: any, error?: Error): Promise<string>;
11
+ }
@@ -0,0 +1,3 @@
1
+ export const View = Symbol('View');
2
+ export const JsonViewTemplateRenderer = Symbol('JsonViewTemplateRenderer');
3
+ //# sourceMappingURL=view-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-protocol.js","sourceRoot":"","sources":["../../../src/node/view/view-protocol.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AACnC,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,0BAA0B,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { View } from './view-protocol.js';
2
+ export declare class ViewProvider {
3
+ protected readonly views: View[];
4
+ protected prioritized: View[];
5
+ constructor(views: View[]);
6
+ provide(): View[];
7
+ }
@@ -0,0 +1,32 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { Component, Autowired, Prioritizeable } from '@celljs/core';
14
+ import { View } from './view-protocol.js';
15
+ let ViewProvider = class ViewProvider {
16
+ constructor(views) {
17
+ this.views = views;
18
+ }
19
+ provide() {
20
+ if (!this.prioritized) {
21
+ this.prioritized = Prioritizeable.prioritizeAllSync(this.views).map(c => c.value);
22
+ }
23
+ return this.prioritized;
24
+ }
25
+ };
26
+ ViewProvider = __decorate([
27
+ Component(),
28
+ __param(0, Autowired(View)),
29
+ __metadata("design:paramtypes", [Array])
30
+ ], ViewProvider);
31
+ export { ViewProvider };
32
+ //# sourceMappingURL=view-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-provider.js","sourceRoot":"","sources":["../../../src/node/view/view-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGhC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAIrB,YAEuB,KAAa;qBAAb,KAAK;IACxB,CAAC;IAEL,OAAO;QACH,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACpB,IAAI,CAAC,WAAW,GAAG,cAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACtF,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;CAEJ,CAAA;AAhBY,YAAY;IADxB,SAAS,EAAE;IAMH,WAAA,SAAS,CAAC,IAAI,CAAC,CAAA;;GALX,YAAY,CAgBxB"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -8,12 +8,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.HtmlView = void 0;
13
16
  const core_1 = require("@celljs/core");
14
17
  const view_protocol_1 = require("./view-protocol");
15
18
  const node_1 = require("@celljs/web/lib/node");
16
- const mustache_1 = require("mustache");
19
+ const mustache_1 = __importDefault(require("mustache"));
17
20
  const path_1 = require("path");
18
21
  const fs_extra_1 = require("fs-extra");
19
22
  const html_1 = require("../annotation/html");
@@ -28,9 +31,9 @@ let HtmlView = class HtmlView {
28
31
  const { baseViewDir, cache } = this.options;
29
32
  const template = await (0, fs_extra_1.readFile)((0, path_1.join)(__dirname, baseViewDir, metadata.file), { encoding: 'utf8' });
30
33
  if (cache) {
31
- (0, mustache_1.parse)(template);
34
+ mustache_1.default.parse(template);
32
35
  }
33
- response.body = (0, mustache_1.render)(template, model);
36
+ response.body = mustache_1.default.render(template, model);
34
37
  }
35
38
  support({ viewName, metadata }) {
36
39
  var _a;
@@ -1 +1 @@
1
- {"version":3,"file":"html-view.js","sourceRoot":"","sources":["../../../src/node/view/html-view.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAgD;AAChD,mDAAuC;AACvC,+CAA+C;AAC/C,uCAAyC;AACzC,+BAA4B;AAC5B,uCAAoC;AAEpC,6CAAoD;AACpD,uCAAyC;AAGlC,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAAd;QAEM,gBAAW,GAAG,gBAAS,CAAC,SAAS,CAAC;QAElC,aAAQ,GAAG,GAAG,CAAC;IAkB5B,CAAC;IAbG,KAAK,CAAC,MAAM,CAAC,KAAU,EAAE,EAAE,QAAQ,EAAgB;QAC/C,MAAM,QAAQ,GAAG,cAAO,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC;QAC/C,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,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,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,WAAW,EAAE,QAAS,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QACpG,IAAI,KAAK,EAAE,CAAC;YACR,kBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC;QACD,QAAQ,CAAC,IAAI,GAAG,kBAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAgB;;QACxC,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,qBAAc,KAAI,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,0CAAE,QAAQ,CAAC,WAAW,CAAC,CAAA,CAAC,CAAC;IACjG,CAAC;CACJ,CAAA;;AAfsB;IADlB,IAAA,YAAK,EAAC,eAAe,CAAC;;yCACS;mBAPvB,QAAQ;IADpB,IAAA,gBAAS,EAAC,oBAAI,CAAC;GACH,QAAQ,CAsBpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/mvc",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "cell-component"
@@ -18,19 +18,20 @@
18
18
  "typings": "lib/common/index.d.ts",
19
19
  "files": [
20
20
  "lib",
21
+ "esm",
21
22
  "src",
22
23
  "cell.yml"
23
24
  ],
24
25
  "scripts": {
25
- "build": "tsc -b",
26
- "clean": "rm -rf lib *.tsbuildinfo",
26
+ "build": "tsc -b && bun ../../scripts/build-esm.ts",
27
+ "clean": "rm -rf lib esm *.tsbuildinfo",
27
28
  "test": "bun test --preload reflect-metadata ./lib",
28
29
  "watch": "tsc -b -w --preserveWatchOutput"
29
30
  },
30
31
  "dependencies": {
31
- "@celljs/core": "3.8.0",
32
- "@celljs/http": "3.8.0",
33
- "@celljs/web": "3.8.0",
32
+ "@celljs/core": "3.9.0",
33
+ "@celljs/http": "3.9.0",
34
+ "@celljs/web": "3.9.0",
34
35
  "fs-extra": "^11.1.1",
35
36
  "mustache": "^4.2.0",
36
37
  "reflect-metadata": "^0.1.13",
@@ -41,5 +42,59 @@
41
42
  },
42
43
  "publishConfig": {
43
44
  "access": "public"
45
+ },
46
+ "exports": {
47
+ ".": {
48
+ "webpack": "./lib/common/index.js",
49
+ "import": "./esm/common/index.js",
50
+ "default": "./lib/common/index.js"
51
+ },
52
+ "./package.json": "./package.json",
53
+ "./lib/common": {
54
+ "webpack": "./lib/common/index.js",
55
+ "import": "./esm/common/index.js",
56
+ "default": "./lib/common/index.js"
57
+ },
58
+ "./lib/node": {
59
+ "webpack": "./lib/node/index.js",
60
+ "import": "./esm/node/index.js",
61
+ "default": "./lib/node/index.js"
62
+ },
63
+ "./lib/node/annotation": {
64
+ "webpack": "./lib/node/annotation/index.js",
65
+ "import": "./esm/node/annotation/index.js",
66
+ "default": "./lib/node/annotation/index.js"
67
+ },
68
+ "./lib/node/error": {
69
+ "webpack": "./lib/node/error/index.js",
70
+ "import": "./esm/node/error/index.js",
71
+ "default": "./lib/node/error/index.js"
72
+ },
73
+ "./lib/node/handler": {
74
+ "webpack": "./lib/node/handler/index.js",
75
+ "import": "./esm/node/handler/index.js",
76
+ "default": "./lib/node/handler/index.js"
77
+ },
78
+ "./lib/node/resolver": {
79
+ "webpack": "./lib/node/resolver/index.js",
80
+ "import": "./esm/node/resolver/index.js",
81
+ "default": "./lib/node/resolver/index.js"
82
+ },
83
+ "./lib/node/view": {
84
+ "webpack": "./lib/node/view/index.js",
85
+ "import": "./esm/node/view/index.js",
86
+ "default": "./lib/node/view/index.js"
87
+ },
88
+ "./lib/*.js": {
89
+ "webpack": "./lib/*.js",
90
+ "import": "./esm/*.js",
91
+ "default": "./lib/*.js"
92
+ },
93
+ "./lib/*": {
94
+ "webpack": "./lib/*.js",
95
+ "import": "./esm/*.js",
96
+ "default": "./lib/*.js"
97
+ },
98
+ "./*": "./*"
44
99
  }
45
100
  }
@@ -1,7 +1,7 @@
1
1
  import { Component, Value } from '@celljs/core';
2
2
  import { View } from './view-protocol';
3
3
  import { Context } from '@celljs/web/lib/node';
4
- import { parse, render } from 'mustache';
4
+ import Mustache from 'mustache';
5
5
  import { join } from 'path';
6
6
  import { readFile } from 'fs-extra';
7
7
  import { ViewMetadata } from '../annotation/view';
@@ -23,9 +23,9 @@ export class HtmlView implements View {
23
23
  const { baseViewDir, cache } = this.options;
24
24
  const template = await readFile(join(__dirname, baseViewDir, metadata!.file), { encoding: 'utf8' });
25
25
  if (cache) {
26
- parse(template);
26
+ Mustache.parse(template);
27
27
  }
28
- response.body = render(template, model);
28
+ response.body = Mustache.render(template, model);
29
29
  }
30
30
 
31
31
  support({ viewName, metadata }: ViewMetadata): Promise<boolean> {