@tsrx/react 0.2.58 → 0.2.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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "React compiler built on @tsrx/core",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.2.58",
6
+ "version": "0.2.60",
7
7
  "type": "module",
8
8
  "publishConfig": {
9
9
  "access": "public"
@@ -37,7 +37,8 @@
37
37
  "dependencies": {
38
38
  "esrap": "^2.3.2",
39
39
  "zimmerframe": "^1.1.2",
40
- "@tsrx/core": "0.1.58"
40
+ "@tsrx/core": "0.1.60",
41
+ "@tsrx/react-runtime": "0.1.1"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "react": ">=18"
@@ -1,40 +1 @@
1
- /** @import { ReactNode } from 'react' */
2
- /** @import { TsrxErrorBoundaryProps, TsrxErrorBoundaryState } from '../types/error-boundary' */
3
-
4
- import { Component } from 'react';
5
-
6
- /**
7
- * A reusable React error boundary class component.
8
- *
9
- * Used by the `@tsrx/react` compiler to implement `try/catch` blocks.
10
- * The `fallback` prop receives the caught error and a `reset` function
11
- * that clears the error state to re-render the children.
12
- *
13
- * @extends {Component<TsrxErrorBoundaryProps, TsrxErrorBoundaryState>}
14
- */
15
- export class TsrxErrorBoundary extends Component {
16
- /** @param {TsrxErrorBoundaryProps} props */
17
- constructor(props) {
18
- super(props);
19
- /** @type {TsrxErrorBoundaryState} */
20
- this.state = { error: null };
21
- }
22
-
23
- /**
24
- * @param {Error} error
25
- * @returns {TsrxErrorBoundaryState}
26
- */
27
- static getDerivedStateFromError(error) {
28
- return { error };
29
- }
30
-
31
- /** @returns {ReactNode} */
32
- render() {
33
- const { error } = this.state;
34
- if (error !== null) {
35
- const reset = () => this.setState({ error: null });
36
- return this.props.fallback(error, reset);
37
- }
38
- return this.props.children;
39
- }
40
- }
1
+ export * from '@tsrx/react-runtime/error-boundary';
package/src/index.js CHANGED
@@ -47,7 +47,7 @@ export function compile(source, filename, options) {
47
47
  ast,
48
48
  source,
49
49
  filename,
50
- collect ? { collect: true, loose: !!options?.loose, errors, comments } : undefined,
50
+ collect ? { ...options, collect: true, loose: !!options?.loose, errors, comments } : options,
51
51
  );
52
52
  return { ...result, errors };
53
53
  }
@@ -58,7 +58,7 @@ export function compile(source, filename, options) {
58
58
  * @template {string} T
59
59
  * @param {string} source
60
60
  * @param {NonEmptyString<T>} filename
61
- * @param {ParseOptions} [options]
61
+ * @param {ParseOptions & BaseCompileOptions} [options]
62
62
  * @returns {VolarMappingsResult}
63
63
  */
64
64
  export function compile_to_volar_mappings(source, filename, options) {
@@ -81,6 +81,7 @@ export function compile_to_volar_mappings(source, filename, options) {
81
81
  comments,
82
82
  });
83
83
  const transformed = transform(ast, source, filename, {
84
+ ...options,
84
85
  collect: true,
85
86
  loose: !!options?.loose,
86
87
  typeOnly: true,
package/src/ref.js CHANGED
@@ -1 +1 @@
1
- export * from '@tsrx/core/runtime/ref';
1
+ export * from '@tsrx/react-runtime/ref';
@@ -1 +1 @@
1
- export * from '@tsrx/core/runtime/iterable';
1
+ export * from '@tsrx/react-runtime/iterable';
package/src/transform.js CHANGED
@@ -25,6 +25,12 @@ const react_platform = {
25
25
  refProp: '@tsrx/react/ref',
26
26
  forOfIterableHelper: '@tsrx/react/runtime/iterable',
27
27
  },
28
+ directRuntimeImports: {
29
+ errorBoundary: '@tsrx/react-runtime/error-boundary',
30
+ mergeRefs: '@tsrx/react-runtime/ref',
31
+ refProp: '@tsrx/react-runtime/ref',
32
+ forOfIterableHelper: '@tsrx/react-runtime/iterable',
33
+ },
28
34
  jsx: {
29
35
  rewriteClassAttr: false,
30
36
  classAttrName: 'className',
@@ -1,15 +1 @@
1
- import { Component, type ReactNode } from 'react';
2
-
3
- export interface TsrxErrorBoundaryProps {
4
- fallback: (error: Error, reset: () => void) => ReactNode;
5
- children?: ReactNode;
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): TsrxErrorBoundaryState;
14
- render(): ReactNode;
15
- }
1
+ export * from '@tsrx/react-runtime/error-boundary';
package/types/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { Program } from 'estree';
2
- import type { CompileFn, ParseOptions, VolarCompileFn } from '@tsrx/core/types';
2
+ import type { BaseCompileOptions, CompileFn, ParseOptions, VolarCompileFn } from '@tsrx/core/types';
3
+
4
+ export type { RuntimeImportMode } from '@tsrx/core/types';
3
5
 
4
6
  export function parse(source: string, filename?: string, options?: ParseOptions): Program;
5
7
 
@@ -8,4 +10,4 @@ export { isRefProp } from './ref.js';
8
10
 
9
11
  export const compile: CompileFn;
10
12
 
11
- export const compile_to_volar_mappings: VolarCompileFn;
13
+ export const compile_to_volar_mappings: VolarCompileFn<ParseOptions & BaseCompileOptions>;
package/types/ref.d.ts CHANGED
@@ -1 +1 @@
1
- export * from '@tsrx/core/runtime/ref';
1
+ export * from '@tsrx/react-runtime/ref';
@@ -1 +1 @@
1
- export * from '@tsrx/core/runtime/iterable';
1
+ export * from '@tsrx/react-runtime/iterable';