@bquery/bquery 1.8.1 → 1.9.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.
- package/README.md +97 -25
- package/dist/{a11y-DVBCy09c.js → a11y-_9X-kt-_.js} +2 -2
- package/dist/{a11y-DVBCy09c.js.map → a11y-_9X-kt-_.js.map} +1 -1
- package/dist/a11y.es.mjs +1 -1
- package/dist/{forms-UcRHsYxC.js → forms-UhAeJEoO.js} +13 -13
- package/dist/{forms-UcRHsYxC.js.map → forms-UhAeJEoO.js.map} +1 -1
- package/dist/forms.es.mjs +1 -1
- package/dist/full.d.ts +4 -4
- package/dist/full.d.ts.map +1 -1
- package/dist/full.es.mjs +201 -196
- package/dist/full.iife.js +20 -20
- package/dist/full.iife.js.map +1 -1
- package/dist/full.umd.js +20 -20
- package/dist/full.umd.js.map +1 -1
- package/dist/index.es.mjs +214 -209
- package/dist/media/index.d.ts +10 -3
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/observers.d.ts +99 -0
- package/dist/media/observers.d.ts.map +1 -0
- package/dist/media/types.d.ts +125 -0
- package/dist/media/types.d.ts.map +1 -1
- package/dist/media-D4zLj9t-.js +514 -0
- package/dist/media-D4zLj9t-.js.map +1 -0
- package/dist/media.es.mjs +12 -9
- package/dist/mount-B-JvH6Y0.js +449 -0
- package/dist/mount-B-JvH6Y0.js.map +1 -0
- package/dist/reactive/index.d.ts +2 -2
- package/dist/reactive/index.d.ts.map +1 -1
- package/dist/reactive/signal.d.ts +2 -1
- package/dist/reactive/signal.d.ts.map +1 -1
- package/dist/reactive/watch.d.ts +49 -0
- package/dist/reactive/watch.d.ts.map +1 -1
- package/dist/reactive-BjpLkclt.js +1184 -0
- package/dist/{reactive-DwkhUJfP.js.map → reactive-BjpLkclt.js.map} +1 -1
- package/dist/reactive.es.mjs +35 -33
- package/dist/{router-CQikC9Ed.js → router-BieVwgci.js} +2 -2
- package/dist/{router-CQikC9Ed.js.map → router-BieVwgci.js.map} +1 -1
- package/dist/router.es.mjs +1 -1
- package/dist/{ssr-_dAcGdzu.js → ssr-CrGSJySz.js} +3 -3
- package/dist/{ssr-_dAcGdzu.js.map → ssr-CrGSJySz.js.map} +1 -1
- package/dist/ssr.es.mjs +1 -1
- package/dist/{store-Cb3gPRve.js → store-CY6sjTW3.js} +2 -2
- package/dist/{store-Cb3gPRve.js.map → store-CY6sjTW3.js.map} +1 -1
- package/dist/store.es.mjs +1 -1
- package/dist/{testing-C5Sjfsna.js → testing-UjAtu9aQ.js} +9 -9
- package/dist/{testing-C5Sjfsna.js.map → testing-UjAtu9aQ.js.map} +1 -1
- package/dist/testing.es.mjs +1 -1
- package/dist/view/directives/aria.d.ts +7 -0
- package/dist/view/directives/aria.d.ts.map +1 -0
- package/dist/view/directives/error.d.ts +7 -0
- package/dist/view/directives/error.d.ts.map +1 -0
- package/dist/view/directives/index.d.ts +2 -0
- package/dist/view/directives/index.d.ts.map +1 -1
- package/dist/view/mount.d.ts.map +1 -1
- package/dist/view/process.d.ts +2 -0
- package/dist/view/process.d.ts.map +1 -1
- package/dist/view.es.mjs +2 -2
- package/package.json +7 -6
- package/src/full.ts +12 -0
- package/src/media/index.ts +20 -2
- package/src/media/observers.ts +421 -0
- package/src/media/types.ts +136 -0
- package/src/reactive/index.ts +3 -0
- package/src/reactive/signal.ts +2 -1
- package/src/reactive/watch.ts +137 -0
- package/src/view/directives/aria.ts +72 -0
- package/src/view/directives/error.ts +56 -0
- package/src/view/directives/index.ts +2 -0
- package/src/view/mount.ts +4 -0
- package/src/view/process.ts +6 -0
- package/dist/media-i-fB5WxI.js +0 -340
- package/dist/media-i-fB5WxI.js.map +0 -1
- package/dist/mount-B4Y8bk8Z.js +0 -403
- package/dist/mount-B4Y8bk8Z.js.map +0 -1
- package/dist/reactive-DwkhUJfP.js +0 -1148
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-D4zLj9t-.js","names":[],"sources":["../src/media/media-query.ts","../src/media/breakpoints.ts","../src/media/viewport.ts","../src/media/network.ts","../src/media/battery.ts","../src/media/geolocation.ts","../src/media/device-sensors.ts","../src/media/clipboard.ts","../src/media/observers.ts"],"sourcesContent":["/**\n * Reactive media query matching.\n *\n * Returns a reactive boolean signal that tracks whether a CSS media query matches.\n *\n * @module bquery/media\n */\n\nimport { readonly, signal } from '../reactive/index';\nimport type { MediaSignalHandle } from './types';\n\n/**\n * Creates a reactive signal that tracks whether a CSS media query matches.\n *\n * Uses `window.matchMedia()` under the hood and automatically updates\n * when the match state changes (e.g., on window resize, device orientation change).\n *\n * @param query - A valid CSS media query string (e.g., `'(min-width: 768px)'`)\n * @returns A readonly reactive signal that is `true` when the query matches,\n * plus a `destroy()` method to remove the media query listener\n *\n * @example\n * ```ts\n * import { mediaQuery } from '@bquery/bquery/media';\n * import { effect } from '@bquery/bquery/reactive';\n *\n * const isDark = mediaQuery('(prefers-color-scheme: dark)');\n * effect(() => {\n * document.body.classList.toggle('dark', isDark.value);\n * });\n *\n * const isWide = mediaQuery('(min-width: 1024px)');\n * effect(() => {\n * console.log('Wide screen:', isWide.value);\n * });\n * ```\n */\nexport const mediaQuery = (query: string): MediaSignalHandle<boolean> => {\n const s = signal(false);\n let cleanup: (() => void) | undefined;\n\n if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {\n try {\n const mql = window.matchMedia(query);\n s.value = mql.matches;\n\n const handler = (e: MediaQueryListEvent): void => {\n s.value = e.matches;\n };\n\n if (typeof mql.addEventListener === 'function') {\n mql.addEventListener('change', handler);\n cleanup = () => {\n mql.removeEventListener('change', handler);\n };\n } else if (\n typeof (\n mql as MediaQueryList & {\n addListener?: (listener: (event: MediaQueryListEvent) => void) => void;\n removeListener?: (listener: (event: MediaQueryListEvent) => void) => void;\n }\n ).addListener === 'function'\n ) {\n const legacyMql = mql as MediaQueryList & {\n addListener: (listener: (event: MediaQueryListEvent) => void) => void;\n removeListener: (listener: (event: MediaQueryListEvent) => void) => void;\n };\n legacyMql.addListener(handler);\n cleanup = () => {\n legacyMql.removeListener(handler);\n };\n }\n } catch {\n // matchMedia may throw in non-browser environments\n }\n }\n\n const ro = readonly(s) as MediaSignalHandle<boolean>;\n let destroyed = false;\n Object.defineProperty(ro, 'destroy', {\n enumerable: false,\n configurable: true,\n value(): void {\n if (destroyed) return;\n destroyed = true;\n cleanup?.();\n s.dispose();\n },\n });\n\n return ro;\n};\n","/**\n * Named breakpoint signals.\n *\n * Defines named breakpoints that return reactive boolean signals,\n * making it easy to respond to viewport size changes.\n *\n * @module bquery/media\n */\n\nimport { readonly, signal } from '../reactive/index';\nimport type { BreakpointMap, MediaSignalHandle } from './types';\n\ntype BreakpointSignals<T extends BreakpointMap> = { [K in keyof T]: MediaSignalHandle<boolean> } & {\n destroyAll(): void;\n} & ('destroy' extends keyof T ? Record<never, never> : { destroy(): void });\n\n/**\n * Defines named breakpoints and returns reactive boolean signals for each.\n *\n * Each breakpoint is a minimum-width media query. The returned object maps\n * each breakpoint name to a `ReadonlySignal<boolean>` that is `true` when\n * the viewport width is at or above the breakpoint value.\n *\n * @param bp - An object mapping breakpoint names to minimum widths in pixels\n * @returns An object with the same keys, each a reactive boolean signal with\n * `destroy()`, plus a top-level `destroyAll()` method to clean up all listeners.\n * When no breakpoint is named `destroy`, a `destroy()` alias is also provided.\n *\n * @example\n * ```ts\n * import { breakpoints } from '@bquery/bquery/media';\n * import { effect } from '@bquery/bquery/reactive';\n *\n * const bp = breakpoints({ sm: 640, md: 768, lg: 1024, xl: 1280 });\n *\n * effect(() => {\n * if (bp.xl.value) {\n * console.log('Extra large viewport');\n * } else if (bp.lg.value) {\n * console.log('Large viewport');\n * } else if (bp.md.value) {\n * console.log('Medium viewport');\n * } else {\n * console.log('Small viewport');\n * }\n * });\n * ```\n */\nexport const breakpoints = <T extends BreakpointMap>(bp: T): BreakpointSignals<T> => {\n const signals = {} as { [K in keyof T]: MediaSignalHandle<boolean> };\n const destroyers: Array<() => void> = [];\n\n type LegacyMediaQueryList = MediaQueryList & {\n addListener?: (listener: (event: MediaQueryListEvent | MediaQueryList) => void) => void;\n removeListener?: (listener: (event: MediaQueryListEvent | MediaQueryList) => void) => void;\n };\n\n for (const key of Object.keys(bp) as Array<keyof T>) {\n const width = bp[key];\n const s = signal(false);\n let cleanup: (() => void) | undefined;\n\n if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {\n try {\n const mql = window.matchMedia(`(min-width: ${width}px)`);\n s.value = mql.matches;\n\n const handler = (e: MediaQueryListEvent | MediaQueryList): void => {\n s.value = e.matches;\n };\n\n if (typeof mql.addEventListener === 'function') {\n mql.addEventListener('change', handler);\n cleanup = () => {\n mql.removeEventListener('change', handler);\n };\n } else {\n const legacyMql = mql as LegacyMediaQueryList;\n if (typeof legacyMql.addListener === 'function') {\n legacyMql.addListener(handler);\n cleanup = () => {\n legacyMql.removeListener?.(handler);\n };\n }\n }\n } catch {\n // matchMedia may throw in non-browser environments\n }\n }\n\n const ro = readonly(s) as MediaSignalHandle<boolean>;\n let destroyed = false;\n Object.defineProperty(ro, 'destroy', {\n enumerable: false,\n configurable: true,\n value(): void {\n if (destroyed) return;\n destroyed = true;\n cleanup?.();\n s.dispose();\n },\n });\n destroyers.push(ro.destroy);\n signals[key] = ro;\n }\n\n let destroyed = false;\n const result = Object.defineProperty(signals, 'destroyAll', {\n enumerable: false,\n configurable: true,\n value(): void {\n if (destroyed) return;\n destroyed = true;\n destroyers.forEach((destroy) => {\n destroy();\n });\n },\n }) as BreakpointSignals<T>;\n\n if (!Object.prototype.hasOwnProperty.call(signals, 'destroy')) {\n Object.defineProperty(result, 'destroy', {\n enumerable: false,\n configurable: true,\n value: result.destroyAll,\n });\n }\n\n return result;\n};\n","/**\n * Reactive viewport dimensions.\n *\n * Provides a reactive signal tracking the browser viewport's\n * width, height, and orientation.\n *\n * @module bquery/media\n */\n\nimport { readonly, signal } from '../reactive/index';\nimport type { ViewportSignal, ViewportState } from './types';\n\n/**\n * Computes orientation from width and height.\n * @internal\n */\nconst getOrientation = (w: number, h: number): 'portrait' | 'landscape' =>\n h >= w ? 'portrait' : 'landscape';\n\n/**\n * Returns a reactive signal tracking the current viewport dimensions and orientation.\n *\n * Updates automatically when the window is resized. Uses `window.innerWidth`\n * and `window.innerHeight` under the hood.\n *\n * @returns A readonly reactive signal with `{ width, height, orientation }`\n * and a `destroy()` method to remove the resize listener\n *\n * @example\n * ```ts\n * import { useViewport } from '@bquery/bquery/media';\n * import { effect } from '@bquery/bquery/reactive';\n *\n * const viewport = useViewport();\n * effect(() => {\n * console.log(`Viewport: ${viewport.value.width}x${viewport.value.height}`);\n * console.log(`Orientation: ${viewport.value.orientation}`);\n * });\n * ```\n */\nexport const useViewport = (): ViewportSignal => {\n const initial: ViewportState = {\n width: typeof window !== 'undefined' ? window.innerWidth : 0,\n height: typeof window !== 'undefined' ? window.innerHeight : 0,\n orientation:\n typeof window !== 'undefined'\n ? getOrientation(window.innerWidth, window.innerHeight)\n : 'portrait',\n };\n\n const s = signal<ViewportState>(initial);\n\n let cleanup: (() => void) | undefined;\n\n if (typeof window !== 'undefined') {\n const handler = (): void => {\n s.value = {\n width: window.innerWidth,\n height: window.innerHeight,\n orientation: getOrientation(window.innerWidth, window.innerHeight),\n };\n };\n\n window.addEventListener('resize', handler);\n cleanup = () => {\n window.removeEventListener('resize', handler);\n };\n }\n\n const ro = readonly(s) as ViewportSignal;\n let destroyed = false;\n Object.defineProperty(ro, 'destroy', {\n enumerable: false,\n configurable: true,\n value: (): void => {\n if (destroyed) return;\n destroyed = true;\n cleanup?.();\n s.dispose();\n },\n });\n\n return ro;\n};\n","/**\n * Reactive network status.\n *\n * Provides a reactive signal tracking the browser's network connectivity\n * and connection quality via the Network Information API.\n *\n * @module bquery/media\n */\n\nimport { readonly, signal } from '../reactive/index';\nimport type { NetworkSignal, NetworkState } from './types';\n\n/**\n * Navigator connection interface for the Network Information API.\n * @internal\n */\ninterface NavigatorConnection extends EventTarget {\n effectiveType?: string;\n downlink?: number;\n rtt?: number;\n}\n\n/**\n * Extended Navigator with connection property.\n * @internal\n */\ninterface NavigatorWithConnection extends Navigator {\n connection?: NavigatorConnection;\n}\n\n/**\n * Reads current network state from browser APIs.\n * @internal\n */\nconst getNetworkState = (): NetworkState => {\n const online =\n typeof navigator !== 'undefined' && navigator.onLine !== undefined ? navigator.onLine : true;\n\n const nav = typeof navigator !== 'undefined' ? (navigator as NavigatorWithConnection) : undefined;\n const conn = nav?.connection;\n\n return {\n online,\n effectiveType: conn?.effectiveType ?? 'unknown',\n downlink: conn?.downlink ?? 0,\n rtt: conn?.rtt ?? 0,\n };\n};\n\n/**\n * Returns a reactive signal tracking network connectivity and quality.\n *\n * Tracks whether the browser is online/offline and, where supported,\n * the effective connection type, downlink speed, and round-trip time\n * via the Network Information API.\n *\n * @returns A readonly reactive signal with `{ online, effectiveType, downlink, rtt }`\n * and a `destroy()` method to remove attached listeners\n *\n * @example\n * ```ts\n * import { useNetworkStatus } from '@bquery/bquery/media';\n * import { effect } from '@bquery/bquery/reactive';\n *\n * const net = useNetworkStatus();\n * effect(() => {\n * if (!net.value.online) {\n * console.warn('You are offline!');\n * }\n * console.log(`Connection: ${net.value.effectiveType}, RTT: ${net.value.rtt}ms`);\n * });\n * ```\n */\nexport const useNetworkStatus = (): NetworkSignal => {\n const s = signal<NetworkState>(getNetworkState());\n let cleanup: (() => void) | undefined;\n\n if (typeof window !== 'undefined') {\n const update = (): void => {\n s.value = getNetworkState();\n };\n\n window.addEventListener('online', update);\n window.addEventListener('offline', update);\n\n const nav =\n typeof navigator !== 'undefined' ? (navigator as NavigatorWithConnection) : undefined;\n if (nav?.connection && typeof nav.connection.addEventListener === 'function') {\n nav.connection.addEventListener('change', update);\n }\n\n cleanup = () => {\n window.removeEventListener('online', update);\n window.removeEventListener('offline', update);\n if (nav?.connection && typeof nav.connection.removeEventListener === 'function') {\n nav.connection.removeEventListener('change', update);\n }\n };\n }\n\n const ro = readonly(s) as NetworkSignal;\n let destroyed = false;\n Object.defineProperty(ro, 'destroy', {\n value(): void {\n if (destroyed) return;\n destroyed = true;\n cleanup?.();\n s.dispose();\n },\n enumerable: false,\n configurable: true,\n });\n\n return ro;\n};\n","/**\n * Reactive battery status.\n *\n * Provides a reactive signal tracking the device's battery status\n * via the Battery Status API.\n *\n * @module bquery/media\n */\n\nimport { signal, readonly } from '../reactive/index';\nimport type { BatterySignal, BatteryState } from './types';\n\n/**\n * BatteryManager interface for the Battery Status API.\n * @internal\n */\ninterface BatteryManager extends EventTarget {\n charging: boolean;\n chargingTime: number;\n dischargingTime: number;\n level: number;\n}\n\n/** Default battery state when API is unavailable. */\nconst DEFAULT_BATTERY_STATE: BatteryState = {\n supported: false,\n charging: false,\n chargingTime: 0,\n dischargingTime: 0,\n level: 1,\n};\n\n/**\n * Returns a reactive signal tracking the device's battery status.\n *\n * Uses the Battery Status API (`navigator.getBattery()`) where available.\n * Falls back gracefully to a default state with `supported: false` when\n * the API is not available.\n *\n * @returns A readonly reactive signal with battery state and a `destroy()` method\n * to remove Battery Status API listeners\n *\n * @example\n * ```ts\n * import { useBattery } from '@bquery/bquery/media';\n * import { effect } from '@bquery/bquery/reactive';\n *\n * const battery = useBattery();\n * effect(() => {\n * if (battery.value.supported) {\n * console.log(`Battery: ${(battery.value.level * 100).toFixed(0)}%`);\n * console.log(`Charging: ${battery.value.charging}`);\n * }\n * });\n * ```\n */\nexport const useBattery = (): BatterySignal => {\n const s = signal<BatteryState>({ ...DEFAULT_BATTERY_STATE });\n let cleanup: (() => void) | undefined;\n let destroyed = false;\n\n if (\n typeof navigator !== 'undefined' &&\n 'getBattery' in navigator &&\n typeof (navigator as Navigator & { getBattery: () => Promise<BatteryManager> }).getBattery ===\n 'function'\n ) {\n const nav = navigator as Navigator & { getBattery: () => Promise<BatteryManager> };\n\n nav\n .getBattery()\n .then((battery) => {\n if (destroyed) return;\n\n const update = (): void => {\n s.value = {\n supported: true,\n charging: battery.charging,\n chargingTime: battery.chargingTime,\n dischargingTime: battery.dischargingTime,\n level: battery.level,\n };\n };\n\n update();\n\n battery.addEventListener('chargingchange', update);\n battery.addEventListener('chargingtimechange', update);\n battery.addEventListener('dischargingtimechange', update);\n battery.addEventListener('levelchange', update);\n cleanup = () => {\n battery.removeEventListener('chargingchange', update);\n battery.removeEventListener('chargingtimechange', update);\n battery.removeEventListener('dischargingtimechange', update);\n battery.removeEventListener('levelchange', update);\n };\n })\n .catch(() => {\n // Battery API rejected — keep default state\n });\n }\n\n const ro = readonly(s) as BatterySignal;\n Object.defineProperty(ro, 'destroy', {\n enumerable: false,\n configurable: true,\n value(): void {\n if (destroyed) return;\n destroyed = true;\n cleanup?.();\n s.dispose();\n },\n });\n\n return ro;\n};\n","/**\n * Reactive geolocation.\n *\n * Provides a reactive signal tracking the device's geographic position\n * via the Geolocation API.\n *\n * @module bquery/media\n */\n\nimport { signal, readonly } from '../reactive/index';\nimport type { GeolocationOptions, GeolocationSignal, GeolocationState } from './types';\n\n/** Default geolocation state. */\nconst DEFAULT_GEO_STATE: GeolocationState = {\n supported: false,\n loading: false,\n latitude: null,\n longitude: null,\n accuracy: null,\n altitude: null,\n altitudeAccuracy: null,\n heading: null,\n speed: null,\n timestamp: null,\n error: null,\n};\n\n/**\n * Returns a reactive signal tracking the device's geographic position.\n *\n * Uses the Geolocation API (`navigator.geolocation`) where available.\n * Can operate in one-shot mode (default) or continuous watch mode.\n *\n * @param options - Configuration for the geolocation request\n * @returns A readonly reactive signal with position data and loading/error state,\n * plus a `destroy()` method to stop an active watcher\n *\n * @example\n * ```ts\n * import { useGeolocation } from '@bquery/bquery/media';\n * import { effect } from '@bquery/bquery/reactive';\n *\n * // One-shot position\n * const geo = useGeolocation();\n * effect(() => {\n * if (geo.value.loading) return console.log('Getting position...');\n * if (geo.value.error) return console.error(geo.value.error);\n * console.log(`Lat: ${geo.value.latitude}, Lng: ${geo.value.longitude}`);\n * });\n *\n * // Continuous watch with high accuracy\n * const geoWatch = useGeolocation({ watch: true, enableHighAccuracy: true });\n * ```\n */\nexport const useGeolocation = (options: GeolocationOptions = {}): GeolocationSignal => {\n const { enableHighAccuracy = false, maximumAge = 0, timeout = Infinity, watch = false } = options;\n\n const s = signal<GeolocationState>({ ...DEFAULT_GEO_STATE });\n\n let destroyWatcher: (() => void) | undefined;\n\n if (typeof navigator !== 'undefined' && 'geolocation' in navigator) {\n s.value = { ...DEFAULT_GEO_STATE, supported: true, loading: true };\n\n const posOptions: PositionOptions = {\n enableHighAccuracy,\n maximumAge,\n timeout: timeout === Infinity ? undefined : timeout,\n };\n\n const onSuccess = (pos: GeolocationPosition): void => {\n s.value = {\n supported: true,\n loading: false,\n latitude: pos.coords.latitude,\n longitude: pos.coords.longitude,\n accuracy: pos.coords.accuracy,\n altitude: pos.coords.altitude,\n altitudeAccuracy: pos.coords.altitudeAccuracy,\n heading: pos.coords.heading,\n speed: pos.coords.speed,\n timestamp: pos.timestamp,\n error: null,\n };\n };\n\n const onError = (err: GeolocationPositionError): void => {\n s.value = {\n ...s.value,\n loading: false,\n error: err.message,\n };\n };\n\n if (watch) {\n const watchId = navigator.geolocation.watchPosition(onSuccess, onError, posOptions);\n destroyWatcher = () => {\n navigator.geolocation.clearWatch(watchId);\n };\n } else {\n navigator.geolocation.getCurrentPosition(onSuccess, onError, posOptions);\n }\n }\n\n const ro = readonly(s) as GeolocationSignal;\n let destroyed = false;\n Object.defineProperty(ro, 'destroy', {\n enumerable: false,\n configurable: true,\n value(): void {\n if (destroyed) return;\n destroyed = true;\n destroyWatcher?.();\n s.dispose();\n },\n });\n\n return ro;\n};\n","/**\n * Reactive device motion and orientation sensors.\n *\n * Provides reactive signals for accelerometer, gyroscope, and\n * compass data via the DeviceMotion and DeviceOrientation APIs.\n *\n * @module bquery/media\n */\n\nimport { signal, readonly } from '../reactive/index';\nimport type {\n DeviceMotionSignal,\n DeviceMotionState,\n DeviceOrientationSignal,\n DeviceOrientationState,\n} from './types';\n\n/** Default device motion state. */\nconst DEFAULT_MOTION_STATE: DeviceMotionState = {\n acceleration: { x: null, y: null, z: null },\n accelerationIncludingGravity: { x: null, y: null, z: null },\n rotationRate: { alpha: null, beta: null, gamma: null },\n interval: 0,\n};\n\n/** Default device orientation state. */\nconst DEFAULT_ORIENTATION_STATE: DeviceOrientationState = {\n alpha: null,\n beta: null,\n gamma: null,\n absolute: false,\n};\n\n/**\n * Returns a reactive signal tracking device motion (accelerometer + gyroscope).\n *\n * Uses the `devicemotion` event to provide acceleration, acceleration\n * including gravity, and rotation rate data.\n *\n * @returns A readonly reactive signal with motion sensor data and a `destroy()`\n * method to remove the underlying event listener\n *\n * @example\n * ```ts\n * import { useDeviceMotion } from '@bquery/bquery/media';\n * import { effect } from '@bquery/bquery/reactive';\n *\n * const motion = useDeviceMotion();\n * effect(() => {\n * const { acceleration } = motion.value;\n * console.log(`Acceleration: x=${acceleration.x}, y=${acceleration.y}, z=${acceleration.z}`);\n * });\n * ```\n */\nexport const useDeviceMotion = (): DeviceMotionSignal => {\n const s = signal<DeviceMotionState>({ ...DEFAULT_MOTION_STATE });\n let cleanup: (() => void) | undefined;\n\n if (typeof window !== 'undefined') {\n const handler = (e: DeviceMotionEvent): void => {\n s.value = {\n acceleration: {\n x: e.acceleration?.x ?? null,\n y: e.acceleration?.y ?? null,\n z: e.acceleration?.z ?? null,\n },\n accelerationIncludingGravity: {\n x: e.accelerationIncludingGravity?.x ?? null,\n y: e.accelerationIncludingGravity?.y ?? null,\n z: e.accelerationIncludingGravity?.z ?? null,\n },\n rotationRate: {\n alpha: e.rotationRate?.alpha ?? null,\n beta: e.rotationRate?.beta ?? null,\n gamma: e.rotationRate?.gamma ?? null,\n },\n interval: e.interval ?? 0,\n };\n };\n\n window.addEventListener('devicemotion', handler);\n cleanup = () => {\n window.removeEventListener('devicemotion', handler);\n };\n }\n\n const ro = readonly(s) as DeviceMotionSignal;\n let destroyed = false;\n Object.defineProperty(ro, 'destroy', {\n enumerable: false,\n configurable: true,\n value(): void {\n if (destroyed) return;\n destroyed = true;\n cleanup?.();\n s.dispose();\n },\n });\n\n return ro;\n};\n\n/**\n * Returns a reactive signal tracking device orientation (compass/gyroscope).\n *\n * Uses the `deviceorientation` event to provide alpha (compass heading),\n * beta (front-to-back tilt), and gamma (left-to-right tilt) data.\n *\n * @returns A readonly reactive signal with orientation data and a `destroy()`\n * method to remove the underlying event listener\n *\n * @example\n * ```ts\n * import { useDeviceOrientation } from '@bquery/bquery/media';\n * import { effect } from '@bquery/bquery/reactive';\n *\n * const orientation = useDeviceOrientation();\n * effect(() => {\n * console.log(`Compass heading: ${orientation.value.alpha}°`);\n * console.log(`Tilt: ${orientation.value.beta}° / ${orientation.value.gamma}°`);\n * });\n * ```\n */\nexport const useDeviceOrientation = (): DeviceOrientationSignal => {\n const s = signal<DeviceOrientationState>({ ...DEFAULT_ORIENTATION_STATE });\n let cleanup: (() => void) | undefined;\n\n if (typeof window !== 'undefined') {\n const handler = (e: DeviceOrientationEvent): void => {\n s.value = {\n alpha: e.alpha ?? null,\n beta: e.beta ?? null,\n gamma: e.gamma ?? null,\n absolute: e.absolute ?? false,\n };\n };\n\n window.addEventListener('deviceorientation', handler);\n cleanup = () => {\n window.removeEventListener('deviceorientation', handler);\n };\n }\n\n const ro = readonly(s) as DeviceOrientationSignal;\n let destroyed = false;\n Object.defineProperty(ro, 'destroy', {\n enumerable: false,\n configurable: true,\n value(): void {\n if (destroyed) return;\n destroyed = true;\n cleanup?.();\n s.dispose();\n },\n });\n\n return ro;\n};\n","/**\n * Async clipboard API wrappers.\n *\n * Provides simple read/write access to the system clipboard\n * via the Async Clipboard API.\n *\n * @module bquery/media\n */\n\nimport type { ClipboardAPI } from './types';\n\nconst CLIPBOARD_UNAVAILABLE_ERROR =\n 'bQuery media: Clipboard API is unavailable. Use a secure context (HTTPS or localhost) and ensure clipboard permissions or user-activation requirements are met.';\n\n/**\n * Clipboard API wrapper providing simple async read/write access.\n *\n * Uses the modern Async Clipboard API (`navigator.clipboard`) under the hood.\n * Both methods are `Promise`-based and will reject if the API is unavailable\n * or permission is denied.\n *\n * @example\n * ```ts\n * import { clipboard } from '@bquery/bquery/media';\n *\n * // Write text to clipboard\n * await clipboard.write('Hello, world!');\n *\n * // Read text from clipboard\n * const text = await clipboard.read();\n * console.log(text); // \"Hello, world!\"\n * ```\n */\nexport const clipboard: ClipboardAPI = {\n /**\n * Reads text from the system clipboard.\n *\n * @returns A promise that resolves with the clipboard text content\n * @throws Error if the Clipboard API is not available or permission is denied\n *\n * @example\n * ```ts\n * const text = await clipboard.read();\n * console.log('Clipboard contains:', text);\n * ```\n */\n read: async (): Promise<string> => {\n if (\n typeof navigator === 'undefined' ||\n !navigator.clipboard ||\n typeof navigator.clipboard.readText !== 'function'\n ) {\n throw new Error(CLIPBOARD_UNAVAILABLE_ERROR);\n }\n return navigator.clipboard.readText();\n },\n\n /**\n * Writes text to the system clipboard.\n *\n * @param text - The text to write to the clipboard\n * @returns A promise that resolves when the text has been written\n * @throws Error if the Clipboard API is not available or permission is denied\n *\n * @example\n * ```ts\n * await clipboard.write('Copied!');\n * ```\n */\n write: async (text: string): Promise<void> => {\n if (\n typeof navigator === 'undefined' ||\n !navigator.clipboard ||\n typeof navigator.clipboard.writeText !== 'function'\n ) {\n throw new Error(CLIPBOARD_UNAVAILABLE_ERROR);\n }\n return navigator.clipboard.writeText(text);\n },\n};\n","/**\n * Reactive wrappers for browser Observer APIs.\n *\n * Provides composables for IntersectionObserver, ResizeObserver, and\n * MutationObserver that expose reactive signals updated on every callback.\n *\n * @module bquery/media\n */\n\nimport { readonly, signal } from '../reactive/index';\nimport type {\n IntersectionObserverOptions,\n IntersectionObserverSignal,\n IntersectionObserverState,\n MutationObserverOptions,\n MutationObserverSignal,\n MutationObserverState,\n ResizeObserverOptions,\n ResizeObserverSignal,\n ResizeObserverState,\n} from './types';\n\ntype ResizeObserverBoxSizeLike = {\n inlineSize: number;\n blockSize: number;\n};\n\nconst getResizeDimensions = (\n entry: ResizeObserverEntry,\n box: ResizeObserverBoxOptions\n): Pick<ResizeObserverState, 'width' | 'height'> => {\n let boxSize:\n | ResizeObserverBoxSizeLike\n | readonly ResizeObserverBoxSizeLike[]\n | undefined;\n\n if (box === 'border-box') {\n boxSize = entry.borderBoxSize;\n } else if (box === 'device-pixel-content-box') {\n boxSize = (\n entry as ResizeObserverEntry & {\n devicePixelContentBoxSize?:\n | ResizeObserverBoxSizeLike\n | readonly ResizeObserverBoxSizeLike[];\n }\n ).devicePixelContentBoxSize;\n } else {\n boxSize = entry.contentBoxSize;\n }\n\n const resolvedBoxSize = Array.isArray(boxSize) ? boxSize[0] : boxSize;\n if (\n resolvedBoxSize &&\n typeof resolvedBoxSize.inlineSize === 'number' &&\n typeof resolvedBoxSize.blockSize === 'number'\n ) {\n return {\n width: resolvedBoxSize.inlineSize,\n height: resolvedBoxSize.blockSize,\n };\n }\n\n return {\n width: entry.contentRect.width,\n height: entry.contentRect.height,\n };\n};\n\n// ─── useIntersectionObserver ────────────────────────────────────────────────\n\n/**\n * Returns a reactive signal tracking element intersection with a root viewport.\n *\n * The returned handle exposes `observe()` / `unobserve()` methods so you can\n * control which elements are watched. If an initial `target` is provided it is\n * observed immediately.\n *\n * @param target - Optional element or array of elements to observe immediately.\n * @param options - Standard `IntersectionObserver` init options.\n * @returns A readonly reactive signal with intersection state, plus `observe`,\n * `unobserve`, and `destroy` methods.\n *\n * @example\n * ```ts\n * import { useIntersectionObserver } from '@bquery/bquery/media';\n * import { effect } from '@bquery/bquery/reactive';\n *\n * const el = document.querySelector('#lazy-image')!;\n * const io = useIntersectionObserver(el, { threshold: 0.5 });\n *\n * effect(() => {\n * if (io.value.isIntersecting) {\n * console.log('Element is 50% visible');\n * }\n * });\n *\n * // Cleanup when done\n * io.destroy();\n * ```\n */\nexport const useIntersectionObserver = (\n target?: Element | Element[] | null,\n options?: IntersectionObserverOptions,\n): IntersectionObserverSignal => {\n const initial: IntersectionObserverState = {\n isIntersecting: false,\n intersectionRatio: 0,\n entry: null,\n };\n\n const s = signal<IntersectionObserverState>(initial);\n let observer: IntersectionObserver | undefined;\n let destroyed = false;\n\n if (typeof window !== 'undefined' && typeof IntersectionObserver !== 'undefined') {\n try {\n observer = new IntersectionObserver(\n (entries: IntersectionObserverEntry[]) => {\n if (destroyed) return;\n const last = entries[entries.length - 1];\n if (last) {\n s.value = {\n isIntersecting: last.isIntersecting,\n intersectionRatio: last.intersectionRatio,\n entry: last,\n };\n }\n },\n {\n root: options?.root ?? null,\n rootMargin: options?.rootMargin ?? '0px',\n threshold: options?.threshold ?? 0,\n },\n );\n\n // Observe initial targets\n if (target) {\n const targets = Array.isArray(target) ? target : [target];\n for (const el of targets) {\n observer.observe(el);\n }\n }\n } catch {\n if (observer) observer.disconnect();\n observer = undefined;\n }\n }\n\n const ro = readonly(s) as IntersectionObserverSignal;\n\n Object.defineProperties(ro, {\n observe: {\n enumerable: false,\n configurable: true,\n value(el: Element): void {\n if (!destroyed) {\n try {\n observer?.observe(el);\n } catch {}\n }\n },\n },\n unobserve: {\n enumerable: false,\n configurable: true,\n value(el: Element): void {\n if (!destroyed) observer?.unobserve(el);\n },\n },\n destroy: {\n enumerable: false,\n configurable: true,\n value(): void {\n if (destroyed) return;\n destroyed = true;\n observer?.disconnect();\n observer = undefined;\n s.dispose();\n },\n },\n });\n\n return ro;\n};\n\n// ─── useResizeObserver ──────────────────────────────────────────────────────\n\n/**\n * Returns a reactive signal tracking the size of observed elements.\n *\n * By default it uses the `content-box`, but you can configure the observed box\n * via the underlying `ResizeObserver` options (e.g. `{ box: 'border-box' }`).\n *\n * The returned handle exposes `observe()` / `unobserve()` methods. If an\n * initial `target` is provided it is observed immediately.\n *\n * @param target - Optional element or array of elements to observe immediately.\n * @param options - ResizeObserver options (e.g. `{ box: 'border-box' }`).\n * @returns A readonly reactive signal with `{ width, height, entry }` derived\n * from the configured box, plus `observe`, `unobserve`, and `destroy` methods.\n *\n * @example\n * ```ts\n * import { useResizeObserver } from '@bquery/bquery/media';\n * import { effect } from '@bquery/bquery/reactive';\n *\n * const el = document.querySelector('#panel')!;\n * const size = useResizeObserver(el);\n *\n * effect(() => {\n * console.log(`Panel size: ${size.value.width}x${size.value.height}`);\n * });\n *\n * size.destroy();\n * ```\n */\nexport const useResizeObserver = (\n target?: Element | Element[] | null,\n options?: ResizeObserverOptions,\n): ResizeObserverSignal => {\n const initial: ResizeObserverState = {\n width: 0,\n height: 0,\n entry: null,\n };\n\n const s = signal<ResizeObserverState>(initial);\n let observer: ResizeObserver | undefined;\n let destroyed = false;\n const box = options?.box ?? 'content-box';\n const observeOptions = options?.box ? { box: options.box } : undefined;\n\n if (typeof window !== 'undefined' && typeof ResizeObserver !== 'undefined') {\n try {\n observer = new ResizeObserver((entries: ResizeObserverEntry[]) => {\n if (destroyed) return;\n const last = entries[entries.length - 1];\n if (last) {\n const { width, height } = getResizeDimensions(last, box);\n s.value = {\n width,\n height,\n entry: last,\n };\n }\n });\n\n // Observe initial targets\n if (target) {\n const targets = Array.isArray(target) ? target : [target];\n for (const el of targets) {\n observer.observe(el, observeOptions);\n }\n }\n } catch {\n if (observer) observer.disconnect();\n observer = undefined;\n }\n }\n\n const ro = readonly(s) as ResizeObserverSignal;\n\n Object.defineProperties(ro, {\n observe: {\n enumerable: false,\n configurable: true,\n value(el: Element): void {\n if (!destroyed) {\n try {\n observer?.observe(el, observeOptions);\n } catch {}\n }\n },\n },\n unobserve: {\n enumerable: false,\n configurable: true,\n value(el: Element): void {\n if (!destroyed) observer?.unobserve(el);\n },\n },\n destroy: {\n enumerable: false,\n configurable: true,\n value(): void {\n if (destroyed) return;\n destroyed = true;\n observer?.disconnect();\n observer = undefined;\n s.dispose();\n },\n },\n });\n\n return ro;\n};\n\n// ─── useMutationObserver ────────────────────────────────────────────────────\n\n/**\n * Returns a reactive signal tracking DOM mutations on observed nodes.\n *\n * The returned handle exposes `observe()` and `takeRecords()` for manual\n * lifecycle control. If an initial `target` is provided it is observed\n * immediately.\n *\n * @param target - Optional node to observe immediately.\n * @param options - MutationObserver init options. Defaults to `{ attributes: true }`.\n * @returns A readonly reactive signal with `{ mutations, count }`, plus\n * `observe`, `takeRecords`, and `destroy` methods.\n *\n * @example\n * ```ts\n * import { useMutationObserver } from '@bquery/bquery/media';\n * import { effect } from '@bquery/bquery/reactive';\n *\n * const el = document.querySelector('#dynamic-content')!;\n * const mo = useMutationObserver(el, { childList: true, subtree: true });\n *\n * effect(() => {\n * console.log(`${mo.value.count} mutation batches observed`);\n * });\n *\n * mo.destroy();\n * ```\n */\nexport const useMutationObserver = (\n target?: Node | null,\n options?: MutationObserverOptions,\n): MutationObserverSignal => {\n const initial: MutationObserverState = {\n mutations: [],\n count: 0,\n };\n\n const s = signal<MutationObserverState>(initial);\n let observer: MutationObserver | undefined;\n let destroyed = false;\n let totalCount = 0;\n\n const resolvedOptions: MutationObserverInit = {\n attributes: options?.attributes ?? true,\n childList: options?.childList ?? false,\n characterData: options?.characterData ?? false,\n subtree: options?.subtree ?? false,\n attributeOldValue: options?.attributeOldValue ?? false,\n characterDataOldValue: options?.characterDataOldValue ?? false,\n ...(options && options.attributeFilter !== undefined\n ? { attributeFilter: options.attributeFilter }\n : {}),\n };\n\n if (!resolvedOptions.attributes && !resolvedOptions.childList && !resolvedOptions.characterData) {\n resolvedOptions.attributes = true;\n }\n\n if (!resolvedOptions.attributes) {\n resolvedOptions.attributeOldValue = false;\n delete resolvedOptions.attributeFilter;\n }\n\n if (!resolvedOptions.characterData) {\n resolvedOptions.characterDataOldValue = false;\n }\n\n if (typeof window !== 'undefined' && typeof MutationObserver !== 'undefined') {\n try {\n observer = new MutationObserver((mutations: MutationRecord[]) => {\n if (destroyed) return;\n totalCount += 1;\n s.value = {\n mutations,\n count: totalCount,\n };\n });\n\n if (target) {\n observer.observe(target, resolvedOptions);\n }\n } catch {\n if (observer) observer.disconnect();\n observer = undefined;\n }\n }\n\n const ro = readonly(s) as MutationObserverSignal;\n\n Object.defineProperties(ro, {\n observe: {\n enumerable: false,\n configurable: true,\n value(node: Node): void {\n if (!destroyed) {\n try {\n observer?.observe(node, resolvedOptions);\n } catch {}\n }\n },\n },\n takeRecords: {\n enumerable: false,\n configurable: true,\n value(): MutationRecord[] {\n return observer?.takeRecords() ?? [];\n },\n },\n destroy: {\n enumerable: false,\n configurable: true,\n value(): void {\n if (destroyed) return;\n destroyed = true;\n observer?.disconnect();\n observer = undefined;\n s.dispose();\n },\n },\n });\n\n return ro;\n};\n"],"mappings":";;AAqCA,IAAa,IAAA,CAAc,MAA8C;AACvE,QAAM,IAAI,EAAO,EAAA;AACjB,MAAI;AAEJ,MAAI,OAAO,SAAW,OAAe,OAAO,OAAO,cAAe,WAChE,KAAI;AACF,UAAM,IAAM,OAAO,WAAW,CAAA;AAC9B,IAAA,EAAE,QAAQ,EAAI;AAEd,UAAM,IAAA,CAAW,MAAiC;AAChD,MAAA,EAAE,QAAQ,EAAE;AAAA;AAGd,QAAI,OAAO,EAAI,oBAAqB;AAClC,MAAA,EAAI,iBAAiB,UAAU,CAAA,GAC/B,IAAA,MAAgB;AACd,QAAA,EAAI,oBAAoB,UAAU,CAAA;AAAA;aAGpC,OACE,EAIA,eAAgB,YAClB;AACA,YAAM,IAAY;AAIlB,MAAA,EAAU,YAAY,CAAA,GACtB,IAAA,MAAgB;AACd,QAAA,EAAU,eAAe,CAAA;AAAA;;UAGvB;AAAA,EAAA;AAKV,QAAM,IAAK,EAAS,CAAA;AACpB,MAAI,IAAY;AAChB,gBAAO,eAAe,GAAI,WAAW;AAAA,IACnC,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,QAAc;AACZ,MAAI,MACJ,IAAY,IACZ,IAAA,GACA,EAAE,QAAA;AAAA;GAEL,GAEM;GC1CI,IAAA,CAAwC,MAAgC;AACnF,QAAM,IAAU,CAAA,GACV,IAAgC,CAAA;AAOtC,aAAW,KAAO,OAAO,KAAK,CAAA,GAAuB;AACnD,UAAM,IAAQ,EAAG,CAAA,GACX,IAAI,EAAO,EAAA;AACjB,QAAI;AAEJ,QAAI,OAAO,SAAW,OAAe,OAAO,OAAO,cAAe,WAChE,KAAI;AACF,YAAM,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BAAqB,IAC/D,KAAI;AACF,IAAA,IAAW,IAAI,iBAAA,CAAkB,MAAgC;AAC/D,MAAI,MACJ,KAAc,GACd,EAAE,QAAQ;AAAA,QACR,WAAA;AAAA,QACA,OAAO;AAAA;QAIP,KACF,EAAS,QAAQ,GAAQ,CAAA;AAAA,UAErB;AACN,IAAI,KAAU,EAAS,WAAA,GACvB,IAAW;AAAA;AAIf,QAAM,IAAK,EAAS,CAAA;AAEpB,gBAAO,iBAAiB,GAAI;AAAA,IAC1B,SAAS;AAAA,MACP,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,MAAM,GAAkB;AACtB,YAAI,CAAC,EACH,KAAI;AACF,UAAA,GAAU,QAAQ,GAAM,CAAA;AAAA,gBAClB;AAAA,QAAA;AAAA;;IAId,aAAa;AAAA,MACX,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,QAA0B;AACxB,eAAO,GAAU,YAAA,KAAiB,CAAA;AAAA;;IAGtC,SAAS;AAAA,MACP,YAAY;AAAA,MACZ,cAAc;AAAA,MACd,QAAc;AACZ,QAAI,MACJ,IAAY,IACZ,GAAU,WAAA,GACV,IAAW,QACX,EAAE,QAAA;AAAA;;GAGP,GAEM"}
|
package/dist/media.es.mjs
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { a as s, c as a, i as o, l as
|
|
1
|
+
import { a as s, c as a, d as r, f as t, i as o, l as i, n as u, o as n, r as c, s as b, t as p, u as v } from "./media-D4zLj9t-.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
r as breakpoints,
|
|
4
|
+
o as clipboard,
|
|
5
5
|
t as mediaQuery,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
a as useBattery,
|
|
7
|
+
s as useDeviceMotion,
|
|
8
|
+
n as useDeviceOrientation,
|
|
9
|
+
b as useGeolocation,
|
|
10
|
+
p as useIntersectionObserver,
|
|
11
|
+
u as useMutationObserver,
|
|
12
|
+
i as useNetworkStatus,
|
|
13
|
+
c as useResizeObserver,
|
|
14
|
+
v as useViewport
|
|
12
15
|
};
|
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import { n as U } from "./sanitize-B1V4JswB.js";
|
|
2
|
+
import { i as K } from "./object-BCk-1c8T.js";
|
|
3
|
+
import { n as D, r as b } from "./core-DdtZHzsS.js";
|
|
4
|
+
import { c as N, l as j } from "./reactive-BjpLkclt.js";
|
|
5
|
+
import { t as X } from "./env-CTdvLaH2.js";
|
|
6
|
+
import { t as G } from "./custom-directives-Dr4C5lVV.js";
|
|
7
|
+
var V = 500, _ = class {
|
|
8
|
+
constructor(t) {
|
|
9
|
+
this.cache = /* @__PURE__ */ new Map(), this.maxSize = t;
|
|
10
|
+
}
|
|
11
|
+
get(t) {
|
|
12
|
+
const e = this.cache.get(t);
|
|
13
|
+
return e !== void 0 && (this.cache.delete(t), this.cache.set(t, e)), e;
|
|
14
|
+
}
|
|
15
|
+
set(t, e) {
|
|
16
|
+
if (this.cache.has(t)) this.cache.delete(t);
|
|
17
|
+
else if (this.cache.size >= this.maxSize) {
|
|
18
|
+
const i = this.cache.keys().next().value;
|
|
19
|
+
i !== void 0 && this.cache.delete(i);
|
|
20
|
+
}
|
|
21
|
+
this.cache.set(t, e);
|
|
22
|
+
}
|
|
23
|
+
clear() {
|
|
24
|
+
this.cache.clear();
|
|
25
|
+
}
|
|
26
|
+
get size() {
|
|
27
|
+
return this.cache.size;
|
|
28
|
+
}
|
|
29
|
+
}, z = new _(V), I = new _(V), Ee = () => {
|
|
30
|
+
z.clear(), I.clear();
|
|
31
|
+
}, J = (t) => new Proxy(t, {
|
|
32
|
+
get(e, i) {
|
|
33
|
+
if (typeof i != "string") return Reflect.get(e, i);
|
|
34
|
+
const s = e[i];
|
|
35
|
+
return j(s) || N(s) ? s.value : s;
|
|
36
|
+
},
|
|
37
|
+
has(e, i) {
|
|
38
|
+
return typeof i != "string" ? Reflect.has(e, i) : i in e;
|
|
39
|
+
}
|
|
40
|
+
}), p = (t, e) => {
|
|
41
|
+
try {
|
|
42
|
+
const i = J(e);
|
|
43
|
+
let s = z.get(t);
|
|
44
|
+
return s || (s = new Function("$ctx", `with($ctx) { return (${t}); }`), z.set(t, s)), s(i);
|
|
45
|
+
} catch (i) {
|
|
46
|
+
console.error(`bQuery view: Error evaluating "${t}"`, i);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}, O = (t, e) => {
|
|
50
|
+
try {
|
|
51
|
+
let i = I.get(t);
|
|
52
|
+
return i || (i = new Function("$ctx", `with($ctx) { return (${t}); }`), I.set(t, i)), i(e);
|
|
53
|
+
} catch (i) {
|
|
54
|
+
console.error(`bQuery view: Error evaluating "${t}"`, i);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}, H = (t) => {
|
|
58
|
+
const e = {}, i = t.trim().replace(/^\{|\}$/g, "").trim();
|
|
59
|
+
if (!i) return e;
|
|
60
|
+
const s = [];
|
|
61
|
+
let r = "", c = 0, o = null;
|
|
62
|
+
for (let a = 0; a < i.length; a++) {
|
|
63
|
+
const n = i[a];
|
|
64
|
+
if (n === '"' || n === "'" || n === "`") {
|
|
65
|
+
let l = 0, u = a - 1;
|
|
66
|
+
for (; u >= 0 && i[u] === "\\"; )
|
|
67
|
+
l++, u--;
|
|
68
|
+
l % 2 === 0 && (o === null ? o = n : o === n && (o = null)), r += n;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (o !== null) {
|
|
72
|
+
r += n;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
n === "(" || n === "[" || n === "{" ? (c++, r += n) : n === ")" || n === "]" || n === "}" ? (c--, r += n) : n === "," && c === 0 ? (s.push(r.trim()), r = "") : r += n;
|
|
76
|
+
}
|
|
77
|
+
r.trim() && s.push(r.trim());
|
|
78
|
+
for (const a of s) {
|
|
79
|
+
let n = -1, l = 0, u = null;
|
|
80
|
+
for (let f = 0; f < a.length; f++) {
|
|
81
|
+
const h = a[f];
|
|
82
|
+
if (h === '"' || h === "'" || h === "`") {
|
|
83
|
+
let M = 0, $ = f - 1;
|
|
84
|
+
for (; $ >= 0 && a[$] === "\\"; )
|
|
85
|
+
M++, $--;
|
|
86
|
+
M % 2 === 0 && (u === null ? u = h : u === h && (u = null));
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (u === null) {
|
|
90
|
+
if (h === "(" || h === "[" || h === "{") l++;
|
|
91
|
+
else if (h === ")" || h === "]" || h === "}") l--;
|
|
92
|
+
else if (h === ":" && l === 0) {
|
|
93
|
+
n = f;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (n > -1) {
|
|
99
|
+
const f = a.slice(0, n).trim().replace(/^['"]|['"]$/g, "");
|
|
100
|
+
if (K(f)) continue;
|
|
101
|
+
e[f] = a.slice(n + 1).trim();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return e;
|
|
105
|
+
}, Y = (t) => t.replace(/([A-Z])/g, "-$1").toLowerCase(), x = (t) => {
|
|
106
|
+
const e = t.trim(), i = e.toLowerCase();
|
|
107
|
+
return i.startsWith("aria-") ? i : `aria-${Y(/^aria[A-Z]/.test(e) ? e.slice(4) : e).replace(/^-/, "")}`;
|
|
108
|
+
}, ee = (t) => t == null || t === "", te = (t, e, i, s) => {
|
|
109
|
+
let r = /* @__PURE__ */ new Set();
|
|
110
|
+
const c = b(() => {
|
|
111
|
+
const o = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ Object.create(null);
|
|
112
|
+
if (e.trimStart().startsWith("{")) {
|
|
113
|
+
const n = H(e);
|
|
114
|
+
for (const [l, u] of Object.entries(n)) a[l] = p(u, i);
|
|
115
|
+
} else {
|
|
116
|
+
const n = p(e, i);
|
|
117
|
+
if (n && typeof n == "object" && !Array.isArray(n)) for (const [l, u] of Object.entries(n))
|
|
118
|
+
K(l) || (a[l] = u);
|
|
119
|
+
}
|
|
120
|
+
for (const [n, l] of Object.entries(a)) {
|
|
121
|
+
const u = x(n);
|
|
122
|
+
if (ee(l)) {
|
|
123
|
+
t.removeAttribute(u);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
t.setAttribute(u, l === !0 ? "true" : String(l)), o.add(u);
|
|
127
|
+
}
|
|
128
|
+
for (const n of r) o.has(n) || t.removeAttribute(n);
|
|
129
|
+
r = o;
|
|
130
|
+
});
|
|
131
|
+
s.push(c);
|
|
132
|
+
}, re = (t) => (e, i, s, r) => {
|
|
133
|
+
const c = b(() => {
|
|
134
|
+
const o = p(i, s);
|
|
135
|
+
o == null || o === !1 ? e.removeAttribute(t) : o === !0 ? e.setAttribute(t, "") : e.setAttribute(t, String(o));
|
|
136
|
+
});
|
|
137
|
+
r.push(c);
|
|
138
|
+
}, ne = (t, e, i, s) => {
|
|
139
|
+
let r = /* @__PURE__ */ new Set();
|
|
140
|
+
const c = b(() => {
|
|
141
|
+
const o = /* @__PURE__ */ new Set();
|
|
142
|
+
if (e.trimStart().startsWith("{")) {
|
|
143
|
+
const a = H(e);
|
|
144
|
+
for (const [n, l] of Object.entries(a)) {
|
|
145
|
+
const u = p(l, i);
|
|
146
|
+
t.classList.toggle(n, !!u), o.add(n);
|
|
147
|
+
}
|
|
148
|
+
} else if (/^\s*\[/.test(e)) {
|
|
149
|
+
const a = p(e, i);
|
|
150
|
+
if (Array.isArray(a))
|
|
151
|
+
for (const n of a) n && (t.classList.add(n), o.add(n));
|
|
152
|
+
} else {
|
|
153
|
+
const a = p(e, i);
|
|
154
|
+
typeof a == "string" ? a.split(/\s+/).forEach((n) => {
|
|
155
|
+
n && (t.classList.add(n), o.add(n));
|
|
156
|
+
}) : Array.isArray(a) && a.forEach((n) => {
|
|
157
|
+
n && (t.classList.add(n), o.add(n));
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
for (const a of r) o.has(a) || t.classList.remove(a);
|
|
161
|
+
r = o;
|
|
162
|
+
});
|
|
163
|
+
s.push(c);
|
|
164
|
+
}, ie = (t) => {
|
|
165
|
+
if (j(t) || N(t)) return String(t.value ?? "");
|
|
166
|
+
if (t && typeof t == "object" && "error" in t) {
|
|
167
|
+
const e = t.error;
|
|
168
|
+
return j(e) || N(e) ? String(e.value ?? "") : String(e ?? "");
|
|
169
|
+
}
|
|
170
|
+
return String(t ?? "");
|
|
171
|
+
}, se = (t, e, i, s) => {
|
|
172
|
+
const r = t, c = !r.hasAttribute("aria-hidden");
|
|
173
|
+
r.hasAttribute("role") || r.setAttribute("role", "alert"), r.hasAttribute("aria-live") || r.setAttribute("aria-live", "assertive");
|
|
174
|
+
const o = b(() => {
|
|
175
|
+
const a = ie(p(e, i)).trim(), n = a.length > 0;
|
|
176
|
+
r.textContent = a, r.hidden = !n, c && (n ? r.removeAttribute("aria-hidden") : r.setAttribute("aria-hidden", "true"));
|
|
177
|
+
});
|
|
178
|
+
s.push(o);
|
|
179
|
+
}, ae = (t, e, i, s, r, c) => {
|
|
180
|
+
if (!i) return e;
|
|
181
|
+
const o = {
|
|
182
|
+
...c,
|
|
183
|
+
[s]: t
|
|
184
|
+
};
|
|
185
|
+
return r && (o[r] = e), p(i, o);
|
|
186
|
+
}, oe = (t) => {
|
|
187
|
+
const { prefix: e, processElement: i, processChildren: s } = t;
|
|
188
|
+
return (r, c, o, a) => {
|
|
189
|
+
const n = r.parentNode;
|
|
190
|
+
if (!n) return;
|
|
191
|
+
const l = c.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);
|
|
192
|
+
if (!l) {
|
|
193
|
+
console.error(`bQuery view: Invalid bq-for expression "${c}"`);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const [, u, f, h] = l, M = r.getAttribute(":key") || r.getAttribute(`${e}-key`), $ = r.cloneNode(!0);
|
|
197
|
+
$.removeAttribute(`${e}-for`), $.removeAttribute(":key"), $.removeAttribute(`${e}-key`);
|
|
198
|
+
const P = document.createComment(`bq-for: ${c}`);
|
|
199
|
+
n.replaceChild(P, r);
|
|
200
|
+
let E = /* @__PURE__ */ new Map(), q = [];
|
|
201
|
+
const F = (m, v, A) => {
|
|
202
|
+
const C = $.cloneNode(!0), k = [], L = D(m), S = f ? D(v) : null, d = {
|
|
203
|
+
...o,
|
|
204
|
+
[u]: L
|
|
205
|
+
};
|
|
206
|
+
return f && S && (d[f] = S), i(C, d, e, k), s(C, d, e, k), {
|
|
207
|
+
key: A,
|
|
208
|
+
element: C,
|
|
209
|
+
cleanups: k,
|
|
210
|
+
item: m,
|
|
211
|
+
index: v,
|
|
212
|
+
itemSignal: L,
|
|
213
|
+
indexSignal: S
|
|
214
|
+
};
|
|
215
|
+
}, Q = (m) => {
|
|
216
|
+
for (const v of m.cleanups) v();
|
|
217
|
+
m.element.remove();
|
|
218
|
+
}, Z = (m, v, A) => {
|
|
219
|
+
Object.is(m.item, v) || (m.item = v, m.itemSignal.value = v), m.index !== A && (m.index = A, m.indexSignal && (m.indexSignal.value = A));
|
|
220
|
+
}, B = b(() => {
|
|
221
|
+
const m = p(h, o);
|
|
222
|
+
if (!Array.isArray(m)) {
|
|
223
|
+
for (const d of E.values()) Q(d);
|
|
224
|
+
E.clear(), q = [];
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const v = [], A = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Set();
|
|
228
|
+
m.forEach((d, y) => {
|
|
229
|
+
let g = ae(d, y, M, u, f, o);
|
|
230
|
+
C.has(g) && (console.warn(`bq-for: Duplicate key "${String(g)}" detected at index ${y}. Falling back to index-based key for this item. Ensure :key expressions produce unique values for each item.`), g = {
|
|
231
|
+
__bqDuplicateKey: g,
|
|
232
|
+
__bqIndex: y
|
|
233
|
+
}), C.add(g), v.push(g), A.set(g, {
|
|
234
|
+
item: d,
|
|
235
|
+
index: y
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
const k = [];
|
|
239
|
+
for (const d of q) A.has(d) || k.push(d);
|
|
240
|
+
for (const d of k) {
|
|
241
|
+
const y = E.get(d);
|
|
242
|
+
y && (Q(y), E.delete(d));
|
|
243
|
+
}
|
|
244
|
+
const L = /* @__PURE__ */ new Map();
|
|
245
|
+
let S = P;
|
|
246
|
+
for (let d = 0; d < v.length; d++) {
|
|
247
|
+
const y = v[d], { item: g, index: R } = A.get(y);
|
|
248
|
+
let w = E.get(y);
|
|
249
|
+
w ? (Z(w, g, R), L.set(y, w), S.nextSibling !== w.element && S.after(w.element), S = w.element) : (w = F(g, R, y), L.set(y, w), S.after(w.element), S = w.element);
|
|
250
|
+
}
|
|
251
|
+
E = L, q = v;
|
|
252
|
+
});
|
|
253
|
+
a.push(() => {
|
|
254
|
+
B();
|
|
255
|
+
for (const m of E.values()) for (const v of m.cleanups) v();
|
|
256
|
+
E.clear();
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
}, le = (t) => (e, i, s, r) => {
|
|
260
|
+
const c = b(() => {
|
|
261
|
+
const o = p(i, s), a = String(o ?? "");
|
|
262
|
+
e.innerHTML = t ? U(a) : a;
|
|
263
|
+
});
|
|
264
|
+
r.push(c);
|
|
265
|
+
}, ce = (t, e, i, s) => {
|
|
266
|
+
const r = document.createComment(`bq-if: ${e}`);
|
|
267
|
+
let c = !0;
|
|
268
|
+
const o = b(() => {
|
|
269
|
+
const a = p(e, i);
|
|
270
|
+
a && !c ? (r.replaceWith(t), c = !0) : !a && c && (t.replaceWith(r), c = !1);
|
|
271
|
+
});
|
|
272
|
+
s.push(o);
|
|
273
|
+
}, ue = (t, e, i, s) => {
|
|
274
|
+
const r = t, c = O(e, i);
|
|
275
|
+
if (!j(c)) {
|
|
276
|
+
console.warn(`bQuery view: bq-model requires a signal, got "${e}"`);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const o = c, a = r.type === "checkbox", n = r.type === "radio", l = () => {
|
|
280
|
+
a ? r.checked = !!o.value : n ? r.checked = o.value === r.value : r.value = String(o.value ?? "");
|
|
281
|
+
}, u = b(() => {
|
|
282
|
+
l();
|
|
283
|
+
});
|
|
284
|
+
s.push(u);
|
|
285
|
+
const f = r.tagName === "SELECT" ? "change" : "input", h = () => {
|
|
286
|
+
a ? o.value = r.checked : n ? r.checked && (o.value = r.value) : o.value = r.value;
|
|
287
|
+
};
|
|
288
|
+
r.addEventListener(f, h), s.push(() => r.removeEventListener(f, h));
|
|
289
|
+
}, fe = (t) => (e, i, s, r) => {
|
|
290
|
+
const c = (o) => {
|
|
291
|
+
const a = {
|
|
292
|
+
...s,
|
|
293
|
+
$event: o,
|
|
294
|
+
$el: e
|
|
295
|
+
};
|
|
296
|
+
if (!i.includes("(")) {
|
|
297
|
+
const n = O(i, a);
|
|
298
|
+
if (typeof n == "function") {
|
|
299
|
+
n(o);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
O(i, a);
|
|
305
|
+
};
|
|
306
|
+
e.addEventListener(t, c), r.push(() => e.removeEventListener(t, c));
|
|
307
|
+
};
|
|
308
|
+
function he(t) {
|
|
309
|
+
const e = Object.getOwnPropertyDescriptor(t, "value");
|
|
310
|
+
return e ? "value" in e ? e.writable === !0 : typeof e.set == "function" : !1;
|
|
311
|
+
}
|
|
312
|
+
var me = (t, e, i, s) => {
|
|
313
|
+
const r = O(e, i);
|
|
314
|
+
j(r) ? (r.value = t, s.push(() => {
|
|
315
|
+
r.value = null;
|
|
316
|
+
})) : typeof r == "object" && r !== null && he(r) && (r.value = t, s.push(() => {
|
|
317
|
+
r.value = null;
|
|
318
|
+
}));
|
|
319
|
+
}, de = (t, e, i, s) => {
|
|
320
|
+
const r = t;
|
|
321
|
+
let c = r.style.display;
|
|
322
|
+
if (!c || c === "none") {
|
|
323
|
+
const a = r.ownerDocument.defaultView?.getComputedStyle(r).display ?? "";
|
|
324
|
+
c = a !== "none" ? a : "";
|
|
325
|
+
}
|
|
326
|
+
const o = b(() => {
|
|
327
|
+
const a = p(e, i);
|
|
328
|
+
r.style.display = a ? c : "none";
|
|
329
|
+
});
|
|
330
|
+
s.push(o);
|
|
331
|
+
}, ve = (t, e, i, s) => {
|
|
332
|
+
const r = t;
|
|
333
|
+
let c = /* @__PURE__ */ new Set();
|
|
334
|
+
const o = b(() => {
|
|
335
|
+
const a = /* @__PURE__ */ new Set();
|
|
336
|
+
if (e.trimStart().startsWith("{")) {
|
|
337
|
+
const n = H(e);
|
|
338
|
+
for (const [l, u] of Object.entries(n)) {
|
|
339
|
+
const f = p(u, i), h = l.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
340
|
+
r.style.setProperty(h, String(f ?? "")), a.add(h);
|
|
341
|
+
}
|
|
342
|
+
} else {
|
|
343
|
+
const n = p(e, i);
|
|
344
|
+
if (n && typeof n == "object") for (const [l, u] of Object.entries(n)) {
|
|
345
|
+
const f = l.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
346
|
+
r.style.setProperty(f, String(u ?? "")), a.add(f);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
for (const n of c) a.has(n) || r.style.removeProperty(n);
|
|
350
|
+
c = a;
|
|
351
|
+
});
|
|
352
|
+
s.push(o);
|
|
353
|
+
}, pe = (t, e, i, s) => {
|
|
354
|
+
const r = b(() => {
|
|
355
|
+
const c = p(e, i);
|
|
356
|
+
t.textContent = String(c ?? "");
|
|
357
|
+
});
|
|
358
|
+
s.push(r);
|
|
359
|
+
}, W = (t, e, i, s, r) => {
|
|
360
|
+
const c = Array.from(t.attributes);
|
|
361
|
+
for (const o of c) {
|
|
362
|
+
const { name: a, value: n } = o;
|
|
363
|
+
if (!a.startsWith(`${i}-`)) continue;
|
|
364
|
+
const l = a.slice(i.length + 1);
|
|
365
|
+
if (l === "for") {
|
|
366
|
+
r.for(t, n, e, s);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (l === "text") r.text(t, n, e, s);
|
|
370
|
+
else if (l === "error") r.error(t, n, e, s);
|
|
371
|
+
else if (l === "aria") r.aria(t, n, e, s);
|
|
372
|
+
else if (l === "html") r.html(t, n, e, s);
|
|
373
|
+
else if (l === "if") r.if(t, n, e, s);
|
|
374
|
+
else if (l === "show") r.show(t, n, e, s);
|
|
375
|
+
else if (l === "class") r.class(t, n, e, s);
|
|
376
|
+
else if (l === "style") r.style(t, n, e, s);
|
|
377
|
+
else if (l === "model") r.model(t, n, e, s);
|
|
378
|
+
else if (l === "ref") r.ref(t, n, e, s);
|
|
379
|
+
else if (l.startsWith("bind:")) {
|
|
380
|
+
const u = l.slice(5);
|
|
381
|
+
r.bind(u)(t, n, e, s);
|
|
382
|
+
} else if (l.startsWith("on:")) {
|
|
383
|
+
const u = l.slice(3);
|
|
384
|
+
r.on(u)(t, n, e, s);
|
|
385
|
+
} else {
|
|
386
|
+
const u = G(l);
|
|
387
|
+
u ? u(t, n, e, s) : X() && typeof console < "u" && typeof console.warn == "function" && console.warn(`[bQuery][view] Unknown directive "${a}" (parsed as "${l}") on <${t.tagName.toLowerCase()}>. This may be a typo or a missing custom directive registration.`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}, T = (t, e, i, s, r) => {
|
|
391
|
+
const c = Array.from(t.children);
|
|
392
|
+
for (const o of c) o.hasAttribute(`${i}-for`) ? W(o, e, i, s, r) : (W(o, e, i, s, r), T(o, e, i, s, r));
|
|
393
|
+
}, ye = (t, e, i = {}) => {
|
|
394
|
+
const { prefix: s = "bq", sanitize: r = !0 } = i, c = typeof t == "string" ? document.querySelector(t) : t;
|
|
395
|
+
if (!c) throw new Error(`bQuery view: Element "${t}" not found.`);
|
|
396
|
+
if (c.hasAttribute(`${s}-for`)) throw new Error(`bQuery view: Cannot mount on element with ${s}-for directive. Wrap the ${s}-for element in a container instead.`);
|
|
397
|
+
const o = [], a = {
|
|
398
|
+
text: pe,
|
|
399
|
+
error: se,
|
|
400
|
+
aria: te,
|
|
401
|
+
html: le(r),
|
|
402
|
+
if: ce,
|
|
403
|
+
show: de,
|
|
404
|
+
class: ne,
|
|
405
|
+
style: ve,
|
|
406
|
+
model: ue,
|
|
407
|
+
ref: me,
|
|
408
|
+
for: oe({
|
|
409
|
+
prefix: s,
|
|
410
|
+
processElement: (l, u, f, h) => W(l, u, f, h, a),
|
|
411
|
+
processChildren: (l, u, f, h) => T(l, u, f, h, a)
|
|
412
|
+
}),
|
|
413
|
+
bind: re,
|
|
414
|
+
on: fe
|
|
415
|
+
};
|
|
416
|
+
return ((l, u, f) => {
|
|
417
|
+
const h = l.hasAttribute(`${s}-for`);
|
|
418
|
+
W(l, u, s, f, a), h || T(l, u, s, f, a);
|
|
419
|
+
})(c, e, o), {
|
|
420
|
+
el: c,
|
|
421
|
+
context: e,
|
|
422
|
+
update: (l) => {
|
|
423
|
+
Object.assign(e, l);
|
|
424
|
+
},
|
|
425
|
+
destroy: () => {
|
|
426
|
+
for (const l of o) l();
|
|
427
|
+
o.length = 0;
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
}, Ce = (t, e = {}) => (i) => {
|
|
431
|
+
const s = document.createElement("div");
|
|
432
|
+
s.innerHTML = t.trim();
|
|
433
|
+
const r = s.firstElementChild;
|
|
434
|
+
if (!r) throw new Error("bQuery view: Template must contain a single root element.");
|
|
435
|
+
if (s.childElementCount > 1) throw new Error(`bQuery view: Template must contain exactly one root element, found ${s.childElementCount}.`);
|
|
436
|
+
const { prefix: c = "bq" } = e;
|
|
437
|
+
if (r.hasAttribute(`${c}-for`) || r.hasAttribute(`${c}-if`)) {
|
|
438
|
+
const o = r.hasAttribute(`${c}-for`) ? "for" : "if";
|
|
439
|
+
throw new Error(`bQuery view: Template root element cannot have ${c}-${o} directive. Wrap the ${c}-${o} element in a container instead.`);
|
|
440
|
+
}
|
|
441
|
+
return ye(r, i, e);
|
|
442
|
+
};
|
|
443
|
+
export {
|
|
444
|
+
ye as n,
|
|
445
|
+
Ee as r,
|
|
446
|
+
Ce as t
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
//# sourceMappingURL=mount-B-JvH6Y0.js.map
|