@simpleapps-com/augur-hooks 2.0.23 → 2.1.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/EXPORTS.md +10 -117
- package/dist/cart-pricing-D_mSECzx.d.cts +184 -0
- package/dist/cart-pricing-D_mSECzx.d.ts +184 -0
- package/dist/chunk-JPSDNJIZ.js +138 -0
- package/dist/chunk-JPSDNJIZ.js.map +1 -0
- package/dist/chunk-Q5YH4HDR.cjs +138 -0
- package/dist/chunk-Q5YH4HDR.cjs.map +1 -0
- package/dist/index.cjs +53 -818
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -622
- package/dist/index.d.ts +5 -622
- package/dist/index.js +28 -793
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +2 -82
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -81
- package/dist/server.js.map +1 -1
- package/dist/web.cjs +42 -6
- package/dist/web.cjs.map +1 -1
- package/dist/web.d.cts +16 -3
- package/dist/web.d.ts +16 -3
- package/dist/web.js +40 -4
- package/dist/web.js.map +1 -1
- package/llms.txt +12 -117
- package/package.json +3 -3
- package/dist/chunk-AXCNTEAB.cjs +0 -44
- package/dist/chunk-AXCNTEAB.cjs.map +0 -1
- package/dist/chunk-H7OXSAHP.cjs +0 -748
- package/dist/chunk-H7OXSAHP.cjs.map +0 -1
- package/dist/chunk-LTBEP4MC.js +0 -44
- package/dist/chunk-LTBEP4MC.js.map +0 -1
- package/dist/chunk-QFZHOGID.js +0 -748
- package/dist/chunk-QFZHOGID.js.map +0 -1
- package/dist/customer-quotes-BQYqzomR.d.cts +0 -562
- package/dist/customer-quotes-BQYqzomR.d.ts +0 -562
- package/dist/use-image-with-fallback-DgmtrGZU.d.cts +0 -17
- package/dist/use-image-with-fallback-DgmtrGZU.d.ts +0 -17
package/dist/server.cjs
CHANGED
|
@@ -4,47 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var _chunkH7OXSAHPcjs = require('./chunk-H7OXSAHP.cjs');
|
|
7
|
+
var _chunkQ5YH4HDRcjs = require('./chunk-Q5YH4HDR.cjs');
|
|
48
8
|
|
|
49
9
|
// src/server.ts
|
|
50
10
|
var _react = require('react');
|
|
@@ -72,45 +32,5 @@ function createAugurOptions(api, cacheConfig) {
|
|
|
72
32
|
|
|
73
33
|
|
|
74
34
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
exports.createAugurOptions = createAugurOptions; exports.executeBatchQuery = _chunkH7OXSAHPcjs.executeBatchQuery; exports.getBatchInvMastDocKey = _chunkH7OXSAHPcjs.getBatchInvMastDocKey; exports.getBatchInvMastDocOptions = _chunkH7OXSAHPcjs.getBatchInvMastDocOptions; exports.getCartPricingQueryOptions = _chunkH7OXSAHPcjs.getCartPricingQueryOptions; exports.getCategoryItemsInfiniteKey = _chunkH7OXSAHPcjs.getCategoryItemsInfiniteKey; exports.getCategoryItemsInfiniteOptions = _chunkH7OXSAHPcjs.getCategoryItemsInfiniteOptions; exports.getCustomerInvoiceDetailKey = _chunkH7OXSAHPcjs.getCustomerInvoiceDetailKey; exports.getCustomerInvoicesKey = _chunkH7OXSAHPcjs.getCustomerInvoicesKey; exports.getCustomerOrderDetailKey = _chunkH7OXSAHPcjs.getCustomerOrderDetailKey; exports.getCustomerOrdersKey = _chunkH7OXSAHPcjs.getCustomerOrdersKey; exports.getCustomerQuoteDetailKey = _chunkH7OXSAHPcjs.getCustomerQuoteDetailKey; exports.getCustomerQuotesKey = _chunkH7OXSAHPcjs.getCustomerQuotesKey; exports.getInvMastDocKey = _chunkH7OXSAHPcjs.getInvMastDocKey; exports.getInvMastDocOptions = _chunkH7OXSAHPcjs.getInvMastDocOptions; exports.getInvMastKey = _chunkH7OXSAHPcjs.getInvMastKey; exports.getInvMastOptions = _chunkH7OXSAHPcjs.getInvMastOptions; exports.getInvMastStockKey = _chunkH7OXSAHPcjs.getInvMastStockKey; exports.getInvMastStockOptions = _chunkH7OXSAHPcjs.getInvMastStockOptions; exports.getItemAttributesKey = _chunkH7OXSAHPcjs.getItemAttributesKey; exports.getItemAttributesOptions = _chunkH7OXSAHPcjs.getItemAttributesOptions; exports.getItemCategoryKey = _chunkH7OXSAHPcjs.getItemCategoryKey; exports.getItemCategoryOptions = _chunkH7OXSAHPcjs.getItemCategoryOptions; exports.getItemDetailsKey = _chunkH7OXSAHPcjs.getItemDetailsKey; exports.getItemDetailsOptions = _chunkH7OXSAHPcjs.getItemDetailsOptions; exports.getItemPriceKey = _chunkH7OXSAHPcjs.getItemPriceKey; exports.getItemPriceOptions = _chunkH7OXSAHPcjs.getItemPriceOptions; exports.getItemSearchInfiniteKey = _chunkH7OXSAHPcjs.getItemSearchInfiniteKey; exports.getItemSearchInfiniteOptions = _chunkH7OXSAHPcjs.getItemSearchInfiniteOptions; exports.getJoomlaContentKey = _chunkH7OXSAHPcjs.getJoomlaContentKey; exports.getJoomlaContentListKey = _chunkH7OXSAHPcjs.getJoomlaContentListKey; exports.getJoomlaContentListOptions = _chunkH7OXSAHPcjs.getJoomlaContentListOptions; exports.getJoomlaContentOptions = _chunkH7OXSAHPcjs.getJoomlaContentOptions; exports.getJoomlaMenuDocKey = _chunkH7OXSAHPcjs.getJoomlaMenuDocKey; exports.getJoomlaMenuDocOptions = _chunkH7OXSAHPcjs.getJoomlaMenuDocOptions; exports.getJoomlaMenuKey = _chunkH7OXSAHPcjs.getJoomlaMenuKey; exports.getJoomlaMenuOptions = _chunkH7OXSAHPcjs.getJoomlaMenuOptions; exports.getProductCategoryKey = _chunkH7OXSAHPcjs.getProductCategoryKey; exports.getProductCategoryOptions = _chunkH7OXSAHPcjs.getProductCategoryOptions; exports.getProductSearchKey = _chunkH7OXSAHPcjs.getProductSearchKey; exports.getProductSearchOptions = _chunkH7OXSAHPcjs.getProductSearchOptions; exports.getQueryClient = getQueryClient; exports.getSearchSuggestionsKey = _chunkH7OXSAHPcjs.getSearchSuggestionsKey; exports.getSearchSuggestionsOptions = _chunkH7OXSAHPcjs.getSearchSuggestionsOptions; exports.getStockKey = _chunkH7OXSAHPcjs.getStockKey; exports.getStockOptions = _chunkH7OXSAHPcjs.getStockOptions; exports.stableStringify = _chunkH7OXSAHPcjs.stableStringify;
|
|
35
|
+
exports.createAugurOptions = createAugurOptions; exports.executeBatchQuery = _chunkQ5YH4HDRcjs.executeBatchQuery; exports.getCartPricingQueryOptions = _chunkQ5YH4HDRcjs.getCartPricingQueryOptions; exports.getQueryClient = getQueryClient; exports.getStockKey = _chunkQ5YH4HDRcjs.getStockKey; exports.getStockOptions = _chunkQ5YH4HDRcjs.getStockOptions; exports.stableStringify = _chunkQ5YH4HDRcjs.stableStringify;
|
|
116
36
|
//# sourceMappingURL=server.cjs.map
|
package/dist/server.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/server.cjs","../src/server.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/server.cjs","../src/server.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,8BAAsB;AACtB,mDAA4B;AAC5B,uDAAmC;AAU5B,IAAM,eAAA,EAAiB,0BAAA;AAAA,EAC5B,CAAA,EAAA,GACE,IAAI,4BAAA,CAAY;AAAA,IACd,cAAA,EAAgB;AAAA,MACd,OAAA,EAAS;AAAA,QACP,SAAA,EAAW,GAAA,EAAK,GAAA;AAAA,QAChB,oBAAA,EAAsB;AAAA,MACxB;AAAA,IACF;AAAA,EACF,CAAC;AACL,CAAA;AAgBO,SAAS,kBAAA,CACd,GAAA,EACA,WAAA,EAC6C;AAC7C,EAAA,MAAM,YAAA,EAA8C,YAAA,EAChD,EAAE,KAAA,EAAO,EAAE,MAAA,EAAQ,WAAA,CAAY,MAAA,EAAQ,UAAA,EAAY,WAAA,CAAY,WAAW,EAAE,EAAA,EAC5E,KAAA,CAAA;AACJ,EAAA,OAAO,2CAAA,GAAmB,EAAK,WAAW,CAAA;AAC5C;ADvBA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,4ZAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/server.cjs","sourcesContent":[null,"// @simpleapps-com/augur-hooks/server\n// Query options, keys, and utilities for server-side prefetching in Next.js App Router.\n\nimport { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { createOptionsProxy } from \"@simpleapps-com/augur-core\";\nimport type { OptionsProxyConfig, CacheConfig } from \"@simpleapps-com/augur-core\";\n\n/**\n * Returns a per-request singleton QueryClient for React Server Components.\n *\n * React's `cache()` deduplicates calls within a single server request,\n * so layout, page, and header all share the same prefetch cache without\n * leaking state between requests.\n */\nexport const getQueryClient = cache(\n () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60 * 1000,\n refetchOnWindowFocus: false,\n },\n },\n }),\n);\n\n/**\n * Creates server-side query options proxy for prefetching.\n *\n * Uses the same augur-core proxy as `useAugurOptions()`, so query keys\n * are identical on server and client — SSR hydration is automatic.\n *\n * @example\n * ```ts\n * import { createAugurOptions } from \"@simpleapps-com/augur-hooks/server\";\n *\n * const q = createAugurOptions(api, cacheConfig);\n * await queryClient.prefetchQuery(q.items.invMast.doc.get(params.id));\n * ```\n */\nexport function createAugurOptions<TApi extends object>(\n api: TApi,\n cacheConfig?: CacheConfig,\n): ReturnType<typeof createOptionsProxy<TApi>> {\n const proxyConfig: OptionsProxyConfig | undefined = cacheConfig\n ? { cache: { static: cacheConfig.static, semiStatic: cacheConfig.semiStatic } }\n : undefined;\n return createOptionsProxy(api, proxyConfig);\n}\n\n// All pure query options and keys (legacy)\nexport * from \"./queries\";\n\n// Re-export shared types from augur-core\nexport type { AugurAuthContext, InfiniteScrollPage, CacheConfig } from \"@simpleapps-com/augur-core\";\n\n// Types needed for server-side usage (type-only, erased at compile time)\nexport type { AugurApiClient } from \"./provider\";\nexport type { PageData } from \"./types\";\n"]}
|
package/dist/server.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { CacheConfig, createOptionsProxy } from '@simpleapps-com/augur-core';
|
|
3
3
|
export { AugurAuthContext, CacheConfig, InfiniteScrollPage, stableStringify } from '@simpleapps-com/augur-core';
|
|
4
|
-
export {
|
|
4
|
+
export { A as AugurApiClient, B as BatchQueryConfig, b as PageData, e as executeBatchQuery, g as getCartPricingQueryOptions, c as getStockKey, d as getStockOptions } from './cart-pricing-D_mSECzx.cjs';
|
|
5
5
|
import '@simpleapps-com/augur-utils';
|
|
6
6
|
import 'react/jsx-runtime';
|
|
7
7
|
import 'react';
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { CacheConfig, createOptionsProxy } from '@simpleapps-com/augur-core';
|
|
3
3
|
export { AugurAuthContext, CacheConfig, InfiniteScrollPage, stableStringify } from '@simpleapps-com/augur-core';
|
|
4
|
-
export {
|
|
4
|
+
export { A as AugurApiClient, B as BatchQueryConfig, b as PageData, e as executeBatchQuery, g as getCartPricingQueryOptions, c as getStockKey, d as getStockOptions } from './cart-pricing-D_mSECzx.js';
|
|
5
5
|
import '@simpleapps-com/augur-utils';
|
|
6
6
|
import 'react/jsx-runtime';
|
|
7
7
|
import 'react';
|
package/dist/server.js
CHANGED
|
@@ -1,50 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeBatchQuery,
|
|
3
|
-
getBatchInvMastDocKey,
|
|
4
|
-
getBatchInvMastDocOptions,
|
|
5
3
|
getCartPricingQueryOptions,
|
|
6
|
-
getCategoryItemsInfiniteKey,
|
|
7
|
-
getCategoryItemsInfiniteOptions,
|
|
8
|
-
getCustomerInvoiceDetailKey,
|
|
9
|
-
getCustomerInvoicesKey,
|
|
10
|
-
getCustomerOrderDetailKey,
|
|
11
|
-
getCustomerOrdersKey,
|
|
12
|
-
getCustomerQuoteDetailKey,
|
|
13
|
-
getCustomerQuotesKey,
|
|
14
|
-
getInvMastDocKey,
|
|
15
|
-
getInvMastDocOptions,
|
|
16
|
-
getInvMastKey,
|
|
17
|
-
getInvMastOptions,
|
|
18
|
-
getInvMastStockKey,
|
|
19
|
-
getInvMastStockOptions,
|
|
20
|
-
getItemAttributesKey,
|
|
21
|
-
getItemAttributesOptions,
|
|
22
|
-
getItemCategoryKey,
|
|
23
|
-
getItemCategoryOptions,
|
|
24
|
-
getItemDetailsKey,
|
|
25
|
-
getItemDetailsOptions,
|
|
26
|
-
getItemPriceKey,
|
|
27
|
-
getItemPriceOptions,
|
|
28
|
-
getItemSearchInfiniteKey,
|
|
29
|
-
getItemSearchInfiniteOptions,
|
|
30
|
-
getJoomlaContentKey,
|
|
31
|
-
getJoomlaContentListKey,
|
|
32
|
-
getJoomlaContentListOptions,
|
|
33
|
-
getJoomlaContentOptions,
|
|
34
|
-
getJoomlaMenuDocKey,
|
|
35
|
-
getJoomlaMenuDocOptions,
|
|
36
|
-
getJoomlaMenuKey,
|
|
37
|
-
getJoomlaMenuOptions,
|
|
38
|
-
getProductCategoryKey,
|
|
39
|
-
getProductCategoryOptions,
|
|
40
|
-
getProductSearchKey,
|
|
41
|
-
getProductSearchOptions,
|
|
42
|
-
getSearchSuggestionsKey,
|
|
43
|
-
getSearchSuggestionsOptions,
|
|
44
4
|
getStockKey,
|
|
45
5
|
getStockOptions,
|
|
46
6
|
stableStringify
|
|
47
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-JPSDNJIZ.js";
|
|
48
8
|
|
|
49
9
|
// src/server.ts
|
|
50
10
|
import { cache } from "react";
|
|
@@ -67,48 +27,8 @@ function createAugurOptions(api, cacheConfig) {
|
|
|
67
27
|
export {
|
|
68
28
|
createAugurOptions,
|
|
69
29
|
executeBatchQuery,
|
|
70
|
-
getBatchInvMastDocKey,
|
|
71
|
-
getBatchInvMastDocOptions,
|
|
72
30
|
getCartPricingQueryOptions,
|
|
73
|
-
getCategoryItemsInfiniteKey,
|
|
74
|
-
getCategoryItemsInfiniteOptions,
|
|
75
|
-
getCustomerInvoiceDetailKey,
|
|
76
|
-
getCustomerInvoicesKey,
|
|
77
|
-
getCustomerOrderDetailKey,
|
|
78
|
-
getCustomerOrdersKey,
|
|
79
|
-
getCustomerQuoteDetailKey,
|
|
80
|
-
getCustomerQuotesKey,
|
|
81
|
-
getInvMastDocKey,
|
|
82
|
-
getInvMastDocOptions,
|
|
83
|
-
getInvMastKey,
|
|
84
|
-
getInvMastOptions,
|
|
85
|
-
getInvMastStockKey,
|
|
86
|
-
getInvMastStockOptions,
|
|
87
|
-
getItemAttributesKey,
|
|
88
|
-
getItemAttributesOptions,
|
|
89
|
-
getItemCategoryKey,
|
|
90
|
-
getItemCategoryOptions,
|
|
91
|
-
getItemDetailsKey,
|
|
92
|
-
getItemDetailsOptions,
|
|
93
|
-
getItemPriceKey,
|
|
94
|
-
getItemPriceOptions,
|
|
95
|
-
getItemSearchInfiniteKey,
|
|
96
|
-
getItemSearchInfiniteOptions,
|
|
97
|
-
getJoomlaContentKey,
|
|
98
|
-
getJoomlaContentListKey,
|
|
99
|
-
getJoomlaContentListOptions,
|
|
100
|
-
getJoomlaContentOptions,
|
|
101
|
-
getJoomlaMenuDocKey,
|
|
102
|
-
getJoomlaMenuDocOptions,
|
|
103
|
-
getJoomlaMenuKey,
|
|
104
|
-
getJoomlaMenuOptions,
|
|
105
|
-
getProductCategoryKey,
|
|
106
|
-
getProductCategoryOptions,
|
|
107
|
-
getProductSearchKey,
|
|
108
|
-
getProductSearchOptions,
|
|
109
31
|
getQueryClient,
|
|
110
|
-
getSearchSuggestionsKey,
|
|
111
|
-
getSearchSuggestionsOptions,
|
|
112
32
|
getStockKey,
|
|
113
33
|
getStockOptions,
|
|
114
34
|
stableStringify
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server.ts"],"sourcesContent":["// @simpleapps-com/augur-hooks/server\n// Query options, keys, and utilities for server-side prefetching in Next.js App Router.\n\nimport { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { createOptionsProxy } from \"@simpleapps-com/augur-core\";\nimport type { OptionsProxyConfig, CacheConfig } from \"@simpleapps-com/augur-core\";\n\n/**\n * Returns a per-request singleton QueryClient for React Server Components.\n *\n * React's `cache()` deduplicates calls within a single server request,\n * so layout, page, and header all share the same prefetch cache without\n * leaking state between requests.\n */\nexport const getQueryClient = cache(\n () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60 * 1000,\n refetchOnWindowFocus: false,\n },\n },\n }),\n);\n\n/**\n * Creates server-side query options proxy for prefetching.\n *\n * Uses the same augur-core proxy as `useAugurOptions()`, so query keys\n * are identical on server and client — SSR hydration is automatic.\n *\n * @example\n * ```ts\n * import { createAugurOptions } from \"@simpleapps-com/augur-hooks/server\";\n *\n * const q = createAugurOptions(api, cacheConfig);\n * await queryClient.prefetchQuery(q.items.invMast.doc.get(params.id));\n * ```\n */\nexport function createAugurOptions<TApi extends object>(\n api: TApi,\n cacheConfig?: CacheConfig,\n): ReturnType<typeof createOptionsProxy<TApi>> {\n const proxyConfig: OptionsProxyConfig | undefined = cacheConfig\n ? { cache: { static: cacheConfig.static, semiStatic: cacheConfig.semiStatic } }\n : undefined;\n return createOptionsProxy(api, proxyConfig);\n}\n\n// All pure query options and keys (legacy)\nexport * from \"./queries\";\n\n//
|
|
1
|
+
{"version":3,"sources":["../src/server.ts"],"sourcesContent":["// @simpleapps-com/augur-hooks/server\n// Query options, keys, and utilities for server-side prefetching in Next.js App Router.\n\nimport { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { createOptionsProxy } from \"@simpleapps-com/augur-core\";\nimport type { OptionsProxyConfig, CacheConfig } from \"@simpleapps-com/augur-core\";\n\n/**\n * Returns a per-request singleton QueryClient for React Server Components.\n *\n * React's `cache()` deduplicates calls within a single server request,\n * so layout, page, and header all share the same prefetch cache without\n * leaking state between requests.\n */\nexport const getQueryClient = cache(\n () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60 * 1000,\n refetchOnWindowFocus: false,\n },\n },\n }),\n);\n\n/**\n * Creates server-side query options proxy for prefetching.\n *\n * Uses the same augur-core proxy as `useAugurOptions()`, so query keys\n * are identical on server and client — SSR hydration is automatic.\n *\n * @example\n * ```ts\n * import { createAugurOptions } from \"@simpleapps-com/augur-hooks/server\";\n *\n * const q = createAugurOptions(api, cacheConfig);\n * await queryClient.prefetchQuery(q.items.invMast.doc.get(params.id));\n * ```\n */\nexport function createAugurOptions<TApi extends object>(\n api: TApi,\n cacheConfig?: CacheConfig,\n): ReturnType<typeof createOptionsProxy<TApi>> {\n const proxyConfig: OptionsProxyConfig | undefined = cacheConfig\n ? { cache: { static: cacheConfig.static, semiStatic: cacheConfig.semiStatic } }\n : undefined;\n return createOptionsProxy(api, proxyConfig);\n}\n\n// All pure query options and keys (legacy)\nexport * from \"./queries\";\n\n// Re-export shared types from augur-core\nexport type { AugurAuthContext, InfiniteScrollPage, CacheConfig } from \"@simpleapps-com/augur-core\";\n\n// Types needed for server-side usage (type-only, erased at compile time)\nexport type { AugurApiClient } from \"./provider\";\nexport type { PageData } from \"./types\";\n"],"mappings":";;;;;;;;;AAGA,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AAU5B,IAAM,iBAAiB;AAAA,EAC5B,MACE,IAAI,YAAY;AAAA,IACd,gBAAgB;AAAA,MACd,SAAS;AAAA,QACP,WAAW,KAAK;AAAA,QAChB,sBAAsB;AAAA,MACxB;AAAA,IACF;AAAA,EACF,CAAC;AACL;AAgBO,SAAS,mBACd,KACA,aAC6C;AAC7C,QAAM,cAA8C,cAChD,EAAE,OAAO,EAAE,QAAQ,YAAY,QAAQ,YAAY,YAAY,WAAW,EAAE,IAC5E;AACJ,SAAO,mBAAmB,KAAK,WAAW;AAC5C;","names":[]}
|
package/dist/web.cjs
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
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
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/web/use-mobile-detection.tsx
|
|
6
2
|
var _react = require('react');
|
|
7
3
|
var _jsxruntime = require('react/jsx-runtime');
|
|
8
4
|
var MOBILE_BREAKPOINT = 992;
|
|
@@ -104,10 +100,50 @@ var useMobileOptimizedIntersection = ({
|
|
|
104
100
|
};
|
|
105
101
|
};
|
|
106
102
|
|
|
103
|
+
// src/web/use-image-with-fallback.ts
|
|
104
|
+
|
|
105
|
+
var _augurutils = require('@simpleapps-com/augur-utils');
|
|
106
|
+
function useImageWithFallback(config, imagePath, options) {
|
|
107
|
+
const defaultSrc = _augurutils.getDefaultImageUrl.call(void 0, config, options);
|
|
108
|
+
const realSrc = imagePath ? _augurutils.getImageUrl.call(void 0, config, imagePath) : "";
|
|
109
|
+
const [src, setSrc] = _react.useState.call(void 0, defaultSrc);
|
|
110
|
+
const [isLoading, setIsLoading] = _react.useState.call(void 0, !!realSrc);
|
|
111
|
+
const [hasError, setHasError] = _react.useState.call(void 0, false);
|
|
112
|
+
const imageRef = _react.useRef.call(void 0, null);
|
|
113
|
+
_react.useEffect.call(void 0, () => {
|
|
114
|
+
if (!realSrc) {
|
|
115
|
+
setSrc(defaultSrc);
|
|
116
|
+
setIsLoading(false);
|
|
117
|
+
setHasError(false);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
setSrc(defaultSrc);
|
|
121
|
+
setIsLoading(true);
|
|
122
|
+
setHasError(false);
|
|
123
|
+
const img = new Image();
|
|
124
|
+
imageRef.current = img;
|
|
125
|
+
img.onload = () => {
|
|
126
|
+
setSrc(realSrc);
|
|
127
|
+
setIsLoading(false);
|
|
128
|
+
};
|
|
129
|
+
img.onerror = () => {
|
|
130
|
+
setIsLoading(false);
|
|
131
|
+
setHasError(true);
|
|
132
|
+
};
|
|
133
|
+
img.src = realSrc;
|
|
134
|
+
return () => {
|
|
135
|
+
img.onload = null;
|
|
136
|
+
img.onerror = null;
|
|
137
|
+
imageRef.current = null;
|
|
138
|
+
};
|
|
139
|
+
}, [realSrc, defaultSrc]);
|
|
140
|
+
return { src, isLoading, hasError };
|
|
141
|
+
}
|
|
142
|
+
|
|
107
143
|
|
|
108
144
|
|
|
109
145
|
|
|
110
146
|
|
|
111
147
|
|
|
112
|
-
exports.MobileProvider = MobileProvider; exports.useImageWithFallback =
|
|
148
|
+
exports.MobileProvider = MobileProvider; exports.useImageWithFallback = useImageWithFallback; exports.useIsHydrated = useIsHydrated; exports.useIsMobile = useIsMobile; exports.useMobileOptimizedIntersection = useMobileOptimizedIntersection;
|
|
113
149
|
//# 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;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA,8BAAgF;AAyFvE,+CAAA;AAvFT,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,CA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;AAAA,UACxB;AAAA,QACF,CAAC,CAAA;AAAA,MACH,CAAA;AAAA,MACA;AAAA,QACE,UAAA,EAAY,SAAA,EAAW,iBAAA,EAAmB,iBAAA;AAAA,QAC1C;AAAA,MACF;AAAA,IACF,CAAA;AAEA,IAAA,QAAA,CAAS,OAAA,CAAQ,UAAA,CAAW,OAAO,CAAA;AAEnC,IAAA,OAAO,CAAA,EAAA,GAAM;AACX,MAAA,QAAA,CAAS,UAAA,CAAW,CAAA;AAAA,IACtB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,OAAA,EAAS,gBAAA,EAAkB,iBAAA,EAAmB,SAAA,EAAW,cAAA,EAAgB,gBAAgB,CAAC,CAAA;AAE9F,EAAA,OAAO;AAAA,IACL,GAAA,EAAK,UAAA;AAAA,IACL;AAAA,EACF,CAAA;AACF,CAAA;AFiDA;AACE;AACA;AACA;AACA;AACA;AACF,kQAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/web.cjs","sourcesContent":[null,"import { createContext, useContext, useSyncExternalStore, type ReactNode } 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 <HydrationContext.Provider value={isHydrated}>{children}</HydrationContext.Provider>;\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 }, [enabled, rootMarginMobile, rootMarginDesktop, threshold, isIntersecting, mobileBreakpoint]);\n\n return {\n ref: elementRef,\n isIntersecting,\n };\n};\n"]}
|
|
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","../src/web/use-image-with-fallback.ts"],"names":["useState","useRef","useEffect"],"mappings":"AAAA;ACAA,8BAAgF;AAyFvE,+CAAA;AAvFT,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,E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AAA;AACjB,IAAA,YAAA,CAAa,IAAI,CAAA;AACjB,IAAA,WAAA,CAAY,KAAK,CAAA;AAEjB,IAAA,MAAM,IAAA,EAAM,IAAI,KAAA,CAAM,CAAA;AACtB,IAAA,QAAA,CAAS,QAAA,EAAU,GAAA;AAEnB,IAAA,GAAA,CAAI,OAAA,EAAS,CAAA,EAAA,GAAM;AACjB,MAAA,MAAA,CAAO,OAAO,CAAA;AACd,MAAA,YAAA,CAAa,KAAK,CAAA;AAAA,IACpB,CAAA;AAEA,IAAA,GAAA,CAAI,QAAA,EAAU,CAAA,EAAA,GAAM;AAClB,MAAA,YAAA,CAAa,KAAK,CAAA;AAClB,MAAA,WAAA,CAAY,IAAI,CAAA;AAAA,IAClB,CAAA;AAEA,IAAA,GAAA,CAAI,IAAA,EAAM,OAAA;AAEV,IAAA,OAAO,CAAA,EAAA,GAAM;AACX,MAAA,GAAA,CAAI,OAAA,EAAS,IAAA;AACb,MAAA,GAAA,CAAI,QAAA,EAAU,IAAA;AACd,MAAA,QAAA,CAAS,QAAA,EAAU,IAAA;AAAA,IACrB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,OAAA,EAAS,UAAU,CAAC,CAAA;AAExB,EAAA,OAAO,EAAE,GAAA,EAAK,SAAA,EAAW,SAAS,CAAA;AACpC;AH0EA;AACE;AACA;AACA;AACA;AACA;AACF,gPAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/web.cjs","sourcesContent":[null,"import { createContext, useContext, useSyncExternalStore, type ReactNode } 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 <HydrationContext.Provider value={isHydrated}>{children}</HydrationContext.Provider>;\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 }, [enabled, rootMarginMobile, rootMarginDesktop, threshold, isIntersecting, mobileBreakpoint]);\n\n return {\n ref: elementRef,\n isIntersecting,\n };\n};\n","\"use client\";\n\nimport { useEffect, useState, useRef } from \"react\";\nimport type { ImageConfig, ImageUrlOptions } from \"@simpleapps-com/augur-utils\";\nimport { getImageUrl, getDefaultImageUrl } from \"@simpleapps-com/augur-utils\";\n\ninterface UseImageWithFallbackResult {\n src: string;\n isLoading: boolean;\n hasError: boolean;\n}\n\n/**\n * Preloads an agr.media image and shows a fallback while loading.\n *\n * 1. Returns the default image immediately.\n * 2. Preloads the real image via `new Image()`.\n * 3. Swaps to the real URL on success; keeps the fallback on error.\n */\nexport function useImageWithFallback(\n config: ImageConfig,\n imagePath: string | undefined,\n options?: ImageUrlOptions,\n): UseImageWithFallbackResult {\n const defaultSrc = getDefaultImageUrl(config, options);\n const realSrc = imagePath ? getImageUrl(config, imagePath) : \"\";\n\n const [src, setSrc] = useState(defaultSrc);\n const [isLoading, setIsLoading] = useState(!!realSrc);\n const [hasError, setHasError] = useState(false);\n const imageRef = useRef<HTMLImageElement | null>(null);\n\n useEffect(() => {\n if (!realSrc) {\n setSrc(defaultSrc);\n setIsLoading(false);\n setHasError(false);\n return;\n }\n\n setSrc(defaultSrc);\n setIsLoading(true);\n setHasError(false);\n\n const img = new Image();\n imageRef.current = img;\n\n img.onload = () => {\n setSrc(realSrc);\n setIsLoading(false);\n };\n\n img.onerror = () => {\n setIsLoading(false);\n setHasError(true);\n };\n\n img.src = realSrc;\n\n return () => {\n img.onload = null;\n img.onerror = null;\n imageRef.current = null;\n };\n }, [realSrc, defaultSrc]);\n\n return { src, isLoading, hasError };\n}\n"]}
|
package/dist/web.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
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
|
-
|
|
5
|
-
import '@simpleapps-com/augur-utils';
|
|
4
|
+
import { ImageConfig, ImageUrlOptions } from '@simpleapps-com/augur-utils';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Returns whether the screen is mobile-sized.
|
|
@@ -44,4 +43,18 @@ declare const useMobileOptimizedIntersection: ({ rootMarginMobile, rootMarginDes
|
|
|
44
43
|
isIntersecting: boolean;
|
|
45
44
|
};
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
interface UseImageWithFallbackResult {
|
|
47
|
+
src: string;
|
|
48
|
+
isLoading: boolean;
|
|
49
|
+
hasError: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Preloads an agr.media image and shows a fallback while loading.
|
|
53
|
+
*
|
|
54
|
+
* 1. Returns the default image immediately.
|
|
55
|
+
* 2. Preloads the real image via `new Image()`.
|
|
56
|
+
* 3. Swaps to the real URL on success; keeps the fallback on error.
|
|
57
|
+
*/
|
|
58
|
+
declare function useImageWithFallback(config: ImageConfig, imagePath: string | undefined, options?: ImageUrlOptions): UseImageWithFallbackResult;
|
|
59
|
+
|
|
60
|
+
export { MobileProvider, useImageWithFallback, useIsHydrated, useIsMobile, useMobileOptimizedIntersection };
|
package/dist/web.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
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
|
-
|
|
5
|
-
import '@simpleapps-com/augur-utils';
|
|
4
|
+
import { ImageConfig, ImageUrlOptions } from '@simpleapps-com/augur-utils';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Returns whether the screen is mobile-sized.
|
|
@@ -44,4 +43,18 @@ declare const useMobileOptimizedIntersection: ({ rootMarginMobile, rootMarginDes
|
|
|
44
43
|
isIntersecting: boolean;
|
|
45
44
|
};
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
interface UseImageWithFallbackResult {
|
|
47
|
+
src: string;
|
|
48
|
+
isLoading: boolean;
|
|
49
|
+
hasError: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Preloads an agr.media image and shows a fallback while loading.
|
|
53
|
+
*
|
|
54
|
+
* 1. Returns the default image immediately.
|
|
55
|
+
* 2. Preloads the real image via `new Image()`.
|
|
56
|
+
* 3. Swaps to the real URL on success; keeps the fallback on error.
|
|
57
|
+
*/
|
|
58
|
+
declare function useImageWithFallback(config: ImageConfig, imagePath: string | undefined, options?: ImageUrlOptions): UseImageWithFallbackResult;
|
|
59
|
+
|
|
60
|
+
export { MobileProvider, useImageWithFallback, useIsHydrated, useIsMobile, useMobileOptimizedIntersection };
|
package/dist/web.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useImageWithFallback
|
|
3
|
-
} from "./chunk-LTBEP4MC.js";
|
|
4
|
-
|
|
5
1
|
// src/web/use-mobile-detection.tsx
|
|
6
2
|
import { createContext, useContext, useSyncExternalStore } from "react";
|
|
7
3
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -103,6 +99,46 @@ var useMobileOptimizedIntersection = ({
|
|
|
103
99
|
isIntersecting
|
|
104
100
|
};
|
|
105
101
|
};
|
|
102
|
+
|
|
103
|
+
// src/web/use-image-with-fallback.ts
|
|
104
|
+
import { useEffect as useEffect2, useState as useState2, useRef as useRef2 } from "react";
|
|
105
|
+
import { getImageUrl, getDefaultImageUrl } from "@simpleapps-com/augur-utils";
|
|
106
|
+
function useImageWithFallback(config, imagePath, options) {
|
|
107
|
+
const defaultSrc = getDefaultImageUrl(config, options);
|
|
108
|
+
const realSrc = imagePath ? getImageUrl(config, imagePath) : "";
|
|
109
|
+
const [src, setSrc] = useState2(defaultSrc);
|
|
110
|
+
const [isLoading, setIsLoading] = useState2(!!realSrc);
|
|
111
|
+
const [hasError, setHasError] = useState2(false);
|
|
112
|
+
const imageRef = useRef2(null);
|
|
113
|
+
useEffect2(() => {
|
|
114
|
+
if (!realSrc) {
|
|
115
|
+
setSrc(defaultSrc);
|
|
116
|
+
setIsLoading(false);
|
|
117
|
+
setHasError(false);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
setSrc(defaultSrc);
|
|
121
|
+
setIsLoading(true);
|
|
122
|
+
setHasError(false);
|
|
123
|
+
const img = new Image();
|
|
124
|
+
imageRef.current = img;
|
|
125
|
+
img.onload = () => {
|
|
126
|
+
setSrc(realSrc);
|
|
127
|
+
setIsLoading(false);
|
|
128
|
+
};
|
|
129
|
+
img.onerror = () => {
|
|
130
|
+
setIsLoading(false);
|
|
131
|
+
setHasError(true);
|
|
132
|
+
};
|
|
133
|
+
img.src = realSrc;
|
|
134
|
+
return () => {
|
|
135
|
+
img.onload = null;
|
|
136
|
+
img.onerror = null;
|
|
137
|
+
imageRef.current = null;
|
|
138
|
+
};
|
|
139
|
+
}, [realSrc, defaultSrc]);
|
|
140
|
+
return { src, isLoading, hasError };
|
|
141
|
+
}
|
|
106
142
|
export {
|
|
107
143
|
MobileProvider,
|
|
108
144
|
useImageWithFallback,
|
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 { createContext, useContext, useSyncExternalStore, type ReactNode } 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 <HydrationContext.Provider value={isHydrated}>{children}</HydrationContext.Provider>;\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 }, [enabled, rootMarginMobile, rootMarginDesktop, threshold, isIntersecting, mobileBreakpoint]);\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","../src/web/use-image-with-fallback.ts"],"sourcesContent":["import { createContext, useContext, useSyncExternalStore, type ReactNode } 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 <HydrationContext.Provider value={isHydrated}>{children}</HydrationContext.Provider>;\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 }, [enabled, rootMarginMobile, rootMarginDesktop, threshold, isIntersecting, mobileBreakpoint]);\n\n return {\n ref: elementRef,\n isIntersecting,\n };\n};\n","\"use client\";\n\nimport { useEffect, useState, useRef } from \"react\";\nimport type { ImageConfig, ImageUrlOptions } from \"@simpleapps-com/augur-utils\";\nimport { getImageUrl, getDefaultImageUrl } from \"@simpleapps-com/augur-utils\";\n\ninterface UseImageWithFallbackResult {\n src: string;\n isLoading: boolean;\n hasError: boolean;\n}\n\n/**\n * Preloads an agr.media image and shows a fallback while loading.\n *\n * 1. Returns the default image immediately.\n * 2. Preloads the real image via `new Image()`.\n * 3. Swaps to the real URL on success; keeps the fallback on error.\n */\nexport function useImageWithFallback(\n config: ImageConfig,\n imagePath: string | undefined,\n options?: ImageUrlOptions,\n): UseImageWithFallbackResult {\n const defaultSrc = getDefaultImageUrl(config, options);\n const realSrc = imagePath ? getImageUrl(config, imagePath) : \"\";\n\n const [src, setSrc] = useState(defaultSrc);\n const [isLoading, setIsLoading] = useState(!!realSrc);\n const [hasError, setHasError] = useState(false);\n const imageRef = useRef<HTMLImageElement | null>(null);\n\n useEffect(() => {\n if (!realSrc) {\n setSrc(defaultSrc);\n setIsLoading(false);\n setHasError(false);\n return;\n }\n\n setSrc(defaultSrc);\n setIsLoading(true);\n setHasError(false);\n\n const img = new Image();\n imageRef.current = img;\n\n img.onload = () => {\n setSrc(realSrc);\n setIsLoading(false);\n };\n\n img.onerror = () => {\n setIsLoading(false);\n setHasError(true);\n };\n\n img.src = realSrc;\n\n return () => {\n img.onload = null;\n img.onerror = null;\n imageRef.current = null;\n };\n }, [realSrc, defaultSrc]);\n\n return { src, isLoading, hasError };\n}\n"],"mappings":";AAAA,SAAS,eAAe,YAAY,4BAA4C;AAyFvE;AAvFT,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,oBAA6B;AACpC,SAAO;AACT;AAEA,SAAS,UAAU,UAAkC;AACnD,MAAI,UAAU,SAAS,KAAK,OAAO,WAAW,aAAa;AACzD,oBAAgB,OAAO,cAAc;AAErC,UAAM,eAAe,MAAM;AACzB,UAAI,gBAAiB;AAErB,wBAAkB,WAAW,MAAM;AACjC,0BAAkB;AAClB,cAAM,WAAW,OAAO,cAAc;AACtC,YAAI,aAAa,eAAe;AAC9B,0BAAgB;AAChB,oBAAU,QAAQ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