Skip to content

Commit 0b30d0d

Browse files
chore: wip
1 parent 31c9507 commit 0b30d0d

File tree

25 files changed

+2353
-2217
lines changed

25 files changed

+2353
-2217
lines changed

.stacks/core/modules/src/pinia.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { createPinia } from 'pinia'
2+
import { type UserModule } from '@stacksjs/types'
3+
4+
// Setup Pinia
5+
// https://pinia.vuejs.org/
6+
export const install: UserModule = ({ isClient, initialState, app }) => {
7+
const pinia = createPinia()
8+
app.use(pinia)
9+
// Refer to
10+
// https://github.com/antfu/vite-ssg/blob/main/README.md#state-serialization
11+
// for other serialization strategies.
12+
if (isClient)
13+
pinia.state.value = (initialState.pinia) || {}
14+
15+
else
16+
initialState.pinia = pinia.state.value
17+
}

.stacks/core/router/src/middleware.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export interface MiddlewareType {
2+
name: string
3+
priority: number
4+
handle: Function
5+
}
6+
7+
export class Middleware implements MiddlewareType {
8+
name: string
9+
priority: number
10+
handle: Function
11+
12+
constructor(data: MiddlewareType) {
13+
this.name = data.name
14+
this.priority = data.priority
15+
this.handle = data.handle
16+
}
17+
}

.stacks/core/router/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { URL } from 'node:url'
22
import { extname } from 'node:path'
33
import type { Route, StatusCode } from '@stacksjs/types'
4-
import middlewares from '../../../../app/middleware'
4+
import { middlewares } from './middleware'
55
import { request } from './request'
66
import { route } from './index'
77

.stacks/core/vite/src/plugin/auto-imports.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import AutoImport from 'unplugin-auto-import/vite'
22
import { defu } from 'defu'
33
import type { AutoImportsOptions } from '@stacksjs/types'
4-
import { frameworkPath, resourcesPath } from '@stacksjs/path'
4+
import { frameworkPath, resourcesPath, projectStoragePath } from '@stacksjs/path'
55
import type { Plugin } from 'vite'
6+
import { unheadVueComposablesImports } from '@unhead/vue'
67

78
export function autoImports(options?: AutoImportsOptions): Plugin {
89
const defaultOptions: AutoImportsOptions = {
910
imports: [
1011
'vue', 'vue-router', 'vue/macros', 'pinia',
12+
unheadVueComposablesImports
1113
// 'vitepress'
1214
// { '@stacksjs/ui': ['CssEngine', 'UiEngine', 'Store', 'presetForms', 'transformerCompileClass'] },
1315
// { '@stacksjs/logging': ['dd', 'dump'] }, // we also export `log` in st stacks/cli
@@ -20,13 +22,13 @@ export function autoImports(options?: AutoImportsOptions): Plugin {
2022
// here, we say that everything that lives here in .stacks/src/index.ts will be auto-imported
2123
frameworkPath('src'),
2224
],
23-
dts: frameworkPath('types/auto-imports.d.ts'),
25+
dts: projectStoragePath('framework/types/auto-imports.d.ts'),
2426
vueTemplate: true,
2527
eslintrc: {
2628
enabled: false,
2729
// filepath: frameworkPath('.eslintrc-auto-import.json'),
2830
},
29-
}
31+
}
3032

3133
const newOptions = defu(options, defaultOptions)
3234

.stacks/core/vite/src/plugin/components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function components(options?: ComponentOptions): Plugin {
1313
p.componentsPath(),
1414
// viewsPath(),
1515
],
16-
dts: p.frameworkPath('types/components.d.ts'),
16+
dts: p.projectStoragePath('framework/types/components.d.ts'),
1717
}
1818

1919
const newOptions = defu(options, defaultOptions)

.stacks/core/vite/src/plugin/layouts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import Layouts from 'vite-plugin-vue-layouts'
1+
import Layouts from 'vite-plugin-vue-layouts';
2+
23
import type { Options as LayoutOptions } from 'vite-plugin-vue-layouts'
34

45
export function layouts(options?: LayoutOptions) {

.stacks/core/vite/src/plugin/pages.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
import { defu } from 'defu'
2-
import type { Options } from 'unplugin-vue-router'
2+
import type { Options, TreeNode } from 'unplugin-vue-router'
33
import VueRouter from 'unplugin-vue-router/vite'
44

55
// https://github.com/posva/unplugin-vue-router
66
export function pages(options?: Options) {
77
const defaultOptions = {
88
extensions: ['.vue', '.md'],
9+
getRouteName: (routeNode: TreeNode) => getFileBasedRouteName(routeNode),
910
}
1011

1112
const newOptions = defu(options, defaultOptions)
1213

1314
return VueRouter(newOptions)
1415
}
16+
17+
function getFileBasedRouteName(node: TreeNode): string {
18+
// Base case: If node doesn't have a parent, return an empty string
19+
if (!node.parent) {
20+
return "";
21+
}
22+
23+
// Recursive case: Concatenate the parent's value with the current node's value
24+
const segment = node.value.rawSegment === "index" ? "" : node.value.rawSegment;
25+
26+
const path = getFileBasedRouteName(node.parent) + (segment ? "/" + segment : "");
27+
28+
// Process the path to get the desired format
29+
const cleanedPath = path
30+
.replace(/^\//, "") // Remove leading slash
31+
.replace(/\//g, ".") // Replace all remaining slashes with dots
32+
.replace(/\[|\]/g, ""); // Remove [ and ]
33+
34+
return cleanedPath;
35+
}

.stacks/core/vite/src/views.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type ViteConfig } from '@stacksjs/types'
22
import { resourcesPath, projectPath } from '@stacksjs/path'
33

4-
import { cssEngine, inspect, autoImports, components, layouts, pages, uiEngine, pwa } from './stacks'
4+
import { cssEngine, inspect, autoImports, components, layouts, pages, uiEngine } from './stacks'
55

66
import { alias } from '@stacksjs/alias'
77
import { defineConfig } from './'

.stacks/src/index.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
export * from '../core/actions/src'
2+
export * from '../core/ai/src'
3+
export * from '../core/alias/src'
4+
export * from '../core/analytics/src'
5+
export * as arrays from '../core/arrays/src'
6+
export * from '../core/auth/src'
7+
export * as buddy from '../core/buddy/src'
8+
export * from '../core/build/src'
9+
export * as cache from '../core/cache/src'
10+
export * as chat from '../core/chat/src'
11+
export * as cli from '../core/cli/src'
12+
export * as cloud from '../core/cloud/src'
13+
export * as collections from '../core/collections/src'
14+
export * as config from '../core/config/src'
15+
export * from '../core/database/src'
16+
export * from '../core/datetime/src'
17+
export * from '../core/desktop/src'
18+
export * from '../core/development/src'
19+
export * from '../core/dns/src'
20+
export { default as docsConfig } from '../core/docs/src'
21+
export * as email from '../core/email/src'
22+
export * from '../core/error-handling/src'
23+
export * from '../core/env/src'
24+
export * from '../core/events/src'
25+
export * from '../core/faker/src'
26+
export * from '../core/git/src'
27+
export * from '../core/health/src'
28+
export * from '../core/lint/src'
29+
export * from '../core/logging/src'
30+
export * from '../core/notifications/src'
31+
export * from '../core/objects/src'
32+
export * from '../core/orm/src'
33+
export * from '../core/path/src'
34+
export * from '../core/payments/src'
35+
export * from '../core/push/src'
36+
export * from '../core/query-builder/src'
37+
export * as queue from '../core/queue/src'
38+
export * from '../core/realtime/src'
39+
export * from '../core/repl/src'
40+
export * from '../core/router/src'
41+
export * from '../core/scheduler/src'
42+
export * from '../core/search-engine/src'
43+
export * from '../core/security/src'
44+
export * from '../core/server/src'
45+
export * from '../core/signals/src'
46+
export * from '../core/slug/src'
47+
export * from '../core/sms/src'
48+
export * from '../core/storage/src'
49+
export * as strings from '../core/strings/src'
50+
export * from '../core/testing/src'
51+
export * from '../core/types/src'
52+
export * from '../core/ui/src'
53+
export * from '../core/utils/src'
54+
export * from '../core/validation/src'

.stacks/stacks.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)