@stacksjs/browser 0.70.87 → 0.70.88

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.
Files changed (55) hide show
  1. package/package.json +3 -3
  2. package/dist/auto-init.d.ts +0 -7
  3. package/dist/auto-init.js +0 -61
  4. package/dist/composables/auth/useGithub.d.ts +0 -12
  5. package/dist/composables/auth/useGithub.js +0 -41
  6. package/dist/composables/index.d.ts +0 -140
  7. package/dist/composables/index.js +0 -110
  8. package/dist/composables/useApi.d.ts +0 -56
  9. package/dist/composables/useApi.js +0 -66
  10. package/dist/composables/useAuth.d.ts +0 -6
  11. package/dist/composables/useAuth.js +0 -127
  12. package/dist/composables/useFetch.d.ts +0 -1
  13. package/dist/composables/useFetch.js +0 -1
  14. package/dist/index.d.ts +0 -32
  15. package/dist/index.js +0 -16
  16. package/dist/model-loader.d.ts +0 -84
  17. package/dist/model-loader.js +0 -61
  18. package/dist/types/dashboard.d.ts +0 -69
  19. package/dist/types/dashboard.js +0 -3
  20. package/dist/utils/base.d.ts +0 -7
  21. package/dist/utils/base.js +0 -4
  22. package/dist/utils/billable.d.ts +0 -7
  23. package/dist/utils/billable.js +0 -72
  24. package/dist/utils/date.d.ts +0 -2
  25. package/dist/utils/date.js +0 -2
  26. package/dist/utils/debounce.d.ts +0 -5
  27. package/dist/utils/debounce.js +0 -43
  28. package/dist/utils/fetch.d.ts +0 -33
  29. package/dist/utils/fetch.js +0 -94
  30. package/dist/utils/function.d.ts +0 -18
  31. package/dist/utils/function.js +0 -7
  32. package/dist/utils/guards.d.ts +0 -28
  33. package/dist/utils/guards.js +0 -12
  34. package/dist/utils/index.d.ts +0 -17
  35. package/dist/utils/index.js +0 -17
  36. package/dist/utils/lazy.d.ts +0 -6
  37. package/dist/utils/lazy.js +0 -9
  38. package/dist/utils/math.d.ts +0 -20
  39. package/dist/utils/math.js +0 -23
  40. package/dist/utils/plans.d.ts +0 -2
  41. package/dist/utils/plans.js +0 -135
  42. package/dist/utils/promise.d.ts +0 -49
  43. package/dist/utils/promise.js +0 -55
  44. package/dist/utils/random.d.ts +0 -10
  45. package/dist/utils/random.js +0 -67
  46. package/dist/utils/regex.d.ts +0 -38
  47. package/dist/utils/regex.js +0 -29
  48. package/dist/utils/retry.d.ts +0 -10
  49. package/dist/utils/retry.js +0 -28
  50. package/dist/utils/sleep.d.ts +0 -35
  51. package/dist/utils/sleep.js +0 -59
  52. package/dist/utils/throttle.d.ts +0 -20
  53. package/dist/utils/throttle.js +0 -18
  54. package/dist/utils/vendors.d.ts +0 -29
  55. package/dist/utils/vendors.js +0 -37
package/dist/index.js DELETED
@@ -1,16 +0,0 @@
1
- import"./auto-init";
2
-
3
- export * from "./composables";
4
- export * from "./utils";
5
- export * from "./model-loader";
6
- export {
7
- browserQuery,
8
- BrowserQueryBuilder,
9
- BrowserQueryError,
10
- browserAuth,
11
- configureBrowser,
12
- getBrowserConfig,
13
- createBrowserDb,
14
- createBrowserModel,
15
- isBrowser
16
- } from "bun-query-builder/browser";
@@ -1,84 +0,0 @@
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): BrowserModel | null;
9
- /**
10
- * Get all loaded model names
11
- */
12
- export declare function getBrowserModelNames(): string[];
13
- /**
14
- * Minimal shape of a model attribute as far as the browser model
15
- * loader is concerned. The full server-side attribute has
16
- * `factory`, validation rules, casters, etc. — none of which are
17
- * meaningful client-side, so we strip them off in
18
- * {@link extractBrowserAttributes}.
19
- */
20
- export declare interface BrowserAttributeDefinition {
21
- fillable?: boolean
22
- hidden?: boolean
23
- guarded?: boolean
24
- nullable?: boolean
25
- }
26
- /**
27
- * `useApi` trait shape — declares the REST URI the browser model
28
- * should call into. When omitted, the loader skips the model
29
- * (browser code can't reach a model that has no API surface).
30
- */
31
- export declare interface BrowserUseApiTrait {
32
- uri: string
33
- [extra: string]: unknown
34
- }
35
- /**
36
- * Subset of model-traits the browser loader inspects. Server-side
37
- * traits like `useAudit`, `observe`, etc. aren't meaningful client-
38
- * side — only the four below influence browser-side behaviour.
39
- */
40
- export declare interface BrowserModelTraits {
41
- useApi?: BrowserUseApiTrait
42
- useUuid?: boolean
43
- useTimestamps?: boolean
44
- useSoftDeletes?: boolean
45
- [extra: string]: unknown
46
- }
47
- /**
48
- * Shape of a `defineModel(...)`-returned module's default export
49
- * that the browser loader cares about. Mirrors a tight subset of
50
- * `StacksModelDefinition` from `@stacksjs/orm` — typed locally so
51
- * the browser package doesn't pull the full ORM types in.
52
- */
53
- export declare interface BrowserModelDefinition {
54
- name: string
55
- table?: string
56
- primaryKey?: string
57
- traits?: BrowserModelTraits
58
- attributes?: Record<string, BrowserAttributeDefinition & { [extra: string]: unknown }>
59
- [extra: string]: unknown
60
- }
61
- /**
62
- * Shape of a model returned by `createBrowserModel`. Methods are
63
- * declared loosely (the underlying bun-query-builder API surface
64
- * is broader and changes) — we only check `.all` / `.find` exist
65
- * in {@link getBrowserModelNames} for discovery.
66
- */
67
- export declare interface BrowserModel {
68
- all: (...args: unknown[]) => unknown
69
- find: (id: string | number, ...args: unknown[]) => unknown
70
- [extra: string]: unknown
71
- }
72
- /**
73
- * Window augmentation for the framework's `StacksBrowser` global
74
- * (stacksjs/stacks#1894 T-9). Pre-fix every access went through
75
- * `(window as any)` — typos in model names silently returned
76
- * `undefined`. The augmented index signature still permits any
77
- * model name at runtime; what it adds is the existence + shape of
78
- * the StacksBrowser bag itself.
79
- */
80
- declare global {
81
- interface Window {
82
- StacksBrowser?: Record<string, BrowserModel | undefined>
83
- }
84
- }
@@ -1,61 +0,0 @@
1
- import { createBrowserModel } from "bun-query-builder/browser";
2
- const modelModules = typeof import.meta.glob === "function" ? import.meta.glob("~/app/Models/*.ts", { eager: !0 }) : {};
3
- export function loadBrowserModels() {
4
- if (typeof window > "u")
5
- return;
6
- if (!window.StacksBrowser)
7
- window.StacksBrowser = {};
8
- for (const [path, module] of Object.entries(modelModules)) {
9
- const definition = module.default;
10
- if (!definition || !definition.name) {
11
- console.warn(`[model-loader] Skipping ${path}: no valid model definition`);
12
- continue;
13
- }
14
- if (!definition.traits?.useApi?.uri)
15
- continue;
16
- try {
17
- const browserModel = createBrowserModel({
18
- name: definition.name,
19
- table: definition.table ?? definition.name.toLowerCase(),
20
- primaryKey: definition.primaryKey || "id",
21
- traits: {
22
- useUuid: definition.traits?.useUuid ?? !1,
23
- useTimestamps: definition.traits?.useTimestamps ?? !0,
24
- useSoftDeletes: definition.traits?.useSoftDeletes ?? !1,
25
- useApi: definition.traits?.useApi
26
- },
27
- attributes: extractBrowserAttributes(definition.attributes ?? {})
28
- });
29
- window.StacksBrowser[definition.name] = browserModel;
30
- } catch (error) {
31
- console.error(`[model-loader] Failed to create browser model for ${definition.name}:`, error);
32
- }
33
- }
34
- }
35
- function extractBrowserAttributes(attributes) {
36
- const browserAttrs = {};
37
- for (const [name, attr] of Object.entries(attributes))
38
- browserAttrs[name] = {
39
- fillable: attr.fillable ?? !1,
40
- hidden: attr.hidden ?? !1,
41
- guarded: attr.guarded ?? !1,
42
- nullable: attr.nullable ?? !1
43
- };
44
- return browserAttrs;
45
- }
46
- export function getBrowserModel(name) {
47
- if (typeof window > "u")
48
- return null;
49
- return window.StacksBrowser?.[name] ?? null;
50
- }
51
- export function getBrowserModelNames() {
52
- if (typeof window > "u")
53
- return [];
54
- const stacksBrowser = window.StacksBrowser;
55
- if (!stacksBrowser)
56
- return [];
57
- return Object.keys(stacksBrowser).filter((key) => {
58
- const value = stacksBrowser[key];
59
- return value != null && typeof value.all === "function" && typeof value.find === "function";
60
- });
61
- }
@@ -1,69 +0,0 @@
1
- import type { Ref } from '@stacksjs/stx';
2
- export declare function isGeneralError(error: ResponseError): error is { error: string };
3
- export declare interface ValidationError {
4
- [key: string]: {
5
- message: string
6
- }[]
7
- }
8
- export declare interface RegisterError {
9
- errors: ResponseError
10
- }
11
- // LoginAction/RegisterAction/AuthUserAction respond via `response.json(...)`,
12
- // which serializes flat (see @stacksjs/bun-router's ResponseFactory.json) —
13
- // there is no `{ data: ... }` envelope, unlike endpoints built on
14
- // `response.success()` or a JsonResource. These types mirror the actual
15
- // flat wire shape.
16
- export declare interface RegisterResponse {
17
- token: string
18
- user: {
19
- id: number
20
- email: string
21
- name: string
22
- }
23
- }
24
- // LoginAction additionally mints an OAuth2-compatible token pack; `token`
25
- // is kept alongside `access_token` for backward compatibility.
26
- export declare interface LoginResponse {
27
- access_token: string
28
- refresh_token: string
29
- token_type: string
30
- expires_in: number
31
- token: string
32
- user: {
33
- id: number
34
- email: string
35
- name: string
36
- }
37
- }
38
- export declare interface Response<T> {
39
- errors: ResponseError
40
- data: T
41
- }
42
- export declare interface AuthUser {
43
- email: string
44
- password: string
45
- }
46
- export declare interface ErrorResponse {
47
- message: string
48
- }
49
- export declare interface UserData {
50
- id: number
51
- email: string
52
- name: string
53
- }
54
- export declare interface AuthComposable {
55
- isAuthenticated: Ref<boolean>
56
- user: Ref<UserData | null>
57
- login: (user: AuthUser) => Promise<LoginResponse | LoginError>
58
- register: (user: AuthUser) => Promise<RegisterResponse | RegisterError>
59
- fetchAuthUser: () => Promise<UserData | null>
60
- checkAuthentication: () => Promise<boolean>
61
- logout: () => void
62
- getToken: () => string | null
63
- token: Ref<string | null>
64
- }
65
- export type ResponseError = {
66
- error: string
67
- } | ValidationError;
68
- export type LoginError = RegisterError;
69
- export type MeResponse = UserData;
@@ -1,3 +0,0 @@
1
- export function isGeneralError(error) {
2
- return "error" in error;
3
- }
@@ -1,7 +0,0 @@
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,4 +0,0 @@
1
- export { toString } from "@stacksjs/strings";
2
- export async function loop(times, callback) {
3
- Array.from({ length: times }).forEach(async (_, i) => await callback(i));
4
- }
@@ -1,7 +0,0 @@
1
- export declare function loadCardElement(clientSecret: string): Promise<any>;
2
- export declare function loadPaymentElement(clientSecret: string): Promise<any>;
3
- export declare function confirmCardSetup(clientSecret: string, elements: any): Promise<{ setupIntent: any, error: any }>;
4
- export declare function confirmCardPayment(clientSecret: string, elements: any): Promise<{ paymentIntent: any, error: any }>;
5
- export declare function createPaymentMethod(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;
@@ -1,72 +0,0 @@
1
- const stacksConfig = globalThis.__STACKS_CONFIG__ || {};
2
- export const publishableKey = stacksConfig.FRONTEND_STRIPE_PUBLIC_KEY || "";
3
- let client;
4
- async function loadStripe(key) {
5
- let stripeJs;
6
- try {
7
- stripeJs = await import("@stripe/stripe-js");
8
- } catch {
9
- throw Error("Stripe is being used but the `@stripe/stripe-js` package is not installed. " + "It is an opt-in dependency \u2014 run `bun add @stripe/stripe-js` to enable Stripe payments in the browser.");
10
- }
11
- return stripeJs.loadStripe(key);
12
- }
13
- export async function loadCardElement(clientSecret) {
14
- client = await loadStripe(publishableKey);
15
- const cardElement = client.elements({ clientSecret }).create("card");
16
- cardElement.mount("#card-element");
17
- return cardElement;
18
- }
19
- export async function loadPaymentElement(clientSecret) {
20
- client = await loadStripe(publishableKey);
21
- const elements = client.elements({ clientSecret });
22
- elements.create("payment", {
23
- fields: { billingDetails: "auto" }
24
- }).mount("#payment-element");
25
- return elements;
26
- }
27
- export async function confirmCardSetup(clientSecret, elements) {
28
- const data = await client.confirmCardSetup(clientSecret, { payment_method: { card: elements } }), { setupIntent, error } = data;
29
- return { setupIntent, error };
30
- }
31
- export async function confirmCardPayment(clientSecret, elements) {
32
- try {
33
- const data = await client.confirmCardPayment(clientSecret, {
34
- payment_method: {
35
- card: elements,
36
- billing_details: {
37
- name: stacksConfig.USER_NAME || ""
38
- }
39
- }
40
- }), { paymentIntent, error } = data;
41
- return { paymentIntent, error };
42
- } catch (err) {
43
- console.error("Error confirming card payment:", err);
44
- return { paymentIntent: null, error: err };
45
- }
46
- }
47
- export async function createPaymentMethod(elements) {
48
- try {
49
- const data = await client.createPaymentMethod({
50
- type: "card",
51
- card: elements
52
- }), { paymentIntent, error } = data;
53
- return { paymentIntent, error };
54
- } catch (err) {
55
- console.error("Error confirming card payment:", err);
56
- return { paymentIntent: null, error: err };
57
- }
58
- }
59
- export async function confirmPayment(elements) {
60
- try {
61
- const data = await client.confirmPayment({
62
- elements,
63
- confirmParams: {
64
- return_url: `${window.location.origin}/settings/billing`
65
- }
66
- }), { paymentIntent, error } = data;
67
- return { paymentIntent, error };
68
- } catch (err) {
69
- console.error("Error confirming card payment:", err);
70
- return { paymentIntent: null, error: err };
71
- }
72
- }
@@ -1,2 +0,0 @@
1
- export { useDateFormat, useNow } from '@stacksjs/composables';
2
- export { format, parse } from '@stacksjs/datetime';
@@ -1,2 +0,0 @@
1
- export { useDateFormat, useNow } from "@stacksjs/composables";
2
- export { format, parse } from "@stacksjs/datetime";
@@ -1,5 +0,0 @@
1
- export declare function debounce<T extends (..._args: any[]) => any>(fn: T, wait?: number, options?: DebounceOptions): T & { cancel: () => void, flush: () => void };
2
- export declare interface DebounceOptions {
3
- leading?: boolean
4
- trailing?: boolean
5
- }
@@ -1,43 +0,0 @@
1
- export function debounce(fn, wait = 0, options = {}) {
2
- const { leading = !1, trailing = !0 } = options;
3
- let timeout = null, lastArgs = null, lastThis = null, result;
4
- const invokeFunc = () => {
5
- if (lastArgs) {
6
- result = fn.apply(lastThis, lastArgs);
7
- lastArgs = null;
8
- lastThis = null;
9
- }
10
- return result;
11
- }, cancel = () => {
12
- if (timeout) {
13
- clearTimeout(timeout);
14
- timeout = null;
15
- }
16
- lastArgs = null;
17
- lastThis = null;
18
- }, flush = () => {
19
- if (timeout) {
20
- clearTimeout(timeout);
21
- timeout = null;
22
- return invokeFunc();
23
- }
24
- return result;
25
- }, debounced = function(...args) {
26
- lastArgs = args;
27
- lastThis = this;
28
- const shouldCallNow = leading && !timeout;
29
- if (timeout)
30
- clearTimeout(timeout);
31
- timeout = setTimeout(() => {
32
- timeout = null;
33
- if (trailing && lastArgs)
34
- invokeFunc();
35
- }, wait);
36
- if (shouldCallNow)
37
- return invokeFunc();
38
- return result;
39
- };
40
- debounced.cancel = cancel;
41
- debounced.flush = flush;
42
- return debounced;
43
- }
@@ -1,33 +0,0 @@
1
- declare function get(url: string, params?: Params, headers?: Headers): Promise<FetchResponse>;
2
- declare function post(url: string, params?: Params, headers?: Headers): Promise<FetchResponse>;
3
- declare function patch(url: string, params?: Params, headers?: Headers): Promise<FetchResponse>;
4
- declare function put(url: string, params?: Params, headers?: Headers): Promise<FetchResponse>;
5
- declare function destroy(url: string, params?: Params, headers?: Headers): Promise<FetchResponse>;
6
- declare function setToken(authToken: string): void;
7
- declare const baseURL: '/';
8
- export declare const Fetch: ApiFetch;
9
- declare interface Params {
10
- [key: string]: Primitive | Primitive[] | Params | Params[]
11
- }
12
- declare interface ApiFetch {
13
- get: (url: string, params?: Params, header?: Headers) => Promise<FetchResponse>
14
- post: (url: string, params?: Params, header?: Headers) => Promise<FetchResponse>
15
- destroy: (url: string, params?: Params, header?: Headers) => Promise<FetchResponse>
16
- patch: (url: string, params?: Params, header?: Headers) => Promise<FetchResponse>
17
- put: (url: string, params?: Params, header?: Headers) => Promise<FetchResponse>
18
- setToken: (authToken: string) => void
19
- baseURL: '/' | string
20
- loading: boolean
21
- token: string
22
- }
23
- /**
24
- * Loose payload type for `Fetch.{get,post,patch,put,destroy}`.
25
- *
26
- * GET sends this as a query string; POST/PATCH/PUT send it as a JSON body.
27
- * Values are constrained to JSON-serializable primitives + nested
28
- * arrays/objects so we catch unintentional `Function` / `Date` / `Symbol`
29
- * payloads at the call site instead of seeing them silently coerced
30
- * to `[object Object]` over the wire.
31
- */
32
- declare type Primitive = string | number | boolean | null | undefined;
33
- declare type FetchResponse = string | Blob | ArrayBuffer | ReadableStream<Uint8Array> | object;
@@ -1,94 +0,0 @@
1
- let loading = !1, token = "";
2
- const baseURL = "/";
3
- function appendParam(search, key, value) {
4
- if (value === void 0 || value === null)
5
- return;
6
- if (Array.isArray(value)) {
7
- for (const v of value)
8
- appendParam(search, key, v);
9
- return;
10
- }
11
- if (typeof value === "object") {
12
- search.append(key, JSON.stringify(value));
13
- return;
14
- }
15
- search.append(key, String(value));
16
- }
17
- function buildUrl(url, params) {
18
- const full = /^https?:\/\//i.test(url) ? url : `${baseURL.replace(/\/$/, "")}/${url.replace(/^\//, "")}`;
19
- if (!params || Object.keys(params).length === 0)
20
- return full;
21
- const search = new URLSearchParams;
22
- for (const [key, value] of Object.entries(params))
23
- appendParam(search, key, value);
24
- const qs = search.toString();
25
- if (!qs)
26
- return full;
27
- return full.includes("?") ? `${full}&${qs}` : `${full}?${qs}`;
28
- }
29
- function applyAuth(headers) {
30
- const h = headers ?? new Headers;
31
- if (token && !h.has("Authorization"))
32
- h.set("Authorization", `Bearer ${token}`);
33
- return h;
34
- }
35
- async function parseBody(response) {
36
- const contentType = response.headers.get("content-type") ?? "";
37
- if (contentType.includes("application/json"))
38
- return await response.json();
39
- if (contentType.startsWith("text/") || contentType.includes("xml"))
40
- return await response.text();
41
- return await response.blob();
42
- }
43
- async function request(method, url, params, headers) {
44
- const sendsBody = method !== "GET" && method !== "DELETE", finalUrl = sendsBody ? buildUrl(url) : buildUrl(url, params), finalHeaders = applyAuth(headers), init = { method, headers: finalHeaders };
45
- if (sendsBody && params !== void 0) {
46
- if (!finalHeaders.has("Content-Type"))
47
- finalHeaders.set("Content-Type", "application/json");
48
- init.body = JSON.stringify(params);
49
- }
50
- if (sendsBody)
51
- loading = !0;
52
- try {
53
- const response = await fetch(finalUrl, init);
54
- if (!response.ok) {
55
- const errorBody = await parseBody(response).catch(() => null), error = Error(`Request failed with status ${response.status}`);
56
- error.status = response.status;
57
- error.data = errorBody;
58
- throw error;
59
- }
60
- return await parseBody(response);
61
- } finally {
62
- if (sendsBody)
63
- loading = !1;
64
- }
65
- }
66
- async function get(url, params, headers) {
67
- return await request("GET", url, params, headers);
68
- }
69
- async function post(url, params, headers) {
70
- return await request("POST", url, params, headers);
71
- }
72
- async function patch(url, params, headers) {
73
- return await request("PATCH", url, params, headers);
74
- }
75
- async function put(url, params, headers) {
76
- return await request("PUT", url, params, headers);
77
- }
78
- async function destroy(url, params, headers) {
79
- return await request("DELETE", url, params, headers);
80
- }
81
- function setToken(authToken) {
82
- token = authToken;
83
- }
84
- export const Fetch = {
85
- get,
86
- post,
87
- patch,
88
- put,
89
- destroy,
90
- baseURL,
91
- token,
92
- setToken,
93
- loading
94
- };
@@ -1,18 +0,0 @@
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;
@@ -1,7 +0,0 @@
1
- export function batchInvoke(functions) {
2
- functions.forEach((fn) => fn?.());
3
- }
4
- export function tap(value, callback) {
5
- callback(value);
6
- return value;
7
- }
@@ -1,28 +0,0 @@
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>;
@@ -1,12 +0,0 @@
1
- export function notNullish(v) {
2
- return v != null;
3
- }
4
- export function noNull(v) {
5
- return v !== null;
6
- }
7
- export function notUndefined(v) {
8
- return v !== void 0;
9
- }
10
- export function isTruthy(v) {
11
- return Boolean(v);
12
- }
@@ -1,17 +0,0 @@
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,17 +0,0 @@
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,6 +0,0 @@
1
- /**
2
- * Lazily evaluate a value.
3
- * @param getter A function that returns the value to be lazily evaluated.
4
- * @returns An object with a `value` property that contains the lazily evaluated value.
5
- */
6
- export declare function lazy<T>(getter: () => T): { value: T };
@@ -1,9 +0,0 @@
1
- export function lazy(getter) {
2
- return {
3
- get value() {
4
- const value = getter();
5
- Object.defineProperty(this, "value", { value });
6
- return value;
7
- }
8
- };
9
- }
@@ -1,20 +0,0 @@
1
- export declare function rand(min: number, max: number): number;
2
- export declare const clamp: (n: number, min: number, max: number) => number;
3
- // Re-export reactive math utilities from @stacksjs/composables
4
- export {
5
- and,
6
- logicNot,
7
- logicOr,
8
- or,
9
- useAbs,
10
- useAverage,
11
- useCeil,
12
- useClamp,
13
- useFloor,
14
- useMax,
15
- useMin,
16
- usePrecision,
17
- useRound,
18
- useSum,
19
- useTrunc,
20
- } from '@stacksjs/composables';