@bagelink/vue 1.9.75 → 1.9.79

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.9.75",
4
+ "version": "1.9.79",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -27,7 +27,10 @@ const lightboxDirective: Directive = {
27
27
  },
28
28
  unmounted(el: HTMLElement) {
29
29
  el.removeEventListener('click', clickHandler)
30
- }
30
+ },
31
+ getSSRProps() {
32
+ return {}
33
+ },
31
34
  }
32
35
 
33
36
  function groupHandler(item: LightboxItem) {
@@ -77,7 +80,8 @@ function determineFileType(url: any): string {
77
80
 
78
81
  let lightboxInstance: InstanceType<typeof Lightbox> | undefined
79
82
 
80
- function getLightboxInstance(): InstanceType<typeof Lightbox> {
83
+ function getLightboxInstance(): InstanceType<typeof Lightbox> | undefined {
84
+ if (typeof document === 'undefined') { return undefined }
81
85
  if (!lightboxInstance) {
82
86
  const lightboxEl = document.createElement('div')
83
87
  document.body.prepend(lightboxEl)
@@ -1,17 +1,17 @@
1
1
  import { onMounted, onUnmounted, ref } from 'vue'
2
2
 
3
3
  export function useDevice() {
4
- const innerWidth = ref(window.innerWidth)
5
- const isMobile = ref(window.innerWidth < 768)
6
- const scrollY = ref(window.scrollY)
7
- const scrollX = ref(window.scrollX)
8
- const innerHeight = ref(window.innerHeight)
4
+ const innerWidth = ref(0)
5
+ const isMobile = ref(false)
6
+ const scrollY = ref(0)
7
+ const scrollX = ref(0)
8
+ const innerHeight = ref(0)
9
9
 
10
10
  // Scroll direction tracking
11
11
  const scrollDirY = ref<'up' | 'down' | null>(null)
12
12
  const scrollDirX = ref<'left' | 'right' | null>(null)
13
- const prevScrollY = ref(window.scrollY)
14
- const prevScrollX = ref(window.scrollX)
13
+ const prevScrollY = ref(0)
14
+ const prevScrollX = ref(0)
15
15
 
16
16
  function updateDeviceInfo() {
17
17
  // Store previous scroll positions
@@ -8,8 +8,10 @@ type LocalStoreTyped<T extends LocalStoreDefaults> = { [K in keyof T]: Ref<T[K]
8
8
  const _localStoreCache: Record<string, Ref> = {}
9
9
  let _storageListenerRegistered = false
10
10
 
11
+ const isBrowser = typeof window !== 'undefined'
12
+
11
13
  function _ensureListener() {
12
- if (_storageListenerRegistered) return
14
+ if (!isBrowser || _storageListenerRegistered) return
13
15
  _storageListenerRegistered = true
14
16
  window.addEventListener('storage', (e) => {
15
17
  if (e.key !== null && e.key in _localStoreCache) {
@@ -20,10 +22,10 @@ function _ensureListener() {
20
22
 
21
23
  function _getRef<T>(key: string, defaultValue: T | null = null): Ref<T | null> {
22
24
  if (!(key in _localStoreCache)) {
23
- const stored = localStorage.getItem(key)
25
+ const stored = isBrowser ? localStorage.getItem(key) : null
24
26
  _localStoreCache[key] = ref(stored !== null ? JSON.parse(stored) : defaultValue)
25
27
  watch(_localStoreCache[key], (val) => {
26
- localStorage.setItem(key, JSON.stringify(val))
28
+ if (isBrowser) localStorage.setItem(key, JSON.stringify(val))
27
29
  })
28
30
  }
29
31
  return _localStoreCache[key] as Ref<T | null>
@@ -37,8 +37,10 @@ const STORAGE_KEY = 'color-mode'
37
37
  const colorMode = ref<string>('system')
38
38
  const isDark = ref(false)
39
39
 
40
+ const isBrowser = typeof window !== 'undefined'
41
+
40
42
  function getSystemPrefersDark() {
41
- return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
43
+ return isBrowser && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
42
44
  }
43
45
 
44
46
  function findTheme(value: string) {
@@ -46,6 +48,7 @@ function findTheme(value: string) {
46
48
  }
47
49
 
48
50
  function applyTheme(themeValue: string) {
51
+ if (!isBrowser) return
49
52
  const root = document.documentElement
50
53
 
51
54
  // Remove all theme classes
@@ -139,7 +142,7 @@ export function useTheme() {
139
142
 
140
143
  // Watch for mode changes
141
144
  watch(colorMode, (newMode) => {
142
- window.localStorage.setItem(STORAGE_KEY, newMode)
145
+ if (isBrowser) localStorage.setItem(STORAGE_KEY, newMode)
143
146
  applyTheme(newMode)
144
147
  })
145
148
 
@@ -228,6 +228,9 @@ const pattern = {
228
228
 
229
229
  stateMap.delete(el)
230
230
  },
231
+ getSSRProps() {
232
+ return {}
233
+ },
231
234
  }
232
235
 
233
236
  export default pattern
@@ -54,6 +54,9 @@ const ripple: Directive<HTMLElement, boolean> = {
54
54
  delete (el as any).__rippleClickHandler
55
55
  }
56
56
  },
57
+ getSSRProps() {
58
+ return {}
59
+ },
57
60
  }
58
61
 
59
62
  export default ripple
@@ -201,5 +201,8 @@ export const vResize: Directive<HTMLElement, ResizeOptions> = {
201
201
  }
202
202
  initResize(el, binding)
203
203
  }
204
- }
204
+ },
205
+ getSSRProps() {
206
+ return {}
207
+ },
205
208
  }
@@ -675,7 +675,7 @@ showdown.Converter = function (this: any, converterOptions?: ShowdownOptions) {
675
675
  src = src.replace(/>[ \t]+</, '>¨NBSP;<')
676
676
 
677
677
  if (!HTMLParser) {
678
- if (window && window.document) {
678
+ if (typeof window !== 'undefined' && window.document) {
679
679
  HTMLParser = window.document
680
680
  } else {
681
681
  throw new Error('HTMLParser is undefined. If in a webworker or nodejs environment, you need to provide a WHATWG DOM and HTML such as JSDOM')