@wsxjs/wsx-core 0.0.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.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/dist/chunk-3CJEWYVF.mjs +197 -0
  3. package/dist/chunk-5JVEHB6H.mjs +197 -0
  4. package/dist/chunk-7E7KJQSW.mjs +210 -0
  5. package/dist/chunk-A5GYVTI3.mjs +222 -0
  6. package/dist/chunk-A5GYVTI3.mjs.map +1 -0
  7. package/dist/chunk-BV2V6BVN.mjs +221 -0
  8. package/dist/chunk-K6N3JDTI.mjs +216 -0
  9. package/dist/chunk-RVGKV4GP.mjs +79 -0
  10. package/dist/chunk-S3O776FY.mjs +173 -0
  11. package/dist/chunk-VNK4B3FW.mjs +217 -0
  12. package/dist/chunk-YNUVFDKT.mjs +222 -0
  13. package/dist/chunk-YNUVFDKT.mjs.map +1 -0
  14. package/dist/index.d.mts +235 -0
  15. package/dist/index.d.ts +235 -0
  16. package/dist/index.js +755 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/index.mjs +524 -0
  19. package/dist/index.mjs.map +1 -0
  20. package/dist/jsx-factory-pFUwL2Dz.d.mts +26 -0
  21. package/dist/jsx-factory-pFUwL2Dz.d.ts +26 -0
  22. package/dist/jsx-pFUwL2Dz.d.mts +26 -0
  23. package/dist/jsx-pFUwL2Dz.d.ts +26 -0
  24. package/dist/jsx-runtime-pFUwL2Dz.d.mts +26 -0
  25. package/dist/jsx-runtime-pFUwL2Dz.d.ts +26 -0
  26. package/dist/jsx-runtime.d.mts +1 -0
  27. package/dist/jsx-runtime.d.ts +1 -0
  28. package/dist/jsx-runtime.js +248 -0
  29. package/dist/jsx-runtime.js.map +1 -0
  30. package/dist/jsx-runtime.mjs +10 -0
  31. package/dist/jsx-runtime.mjs.map +1 -0
  32. package/dist/jsx.d.mts +66 -0
  33. package/dist/jsx.d.ts +66 -0
  34. package/dist/jsx.js +224 -0
  35. package/dist/jsx.js.map +1 -0
  36. package/dist/jsx.mjs +8 -0
  37. package/dist/jsx.mjs.map +1 -0
  38. package/package.json +49 -0
  39. package/src/auto-register.ts +149 -0
  40. package/src/index.ts +17 -0
  41. package/src/jsx-factory.ts +222 -0
  42. package/src/jsx-runtime.ts +6 -0
  43. package/src/jsx.ts +90 -0
  44. package/src/reactive-component.ts +171 -0
  45. package/src/styles/style-manager.ts +54 -0
  46. package/src/utils/logger.ts +69 -0
  47. package/src/utils/reactive.ts +214 -0
  48. package/src/utils/svg-utils.ts +184 -0
  49. package/src/web-component.ts +250 -0
  50. package/types/css-inline.d.ts +4 -0
  51. package/types/index.d.ts +32 -0
  52. package/types/jsx-runtime.d.ts +2 -0
  53. package/types/jsx.d.ts +28 -0
  54. package/types/wsx-types.d.ts +43 -0
@@ -0,0 +1,214 @@
1
+ /**
2
+ * WSX 响应式状态系统
3
+ *
4
+ * 基于浏览器原生 Proxy API 实现轻量级响应式状态,
5
+ * 遵循 WSX 设计哲学:信任浏览器,零运行时开销
6
+ */
7
+ import { createLogger } from "./logger";
8
+
9
+ const logger = createLogger("ReactiveSystem");
10
+
11
+ /**
12
+ * 响应式回调函数类型
13
+ */
14
+ export type ReactiveCallback = () => void;
15
+
16
+ /**
17
+ * 批量更新调度器
18
+ * 使用浏览器原生的 queueMicrotask 实现批量更新
19
+ */
20
+ class UpdateScheduler {
21
+ private pendingCallbacks = new Set<ReactiveCallback>();
22
+ private isScheduled = false;
23
+
24
+ /**
25
+ * 调度一个更新回调
26
+ */
27
+ schedule(callback: ReactiveCallback): void {
28
+ this.pendingCallbacks.add(callback);
29
+
30
+ if (!this.isScheduled) {
31
+ this.isScheduled = true;
32
+ // 使用浏览器原生的微任务队列
33
+ queueMicrotask(() => {
34
+ this.flush();
35
+ });
36
+ }
37
+ }
38
+
39
+ /**
40
+ * 执行所有待处理的回调
41
+ */
42
+ private flush(): void {
43
+ const callbacks = Array.from(this.pendingCallbacks);
44
+ this.pendingCallbacks.clear();
45
+ this.isScheduled = false;
46
+
47
+ // 执行所有回调
48
+ callbacks.forEach((callback) => {
49
+ try {
50
+ callback();
51
+ } catch (error) {
52
+ console.error("[WSX Reactive] Error in callback:", error);
53
+ }
54
+ });
55
+ }
56
+ }
57
+
58
+ // 全局调度器实例
59
+ const scheduler = new UpdateScheduler();
60
+
61
+ /**
62
+ * 创建响应式对象
63
+ *
64
+ * @param obj 要变为响应式的对象
65
+ * @param onChange 状态变化时的回调函数
66
+ * @returns 响应式代理对象
67
+ */
68
+ export function reactive<T extends object>(obj: T, onChange: ReactiveCallback): T {
69
+ return new Proxy(obj, {
70
+ set(target: T, key: string | symbol, value: any): boolean {
71
+ const oldValue = target[key as keyof T];
72
+
73
+ // 只有值真正改变时才触发更新
74
+ if (oldValue !== value) {
75
+ target[key as keyof T] = value;
76
+
77
+ // 调度更新
78
+ scheduler.schedule(onChange);
79
+ }
80
+
81
+ return true;
82
+ },
83
+
84
+ get(target: T, key: string | symbol): any {
85
+ return target[key as keyof T];
86
+ },
87
+
88
+ has(target: T, key: string | symbol): boolean {
89
+ return key in target;
90
+ },
91
+
92
+ ownKeys(target: T): ArrayLike<string | symbol> {
93
+ return Reflect.ownKeys(target);
94
+ },
95
+
96
+ getOwnPropertyDescriptor(target: T, key: string | symbol): PropertyDescriptor | undefined {
97
+ return Reflect.getOwnPropertyDescriptor(target, key);
98
+ },
99
+ });
100
+ }
101
+
102
+ /**
103
+ * 创建响应式状态钩子
104
+ * 提供类似 useState 的 API
105
+ *
106
+ * @param initialValue 初始值
107
+ * @param onChange 变化回调
108
+ * @returns [getter, setter] 元组
109
+ */
110
+ export function createState<T>(
111
+ initialValue: T,
112
+ onChange: ReactiveCallback
113
+ ): [() => T, (value: T | ((prev: T) => T)) => void] {
114
+ let currentValue = initialValue;
115
+
116
+ const getter = (): T => currentValue;
117
+
118
+ const setter = (value: T | ((prev: T) => T)): void => {
119
+ const newValue =
120
+ typeof value === "function" ? (value as (prev: T) => T)(currentValue) : value;
121
+
122
+ if (currentValue !== newValue) {
123
+ currentValue = newValue;
124
+ scheduler.schedule(onChange);
125
+ }
126
+ };
127
+
128
+ return [getter, setter];
129
+ }
130
+
131
+ /**
132
+ * 检查一个值是否为响应式对象
133
+ */
134
+ export function isReactive(value: any): boolean {
135
+ return (
136
+ value != null &&
137
+ typeof value === "object" &&
138
+ value.constructor === Object &&
139
+ typeof value.valueOf === "function"
140
+ );
141
+ }
142
+
143
+ /**
144
+ * 开发模式下的调试工具
145
+ */
146
+ export const ReactiveDebug = {
147
+ /**
148
+ * 启用调试模式
149
+ */
150
+ enable(): void {
151
+ if (typeof window !== "undefined") {
152
+ (window as any).__WSX_REACTIVE_DEBUG__ = true;
153
+ }
154
+ },
155
+
156
+ /**
157
+ * 禁用调试模式
158
+ */
159
+ disable(): void {
160
+ if (typeof window !== "undefined") {
161
+ (window as any).__WSX_REACTIVE_DEBUG__ = false;
162
+ }
163
+ },
164
+
165
+ /**
166
+ * 检查是否启用调试模式
167
+ */
168
+ isEnabled(): boolean {
169
+ return typeof window !== "undefined" && (window as any).__WSX_REACTIVE_DEBUG__ === true;
170
+ },
171
+
172
+ /**
173
+ * 调试日志
174
+ */
175
+ log(message: string, ...args: any[]): void {
176
+ if (this.isEnabled()) {
177
+ logger.info(`[WSX Reactive] ${message}`, ...args);
178
+ }
179
+ },
180
+ };
181
+
182
+ /**
183
+ * 增强的 reactive 函数,带调试支持
184
+ */
185
+ export function reactiveWithDebug<T extends object>(
186
+ obj: T,
187
+ onChange: ReactiveCallback,
188
+ debugName?: string
189
+ ): T {
190
+ const name = debugName || obj.constructor.name || "Unknown";
191
+
192
+ return new Proxy(obj, {
193
+ set(target: T, key: string | symbol, value: any): boolean {
194
+ const oldValue = target[key as keyof T];
195
+
196
+ if (oldValue !== value) {
197
+ ReactiveDebug.log(`State change in ${name}:`, {
198
+ key: String(key),
199
+ oldValue,
200
+ newValue: value,
201
+ });
202
+
203
+ target[key as keyof T] = value;
204
+ scheduler.schedule(onChange);
205
+ }
206
+
207
+ return true;
208
+ },
209
+
210
+ get(target: T, key: string | symbol): any {
211
+ return target[key as keyof T];
212
+ },
213
+ });
214
+ }
@@ -0,0 +1,184 @@
1
+ /**
2
+ * SVG utilities for namespace-aware element creation
3
+ */
4
+
5
+ // SVG namespace URI
6
+ export const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
7
+
8
+ // SVG专用元素 - 只存在于SVG中的元素
9
+ export const SVG_ONLY_ELEMENTS = new Set([
10
+ // 结构元素 (Structural elements)
11
+ "svg",
12
+ "defs",
13
+ "g",
14
+ "symbol",
15
+ "use",
16
+
17
+ // 图形元素 (Graphics elements)
18
+ "circle",
19
+ "ellipse",
20
+ "line",
21
+ "path",
22
+ "polygon",
23
+ "polyline",
24
+ "rect",
25
+
26
+ // 文本元素 (Text elements)
27
+ "textPath",
28
+ "tspan",
29
+
30
+ // 渐变和模式 (Gradients and patterns)
31
+ "linearGradient",
32
+ "radialGradient",
33
+ "stop",
34
+ "pattern",
35
+
36
+ // 滤镜 (Filter elements)
37
+ "filter",
38
+ "feBlend",
39
+ "feColorMatrix",
40
+ "feComponentTransfer",
41
+ "feComposite",
42
+ "feConvolveMatrix",
43
+ "feDiffuseLighting",
44
+ "feDisplacementMap",
45
+ "feDistantLight",
46
+ "feDropShadow",
47
+ "feFlood",
48
+ "feFuncA",
49
+ "feFuncB",
50
+ "feFuncG",
51
+ "feFuncR",
52
+ "feGaussianBlur",
53
+ "feImage",
54
+ "feMerge",
55
+ "feMergeNode",
56
+ "feMorphology",
57
+ "feOffset",
58
+ "fePointLight",
59
+ "feSpecularLighting",
60
+ "feSpotLight",
61
+ "feTile",
62
+ "feTurbulence",
63
+
64
+ // 动画元素 (Animation elements)
65
+ "animate",
66
+ "animateMotion",
67
+ "animateTransform",
68
+ "set",
69
+
70
+ // 其他元素 (Other elements)
71
+ "clipPath",
72
+ "foreignObject",
73
+ "marker",
74
+ "mask",
75
+ "metadata",
76
+ "switch",
77
+ "desc",
78
+ ]);
79
+
80
+ // 既存在于HTML又存在于SVG的元素 - 默认使用HTML版本
81
+ export const DUAL_ELEMENTS = new Set(["image", "style", "title", "text"]);
82
+
83
+ // 强制使用HTML版本的元素(即使在SVG上下文中)
84
+ export const FORCE_HTML_ELEMENTS = new Set(["a"]);
85
+
86
+ // 所有SVG元素的集合
87
+ export const SVG_ELEMENTS = new Set([
88
+ ...SVG_ONLY_ELEMENTS,
89
+ ...DUAL_ELEMENTS,
90
+ ...FORCE_HTML_ELEMENTS,
91
+ ]);
92
+
93
+ // SVG上下文追踪
94
+ let svgContext = false;
95
+
96
+ /**
97
+ * 检查标签名是否为SVG专用元素
98
+ */
99
+ export function isSVGOnlyElement(tagName: string): boolean {
100
+ return SVG_ONLY_ELEMENTS.has(tagName);
101
+ }
102
+
103
+ /**
104
+ * 检查标签名是否为双重元素(HTML和SVG都有)
105
+ */
106
+ export function isDualElement(tagName: string): boolean {
107
+ return DUAL_ELEMENTS.has(tagName);
108
+ }
109
+
110
+ /**
111
+ * 检查标签名是否为强制HTML元素
112
+ */
113
+ export function isForceHTMLElement(tagName: string): boolean {
114
+ return FORCE_HTML_ELEMENTS.has(tagName);
115
+ }
116
+
117
+ /**
118
+ * 检查标签名是否为SVG元素(保持向后兼容)
119
+ */
120
+ export function isSVGElement(tagName: string): boolean {
121
+ return SVG_ELEMENTS.has(tagName);
122
+ }
123
+
124
+ /**
125
+ * 设置SVG上下文状态
126
+ */
127
+ export function setSVGContext(inSVG: boolean): void {
128
+ svgContext = inSVG;
129
+ }
130
+
131
+ /**
132
+ * 获取当前SVG上下文状态
133
+ */
134
+ export function getSVGContext(): boolean {
135
+ return svgContext;
136
+ }
137
+
138
+ /**
139
+ * 创建元素 - 基于上下文和元素类型智能选择命名空间
140
+ */
141
+ export function createElement(tagName: string): HTMLElement | SVGElement {
142
+ // 强制HTML元素始终使用HTML版本
143
+ if (isForceHTMLElement(tagName)) {
144
+ return document.createElement(tagName) as HTMLElement;
145
+ }
146
+
147
+ // SVG专用元素始终使用SVG命名空间
148
+ if (isSVGOnlyElement(tagName)) {
149
+ setSVGContext(true); // 进入SVG上下文
150
+ return document.createElementNS(SVG_NAMESPACE, tagName) as SVGElement;
151
+ }
152
+
153
+ // 双重元素根据上下文决定
154
+ if (isDualElement(tagName)) {
155
+ if (svgContext) {
156
+ return document.createElementNS(SVG_NAMESPACE, tagName) as SVGElement;
157
+ }
158
+ }
159
+
160
+ // 默认创建HTML元素
161
+ return document.createElement(tagName) as HTMLElement;
162
+ }
163
+
164
+ /**
165
+ * 检测元素是否需要在SVG上下文中处理
166
+ */
167
+ export function shouldUseSVGNamespace(tagName: string): boolean {
168
+ return isSVGOnlyElement(tagName) || (isDualElement(tagName) && svgContext);
169
+ }
170
+
171
+ /**
172
+ * SVG特殊属性映射 - 处理SVG和HTML属性差异
173
+ */
174
+ export const SVG_ATTRIBUTE_MAP = new Map([
175
+ ["className", "class"],
176
+ ["htmlFor", "for"],
177
+ ]);
178
+
179
+ /**
180
+ * 获取SVG元素的正确属性名
181
+ */
182
+ export function getSVGAttributeName(attributeName: string): string {
183
+ return SVG_ATTRIBUTE_MAP.get(attributeName) || attributeName;
184
+ }
@@ -0,0 +1,250 @@
1
+ /**
2
+ * 通用 WSX Web Component 基础抽象类
3
+ *
4
+ * 提供JSX + CSS文件支持的通用基础类:
5
+ * - 抽象render方法强制子类实现JSX渲染
6
+ * - 自动集成StyleManager处理外部CSS
7
+ * - 提供完整的Web Component生命周期
8
+ * - 完全通用,不依赖任何特定框架
9
+ */
10
+
11
+ import { h, type JSXChildren } from "./jsx-factory";
12
+ import { StyleManager } from "./styles/style-manager";
13
+
14
+ /**
15
+ * Web Component 配置接口
16
+ */
17
+ export interface WebComponentConfig {
18
+ styles?: string; // CSS内容
19
+ styleName?: string; // 样式名称,用于缓存
20
+ [key: string]: unknown;
21
+ }
22
+
23
+ /**
24
+ * 通用 WSX Web Component 基础抽象类
25
+ */
26
+ export abstract class WebComponent extends HTMLElement {
27
+ declare shadowRoot: ShadowRoot;
28
+ protected config: WebComponentConfig;
29
+ protected connected: boolean = false;
30
+
31
+ /**
32
+ * 子类应该重写这个方法来定义观察的属性
33
+ * @returns 要观察的属性名数组
34
+ */
35
+ static get observedAttributes(): string[] {
36
+ return [];
37
+ }
38
+
39
+ constructor(config: WebComponentConfig = {}) {
40
+ super();
41
+
42
+ this.config = config;
43
+ this.attachShadow({ mode: "open" });
44
+
45
+ // 自动应用CSS样式
46
+ if (config.styles) {
47
+ const styleName = config.styleName || this.constructor.name;
48
+ StyleManager.applyStyles(this.shadowRoot, styleName, config.styles);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * 抽象方法:子类必须实现JSX渲染
54
+ *
55
+ * @returns JSX元素
56
+ */
57
+ abstract render(): HTMLElement;
58
+
59
+ /**
60
+ * Web Component生命周期:连接到DOM
61
+ */
62
+ connectedCallback(): void {
63
+ this.connected = true;
64
+ try {
65
+ // 渲染JSX内容到Shadow DOM
66
+ const content = this.render();
67
+ this.shadowRoot.appendChild(content);
68
+
69
+ // 调用子类的初始化钩子
70
+ this.onConnected?.();
71
+ } catch (error) {
72
+ console.error(`[${this.constructor.name}] Error in connectedCallback:`, error);
73
+ this.renderError(error);
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Web Component生命周期:从DOM断开
79
+ */
80
+ disconnectedCallback(): void {
81
+ this.onDisconnected?.();
82
+ }
83
+
84
+ /**
85
+ * Web Component生命周期:属性变化
86
+ */
87
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void {
88
+ this.onAttributeChanged?.(name, oldValue, newValue);
89
+ }
90
+
91
+ /**
92
+ * 可选生命周期钩子:组件已连接
93
+ */
94
+ protected onConnected?(): void;
95
+
96
+ /**
97
+ * 可选生命周期钩子:组件已断开
98
+ */
99
+ protected onDisconnected?(): void;
100
+
101
+ /**
102
+ * 可选生命周期钩子:属性已更改
103
+ */
104
+ protected onAttributeChanged?(name: string, oldValue: string, newValue: string): void;
105
+
106
+ /**
107
+ * 查找Shadow DOM内的元素
108
+ *
109
+ * @param selector - CSS选择器
110
+ * @returns 元素或null
111
+ */
112
+ public querySelector<T extends HTMLElement>(selector: string): T | null {
113
+ return this.shadowRoot.querySelector<T>(selector);
114
+ }
115
+
116
+ /**
117
+ * 查找Shadow DOM内的所有匹配元素
118
+ *
119
+ * @param selector - CSS选择器
120
+ * @returns 元素列表
121
+ */
122
+ public querySelectorAll<T extends HTMLElement>(selector: string): NodeListOf<T> {
123
+ return this.shadowRoot.querySelectorAll<T>(selector);
124
+ }
125
+
126
+ /**
127
+ * 重新渲染组件
128
+ */
129
+ protected rerender(): void {
130
+ if (!this.connected) {
131
+ console.warn(
132
+ `[${this.constructor.name}] Component is not connected, skipping rerender.`
133
+ );
134
+ return;
135
+ }
136
+ // 保存当前的 adopted stylesheets (jsdom may not support this)
137
+ const adoptedStyleSheets = this.shadowRoot.adoptedStyleSheets || [];
138
+
139
+ // 清空现有内容但保留样式
140
+ this.shadowRoot.innerHTML = "";
141
+
142
+ // 恢复 adopted stylesheets (避免重新应用样式)
143
+ if (this.shadowRoot.adoptedStyleSheets) {
144
+ this.shadowRoot.adoptedStyleSheets = adoptedStyleSheets;
145
+ }
146
+
147
+ // 只有在没有 adopted stylesheets 时才重新应用样式
148
+ if (adoptedStyleSheets.length === 0 && this.config.styles) {
149
+ const styleName = this.config.styleName || this.constructor.name;
150
+ StyleManager.applyStyles(this.shadowRoot, styleName, this.config.styles);
151
+ }
152
+
153
+ // 重新渲染JSX
154
+ try {
155
+ const content = this.render();
156
+ this.shadowRoot.appendChild(content);
157
+ } catch (error) {
158
+ console.error(`[${this.constructor.name}] Error in rerender:`, error);
159
+ this.renderError(error);
160
+ }
161
+ }
162
+
163
+ /**
164
+ * 渲染错误信息
165
+ *
166
+ * @param error - 错误对象
167
+ */
168
+ private renderError(error: unknown): void {
169
+ // 清空现有内容
170
+ this.shadowRoot.innerHTML = "";
171
+
172
+ const errorElement = h(
173
+ "div",
174
+ {
175
+ style: "color: red; padding: 10px; border: 1px solid red; background: #ffe6e6; font-family: monospace;",
176
+ },
177
+ [
178
+ h("strong", {}, `[${this.constructor.name}] Component Error:`),
179
+ h("pre", { style: "margin: 10px 0; white-space: pre-wrap;" }, String(error)),
180
+ ]
181
+ );
182
+
183
+ this.shadowRoot.appendChild(errorElement);
184
+ }
185
+
186
+ /**
187
+ * 获取配置值
188
+ *
189
+ * @param key - 配置键
190
+ * @param defaultValue - 默认值
191
+ * @returns 配置值
192
+ */
193
+ protected getConfig<T>(key: string, defaultValue?: T): T {
194
+ return (this.config[key] as T) ?? (defaultValue as T);
195
+ }
196
+
197
+ /**
198
+ * 设置配置值
199
+ *
200
+ * @param key - 配置键
201
+ * @param value - 配置值
202
+ */
203
+ protected setConfig(key: string, value: unknown): void {
204
+ this.config[key] = value;
205
+ }
206
+
207
+ /**
208
+ * 获取属性值
209
+ *
210
+ * @param name - 属性名
211
+ * @param defaultValue - 默认值
212
+ * @returns 属性值
213
+ */
214
+ protected getAttr(name: string, defaultValue = ""): string {
215
+ return this.getAttribute(name) || defaultValue;
216
+ }
217
+
218
+ /**
219
+ * 设置属性值
220
+ *
221
+ * @param name - 属性名
222
+ * @param value - 属性值
223
+ */
224
+ protected setAttr(name: string, value: string): void {
225
+ this.setAttribute(name, value);
226
+ }
227
+
228
+ /**
229
+ * 移除属性
230
+ *
231
+ * @param name - 属性名
232
+ */
233
+ protected removeAttr(name: string): void {
234
+ this.removeAttribute(name);
235
+ }
236
+
237
+ /**
238
+ * 检查是否有属性
239
+ *
240
+ * @param name - 属性名
241
+ * @returns 是否存在
242
+ */
243
+ protected hasAttr(name: string): boolean {
244
+ return this.hasAttribute(name);
245
+ }
246
+ }
247
+
248
+ // 导出JSX助手
249
+ export { h };
250
+ export type { JSXChildren };
@@ -0,0 +1,4 @@
1
+ declare module "*.css?inline" {
2
+ const styles: string;
3
+ export default styles;
4
+ }
@@ -0,0 +1,32 @@
1
+ // 导入所有类型定义
2
+ import "./css-inline.d.ts";
3
+ import "./wsx-types";
4
+ import "./global.d.ts";
5
+
6
+ // 重新导出 JSX 工厂函数和类型
7
+ export { h, Fragment } from "./wsx-types";
8
+ export type { JSXChildren } from "../src/jsx-factory";
9
+
10
+ // 导出 WebComponent 类和配置
11
+ export { WebComponent, type WebComponentConfig } from "../src/web-component";
12
+
13
+ // 导出 auto-register 相关类型和函数
14
+ export {
15
+ autoRegister,
16
+ registerComponent,
17
+ registerAll,
18
+ isRegistered,
19
+ getTagName,
20
+ } from "../src/auto-register";
21
+ export type { AutoRegistrationOptions } from "../src/auto-register";
22
+
23
+ // 导出 StyleManager
24
+ export { StyleManager } from "../src/styles/style-manager";
25
+
26
+ // 导出 Logger 相关类型和函数
27
+ export { WSXLogger, logger, createLogger } from "../src/utils/logger.ts";
28
+ export type { Logger, LogLevel } from "../src/utils/logger.ts";
29
+
30
+ // 重新导出 JSX 运行时
31
+ export { h as jsx, h as jsxs, Fragment as F } from "../src/jsx-factory";
32
+ export type { JSXChildren as J } from "../src/jsx-factory";
@@ -0,0 +1,2 @@
1
+ export { h as jsx, h as jsxs, Fragment } from "./wsx-types";
2
+ export type { JSX } from "./jsx";
package/types/jsx.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * JSX 专用类型声明文件
3
+ * 为 jsxImportSource 机制提供类型支持
4
+ */
5
+
6
+ // 导入全局 JSX 类型声明
7
+ import "./wsx-types";
8
+
9
+ // 导出 JSX 工厂函数
10
+ export { h, Fragment } from "./wsx-types";
11
+
12
+ // JSX namespace declaration for TypeScript
13
+ export namespace JSX {
14
+ type Element = HTMLElement;
15
+
16
+ interface IntrinsicElements {
17
+ // HTML elements
18
+ [elemName: string]: object;
19
+ }
20
+
21
+ interface ElementAttributesProperty {
22
+ props: object;
23
+ }
24
+
25
+ interface ElementChildrenAttribute {
26
+ children: object;
27
+ }
28
+ }