@tsrx/core 0.1.58 → 0.1.60

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.
@@ -1,30 +1 @@
1
- export const get_descriptor: typeof Object.getOwnPropertyDescriptor;
2
- export const get_descriptors: typeof Object.getOwnPropertyDescriptors;
3
- export const array_from: typeof Array.from;
4
- export const is_array: typeof Array.isArray;
5
- export const define_property: typeof Object.defineProperty;
6
- export const get_prototype_of: typeof Object.getPrototypeOf;
7
- export const object_values: typeof Object.values;
8
- export const object_entries: typeof Object.entries;
9
- export const object_keys: typeof Object.keys;
10
- export const get_own_property_symbols: typeof Object.getOwnPropertySymbols;
11
- export const structured_clone: typeof structuredClone;
12
- export const object_prototype: typeof Object.prototype;
13
- export const array_prototype: typeof Array.prototype;
14
- export const has_own_property: typeof Object.prototype.hasOwnProperty;
15
-
16
- export function has_prototype_accessor(value: object, key: PropertyKey): boolean;
17
- export function array_slice<T>(array_like: ArrayLike<T>, ...args: number[]): T[];
18
- export function iterable_array_from<T>(
19
- iterable: Iterable<T> | Iterator<T> | ArrayLike<T>,
20
- index?: number,
21
- ): T[];
22
- /**
23
- * The props bag minus one prop. Constrained to `object` rather than an index
24
- * signature so an interface- or class-typed props bag is accepted; returns `{}`
25
- * when `props` is nullish.
26
- */
27
- export function exclude_prop_from_object<
28
- T extends object = Record<PropertyKey, unknown>,
29
- K extends PropertyKey = PropertyKey,
30
- >(props: T | null | undefined, exclude_prop: K): Omit<T, K>;
1
+ export * from '@tsrx/runtime/language-helpers';
@@ -1,88 +1 @@
1
- export type MergeableRefCallback<T> = {
2
- bivarianceHack(node: T | null): void | (() => void);
3
- }['bivarianceHack'];
4
- export type MergeableRefObject<T> = { current: T | null };
5
- export type MergeableVueRef<T> = { value: T | null };
6
- export type RefProp<T = unknown> = (node: T | null) => void | (() => void);
7
- export type RefValue<T = Element> =
8
- | ((node: T) => void | (() => void))
9
- | readonly RefValue<T>[]
10
- | { current: T | null }
11
- | { value: T | null }
12
- | T
13
- | null
14
- | undefined;
15
-
16
- export type MergeableRef<T> =
17
- MergeableRefCallback<T> | MergeableRefObject<T> | MergeableVueRef<T> | null | undefined;
18
-
19
- /**
20
- * A props bag as it reaches a spread: keys the caller has not narrowed.
21
- *
22
- * Accepting bag is spelled `object` at the parameter position — an index
23
- * signature would reject an interface- or class-typed props bag — while this
24
- * is what the helpers hand back when they rebuild one.
25
- */
26
- export type SpreadProps = Record<PropertyKey, unknown>;
27
-
28
- /**
29
- * The node a ref value points at, derived from the ref's own type in the order
30
- * the runtime resolves it (see `apply_ref_value` and `is_ref_object`): a list
31
- * resolves through its entries, a callback through its parameter, and a DOM
32
- * node is never treated as a ref object.
33
- *
34
- * Inferring through `RefValue<T>` instead would read the target off the wrong
35
- * union member: TypeScript prefers a structural member over a naked type
36
- * parameter, so `HTMLInputElement` would match the `{ value: T | null }`
37
- * (Vue ref) branch and resolve `T` to `string`.
38
- */
39
- export type RefTarget<V> = [V] extends [never]
40
- ? never
41
- : V extends null | undefined
42
- ? never
43
- : V extends (node: infer N) => unknown
44
- ? N
45
- : V extends readonly (infer E)[]
46
- ? RefTarget<E>
47
- : V extends Node
48
- ? V
49
- : V extends { current: infer C }
50
- ? NonNullable<C>
51
- : V extends { value: infer C }
52
- ? NonNullable<C>
53
- : V;
54
-
55
- export function mergeRefs<T = Element>(
56
- ...refs: Array<MergeableRef<T>>
57
- ): (node: T | null) => () => void;
58
- export function isRefProp(value: unknown): boolean;
59
- // The inference overload comes first so an inferred call resolves the target
60
- // through `RefTarget`; the `T` overload below still serves explicit type
61
- // arguments, which is what every compiler-generated call passes.
62
- export function create_ref_prop<V>(
63
- get_ref_value: () => V,
64
- set_ref_value?: (value: RefTarget<V> | null) => void,
65
- ): RefProp<RefTarget<V>>;
66
- export function create_ref_prop<T = Element>(
67
- get_ref_value: () => RefValue<T>,
68
- set_ref_value?: (value: T | null) => void,
69
- ): RefProp<T>;
70
- export function apply_ref_value<V>(
71
- ref_value: V,
72
- node: RefTarget<V> | null,
73
- set_ref_value?: (value: RefTarget<V> | null) => void,
74
- ): void | (() => void);
75
- export function apply_ref_value<T = Element>(
76
- ref_value: RefValue<T>,
77
- node: T | null,
78
- set_ref_value?: (value: T | null) => void,
79
- ): void | (() => void);
80
- export function merge_ref_props<T = Element>(...refs: Array<RefValue<T>>): RefValue<T>;
81
- export function normalize_spread_props<T extends object | null | undefined>(
82
- props: T,
83
- ...outer_refs: Array<RefValue<Element>>
84
- ): T | SpreadProps;
85
- export function normalize_spread_props_for_ref_attr<T extends object | null | undefined>(
86
- props: T,
87
- ...outer_refs: Array<RefValue<Element>>
88
- ): T | SpreadProps;
1
+ export * from '@tsrx/runtime/ref';