@tsed/vike 7.61.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 (53) hide show
  1. package/.eslintignore +13 -0
  2. package/.eslintrc.js +1 -0
  3. package/jest.config.js +17 -0
  4. package/lib/cjs/ViteModule.js +55 -0
  5. package/lib/cjs/ViteModule.js.map +1 -0
  6. package/lib/cjs/decorators/vite.js +9 -0
  7. package/lib/cjs/decorators/vite.js.map +1 -0
  8. package/lib/cjs/index.js +15 -0
  9. package/lib/cjs/index.js.map +1 -0
  10. package/lib/cjs/interfaces/ViteConfig.js +3 -0
  11. package/lib/cjs/interfaces/ViteConfig.js.map +1 -0
  12. package/lib/cjs/interfaces/ViteRenderContext.js +3 -0
  13. package/lib/cjs/interfaces/ViteRenderContext.js.map +1 -0
  14. package/lib/cjs/interfaces/interfaces.js +3 -0
  15. package/lib/cjs/interfaces/interfaces.js.map +1 -0
  16. package/lib/cjs/middlewares/ViteRendererMiddleware.js +29 -0
  17. package/lib/cjs/middlewares/ViteRendererMiddleware.js.map +1 -0
  18. package/lib/cjs/package.json +3 -0
  19. package/lib/cjs/services/ViteServer.js +43 -0
  20. package/lib/cjs/services/ViteServer.js.map +1 -0
  21. package/lib/cjs/services/ViteService.js +67 -0
  22. package/lib/cjs/services/ViteService.js.map +1 -0
  23. package/lib/esm/ViteModule.js +51 -0
  24. package/lib/esm/ViteModule.js.map +1 -0
  25. package/lib/esm/decorators/vite.js +5 -0
  26. package/lib/esm/decorators/vite.js.map +1 -0
  27. package/lib/esm/index.js +12 -0
  28. package/lib/esm/index.js.map +1 -0
  29. package/lib/esm/interfaces/ViteConfig.js +2 -0
  30. package/lib/esm/interfaces/ViteConfig.js.map +1 -0
  31. package/lib/esm/interfaces/ViteRenderContext.js +2 -0
  32. package/lib/esm/interfaces/ViteRenderContext.js.map +1 -0
  33. package/lib/esm/interfaces/interfaces.js +2 -0
  34. package/lib/esm/interfaces/interfaces.js.map +1 -0
  35. package/lib/esm/middlewares/ViteRendererMiddleware.js +26 -0
  36. package/lib/esm/middlewares/ViteRendererMiddleware.js.map +1 -0
  37. package/lib/esm/package.json +3 -0
  38. package/lib/esm/services/ViteServer.js +40 -0
  39. package/lib/esm/services/ViteServer.js.map +1 -0
  40. package/lib/esm/services/ViteService.js +64 -0
  41. package/lib/esm/services/ViteService.js.map +1 -0
  42. package/lib/types/ViteModule.d.ts +13 -0
  43. package/lib/types/decorators/vite.d.ts +1 -0
  44. package/lib/types/index.d.ts +11 -0
  45. package/lib/types/interfaces/ViteConfig.d.ts +7 -0
  46. package/lib/types/interfaces/ViteRenderContext.d.ts +14 -0
  47. package/lib/types/interfaces/interfaces.d.ts +8 -0
  48. package/lib/types/middlewares/ViteRendererMiddleware.d.ts +6 -0
  49. package/lib/types/services/ViteServer.d.ts +3 -0
  50. package/lib/types/services/ViteService.d.ts +14 -0
  51. package/package.json +58 -0
  52. package/readme.md +70 -0
  53. package/tsconfig.esm.json +42 -0
package/.eslintignore ADDED
@@ -0,0 +1,13 @@
1
+ node_modules
2
+ docs
3
+ docs-references
4
+ lib
5
+ dist
6
+ coverage
7
+ .nyc_output
8
+ *-lock.json
9
+ *.lock
10
+ benchmarks.*
11
+ **/generated
12
+
13
+ **/*.js
package/.eslintrc.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require("@tsed/eslint/node.js");
package/jest.config.js ADDED
@@ -0,0 +1,17 @@
1
+ // For a detailed explanation regarding each configuration property, visit:
2
+ // https://jestjs.io/docs/en/configuration.html
3
+
4
+ module.exports = {
5
+ ...require("@tsed/jest-config"),
6
+ moduleNameMapper: {
7
+ "@tsed/vike": "<rootDir>/src/index.ts"
8
+ },
9
+ coverageThreshold: {
10
+ global: {
11
+ statements: 100,
12
+ branches: 81.08,
13
+ functions: 100,
14
+ lines: 100
15
+ }
16
+ }
17
+ };
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ViteModule = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const common_1 = require("@tsed/common");
7
+ const di_1 = require("@tsed/di");
8
+ const platform_views_1 = require("@tsed/platform-views");
9
+ const compression_1 = tslib_1.__importDefault(require("compression"));
10
+ const ViteRendererMiddleware_1 = require("./middlewares/ViteRendererMiddleware");
11
+ const ViteServer_1 = require("./services/ViteServer");
12
+ const ViteService_1 = require("./services/ViteService");
13
+ let ViteModule = class ViteModule {
14
+ app;
15
+ platformView;
16
+ viteService;
17
+ viteServer;
18
+ $onInit() {
19
+ this.platformView.registerEngine("vite", {
20
+ options: {},
21
+ render: async (path, options) => {
22
+ return (await this.viteService.render(path, options)) || "";
23
+ }
24
+ });
25
+ }
26
+ $afterInit() {
27
+ this.app.use((0, compression_1.default)(), this.viteServer.middlewares);
28
+ }
29
+ $afterRoutesInit() {
30
+ return this.app.get("*", ViteRendererMiddleware_1.ViteRendererMiddleware);
31
+ }
32
+ };
33
+ tslib_1.__decorate([
34
+ (0, di_1.Inject)(),
35
+ tslib_1.__metadata("design:type", common_1.PlatformApplication)
36
+ ], ViteModule.prototype, "app", void 0);
37
+ tslib_1.__decorate([
38
+ (0, di_1.Inject)(),
39
+ tslib_1.__metadata("design:type", platform_views_1.PlatformViews)
40
+ ], ViteModule.prototype, "platformView", void 0);
41
+ tslib_1.__decorate([
42
+ (0, di_1.Inject)(),
43
+ tslib_1.__metadata("design:type", ViteService_1.ViteService)
44
+ ], ViteModule.prototype, "viteService", void 0);
45
+ tslib_1.__decorate([
46
+ (0, di_1.Inject)(ViteServer_1.VITE_SERVER),
47
+ tslib_1.__metadata("design:type", typeof (_a = typeof ViteServer_1.VITE_SERVER !== "undefined" && ViteServer_1.VITE_SERVER) === "function" ? _a : Object)
48
+ ], ViteModule.prototype, "viteServer", void 0);
49
+ ViteModule = tslib_1.__decorate([
50
+ (0, di_1.Module)({
51
+ imports: []
52
+ })
53
+ ], ViteModule);
54
+ exports.ViteModule = ViteModule;
55
+ //# sourceM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0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Vite = void 0;
4
+ const schema_1 = require("@tsed/schema");
5
+ function Vite(path) {
6
+ return (0, schema_1.View)(`${path || "*"}.vite`);
7
+ }
8
+ exports.Vite = Vite;
9
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","sourceRoot":"","sources":["../../../src/decorators/vite.ts"],"names":[],"mappings":";;;AAAA,yCAAkC;AAElC,SAAgB,IAAI,CAAC,IAAa;IAChC,OAAO,IAAA,aAAI,EAAC,GAAG,IAAI,IAAI,GAAG,OAAO,CAAC,CAAC;AACrC,CAAC;AAFD,oBAEC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * @file Automatically generated by barrelsby.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const tslib_1 = require("tslib");
7
+ tslib_1.__exportStar(require("./ViteModule"), exports);
8
+ tslib_1.__exportStar(require("./decorators/vite"), exports);
9
+ tslib_1.__exportStar(require("./interfaces/ViteConfig"), exports);
10
+ tslib_1.__exportStar(require("./interfaces/ViteRenderContext"), exports);
11
+ tslib_1.__exportStar(require("./interfaces/interfaces"), exports);
12
+ tslib_1.__exportStar(require("./middlewares/ViteRendererMiddleware"), exports);
13
+ tslib_1.__exportStar(require("./services/ViteServer"), exports);
14
+ tslib_1.__exportStar(require("./services/ViteService"), exports);
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,uDAA6B;AAC7B,4DAAkC;AAClC,kEAAwC;AACxC,yEAA+C;AAC/C,kEAAwC;AACxC,+EAAqD;AACrD,gEAAsC;AACtC,iEAAuC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ViteConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViteConfig.js","sourceRoot":"","sources":["../../../src/interfaces/ViteConfig.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ViteRenderContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViteRenderContext.js","sourceRoot":"","sources":["../../../src/interfaces/ViteRenderContext.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ViteRendererMiddleware = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@tsed/common");
6
+ const di_1 = require("@tsed/di");
7
+ const ViteService_1 = require("../services/ViteService");
8
+ let ViteRendererMiddleware = class ViteRendererMiddleware {
9
+ viteService;
10
+ async use($ctx) {
11
+ const response = await this.viteService.render("*", { $ctx });
12
+ response && !$ctx.response.isDone() && $ctx.response.body(response);
13
+ }
14
+ };
15
+ tslib_1.__decorate([
16
+ (0, di_1.Inject)(),
17
+ tslib_1.__metadata("design:type", ViteService_1.ViteService)
18
+ ], ViteRendererMiddleware.prototype, "viteService", void 0);
19
+ tslib_1.__decorate([
20
+ tslib_1.__param(0, (0, common_1.Context)()),
21
+ tslib_1.__metadata("design:type", Function),
22
+ tslib_1.__metadata("design:paramtypes", [Object]),
23
+ tslib_1.__metadata("design:returntype", Promise)
24
+ ], ViteRendererMiddleware.prototype, "use", null);
25
+ ViteRendererMiddleware = tslib_1.__decorate([
26
+ (0, common_1.Middleware)()
27
+ ], ViteRendererMiddleware);
28
+ exports.ViteRendererMiddleware = ViteRendererMiddleware;
29
+ //# sourceMappingURL=ViteRendererMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViteRendererMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/ViteRendererMiddleware.ts"],"names":[],"mappings":";;;;AAAA,yCAAiD;AACjD,iCAAgC;AAEhC,yDAAoD;AAG7C,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAEvB,WAAW,CAAc;IAE7B,AAAN,KAAK,CAAC,GAAG,CAAY,IAAa;QAChC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,EAAC,IAAI,EAAC,CAAC,CAAC;QAE5D,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtE,CAAC;CACF,CAAA;AARC;IAAC,IAAA,WAAM,GAAE;sCACc,yBAAW;2DAAC;AAE7B;IAAK,mBAAA,IAAA,gBAAO,GAAE,CAAA;;;;iDAInB;AARU,sBAAsB;IADlC,IAAA,mBAAU,GAAE;GACA,sBAAsB,CASlC;AATY,wDAAsB"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VITE_SERVER = void 0;
4
+ const common_1 = require("@tsed/common");
5
+ const core_1 = require("@tsed/core");
6
+ const di_1 = require("@tsed/di");
7
+ exports.VITE_SERVER = Symbol.for("VITE_DEV_SERVER");
8
+ (0, di_1.registerProvider)({
9
+ provide: exports.VITE_SERVER,
10
+ deps: [di_1.Configuration, common_1.Logger],
11
+ async useAsyncFactory(settings, logger) {
12
+ const { enableStream, statics: staticsOpts = {}, ...config } = settings.get("vite", {});
13
+ const level = settings.logger.level;
14
+ if (settings.env !== core_1.Env.PROD) {
15
+ logger.info("Start Vite Dev Server 🚀...");
16
+ // @ts-ignore
17
+ const { createServer } = await import("vite");
18
+ return createServer({
19
+ ...config,
20
+ server: {
21
+ ...(config?.server || {}),
22
+ middlewareMode: true
23
+ },
24
+ logLevel: String(config.logLevel || level)
25
+ });
26
+ }
27
+ logger.info("Initialize statics vite application");
28
+ const { default: sirv } = await import("sirv");
29
+ return Promise.resolve({
30
+ middlewares: sirv(`${config.root || ""}/dist/client`, {
31
+ dotfiles: false,
32
+ ...staticsOpts,
33
+ dev: false
34
+ })
35
+ });
36
+ },
37
+ hooks: {
38
+ $onDestroy(viteDevServer) {
39
+ return viteDevServer.close && viteDevServer.close();
40
+ }
41
+ }
42
+ });
43
+ //# sourceMappingURL=ViteServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViteServer.js","sourceRoot":"","sources":["../../../src/services/ViteServer.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AACpC,qCAA+B;AAC/B,iCAAyD;AAM5C,QAAA,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAGzD,IAAA,qBAAgB,EAAC;IACf,OAAO,EAAE,mBAAW;IACpB,IAAI,EAAE,CAAC,kBAAa,EAAE,eAAM,CAAC;IAC7B,KAAK,CAAC,eAAe,CAAC,QAAuB,EAAE,MAAc;QAC3D,MAAM,EAAC,YAAY,EAAE,OAAO,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,MAAM,EAAC,GAAG,QAAQ,CAAC,GAAG,CAA4B,MAAM,EAAE,EAAE,CAAC,CAAC;QACjH,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC;QAEpC,IAAI,QAAQ,CAAC,GAAG,KAAK,UAAG,CAAC,IAAI,EAAE;YAC7B,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;YAC3C,aAAa;YACb,MAAM,EAAC,YAAY,EAAC,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;YAE5C,OAAO,YAAY,CAAC;gBAClB,GAAG,MAAM;gBACT,MAAM,EAAE;oBACN,GAAG,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC;oBACzB,cAAc,EAAE,IAAI;iBACrB;gBACD,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAQ;aAClD,CAAC,CAAC;SACJ;QAED,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QACnD,MAAM,EAAC,OAAO,EAAE,IAAI,EAAC,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;QAE7C,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,WAAW,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,cAAc,EAAE;gBACpD,QAAQ,EAAE,KAAK;gBACf,GAAG,WAAW;gBACd,GAAG,EAAE,KAAK;aACX,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IACD,KAAK,EAAE;QACL,UAAU,CAAC,aAAqC;YAC9C,OAAO,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;QACtD,CAAC;KACF;CACF,CAAC,CAAC"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var ViteService_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ViteService = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const common_1 = require("@tsed/common");
7
+ const di_1 = require("@tsed/di");
8
+ let ViteService = ViteService_1 = class ViteService {
9
+ static moduleName = "vike/server";
10
+ config;
11
+ enableStream;
12
+ async render(viewPath, { $ctx, ...opts }) {
13
+ const urlOriginal = $ctx.request.url;
14
+ const { data } = $ctx;
15
+ const view = viewPath.replace(".vite", "");
16
+ const pageProps = {
17
+ view,
18
+ ...$ctx.response.locals,
19
+ ...opts,
20
+ ...data
21
+ };
22
+ const contextProps = {
23
+ host: $ctx.request.host,
24
+ protocol: $ctx.request.protocol,
25
+ method: $ctx.request.method,
26
+ url: urlOriginal,
27
+ secure: $ctx.request.secure,
28
+ headers: $ctx.request.headers,
29
+ session: $ctx.request.session,
30
+ stateSnapshot: this.config.stateSnapshot && this.config.stateSnapshot()
31
+ };
32
+ const { renderPage } = await import(ViteService_1.moduleName);
33
+ const pageContext = await renderPage({
34
+ view,
35
+ urlOriginal,
36
+ pageProps,
37
+ contextProps
38
+ });
39
+ if (pageContext.errorWhileRendering) {
40
+ $ctx.logger.error({
41
+ event: "VITE_RENDER_ERROR",
42
+ error: pageContext.errorWhileRendering
43
+ });
44
+ }
45
+ if (pageContext.httpResponse) {
46
+ const { httpResponse } = pageContext;
47
+ $ctx.response.contentType(httpResponse.contentType).status(httpResponse.statusCode);
48
+ if (this.enableStream) {
49
+ return httpResponse;
50
+ }
51
+ return httpResponse.body;
52
+ }
53
+ }
54
+ };
55
+ tslib_1.__decorate([
56
+ (0, common_1.Constant)("vite", {}),
57
+ tslib_1.__metadata("design:type", Object)
58
+ ], ViteService.prototype, "config", void 0);
59
+ tslib_1.__decorate([
60
+ (0, common_1.Constant)("vite.enableStream", false),
61
+ tslib_1.__metadata("design:type", Boolean)
62
+ ], ViteService.prototype, "enableStream", void 0);
63
+ ViteService = ViteService_1 = tslib_1.__decorate([
64
+ (0, di_1.Injectable)()
65
+ ], ViteService);
66
+ exports.ViteService = ViteService;
67
+ //# sourceMappingURL=ViteService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViteService.js","sourceRoot":"","sources":["../../../src/services/ViteService.ts"],"names":[],"mappings":";;;;;AAAA,yCAAuD;AACvD,iCAAoC;AAM7B,IAAM,WAAW,mBAAjB,MAAM,WAAW;IACtB,MAAM,CAAC,UAAU,GAAG,aAAa,CAAC;IAGxB,MAAM,CAAa;IAGrB,YAAY,CAAU;IAE9B,KAAK,CAAC,MAAM,CACV,QAAgB,EAChB,EAAC,IAAI,EAAE,GAAG,IAAI,EAAgD;QAE9D,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAA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,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;YAEpF,IAAI,IAAI,CAAC,YAAY,EAAE;gBACrB,OAAO,YAAY,CAAC;aACrB;YAED,OAAO,YAAY,CAAC,IAAI,CAAC;SAC1B;IACH,CAAC;;AA5DD;IAAC,IAAA,iBAAQ,EAAC,MAAM,EAAE,EAAE,CAAC;;2CACQ;AAE7B;IAAC,IAAA,iBAAQ,EAAC,mBAAmB,EAAE,KAAK,CAAC;;iDACP;AAPnB,WAAW;IADvB,IAAA,eAAU,GAAE;GACA,WAAW,CAgEvB;AAhEY,kCAAW"}
@@ -0,0 +1,51 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { PlatformApplication } from "@tsed/common";
3
+ import { Inject, Module } from "@tsed/di";
4
+ import { PlatformViews } from "@tsed/platform-views";
5
+ import compress from "compression";
6
+ import { ViteRendererMiddleware } from "./middlewares/ViteRendererMiddleware.js";
7
+ import { VITE_SERVER } from "./services/ViteServer.js";
8
+ import { ViteService } from "./services/ViteService.js";
9
+ let ViteModule = class ViteModule {
10
+ app;
11
+ platformView;
12
+ viteService;
13
+ viteServer;
14
+ $onInit() {
15
+ this.platformView.registerEngine("vite", {
16
+ options: {},
17
+ render: async (path, options) => {
18
+ return (await this.viteService.render(path, options)) || "";
19
+ }
20
+ });
21
+ }
22
+ $afterInit() {
23
+ this.app.use(compress(), this.viteServer.middlewares);
24
+ }
25
+ $afterRoutesInit() {
26
+ return this.app.get("*", ViteRendererMiddleware);
27
+ }
28
+ };
29
+ __decorate([
30
+ Inject(),
31
+ __metadata("design:type", PlatformApplication)
32
+ ], ViteModule.prototype, "app", void 0);
33
+ __decorate([
34
+ Inject(),
35
+ __metadata("design:type", PlatformViews)
36
+ ], ViteModule.prototype, "platformView", void 0);
37
+ __decorate([
38
+ Inject(),
39
+ __metadata("design:type", ViteService)
40
+ ], ViteModule.prototype, "viteService", void 0);
41
+ __decorate([
42
+ Inject(VITE_SERVER),
43
+ __metadata("design:type", Object)
44
+ ], ViteModule.prototype, "viteServer", void 0);
45
+ ViteModule = __decorate([
46
+ Module({
47
+ imports: []
48
+ })
49
+ ], ViteModule);
50
+ export { ViteModule };
51
+ //# sourceMappingURL=ViteModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViteModule.js","sourceRoot":"","sources":["../../src/ViteModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,cAAc,CAAC;AACjD,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AACxC,OAAO,EAAwB,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAC1E,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAK5C,IAAM,UAAU,GAAhB,MAAM,UAAU;IAEX,GAAG,CAAsB;IAGzB,YAAY,CAAgB;IAG5B,WAAW,CAAc;IAGzB,UAAU,CAAc;IAElC,OAAO;QACL,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,MAAM,EAAE;YACvC,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,KAAK,EAAE,IAAY,EAAE,OAA8B,EAAE,EAAE;gBAC7D,OAAO,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;YAC9D,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,UAAU;QACR,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IACxD,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AA5BC;IAAC,MAAM,EAAE;8BACM,mBAAmB;uCAAC;AAEnC;IAAC,MAAM,EAAE;8BACe,aAAa;gDAAC;AAEtC;IAAC,MAAM,EAAE;8BACc,WAAW;+CAAC;AAEnC;IAAC,MAAM,CAAC,WAAW,CAAC;;8CACc;AAXvB,UAAU;IAHtB,MAAM,CAAC;QACN,OAAO,EAAE,EAAE;KACZ,CAAC;GACW,UAAU,CA6BtB;SA7BY,UAAU"}
@@ -0,0 +1,5 @@
1
+ import { View } from "@tsed/schema";
2
+ export function Vite(path) {
3
+ return View(`${path || "*"}.vite`);
4
+ }
5
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","sourceRoot":"","sources":["../../../src/decorators/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAElC,MAAM,UAAU,IAAI,CAAC,IAAa;IAChC,OAAO,IAAI,CAAC,GAAG,IAAI,IAAI,GAAG,OAAO,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
4
+ export * from "./ViteModule.js";
5
+ export * from "./decorators/vite.js";
6
+ export * from "./interfaces/ViteConfig.js";
7
+ export * from "./interfaces/ViteRenderContext.js";
8
+ export * from "./interfaces/interfaces.js";
9
+ export * from "./middlewares/ViteRendererMiddleware.js";
10
+ export * from "./services/ViteServer.js";
11
+ export * from "./services/ViteService.js";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ViteConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViteConfig.js","sourceRoot":"","sources":["../../../src/interfaces/ViteConfig.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ViteRenderContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViteRenderContext.js","sourceRoot":"","sources":["../../../src/interfaces/ViteRenderContext.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Context, Middleware } from "@tsed/common";
3
+ import { Inject } from "@tsed/di";
4
+ import { ViteService } from "../services/ViteService.js";
5
+ let ViteRendererMiddleware = class ViteRendererMiddleware {
6
+ viteService;
7
+ async use($ctx) {
8
+ const response = await this.viteService.render("*", { $ctx });
9
+ response && !$ctx.response.isDone() && $ctx.response.body(response);
10
+ }
11
+ };
12
+ __decorate([
13
+ Inject(),
14
+ __metadata("design:type", ViteService)
15
+ ], ViteRendererMiddleware.prototype, "viteService", void 0);
16
+ __decorate([
17
+ __param(0, Context()),
18
+ __metadata("design:type", Function),
19
+ __metadata("design:paramtypes", [Object]),
20
+ __metadata("design:returntype", Promise)
21
+ ], ViteRendererMiddleware.prototype, "use", null);
22
+ ViteRendererMiddleware = __decorate([
23
+ Middleware()
24
+ ], ViteRendererMiddleware);
25
+ export { ViteRendererMiddleware };
26
+ //# sourceMappingURL=ViteRendererMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViteRendererMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/ViteRendererMiddleware.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AACjD,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAG7C,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAEvB,WAAW,CAAc;IAE7B,AAAN,KAAK,CAAC,GAAG,CAAY,IAAa;QAChC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,EAAC,IAAI,EAAC,CAAC,CAAC;QAE5D,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtE,CAAC;CACF,CAAA;AARC;IAAC,MAAM,EAAE;8BACc,WAAW;2DAAC;AAE7B;IAAK,WAAA,OAAO,EAAE,CAAA;;;;iDAInB;AARU,sBAAsB;IADlC,UAAU,EAAE;GACA,sBAAsB,CASlC;SATY,sBAAsB"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,40 @@
1
+ import { Logger } from "@tsed/common";
2
+ import { Env } from "@tsed/core";
3
+ import { Configuration, registerProvider } from "@tsed/di";
4
+ export const VITE_SERVER = Symbol.for("VITE_DEV_SERVER");
5
+ registerProvider({
6
+ provide: VITE_SERVER,
7
+ deps: [Configuration, Logger],
8
+ async useAsyncFactory(settings, logger) {
9
+ const { enableStream, statics: staticsOpts = {}, ...config } = settings.get("vite", {});
10
+ const level = settings.logger.level;
11
+ if (settings.env !== Env.PROD) {
12
+ logger.info("Start Vite Dev Server 🚀...");
13
+ // @ts-ignore
14
+ const { createServer } = await import("vite");
15
+ return createServer({
16
+ ...config,
17
+ server: {
18
+ ...(config?.server || {}),
19
+ middlewareMode: true
20
+ },
21
+ logLevel: String(config.logLevel || level)
22
+ });
23
+ }
24
+ logger.info("Initialize statics vite application");
25
+ const { default: sirv } = await import("sirv");
26
+ return Promise.resolve({
27
+ middlewares: sirv(`${config.root || ""}/dist/client`, {
28
+ dotfiles: false,
29
+ ...staticsOpts,
30
+ dev: false
31
+ })
32
+ });
33
+ },
34
+ hooks: {
35
+ $onDestroy(viteDevServer) {
36
+ return viteDevServer.close && viteDevServer.close();
37
+ }
38
+ }
39
+ });
40
+ //# sourceMappingURL=ViteServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViteServer.js","sourceRoot":"","sources":["../../../src/services/ViteServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACpC,OAAO,EAAC,GAAG,EAAC,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAMzD,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAGzD,gBAAgB,CAAC;IACf,OAAO,EAAE,WAAW;IACpB,IAAI,EAAE,CAAC,aAAa,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,eAAe,CAAC,QAAuB,EAAE,MAAc;QAC3D,MAAM,EAAC,YAAY,EAAE,OAAO,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,MAAM,EAAC,GAAG,QAAQ,CAAC,GAAG,CAA4B,MAAM,EAAE,EAAE,CAAC,CAAC;QACjH,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC;QAEpC,IAAI,QAAQ,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,EAAE;YAC7B,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;YAC3C,aAAa;YACb,MAAM,EAAC,YAAY,EAAC,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;YAE5C,OAAO,YAAY,CAAC;gBAClB,GAAG,MAAM;gBACT,MAAM,EAAE;oBACN,GAAG,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC;oBACzB,cAAc,EAAE,IAAI;iBACrB;gBACD,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAQ;aAClD,CAAC,CAAC;SACJ;QAED,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QACnD,MAAM,EAAC,OAAO,EAAE,IAAI,EAAC,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;QAE7C,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,WAAW,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,cAAc,EAAE;gBACpD,QAAQ,EAAE,KAAK;gBACf,GAAG,WAAW;gBACd,GAAG,EAAE,KAAK;aACX,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IACD,KAAK,EAAE;QACL,UAAU,CAAC,aAAqC;YAC9C,OAAO,aAAa,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;QACtD,CAAC;KACF;CACF,CAAC,CAAC"}
@@ -0,0 +1,64 @@
1
+ var ViteService_1;
2
+ import { __decorate, __metadata } from "tslib";
3
+ import { Constant } from "@tsed/common";
4
+ import { Injectable } from "@tsed/di";
5
+ let ViteService = ViteService_1 = class ViteService {
6
+ static moduleName = "vike/server";
7
+ config;
8
+ enableStream;
9
+ async render(viewPath, { $ctx, ...opts }) {
10
+ const urlOriginal = $ctx.request.url;
11
+ const { data } = $ctx;
12
+ const view = viewPath.replace(".vite", "");
13
+ const pageProps = {
14
+ view,
15
+ ...$ctx.response.locals,
16
+ ...opts,
17
+ ...data
18
+ };
19
+ const contextProps = {
20
+ host: $ctx.request.host,
21
+ protocol: $ctx.request.protocol,
22
+ method: $ctx.request.method,
23
+ url: urlOriginal,
24
+ secure: $ctx.request.secure,
25
+ headers: $ctx.request.headers,
26
+ session: $ctx.request.session,
27
+ stateSnapshot: this.config.stateSnapshot && this.config.stateSnapshot()
28
+ };
29
+ const { renderPage } = await import(ViteService_1.moduleName);
30
+ const pageContext = await renderPage({
31
+ view,
32
+ urlOriginal,
33
+ pageProps,
34
+ contextProps
35
+ });
36
+ if (pageContext.errorWhileRendering) {
37
+ $ctx.logger.error({
38
+ event: "VITE_RENDER_ERROR",
39
+ error: pageContext.errorWhileRendering
40
+ });
41
+ }
42
+ if (pageContext.httpResponse) {
43
+ const { httpResponse } = pageContext;
44
+ $ctx.response.contentType(httpResponse.contentType).status(httpResponse.statusCode);
45
+ if (this.enableStream) {
46
+ return httpResponse;
47
+ }
48
+ return httpResponse.body;
49
+ }
50
+ }
51
+ };
52
+ __decorate([
53
+ Constant("vite", {}),
54
+ __metadata("design:type", Object)
55
+ ], ViteService.prototype, "config", void 0);
56
+ __decorate([
57
+ Constant("vite.enableStream", false),
58
+ __metadata("design:type", Boolean)
59
+ ], ViteService.prototype, "enableStream", void 0);
60
+ ViteService = ViteService_1 = __decorate([
61
+ Injectable()
62
+ ], ViteService);
63
+ export { ViteService };
64
+ //# sourceMappingURL=ViteService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViteService.js","sourceRoot":"","sources":["../../../src/services/ViteService.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,QAAQ,EAAkB,MAAM,cAAc,CAAC;AACvD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAM7B,IAAM,WAAW,mBAAjB,MAAM,WAAW;IACtB,MAAM,CAAC,UAAU,GAAG,aAAa,CAAC;IAGxB,MAAM,CAAa;IAGrB,YAAY,CAAU;IAE9B,KAAK,CAAC,MAAM,CACV,QAAgB,EAChB,EAAC,IAAI,EAAE,GAAG,IAAI,EAAgD;QAE9D,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;QAErC,MAAM,EAAC,IAAI,EAAC,GAAG,IAAI,CAAC;QACpB,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO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,CAAC;aACrB;YAED,OAAO,YAAY,CAAC,IAAI,CAAC;SAC1B;IACH,CAAC;;AA5DD;IAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;;2CACQ;AAE7B;IAAC,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC;;iDACP;AAPnB,WAAW;IADvB,UAAU,EAAE;GACA,WAAW,CAgEvB;SAhEY,WAAW"}
@@ -0,0 +1,13 @@
1
+ import { PlatformApplication } from "@tsed/common";
2
+ import { PlatformViews } from "@tsed/platform-views";
3
+ import { VITE_SERVER } from "./services/ViteServer";
4
+ import { ViteService } from "./services/ViteService";
5
+ export declare class ViteModule {
6
+ protected app: PlatformApplication;
7
+ protected platformView: PlatformViews;
8
+ protected viteService: ViteService;
9
+ protected viteServer: VITE_SERVER;
10
+ $onInit(): void;
11
+ $afterInit(): void;
12
+ $afterRoutesInit(): PlatformApplication<TsED.Application>;
13
+ }
@@ -0,0 +1 @@
1
+ export declare function Vite(path?: string): MethodDecorator;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
4
+ export * from "./ViteModule";
5
+ export * from "./decorators/vite";
6
+ export * from "./interfaces/ViteConfig";
7
+ export * from "./interfaces/ViteRenderContext";
8
+ export * from "./interfaces/interfaces";
9
+ export * from "./middlewares/ViteRendererMiddleware";
10
+ export * from "./services/ViteServer";
11
+ export * from "./services/ViteService";
@@ -0,0 +1,7 @@
1
+ import { Options } from "sirv";
2
+ import type { InlineConfig } from "vite";
3
+ export type ViteConfig = InlineConfig & {
4
+ enableStream?: boolean;
5
+ statics?: Omit<Options, "dev">;
6
+ stateSnapshot?(): unknown;
7
+ };
@@ -0,0 +1,14 @@
1
+ /// <reference types="node" />
2
+ import type { IncomingHttpHeaders } from "http";
3
+ export type VitePageProps<Data = Record<string, unknown>> = Data & {
4
+ view: string;
5
+ };
6
+ export interface ViteRenderContext<Data = Record<string, unknown>, Session = Record<string, unknown>> extends Record<string, unknown> {
7
+ host: string;
8
+ protocol: string;
9
+ method: string;
10
+ url: string;
11
+ secure: boolean;
12
+ headers: IncomingHttpHeaders;
13
+ session?: Session;
14
+ }
@@ -0,0 +1,8 @@
1
+ import { ViteConfig } from "./ViteConfig";
2
+ declare global {
3
+ namespace TsED {
4
+ interface Configuration {
5
+ vite: ViteConfig;
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ import { Context } from "@tsed/common";
2
+ import { ViteService } from "../services/ViteService";
3
+ export declare class ViteRendererMiddleware {
4
+ protected viteService: ViteService;
5
+ use($ctx: Context): Promise<void>;
6
+ }
@@ -0,0 +1,3 @@
1
+ import type { ViteDevServer } from "vite";
2
+ export declare const VITE_SERVER: unique symbol;
3
+ export type VITE_SERVER = ViteDevServer;
@@ -0,0 +1,14 @@
1
+ /// <reference types="node" />
2
+ import { PlatformContext } from "@tsed/common";
3
+ import { Writable } from "stream";
4
+ import { ViteConfig } from "../interfaces/ViteConfig";
5
+ export declare class ViteService {
6
+ static moduleName: string;
7
+ protected config: ViteConfig;
8
+ private enableStream;
9
+ render(viewPath: string, { $ctx, ...opts }: {
10
+ $ctx: PlatformContext;
11
+ } & Record<string, any>): Promise<string | {
12
+ pipe(stream: Writable): void;
13
+ } | undefined>;
14
+ }
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@tsed/vike",
3
+ "version": "7.61.0",
4
+ "description": "Vike package for Ts.ED framework",
5
+ "private": false,
6
+ "source": "./src/index.ts",
7
+ "main": "./lib/cjs/index.js",
8
+ "module": "./lib/esm/index.js",
9
+ "typings": "./lib/types/index.d.ts",
10
+ "exports": {
11
+ "types": "./lib/types/index.d.ts",
12
+ "import": "./lib/esm/index.js",
13
+ "require": "./lib/cjs/index.js",
14
+ "default": "./lib/esm/index.js"
15
+ },
16
+ "scripts": {
17
+ "build": "yarn barrels && yarn build:ts",
18
+ "barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
19
+ "test": "cross-env NODE_ENV=test yarn jest --max-workers=2 && jest-coverage-thresholds-bumper",
20
+ "build:ts": "tsc --build tsconfig.json && tsc --build tsconfig.esm.json",
21
+ "lint": "eslint '**/*.{ts,js}'",
22
+ "lint:fix": "eslint '**/*.{ts,js}' --fix"
23
+ },
24
+ "dependencies": {
25
+ "sirv": ">=2.0.2"
26
+ },
27
+ "devDependencies": {
28
+ "@tsed/common": "7.61.0",
29
+ "@tsed/core": "7.61.0",
30
+ "@tsed/di": "7.61.0",
31
+ "@tsed/eslint": "7.44.1",
32
+ "@tsed/exceptions": "7.61.0",
33
+ "@tsed/typescript": "7.44.1",
34
+ "eslint": "^8.12.0",
35
+ "vike": "0.4.160",
36
+ "vite": "5.0.12"
37
+ },
38
+ "peerDependencies": {
39
+ "@tsed/common": "^7.61.0",
40
+ "vike": ">=0.4.160",
41
+ "vite": ">=4"
42
+ },
43
+ "peerDependenciesMeta": {
44
+ "@tsed/common": {
45
+ "optional": false
46
+ },
47
+ "vike": {
48
+ "optional": true
49
+ }
50
+ },
51
+ "repository": "https://github.com/tsedio/tsed",
52
+ "bugs": {
53
+ "url": "https://github.com/tsedio/tsed/issues"
54
+ },
55
+ "homepage": "https://github.com/tsedio/tsed/tree/production/packages/third-parties/vike",
56
+ "author": "Romain Lenzotti",
57
+ "license": "MIT"
58
+ }
package/readme.md ADDED
@@ -0,0 +1,70 @@
1
+ <p style="text-align: center" align="center">
2
+ <a href="https://tsed.io" target="_blank"><img src="https://tsed.io/tsed-og.png" width="200" alt="Ts.ED logo"/></a>
3
+ </p>
4
+
5
+ <div align="center">
6
+ <h1>Vike</h1>
7
+
8
+ [![Build & Release](https://github.com/tsedio/tsed/workflows/Build%20&%20Release/badge.svg)](https://github.com/tsedio/tsed/actions?query=workflow%3A%22Build+%26+Release%22)
9
+ [![PR Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/tsedio/tsed/blob/master/CONTRIBUTING.md)
10
+ [![npm version](https://badge.fury.io/js/%40tsed%2Fcommon.svg)](https://badge.fury.io/js/%40tsed%2Fcommon)
11
+ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
12
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
13
+ [![github](https://img.shields.io/static/v1?label=Github%20sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/romakita)
14
+ [![opencollective](https://img.shields.io/static/v1?label=OpenCollective%20sponsor&message=%E2%9D%A4&logo=OpenCollective&color=%23fe8e86)](https://opencollective.com/tsed)
15
+
16
+ </div>
17
+
18
+ <div align="center">
19
+ <a href="https://tsed.io/">Website</a>
20
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
21
+ <a href="https://tsed.io/getting-started/">Getting started</a>
22
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
23
+ <a href="https://api.tsed.io/rest/slack/tsedio/tsed">Slack</a>
24
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
25
+ <a href="https://twitter.com/TsED_io">Twitter</a>
26
+ </div>
27
+
28
+ <hr />
29
+
30
+ A package of Ts.ED framework. See website: https://tsed.io/tutorials/vike
31
+
32
+ ## Feature
33
+
34
+ - Render page using @View with Vite
35
+
36
+ ## Installation
37
+
38
+ To begin, install the oidc-provider module for TS.ED:
39
+
40
+ ```bash
41
+ npm install --save @tsed/vike vite@4 vike
42
+ ```
43
+
44
+ ## Contributors
45
+
46
+ Please read [contributing guidelines here](https://tsed.io/contributing.html)
47
+
48
+ <a href="https://github.com/tsedio/tsed/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
49
+
50
+ ## Backers
51
+
52
+ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
53
+
54
+ <a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/backers.svg?width=890"></a>
55
+
56
+ ## Sponsors
57
+
58
+ Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
59
+
60
+ ## License
61
+
62
+ The MIT License (MIT)
63
+
64
+ Copyright (c) 2016 - 2022 Romain Lenzotti
65
+
66
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
67
+
68
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
69
+
70
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ {
2
+ "extends": "@tsed/typescript/tsconfig.node.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "module": "ES2020",
6
+ "rootDir": "src",
7
+ "outDir": "./lib/esm",
8
+ "declaration": true,
9
+ "declarationDir": "./lib/types",
10
+ "composite": true,
11
+ "noEmit": false
12
+ },
13
+ "include": ["src", "src/**/*.json"],
14
+ "exclude": [
15
+ "node_modules",
16
+ "test",
17
+ "lib",
18
+ "benchmark",
19
+ "coverage",
20
+ "spec",
21
+ "**/*.benchmark.ts",
22
+ "**/*.spec.ts",
23
+ "keys",
24
+ "jest.config.js",
25
+ "**/__mock__/**",
26
+ "webpack.config.js"
27
+ ],
28
+ "references": [
29
+ {
30
+ "path": "../../platform/common"
31
+ },
32
+ {
33
+ "path": "../../core"
34
+ },
35
+ {
36
+ "path": "../../di"
37
+ },
38
+ {
39
+ "path": "../../specs/exceptions"
40
+ }
41
+ ]
42
+ }