@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.
- package/package.json +10 -1
- package/src/analyze/prune.js +62 -77
- package/src/analyze/validation.js +7 -7
- package/src/parse/index.js +59 -80
- package/src/plugin.js +219 -107
- package/src/runtime/language-helpers.js +34 -25
- package/src/runtime/ref.js +57 -36
- package/src/scope.js +4 -5
- package/src/source-map-utils.js +8 -22
- package/src/transform/imports.js +8 -14
- package/src/transform/jsx/ast-builders.js +4 -1
- package/src/transform/jsx/index.js +1 -13
- package/src/transform/jsx/server-module.js +102 -96
- package/src/transform/jsx-hoist.js +4 -4
- package/src/transform/lazy.js +196 -137
- package/src/transform/scoping.js +108 -100
- package/src/transform/segments.js +24 -49
- package/src/transform/style-ref.js +92 -106
- package/src/transform/stylesheet.js +5 -21
- package/src/utils/ast.js +25 -20
- package/src/utils/builders.js +66 -2
- package/src/vite/dep-scan.js +135 -0
- package/types/index.d.ts +317 -17
- package/types/parse.d.ts +98 -13
- package/types/runtime/language-helpers.d.ts +10 -5
- package/types/runtime/ref.d.ts +63 -14
- package/types/vite/dep-scan.d.ts +26 -0
package/types/runtime/ref.d.ts
CHANGED
|
@@ -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
|
-
|
|
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:
|
|
68
|
+
set_ref_value?: (value: T | null) => void,
|
|
24
69
|
): RefProp<T>;
|
|
25
|
-
export function apply_ref_value<
|
|
26
|
-
ref_value:
|
|
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 =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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:
|
|
36
|
-
): T |
|
|
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
|
+
}
|