@simpleapps-com/augur-hooks 0.4.0 → 0.4.2
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/dist/chunk-AXCNTEAB.cjs +44 -0
- package/dist/chunk-AXCNTEAB.cjs.map +1 -0
- package/dist/chunk-LTBEP4MC.js +44 -0
- package/dist/chunk-LTBEP4MC.js.map +1 -0
- package/dist/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/dist/use-image-with-fallback-DgmtrGZU.d.cts +17 -0
- package/dist/use-image-with-fallback-DgmtrGZU.d.ts +17 -0
- package/dist/web.cjs +7 -2
- package/dist/web.cjs.map +1 -1
- package/dist/web.d.cts +2 -0
- package/dist/web.d.ts +2 -0
- package/dist/web.js +5 -0
- package/dist/web.js.map +1 -1
- package/package.json +2 -2
package/dist/web.cjs
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkAXCNTEABcjs = require('./chunk-AXCNTEAB.cjs');
|
|
4
|
+
|
|
5
|
+
// src/web/use-mobile-detection.tsx
|
|
2
6
|
|
|
3
7
|
|
|
4
8
|
|
|
@@ -115,5 +119,6 @@ var useMobileOptimizedIntersection = ({
|
|
|
115
119
|
|
|
116
120
|
|
|
117
121
|
|
|
118
|
-
|
|
122
|
+
|
|
123
|
+
exports.MobileProvider = MobileProvider; exports.useImageWithFallback = _chunkAXCNTEABcjs.useImageWithFallback; exports.useIsHydrated = useIsHydrated; exports.useIsMobile = useIsMobile; exports.useMobileOptimizedIntersection = useMobileOptimizedIntersection;
|
|
119
124
|
//# sourceMappingURL=web.cjs.map
|
package/dist/web.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/web.cjs","../src/web/use-mobile-detection.tsx","../src/web/use-mobile-optimized-intersection.ts"],"names":[],"mappings":"AAAA;
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/web.cjs","../src/web/use-mobile-detection.tsx","../src/web/use-mobile-optimized-intersection.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA;AACE;AACA;AACA;AAAA,8BAEK;AA0FH,+CAAA;AAxFJ,IAAM,kBAAA,EAAoB,GAAA;AAC1B,IAAM,YAAA,EAAc,GAAA;AAGpB,IAAI,cAAA,EAAgB,KAAA;AACpB,IAAM,UAAA,kBAA6B,IAAI,GAAA,CAAI,CAAA;AAC3C,IAAI,gBAAA,EAAwD,IAAA;AAC5D,IAAI,cAAA,EAAqC,IAAA;AAEzC,SAAS,WAAA,CAAA,EAAuB;AAC9B,EAAA,OAAO,aAAA;AACT;AAGA,SAAS,iBAAA,CAAA,EAA6B;AACpC,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,SAAA,CAAU,QAAA,EAAkC;AACnD,EAAA,GAAA,CAAI,SAAA,CAAU,KAAA,IAAS,EAAA,GAAK,OAAO,OAAA,IAAW,WAAA,EAAa;AACzD,IAAA,cAAA,EAAgB,MAAA,CAAO,WAAA,GAAc,iBAAA;AAErC,IAAA,MAAM,aAAA,EAAe,CAAA,EAAA,GAAM;AACzB,MAAA,GAAA,CAAI,eAAA,EAAiB,MAAA;AAErB,MAAA,gBAAA,EAAkB,UAAA,CAAW,CAAA,EAAA,GAAM;AACjC,QAAA,gBAAA,EAAkB,IAAA;AAClB,QAAA,MAAM,SAAA,EAAW,MAAA,CAAO,WAAA,GAAc,iBAAA;AACtC,QAAA,GAAA,CAAI,SAAA,IAAa,aAAA,EAAe;AAC9B,UAAA,cAAA,EAAgB,QAAA;AAChB,UAAA,SAAA,CA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tB,CAAA;AAAA,EACF,CAAA,EAAG;AAAA,IACD,OAAA;AAAA,IACA,gBAAA;AAAA,IACA,iBAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO;AAAA,IACL,GAAA,EAAK,UAAA;AAAA,IACL;AAAA,EACF,CAAA;AACF,CAAA;AFqDA;AACE;AACA;AACA;AACA;AACA;AACF,kQAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/web.cjs","sourcesContent":[null,"import {\n createContext,\n useContext,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\";\n\nconst MOBILE_BREAKPOINT = 992;\nconst THROTTLE_MS = 150;\n\n// Singleton state for mobile detection\nlet isMobileState = false;\nconst listeners: Set<() => void> = new Set();\nlet throttleTimeout: ReturnType<typeof setTimeout> | null = null;\nlet cleanupResize: (() => void) | null = null;\n\nfunction getSnapshot(): boolean {\n return isMobileState;\n}\n\n/* v8 ignore next 3 */\nfunction getServerSnapshot(): boolean {\n return false;\n}\n\nfunction subscribe(callback: () => void): () => void {\n if (listeners.size === 0 && typeof window !== \"undefined\") {\n isMobileState = window.innerWidth <= MOBILE_BREAKPOINT;\n\n const handleResize = () => {\n if (throttleTimeout) return;\n\n throttleTimeout = setTimeout(() => {\n throttleTimeout = null;\n const newValue = window.innerWidth <= MOBILE_BREAKPOINT;\n if (newValue !== isMobileState) {\n isMobileState = newValue;\n listeners.forEach((listener) => listener());\n }\n }, THROTTLE_MS);\n };\n\n window.addEventListener(\"resize\", handleResize, { passive: true });\n\n cleanupResize = () => {\n window.removeEventListener(\"resize\", handleResize);\n if (throttleTimeout) {\n clearTimeout(throttleTimeout);\n throttleTimeout = null;\n }\n };\n }\n\n listeners.add(callback);\n\n return () => {\n listeners.delete(callback);\n if (listeners.size === 0 && cleanupResize) {\n cleanupResize();\n cleanupResize = null;\n }\n };\n}\n\n/**\n * Returns whether the screen is mobile-sized.\n * Uses `useSyncExternalStore` for proper SSR support.\n *\n * - SSR-safe: returns false on server, updates on client after hydration\n * - Single listener: one resize listener regardless of component count\n * - Throttled: resize events throttled to prevent excessive re-renders\n */\nexport function useIsMobile(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n\nconst HydrationContext = createContext(false);\n\ninterface MobileProviderProps {\n children: ReactNode;\n}\n\n/**\n * Optional provider that tracks hydration state.\n * Wrap your app with this if you need to conditionally render\n * mobile-only content after hydration.\n */\nexport function MobileProvider({ children }: MobileProviderProps) {\n const isHydrated = useSyncExternalStore(\n () => () => {},\n () => true,\n () => false,\n );\n\n return (\n <HydrationContext.Provider value={isHydrated}>\n {children}\n </HydrationContext.Provider>\n );\n}\n\n/**\n * Returns true only after the client has hydrated.\n * Prevents hydration mismatches with conditional rendering.\n */\nexport function useIsHydrated(): boolean {\n return useContext(HydrationContext);\n}\n","\"use client\";\n\nimport { useEffect, useState, useRef } from \"react\";\n\ninterface UseMobileOptimizedIntersectionOptions {\n rootMarginMobile?: string;\n rootMarginDesktop?: string;\n threshold?: number;\n enabled?: boolean;\n mobileBreakpoint?: number;\n}\n\n/**\n * IntersectionObserver hook with mobile-optimized root margins.\n * Uses larger margins on mobile for more aggressive prefetching/lazy loading.\n */\nexport const useMobileOptimizedIntersection = ({\n rootMarginMobile = \"300px\",\n rootMarginDesktop = \"150px\",\n threshold = 0,\n enabled = true,\n mobileBreakpoint = 992,\n}: UseMobileOptimizedIntersectionOptions = {}) => {\n const [isIntersecting, setIsIntersecting] = useState(false);\n const elementRef = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (!enabled || !elementRef.current) return;\n\n const isMobile = window.innerWidth <= mobileBreakpoint;\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting && !isIntersecting) {\n setIsIntersecting(true);\n }\n });\n },\n {\n rootMargin: isMobile ? rootMarginMobile : rootMarginDesktop,\n threshold,\n },\n );\n\n observer.observe(elementRef.current);\n\n return () => {\n observer.disconnect();\n };\n }, [\n enabled,\n rootMarginMobile,\n rootMarginDesktop,\n threshold,\n isIntersecting,\n mobileBreakpoint,\n ]);\n\n return {\n ref: elementRef,\n isIntersecting,\n };\n};\n"]}
|
package/dist/web.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
+
export { u as useImageWithFallback } from './use-image-with-fallback-DgmtrGZU.cjs';
|
|
5
|
+
import '@simpleapps-com/augur-utils';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Returns whether the screen is mobile-sized.
|
package/dist/web.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
+
export { u as useImageWithFallback } from './use-image-with-fallback-DgmtrGZU.js';
|
|
5
|
+
import '@simpleapps-com/augur-utils';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Returns whether the screen is mobile-sized.
|
package/dist/web.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useImageWithFallback
|
|
3
|
+
} from "./chunk-LTBEP4MC.js";
|
|
4
|
+
|
|
1
5
|
// src/web/use-mobile-detection.tsx
|
|
2
6
|
import {
|
|
3
7
|
createContext,
|
|
@@ -112,6 +116,7 @@ var useMobileOptimizedIntersection = ({
|
|
|
112
116
|
};
|
|
113
117
|
export {
|
|
114
118
|
MobileProvider,
|
|
119
|
+
useImageWithFallback,
|
|
115
120
|
useIsHydrated,
|
|
116
121
|
useIsMobile,
|
|
117
122
|
useMobileOptimizedIntersection
|
package/dist/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/web/use-mobile-detection.tsx","../src/web/use-mobile-optimized-intersection.ts"],"sourcesContent":["import {\n createContext,\n useContext,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\";\n\nconst MOBILE_BREAKPOINT = 992;\nconst THROTTLE_MS = 150;\n\n// Singleton state for mobile detection\nlet isMobileState = false;\nconst listeners: Set<() => void> = new Set();\nlet throttleTimeout: ReturnType<typeof setTimeout> | null = null;\nlet cleanupResize: (() => void) | null = null;\n\nfunction getSnapshot(): boolean {\n return isMobileState;\n}\n\n/* v8 ignore next 3 */\nfunction getServerSnapshot(): boolean {\n return false;\n}\n\nfunction subscribe(callback: () => void): () => void {\n if (listeners.size === 0 && typeof window !== \"undefined\") {\n isMobileState = window.innerWidth <= MOBILE_BREAKPOINT;\n\n const handleResize = () => {\n if (throttleTimeout) return;\n\n throttleTimeout = setTimeout(() => {\n throttleTimeout = null;\n const newValue = window.innerWidth <= MOBILE_BREAKPOINT;\n if (newValue !== isMobileState) {\n isMobileState = newValue;\n listeners.forEach((listener) => listener());\n }\n }, THROTTLE_MS);\n };\n\n window.addEventListener(\"resize\", handleResize, { passive: true });\n\n cleanupResize = () => {\n window.removeEventListener(\"resize\", handleResize);\n if (throttleTimeout) {\n clearTimeout(throttleTimeout);\n throttleTimeout = null;\n }\n };\n }\n\n listeners.add(callback);\n\n return () => {\n listeners.delete(callback);\n if (listeners.size === 0 && cleanupResize) {\n cleanupResize();\n cleanupResize = null;\n }\n };\n}\n\n/**\n * Returns whether the screen is mobile-sized.\n * Uses `useSyncExternalStore` for proper SSR support.\n *\n * - SSR-safe: returns false on server, updates on client after hydration\n * - Single listener: one resize listener regardless of component count\n * - Throttled: resize events throttled to prevent excessive re-renders\n */\nexport function useIsMobile(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n\nconst HydrationContext = createContext(false);\n\ninterface MobileProviderProps {\n children: ReactNode;\n}\n\n/**\n * Optional provider that tracks hydration state.\n * Wrap your app with this if you need to conditionally render\n * mobile-only content after hydration.\n */\nexport function MobileProvider({ children }: MobileProviderProps) {\n const isHydrated = useSyncExternalStore(\n () => () => {},\n () => true,\n () => false,\n );\n\n return (\n <HydrationContext.Provider value={isHydrated}>\n {children}\n </HydrationContext.Provider>\n );\n}\n\n/**\n * Returns true only after the client has hydrated.\n * Prevents hydration mismatches with conditional rendering.\n */\nexport function useIsHydrated(): boolean {\n return useContext(HydrationContext);\n}\n","\"use client\";\n\nimport { useEffect, useState, useRef } from \"react\";\n\ninterface UseMobileOptimizedIntersectionOptions {\n rootMarginMobile?: string;\n rootMarginDesktop?: string;\n threshold?: number;\n enabled?: boolean;\n mobileBreakpoint?: number;\n}\n\n/**\n * IntersectionObserver hook with mobile-optimized root margins.\n * Uses larger margins on mobile for more aggressive prefetching/lazy loading.\n */\nexport const useMobileOptimizedIntersection = ({\n rootMarginMobile = \"300px\",\n rootMarginDesktop = \"150px\",\n threshold = 0,\n enabled = true,\n mobileBreakpoint = 992,\n}: UseMobileOptimizedIntersectionOptions = {}) => {\n const [isIntersecting, setIsIntersecting] = useState(false);\n const elementRef = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (!enabled || !elementRef.current) return;\n\n const isMobile = window.innerWidth <= mobileBreakpoint;\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting && !isIntersecting) {\n setIsIntersecting(true);\n }\n });\n },\n {\n rootMargin: isMobile ? rootMarginMobile : rootMarginDesktop,\n threshold,\n },\n );\n\n observer.observe(elementRef.current);\n\n return () => {\n observer.disconnect();\n };\n }, [\n enabled,\n rootMarginMobile,\n rootMarginDesktop,\n threshold,\n isIntersecting,\n mobileBreakpoint,\n ]);\n\n return {\n ref: elementRef,\n isIntersecting,\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/web/use-mobile-detection.tsx","../src/web/use-mobile-optimized-intersection.ts"],"sourcesContent":["import {\n createContext,\n useContext,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\";\n\nconst MOBILE_BREAKPOINT = 992;\nconst THROTTLE_MS = 150;\n\n// Singleton state for mobile detection\nlet isMobileState = false;\nconst listeners: Set<() => void> = new Set();\nlet throttleTimeout: ReturnType<typeof setTimeout> | null = null;\nlet cleanupResize: (() => void) | null = null;\n\nfunction getSnapshot(): boolean {\n return isMobileState;\n}\n\n/* v8 ignore next 3 */\nfunction getServerSnapshot(): boolean {\n return false;\n}\n\nfunction subscribe(callback: () => void): () => void {\n if (listeners.size === 0 && typeof window !== \"undefined\") {\n isMobileState = window.innerWidth <= MOBILE_BREAKPOINT;\n\n const handleResize = () => {\n if (throttleTimeout) return;\n\n throttleTimeout = setTimeout(() => {\n throttleTimeout = null;\n const newValue = window.innerWidth <= MOBILE_BREAKPOINT;\n if (newValue !== isMobileState) {\n isMobileState = newValue;\n listeners.forEach((listener) => listener());\n }\n }, THROTTLE_MS);\n };\n\n window.addEventListener(\"resize\", handleResize, { passive: true });\n\n cleanupResize = () => {\n window.removeEventListener(\"resize\", handleResize);\n if (throttleTimeout) {\n clearTimeout(throttleTimeout);\n throttleTimeout = null;\n }\n };\n }\n\n listeners.add(callback);\n\n return () => {\n listeners.delete(callback);\n if (listeners.size === 0 && cleanupResize) {\n cleanupResize();\n cleanupResize = null;\n }\n };\n}\n\n/**\n * Returns whether the screen is mobile-sized.\n * Uses `useSyncExternalStore` for proper SSR support.\n *\n * - SSR-safe: returns false on server, updates on client after hydration\n * - Single listener: one resize listener regardless of component count\n * - Throttled: resize events throttled to prevent excessive re-renders\n */\nexport function useIsMobile(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n\nconst HydrationContext = createContext(false);\n\ninterface MobileProviderProps {\n children: ReactNode;\n}\n\n/**\n * Optional provider that tracks hydration state.\n * Wrap your app with this if you need to conditionally render\n * mobile-only content after hydration.\n */\nexport function MobileProvider({ children }: MobileProviderProps) {\n const isHydrated = useSyncExternalStore(\n () => () => {},\n () => true,\n () => false,\n );\n\n return (\n <HydrationContext.Provider value={isHydrated}>\n {children}\n </HydrationContext.Provider>\n );\n}\n\n/**\n * Returns true only after the client has hydrated.\n * Prevents hydration mismatches with conditional rendering.\n */\nexport function useIsHydrated(): boolean {\n return useContext(HydrationContext);\n}\n","\"use client\";\n\nimport { useEffect, useState, useRef } from \"react\";\n\ninterface UseMobileOptimizedIntersectionOptions {\n rootMarginMobile?: string;\n rootMarginDesktop?: string;\n threshold?: number;\n enabled?: boolean;\n mobileBreakpoint?: number;\n}\n\n/**\n * IntersectionObserver hook with mobile-optimized root margins.\n * Uses larger margins on mobile for more aggressive prefetching/lazy loading.\n */\nexport const useMobileOptimizedIntersection = ({\n rootMarginMobile = \"300px\",\n rootMarginDesktop = \"150px\",\n threshold = 0,\n enabled = true,\n mobileBreakpoint = 992,\n}: UseMobileOptimizedIntersectionOptions = {}) => {\n const [isIntersecting, setIsIntersecting] = useState(false);\n const elementRef = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (!enabled || !elementRef.current) return;\n\n const isMobile = window.innerWidth <= mobileBreakpoint;\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting && !isIntersecting) {\n setIsIntersecting(true);\n }\n });\n },\n {\n rootMargin: isMobile ? rootMarginMobile : rootMarginDesktop,\n threshold,\n },\n );\n\n observer.observe(elementRef.current);\n\n return () => {\n observer.disconnect();\n };\n }, [\n enabled,\n rootMarginMobile,\n rootMarginDesktop,\n threshold,\n isIntersecting,\n mobileBreakpoint,\n ]);\n\n return {\n ref: elementRef,\n isIntersecting,\n };\n};\n"],"mappings":";;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AA0FH;AAxFJ,IAAM,oBAAoB;AAC1B,IAAM,cAAc;AAGpB,IAAI,gBAAgB;AACpB,IAAM,YAA6B,oBAAI,IAAI;AAC3C,IAAI,kBAAwD;AAC5D,IAAI,gBAAqC;AAEzC,SAAS,cAAuB;AAC9B,SAAO;AACT;AAGA,SAAS,oB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V,mBAAmB;AACrB,IAA2C,CAAC,MAAM;AAChD,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,KAAK;AAC1D,QAAM,aAAa,OAA8B,IAAI;AAErD,YAAU,MAAM;AACd,QAAI,CAAC,WAAW,CAAC,WAAW,QAAS;AAErC,UAAM,WAAW,OAAO,cAAc;AAEtC,UAAM,WAAW,IAAI;AAAA,MACnB,CAAC,YAAY;AACX,gBAAQ,QAAQ,CAAC,UAAU;AACzB,cAAI,MAAM,kBAAkB,CAAC,gBAAgB;AAC3C,8BAAkB,IAAI;AAAA,UACxB;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MACA;AAAA,QACE,YAAY,WAAW,mBAAmB;AAAA,QAC1C;AAAA,MACF;AAAA,IACF;AAEA,aAAS,QAAQ,WAAW,OAAO;AAEnC,WAAO,MAAM;AACX,eAAS,WAAW;AAAA,IACtB;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,KAAK;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleapps-com/augur-hooks",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Cross-platform React Query hooks and Zustand stores for Augur ecommerce sites",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dist"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@simpleapps-com/augur-utils": "0.4.
|
|
34
|
+
"@simpleapps-com/augur-utils": "0.4.2"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@simpleapps-com/augur-api": "^0.9.11",
|