@tsrx/core 0.1.49 → 0.1.51

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.
@@ -16,24 +16,73 @@ export type RefValue<T = Element> =
16
16
  export type MergeableRef<T> =
17
17
  MergeableRefCallback<T> | MergeableRefObject<T> | MergeableVueRef<T> | null | undefined;
18
18
 
19
- export function mergeRefs<T = any>(...refs: Array<MergeableRef<T>>): (node: T | null) => () => void;
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;
20
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>>;
21
66
  export function create_ref_prop<T = Element>(
22
67
  get_ref_value: () => RefValue<T>,
23
- set_ref_value?: (value: any) => void,
68
+ set_ref_value?: (value: T | null) => void,
24
69
  ): RefProp<T>;
25
- export function apply_ref_value<T>(
26
- ref_value: unknown,
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>,
27
77
  node: T | null,
28
- set_ref_value?: (value: T) => void,
78
+ set_ref_value?: (value: T | null) => void,
29
79
  ): void | (() => void);
30
- export function merge_ref_props<T = any>(
31
- ...refs: unknown[]
32
- ): undefined | ((node: T | null) => void | (() => void));
33
- export function normalize_spread_props<T extends Record<PropertyKey, any> | null | undefined>(
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>(
34
86
  props: T,
35
- ...outer_refs: unknown[]
36
- ): T | Record<PropertyKey, any>;
37
- export function normalize_spread_props_for_ref_attr<
38
- T extends Record<PropertyKey, any> | null | undefined,
39
- >(props: T, ...outer_refs: unknown[]): T | Record<PropertyKey, any>;
87
+ ...outer_refs: Array<RefValue<Element>>
88
+ ): T | SpreadProps;
@@ -0,0 +1,26 @@
1
+ export interface DepScanCompiled {
2
+ code: string;
3
+ }
4
+
5
+ export type DepScanCompile = (
6
+ code: string,
7
+ id: string,
8
+ ) => DepScanCompiled | Promise<DepScanCompiled>;
9
+
10
+ export interface DepScanModule {
11
+ code: string;
12
+ moduleType: string;
13
+ }
14
+
15
+ export interface DepScanTransformPlugin {
16
+ name: string;
17
+ transform: {
18
+ filter: { id: RegExp };
19
+ handler: (code: string, id: string) => Promise<DepScanModule>;
20
+ };
21
+ }
22
+
23
+ export interface DepScanLoadPlugin {
24
+ name: string;
25
+ load: (id: string) => Promise<DepScanModule | null>;
26
+ }