@tsrx/preact 0.0.13 → 0.0.14
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 +4 -2
- package/src/index.js +20 -4
- package/types/error-boundary.d.ts +15 -0
- package/types/merge-refs.d.ts +1 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Preact compiler built on @tsrx/core",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.14",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
@@ -19,16 +19,18 @@
|
|
|
19
19
|
"default": "./src/index.js"
|
|
20
20
|
},
|
|
21
21
|
"./error-boundary": {
|
|
22
|
+
"types": "./types/error-boundary.d.ts",
|
|
22
23
|
"default": "./src/error-boundary.js"
|
|
23
24
|
},
|
|
24
25
|
"./merge-refs": {
|
|
26
|
+
"types": "./types/merge-refs.d.ts",
|
|
25
27
|
"default": "./src/merge-refs.js"
|
|
26
28
|
}
|
|
27
29
|
},
|
|
28
30
|
"dependencies": {
|
|
29
31
|
"esrap": "^2.1.0",
|
|
30
32
|
"zimmerframe": "^1.1.2",
|
|
31
|
-
"@tsrx/core": "0.0.
|
|
33
|
+
"@tsrx/core": "0.0.19"
|
|
32
34
|
},
|
|
33
35
|
"peerDependencies": {
|
|
34
36
|
"preact": ">=10"
|
package/src/index.js
CHANGED
|
@@ -29,9 +29,19 @@ export function parse(source, filename, options) {
|
|
|
29
29
|
*/
|
|
30
30
|
export function compile(source, filename, compile_options) {
|
|
31
31
|
const errors = /** @type {CompileError[]} */ ([]);
|
|
32
|
+
const comments = /** @type {AST.CommentWithLocation[]} */ ([]);
|
|
32
33
|
const collect = !!compile_options?.loose;
|
|
33
|
-
const ast = parseModule(
|
|
34
|
-
|
|
34
|
+
const ast = parseModule(
|
|
35
|
+
source,
|
|
36
|
+
filename,
|
|
37
|
+
collect ? { loose: true, errors, comments } : undefined,
|
|
38
|
+
);
|
|
39
|
+
const { ast: _ast, ...result } = transform(
|
|
40
|
+
ast,
|
|
41
|
+
source,
|
|
42
|
+
filename,
|
|
43
|
+
collect ? { ...compile_options, loose: true, errors, comments } : compile_options,
|
|
44
|
+
);
|
|
35
45
|
return { ...result, errors };
|
|
36
46
|
}
|
|
37
47
|
|
|
@@ -45,8 +55,14 @@ export function compile(source, filename, compile_options) {
|
|
|
45
55
|
*/
|
|
46
56
|
export function compile_to_volar_mappings(source, filename, options) {
|
|
47
57
|
const errors = /** @type {import('@tsrx/core/types').CompileError[]} */ ([]);
|
|
48
|
-
const
|
|
49
|
-
const
|
|
58
|
+
const comments = /** @type {AST.CommentWithLocation[]} */ ([]);
|
|
59
|
+
const ast = parseModule(source, filename, { ...options, errors, comments });
|
|
60
|
+
const transformed = transform(ast, source, filename, {
|
|
61
|
+
...options,
|
|
62
|
+
loose: true,
|
|
63
|
+
errors,
|
|
64
|
+
comments,
|
|
65
|
+
});
|
|
50
66
|
const result = createVolarMappingsResult({
|
|
51
67
|
ast: transformed.ast,
|
|
52
68
|
ast_from_source: ast,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Component, type ComponentChildren, type VNode } from 'preact';
|
|
2
|
+
|
|
3
|
+
export interface TsrxErrorBoundaryProps {
|
|
4
|
+
fallback: (error: Error, reset: () => void) => ComponentChildren;
|
|
5
|
+
children?: ComponentChildren;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface TsrxErrorBoundaryState {
|
|
9
|
+
error: Error | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class TsrxErrorBoundary extends Component<TsrxErrorBoundaryProps, TsrxErrorBoundaryState> {
|
|
13
|
+
static getDerivedStateFromError(error: Error): { error: Error };
|
|
14
|
+
render(): ComponentChildren | VNode;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { mergeRefs } from '@tsrx/core/runtime/merge-refs';
|