@tsrx/vue 0.1.22 → 0.1.25
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 +6 -2
- package/src/dynamic.js +16 -0
- package/src/index.js +1 -0
- package/src/transform.js +2 -1
- package/types/dynamic.d.ts +32 -0
- package/types/index.d.ts +1 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Vue compiler built on @tsrx/core",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.25",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"types": "./types/error-boundary.d.ts",
|
|
23
23
|
"default": "./src/error-boundary.js"
|
|
24
24
|
},
|
|
25
|
+
"./dynamic": {
|
|
26
|
+
"types": "./types/dynamic.d.ts",
|
|
27
|
+
"default": "./src/dynamic.js"
|
|
28
|
+
},
|
|
25
29
|
"./interop": {
|
|
26
30
|
"types": "./types/interop.d.ts",
|
|
27
31
|
"default": "./src/interop.js"
|
|
@@ -35,7 +39,7 @@
|
|
|
35
39
|
"esrap": "^2.2.8",
|
|
36
40
|
"is-reference": "^3.0.3",
|
|
37
41
|
"zimmerframe": "^1.1.2",
|
|
38
|
-
"@tsrx/core": "0.1.
|
|
42
|
+
"@tsrx/core": "0.1.25"
|
|
39
43
|
},
|
|
40
44
|
"peerDependencies": {
|
|
41
45
|
"vue": ">=3.5",
|
package/src/dynamic.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { exclude_prop_from_object } from '@tsrx/core/runtime/language-helpers';
|
|
2
|
+
import { createNodes, h } from 'vue-jsx-vapor';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {{ is?: any, [key: string]: any }} props
|
|
6
|
+
* @param {{ slots?: any }} [context]
|
|
7
|
+
* @returns {any}
|
|
8
|
+
*/
|
|
9
|
+
export function Dynamic(props, context) {
|
|
10
|
+
return createNodes(() => {
|
|
11
|
+
const component = props?.is;
|
|
12
|
+
return component
|
|
13
|
+
? h(component, exclude_prop_from_object(props, 'is'), context?.slots ?? props?.children)
|
|
14
|
+
: null;
|
|
15
|
+
});
|
|
16
|
+
}
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { createVolarMappingsResult, dedupeMappings, parseModule } from '@tsrx/co
|
|
|
5
5
|
import { transform } from './transform.js';
|
|
6
6
|
|
|
7
7
|
export { isRefProp } from './ref.js';
|
|
8
|
+
export { Dynamic } from './dynamic.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Parse tsrx-vue source code to an ESTree AST.
|
package/src/transform.js
CHANGED
|
@@ -33,6 +33,7 @@ const vue_platform = {
|
|
|
33
33
|
name: 'Vue',
|
|
34
34
|
imports: {
|
|
35
35
|
suspense: 'vue',
|
|
36
|
+
dynamic: '@tsrx/vue/dynamic',
|
|
36
37
|
errorBoundary: '@tsrx/vue/error-boundary',
|
|
37
38
|
mergeRefs: '@tsrx/vue/ref',
|
|
38
39
|
refProp: '@tsrx/vue/ref',
|
|
@@ -48,7 +49,7 @@ const vue_platform = {
|
|
|
48
49
|
},
|
|
49
50
|
hooks: {
|
|
50
51
|
// Hoist to module scope
|
|
51
|
-
// in the regular client transform —
|
|
52
|
+
// in the regular client transform — one
|
|
52
53
|
// definition per helper keeps bundles small and source mappings 1:1
|
|
53
54
|
// for editor IntelliSense. The `compile_to_volar_mappings` entry point
|
|
54
55
|
// opts back out so Volar's type-only output keeps helpers inline,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { NativeElements } from 'vue-jsx-vapor';
|
|
2
|
+
|
|
3
|
+
type DynamicIntrinsicElements = NativeElements;
|
|
4
|
+
|
|
5
|
+
export type DynamicElementType =
|
|
6
|
+
| keyof DynamicIntrinsicElements
|
|
7
|
+
| ((props: any, ...args: any[]) => any)
|
|
8
|
+
| (new (...args: any[]) => { $props: any })
|
|
9
|
+
| (string & {});
|
|
10
|
+
|
|
11
|
+
type DynamicTarget<T> = Exclude<T, null | undefined | false>;
|
|
12
|
+
type DynamicComponentProps<T> = [T] extends [never]
|
|
13
|
+
? Record<string, unknown>
|
|
14
|
+
: T extends new (...args: any[]) => { $props: infer P }
|
|
15
|
+
? Omit<P, 'is'>
|
|
16
|
+
: T extends (props: infer P, ...args: any[]) => any
|
|
17
|
+
? Omit<P, 'is'>
|
|
18
|
+
: T extends keyof DynamicIntrinsicElements
|
|
19
|
+
? DynamicIntrinsicElements[T]
|
|
20
|
+
: Record<string, unknown>;
|
|
21
|
+
|
|
22
|
+
export type DynamicProps<T extends DynamicElementType> = DynamicComponentProps<
|
|
23
|
+
DynamicTarget<NoInfer<T>>
|
|
24
|
+
> & {
|
|
25
|
+
is: T | null | undefined | false;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function Dynamic<T extends DynamicElementType>(
|
|
29
|
+
props: DynamicComponentProps<DynamicTarget<NoInfer<T>>> & {
|
|
30
|
+
is: T | null | undefined | false;
|
|
31
|
+
},
|
|
32
|
+
): any;
|
package/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { CompileFn, ParseOptions, VolarCompileFn } from '@tsrx/core/types';
|
|
|
4
4
|
export function parse(source: string, filename?: string, options?: ParseOptions): Program;
|
|
5
5
|
|
|
6
6
|
export { isRefProp } from './ref.js';
|
|
7
|
+
export { Dynamic, type DynamicElementType, type DynamicProps } from './dynamic.js';
|
|
7
8
|
|
|
8
9
|
export const compile: CompileFn;
|
|
9
10
|
|