/* @ts-self-types="./index.d.ts" */ import { AccessReturnTypes, AccessorArray, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Narrow, NoInfer, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterParam, Simplify, Size, Tail, Truthy, UnboxLazy, UnionToIntersection, Values } from "./types.js"; import { Accessor, ComputeFunction, NoInfer as NoInfer$1, Setter, Signal, SignalOptions, Store, StoreSetter, createSignal, onCleanup } from "solid-js"; declare const isServer: boolean; /** `true` in the browser, `false` on the server. */ export declare const isClient: boolean; /** `true` in the browser with Solid's DEV mode active. */ export declare const isDev: boolean; /** `true` when DEV mode is off (i.e. production browser builds and all SSR). */ export declare const isProd: boolean; /** No-operation function — accepts any arguments and returns `undefined`. */ export declare const noop: Noop; /** A function that always returns `true`. Useful as a default predicate prop. */ export declare const trueFn: () => boolean; /** A function that always returns `false`. Useful as a default predicate prop. */ export declare const falseFn: () => boolean; /** @deprecated use {@link equalFn} from "solid-js" */ export declare const defaultEquals: typeof Object.is; /** * Signal options that disable equality checking, causing the signal to always * notify subscribers even when the value hasn't changed. Useful for signals * holding mutable objects where structural equality cannot be assumed. */ export declare const EQUALS_FALSE_OPTIONS: { readonly equals: false; }; /** * Signal options that allow writes from inside an owned reactive scope * (component body, memo, or effect) without throwing `SIGNAL_WRITE_IN_OWNED_SCOPE` * in Solid 2.0 dev mode. * * Use only for implementation-detail signals that genuinely need to be written * from within a scope — not as a general escape hatch. */ export declare const INTERNAL_OPTIONS: { readonly ownedWrite: true; }; /** * Returns `true` if `v` is an instance of `c`. Checks both `instanceof` and * `constructor` so that values created across different realms (e.g. iframes) match. */ export declare const ofClass: (v: any, c: AnyClass) => boolean; /** Check if value is typeof "object" or "function" */ export declare function isObject(value: any): value is AnyObject; /** Type guard: returns `true` when `i` is neither `null` nor `undefined`. */ export declare const isNonNullable: (i: T) => i is NonNullable; /** Returns a new array with all `null` and `undefined` items removed. */ export declare const filterNonNullable: (arr: T) => NonNullable[]; /** Three-way comparison: returns `-1` if `a < b`, `1` if `a > b`, `0` if equal. */ export declare const compare: (a: any, b: any) => number; /** * Check shallow array equality */ export declare const arrayEquals: (a: readonly unknown[], b: readonly unknown[]) => boolean; /** * Returns a function that will call all functions in the order they were chained with the same arguments. */ export declare function chain(callbacks: { [Symbol.iterator](): IterableIterator<((...args: Args) => any) | undefined>; }): (...args: Args) => void; /** * Returns a function that will call all functions in the reversed order with the same arguments. */ export declare function reverseChain(callbacks: (((...args: Args) => any) | undefined)[]): (...args: Args) => void; /** Clamps `n` to the inclusive range `[min, max]`. */ export declare const clamp: (n: number, min: number, max: number) => number; /** Creates an ID generator with its own isolated counter and per-generator random segment. Each call to the returned function produces a `timestamp-sequence-random` string that is unique within the generator and with high probability unique across independent generators (e.g. separate processes or SSR requests). */ export declare const createIdGenerator: () => (() => string); /** * Accesses the value of a MaybeAccessor * @example * ```ts * access("foo") // => "foo" * access(() => "foo") // => "foo" * ``` */ export declare const access: >(v: T) => MaybeAccessorValue; /** * Wraps `value` in a single-element array. If `value` is already an array it is * returned as-is. Only `null` and `undefined` produce an empty array; other falsy * values such as `0`, `""` and `false` are wrapped. */ export declare const asArray: (value: T) => (T extends any[] ? T[number] : NonNullable)[]; /** * Access an array of MaybeAccessors * @example * const list = [1, 2, () => 3)] // T: MaybeAccessor[] * const newList = accessArray(list) // T: number[] */ export declare const accessArray: >(list: readonly A[]) => MaybeAccessorValue[]; /** * Run the function if the accessed value is not `undefined` nor `null` * @param value * @param fn */ export declare const withAccess: , V = MaybeAccessorValue>(value: A, fn: (value: NonNullable) => void) => void; /** * Wraps a plain value in a zero-argument accessor `() => value`. * If `v` is already a function it is returned unchanged. */ export declare const asAccessor: >(v: A) => Accessor>; /** If value is a function – call it with a given arguments – otherwise get the value as is */ export declare function accessWith(valueOrFn: T, ...args: T extends AnyFunction ? Parameters : never): T extends AnyFunction ? ReturnType : T; /** * A deferred effect compute function. Skips the first reactive run and returns * `initialValue` instead, then calls `fn` on subsequent dependency changes. * Useful as the compute phase of `createEffect(defer(...), apply)` when the * initial run should be suppressed. * * @param deps - a single accessor or an array of accessors to track * @param fn - called with the current input, previous input, and previous return value * @param initialValue - returned on the skipped first run (defaults to `undefined`) */ export declare function defer(deps: AccessorArray | Accessor, fn: (input: S, prevInput: S, prev: undefined | NoInfer$1) => Next, initialValue: Next): ComputeFunction, NoInfer$1>; export declare function defer(deps: AccessorArray | Accessor, fn: (input: S, prevInput: S, prev: undefined | NoInfer$1) => Next, initialValue?: undefined): ComputeFunction>; /** * Get entries of an object */ export declare const entries: (obj: T) => [keyof T, T[keyof T]][]; /** * Get keys of an object */ export declare const keys: (object: T) => (keyof T)[]; /** * Solid's `onCleanup` that doesn't warn in development if used outside of a component. */ export declare const tryOnCleanup: typeof onCleanup; /** * Creates a stack of callbacks that can be pushed to, executed all at once, or cleared. * All callbacks receive the same arguments when `execute` is called; the stack is * automatically cleared after execution. * * @example * ```ts * const stack = createCallbackStack(); * stack.push(s => console.log("a:", s)); * stack.push(s => console.log("b:", s)); * stack.execute("hello"); // logs "a: hello", "b: hello" — stack is now empty * ``` */ export declare const createCallbackStack: () => { push: (...callbacks: ((arg0: A0, arg1: A1, arg2: A2, arg3: A3) => void)[]) => void; execute: (arg0: A0, arg1: A1, arg2: A2, arg3: A3) => void; clear: VoidFunction; }; /** * Returns a debounced wrapper around `fn` that batches rapid synchronous calls * into a single invocation. Only the most-recently-passed arguments are forwarded. * The counter resets on cleanup so stale microtasks are silently discarded. * * @example * ```ts * const flush = createMicrotask((value: string) => console.log(value)); * flush("a"); * flush("b"); * flush("c"); // only "c" is logged (in the next microtask) * ``` */ export declare function createMicrotask(fn: (...a: A) => void): (...a: A) => void; /** * `createSignal` on the client; a plain mutable box on the server. * * Solid 2 treats a setter that runs during a server render as an error in waiting * (`SERVER_WRITE`: the write lands as inert data today and throws in a later release) — server * render is pure, state enters through async sources. Primitives that hold *interactive* * state (a cursor, a toggle, a controlled value) have no async source, so on the server they * keep a plain value instead: reads and updater-form writes behave the same within a request, * and nothing touches the reactive graph. * * The signal is still *created* on the server — hydration ids are handed out per created * primitive, so a server branch that skipped it would misalign keys with the client * ("Hydration key miss"). It is simply never read or written there. * * @param value initial value * @param options signal options (the signal only matters on the client) * @returns a `[get, set]` tuple with `createSignal`'s shape * @see {@link createSignal} */ export declare function createServerSafeSignal(value: T, options?: SignalOptions): ReturnType>; /** * A hydratable version of the {@link createSignal}. It will use the serverValue on the server and the update function on the client. If initialized during hydration it will use serverValue as the initial value and update it once hydration is complete. * * @param serverValue initial value of the state on the server * @param update called once on the client or on hydration to initialize the value * @param options {@link SignalOptions} * @returns * ```ts * [state: Accessor, setState: Setter] * ``` * @see {@link createSignal} */ export declare function createHydratableSignal(serverValue: T, update: () => T, options?: SignalOptions): ReturnType>; /** @deprecated use {@link createHydratableSignal} instead */ export declare const createHydrateSignal: typeof createHydratableSignal; /** * Diffs two arrays by reference and calls `handleAdded` / `handleRemoved` for * each item that appeared or disappeared. Items are compared with `===`. * * @param current - the new array * @param prev - the previous array snapshot * @param handleAdded - called once for each item present in `current` but not `prev` * @param handleRemoved - called once for each item present in `prev` but not `current` */ export declare function handleDiffArray(current: readonly T[], prev: readonly T[], handleAdded: (item: T) => void, handleRemoved: (item: T) => void): void; /** * Schedules `fn` to run after the browser has painted by nesting two * requestAnimationFrame calls. No-op in non-browser environments. */ export declare const afterPaint: (fn: () => void) => void; /** * Parse a string as a single JSON value. * * ```ts * const { data } = createSSE<{ status: string }>(url, { transform: json }); * ``` */ export declare const json: (raw: string) => T; /** * Parse a string as newline-delimited JSON (NDJSON / JSON Lines). * * Each non-empty line is parsed as a separate JSON value and returned as an array. * * ```ts * const { data } = createSSE(url, { transform: ndjson }); * // data() === [{ id: 1, type: "tick" }, { id: 2, type: "tick" }] * ``` */ export declare const ndjson: (raw: string) => T[]; /** * Split a string into individual lines, returning a `string[]`. Empty lines are filtered out. * * ```ts * const { data } = createSSE(url, { transform: lines }); * // data() === ["line one", "line two"] * ``` */ export declare const lines: (raw: string) => string[]; /** * Parse a string as a number using `Number()` semantics. * * Note: `""` → `0`, non-numeric strings → `NaN`. * * ```ts * const { data } = createSSE(url, { transform: number }); * // data() === 42 * ``` */ export declare const number: (raw: string) => number; /** * Wrap any `(string) => T` transform in a `try/catch`. Returns `fallback` * (default `undefined`) instead of throwing on malformed input. * * ```ts * const { data } = createSSE(url, { transform: safe(json) }); * const { data } = createSSE(url, { transform: safe(number, 0) }); * ``` */ export declare function safe(transform: (raw: string) => T): (raw: string) => T | undefined; export declare function safe(transform: (raw: string) => T, fallback: T): (raw: string) => T; /** * Compose two transforms into one: the output of `a` is passed as the input of `b`. * * ```ts * const { data } = createSSE(url, { * transform: pipe(ndjson, rows => rows.filter(r => r.type === "tick")), * }); * ``` */ export declare function pipe(a: (raw: string) => A, b: (a: A) => B): (raw: string) => B; /** * Check if a wrapper element contains a target element. * Portal-aware: follows SolidJS `_$host` links so elements rendered inside * a `` are correctly treated as children of the portal's anchor. */ export declare const contains: (wrapper: HTMLElement, target: HTMLElement) => boolean; /** * Returns a singleton value keyed by `key`, shared across every copy of the calling module that * ends up loaded in the same JS realm (a `Symbol.for(key)` slot on `globalThis`, not a module-scope * binding). Use this instead of a plain module-scope `let`/`const` for state that must stay * consistent (ref-counts, active-instance stacks) even if the app's dependency graph ends up with * more than one installed copy of the package — module-scope state would otherwise be split across * copies and go out of sync (e.g. a "topmost instance" check disagreeing between copies). * * ```ts * const registry = globalRegistry("@solid-primitives/my-package:my-state", () => ({ * stack: createSignal([], { ownedWrite: true }), * nextId: 0, * })); * ``` */ export declare function globalRegistry(key: string, init: () => T): T; /** * Wraps a setter function of any signal or store * * ```ts * const [data, setData] = wrapSetter( * createSignal(initialData), * (setter) => (next) => { console.log(next); return setter(next); }, * ); * ``` * If you destructure signal or store in a longer tuple, you need to use a const assertion for the types to work. */ export declare function wrapSetter(signal: Signal, wrapper: (setter: Setter) => Setter): Signal; export declare function wrapSetter(store: [Store, StoreSetter], wrapper: (setter: StoreSetter) => StoreSetter): [Store, StoreSetter]; export declare function wrapSetter | [Store, StoreSetter] | [...Signal, ...any[]] | [Store, StoreSetter, ...any[]]>(signalOrStore: S, wrapper: (setter: S[1]) => S[1]): S; export declare function wrapSetter | [Store, StoreSetter] | readonly [...Signal, ...any[]] | readonly [Store, StoreSetter, ...any[]]>(signalOrStore: S, wrapper: (setter: S[1]) => S[1]): S; export { AccessReturnTypes, AccessorArray, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Narrow, NoInfer, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterParam, Simplify, Size, Tail, Truthy, UnboxLazy, UnionToIntersection, Values, isServer };