Skip to content

Commit fc94340

Browse files
committed
chore: wip
1 parent d0df446 commit fc94340

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+646
-254
lines changed

bun.lock

Lines changed: 24 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

storage/framework/core/browser/src/composables/auth/useGithub.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Ref } from 'vue'
2-
import { onMounted, ref } from 'vue'
1+
import type { Ref } from '@stacksjs/stx'
2+
import { onMounted, ref } from '@stacksjs/stx'
33

44
interface GitHubOAuthReturn {
55
login: () => void
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
export * from './useAuth'
22
export * from './useApi'
3+
4+
// Re-export all composables from @stacksjs/composables
5+
export {
6+
useDark,
7+
useDateFormat,
8+
useFetch,
9+
useNow,
10+
useOnline,
11+
usePreferredDark,
12+
useStorage,
13+
useToggle,
14+
} from '@stacksjs/composables'

storage/framework/core/browser/src/composables/useAuth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { AuthComposable, AuthUser, ErrorResponse, LoginError, LoginResponse, MeResponse, RegisterError, RegisterResponse, UserData } from '../types/dashboard'
2-
import { useStorage } from '@vueuse/core'
2+
import { useStorage } from '@stacksjs/composables'
33
/// <reference lib="dom" />
4-
import { ref } from 'vue'
4+
import { ref } from '@stacksjs/stx'
55

66
const token = useStorage('token', '')
77

Lines changed: 1 addition & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1 @@
1-
import type { Ref } from 'vue'
2-
import { ofetch } from 'ofetch'
3-
import { ref } from 'vue'
4-
5-
interface Params {
6-
[key: string]: any
7-
}
8-
9-
type FetchResponse = string | Blob | ArrayBuffer | ReadableStream<Uint8Array>
10-
11-
interface UseFetchReturn {
12-
get: (url: string, params?: Params, headers?: Headers) => Promise<FetchResponse>
13-
post: (url: string, params?: Params, headers?: Headers) => Promise<FetchResponse>
14-
patch: (url: string, params?: Params, headers?: Headers) => Promise<FetchResponse>
15-
put: (url: string, params?: Params, headers?: Headers) => Promise<FetchResponse>
16-
destroy: (url: string, params?: Params, headers?: Headers) => Promise<FetchResponse>
17-
setToken: (authToken: string) => void
18-
loading: Ref<boolean>
19-
token: Ref<string>
20-
baseURL: Ref<string>
21-
}
22-
23-
export function useFetch(): UseFetchReturn {
24-
const loading = ref(false)
25-
const token = ref('')
26-
const baseURL = ref('/')
27-
28-
const setToken = (authToken: string): void => {
29-
token.value = authToken
30-
}
31-
32-
const getHeaders = (headers?: Headers): Headers | undefined => {
33-
if (headers && token.value) {
34-
headers.set('Authorization', `Bearer ${token.value}`)
35-
}
36-
return headers
37-
}
38-
39-
const get = async (url: string, params?: Params, headers?: Headers): Promise<FetchResponse> => {
40-
return await ofetch(url, {
41-
method: 'GET',
42-
baseURL: baseURL.value,
43-
params,
44-
headers: getHeaders(headers),
45-
})
46-
}
47-
48-
const post = async (url: string, params?: Params, headers?: Headers): Promise<FetchResponse> => {
49-
loading.value = true
50-
try {
51-
const result = await ofetch(url, {
52-
method: 'POST',
53-
baseURL: baseURL.value,
54-
params,
55-
headers: getHeaders(headers),
56-
})
57-
return result
58-
}
59-
finally {
60-
loading.value = false
61-
}
62-
}
63-
64-
const patch = async (url: string, params?: Params, headers?: Headers): Promise<FetchResponse> => {
65-
loading.value = true
66-
try {
67-
return await ofetch(url, {
68-
method: 'PATCH',
69-
baseURL: baseURL.value,
70-
params,
71-
headers: getHeaders(headers),
72-
})
73-
}
74-
finally {
75-
loading.value = false
76-
}
77-
}
78-
79-
const put = async (url: string, params?: Params, headers?: Headers): Promise<FetchResponse> => {
80-
loading.value = true
81-
try {
82-
return await ofetch(url, {
83-
method: 'PUT',
84-
baseURL: baseURL.value,
85-
params,
86-
headers: getHeaders(headers),
87-
})
88-
}
89-
finally {
90-
loading.value = false
91-
}
92-
}
93-
94-
const destroy = async (url: string, params?: Params, headers?: Headers): Promise<FetchResponse> => {
95-
loading.value = true
96-
try {
97-
return await ofetch(url, {
98-
method: 'DELETE',
99-
baseURL: baseURL.value,
100-
params,
101-
headers: getHeaders(headers),
102-
})
103-
}
104-
finally {
105-
loading.value = false
106-
}
107-
}
108-
109-
return {
110-
get,
111-
post,
112-
patch,
113-
put,
114-
destroy,
115-
setToken,
116-
loading,
117-
token,
118-
baseURL,
119-
}
120-
}
1+
export { useFetch } from '@stacksjs/composables'

storage/framework/core/browser/src/types/dashboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Ref } from 'vue'
1+
import type { Ref } from '@stacksjs/stx'
22

33
export interface ValidationError {
44
[key: string]: {
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
// Export date utilities directly to avoid circular dependency with @stacksjs/datetime
2-
export { useDateFormat, useNow } from '@vueuse/core'
3-
export { format } from '@stacksjs/datetime'
4-
export { parse } from '@stacksjs/datetime'
1+
export { useDateFormat, useNow } from '@stacksjs/composables'
2+
export { format, parse } from '@stacksjs/datetime'

storage/framework/core/browser/src/utils/math.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ export function rand(min: number, max: number): number {
66
return Math.floor(Math.random() * (max - min + 1)) + min
77
}
88

9-
// not, -> exported as well in ../regex
9+
// Re-export reactive math utilities from @stacksjs/composables
1010
export {
1111
and,
12-
createGenericProjection,
13-
createProjection,
1412
logicNot,
1513
logicOr,
1614
or,
@@ -19,12 +17,10 @@ export {
1917
useCeil,
2018
useClamp,
2119
useFloor,
22-
useMath,
2320
useMax,
2421
useMin,
2522
usePrecision,
26-
useProjection,
2723
useRound,
2824
useSum,
2925
useTrunc,
30-
} from '@vueuse/math'
26+
} from '@stacksjs/composables'

storage/framework/core/browser/src/utils/vendors.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// Only re-export composables that are actually used in the codebase.
2-
// The full set of 240+ composables was causing excessive type resolution
3-
// that crashed Bun's JSC engine on CI runners (SIGILL / OOM at ~1GB RSS).
4-
// useDateFormat and useNow are also exported from ./date.ts.
1+
// Re-export composables from @stacksjs/composables
52
export {
63
useDark,
74
useDateFormat,
@@ -11,7 +8,7 @@ export {
118
usePreferredDark,
129
useStorage,
1310
useToggle,
14-
} from '@vueuse/core'
11+
} from '@stacksjs/composables'
1512

1613
export type {
1714
HeadObject,

storage/framework/core/calendar/src/generators/google.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { CalendarLink } from '../types'
2-
import { useDateFormat } from '@stacksjs/browser'
2+
import { format } from '@stacksjs/datetime'
33

44
const dateFormat = 'YYYYMMDD'
55
const timeFormat = 'YYYYMMDDThhmmss'
@@ -12,8 +12,8 @@ export function generateGoogle(link: CalendarLink): string {
1212
const utcEndDateTime = convertTZ(link.to, 'UTC') // set timezone to UTC
1313
const dateTimeFormat = link.allDay ? dateFormat : timeFormat
1414

15-
url = `${url}&dates=${useDateFormat(utcStartDateTime, dateTimeFormat).value}/${
16-
useDateFormat(utcEndDateTime, dateTimeFormat).value
15+
url = `${url}&dates=${format(utcStartDateTime, dateTimeFormat)}/${
16+
format(utcEndDateTime, dateTimeFormat)
1717
}`
1818

1919
if (link.timezone)

0 commit comments

Comments
 (0)