@creact-labs/creact 0.1.3 → 0.1.5

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/dist/index.d.ts CHANGED
@@ -28,8 +28,7 @@
28
28
 
29
29
  */
30
30
  export { CReact, JSXElement } from './jsx';
31
- export type { FC, PropsWithChildren } from './jsx.d';
32
- import './jsx.d';
31
+ export type { FC, PropsWithChildren, ComponentProps } from './jsx';
33
32
  import { CReact as CReactClass } from './core/CReact';
34
33
  export { CReact as CReactCore, CReactConfig } from './core/CReact';
35
34
  export declare const renderCloudDOM: typeof CReactClass.renderCloudDOM;
package/dist/index.js CHANGED
@@ -35,8 +35,6 @@ exports.parseResourceId = exports.formatPath = exports.normalizePath = exports.n
35
35
  // JSX support
36
36
  var jsx_1 = require("./jsx");
37
37
  Object.defineProperty(exports, "CReact", { enumerable: true, get: function () { return jsx_1.CReact; } });
38
- // Re-export JSX type definitions for consumers
39
- require("./jsx.d");
40
38
  // Core classes
41
39
  const CReact_1 = require("./core/CReact");
42
40
  var CReact_2 = require("./core/CReact");
package/dist/jsx.d.ts CHANGED
@@ -62,3 +62,82 @@ export declare namespace CReact {
62
62
  children?: any;
63
63
  }) => JSXElement;
64
64
  }
65
+ /**
66
+ * Global JSX namespace declarations
67
+ *
68
+ * These declarations tell TypeScript how to validate JSX syntax and component props.
69
+ * By including them in this file (not a separate .d.ts), they are automatically
70
+ * included in the compiled output and available to package consumers.
71
+ */
72
+ declare global {
73
+ namespace JSX {
74
+ /**
75
+ * The type returned by JSX expressions
76
+ */
77
+ interface Element extends JSXElement {
78
+ }
79
+ /**
80
+ * Intrinsic elements (HTML-like elements)
81
+ * Empty for CReact - we only support component elements
82
+ */
83
+ interface IntrinsicElements {
84
+ }
85
+ /**
86
+ * Defines which prop contains children
87
+ * This allows TypeScript to understand the children prop
88
+ */
89
+ interface ElementChildrenAttribute {
90
+ children: {};
91
+ }
92
+ /**
93
+ * Base attributes available on all elements (including key)
94
+ * This applies to all JSX elements, both intrinsic and component-based
95
+ *
96
+ * IMPORTANT: This makes 'key' available on ALL JSX elements,
97
+ * including function components, without needing to add it to props
98
+ */
99
+ interface IntrinsicAttributes {
100
+ key?: string | number;
101
+ }
102
+ /**
103
+ * Attributes available on class components
104
+ */
105
+ interface IntrinsicClassAttributes<T> {
106
+ key?: string | number;
107
+ }
108
+ /**
109
+ * Tell TypeScript how to extract props from a component type
110
+ * This is critical for making LibraryManagedAttributes work
111
+ */
112
+ interface ElementAttributesProperty {
113
+ props: {};
114
+ }
115
+ /**
116
+ * Augment LibraryManagedAttributes to properly handle key prop
117
+ *
118
+ * This tells TypeScript that when checking JSX element props:
119
+ * 1. Take the component's declared props (P)
120
+ * 2. Make key optional (it's in IntrinsicAttributes but shouldn't be required)
121
+ * 3. Allow key to be passed even if not in component props
122
+ *
123
+ * We use Omit to remove 'key' from P if it exists, then add it back as optional
124
+ */
125
+ type LibraryManagedAttributes<C, P> = Omit<P, 'key'> & IntrinsicAttributes;
126
+ }
127
+ }
128
+ /**
129
+ * Type helper for component props with children
130
+ */
131
+ export interface PropsWithChildren {
132
+ children?: JSX.Element | JSX.Element[];
133
+ }
134
+ /**
135
+ * Type helper for functional components
136
+ * Note: key is handled by JSX.IntrinsicAttributes and doesn't need to be in props
137
+ */
138
+ export type FC<P = Record<string, unknown>> = (props: P & PropsWithChildren) => JSX.Element | null;
139
+ /**
140
+ * Type helper for component props that includes JSX attributes (like key)
141
+ * Use this when defining component prop types to allow key prop
142
+ */
143
+ export type ComponentProps<P = Record<string, unknown>> = P & JSX.IntrinsicAttributes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creact-labs/creact",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "CReact - React for Infrastructure. Render JSX to CloudDOM.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",