@tsrx/preact 0.1.58 → 0.1.59

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": "Preact compiler built on @tsrx/core",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.1.58",
6
+ "version": "0.1.59",
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.59",
41
+ "@tsrx/preact-runtime": "0.1.1"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "preact": ">=10"
@@ -1,40 +1 @@
1
- /** @import { ComponentChildren } from 'preact' */
2
- /** @import { TsrxErrorBoundaryProps, TsrxErrorBoundaryState } from '../types/error-boundary' */
3
-
4
- import { Component } from 'preact';
5
-
6
- /**
7
- * A reusable Preact error boundary class component.
8
- *
9
- * Used by the `@tsrx/preact` 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 {ComponentChildren} */
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/preact-runtime/error-boundary';
package/src/index.js CHANGED
@@ -69,7 +69,7 @@ export function compile(source, filename, compile_options) {
69
69
  * @template {string} T
70
70
  * @param {string} source
71
71
  * @param {NonEmptyString<T>} filename
72
- * @param {ParseOptions & CompileOptions} [options]
72
+ * @param {ParseOptions & CompileOptions & BaseCompileOptions} [options]
73
73
  * @returns {VolarMappingsResult}
74
74
  */
75
75
  export function compile_to_volar_mappings(source, filename, options) {
package/src/ref.js CHANGED
@@ -1 +1 @@
1
- export * from '@tsrx/core/runtime/ref';
1
+ export * from '@tsrx/preact-runtime/ref';
@@ -1 +1 @@
1
- export * from '@tsrx/core/runtime/iterable';
1
+ export * from '@tsrx/preact-runtime/iterable';
package/src/transform.js CHANGED
@@ -35,6 +35,12 @@ const preact_platform = {
35
35
  refProp: '@tsrx/preact/ref',
36
36
  forOfIterableHelper: '@tsrx/preact/runtime/iterable',
37
37
  },
38
+ directRuntimeImports: {
39
+ errorBoundary: '@tsrx/preact-runtime/error-boundary',
40
+ mergeRefs: '@tsrx/preact-runtime/ref',
41
+ refProp: '@tsrx/preact-runtime/ref',
42
+ forOfIterableHelper: '@tsrx/preact-runtime/iterable',
43
+ },
38
44
  jsx: {
39
45
  rewriteClassAttr: false,
40
46
  multiRefStrategy: 'merge-refs',
@@ -1,15 +1 @@
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): TsrxErrorBoundaryState;
14
- render(): ComponentChildren | VNode;
15
- }
1
+ export * from '@tsrx/preact-runtime/error-boundary';
package/types/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import type { Program } from 'estree';
2
2
  import type { BaseCompileOptions, CompileFn, ParseOptions, VolarCompileFn } from '@tsrx/core/types';
3
3
 
4
+ export type { RuntimeImportMode } from '@tsrx/core/types';
5
+
4
6
  /**
5
7
  * Per-call compile options for tsrx-preact. Exposed publicly so the Vite
6
8
  * plugin's typings can extend them.
@@ -23,4 +25,6 @@ export { isRefProp } from './ref.js';
23
25
 
24
26
  export const compile: CompileFn<CompileOptions & BaseCompileOptions>;
25
27
 
26
- export const compile_to_volar_mappings: VolarCompileFn<ParseOptions & CompileOptions>;
28
+ export const compile_to_volar_mappings: VolarCompileFn<
29
+ ParseOptions & CompileOptions & BaseCompileOptions
30
+ >;
package/types/ref.d.ts CHANGED
@@ -1 +1 @@
1
- export * from '@tsrx/core/runtime/ref';
1
+ export * from '@tsrx/preact-runtime/ref';
@@ -1 +1 @@
1
- export * from '@tsrx/core/runtime/iterable';
1
+ export * from '@tsrx/preact-runtime/iterable';