@stacksjs/browser 0.70.23 → 0.70.25
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/index.js +2113 -16871
- package/dist/src/composables/index.d.ts +140 -0
- package/dist/src/composables/useApi.d.ts +56 -0
- package/dist/src/composables/useAuth.d.ts +6 -0
- package/dist/src/index.d.ts +32 -0
- package/dist/src/model-loader.d.ts +12 -0
- package/dist/src/utils/base.d.ts +7 -0
- package/dist/{billable.d.ts → src/utils/billable.d.ts} +2 -2
- package/dist/src/utils/date.d.ts +2 -0
- package/dist/src/utils/debounce.d.ts +5 -0
- package/dist/src/utils/fetch.d.ts +11 -0
- package/dist/src/utils/function.d.ts +18 -0
- package/dist/src/utils/guards.d.ts +28 -0
- package/dist/src/utils/index.d.ts +17 -0
- package/dist/src/utils/lazy.d.ts +6 -0
- package/dist/{math.d.ts → src/utils/math.d.ts} +3 -7
- package/dist/src/utils/plans.d.ts +2 -0
- package/dist/src/utils/promise.d.ts +49 -0
- package/dist/src/utils/random.d.ts +10 -0
- package/dist/src/utils/regex.d.ts +38 -0
- package/dist/{retry.d.ts → src/utils/retry.d.ts} +4 -2
- package/dist/src/utils/sleep.d.ts +35 -0
- package/dist/src/utils/throttle.d.ts +20 -0
- package/dist/src/utils/vendors.d.ts +29 -0
- package/package.json +26 -6
- package/dist/base.d.ts +0 -3
- package/dist/date.d.ts +0 -1
- package/dist/debounce.d.ts +0 -1
- package/dist/fetch.d.ts +0 -103
- package/dist/function.d.ts +0 -2
- package/dist/guards.d.ts +0 -4
- package/dist/index.d.ts +0 -1
- package/dist/lazy.d.ts +0 -1
- package/dist/plans.d.ts +0 -32
- package/dist/promise.d.ts +0 -10
- package/dist/random.d.ts +0 -15
- package/dist/regex.d.ts +0 -29
- package/dist/sleep.d.ts +0 -11
- package/dist/throttle.d.ts +0 -1
- package/dist/useFetch.d.ts +0 -19
- package/dist/vendors.d.ts +0 -252
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
export * from './useAuth';
|
|
2
|
+
export * from './useApi';
|
|
3
|
+
// Re-export browser-relevant composables from @stacksjs/composables
|
|
4
|
+
export {
|
|
5
|
+
// Color mode / Theme
|
|
6
|
+
useColorMode,
|
|
7
|
+
useDark,
|
|
8
|
+
usePreferredColorScheme,
|
|
9
|
+
usePreferredContrast,
|
|
10
|
+
usePreferredDark,
|
|
11
|
+
usePreferredReducedMotion,
|
|
12
|
+
|
|
13
|
+
// Date / Time
|
|
14
|
+
useDateFormat,
|
|
15
|
+
useNow,
|
|
16
|
+
useTimeAgo,
|
|
17
|
+
useTimestamp,
|
|
18
|
+
|
|
19
|
+
// Network / Online
|
|
20
|
+
useFetch,
|
|
21
|
+
useNetwork,
|
|
22
|
+
useOnline,
|
|
23
|
+
|
|
24
|
+
// Storage
|
|
25
|
+
useLocalStorage,
|
|
26
|
+
useSessionStorage,
|
|
27
|
+
useStorage,
|
|
28
|
+
|
|
29
|
+
// Toggle / State
|
|
30
|
+
useToggle,
|
|
31
|
+
useCounter,
|
|
32
|
+
useStepper,
|
|
33
|
+
useCycleList,
|
|
34
|
+
|
|
35
|
+
// DOM / Elements
|
|
36
|
+
useActiveElement,
|
|
37
|
+
useClipboard,
|
|
38
|
+
useClipboardItems,
|
|
39
|
+
useCssVar,
|
|
40
|
+
useDocumentVisibility,
|
|
41
|
+
useElementBounding,
|
|
42
|
+
useElementHover,
|
|
43
|
+
useElementSize,
|
|
44
|
+
useElementVisibility,
|
|
45
|
+
useFocus,
|
|
46
|
+
useFocusWithin,
|
|
47
|
+
useFullscreen,
|
|
48
|
+
useScroll,
|
|
49
|
+
useScrollLock,
|
|
50
|
+
useTitle,
|
|
51
|
+
useWindowFocus,
|
|
52
|
+
useWindowScroll,
|
|
53
|
+
useWindowSize,
|
|
54
|
+
|
|
55
|
+
// Events / Interaction
|
|
56
|
+
onClickOutside,
|
|
57
|
+
onKeyDown,
|
|
58
|
+
onKeyStroke,
|
|
59
|
+
onKeyUp,
|
|
60
|
+
onLongPress,
|
|
61
|
+
onStartTyping,
|
|
62
|
+
useEventListener,
|
|
63
|
+
useKeyModifier,
|
|
64
|
+
useMagicKeys,
|
|
65
|
+
|
|
66
|
+
// Mouse / Pointer / Swipe
|
|
67
|
+
useDraggable,
|
|
68
|
+
useDropZone,
|
|
69
|
+
useMouse,
|
|
70
|
+
useMouseInElement,
|
|
71
|
+
useMousePressed,
|
|
72
|
+
usePointer,
|
|
73
|
+
usePointerSwipe,
|
|
74
|
+
useSwipe,
|
|
75
|
+
|
|
76
|
+
// Sensors
|
|
77
|
+
useBattery,
|
|
78
|
+
useDeviceMotion,
|
|
79
|
+
useDeviceOrientation,
|
|
80
|
+
useDevicePixelRatio,
|
|
81
|
+
useGeolocation,
|
|
82
|
+
|
|
83
|
+
// Media
|
|
84
|
+
useBreakpoints,
|
|
85
|
+
useMediaQuery,
|
|
86
|
+
breakpointsTailwind,
|
|
87
|
+
breakpointsBootstrapV5,
|
|
88
|
+
|
|
89
|
+
// Page / Navigation
|
|
90
|
+
useBrowserLocation,
|
|
91
|
+
useIdle,
|
|
92
|
+
useInfiniteScroll,
|
|
93
|
+
useNavigatorLanguage,
|
|
94
|
+
usePageLeave,
|
|
95
|
+
usePreferredLanguages,
|
|
96
|
+
useScreenOrientation,
|
|
97
|
+
useTextDirection,
|
|
98
|
+
useTextSelection,
|
|
99
|
+
useUrlSearchParams,
|
|
100
|
+
|
|
101
|
+
// Timing
|
|
102
|
+
useDebounceFn,
|
|
103
|
+
useInterval,
|
|
104
|
+
useIntervalFn,
|
|
105
|
+
useRafFn,
|
|
106
|
+
useThrottleFn,
|
|
107
|
+
useTimeout,
|
|
108
|
+
useTimeoutFn,
|
|
109
|
+
useTimeoutPoll,
|
|
110
|
+
|
|
111
|
+
// Animations
|
|
112
|
+
useAnimate,
|
|
113
|
+
useTransition,
|
|
114
|
+
TransitionPresets,
|
|
115
|
+
|
|
116
|
+
// APIs
|
|
117
|
+
useBase64,
|
|
118
|
+
useBroadcastChannel,
|
|
119
|
+
useConfirmDialog,
|
|
120
|
+
useEventBus,
|
|
121
|
+
useEventSource,
|
|
122
|
+
useEyeDropper,
|
|
123
|
+
useFavicon,
|
|
124
|
+
useFileDialog,
|
|
125
|
+
useImage,
|
|
126
|
+
useObjectUrl,
|
|
127
|
+
usePermission,
|
|
128
|
+
useShare,
|
|
129
|
+
useVibrate,
|
|
130
|
+
useWakeLock,
|
|
131
|
+
useWebNotification,
|
|
132
|
+
useWebSocket,
|
|
133
|
+
useWebWorker,
|
|
134
|
+
useWebWorkerFn,
|
|
135
|
+
|
|
136
|
+
// Utilities
|
|
137
|
+
useSupported,
|
|
138
|
+
useMemoize,
|
|
139
|
+
useMounted,
|
|
140
|
+
} from '@stacksjs/composables';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initialize the API client with custom configuration
|
|
3
|
+
*
|
|
4
|
+
* NOTE: This is now OPTIONAL. The framework auto-initializes with
|
|
5
|
+
* sensible defaults when @stacksjs/browser is imported.
|
|
6
|
+
*
|
|
7
|
+
* Only call this if you need custom configuration:
|
|
8
|
+
* - Different API base URL
|
|
9
|
+
* - Custom unauthorized handler
|
|
10
|
+
* - Custom token retrieval
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Custom base URL
|
|
14
|
+
* initApi({ baseUrl: 'https://api.example.com' })
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Custom unauthorized handler
|
|
18
|
+
* initApi({
|
|
19
|
+
* onUnauthorized: () => showLoginModal()
|
|
20
|
+
* })
|
|
21
|
+
*/
|
|
22
|
+
export declare function initApi(options?: {
|
|
23
|
+
baseUrl?: string
|
|
24
|
+
onUnauthorized?: () => void
|
|
25
|
+
}): void;
|
|
26
|
+
/**
|
|
27
|
+
* Helper to format area size for display
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatAreaSize(sqMeters: number): string;
|
|
30
|
+
/**
|
|
31
|
+
* Helper to format distance for display
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatDistance(miles: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* Helper to format elevation for display
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatElevation(feet: number): string;
|
|
38
|
+
/**
|
|
39
|
+
* Helper to format duration for display
|
|
40
|
+
*/
|
|
41
|
+
export declare function formatDuration(seconds: number): string;
|
|
42
|
+
/**
|
|
43
|
+
* Helper to get relative time (e.g., "2 hours ago")
|
|
44
|
+
*/
|
|
45
|
+
export declare function getRelativeTime(dateString: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Type-safe API fetch wrapper with error handling
|
|
48
|
+
*/
|
|
49
|
+
export declare function fetchData<T>(fetcher: () => Promise<T>, options?: {
|
|
50
|
+
onError?: (error: Error) => void
|
|
51
|
+
fallback?: T
|
|
52
|
+
}): Promise<T | undefined>;
|
|
53
|
+
/**
|
|
54
|
+
* Auth utilities
|
|
55
|
+
*/
|
|
56
|
+
export declare const auth: unknown;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AuthComposable } from '../types/dashboard';
|
|
2
|
+
export declare function useAuth(): AuthComposable;
|
|
3
|
+
// Strict auth guard middleware
|
|
4
|
+
// Usage: call in setup() of page/component, or in router beforeEach
|
|
5
|
+
// Pass { guest: true } for guest-only pages
|
|
6
|
+
export declare function authGuard(options?: { guest?: boolean }): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import './auto-init';
|
|
2
|
+
export type {
|
|
3
|
+
BrowserModelDefinition,
|
|
4
|
+
BrowserTypedAttribute,
|
|
5
|
+
BrowserModelInstance,
|
|
6
|
+
BrowserModelQueryBuilder,
|
|
7
|
+
} from 'bun-query-builder/browser';
|
|
8
|
+
// `BrowserConfig` lives in the main `bun-query-builder` types entry, not the
|
|
9
|
+
// `/browser` subpath — re-export it from there. The runtime code in this file
|
|
10
|
+
// uses only the `/browser` entry, so server-only code paths are still avoided.
|
|
11
|
+
export type { BrowserConfig } from 'bun-query-builder';
|
|
12
|
+
export * from './composables';
|
|
13
|
+
export * from './utils';
|
|
14
|
+
export * from './model-loader';
|
|
15
|
+
// Re-export browser query builder from bun-query-builder.
|
|
16
|
+
//
|
|
17
|
+
// Pull from the dedicated `/browser` subpath instead of the main entry —
|
|
18
|
+
// the main entry pulls in `bun:sqlite`, `child_process`, `stream/promises`,
|
|
19
|
+
// etc. through server-side code branches, which the browser bundler can't
|
|
20
|
+
// elide. The package's own `./browser` export is purpose-built for this:
|
|
21
|
+
// only browser-safe code, no Node/Bun builtins.
|
|
22
|
+
export {
|
|
23
|
+
browserQuery,
|
|
24
|
+
BrowserQueryBuilder,
|
|
25
|
+
BrowserQueryError,
|
|
26
|
+
browserAuth,
|
|
27
|
+
configureBrowser,
|
|
28
|
+
getBrowserConfig,
|
|
29
|
+
createBrowserDb,
|
|
30
|
+
createBrowserModel,
|
|
31
|
+
isBrowser,
|
|
32
|
+
} from 'bun-query-builder/browser';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load all models and register them on window.StacksBrowser
|
|
3
|
+
*/
|
|
4
|
+
export declare function loadBrowserModels(): void;
|
|
5
|
+
/**
|
|
6
|
+
* Get a loaded model by name
|
|
7
|
+
*/
|
|
8
|
+
export declare function getBrowserModel(name: string): any;
|
|
9
|
+
/**
|
|
10
|
+
* Get all loaded model names
|
|
11
|
+
*/
|
|
12
|
+
export declare function getBrowserModelNames(): string[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// export function assert(condition: boolean, message: string): asserts condition {
|
|
2
|
+
// if (!condition)
|
|
3
|
+
// throw new Error(message)
|
|
4
|
+
// }
|
|
5
|
+
// export function noop() {}
|
|
6
|
+
export declare function loop(times: number, callback: any): Promise<void>;
|
|
7
|
+
export { toString } from '@stacksjs/strings';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare let publishableKey: string;
|
|
2
1
|
export declare function loadCardElement(clientSecret: string): Promise<any>;
|
|
3
2
|
export declare function loadPaymentElement(clientSecret: string): Promise<any>;
|
|
4
3
|
export declare function confirmCardSetup(clientSecret: string, elements: any): Promise<{ setupIntent: any, error: any }>;
|
|
5
4
|
export declare function confirmCardPayment(clientSecret: string, elements: any): Promise<{ paymentIntent: any, error: any }>;
|
|
6
5
|
export declare function createPaymentMethod(elements: any): Promise<{ paymentIntent: any, error: any }>;
|
|
7
|
-
export declare function confirmPayment(elements: any): Promise<{ paymentIntent: any, error: any }>;
|
|
6
|
+
export declare function confirmPayment(elements: any): Promise<{ paymentIntent: any, error: any }>;
|
|
7
|
+
export declare const publishableKey: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loose payload type for `Fetch.{get,post,patch,put,destroy}`.
|
|
3
|
+
*
|
|
4
|
+
* GET sends this as a query string; POST/PATCH/PUT send it as a JSON body.
|
|
5
|
+
* Values are constrained to JSON-serializable primitives + nested
|
|
6
|
+
* arrays/objects so we catch unintentional `Function` / `Date` / `Symbol`
|
|
7
|
+
* payloads at the call site instead of seeing them silently coerced
|
|
8
|
+
* to `[object Object]` over the wire.
|
|
9
|
+
*/
|
|
10
|
+
declare type Primitive = string | number | boolean | null | undefined;
|
|
11
|
+
declare type FetchResponse = string | Blob | ArrayBuffer | ReadableStream<Uint8Array> | object;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Fn, Nullable } from '@stacksjs/types';
|
|
2
|
+
/**
|
|
3
|
+
* Call every function in an array
|
|
4
|
+
*/
|
|
5
|
+
export declare function batchInvoke(functions: Nullable<Fn>[]): void;
|
|
6
|
+
/**
|
|
7
|
+
* Pass the value through the callback, and return the value
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```
|
|
11
|
+
* function createUser(name: string): User {
|
|
12
|
+
* return tap(new User, user => {
|
|
13
|
+
* user.name = name
|
|
14
|
+
* })
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function tap<T>(value: T, callback: (value: T) => void): T;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard to filter out null-ish values
|
|
3
|
+
*
|
|
4
|
+
* @category Guards
|
|
5
|
+
* @example array.filter(notNullish)
|
|
6
|
+
*/
|
|
7
|
+
export declare function notNullish<T>(v: T | null | undefined): v is NonNullable<T>;
|
|
8
|
+
/**
|
|
9
|
+
* Type guard to filter out null values
|
|
10
|
+
*
|
|
11
|
+
* @category Guards
|
|
12
|
+
* @example array.filter(noNull)
|
|
13
|
+
*/
|
|
14
|
+
export declare function noNull<T>(v: T | null): v is Exclude<T, null>;
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to filter out null-ish values
|
|
17
|
+
*
|
|
18
|
+
* @category Guards
|
|
19
|
+
* @example array.filter(notUndefined)
|
|
20
|
+
*/
|
|
21
|
+
export declare function notUndefined<T>(v: T): v is Exclude<T, undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* Type guard to filter out falsy values
|
|
24
|
+
*
|
|
25
|
+
* @category Guards
|
|
26
|
+
* @example array.filter(isTruthy)
|
|
27
|
+
*/
|
|
28
|
+
export declare function isTruthy<T>(v: T): v is NonNullable<T>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './base';
|
|
2
|
+
export * from './billable';
|
|
3
|
+
export * from './date';
|
|
4
|
+
export * from './debounce';
|
|
5
|
+
export * from './fetch';
|
|
6
|
+
export * from './function';
|
|
7
|
+
export * from './guards';
|
|
8
|
+
export * from './lazy';
|
|
9
|
+
export * from './math';
|
|
10
|
+
export * from './plans';
|
|
11
|
+
export * from './promise';
|
|
12
|
+
export * from './random';
|
|
13
|
+
export * from './regex';
|
|
14
|
+
export * from './retry';
|
|
15
|
+
export * from './sleep';
|
|
16
|
+
export * from './throttle';
|
|
17
|
+
export * from './vendors';
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
export declare const clamp: n;
|
|
2
1
|
export declare function rand(min: number, max: number): number;
|
|
3
|
-
|
|
2
|
+
export declare const clamp: (n: number, min: number, max: number) => number;
|
|
3
|
+
// Re-export reactive math utilities from @stacksjs/composables
|
|
4
4
|
export {
|
|
5
5
|
and,
|
|
6
|
-
createGenericProjection,
|
|
7
|
-
createProjection,
|
|
8
6
|
logicNot,
|
|
9
7
|
logicOr,
|
|
10
8
|
or,
|
|
@@ -13,12 +11,10 @@ export {
|
|
|
13
11
|
useCeil,
|
|
14
12
|
useClamp,
|
|
15
13
|
useFloor,
|
|
16
|
-
useMath,
|
|
17
14
|
useMax,
|
|
18
15
|
useMin,
|
|
19
16
|
usePrecision,
|
|
20
|
-
useProjection,
|
|
21
17
|
useRound,
|
|
22
18
|
useSum,
|
|
23
19
|
useTrunc,
|
|
24
|
-
} from '@
|
|
20
|
+
} from '@stacksjs/composables';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create singleton promise function.
|
|
3
|
+
*
|
|
4
|
+
* @category Promise
|
|
5
|
+
*/
|
|
6
|
+
export declare function createSingletonPromise<T>(fn: () => Promise<T>): SingletonPromiseReturn<T>;
|
|
7
|
+
/**
|
|
8
|
+
* Create a promise lock.
|
|
9
|
+
*
|
|
10
|
+
* @category Promise
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* const lock = createPromiseLock()
|
|
14
|
+
*
|
|
15
|
+
* lock.run(async () => {
|
|
16
|
+
* await doSomething()
|
|
17
|
+
* })
|
|
18
|
+
*
|
|
19
|
+
* // in anther context:
|
|
20
|
+
* await lock.wait() // it will wait all tasking finished
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function createPromiseLock(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Return a Promise with `resolve` and `reject` methods
|
|
26
|
+
*
|
|
27
|
+
* @category Promise
|
|
28
|
+
* @example
|
|
29
|
+
* ```
|
|
30
|
+
* const promise = createControlledPromise()
|
|
31
|
+
*
|
|
32
|
+
* await promise
|
|
33
|
+
*
|
|
34
|
+
* // in anther context:
|
|
35
|
+
* promise.resolve(data)
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function createControlledPromise<T>(): ControlledPromise<T>;
|
|
39
|
+
export declare interface SingletonPromiseReturn<T> {
|
|
40
|
+
(): Promise<T>
|
|
41
|
+
reset: () => Promise<void>
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Promise with `resolve` and `reject` methods of itself
|
|
45
|
+
*/
|
|
46
|
+
export declare interface ControlledPromise<T = void> extends Promise<T> {
|
|
47
|
+
resolve: (value: T | PromiseLike<T>) => void
|
|
48
|
+
reject: (reason?: any) => void
|
|
49
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare function customRandom(alphabet: string, defaultSize: number, getRandom: (bytes: number) => Uint8Array): void;
|
|
2
|
+
declare function customAlphabet(alphabet: string, size?: number): (size?: number) => string;
|
|
3
|
+
declare function randomNonSecure(size?: number): string;
|
|
4
|
+
declare function random(size?: number): string;
|
|
5
|
+
export {
|
|
6
|
+
customAlphabet,
|
|
7
|
+
customRandom,
|
|
8
|
+
random,
|
|
9
|
+
randomNonSecure,
|
|
10
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
Flag,
|
|
3
|
+
Input,
|
|
4
|
+
MagicRegExp,
|
|
5
|
+
MagicRegExpMatchArray,
|
|
6
|
+
MapToStringCapturedBy,
|
|
7
|
+
StringCapturedBy,
|
|
8
|
+
} from 'magic-regexp';
|
|
9
|
+
// export function caseInsensitive(pattern: string): RegExp {
|
|
10
|
+
// return new RegExp(pattern, 'i')
|
|
11
|
+
// }
|
|
12
|
+
export declare function createRegExp(pattern: string, options?: { flags?: string }): RegExp;
|
|
13
|
+
export {
|
|
14
|
+
anyOf,
|
|
15
|
+
carriageReturn,
|
|
16
|
+
caseInsensitive,
|
|
17
|
+
char,
|
|
18
|
+
charIn,
|
|
19
|
+
charNotIn,
|
|
20
|
+
digit,
|
|
21
|
+
dotAll,
|
|
22
|
+
exactly,
|
|
23
|
+
global,
|
|
24
|
+
letter,
|
|
25
|
+
linefeed,
|
|
26
|
+
maybe,
|
|
27
|
+
multiline,
|
|
28
|
+
not,
|
|
29
|
+
oneOrMore,
|
|
30
|
+
sticky,
|
|
31
|
+
tab,
|
|
32
|
+
unicode,
|
|
33
|
+
whitespace,
|
|
34
|
+
withIndices,
|
|
35
|
+
word,
|
|
36
|
+
wordBoundary,
|
|
37
|
+
wordChar,
|
|
38
|
+
} from 'magic-regexp';
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
// Replace the generic Function type with a more specific function type
|
|
2
|
+
export declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
3
|
+
export declare function calculateDelay(attemptCount: number, initialDelay: number, backoffFactor: number, jitter?: boolean): number;
|
|
4
|
+
// Define a more specific RetryOptions interface
|
|
1
5
|
export declare interface RetryOptions {
|
|
2
6
|
retries?: number
|
|
3
7
|
initialDelay?: number
|
|
4
8
|
backoffFactor?: number
|
|
5
9
|
jitter?: boolean
|
|
6
10
|
}
|
|
7
|
-
export declare function retry<T>(fn: ()): Promise<T>;
|
|
8
|
-
export declare function calculateDelay(attemptCount: number, initialDelay: number, backoffFactor: number, jitter?: boolean): number;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pauses execution for a specified number of milliseconds.
|
|
3
|
+
* @param ms The number of milliseconds to pause execution.
|
|
4
|
+
* @returns A promise that resolves after the specified delay.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Pauses execution for a specified number of milliseconds.
|
|
9
|
+
* @param ms The number of milliseconds to pause execution.
|
|
10
|
+
* @returns A promise that resolves after the specified delay.
|
|
11
|
+
*/
|
|
12
|
+
export declare function wait(ms: number): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Pauses execution for a specified number of milliseconds.
|
|
15
|
+
* @param ms The number of milliseconds to pause execution.
|
|
16
|
+
* @returns A promise that resolves after the specified delay.
|
|
17
|
+
*/
|
|
18
|
+
export declare function delay(ms: number): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Pauses execution until a specified condition is met.
|
|
21
|
+
*/
|
|
22
|
+
export declare function waitUntil(condition: () => boolean, options?: WaitOptions): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Pauses execution while a specified condition is met.
|
|
25
|
+
*/
|
|
26
|
+
export declare function waitWhile(condition: () => boolean, options?: WaitOptions): Promise<void>;
|
|
27
|
+
export type NonNegativeInteger<T extends number> = number extends T
|
|
28
|
+
? never
|
|
29
|
+
: `${T}` extends `-${string}` | `${string}.${string}`
|
|
30
|
+
? never
|
|
31
|
+
: T;
|
|
32
|
+
export type WaitOptions = number | {
|
|
33
|
+
interval?: number
|
|
34
|
+
timeout?: number
|
|
35
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throttle a function.
|
|
3
|
+
*
|
|
4
|
+
* @param {Function} fn - The function to throttle.
|
|
5
|
+
* @param {number} [wait] - The time to wait between function calls.
|
|
6
|
+
* @returns {Function} - A new function that throttles the calls to the original function.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* // logs window dimensions at most every 250ms
|
|
11
|
+
* window.addEventListener(
|
|
12
|
+
* "resize",
|
|
13
|
+
* throttle(function (evt) {
|
|
14
|
+
* console.log(window.innerWidth)
|
|
15
|
+
* console.log(window.innerHeight)
|
|
16
|
+
* }, 250)
|
|
17
|
+
* )
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function throttle<T extends (...args: any[]) => any>(fn: T, wait?: number): (...args: Parameters<T>) => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
HeadConfig as HeadObject,
|
|
3
|
+
HeadConfig as HeadObjectPlain,
|
|
4
|
+
} from '@stacksjs/stx';
|
|
5
|
+
export declare function readableSize(bytes: number, options?: ReadableSizeOptions): string;
|
|
6
|
+
export declare interface ReadableSizeOptions {
|
|
7
|
+
precision?: number
|
|
8
|
+
binary?: boolean
|
|
9
|
+
space?: boolean
|
|
10
|
+
locale?: string
|
|
11
|
+
minimumFractionDigits?: number
|
|
12
|
+
maximumFractionDigits?: number
|
|
13
|
+
}
|
|
14
|
+
// Re-export composables from @stacksjs/composables
|
|
15
|
+
export {
|
|
16
|
+
useDark,
|
|
17
|
+
useDateFormat,
|
|
18
|
+
useFetch,
|
|
19
|
+
useNow,
|
|
20
|
+
useOnline,
|
|
21
|
+
usePreferredDark,
|
|
22
|
+
useStorage,
|
|
23
|
+
useToggle,
|
|
24
|
+
} from '@stacksjs/composables';
|
|
25
|
+
export {
|
|
26
|
+
useHead as createHead,
|
|
27
|
+
useHead as Head,
|
|
28
|
+
renderHead as renderHeadToString,
|
|
29
|
+
} from '@stacksjs/stx';
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/browser",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.70.
|
|
4
|
+
"version": "0.70.25",
|
|
5
5
|
"description": "Stacks core frontend/browser functionalities.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
|
-
"contributors": [
|
|
7
|
+
"contributors": [
|
|
8
|
+
"Chris Breuer <chris@stacksjs.com>"
|
|
9
|
+
],
|
|
8
10
|
"license": "MIT",
|
|
9
11
|
"funding": "https://github.com/sponsors/chrisbbreuer",
|
|
10
12
|
"homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/browser#readme",
|
|
@@ -16,25 +18,43 @@
|
|
|
16
18
|
"bugs": {
|
|
17
19
|
"url": "https://github.com/stacksjs/stacks/issues"
|
|
18
20
|
},
|
|
19
|
-
"keywords": [
|
|
21
|
+
"keywords": [
|
|
22
|
+
"frontend",
|
|
23
|
+
"browser",
|
|
24
|
+
"stacks",
|
|
25
|
+
"api"
|
|
26
|
+
],
|
|
20
27
|
"exports": {
|
|
21
28
|
".": {
|
|
29
|
+
"bun": "./src/index.ts",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
22
31
|
"import": "./dist/index.js"
|
|
23
32
|
},
|
|
24
33
|
"./*": {
|
|
34
|
+
"bun": "./src/*",
|
|
25
35
|
"import": "./dist/*"
|
|
26
36
|
}
|
|
27
37
|
},
|
|
28
38
|
"module": "dist/index.js",
|
|
29
39
|
"types": "dist/index.d.ts",
|
|
30
|
-
"files": [
|
|
40
|
+
"files": [
|
|
41
|
+
"README.md",
|
|
42
|
+
"dist"
|
|
43
|
+
],
|
|
31
44
|
"scripts": {
|
|
32
45
|
"build": "bun build.ts",
|
|
33
46
|
"typecheck": "bun tsc --noEmit",
|
|
34
47
|
"prepublishOnly": "bun run build"
|
|
35
48
|
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@stacksjs/composables": "0.70.23",
|
|
51
|
+
"@stacksjs/stx": "^0.2.40",
|
|
52
|
+
"@stripe/stripe-js": "^9.0.0",
|
|
53
|
+
"bun-query-builder": "^0.1.18",
|
|
54
|
+
"magic-regexp": "^0.11.0"
|
|
55
|
+
},
|
|
36
56
|
"devDependencies": {
|
|
37
|
-
"
|
|
38
|
-
"@stacksjs/utils": "0.70.
|
|
57
|
+
"better-dx": "^0.2.12",
|
|
58
|
+
"@stacksjs/utils": "0.70.23"
|
|
39
59
|
}
|
|
40
60
|
}
|
package/dist/base.d.ts
DELETED
package/dist/date.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@stacksjs/datetime'
|
package/dist/debounce.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { debounce } from 'perfect-debounce'
|