Skip to content

Commit 85ff560

Browse files
committed
chore: wip
1 parent 1df9525 commit 85ff560

File tree

18 files changed

+666
-556
lines changed

18 files changed

+666
-556
lines changed

bun.lockb

-3.31 KB
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { log, runCommand } from '@stacksjs/cli'
2+
3+
const command: string = 'bun build ./src/index.ts --outdir dist --format esm'
4+
const result = await runCommand(command, {
5+
cwd: import.meta.dir,
6+
})
7+
8+
if (result.isErr())
9+
log.error(result.error)

storage/framework/.stacks/core/api/src/index.ts

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ofetch } from 'ofetch'
2-
import { flare } from '@flareapp/flare-client'
32
import { config, localUrl } from '@stacksjs/config'
4-
3+
import { ref } from 'vue'
54
interface Params {
65
[key: string]: any // Replace 'any' with more specific types if possible
76
}
@@ -24,11 +23,6 @@ interface FetchResponse {
2423
const loading = ref(false)
2524
const token = ref('')
2625

27-
let bearerToken: string | null = ''
28-
29-
if (typeof window !== 'undefined')
30-
bearerToken = window.localStorage.getItem('bearerToken')
31-
3226
export async function useHttpFetch(endpoint = '') {
3327
let baseURL = await localUrl({ domain: config.app.url })
3428

@@ -39,7 +33,7 @@ export async function useHttpFetch(endpoint = '') {
3933
const parameters: FetchParams = {
4034
...params,
4135
...{
42-
headers: { Accept: 'application/json', Authorization: `Bearer ${token.value || bearerToken}` },
36+
headers: { Accept: 'application/json', Authorization: `Bearer ${token.value}` },
4337
parseResponse: JSON.parse,
4438
method: 'POST',
4539
baseURL,
@@ -55,11 +49,6 @@ export async function useHttpFetch(endpoint = '') {
5549
return result
5650
}
5751
catch (err: any) {
58-
flare.report(errReport)
59-
60-
if (err.status === 401)
61-
logout()
62-
6352
loading.value = false
6453

6554
throw err
@@ -70,7 +59,7 @@ export async function useHttpFetch(endpoint = '') {
7059
const parameters: FetchParams = {
7160
...params,
7261
...{
73-
headers: { Accept: 'application/json', Authorization: `Bearer ${token.value || bearerToken}` },
62+
headers: { Accept: 'application/json', Authorization: `Bearer ${token.value}` },
7463
parseResponse: JSON.parse,
7564
method: 'GET',
7665
baseURL,
@@ -82,10 +71,6 @@ export async function useHttpFetch(endpoint = '') {
8271
return result
8372
}
8473
catch (err: any) {
85-
flare.report(err)
86-
if (err.status === 401)
87-
logout()
88-
8974
throw err
9075
}
9176
}
@@ -94,7 +79,7 @@ export async function useHttpFetch(endpoint = '') {
9479
const parameters: FetchParams = {
9580
...params,
9681
...{
97-
headers: { Accept: 'application/json', Authorization: `Bearer ${token.value || bearerToken}` },
82+
headers: { Accept: 'application/json', Authorization: `Bearer ${token.value}` },
9883
parseResponse: JSON.parse,
9984
method: 'PATCH',
10085
baseURL,
@@ -109,8 +94,6 @@ export async function useHttpFetch(endpoint = '') {
10994
return result
11095
}
11196
catch (err: any) {
112-
flare.report(err)
113-
loading.value = false
11497
throw err
11598
}
11699
}
@@ -119,7 +102,7 @@ export async function useHttpFetch(endpoint = '') {
119102
const parameters: FetchParams = {
120103
...params,
121104
...{
122-
headers: { Accept: 'application/json', Authorization: `Bearer ${token.value || bearerToken}` },
105+
headers: { Accept: 'application/json', Authorization: `Bearer ${token.value}` },
123106
method: 'DELETE',
124107
baseURL,
125108
},
@@ -133,9 +116,6 @@ export async function useHttpFetch(endpoint = '') {
133116
return result
134117
}
135118
catch (err: any) {
136-
flare.report(err)
137-
loading.value = false
138-
139119
throw err
140120
}
141121
}
@@ -144,12 +124,5 @@ export async function useHttpFetch(endpoint = '') {
144124
token.value = authToken
145125
}
146126

147-
function logout() {
148-
if (typeof window !== 'undefined')
149-
window.localStorage.clear()
150-
151-
window.location.href = '/login'
152-
}
153-
154127
return { post, get, patch, destroy, baseURL, loading, token, setToken }
155128
}

storage/framework/.stacks/core/vite/src/desktop.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import type { ViteConfig } from '@stacksjs/types'
22
import { path as p } from '@stacksjs/path'
33
import { alias } from '@stacksjs/alias'
44
import generateSitemap from 'vite-ssg-sitemap'
5-
5+
import Components from 'unplugin-vue-components/vite'
66
import UnoCSS from 'unocss/vite'
77
import { layouts, pages, uiEngine } from './stacks'
8+
import AutoImport from 'unplugin-auto-import/vite'
89
import { defineConfig } from './'
910

1011
export const pagesConfig = {
11-
root: p.projectStoragePath('framework/desktop/dashboard'),
12+
root: p.projectStoragePath('framework/stacks/dashboard'),
1213
envDir: p.projectPath(),
1314
envPrefix: 'FRONTEND_',
1415
publicDir: p.projectPath('public'),
@@ -24,15 +25,34 @@ export const pagesConfig = {
2425

2526
plugins: [
2627
uiEngine(),
28+
Components({
29+
// allow auto load markdown components under `./src/components/`
30+
extensions: ['vue', 'md'],
31+
// allow auto import and register components used in markdown
32+
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
33+
dts: p.projectStoragePath('framework/stacks/dashboard/components.d.ts'),
34+
}),
35+
AutoImport({
36+
imports: [
37+
'pinia',
38+
'vue',
39+
'vue-i18n',
40+
],
41+
dts: p.projectStoragePath('framework/stacks/auto-imports.d.ts'),
42+
dirs: [
43+
p.projectStoragePath('framework/stacks/dashboard/src/functions'),
44+
],
45+
}),
2746
pages({
28-
dirs: p.frameworkPath('stacks/dashboard/src/pages'),
47+
routesFolder: p.projectStoragePath('framework/stacks/dashboard/src/pages'),
2948
}),
3049
UnoCSS({
31-
configFile: p.corePath('vite/src/uno.config.ts'),
50+
configFile: p.projectStoragePath('framework/.stacks/core/ui/src/uno.config.ts'),
3251
}),
3352
layouts({
34-
layoutsDirs: p.frameworkPath('stacks/dashboard/src/layouts'),
35-
}),
53+
layoutsDirs: p.projectStoragePath('framework/stacks/dashboard/src/layouts'),
54+
}, false),
55+
3656
],
3757

3858
// https://github.com/antfu/vite-ssg

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import Layouts from 'vite-plugin-vue-layouts'
44
// @ts-expect-error missing types - somehow, @stacksjs/vite-plugin-vue-layouts does not work
55
import type { UserOptions as LayoutOptions } from 'vite-plugin-vue-layouts'
66

7-
export function layouts(options?: LayoutOptions) {
7+
export function layouts(options?: LayoutOptions, isMain = true) {
8+
if (! isMain) {
9+
return Layouts(options)
10+
}
11+
812
return Layouts({
913
layoutsDir: p.resourcesPath('layouts'),
1014
defaultLayout: p.resourcesPath('layouts/default.vue'),
Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
11
import { defu } from 'defu'
2-
import Pages from 'vite-plugin-pages'
3-
import type { UserOptions } from 'vite-plugin-pages'
2+
import type { Options, TreeNode } from 'unplugin-vue-router'
3+
import VueRouter from 'unplugin-vue-router/vite'
44

5-
// https://github.com/hannoeru/vite-plugin-pages
6-
export function pages(options?: UserOptions) {
5+
// https://github.com/posva/unplugin-vue-router
6+
export function pages(options?: Options) {
77
const defaultOptions = {
8-
extensions: ['vue', 'md'],
8+
extensions: ['.vue', '.md'],
9+
getRouteName: (routeNode: TreeNode) => getFileBasedRouteName(routeNode),
910
}
11+
1012
const newOptions = defu(options, defaultOptions)
1113

12-
return Pages(newOptions)
14+
return VueRouter(newOptions)
15+
}
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;
1335
}

storage/framework/.stacks/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from '../core/actions/src'
22
export * from '../core/ai/src'
3+
export * from '../core/api/src'
34
export * from '../core/alias/src'
45
export * from '../core/analytics/src'
56
export * as arrays from '../core/arrays/src'
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/* eslint-disable */
2+
/* prettier-ignore */
3+
// @ts-nocheck
4+
// noinspection JSUnusedGlobalSymbols
5+
// Generated by unplugin-auto-import
6+
export {}
7+
declare global {
8+
const EffectScope: typeof import('vue')['EffectScope']
9+
const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate']
10+
const computed: typeof import('vue')['computed']
11+
const createApp: typeof import('vue')['createApp']
12+
const createPinia: typeof import('pinia')['createPinia']
13+
const customRef: typeof import('vue')['customRef']
14+
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
15+
const defineComponent: typeof import('vue')['defineComponent']
16+
const defineStore: typeof import('pinia')['defineStore']
17+
const effectScope: typeof import('vue')['effectScope']
18+
const getActivePinia: typeof import('pinia')['getActivePinia']
19+
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
20+
const getCurrentScope: typeof import('vue')['getCurrentScope']
21+
const h: typeof import('vue')['h']
22+
const inject: typeof import('vue')['inject']
23+
const isProxy: typeof import('vue')['isProxy']
24+
const isReactive: typeof import('vue')['isReactive']
25+
const isReadonly: typeof import('vue')['isReadonly']
26+
const isRef: typeof import('vue')['isRef']
27+
const mapActions: typeof import('pinia')['mapActions']
28+
const mapGetters: typeof import('pinia')['mapGetters']
29+
const mapState: typeof import('pinia')['mapState']
30+
const mapStores: typeof import('pinia')['mapStores']
31+
const mapWritableState: typeof import('pinia')['mapWritableState']
32+
const markRaw: typeof import('vue')['markRaw']
33+
const nextTick: typeof import('vue')['nextTick']
34+
const onActivated: typeof import('vue')['onActivated']
35+
const onBeforeMount: typeof import('vue')['onBeforeMount']
36+
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
37+
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
38+
const onDeactivated: typeof import('vue')['onDeactivated']
39+
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
40+
const onMounted: typeof import('vue')['onMounted']
41+
const onRenderTracked: typeof import('vue')['onRenderTracked']
42+
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
43+
const onScopeDispose: typeof import('vue')['onScopeDispose']
44+
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
45+
const onUnmounted: typeof import('vue')['onUnmounted']
46+
const onUpdated: typeof import('vue')['onUpdated']
47+
const provide: typeof import('vue')['provide']
48+
const reactive: typeof import('vue')['reactive']
49+
const readonly: typeof import('vue')['readonly']
50+
const ref: typeof import('vue')['ref']
51+
const resolveComponent: typeof import('vue')['resolveComponent']
52+
const setActivePinia: typeof import('pinia')['setActivePinia']
53+
const setMapStoreSuffix: typeof import('pinia')['setMapStoreSuffix']
54+
const shallowReactive: typeof import('vue')['shallowReactive']
55+
const shallowReadonly: typeof import('vue')['shallowReadonly']
56+
const shallowRef: typeof import('vue')['shallowRef']
57+
const storeToRefs: typeof import('pinia')['storeToRefs']
58+
const toRaw: typeof import('vue')['toRaw']
59+
const toRef: typeof import('vue')['toRef']
60+
const toRefs: typeof import('vue')['toRefs']
61+
const toValue: typeof import('vue')['toValue']
62+
const triggerRef: typeof import('vue')['triggerRef']
63+
const unref: typeof import('vue')['unref']
64+
const useAttrs: typeof import('vue')['useAttrs']
65+
const useCssModule: typeof import('vue')['useCssModule']
66+
const useCssVars: typeof import('vue')['useCssVars']
67+
const useGithub: typeof import('./src/functions/github')['useGithub']
68+
const useI18n: typeof import('vue-i18n')['useI18n']
69+
const useSlots: typeof import('vue')['useSlots']
70+
const watch: typeof import('vue')['watch']
71+
const watchEffect: typeof import('vue')['watchEffect']
72+
const watchPostEffect: typeof import('vue')['watchPostEffect']
73+
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
74+
}
75+
// for type re-export
76+
declare global {
77+
// @ts-ignore
78+
export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
79+
import('vue')
80+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* eslint-disable */
2+
/* prettier-ignore */
3+
// @ts-nocheck
4+
// Generated by unplugin-vue-components
5+
// Read more: https://github.com/vuejs/core/pull/3399
6+
export {}
7+
8+
declare module 'vue' {
9+
export interface GlobalComponents {
10+
ActivityFeed: typeof import('./src/components/Deployments/ActivityFeed.vue')['default']
11+
Alert: typeof import('./src/components/Modals/Popups/Alert.vue')['default']
12+
AppButton: typeof import('./src/components/Buttons/AppButton.vue')['default']
13+
BaseModal: typeof import('./src/components/Modals/BaseModal.vue')['default']
14+
DeploymentList: typeof import('./src/components/Deployments/DeploymentList.vue')['default']
15+
MobileSidebar: typeof import('./src/components/MobileSidebar.vue')['default']
16+
Navbar: typeof import('./src/components/Navbar.vue')['default']
17+
Pagination: typeof import('./src/components/Pagination.vue')['default']
18+
RouterLink: typeof import('vue-router')['RouterLink']
19+
RouterView: typeof import('vue-router')['RouterView']
20+
SettingsHeader: typeof import('./src/components/SettingsHeader.vue')['default']
21+
Sidebar: typeof import('./src/components/Sidebar.vue')['default']
22+
Starport: typeof import('vue-starport')['Starport']
23+
StarportCarrier: typeof import('vue-starport')['StarportCarrier']
24+
Toast: typeof import('./src/components/Modals/Popups/Toast.vue')['default']
25+
ToastWrapper: typeof import('./src/components/Modals/ToastWrapper.vue')['default']
26+
}
27+
}

storage/framework/stacks/dashboard/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</head>
1818
<body class="font-sans">
1919
<div id="app"></div>
20-
<script type="module" src="/src/main.ts"></script>
20+
<script type="module" src="./src/main.ts"></script>
2121
<noscript>This website requires JavaScript to function properly. Please enable JavaScript to continue.</noscript>
2222
</body>
2323
</html>

0 commit comments

Comments
 (0)