Skip to content

Commit 5a49ae4

Browse files
committed
fix runtime dep order issue
1 parent 8b28d27 commit 5a49ae4

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

src/use/config.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { AppMetadata, AuthenticateResponse, AutoQueryGridDefaults, UiConfig } from "@/types"
22
import { ref, computed, type Component } from "vue"
3-
import { LocalStore } from "./utils"
43
import { getFormatters } from "./formatters"
54
import { enumFlagsConverter } from "./metadata"
65
import { createBus, toKebabCase } from "@servicestack/client"
@@ -23,6 +22,31 @@ export class Interceptors {
2322
}
2423
}
2524

25+
/** SSR safe wrapper around localStorage */
26+
export class LocalStore implements Storage {
27+
get length() { return typeof localStorage == "undefined" ? 0 : localStorage.length }
28+
getItem(key:string) {
29+
if (typeof localStorage == "undefined") return null
30+
return localStorage.getItem(key)
31+
}
32+
setItem(key:string, value:string) {
33+
if (typeof localStorage == "undefined") return
34+
localStorage.setItem(key, value)
35+
}
36+
removeItem(key:string) {
37+
if (typeof localStorage == "undefined") return
38+
localStorage.removeItem(key)
39+
}
40+
clear() {
41+
if (typeof localStorage == "undefined") return
42+
localStorage.clear()
43+
}
44+
key(index: number) {
45+
if (typeof localStorage == "undefined") return null
46+
return localStorage.key(index)
47+
}
48+
}
49+
2650
export class Sole {
2751
static config:UiConfig = {
2852
redirectSignIn: '/signin',

src/use/utils.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -144,30 +144,6 @@ export function isPrimitive(value:any) { return scalarTypes.indexOf(typeof value
144144
/** Check if value is a non-scalar type */
145145
export function isComplexType(value:any) { return !isPrimitive(value) }
146146

147-
/** SSR safe wrapper around localStorage */
148-
export class LocalStore implements Storage {
149-
get length() { return typeof localStorage == "undefined" ? 0 : localStorage.length }
150-
getItem(key:string) {
151-
if (typeof localStorage == "undefined") return null
152-
return localStorage.getItem(key)
153-
}
154-
setItem(key:string, value:string) {
155-
if (typeof localStorage == "undefined") return
156-
localStorage.setItem(key, value)
157-
}
158-
removeItem(key:string) {
159-
if (typeof localStorage == "undefined") return
160-
localStorage.removeItem(key)
161-
}
162-
clear() {
163-
if (typeof localStorage == "undefined") return
164-
localStorage.clear()
165-
}
166-
key(index: number) {
167-
if (typeof localStorage == "undefined") return null
168-
return localStorage.key(index)
169-
}
170-
}
171147
export function parseJson(json?:string|null) {
172148
return typeof json == 'string' ? JSON.parse(json) : null
173149
}
@@ -251,7 +227,6 @@ export function delay(ms:number) {
251227

252228
export function useUtils() {
253229
return {
254-
LocalStore,
255230
dateInputFormat,
256231
dateTimeInputFormat,
257232
timeInputFormat,

0 commit comments

Comments
 (0)