@globalbrain/sefirot 3.22.1 → 3.23.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.
@@ -30,7 +30,7 @@ export function useQuery<Data = any>(
30
30
  const loading = ref(false)
31
31
  const data = ref<Data | undefined>()
32
32
 
33
- if (options.immediate !== false) {
33
+ if (options.immediate !== false && !import.meta.env.SSR) {
34
34
  execute()
35
35
  }
36
36
 
package/lib/http/Http.ts CHANGED
@@ -1,12 +1,36 @@
1
1
  import { parse as parseContentDisposition } from '@tinyhttp/content-disposition'
2
2
  import { parse as parseCookie } from '@tinyhttp/cookie'
3
3
  import FileSaver from 'file-saver'
4
- import { $fetch, type FetchOptions } from 'ofetch'
4
+ import { type FetchOptions, type FetchRequest, type FetchResponse, ofetch } from 'ofetch'
5
5
  import { stringify } from 'qs'
6
6
 
7
+ export interface HttpClient {
8
+ <T = any>(request: FetchRequest, options?: Omit<FetchOptions, 'method'>): Promise<T>
9
+ raw<T = any>(request: FetchRequest, options?: Omit<FetchOptions, 'method'>): Promise<FetchResponse<T>>
10
+ }
11
+
12
+ export interface HttpOptions {
13
+ baseUrl?: string
14
+ xsrfUrl?: string | false
15
+ client?: HttpClient
16
+ }
17
+
7
18
  export class Http {
8
- static base: string | undefined = undefined
9
- static xsrfUrl: string | false = '/api/csrf-cookie'
19
+ private static baseUrl: string | undefined = undefined
20
+ private static xsrfUrl: string | false = '/api/csrf-cookie'
21
+ private static client: HttpClient = ofetch
22
+
23
+ static config(options: HttpOptions) {
24
+ if (options.baseUrl) {
25
+ Http.baseUrl = options.baseUrl
26
+ }
27
+ if (options.xsrfUrl !== undefined) {
28
+ Http.xsrfUrl = options.xsrfUrl
29
+ }
30
+ if (options.client) {
31
+ Http.client = options.client
32
+ }
33
+ }
10
34
 
11
35
  private async ensureXsrfToken(): Promise<string | undefined> {
12
36
  if (!Http.xsrfUrl) {
@@ -40,7 +64,7 @@ export class Http {
40
64
  return [
41
65
  `${url}${queryString ? `?${queryString}` : ''}`,
42
66
  {
43
- baseURL: Http.base,
67
+ baseURL: Http.baseUrl,
44
68
  method,
45
69
  credentials: 'include',
46
70
  ...options,
@@ -54,11 +78,11 @@ export class Http {
54
78
  }
55
79
 
56
80
  private async performRequest<T>(url: string, options: FetchOptions = {}) {
57
- return $fetch<T, any>(...(await this.buildRequest(url, options)))
81
+ return Http.client<T>(...(await this.buildRequest(url, options)))
58
82
  }
59
83
 
60
84
  private async performRequestRaw<T>(url: string, options: FetchOptions = {}) {
61
- return $fetch.raw<T, any>(...(await this.buildRequest(url, options)))
85
+ return Http.client.raw<T>(...(await this.buildRequest(url, options)))
62
86
  }
63
87
 
64
88
  async get<T = any>(url: string, options?: FetchOptions): Promise<T> {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "3.22.1",
4
- "packageManager": "pnpm@8.14.0",
3
+ "version": "3.23.0",
4
+ "packageManager": "pnpm@8.14.1",
5
5
  "description": "Vue Components for Global Brain Design System.",
6
6
  "author": "Kia Ishii <ka.ishii@globalbrains.com>",
7
7
  "license": "MIT",
@@ -56,7 +56,7 @@
56
56
  "postcss": "^8.4.33",
57
57
  "postcss-nested": "^6.0.1",
58
58
  "v-calendar": "^3.1.2",
59
- "vue": "^3.4.5",
59
+ "vue": "^3.4.10",
60
60
  "vue-router": "^4.2.5"
61
61
  },
62
62
  "dependencies": {
@@ -80,9 +80,9 @@
80
80
  "@types/body-scroll-lock": "^3.1.2",
81
81
  "@types/lodash-es": "^4.17.12",
82
82
  "@types/markdown-it": "^13.0.7",
83
- "@types/node": "^20.10.6",
84
- "@vitejs/plugin-vue": "^5.0.2",
85
- "@vitest/coverage-v8": "^1.1.2",
83
+ "@types/node": "^20.11.0",
84
+ "@vitejs/plugin-vue": "^5.0.3",
85
+ "@vitest/coverage-v8": "^1.1.3",
86
86
  "@vue/test-utils": "^2.4.3",
87
87
  "@vuelidate/core": "^2.0.3",
88
88
  "@vuelidate/validators": "^2.0.4",
@@ -90,7 +90,7 @@
90
90
  "body-scroll-lock": "4.0.0-beta.0",
91
91
  "eslint": "^8.56.0",
92
92
  "fuse.js": "^7.0.0",
93
- "happy-dom": "^12.10.3",
93
+ "happy-dom": "^13.0.2",
94
94
  "histoire": "^0.17.6",
95
95
  "lodash-es": "^4.17.21",
96
96
  "markdown-it": "^14.0.0",
@@ -102,10 +102,10 @@
102
102
  "release-it": "^17.0.1",
103
103
  "typescript": "~5.3.3",
104
104
  "v-calendar": "^3.1.2",
105
- "vite": "^5.0.10",
106
- "vitepress": "1.0.0-rc.35",
107
- "vitest": "^1.1.2",
108
- "vue": "^3.4.5",
105
+ "vite": "^5.0.11",
106
+ "vitepress": "1.0.0-rc.36",
107
+ "vitest": "^1.1.3",
108
+ "vue": "^3.4.10",
109
109
  "vue-router": "^4.2.5",
110
110
  "vue-tsc": "^1.8.27"
111
111
  }