@finesoft/create-app 0.1.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 (128) hide show
  1. package/dist/index.mjs +129 -0
  2. package/package.json +26 -0
  3. package/templates/react/env.d.ts +1 -0
  4. package/templates/react/index.html +13 -0
  5. package/templates/react/package.json +21 -0
  6. package/templates/react/src/App.tsx +20 -0
  7. package/templates/react/src/actions.ts +14 -0
  8. package/templates/react/src/bootstrap.ts +36 -0
  9. package/templates/react/src/components/Layout.tsx +63 -0
  10. package/templates/react/src/components/Loading.tsx +3 -0
  11. package/templates/react/src/components/Navigation.tsx +51 -0
  12. package/templates/react/src/components/PageRenderer.tsx +41 -0
  13. package/templates/react/src/components/ProductCard.tsx +35 -0
  14. package/templates/react/src/lib/controllers/about.ts +18 -0
  15. package/templates/react/src/lib/controllers/error.ts +11 -0
  16. package/templates/react/src/lib/controllers/home.ts +53 -0
  17. package/templates/react/src/lib/controllers/product-detail.ts +52 -0
  18. package/templates/react/src/lib/controllers/search.ts +58 -0
  19. package/templates/react/src/lib/guards/auth.ts +17 -0
  20. package/templates/react/src/lib/guards/seo.ts +15 -0
  21. package/templates/react/src/lib/mappers/product.ts +27 -0
  22. package/templates/react/src/lib/models/product.ts +48 -0
  23. package/templates/react/src/lib/services/api-client.ts +28 -0
  24. package/templates/react/src/main.tsx +49 -0
  25. package/templates/react/src/pages/About.tsx +16 -0
  26. package/templates/react/src/pages/Home.tsx +34 -0
  27. package/templates/react/src/pages/NotFound.tsx +25 -0
  28. package/templates/react/src/pages/ProductDetail.tsx +34 -0
  29. package/templates/react/src/pages/Search.tsx +23 -0
  30. package/templates/react/src/ssr.tsx +23 -0
  31. package/templates/react/tsconfig.json +17 -0
  32. package/templates/react/vite.config.ts +20 -0
  33. package/templates/react-minimal/env.d.ts +1 -0
  34. package/templates/react-minimal/index.html +13 -0
  35. package/templates/react-minimal/package.json +21 -0
  36. package/templates/react-minimal/src/App.tsx +22 -0
  37. package/templates/react-minimal/src/bootstrap.ts +6 -0
  38. package/templates/react-minimal/src/lib/controllers/home.ts +14 -0
  39. package/templates/react-minimal/src/main.tsx +44 -0
  40. package/templates/react-minimal/src/ssr.tsx +25 -0
  41. package/templates/react-minimal/tsconfig.json +17 -0
  42. package/templates/react-minimal/vite.config.ts +12 -0
  43. package/templates/svelte/env.d.ts +9 -0
  44. package/templates/svelte/index.html +13 -0
  45. package/templates/svelte/package.json +18 -0
  46. package/templates/svelte/src/App.svelte +85 -0
  47. package/templates/svelte/src/actions.ts +14 -0
  48. package/templates/svelte/src/bootstrap.ts +36 -0
  49. package/templates/svelte/src/components/Layout.svelte +19 -0
  50. package/templates/svelte/src/components/Loading.svelte +1 -0
  51. package/templates/svelte/src/components/Navigation.svelte +75 -0
  52. package/templates/svelte/src/components/PageRenderer.svelte +22 -0
  53. package/templates/svelte/src/components/ProductCard.svelte +37 -0
  54. package/templates/svelte/src/lib/controllers/about.ts +18 -0
  55. package/templates/svelte/src/lib/controllers/error.ts +11 -0
  56. package/templates/svelte/src/lib/controllers/home.ts +53 -0
  57. package/templates/svelte/src/lib/controllers/product-detail.ts +52 -0
  58. package/templates/svelte/src/lib/controllers/search.ts +58 -0
  59. package/templates/svelte/src/lib/framework-svelte.ts +34 -0
  60. package/templates/svelte/src/lib/guards/auth.ts +17 -0
  61. package/templates/svelte/src/lib/guards/seo.ts +15 -0
  62. package/templates/svelte/src/lib/mappers/product.ts +27 -0
  63. package/templates/svelte/src/lib/models/product.ts +47 -0
  64. package/templates/svelte/src/lib/render.ts +15 -0
  65. package/templates/svelte/src/lib/services/api-client.ts +28 -0
  66. package/templates/svelte/src/main.ts +27 -0
  67. package/templates/svelte/src/pages/About.svelte +10 -0
  68. package/templates/svelte/src/pages/Home.svelte +34 -0
  69. package/templates/svelte/src/pages/NotFound.svelte +23 -0
  70. package/templates/svelte/src/pages/ProductDetail.svelte +32 -0
  71. package/templates/svelte/src/pages/Search.svelte +29 -0
  72. package/templates/svelte/src/ssr.ts +12 -0
  73. package/templates/svelte/tsconfig.json +16 -0
  74. package/templates/svelte/vite.config.ts +21 -0
  75. package/templates/svelte-minimal/env.d.ts +9 -0
  76. package/templates/svelte-minimal/index.html +13 -0
  77. package/templates/svelte-minimal/package.json +18 -0
  78. package/templates/svelte-minimal/src/App.svelte +63 -0
  79. package/templates/svelte-minimal/src/bootstrap.ts +6 -0
  80. package/templates/svelte-minimal/src/lib/controllers/home.ts +15 -0
  81. package/templates/svelte-minimal/src/lib/framework-svelte.ts +34 -0
  82. package/templates/svelte-minimal/src/lib/render.ts +12 -0
  83. package/templates/svelte-minimal/src/main.ts +22 -0
  84. package/templates/svelte-minimal/src/pages/Home.svelte +10 -0
  85. package/templates/svelte-minimal/src/ssr.ts +18 -0
  86. package/templates/svelte-minimal/tsconfig.json +16 -0
  87. package/templates/svelte-minimal/vite.config.ts +12 -0
  88. package/templates/vue/env.d.ts +7 -0
  89. package/templates/vue/index.html +13 -0
  90. package/templates/vue/package.json +18 -0
  91. package/templates/vue/src/App.vue +29 -0
  92. package/templates/vue/src/actions.ts +14 -0
  93. package/templates/vue/src/bootstrap.ts +42 -0
  94. package/templates/vue/src/components/Layout.vue +18 -0
  95. package/templates/vue/src/components/Loading.vue +3 -0
  96. package/templates/vue/src/components/Navigation.vue +58 -0
  97. package/templates/vue/src/components/PageRenderer.vue +26 -0
  98. package/templates/vue/src/components/ProductCard.vue +39 -0
  99. package/templates/vue/src/lib/controllers/about.ts +18 -0
  100. package/templates/vue/src/lib/controllers/error.ts +11 -0
  101. package/templates/vue/src/lib/controllers/home.ts +53 -0
  102. package/templates/vue/src/lib/controllers/product-detail.ts +52 -0
  103. package/templates/vue/src/lib/controllers/search.ts +58 -0
  104. package/templates/vue/src/lib/guards/auth.ts +17 -0
  105. package/templates/vue/src/lib/guards/seo.ts +15 -0
  106. package/templates/vue/src/lib/mappers/product.ts +27 -0
  107. package/templates/vue/src/lib/models/product.ts +47 -0
  108. package/templates/vue/src/lib/services/api-client.ts +31 -0
  109. package/templates/vue/src/main.ts +46 -0
  110. package/templates/vue/src/pages/About.vue +16 -0
  111. package/templates/vue/src/pages/Home.vue +38 -0
  112. package/templates/vue/src/pages/NotFound.vue +22 -0
  113. package/templates/vue/src/pages/ProductDetail.vue +34 -0
  114. package/templates/vue/src/pages/Search.vue +33 -0
  115. package/templates/vue/src/ssr.ts +24 -0
  116. package/templates/vue/tsconfig.json +17 -0
  117. package/templates/vue/vite.config.ts +20 -0
  118. package/templates/vue-minimal/env.d.ts +7 -0
  119. package/templates/vue-minimal/index.html +13 -0
  120. package/templates/vue-minimal/package.json +18 -0
  121. package/templates/vue-minimal/src/App.vue +21 -0
  122. package/templates/vue-minimal/src/bootstrap.ts +6 -0
  123. package/templates/vue-minimal/src/lib/controllers/home.ts +15 -0
  124. package/templates/vue-minimal/src/main.ts +41 -0
  125. package/templates/vue-minimal/src/pages/Home.vue +12 -0
  126. package/templates/vue-minimal/src/ssr.ts +28 -0
  127. package/templates/vue-minimal/tsconfig.json +17 -0
  128. package/templates/vue-minimal/vite.config.ts +12 -0
@@ -0,0 +1,24 @@
1
+ import { createSSRRender, serializeServerData } from "@finesoft/front";
2
+ import { createSSRApp } from "vue";
3
+ import { renderToString } from "vue/server-renderer";
4
+ import App from "./App.vue";
5
+ import { bootstrap } from "./bootstrap";
6
+ import { getErrorPage } from "./lib/controllers/error";
7
+
8
+ export const render = createSSRRender({
9
+ bootstrap,
10
+ getErrorPage,
11
+ async renderApp(page, _locale) {
12
+ const app = createSSRApp(App, { page });
13
+ const html = await renderToString(app);
14
+ return {
15
+ html,
16
+ head: `<title>${page.title}</title><meta name="description" content="${
17
+ page.description ?? ""
18
+ }">`,
19
+ css: "",
20
+ };
21
+ },
22
+ });
23
+
24
+ export { serializeServerData };
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "target": "ESNext",
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "jsx": "preserve",
8
+ "esModuleInterop": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "skipLibCheck": true,
11
+ "noEmit": true,
12
+ "paths": {
13
+ "@/*": ["./src/*"]
14
+ }
15
+ },
16
+ "include": ["src/**/*", "env.d.ts"]
17
+ }
@@ -0,0 +1,20 @@
1
+ import { finesoftFrontViteConfig } from "@finesoft/front";
2
+ import vue from "@vitejs/plugin-vue";
3
+ import { defineConfig } from "vite-plus";
4
+
5
+ export default defineConfig({
6
+ plugins: [
7
+ vue(),
8
+ finesoftFrontViteConfig({
9
+ ssr: { entry: "src/ssr.ts" },
10
+ locales: ["en", "zh"],
11
+ defaultLocale: "en",
12
+ proxies: [
13
+ {
14
+ prefix: "/api",
15
+ target: "https://jsonplaceholder.typicode.com",
16
+ },
17
+ ],
18
+ }),
19
+ ],
20
+ });
@@ -0,0 +1,7 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ declare module "*.vue" {
4
+ import type { DefineComponent } from "vue";
5
+ const component: DefineComponent<object, object, unknown>;
6
+ export default component;
7
+ }
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="<!--ssr-lang-->">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <!--ssr-head-->
7
+ </head>
8
+ <body>
9
+ <div id="app"><!--ssr-body--></div>
10
+ <!--ssr-data-->
11
+ <script type="module" src="/src/main.ts"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "finesoft-vue-minimal",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "vp dev",
7
+ "build": "vp build",
8
+ "preview": "vp preview"
9
+ },
10
+ "dependencies": {
11
+ "@finesoft/front": "workspace:*",
12
+ "vue": "^3.5.0"
13
+ },
14
+ "devDependencies": {
15
+ "@vitejs/plugin-vue": "^5.0.0",
16
+ "vite-plus": "catalog:"
17
+ }
18
+ }
@@ -0,0 +1,21 @@
1
+ <script setup lang="ts">
2
+ import type { Action, BasePage } from "@finesoft/front";
3
+ import { computed } from "vue";
4
+ import Home from "./pages/Home.vue";
5
+
6
+ const { state, page: ssrPage } = defineProps<{
7
+ state?: { page: BasePage | null; loading: boolean };
8
+ page?: BasePage;
9
+ onAction?: (action: Action) => void;
10
+ }>();
11
+
12
+ const currentPage = computed(() => state?.page ?? ssrPage ?? null);
13
+ const loading = computed(() => state?.loading ?? false);
14
+ </script>
15
+
16
+ <template>
17
+ <main style="padding: 1rem">
18
+ <p v-if="loading" style="text-align: center; color: #999">Loading…</p>
19
+ <Home v-else-if="currentPage" :page="currentPage" />
20
+ </main>
21
+ </template>
@@ -0,0 +1,6 @@
1
+ import { type Framework, defineRoutes } from "@finesoft/front";
2
+ import { HomeController } from "./lib/controllers/home";
3
+
4
+ export function bootstrap(framework: Framework): void {
5
+ defineRoutes(framework, [{ path: "/", intentId: "home", controller: new HomeController() }]);
6
+ }
@@ -0,0 +1,15 @@
1
+ import { BaseController, type BasePage } from "@finesoft/front";
2
+
3
+ export class HomeController extends BaseController<Record<string, string>, BasePage> {
4
+ readonly intentId = "home";
5
+
6
+ execute(): BasePage {
7
+ return {
8
+ id: "home",
9
+ pageType: "home",
10
+ url: "/",
11
+ title: "Home",
12
+ description: "Welcome to Finesoft Front",
13
+ };
14
+ }
15
+ }
@@ -0,0 +1,41 @@
1
+ import { startBrowserApp, type Action, type BasePage, type Framework } from "@finesoft/front";
2
+ import { createApp, reactive } from "vue";
3
+ import App from "./App.vue";
4
+ import { bootstrap } from "./bootstrap";
5
+
6
+ void startBrowserApp({
7
+ bootstrap,
8
+ mount(target: HTMLElement, { framework }: { framework: Framework; locale: string }) {
9
+ const state = reactive<{ page: BasePage | null; loading: boolean }>({
10
+ page: null,
11
+ loading: false,
12
+ });
13
+ const handleAction = (action: Action) => {
14
+ void framework.perform(action);
15
+ };
16
+ createApp(App, { state, onAction: handleAction }).mount(target);
17
+
18
+ return ({
19
+ page,
20
+ isFirstPage,
21
+ }: {
22
+ page: Promise<BasePage> | BasePage;
23
+ isFirstPage?: boolean;
24
+ }) => {
25
+ if (page instanceof Promise) {
26
+ if (!isFirstPage) state.loading = true;
27
+ void page.then((p) => {
28
+ state.page = p;
29
+ state.loading = false;
30
+ });
31
+ } else {
32
+ state.page = page;
33
+ state.loading = false;
34
+ }
35
+ };
36
+ },
37
+ callbacks: {
38
+ onNavigate() {},
39
+ onModal() {},
40
+ },
41
+ });
@@ -0,0 +1,12 @@
1
+ <script setup lang="ts">
2
+ import type { BasePage } from "@finesoft/front";
3
+
4
+ defineProps<{ page: BasePage }>();
5
+ </script>
6
+
7
+ <template>
8
+ <div>
9
+ <h1>{{ page.title }}</h1>
10
+ <p>{{ page.description }}</p>
11
+ </div>
12
+ </template>
@@ -0,0 +1,28 @@
1
+ import { createSSRRender, serializeServerData } from "@finesoft/front";
2
+ import { createSSRApp } from "vue";
3
+ import { renderToString } from "vue/server-renderer";
4
+ import App from "./App.vue";
5
+ import { bootstrap } from "./bootstrap";
6
+
7
+ export const render = createSSRRender({
8
+ bootstrap,
9
+ getErrorPage(status, message) {
10
+ return {
11
+ id: "error",
12
+ pageType: "error",
13
+ title: `Error ${status}`,
14
+ description: message,
15
+ };
16
+ },
17
+ async renderApp(page, _locale) {
18
+ const app = createSSRApp(App, { page });
19
+ const html = await renderToString(app);
20
+ return {
21
+ html,
22
+ head: `<title>${page.title}</title>`,
23
+ css: "",
24
+ };
25
+ },
26
+ });
27
+
28
+ export { serializeServerData };
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "target": "ESNext",
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "jsx": "preserve",
8
+ "esModuleInterop": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "skipLibCheck": true,
11
+ "noEmit": true,
12
+ "paths": {
13
+ "@/*": ["./src/*"]
14
+ }
15
+ },
16
+ "include": ["src/**/*", "env.d.ts"]
17
+ }
@@ -0,0 +1,12 @@
1
+ import { finesoftFrontViteConfig } from "@finesoft/front";
2
+ import vue from "@vitejs/plugin-vue";
3
+ import { defineConfig } from "vite-plus";
4
+
5
+ export default defineConfig({
6
+ plugins: [
7
+ vue(),
8
+ finesoftFrontViteConfig({
9
+ ssr: { entry: "src/ssr.ts" },
10
+ }),
11
+ ],
12
+ });