tempest-react-sdk 0.43.0 → 0.44.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 +6 -2
- package/dist/app/AppProviders.cjs +1 -1
- package/dist/app/AppProviders.js +6 -6
- package/dist/audio/sfx-pool.cjs +2 -0
- package/dist/audio/sfx-pool.cjs.map +1 -0
- package/dist/audio/sfx-pool.js +62 -0
- package/dist/audio/sfx-pool.js.map +1 -0
- package/dist/audio/use-sfx-pool.cjs +2 -0
- package/dist/audio/use-sfx-pool.cjs.map +1 -0
- package/dist/audio/use-sfx-pool.js +18 -0
- package/dist/audio/use-sfx-pool.js.map +1 -0
- package/dist/auth/lazy-with-retry.cjs +1 -1
- package/dist/auth/lazy-with-retry.cjs.map +1 -1
- package/dist/auth/lazy-with-retry.js +8 -1
- package/dist/auth/lazy-with-retry.js.map +1 -1
- package/dist/components/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.cjs.map +1 -1
- package/dist/components/AppBar/AppBar.js +27 -25
- package/dist/components/AppBar/AppBar.js.map +1 -1
- package/dist/components/AppBar/use-sticky-body-warning.cjs +2 -0
- package/dist/components/AppBar/use-sticky-body-warning.cjs.map +1 -0
- package/dist/components/AppBar/use-sticky-body-warning.js +16 -0
- package/dist/components/AppBar/use-sticky-body-warning.js.map +1 -0
- package/dist/components/BarList/BarList.cjs +2 -0
- package/dist/components/BarList/BarList.cjs.map +1 -0
- package/dist/components/BarList/BarList.js +42 -0
- package/dist/components/BarList/BarList.js.map +1 -0
- package/dist/components/BarList/BarList.module.cjs +2 -0
- package/dist/components/BarList/BarList.module.cjs.map +1 -0
- package/dist/components/BarList/BarList.module.js +15 -0
- package/dist/components/BarList/BarList.module.js.map +1 -0
- package/dist/components/BarList/bar-list-model.cjs +2 -0
- package/dist/components/BarList/bar-list-model.cjs.map +1 -0
- package/dist/components/BarList/bar-list-model.js +18 -0
- package/dist/components/BarList/bar-list-model.js.map +1 -0
- package/dist/components/DataTable/DataTable.cjs +1 -1
- package/dist/components/DataTable/DataTable.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.js +141 -108
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/DataTable.module.cjs +1 -1
- package/dist/components/DataTable/DataTable.module.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.module.js +13 -10
- package/dist/components/DataTable/DataTable.module.js.map +1 -1
- package/dist/components/DataTable/LoadingRows.cjs +2 -0
- package/dist/components/DataTable/LoadingRows.cjs.map +1 -0
- package/dist/components/DataTable/LoadingRows.js +18 -0
- package/dist/components/DataTable/LoadingRows.js.map +1 -0
- package/dist/components/DataTable/use-dev-warnings.cjs +2 -0
- package/dist/components/DataTable/use-dev-warnings.cjs.map +1 -0
- package/dist/components/DataTable/use-dev-warnings.js +17 -0
- package/dist/components/DataTable/use-dev-warnings.js.map +1 -0
- package/dist/components/FilterBar/filter-apply.cjs +2 -0
- package/dist/components/FilterBar/filter-apply.cjs.map +1 -0
- package/dist/components/FilterBar/filter-apply.js +76 -0
- package/dist/components/FilterBar/filter-apply.js.map +1 -0
- package/dist/components/FilterBar/filter-query.cjs +2 -0
- package/dist/components/FilterBar/filter-query.cjs.map +1 -0
- package/dist/components/FilterBar/filter-query.js +38 -0
- package/dist/components/FilterBar/filter-query.js.map +1 -0
- package/dist/hooks/use-countdown.cjs +2 -0
- package/dist/hooks/use-countdown.cjs.map +1 -0
- package/dist/hooks/use-countdown.js +18 -0
- package/dist/hooks/use-countdown.js.map +1 -0
- package/dist/hooks/use-latest-ref.cjs +2 -0
- package/dist/hooks/use-latest-ref.cjs.map +1 -0
- package/dist/hooks/use-latest-ref.js +10 -0
- package/dist/hooks/use-latest-ref.js.map +1 -0
- package/dist/hooks/use-typewriter.cjs +2 -0
- package/dist/hooks/use-typewriter.cjs.map +1 -0
- package/dist/hooks/use-typewriter.js +28 -0
- package/dist/hooks/use-typewriter.js.map +1 -0
- package/dist/http/describe-api-error.cjs +2 -0
- package/dist/http/describe-api-error.cjs.map +1 -0
- package/dist/http/describe-api-error.js +22 -0
- package/dist/http/describe-api-error.js.map +1 -0
- package/dist/http/use-describe-api-error.cjs +2 -0
- package/dist/http/use-describe-api-error.cjs.map +1 -0
- package/dist/http/use-describe-api-error.js +15 -0
- package/dist/http/use-describe-api-error.js.map +1 -0
- package/dist/i18n/I18nProvider.cjs +1 -1
- package/dist/i18n/I18nProvider.cjs.map +1 -1
- package/dist/i18n/I18nProvider.js +4 -1
- package/dist/i18n/I18nProvider.js.map +1 -1
- package/dist/query/QueryProvider.cjs +1 -1
- package/dist/query/QueryProvider.cjs.map +1 -1
- package/dist/query/QueryProvider.js +13 -12
- package/dist/query/QueryProvider.js.map +1 -1
- package/dist/query/retry-policy.cjs +2 -0
- package/dist/query/retry-policy.cjs.map +1 -0
- package/dist/query/retry-policy.js +10 -0
- package/dist/query/retry-policy.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +788 -9
- package/dist/tempest-react-sdk.js +275 -261
- package/dist/utils/compressed-storage.cjs +2 -0
- package/dist/utils/compressed-storage.cjs.map +1 -0
- package/dist/utils/compressed-storage.js +52 -0
- package/dist/utils/compressed-storage.js.map +1 -0
- package/dist/utils/csv.cjs +4 -0
- package/dist/utils/csv.cjs.map +1 -0
- package/dist/utils/csv.js +25 -0
- package/dist/utils/csv.js.map +1 -0
- package/dist/utils/format.cjs +1 -1
- package/dist/utils/format.cjs.map +1 -1
- package/dist/utils/format.js +11 -4
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/numbers.cjs +1 -1
- package/dist/utils/numbers.cjs.map +1 -1
- package/dist/utils/numbers.js +5 -2
- package/dist/utils/numbers.js.map +1 -1
- package/dist/vite/tempest-pwa-dev-sw.cjs +1 -1
- package/dist/vite/tempest-pwa-dev-sw.cjs.map +1 -1
- package/dist/vite/tempest-pwa-dev-sw.js +10 -5
- package/dist/vite/tempest-pwa-dev-sw.js.map +1 -1
- package/dist/vite/tempest-pwa-manifest.cjs +2 -2
- package/dist/vite/tempest-pwa-manifest.cjs.map +1 -1
- package/dist/vite/tempest-pwa-manifest.js +17 -13
- package/dist/vite/tempest-pwa-manifest.js.map +1 -1
- package/dist/vite.d.ts +19 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nProvider.js","names":[],"sources":["../../src/i18n/I18nProvider.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useEffect, useMemo, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { createI18n, type Catalog, type I18n } from \"./create-i18n\";\n\nexport interface I18nContextValue extends I18n {\n /** Switch the active locale. Persisted when `storageKey` is set. */\n setLocale: (locale: string) => void;\n /** Locales available in the catalog. */\n availableLocales: string[];\n}\n\nconst I18nContext = createContext<I18nContextValue | null>(null);\n\nexport interface I18nProviderProps {\n children: ReactNode;\n /** Initial locale. */\n locale: string;\n /** Fallback locale used when a key is missing. */\n fallbackLocale?: string;\n /** Translation catalog. */\n messages: Catalog;\n /** localStorage key for persisting the user choice. Pass `null` to disable. Default: `\"tempest-locale\"`. */\n storageKey?: string | null;\n}\n\nfunction readStored(storageKey: string | null, available: string[]): string | null {\n if (!storageKey || typeof window === \"undefined\") return null;\n try {\n const value = window.localStorage.getItem(storageKey);\n if (value && available.includes(value)) return value;\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * React provider for the SDK's lightweight i18n. Exposes the translation\n * helpers and a `setLocale` setter to children.\n *\n * @tempest-limits empty-catch — remembering the chosen locale is best-effort. The\n * switch itself is React state and already happened by the time the write runs, so\n * a storage failure costs the preference on the next load and nothing in this one.\n */\nexport function I18nProvider({\n children,\n locale: initialLocale,\n fallbackLocale,\n messages,\n storageKey = \"tempest-locale\",\n}: I18nProviderProps) {\n const availableLocales = useMemo(() => Object.keys(messages), [messages]);\n const [locale, setLocaleState] = useState<string>(\n () => readStored(storageKey, availableLocales) ?? initialLocale,\n );\n\n useEffect(() => {\n if (typeof document !== \"undefined\") {\n document.documentElement.setAttribute(\"lang\", locale);\n }\n }, [locale]);\n\n const setLocale = useCallback(\n (next: string) => {\n setLocaleState(next);\n if (storageKey && typeof window !== \"undefined\") {\n try {\n window.localStorage.setItem(storageKey, next);\n } catch {\n /* empty */\n }\n }\n },\n [storageKey],\n );\n\n const value = useMemo<I18nContextValue>(() => {\n const i18n = createI18n({ locale, fallbackLocale, messages });\n return { ...i18n, setLocale, availableLocales };\n }, [locale, fallbackLocale, messages, setLocale, availableLocales]);\n\n return <I18nContext.Provider value={value}>{children}</I18nContext.Provider>;\n}\n\n/**\n * Access translation helpers. Must be used inside an {@link I18nProvider}.\n */\nexport function useI18n(): I18nContextValue {\n const ctx = useContext(I18nContext);\n if (!ctx) throw new Error(\"useI18n must be used inside an <I18nProvider>\");\n return ctx;\n}\n\n/**\n * Shortcut for components that only need the `t` function — avoids destructuring.\n */\nexport function useTranslate(): I18nContextValue[\"t\"] {\n return useI18n().t;\n}\n"],"mappings":";;;;AAWA,IAAM,IAAc,EAAuC,IAAI;AAc/D,SAAS,EAAW,GAA2B,GAAoC;CAC/E,IAAI,CAAC,KAAc,OAAO,SAAW,KAAa,OAAO;CACzD,IAAI;EACA,IAAM,IAAQ,OAAO,aAAa,QAAQ,CAAU;EAEpD,OADI,KAAS,EAAU,SAAS,CAAK,IAAU,IACxC;CACX,QAAQ;EACJ,OAAO;CACX;AACJ;AAUA,SAAgB,EAAa,EACzB,aACA,QAAQ,GACR,mBACA,aACA,gBAAa,oBACK;CAClB,IAAM,IAAmB,QAAc,OAAO,KAAK,CAAQ,GAAG,CAAC,CAAQ,CAAC,GAClE,CAAC,GAAQ,KAAkB,QACvB,EAAW,GAAY,CAAgB,KAAK,CACtD;CAEA,QAAgB;EACZ,AAAI,OAAO,WAAa,OACpB,SAAS,gBAAgB,aAAa,QAAQ,CAAM;CAE5D,GAAG,CAAC,CAAM,CAAC;CAEX,IAAM,IAAY,GACb,MAAiB;EAEd,IADA,EAAe,CAAI,GACf,KAAc,OAAO,SAAW,KAChC,IAAI;GACA,OAAO,aAAa,QAAQ,GAAY,CAAI;EAChD,QAAQ,CAER;CAER,GACA,CAAC,CAAU,CACf,GAEM,IAAQ,SAEH;EAAE,GADI,EAAW;GAAE;GAAQ;GAAgB;EAAS,CAC/C;EAAM;EAAW;CAAiB,IAC/C;EAAC;EAAQ;EAAgB;EAAU;EAAW;CAAgB,CAAC;CAElE,OAAO,kBAAC,EAAY,UAAb;EAA6B;EAAQ;CAA+B,CAAA;AAC/E;AAKA,SAAgB,IAA4B;CACxC,IAAM,IAAM,EAAW,CAAW;CAClC,IAAI,CAAC,GAAK,MAAU,MAAM,+CAA+C;CACzE,OAAO;AACX;AAKA,SAAgB,IAAsC;CAClD,OAAO,EAAQ,CAAC,CAAC;AACrB"}
|
|
1
|
+
{"version":3,"file":"I18nProvider.js","names":[],"sources":["../../src/i18n/I18nProvider.tsx"],"sourcesContent":["import { createContext, useCallback, useContext, useEffect, useMemo, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { createI18n, type Catalog, type I18n } from \"./create-i18n\";\n\nexport interface I18nContextValue extends I18n {\n /** Switch the active locale. Persisted when `storageKey` is set. */\n setLocale: (locale: string) => void;\n /** Locales available in the catalog. */\n availableLocales: string[];\n}\n\nconst I18nContext = createContext<I18nContextValue | null>(null);\n\nexport interface I18nProviderProps {\n children: ReactNode;\n /** Initial locale. */\n locale: string;\n /** Fallback locale used when a key is missing. */\n fallbackLocale?: string;\n /** Translation catalog. */\n messages: Catalog;\n /** localStorage key for persisting the user choice. Pass `null` to disable. Default: `\"tempest-locale\"`. */\n storageKey?: string | null;\n}\n\nfunction readStored(storageKey: string | null, available: string[]): string | null {\n if (!storageKey || typeof window === \"undefined\") return null;\n try {\n const value = window.localStorage.getItem(storageKey);\n if (value && available.includes(value)) return value;\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * React provider for the SDK's lightweight i18n. Exposes the translation\n * helpers and a `setLocale` setter to children.\n *\n * @tempest-limits empty-catch — remembering the chosen locale is best-effort. The\n * switch itself is React state and already happened by the time the write runs, so\n * a storage failure costs the preference on the next load and nothing in this one.\n */\nexport function I18nProvider({\n children,\n locale: initialLocale,\n fallbackLocale,\n messages,\n storageKey = \"tempest-locale\",\n}: I18nProviderProps) {\n const availableLocales = useMemo(() => Object.keys(messages), [messages]);\n const [locale, setLocaleState] = useState<string>(\n () => readStored(storageKey, availableLocales) ?? initialLocale,\n );\n\n useEffect(() => {\n if (typeof document !== \"undefined\") {\n document.documentElement.setAttribute(\"lang\", locale);\n }\n }, [locale]);\n\n const setLocale = useCallback(\n (next: string) => {\n setLocaleState(next);\n if (storageKey && typeof window !== \"undefined\") {\n try {\n window.localStorage.setItem(storageKey, next);\n } catch {\n /* empty */\n }\n }\n },\n [storageKey],\n );\n\n const value = useMemo<I18nContextValue>(() => {\n const i18n = createI18n({ locale, fallbackLocale, messages });\n return { ...i18n, setLocale, availableLocales };\n }, [locale, fallbackLocale, messages, setLocale, availableLocales]);\n\n return <I18nContext.Provider value={value}>{children}</I18nContext.Provider>;\n}\n\n/**\n * Access translation helpers. Must be used inside an {@link I18nProvider}.\n */\nexport function useI18n(): I18nContextValue {\n const ctx = useContext(I18nContext);\n if (!ctx) throw new Error(\"useI18n must be used inside an <I18nProvider>\");\n return ctx;\n}\n\n/**\n * Access translation helpers when there may be no {@link I18nProvider} above.\n *\n * Returns `null` instead of throwing, which is what a piece of the SDK needs\n * when it wants to be translated where a catalog exists and still work where one\n * does not — i18n is opt-in in this SDK, and a helper that demanded a provider\n * would turn \"you did not configure translations\" into a crash.\n *\n * @returns The context value, or `null` outside a provider.\n */\nexport function useOptionalI18n(): I18nContextValue | null {\n return useContext(I18nContext);\n}\n\n/**\n * Shortcut for components that only need the `t` function — avoids destructuring.\n */\nexport function useTranslate(): I18nContextValue[\"t\"] {\n return useI18n().t;\n}\n"],"mappings":";;;;AAWA,IAAM,IAAc,EAAuC,IAAI;AAc/D,SAAS,EAAW,GAA2B,GAAoC;CAC/E,IAAI,CAAC,KAAc,OAAO,SAAW,KAAa,OAAO;CACzD,IAAI;EACA,IAAM,IAAQ,OAAO,aAAa,QAAQ,CAAU;EAEpD,OADI,KAAS,EAAU,SAAS,CAAK,IAAU,IACxC;CACX,QAAQ;EACJ,OAAO;CACX;AACJ;AAUA,SAAgB,EAAa,EACzB,aACA,QAAQ,GACR,mBACA,aACA,gBAAa,oBACK;CAClB,IAAM,IAAmB,QAAc,OAAO,KAAK,CAAQ,GAAG,CAAC,CAAQ,CAAC,GAClE,CAAC,GAAQ,KAAkB,QACvB,EAAW,GAAY,CAAgB,KAAK,CACtD;CAEA,QAAgB;EACZ,AAAI,OAAO,WAAa,OACpB,SAAS,gBAAgB,aAAa,QAAQ,CAAM;CAE5D,GAAG,CAAC,CAAM,CAAC;CAEX,IAAM,IAAY,GACb,MAAiB;EAEd,IADA,EAAe,CAAI,GACf,KAAc,OAAO,SAAW,KAChC,IAAI;GACA,OAAO,aAAa,QAAQ,GAAY,CAAI;EAChD,QAAQ,CAER;CAER,GACA,CAAC,CAAU,CACf,GAEM,IAAQ,SAEH;EAAE,GADI,EAAW;GAAE;GAAQ;GAAgB;EAAS,CAC/C;EAAM;EAAW;CAAiB,IAC/C;EAAC;EAAQ;EAAgB;EAAU;EAAW;CAAgB,CAAC;CAElE,OAAO,kBAAC,EAAY,UAAb;EAA6B;EAAQ;CAA+B,CAAA;AAC/E;AAKA,SAAgB,IAA4B;CACxC,IAAM,IAAM,EAAW,CAAW;CAClC,IAAI,CAAC,GAAK,MAAU,MAAM,+CAA+C;CACzE,OAAO;AACX;AAYA,SAAgB,IAA2C;CACvD,OAAO,EAAW,CAAW;AACjC;AAKA,SAAgB,IAAsC;CAClD,OAAO,EAAQ,CAAC,CAAC;AACrB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./constants.cjs");let
|
|
1
|
+
const e=require("./constants.cjs"),t=require("./retry-policy.cjs");let n=require("react"),r=require("react/jsx-runtime"),i=require("@tanstack/react-query");function a({children:a,client:o,defaultOptions:s}){let[c]=(0,n.useState)(()=>o??new i.QueryClient({defaultOptions:{queries:{staleTime:e.STALE_TIME.DEFAULT,gcTime:e.CACHE_TIME.DEFAULT,retry:t.shouldRetryQuery,refetchOnWindowFocus:!1,...s?.queries??{}},mutations:{retry:0,...s?.mutations??{}}}}));return(0,r.jsx)(i.QueryClientProvider,{client:c,children:a})}exports.QueryProvider=a;
|
|
2
2
|
//# sourceMappingURL=QueryProvider.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryProvider.cjs","names":[],"sources":["../../src/query/QueryProvider.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport type { DefaultOptions } from \"@tanstack/react-query\";\nimport { STALE_TIME, CACHE_TIME } from \"./constants\";\n\nexport interface QueryProviderProps {\n children: ReactNode;\n /** Pass an existing client to share it across roots. */\n client?: QueryClient;\n /** Overrides for the default options applied when no `client` is provided. */\n defaultOptions?: DefaultOptions;\n}\n\n/**\n * Wrapper around `QueryClientProvider` that bootstraps a `QueryClient` with\n * sane SDK defaults (5-minute stale time, 30-minute gc time,
|
|
1
|
+
{"version":3,"file":"QueryProvider.cjs","names":[],"sources":["../../src/query/QueryProvider.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport type { DefaultOptions } from \"@tanstack/react-query\";\nimport { STALE_TIME, CACHE_TIME } from \"./constants\";\nimport { shouldRetryQuery } from \"./retry-policy\";\n\nexport interface QueryProviderProps {\n children: ReactNode;\n /** Pass an existing client to share it across roots. */\n client?: QueryClient;\n /** Overrides for the default options applied when no `client` is provided. */\n defaultOptions?: DefaultOptions;\n}\n\n/**\n * Wrapper around `QueryClientProvider` that bootstraps a `QueryClient` with\n * sane SDK defaults (5-minute stale time, 30-minute gc time, one retry for\n * failures worth replaying).\n *\n * Retries follow {@link shouldRetryQuery} rather than a flat count: a 4xx other\n * than 408/429 is the server refusing on purpose, and replaying it only doubles\n * the network log while the spinner keeps turning.\n */\nexport function QueryProvider({ children, client, defaultOptions }: QueryProviderProps) {\n const [internalClient] = useState<QueryClient>(\n () =>\n client ??\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: STALE_TIME.DEFAULT,\n gcTime: CACHE_TIME.DEFAULT,\n retry: shouldRetryQuery,\n refetchOnWindowFocus: false,\n ...(defaultOptions?.queries ?? {}),\n },\n mutations: {\n retry: 0,\n ...(defaultOptions?.mutations ?? {}),\n },\n },\n }),\n );\n\n return <QueryClientProvider client={internalClient}>{children}</QueryClientProvider>;\n}\n"],"mappings":"4JAwBA,SAAgB,EAAc,CAAE,WAAU,SAAQ,kBAAsC,CACpF,GAAM,CAAC,IAAA,EAAkB,EAAA,SAAA,KAEjB,GACA,IAAI,EAAA,YAAY,CACZ,eAAgB,CACZ,QAAS,CACL,UAAW,EAAA,WAAW,QACtB,OAAQ,EAAA,WAAW,QACnB,MAAO,EAAA,iBACP,qBAAsB,GACtB,GAAI,GAAgB,SAAW,CAAC,CACpC,EACA,UAAW,CACP,MAAO,EACP,GAAI,GAAgB,WAAa,CAAC,CACtC,CACJ,CACJ,CAAC,CACT,EAEA,OAAO,EAAA,EAAA,IAAA,CAAC,EAAA,oBAAD,CAAqB,OAAQ,EAAiB,UAA8B,CAAA,CACvF"}
|
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import { CACHE_TIME as e, STALE_TIME as t } from "./constants.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { shouldRetryQuery as n } from "./retry-policy.js";
|
|
3
|
+
import { useState as r } from "react";
|
|
4
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
5
|
+
import { QueryClient as a, QueryClientProvider as o } from "@tanstack/react-query";
|
|
5
6
|
//#region src/query/QueryProvider.tsx
|
|
6
|
-
function
|
|
7
|
-
let [
|
|
7
|
+
function s({ children: s, client: c, defaultOptions: l }) {
|
|
8
|
+
let [u] = r(() => c ?? new a({ defaultOptions: {
|
|
8
9
|
queries: {
|
|
9
10
|
staleTime: t.DEFAULT,
|
|
10
11
|
gcTime: e.DEFAULT,
|
|
11
|
-
retry:
|
|
12
|
+
retry: n,
|
|
12
13
|
refetchOnWindowFocus: !1,
|
|
13
|
-
...
|
|
14
|
+
...l?.queries ?? {}
|
|
14
15
|
},
|
|
15
16
|
mutations: {
|
|
16
17
|
retry: 0,
|
|
17
|
-
...
|
|
18
|
+
...l?.mutations ?? {}
|
|
18
19
|
}
|
|
19
20
|
} }));
|
|
20
|
-
return /* @__PURE__ */
|
|
21
|
-
client:
|
|
22
|
-
children:
|
|
21
|
+
return /* @__PURE__ */ i(o, {
|
|
22
|
+
client: u,
|
|
23
|
+
children: s
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
//#endregion
|
|
26
|
-
export {
|
|
27
|
+
export { s as QueryProvider };
|
|
27
28
|
|
|
28
29
|
//# sourceMappingURL=QueryProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryProvider.js","names":[],"sources":["../../src/query/QueryProvider.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport type { DefaultOptions } from \"@tanstack/react-query\";\nimport { STALE_TIME, CACHE_TIME } from \"./constants\";\n\nexport interface QueryProviderProps {\n children: ReactNode;\n /** Pass an existing client to share it across roots. */\n client?: QueryClient;\n /** Overrides for the default options applied when no `client` is provided. */\n defaultOptions?: DefaultOptions;\n}\n\n/**\n * Wrapper around `QueryClientProvider` that bootstraps a `QueryClient` with\n * sane SDK defaults (5-minute stale time, 30-minute gc time,
|
|
1
|
+
{"version":3,"file":"QueryProvider.js","names":[],"sources":["../../src/query/QueryProvider.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport type { DefaultOptions } from \"@tanstack/react-query\";\nimport { STALE_TIME, CACHE_TIME } from \"./constants\";\nimport { shouldRetryQuery } from \"./retry-policy\";\n\nexport interface QueryProviderProps {\n children: ReactNode;\n /** Pass an existing client to share it across roots. */\n client?: QueryClient;\n /** Overrides for the default options applied when no `client` is provided. */\n defaultOptions?: DefaultOptions;\n}\n\n/**\n * Wrapper around `QueryClientProvider` that bootstraps a `QueryClient` with\n * sane SDK defaults (5-minute stale time, 30-minute gc time, one retry for\n * failures worth replaying).\n *\n * Retries follow {@link shouldRetryQuery} rather than a flat count: a 4xx other\n * than 408/429 is the server refusing on purpose, and replaying it only doubles\n * the network log while the spinner keeps turning.\n */\nexport function QueryProvider({ children, client, defaultOptions }: QueryProviderProps) {\n const [internalClient] = useState<QueryClient>(\n () =>\n client ??\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: STALE_TIME.DEFAULT,\n gcTime: CACHE_TIME.DEFAULT,\n retry: shouldRetryQuery,\n refetchOnWindowFocus: false,\n ...(defaultOptions?.queries ?? {}),\n },\n mutations: {\n retry: 0,\n ...(defaultOptions?.mutations ?? {}),\n },\n },\n }),\n );\n\n return <QueryClientProvider client={internalClient}>{children}</QueryClientProvider>;\n}\n"],"mappings":";;;;;;AAwBA,SAAgB,EAAc,EAAE,aAAU,WAAQ,qBAAsC;CACpF,IAAM,CAAC,KAAkB,QAEjB,KACA,IAAI,EAAY,EACZ,gBAAgB;EACZ,SAAS;GACL,WAAW,EAAW;GACtB,QAAQ,EAAW;GACnB,OAAO;GACP,sBAAsB;GACtB,GAAI,GAAgB,WAAW,CAAC;EACpC;EACA,WAAW;GACP,OAAO;GACP,GAAI,GAAgB,aAAa,CAAC;EACtC;CACJ,EACJ,CAAC,CACT;CAEA,OAAO,kBAAC,GAAD;EAAqB,QAAQ;EAAiB;CAA8B,CAAA;AACvF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry-policy.cjs","names":[],"sources":["../../src/query/retry-policy.ts"],"sourcesContent":["import { isApiError } from \"../http/errors\";\n\n/**\n * Statuses in the 4xx range that are still worth replaying.\n *\n * `429` is a refusal that explicitly means \"later\", and `408` is the server\n * saying the request itself timed out — both describe a condition that changes on\n * its own. Every other 4xx is the server refusing on purpose, and repeating it\n * changes nothing.\n */\nconst RETRIABLE_CLIENT_STATUSES: ReadonlySet<number> = new Set([408, 429]);\n\n/** How many times a retriable failure is replayed. */\nconst MAX_RETRIES = 1;\n\n/**\n * Default `retry` for SDK queries: replay transport and server failures, never a\n * deliberate client-side refusal.\n *\n * A flat `retry: 1` replays a 403 on an admin-only listing and a 404 for a record\n * somebody deleted. The server meant both — the second attempt returns the same\n * answer, doubles the network log and holds the spinner on screen for the length\n * of another round trip. A network failure or a 5xx is a different thing: it may\n * well succeed on the next try, so those keep the previous behaviour.\n *\n * @example\n * new QueryClient({ defaultOptions: { queries: { retry: shouldRetryQuery } } });\n *\n * @param failureCount - Attempts already made, as react-query counts them.\n * @param error - The rejection value from the query function.\n * @returns Whether react-query should try again.\n */\nexport function shouldRetryQuery(failureCount: number, error: unknown): boolean {\n if (failureCount >= MAX_RETRIES) return false;\n if (!isApiError(error)) return true;\n if (error.status === 0) return true;\n if (error.status >= 400 && error.status < 500) {\n return RETRIABLE_CLIENT_STATUSES.has(error.status);\n }\n return true;\n}\n"],"mappings":"sCAUA,IAAM,EAAiD,IAAI,IAAI,CAAC,IAAK,GAAG,CAAC,EAGnE,EAAc,EAmBpB,SAAgB,EAAiB,EAAsB,EAAyB,CAO5E,OANI,GAAgB,EAAoB,GACpC,CAAC,EAAA,WAAW,CAAK,GACjB,EAAM,SAAW,EAAU,GAC3B,EAAM,QAAU,KAAO,EAAM,OAAS,IAC/B,EAA0B,IAAI,EAAM,MAAM,EAE9C,EACX"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isApiError as e } from "../http/errors.js";
|
|
2
|
+
//#region src/query/retry-policy.ts
|
|
3
|
+
var t = /* @__PURE__ */ new Set([408, 429]), n = 1;
|
|
4
|
+
function r(r, i) {
|
|
5
|
+
return r >= n ? !1 : !e(i) || i.status === 0 ? !0 : i.status >= 400 && i.status < 500 ? t.has(i.status) : !0;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { r as shouldRetryQuery };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=retry-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry-policy.js","names":[],"sources":["../../src/query/retry-policy.ts"],"sourcesContent":["import { isApiError } from \"../http/errors\";\n\n/**\n * Statuses in the 4xx range that are still worth replaying.\n *\n * `429` is a refusal that explicitly means \"later\", and `408` is the server\n * saying the request itself timed out — both describe a condition that changes on\n * its own. Every other 4xx is the server refusing on purpose, and repeating it\n * changes nothing.\n */\nconst RETRIABLE_CLIENT_STATUSES: ReadonlySet<number> = new Set([408, 429]);\n\n/** How many times a retriable failure is replayed. */\nconst MAX_RETRIES = 1;\n\n/**\n * Default `retry` for SDK queries: replay transport and server failures, never a\n * deliberate client-side refusal.\n *\n * A flat `retry: 1` replays a 403 on an admin-only listing and a 404 for a record\n * somebody deleted. The server meant both — the second attempt returns the same\n * answer, doubles the network log and holds the spinner on screen for the length\n * of another round trip. A network failure or a 5xx is a different thing: it may\n * well succeed on the next try, so those keep the previous behaviour.\n *\n * @example\n * new QueryClient({ defaultOptions: { queries: { retry: shouldRetryQuery } } });\n *\n * @param failureCount - Attempts already made, as react-query counts them.\n * @param error - The rejection value from the query function.\n * @returns Whether react-query should try again.\n */\nexport function shouldRetryQuery(failureCount: number, error: unknown): boolean {\n if (failureCount >= MAX_RETRIES) return false;\n if (!isApiError(error)) return true;\n if (error.status === 0) return true;\n if (error.status >= 400 && error.status < 500) {\n return RETRIABLE_CLIENT_STATUSES.has(error.status);\n }\n return true;\n}\n"],"mappings":";;AAUA,IAAM,oBAAiD,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,GAGnE,IAAc;AAmBpB,SAAgB,EAAiB,GAAsB,GAAyB;CAO5E,OANI,KAAgB,IAAoB,KACpC,CAAC,EAAW,CAAK,KACjB,EAAM,WAAW,IAAU,KAC3B,EAAM,UAAU,OAAO,EAAM,SAAS,MAC/B,EAA0B,IAAI,EAAM,MAAM,IAE9C;AACX"}
|