@tachui/core 0.7.1-alpha → 0.8.1-alpha
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/README.md +20 -2
- package/dist/bundles/assets.d.ts +19 -0
- package/dist/bundles/assets.d.ts.map +1 -0
- package/dist/bundles/common.d.ts +1 -1
- package/dist/bundles/common.d.ts.map +1 -1
- package/dist/bundles/context.d.ts +22 -0
- package/dist/bundles/context.d.ts.map +1 -0
- package/dist/bundles/minimal.d.ts +8 -18
- package/dist/bundles/minimal.d.ts.map +1 -1
- package/dist/bundles/production-minimal.d.ts +2 -16
- package/dist/bundles/production-minimal.d.ts.map +1 -1
- package/dist/common.js +405 -828
- package/dist/compiler/advanced-parser.d.ts.map +1 -1
- package/dist/compiler/codegen.d.ts.map +1 -1
- package/dist/compiler/index.js +6 -1387
- package/dist/compiler/parser.d.ts +1 -1
- package/dist/compiler/parser.d.ts.map +1 -1
- package/dist/compiler/plugin.d.ts.map +1 -1
- package/dist/compiler/types.d.ts +28 -0
- package/dist/compiler/types.d.ts.map +1 -1
- package/dist/component-XAzF1xqs.js +487 -0
- package/dist/component-base-x2XmHFjy.js +255 -0
- package/dist/components/index.d.ts +4 -38
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +7 -4167
- package/dist/components/wrapper.d.ts +5 -152
- package/dist/components/wrapper.d.ts.map +1 -1
- package/dist/concatenated-component-ByPl3_FF.js +2933 -0
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/layout.d.ts +47 -4
- package/dist/constants/layout.d.ts.map +1 -1
- package/dist/constants/layout.js +84 -0
- package/dist/css-classes/index.js +176 -0
- package/dist/{dom-bridge-Cx-s6Ihx.js → dom-bridge-CAa1N2zX.js} +28 -28
- package/dist/{effect-CytAc9em.js → effect-B9Knft0b.js} +3 -3
- package/dist/essential.js +397 -826
- package/dist/index-DEBd8cq7.js +1144 -0
- package/dist/index-DIvMCJQO.js +268 -0
- package/dist/index-vdsiw6gQ.js +777 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +397 -826
- package/dist/minimal-prod.js +101 -155
- package/dist/minimal.js +118 -170
- package/dist/modifiers/background.d.ts +41 -11
- package/dist/modifiers/background.d.ts.map +1 -1
- package/dist/modifiers/base.d.ts +6 -33
- package/dist/modifiers/base.d.ts.map +1 -1
- package/dist/modifiers/base.js +487 -0
- package/dist/modifiers/builder.d.ts +103 -195
- package/dist/modifiers/builder.d.ts.map +1 -1
- package/dist/modifiers/builder.js +9 -0
- package/dist/modifiers/core.d.ts +9 -401
- package/dist/modifiers/core.d.ts.map +1 -1
- package/dist/modifiers/{utils.d.ts → factories.d.ts} +18 -5
- package/dist/modifiers/factories.d.ts.map +1 -0
- package/dist/modifiers/index.d.ts +8 -52
- package/dist/modifiers/index.d.ts.map +1 -1
- package/dist/modifiers/index.js +38 -0
- package/dist/modifiers/presets.d.ts +368 -0
- package/dist/modifiers/presets.d.ts.map +1 -0
- package/dist/modifiers/registry.js +10 -0
- package/dist/modifiers/types.d.ts +39 -211
- package/dist/modifiers/types.d.ts.map +1 -1
- package/dist/modifiers/types.js +4 -0
- package/dist/observed-object-Cos-FtjP.js +269 -0
- package/dist/performance-optimizer-stub-CtfXUwl4.js +38 -0
- package/dist/plugin-BCAdZXKq.js +1680 -0
- package/dist/plugins/index.d.ts +5 -6
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +147 -297
- package/dist/plugins/simplified-index.d.ts +5 -6
- package/dist/plugins/simplified-index.d.ts.map +1 -1
- package/dist/production-minimal-BY_gMc-l.js +2532 -0
- package/dist/reactive/index.js +96 -95
- package/dist/reactive/types.js +4 -0
- package/dist/runtime/concatenation-aria.d.ts +24 -0
- package/dist/runtime/concatenation-aria.d.ts.map +1 -0
- package/dist/runtime/concatenation-aria.js +53 -0
- package/dist/runtime/concatenation-full.d.ts +30 -0
- package/dist/runtime/concatenation-full.d.ts.map +1 -0
- package/dist/runtime/concatenation-full.js +77 -0
- package/dist/runtime/concatenation-minimal.d.ts +25 -0
- package/dist/runtime/concatenation-minimal.d.ts.map +1 -0
- package/dist/runtime/concatenation-minimal.js +40 -0
- package/dist/runtime/dom-bridge.js +5 -5
- package/dist/runtime/element-override.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +0 -7
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/renderer.d.ts.map +1 -1
- package/dist/runtime/renderer.js +7 -8
- package/dist/runtime/semantic-role-manager.d.ts.map +1 -1
- package/dist/runtime/types.js +1 -0
- package/dist/{scheduler-7SvC3a21.js → scheduler-BKeqwrYE.js} +130 -130
- package/dist/validation/build-time-stub.d.ts +33 -0
- package/dist/validation/build-time-stub.d.ts.map +1 -0
- package/dist/validation/debug-tools-stub.d.ts +67 -0
- package/dist/validation/debug-tools-stub.d.ts.map +1 -0
- package/dist/validation/index.d.ts +23 -78
- package/dist/validation/index.d.ts.map +1 -1
- package/dist/validation/index.js +609 -6470
- package/dist/validation/lifecycle-validation.d.ts.map +1 -1
- package/dist/validation/performance-optimizer-stub.d.ts +50 -0
- package/dist/validation/performance-optimizer-stub.d.ts.map +1 -0
- package/dist/validation/plugin-registration.d.ts +5 -1
- package/dist/validation/plugin-registration.d.ts.map +1 -1
- package/dist/validation/production-bypass-core.d.ts +69 -0
- package/dist/validation/production-bypass-core.d.ts.map +1 -0
- package/package.json +61 -5
- package/dist/ScrollView-h-6wYMAm.js +0 -515
- package/dist/Spacer-BbteDQ9I.js +0 -5337
- package/dist/binding-CmdpowkI.js +0 -2276
- package/dist/components/BasicInput.d.ts +0 -116
- package/dist/components/BasicInput.d.ts.map +0 -1
- package/dist/components/Button.d.ts +0 -252
- package/dist/components/Button.d.ts.map +0 -1
- package/dist/components/Divider.d.ts +0 -141
- package/dist/components/Divider.d.ts.map +0 -1
- package/dist/components/EnhancedLink.d.ts +0 -365
- package/dist/components/EnhancedLink.d.ts.map +0 -1
- package/dist/components/Form.d.ts +0 -141
- package/dist/components/Form.d.ts.map +0 -1
- package/dist/components/Grid.d.ts +0 -698
- package/dist/components/Grid.d.ts.map +0 -1
- package/dist/components/GridResponsive.d.ts +0 -214
- package/dist/components/GridResponsive.d.ts.map +0 -1
- package/dist/components/Image.d.ts +0 -162
- package/dist/components/Image.d.ts.map +0 -1
- package/dist/components/List.d.ts +0 -287
- package/dist/components/List.d.ts.map +0 -1
- package/dist/components/Menu.d.ts +0 -159
- package/dist/components/Menu.d.ts.map +0 -1
- package/dist/components/Picker.d.ts +0 -153
- package/dist/components/Picker.d.ts.map +0 -1
- package/dist/components/ScrollView.d.ts +0 -222
- package/dist/components/ScrollView.d.ts.map +0 -1
- package/dist/components/Section.d.ts +0 -153
- package/dist/components/Section.d.ts.map +0 -1
- package/dist/components/Show.d.ts +0 -64
- package/dist/components/Show.d.ts.map +0 -1
- package/dist/components/Spacer.d.ts +0 -35
- package/dist/components/Spacer.d.ts.map +0 -1
- package/dist/components/Text.d.ts +0 -242
- package/dist/components/Text.d.ts.map +0 -1
- package/dist/components/Toggle.d.ts +0 -207
- package/dist/components/Toggle.d.ts.map +0 -1
- package/dist/concatenated-component-DPcl2TEO.js +0 -6779
- package/dist/context--zQFIImS.js +0 -283
- package/dist/debug/index.d.ts +0 -61
- package/dist/debug/index.d.ts.map +0 -1
- package/dist/debug.js +0 -178
- package/dist/developer-experience/enhanced-errors.d.ts +0 -128
- package/dist/developer-experience/enhanced-errors.d.ts.map +0 -1
- package/dist/developer-experience/enhanced-types.d.ts +0 -281
- package/dist/developer-experience/enhanced-types.d.ts.map +0 -1
- package/dist/developer-experience/index.d.ts +0 -44
- package/dist/developer-experience/index.d.ts.map +0 -1
- package/dist/index-Nfi2SBQh.js +0 -3268
- package/dist/modifiers/attributes.d.ts +0 -203
- package/dist/modifiers/attributes.d.ts.map +0 -1
- package/dist/modifiers/backdrop.d.ts +0 -59
- package/dist/modifiers/backdrop.d.ts.map +0 -1
- package/dist/modifiers/border.d.ts +0 -217
- package/dist/modifiers/border.d.ts.map +0 -1
- package/dist/modifiers/effects.d.ts +0 -159
- package/dist/modifiers/effects.d.ts.map +0 -1
- package/dist/modifiers/elements.d.ts +0 -240
- package/dist/modifiers/elements.d.ts.map +0 -1
- package/dist/modifiers/filters.d.ts +0 -275
- package/dist/modifiers/filters.d.ts.map +0 -1
- package/dist/modifiers/flexbox.d.ts +0 -82
- package/dist/modifiers/flexbox.d.ts.map +0 -1
- package/dist/modifiers/font.d.ts +0 -71
- package/dist/modifiers/font.d.ts.map +0 -1
- package/dist/modifiers/grid.d.ts +0 -92
- package/dist/modifiers/grid.d.ts.map +0 -1
- package/dist/modifiers/margin.d.ts +0 -128
- package/dist/modifiers/margin.d.ts.map +0 -1
- package/dist/modifiers/padding.d.ts +0 -204
- package/dist/modifiers/padding.d.ts.map +0 -1
- package/dist/modifiers/responsive/advanced-utilities.d.ts +0 -118
- package/dist/modifiers/responsive/advanced-utilities.d.ts.map +0 -1
- package/dist/modifiers/responsive/breakpoints.d.ts +0 -81
- package/dist/modifiers/responsive/breakpoints.d.ts.map +0 -1
- package/dist/modifiers/responsive/css-generator.d.ts +0 -100
- package/dist/modifiers/responsive/css-generator.d.ts.map +0 -1
- package/dist/modifiers/responsive/dev-tools.d.ts +0 -107
- package/dist/modifiers/responsive/dev-tools.d.ts.map +0 -1
- package/dist/modifiers/responsive/index.d.ts +0 -29
- package/dist/modifiers/responsive/index.d.ts.map +0 -1
- package/dist/modifiers/responsive/layout-patterns.d.ts +0 -230
- package/dist/modifiers/responsive/layout-patterns.d.ts.map +0 -1
- package/dist/modifiers/responsive/performance.d.ts +0 -130
- package/dist/modifiers/responsive/performance.d.ts.map +0 -1
- package/dist/modifiers/responsive/responsive-builder.d.ts +0 -133
- package/dist/modifiers/responsive/responsive-builder.d.ts.map +0 -1
- package/dist/modifiers/responsive/responsive-modifier.d.ts +0 -123
- package/dist/modifiers/responsive/responsive-modifier.d.ts.map +0 -1
- package/dist/modifiers/responsive/types.d.ts +0 -183
- package/dist/modifiers/responsive/types.d.ts.map +0 -1
- package/dist/modifiers/responsive/utilities.d.ts +0 -149
- package/dist/modifiers/responsive/utilities.d.ts.map +0 -1
- package/dist/modifiers/scroll.d.ts +0 -143
- package/dist/modifiers/scroll.d.ts.map +0 -1
- package/dist/modifiers/shadows.d.ts +0 -114
- package/dist/modifiers/shadows.d.ts.map +0 -1
- package/dist/modifiers/size.d.ts +0 -113
- package/dist/modifiers/size.d.ts.map +0 -1
- package/dist/modifiers/text.d.ts +0 -147
- package/dist/modifiers/text.d.ts.map +0 -1
- package/dist/modifiers/transformations.d.ts +0 -329
- package/dist/modifiers/transformations.d.ts.map +0 -1
- package/dist/modifiers/transitions.d.ts +0 -98
- package/dist/modifiers/transitions.d.ts.map +0 -1
- package/dist/modifiers/typography.d.ts +0 -192
- package/dist/modifiers/typography.d.ts.map +0 -1
- package/dist/modifiers/utility.d.ts +0 -69
- package/dist/modifiers/utility.d.ts.map +0 -1
- package/dist/modifiers/utils.d.ts.map +0 -1
- package/dist/plugins/simplified-error-handler.d.ts +0 -83
- package/dist/plugins/simplified-error-handler.d.ts.map +0 -1
- package/dist/runtime/dev-tools.d.ts +0 -240
- package/dist/runtime/dev-tools.d.ts.map +0 -1
- package/dist/runtime/development-warnings.d.ts +0 -42
- package/dist/runtime/development-warnings.d.ts.map +0 -1
- package/dist/runtime/error-boundary.d.ts +0 -302
- package/dist/runtime/error-boundary.d.ts.map +0 -1
- package/dist/runtime/error-recovery.d.ts +0 -267
- package/dist/runtime/error-recovery.d.ts.map +0 -1
- package/dist/runtime/error-reporting.d.ts +0 -287
- package/dist/runtime/error-reporting.d.ts.map +0 -1
- package/dist/runtime/error-utils.d.ts +0 -204
- package/dist/runtime/error-utils.d.ts.map +0 -1
- package/dist/runtime/performance.d.ts +0 -217
- package/dist/runtime/performance.d.ts.map +0 -1
- package/dist/sui-compat.d.ts +0 -110
- package/dist/sui-compat.d.ts.map +0 -1
- package/dist/validation/advanced-debugging.d.ts +0 -319
- package/dist/validation/advanced-debugging.d.ts.map +0 -1
- package/dist/validation/build-time/detection.d.ts +0 -32
- package/dist/validation/build-time/detection.d.ts.map +0 -1
- package/dist/validation/build-time/index.d.ts +0 -84
- package/dist/validation/build-time/index.d.ts.map +0 -1
- package/dist/validation/build-time/plugins.d.ts +0 -75
- package/dist/validation/build-time/plugins.d.ts.map +0 -1
- package/dist/validation/build-time/rules.d.ts +0 -73
- package/dist/validation/build-time/rules.d.ts.map +0 -1
- package/dist/validation/build-time/transformer.d.ts +0 -23
- package/dist/validation/build-time/transformer.d.ts.map +0 -1
- package/dist/validation/build-time/types.d.ts +0 -212
- package/dist/validation/build-time/types.d.ts.map +0 -1
- package/dist/validation/comprehensive.d.ts +0 -160
- package/dist/validation/comprehensive.d.ts.map +0 -1
- package/dist/validation/debug-tools.d.ts +0 -251
- package/dist/validation/debug-tools.d.ts.map +0 -1
- package/dist/validation/developer-experience.d.ts +0 -243
- package/dist/validation/developer-experience.d.ts.map +0 -1
- package/dist/validation/documentation-integration.d.ts +0 -269
- package/dist/validation/documentation-integration.d.ts.map +0 -1
- package/dist/validation/enhanced-runtime.d.ts +0 -279
- package/dist/validation/enhanced-runtime.d.ts.map +0 -1
- package/dist/validation/error-reporting.d.ts +0 -186
- package/dist/validation/error-reporting.d.ts.map +0 -1
- package/dist/validation/ide-integration.d.ts +0 -328
- package/dist/validation/ide-integration.d.ts.map +0 -1
- package/dist/validation/performance-optimizer.d.ts +0 -218
- package/dist/validation/performance-optimizer.d.ts.map +0 -1
- package/dist/validation/production-bypass.d.ts +0 -175
- package/dist/validation/production-bypass.d.ts.map +0 -1
- package/dist/validation/simple.d.ts +0 -111
- package/dist/validation/simple.d.ts.map +0 -1
- package/dist/viewport/adapters/web-adapter.d.ts +0 -227
- package/dist/viewport/adapters/web-adapter.d.ts.map +0 -1
- package/dist/viewport/components.d.ts +0 -131
- package/dist/viewport/components.d.ts.map +0 -1
- package/dist/viewport/environment.d.ts +0 -75
- package/dist/viewport/environment.d.ts.map +0 -1
- package/dist/viewport/index.d.ts +0 -138
- package/dist/viewport/index.d.ts.map +0 -1
- package/dist/viewport/index.js +0 -2085
- package/dist/viewport/platform-detection.d.ts +0 -59
- package/dist/viewport/platform-detection.d.ts.map +0 -1
- package/dist/viewport/types.d.ts +0 -301
- package/dist/viewport/types.d.ts.map +0 -1
- package/dist/viewport/viewport-manager.d.ts +0 -118
- package/dist/viewport/viewport-manager.d.ts.map +0 -1
|
@@ -0,0 +1,1680 @@
|
|
|
1
|
+
import * as l from "typescript";
|
|
2
|
+
var E = Object.defineProperty, $ = (a, e, t) => e in a ? E(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t, u = (a, e, t) => $(a, typeof e != "symbol" ? e + "" : e, t);
|
|
3
|
+
class b {
|
|
4
|
+
constructor(e, t) {
|
|
5
|
+
u(this, "code"), u(this, "filename"), u(this, "position", 0), u(this, "line", 1), u(this, "column", 1), this.code = e, this.filename = t;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Parse advanced SwiftUI syntax into enhanced AST
|
|
9
|
+
*/
|
|
10
|
+
parse() {
|
|
11
|
+
const e = [];
|
|
12
|
+
for (; !this.isAtEnd() && (this.skipWhitespace(), !this.isAtEnd()); ) {
|
|
13
|
+
const t = this.parseAdvancedNode();
|
|
14
|
+
t && e.push(t);
|
|
15
|
+
}
|
|
16
|
+
return e;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parse advanced AST nodes including conditionals and loops
|
|
20
|
+
*/
|
|
21
|
+
parseAdvancedNode() {
|
|
22
|
+
const e = this.currentPosition(), t = this.position;
|
|
23
|
+
return this.match("if") ? this.parseConditional(e) : this.match("ForEach") ? this.parseForEach(e) : this.peek() === "@" ? this.parsePropertyWrapper(e) : this.peek() === "$" ? this.parseStateBinding(e) : this.isComponentStart() ? this.parseEnhancedComponent(e) : (this.position === t && this.advance(), null);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parse conditional rendering (if/else)
|
|
27
|
+
*/
|
|
28
|
+
parseConditional(e) {
|
|
29
|
+
this.skipWhitespace();
|
|
30
|
+
const t = this.parseComplexExpression();
|
|
31
|
+
if (!t)
|
|
32
|
+
throw new Error(`Expected condition after 'if' at line ${this.line}`);
|
|
33
|
+
this.skipWhitespace();
|
|
34
|
+
const i = [];
|
|
35
|
+
if (this.peek() === "{") {
|
|
36
|
+
for (this.advance(), this.skipWhitespace(); !this.isAtEnd() && this.peek() !== "}"; ) {
|
|
37
|
+
const r = this.parseAdvancedNode();
|
|
38
|
+
r && i.push(r), this.skipWhitespace();
|
|
39
|
+
}
|
|
40
|
+
this.peek() === "}" && this.advance();
|
|
41
|
+
}
|
|
42
|
+
let n;
|
|
43
|
+
if (this.skipWhitespace(), this.match("else") && (n = [], this.skipWhitespace(), this.peek() === "{")) {
|
|
44
|
+
for (this.advance(), this.skipWhitespace(); !this.isAtEnd() && this.peek() !== "}"; ) {
|
|
45
|
+
const r = this.parseAdvancedNode();
|
|
46
|
+
r && n.push(r), this.skipWhitespace();
|
|
47
|
+
}
|
|
48
|
+
this.peek() === "}" && this.advance();
|
|
49
|
+
}
|
|
50
|
+
const s = {
|
|
51
|
+
type: "Conditional",
|
|
52
|
+
condition: t,
|
|
53
|
+
thenBody: i,
|
|
54
|
+
loc: {
|
|
55
|
+
start: e,
|
|
56
|
+
end: this.currentPosition(),
|
|
57
|
+
source: this.filename
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return n !== void 0 && (s.elseBody = n), s;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Parse ForEach loops for list rendering
|
|
64
|
+
*/
|
|
65
|
+
parseForEach(e) {
|
|
66
|
+
if (this.skipWhitespace(), this.peek() !== "(")
|
|
67
|
+
throw new Error(`Expected '(' after ForEach at line ${this.line}`);
|
|
68
|
+
this.advance(), this.skipWhitespace();
|
|
69
|
+
const t = this.parseComplexExpression();
|
|
70
|
+
if (!t)
|
|
71
|
+
throw new Error(
|
|
72
|
+
`Expected iterable expression in ForEach at line ${this.line}`
|
|
73
|
+
);
|
|
74
|
+
this.skipWhitespace(), this.peek() === "," && (this.advance(), this.skipWhitespace()), this.match("id:") && (this.skipWhitespace(), this.parseComplexExpression()), this.skipWhitespace(), this.peek() === ")" && this.advance(), this.skipWhitespace();
|
|
75
|
+
let i = "item";
|
|
76
|
+
if (this.peek() === "{") {
|
|
77
|
+
this.advance(), this.skipWhitespace();
|
|
78
|
+
const s = this.position, r = this.parseIdentifier();
|
|
79
|
+
r && this.match("in") ? i = r : this.position = s;
|
|
80
|
+
}
|
|
81
|
+
const n = [];
|
|
82
|
+
for (; !this.isAtEnd() && this.peek() !== "}"; ) {
|
|
83
|
+
const s = this.parseAdvancedNode();
|
|
84
|
+
s && n.push(s), this.skipWhitespace();
|
|
85
|
+
}
|
|
86
|
+
return this.peek() === "}" && this.advance(), {
|
|
87
|
+
type: "ForEach",
|
|
88
|
+
iterable: t,
|
|
89
|
+
itemIdentifier: i,
|
|
90
|
+
body: n,
|
|
91
|
+
loc: {
|
|
92
|
+
start: e,
|
|
93
|
+
end: this.currentPosition(),
|
|
94
|
+
source: this.filename
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Parse property wrappers (@State, @Computed, etc.)
|
|
100
|
+
*/
|
|
101
|
+
parsePropertyWrapper(e) {
|
|
102
|
+
this.advance();
|
|
103
|
+
const t = this.parseIdentifier();
|
|
104
|
+
if (!t || !["State", "Computed", "Effect"].includes(t))
|
|
105
|
+
throw new Error(
|
|
106
|
+
`Unknown property wrapper @${t} at line ${this.line}`
|
|
107
|
+
);
|
|
108
|
+
this.skipWhitespace();
|
|
109
|
+
const i = this.parseIdentifier();
|
|
110
|
+
if (!i)
|
|
111
|
+
throw new Error(
|
|
112
|
+
`Expected identifier after @${t} at line ${this.line}`
|
|
113
|
+
);
|
|
114
|
+
let n;
|
|
115
|
+
if (this.skipWhitespace(), this.peek() === "=") {
|
|
116
|
+
this.advance(), this.skipWhitespace();
|
|
117
|
+
const r = this.parseComplexExpression();
|
|
118
|
+
r && (n = r);
|
|
119
|
+
}
|
|
120
|
+
const s = {
|
|
121
|
+
type: "PropertyWrapper",
|
|
122
|
+
wrapper: t,
|
|
123
|
+
identifier: i,
|
|
124
|
+
loc: {
|
|
125
|
+
start: e,
|
|
126
|
+
end: this.currentPosition(),
|
|
127
|
+
source: this.filename
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
return n !== void 0 && (s.initialValue = n), s;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Parse state bindings ($variable)
|
|
134
|
+
*/
|
|
135
|
+
parseStateBinding(e) {
|
|
136
|
+
this.advance();
|
|
137
|
+
const t = this.parseIdentifier();
|
|
138
|
+
if (!t)
|
|
139
|
+
throw new Error(`Expected identifier after '$' at line ${this.line}`);
|
|
140
|
+
return {
|
|
141
|
+
type: "StateBinding",
|
|
142
|
+
identifier: t,
|
|
143
|
+
loc: {
|
|
144
|
+
start: e,
|
|
145
|
+
end: this.currentPosition(),
|
|
146
|
+
source: this.filename
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Parse enhanced components with complex modifier chains
|
|
152
|
+
*/
|
|
153
|
+
parseEnhancedComponent(e) {
|
|
154
|
+
const t = this.parseIdentifier();
|
|
155
|
+
this.skipWhitespace();
|
|
156
|
+
const i = [], n = [];
|
|
157
|
+
if (this.peek() === "(") {
|
|
158
|
+
for (this.advance(), this.skipWhitespace(); !this.isAtEnd() && this.peek() !== ")"; ) {
|
|
159
|
+
const s = this.parseComplexExpression();
|
|
160
|
+
s && i.push(s), this.skipWhitespace(), this.peek() === "," && (this.advance(), this.skipWhitespace());
|
|
161
|
+
}
|
|
162
|
+
this.peek() === ")" && this.advance();
|
|
163
|
+
} else if (this.peek() === "{") {
|
|
164
|
+
for (this.advance(), this.skipWhitespace(); !this.isAtEnd() && this.peek() !== "}"; ) {
|
|
165
|
+
const s = this.parseAdvancedNode();
|
|
166
|
+
s && i.push(s), this.skipWhitespace();
|
|
167
|
+
}
|
|
168
|
+
this.peek() === "}" && this.advance();
|
|
169
|
+
}
|
|
170
|
+
for (this.skipWhitespace(); this.peek() === "."; ) {
|
|
171
|
+
const s = this.parseAdvancedModifier();
|
|
172
|
+
s && n.push(s), this.skipWhitespace();
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
type: "Component",
|
|
176
|
+
name: t,
|
|
177
|
+
children: i,
|
|
178
|
+
modifiers: n,
|
|
179
|
+
loc: {
|
|
180
|
+
start: e,
|
|
181
|
+
end: this.currentPosition(),
|
|
182
|
+
source: this.filename
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Parse advanced modifiers with complex expressions
|
|
188
|
+
*/
|
|
189
|
+
parseAdvancedModifier() {
|
|
190
|
+
if (this.peek() !== ".") return null;
|
|
191
|
+
const e = this.currentPosition();
|
|
192
|
+
this.advance();
|
|
193
|
+
const t = this.parseIdentifier();
|
|
194
|
+
if (!t) return null;
|
|
195
|
+
const i = [];
|
|
196
|
+
if (this.peek() === "(") {
|
|
197
|
+
for (this.advance(), this.skipWhitespace(); !this.isAtEnd() && this.peek() !== ")"; ) {
|
|
198
|
+
const n = this.parseComplexExpression();
|
|
199
|
+
n && i.push(n), this.skipWhitespace(), this.peek() === "," && (this.advance(), this.skipWhitespace());
|
|
200
|
+
}
|
|
201
|
+
this.peek() === ")" && this.advance();
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
type: "Modifier",
|
|
205
|
+
name: t,
|
|
206
|
+
arguments: i,
|
|
207
|
+
loc: {
|
|
208
|
+
start: e,
|
|
209
|
+
end: this.currentPosition(),
|
|
210
|
+
source: this.filename
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Parse complex expressions including function calls, property access, etc.
|
|
216
|
+
*/
|
|
217
|
+
parseComplexExpression() {
|
|
218
|
+
this.skipWhitespace();
|
|
219
|
+
const e = this.currentPosition();
|
|
220
|
+
if (this.peek() === '"' || this.peek() === "'")
|
|
221
|
+
return this.parseStringLiteral(e);
|
|
222
|
+
if (this.isDigit(this.peek()))
|
|
223
|
+
return this.parseNumberLiteral(e);
|
|
224
|
+
if (this.match("true") || this.match("false") || this.match("null")) {
|
|
225
|
+
const i = this.code.slice(e.offset, this.position);
|
|
226
|
+
return {
|
|
227
|
+
type: "Literal",
|
|
228
|
+
value: i === "true" ? !0 : i === "false" ? !1 : null,
|
|
229
|
+
raw: i,
|
|
230
|
+
loc: {
|
|
231
|
+
start: e,
|
|
232
|
+
end: this.currentPosition(),
|
|
233
|
+
source: this.filename
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const t = this.parseIdentifier();
|
|
238
|
+
return t ? (this.skipWhitespace(), this.peek() === "(" ? this.parseFunctionCall(t, e) : this.peek() === "." ? this.parsePropertyAccess(t, e) : {
|
|
239
|
+
type: "Identifier",
|
|
240
|
+
name: t,
|
|
241
|
+
loc: {
|
|
242
|
+
start: e,
|
|
243
|
+
end: this.currentPosition(),
|
|
244
|
+
source: this.filename
|
|
245
|
+
}
|
|
246
|
+
}) : this.peek() === "[" ? this.parseArrayLiteral(e) : null;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Parse function calls with arguments
|
|
250
|
+
*/
|
|
251
|
+
parseFunctionCall(e, t) {
|
|
252
|
+
this.advance(), this.skipWhitespace();
|
|
253
|
+
const i = [];
|
|
254
|
+
for (; !this.isAtEnd() && this.peek() !== ")"; ) {
|
|
255
|
+
const n = this.parseComplexExpression();
|
|
256
|
+
n && i.push(n), this.skipWhitespace(), this.peek() === "," && (this.advance(), this.skipWhitespace());
|
|
257
|
+
}
|
|
258
|
+
return this.peek() === ")" && this.advance(), {
|
|
259
|
+
type: "CallExpression",
|
|
260
|
+
callee: { type: "Identifier", name: e },
|
|
261
|
+
arguments: i,
|
|
262
|
+
loc: {
|
|
263
|
+
start: t,
|
|
264
|
+
end: this.currentPosition(),
|
|
265
|
+
source: this.filename
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Parse property access (obj.prop)
|
|
271
|
+
*/
|
|
272
|
+
parsePropertyAccess(e, t) {
|
|
273
|
+
let i = e;
|
|
274
|
+
for (; this.peek() === "."; ) {
|
|
275
|
+
this.advance();
|
|
276
|
+
const n = this.parseIdentifier();
|
|
277
|
+
n && (i = `${i}.${n}`);
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
type: "MemberExpression",
|
|
281
|
+
object: e,
|
|
282
|
+
property: i.split(".").slice(1).join("."),
|
|
283
|
+
loc: {
|
|
284
|
+
start: t,
|
|
285
|
+
end: this.currentPosition(),
|
|
286
|
+
source: this.filename
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Parse array literals [1, 2, 3]
|
|
292
|
+
*/
|
|
293
|
+
parseArrayLiteral(e) {
|
|
294
|
+
this.advance(), this.skipWhitespace();
|
|
295
|
+
const t = [];
|
|
296
|
+
for (; !this.isAtEnd() && this.peek() !== "]"; ) {
|
|
297
|
+
const i = this.parseComplexExpression();
|
|
298
|
+
i && t.push(i), this.skipWhitespace(), this.peek() === "," && (this.advance(), this.skipWhitespace());
|
|
299
|
+
}
|
|
300
|
+
return this.peek() === "]" && this.advance(), {
|
|
301
|
+
type: "ArrayExpression",
|
|
302
|
+
elements: t,
|
|
303
|
+
loc: {
|
|
304
|
+
start: e,
|
|
305
|
+
end: this.currentPosition(),
|
|
306
|
+
source: this.filename
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
// Helper methods (reuse from basic parser with enhancements)
|
|
311
|
+
parseStringLiteral(e) {
|
|
312
|
+
const t = this.peek();
|
|
313
|
+
this.advance();
|
|
314
|
+
let i = "";
|
|
315
|
+
for (; !this.isAtEnd() && this.peek() !== t; )
|
|
316
|
+
if (this.peek() === "\\") {
|
|
317
|
+
this.advance();
|
|
318
|
+
const n = this.peek();
|
|
319
|
+
switch (n) {
|
|
320
|
+
case "n":
|
|
321
|
+
i += `
|
|
322
|
+
`;
|
|
323
|
+
break;
|
|
324
|
+
case "t":
|
|
325
|
+
i += " ";
|
|
326
|
+
break;
|
|
327
|
+
case "r":
|
|
328
|
+
i += "\r";
|
|
329
|
+
break;
|
|
330
|
+
case "\\":
|
|
331
|
+
i += "\\";
|
|
332
|
+
break;
|
|
333
|
+
case '"':
|
|
334
|
+
i += '"';
|
|
335
|
+
break;
|
|
336
|
+
case "'":
|
|
337
|
+
i += "'";
|
|
338
|
+
break;
|
|
339
|
+
default:
|
|
340
|
+
i += n;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
this.advance();
|
|
344
|
+
} else
|
|
345
|
+
i += this.peek(), this.advance();
|
|
346
|
+
return this.peek() === t && this.advance(), {
|
|
347
|
+
type: "Literal",
|
|
348
|
+
value: i,
|
|
349
|
+
raw: this.code.slice(e.offset, this.position),
|
|
350
|
+
loc: {
|
|
351
|
+
start: e,
|
|
352
|
+
end: this.currentPosition(),
|
|
353
|
+
source: this.filename
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
parseNumberLiteral(e) {
|
|
358
|
+
let t = "";
|
|
359
|
+
for (; !this.isAtEnd() && (this.isDigit(this.peek()) || this.peek() === "."); )
|
|
360
|
+
t += this.peek(), this.advance();
|
|
361
|
+
return {
|
|
362
|
+
type: "Literal",
|
|
363
|
+
value: t.includes(".") ? parseFloat(t) : parseInt(t, 10),
|
|
364
|
+
raw: t,
|
|
365
|
+
loc: {
|
|
366
|
+
start: e,
|
|
367
|
+
end: this.currentPosition(),
|
|
368
|
+
source: this.filename
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
parseIdentifier() {
|
|
373
|
+
if (!this.isAlpha(this.peek()) && this.peek() !== "_")
|
|
374
|
+
return null;
|
|
375
|
+
let e = "";
|
|
376
|
+
for (; !this.isAtEnd() && (this.isAlphaNumeric(this.peek()) || this.peek() === "_"); )
|
|
377
|
+
e += this.peek(), this.advance();
|
|
378
|
+
return e;
|
|
379
|
+
}
|
|
380
|
+
// Utility methods
|
|
381
|
+
isComponentStart() {
|
|
382
|
+
const e = this.position, t = this.line, i = this.column, n = this.parseIdentifier();
|
|
383
|
+
return this.position = e, this.line = t, this.column = i, n ? [
|
|
384
|
+
"VStack",
|
|
385
|
+
"HStack",
|
|
386
|
+
"ZStack",
|
|
387
|
+
"List",
|
|
388
|
+
"Form",
|
|
389
|
+
"NavigationStack",
|
|
390
|
+
"Text",
|
|
391
|
+
"Button",
|
|
392
|
+
"Image",
|
|
393
|
+
"TextField",
|
|
394
|
+
"Toggle",
|
|
395
|
+
"Slider",
|
|
396
|
+
// ScrollView moved to @tachui/mobile
|
|
397
|
+
"LazyVStack",
|
|
398
|
+
"LazyHStack"
|
|
399
|
+
].includes(n) : !1;
|
|
400
|
+
}
|
|
401
|
+
match(e) {
|
|
402
|
+
return this.code.slice(this.position, this.position + e.length) === e ? (this.position += e.length, this.column += e.length, !0) : !1;
|
|
403
|
+
}
|
|
404
|
+
skipWhitespace() {
|
|
405
|
+
for (; !this.isAtEnd() && this.isWhitespace(this.peek()); )
|
|
406
|
+
this.peek() === `
|
|
407
|
+
` ? (this.line++, this.column = 1) : this.column++, this.position++;
|
|
408
|
+
}
|
|
409
|
+
peek() {
|
|
410
|
+
return this.isAtEnd() ? "\0" : this.code[this.position];
|
|
411
|
+
}
|
|
412
|
+
advance() {
|
|
413
|
+
const e = this.peek();
|
|
414
|
+
return this.isAtEnd() || (this.position++, e === `
|
|
415
|
+
` ? (this.line++, this.column = 1) : this.column++), e;
|
|
416
|
+
}
|
|
417
|
+
isAtEnd() {
|
|
418
|
+
return this.position >= this.code.length;
|
|
419
|
+
}
|
|
420
|
+
isWhitespace(e) {
|
|
421
|
+
return /\s/.test(e);
|
|
422
|
+
}
|
|
423
|
+
isAlpha(e) {
|
|
424
|
+
return /[a-zA-Z]/.test(e);
|
|
425
|
+
}
|
|
426
|
+
isDigit(e) {
|
|
427
|
+
return /[0-9]/.test(e);
|
|
428
|
+
}
|
|
429
|
+
isAlphaNumeric(e) {
|
|
430
|
+
return this.isAlpha(e) || this.isDigit(e);
|
|
431
|
+
}
|
|
432
|
+
currentPosition() {
|
|
433
|
+
return {
|
|
434
|
+
line: this.line,
|
|
435
|
+
column: this.column,
|
|
436
|
+
offset: this.position
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
function K(a, e) {
|
|
441
|
+
return new b(a, e).parse();
|
|
442
|
+
}
|
|
443
|
+
var v = Object.defineProperty, y = (a, e, t) => e in a ? v(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t, m = (a, e, t) => y(a, typeof e != "symbol" ? e + "" : e, t);
|
|
444
|
+
function x(a, e = {}) {
|
|
445
|
+
return new S(e).generate(a);
|
|
446
|
+
}
|
|
447
|
+
class S {
|
|
448
|
+
constructor(e) {
|
|
449
|
+
m(this, "options"), m(this, "imports", /* @__PURE__ */ new Set()), m(this, "variables", []), m(this, "code", []), m(this, "indentLevel", 0), this.options = e;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Generate complete code from AST nodes
|
|
453
|
+
*/
|
|
454
|
+
generate(e) {
|
|
455
|
+
return this.reset(), this.addImport("createSignal", "@tachui/core/reactive"), this.addImport("createEffect", "@tachui/core/reactive"), this.addImport("createComputed", "@tachui/core/reactive"), e.forEach((i) => this.generateNode(i)), {
|
|
456
|
+
code: this.buildFinalCode(),
|
|
457
|
+
map: this.options.sourceMaps ? this.generateSourceMap() : void 0
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Generate code for a single AST node
|
|
462
|
+
*/
|
|
463
|
+
generateNode(e) {
|
|
464
|
+
switch (e.type) {
|
|
465
|
+
case "Component":
|
|
466
|
+
this.generateComponent(e);
|
|
467
|
+
break;
|
|
468
|
+
case "Concatenation":
|
|
469
|
+
this.generateConcatenationNode(e);
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Generate code for a component node
|
|
475
|
+
*/
|
|
476
|
+
generateComponent(e) {
|
|
477
|
+
switch (e.name) {
|
|
478
|
+
case "VStack":
|
|
479
|
+
case "HStack":
|
|
480
|
+
case "ZStack":
|
|
481
|
+
this.generateStackComponent(e);
|
|
482
|
+
break;
|
|
483
|
+
case "Text":
|
|
484
|
+
this.generateTextComponent(e);
|
|
485
|
+
break;
|
|
486
|
+
case "Button":
|
|
487
|
+
this.generateButtonComponent(e);
|
|
488
|
+
break;
|
|
489
|
+
case "List":
|
|
490
|
+
this.generateListComponent(e);
|
|
491
|
+
break;
|
|
492
|
+
default:
|
|
493
|
+
this.generateGenericComponent(e);
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Generate code for stack components (VStack, HStack, ZStack)
|
|
499
|
+
*/
|
|
500
|
+
generateStackComponent(e) {
|
|
501
|
+
const t = e.name.toLowerCase().replace("stack", ""), i = this.createVariable("container");
|
|
502
|
+
this.addLine(`// ${e.name} component`), this.addLine(`const ${i} = document.createElement('div')`), this.addLine(
|
|
503
|
+
`${i}.className = 'tachui-${t} ${this.generateStackClasses(e.name)}'`
|
|
504
|
+
);
|
|
505
|
+
const n = this.generateModifierStyles(e.modifiers);
|
|
506
|
+
n.length > 0 && (this.addLine(`Object.assign(${i}.style, {`), this.indent(), n.forEach((s) => this.addLine(`${s},`)), this.dedent(), this.addLine("})")), e.children.forEach((s) => {
|
|
507
|
+
this.generateNode(s);
|
|
508
|
+
const r = this.getLastVariable();
|
|
509
|
+
r && this.addLine(`${i}.appendChild(${r})`);
|
|
510
|
+
}), this.addEmptyLine();
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Generate code for Text component
|
|
514
|
+
*/
|
|
515
|
+
generateTextComponent(e) {
|
|
516
|
+
const t = this.createVariable("textElement"), i = this.getTextContent(e.children);
|
|
517
|
+
this.addLine("// Text component"), this.addLine(`const ${t} = document.createElement('span')`), this.addLine(`${t}.className = 'tachui-text'`), this.isReactiveExpression(i) ? (this.addLine("createEffect(() => {"), this.indent(), this.addLine(`${t}.textContent = ${i}`), this.dedent(), this.addLine("})")) : this.addLine(`${t}.textContent = ${i}`);
|
|
518
|
+
const n = this.generateModifierStyles(e.modifiers);
|
|
519
|
+
n.length > 0 && (this.addLine(`Object.assign(${t}.style, {`), this.indent(), n.forEach((s) => this.addLine(`${s},`)), this.dedent(), this.addLine("})")), this.addEmptyLine();
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Generate code for Button component
|
|
523
|
+
*/
|
|
524
|
+
generateButtonComponent(e) {
|
|
525
|
+
const t = this.createVariable("buttonElement"), i = this.getTextContent(e.children);
|
|
526
|
+
this.addLine("// Button component"), this.addLine(`const ${t} = document.createElement('button')`), this.addLine(`${t}.className = 'tachui-button'`), this.addLine(`${t}.textContent = ${i}`);
|
|
527
|
+
const n = this.generateModifierStyles(e.modifiers), s = this.generateEventHandlers(e.modifiers);
|
|
528
|
+
n.length > 0 && (this.addLine(`Object.assign(${t}.style, {`), this.indent(), n.forEach((r) => this.addLine(`${r},`)), this.dedent(), this.addLine("})")), s.forEach((r) => this.addLine(r)), this.addEmptyLine();
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Generate code for List component
|
|
532
|
+
*/
|
|
533
|
+
generateListComponent(e) {
|
|
534
|
+
const t = this.createVariable("listElement");
|
|
535
|
+
this.addLine("// List component"), this.addLine(`const ${t} = document.createElement('div')`), this.addLine(`${t}.className = 'tachui-list'`), e.children.forEach((i) => {
|
|
536
|
+
this.generateNode(i);
|
|
537
|
+
const n = this.getLastVariable();
|
|
538
|
+
n && this.addLine(`${t}.appendChild(${n})`);
|
|
539
|
+
}), this.addEmptyLine();
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Generate code for generic/custom components
|
|
543
|
+
*/
|
|
544
|
+
generateGenericComponent(e) {
|
|
545
|
+
const t = this.createVariable("element");
|
|
546
|
+
this.addLine(`// ${e.name} component`), this.addLine(`const ${t} = document.createElement('div')`), this.addLine(
|
|
547
|
+
`${t}.className = 'tachui-${e.name.toLowerCase()}'`
|
|
548
|
+
);
|
|
549
|
+
const i = this.generateModifierStyles(e.modifiers);
|
|
550
|
+
i.length > 0 && (this.addLine(`Object.assign(${t}.style, {`), this.indent(), i.forEach((n) => this.addLine(`${n},`)), this.dedent(), this.addLine("})")), this.addEmptyLine();
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Generate code for a concatenation node
|
|
554
|
+
*/
|
|
555
|
+
generateConcatenationNode(e) {
|
|
556
|
+
e.optimizable && e.staticContent ? this.generateOptimizedConcatenation(e) : this.generateRuntimeConcatenation(e);
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Generate optimized static concatenation code
|
|
560
|
+
*/
|
|
561
|
+
generateOptimizedConcatenation(e) {
|
|
562
|
+
const t = this.createVariable("optimizedConcat");
|
|
563
|
+
if (this.addLine("// Optimized static concatenation"), this.addLine(`const ${t} = document.createElement('span')`), this.addLine(`${t}.className = 'tachui-concatenated-optimized'`), e.staticContent) {
|
|
564
|
+
const i = e.staticContent.segments.map((s) => s.content || "").join("");
|
|
565
|
+
i && this.addLine(`${t}.textContent = "${i}"`);
|
|
566
|
+
const n = this.mergeConcatenationStyles(
|
|
567
|
+
e.staticContent.segments
|
|
568
|
+
);
|
|
569
|
+
Object.keys(n).length > 0 && (this.addLine(`Object.assign(${t}.style, {`), this.indent(), Object.entries(n).forEach(([s, r]) => {
|
|
570
|
+
this.addLine(`${s}: "${r}",`);
|
|
571
|
+
}), this.dedent(), this.addLine("})")), e.staticContent.aria.label && this.addLine(
|
|
572
|
+
`${t}.setAttribute('aria-label', "${e.staticContent.aria.label}")`
|
|
573
|
+
), e.staticContent.aria.role && e.staticContent.aria.role !== "text" && this.addLine(
|
|
574
|
+
`${t}.setAttribute('role', "${e.staticContent.aria.role}")`
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
this.addEmptyLine();
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Generate runtime concatenation fallback
|
|
581
|
+
*/
|
|
582
|
+
generateRuntimeConcatenation(e) {
|
|
583
|
+
const t = this.createVariable("runtimeConcat"), i = this.determineARIARequirement(e), n = i ? "SmartARIAConcatenatedComponent" : "MinimalConcatenatedComponent", s = i ? "@tachui/core/concatenation/smart-aria" : "@tachui/core/concatenation/minimal";
|
|
584
|
+
this.addImport(n, s), this.addLine(
|
|
585
|
+
`// Dynamic concatenation - using ${i ? "Smart ARIA" : "minimal"} runtime`
|
|
586
|
+
), this.addLine(`const ${t} = new ${n}([`), this.indent(), this.generateComponentInline(e.left);
|
|
587
|
+
const r = this.getLastVariable();
|
|
588
|
+
if (this.addLine(
|
|
589
|
+
`{ id: '${e.left.name}-left', component: ${r}, modifiers: [], render: () => ${r} },`
|
|
590
|
+
), e.right.type === "Component") {
|
|
591
|
+
this.generateComponentInline(e.right);
|
|
592
|
+
const o = this.getLastVariable();
|
|
593
|
+
this.addLine(
|
|
594
|
+
`{ id: '${e.right.name}-right', component: ${o}, modifiers: [], render: () => ${o} }`
|
|
595
|
+
);
|
|
596
|
+
} else {
|
|
597
|
+
this.generateConcatenationNode(e.right);
|
|
598
|
+
const o = this.getLastVariable();
|
|
599
|
+
this.addLine(`${o}.toSegment()`);
|
|
600
|
+
}
|
|
601
|
+
this.dedent(), this.addLine("])"), this.addEmptyLine();
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Generate a component inline without creating separate variable
|
|
605
|
+
*/
|
|
606
|
+
generateComponentInline(e) {
|
|
607
|
+
switch (e.name) {
|
|
608
|
+
case "Text":
|
|
609
|
+
this.generateTextComponent(e);
|
|
610
|
+
break;
|
|
611
|
+
case "Button":
|
|
612
|
+
this.generateButtonComponent(e);
|
|
613
|
+
break;
|
|
614
|
+
default:
|
|
615
|
+
this.generateGenericComponent(e);
|
|
616
|
+
break;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Determine if concatenation needs ARIA runtime
|
|
621
|
+
*/
|
|
622
|
+
determineARIARequirement(e) {
|
|
623
|
+
return this.hasInteractiveComponents(e.left) || (e.right.type === "Component" ? this.hasInteractiveComponents(e.right) : e.right.optimizable === !1);
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Check if component is interactive (Button, Link, etc.)
|
|
627
|
+
*/
|
|
628
|
+
hasInteractiveComponents(e) {
|
|
629
|
+
return e.name === "Button" || e.name === "Link" || e.children.some(
|
|
630
|
+
(t) => t.type === "Component" && this.hasInteractiveComponents(t)
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Merge styles from multiple concatenated segments
|
|
635
|
+
*/
|
|
636
|
+
mergeConcatenationStyles(e) {
|
|
637
|
+
const t = {};
|
|
638
|
+
return e.forEach((i) => {
|
|
639
|
+
i.styles && Object.assign(t, i.styles);
|
|
640
|
+
}), t;
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Generate CSS classes for stack layouts
|
|
644
|
+
*/
|
|
645
|
+
generateStackClasses(e) {
|
|
646
|
+
switch (e) {
|
|
647
|
+
case "VStack":
|
|
648
|
+
return "flex flex-col";
|
|
649
|
+
case "HStack":
|
|
650
|
+
return "flex flex-row";
|
|
651
|
+
case "ZStack":
|
|
652
|
+
return "relative";
|
|
653
|
+
default:
|
|
654
|
+
return "flex";
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Generate styles from modifiers
|
|
659
|
+
*/
|
|
660
|
+
generateModifierStyles(e) {
|
|
661
|
+
const t = [];
|
|
662
|
+
return e.forEach((i) => {
|
|
663
|
+
const n = this.convertModifierToStyle(i);
|
|
664
|
+
n && t.push(n);
|
|
665
|
+
}), t;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Generate event handlers from modifiers
|
|
669
|
+
*/
|
|
670
|
+
generateEventHandlers(e) {
|
|
671
|
+
const t = [];
|
|
672
|
+
return e.forEach((i) => {
|
|
673
|
+
if (i.name === "onTapGesture" && i.arguments.length > 0) {
|
|
674
|
+
const n = this.expressionToString(i.arguments[0]);
|
|
675
|
+
t.push(
|
|
676
|
+
`${this.getLastVariable()}.addEventListener('click', ${n})`
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
}), t;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Convert modifier to CSS style property
|
|
683
|
+
*/
|
|
684
|
+
convertModifierToStyle(e) {
|
|
685
|
+
const t = e.arguments;
|
|
686
|
+
switch (e.name) {
|
|
687
|
+
case "padding":
|
|
688
|
+
return `padding: ${t.length > 0 ? this.expressionToString(t[0]) : '"8px"'}`;
|
|
689
|
+
case "background":
|
|
690
|
+
if (t.length > 0)
|
|
691
|
+
return `backgroundColor: ${this.expressionToString(t[0])}`;
|
|
692
|
+
break;
|
|
693
|
+
case "foregroundColor":
|
|
694
|
+
if (t.length > 0)
|
|
695
|
+
return `color: ${this.expressionToString(t[0])}`;
|
|
696
|
+
break;
|
|
697
|
+
case "font":
|
|
698
|
+
if (t.length > 0)
|
|
699
|
+
return `fontSize: ${this.expressionToString(t[0])}`;
|
|
700
|
+
break;
|
|
701
|
+
case "cornerRadius":
|
|
702
|
+
if (t.length > 0)
|
|
703
|
+
return `borderRadius: ${this.expressionToString(t[0])}px`;
|
|
704
|
+
break;
|
|
705
|
+
case "opacity":
|
|
706
|
+
if (t.length > 0)
|
|
707
|
+
return `opacity: ${this.expressionToString(t[0])}`;
|
|
708
|
+
break;
|
|
709
|
+
case "frame":
|
|
710
|
+
if (t.length >= 2)
|
|
711
|
+
return null;
|
|
712
|
+
break;
|
|
713
|
+
}
|
|
714
|
+
return null;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Helper methods
|
|
718
|
+
*/
|
|
719
|
+
getTextContent(e) {
|
|
720
|
+
if (e.length === 0) return '""';
|
|
721
|
+
const t = e[0];
|
|
722
|
+
return t.type === "Literal" ? `"${t.value}"` : this.expressionToString(t);
|
|
723
|
+
}
|
|
724
|
+
expressionToString(e) {
|
|
725
|
+
switch (e.type) {
|
|
726
|
+
case "Literal": {
|
|
727
|
+
const t = e;
|
|
728
|
+
return typeof t.value == "string" ? `"${t.value}"` : String(t.value);
|
|
729
|
+
}
|
|
730
|
+
case "Identifier":
|
|
731
|
+
return e.name;
|
|
732
|
+
default:
|
|
733
|
+
return '""';
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
isReactiveExpression(e) {
|
|
737
|
+
return e.includes("()") || !e.startsWith('"') && !e.match(/^\d+$/);
|
|
738
|
+
}
|
|
739
|
+
createVariable(e) {
|
|
740
|
+
const t = `${e}${this.variables.length + 1}`;
|
|
741
|
+
return this.variables.push(t), t;
|
|
742
|
+
}
|
|
743
|
+
getLastVariable() {
|
|
744
|
+
return this.variables.length > 0 ? this.variables[this.variables.length - 1] : null;
|
|
745
|
+
}
|
|
746
|
+
addImport(e, t) {
|
|
747
|
+
this.imports.add(`import { ${e} } from '${t}'`);
|
|
748
|
+
}
|
|
749
|
+
addLine(e) {
|
|
750
|
+
const t = " ".repeat(this.indentLevel);
|
|
751
|
+
this.code.push(t + e);
|
|
752
|
+
}
|
|
753
|
+
addEmptyLine() {
|
|
754
|
+
this.code.push("");
|
|
755
|
+
}
|
|
756
|
+
indent() {
|
|
757
|
+
this.indentLevel++;
|
|
758
|
+
}
|
|
759
|
+
dedent() {
|
|
760
|
+
this.indentLevel = Math.max(0, this.indentLevel - 1);
|
|
761
|
+
}
|
|
762
|
+
buildFinalCode() {
|
|
763
|
+
const e = Array.from(this.imports).join(`
|
|
764
|
+
`), t = this.code.join(`
|
|
765
|
+
`);
|
|
766
|
+
return `${e}
|
|
767
|
+
|
|
768
|
+
${t}`;
|
|
769
|
+
}
|
|
770
|
+
generateSourceMap() {
|
|
771
|
+
return null;
|
|
772
|
+
}
|
|
773
|
+
reset() {
|
|
774
|
+
this.imports.clear(), this.variables = [], this.code = [], this.indentLevel = 0;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
var w = Object.defineProperty, A = (a, e, t) => e in a ? w(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t, p = (a, e, t) => A(a, typeof e != "symbol" ? e + "" : e, t);
|
|
778
|
+
class T {
|
|
779
|
+
constructor(e) {
|
|
780
|
+
p(this, "options"), p(this, "imports", /* @__PURE__ */ new Set()), p(this, "variables", []), p(this, "code", []), p(this, "indentLevel", 0), p(this, "dependencies", /* @__PURE__ */ new Set()), p(this, "exports", /* @__PURE__ */ new Set()), this.options = e;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Generate enhanced reactive DOM code from AST
|
|
784
|
+
*/
|
|
785
|
+
generate(e) {
|
|
786
|
+
return this.reset(), this.addImport(
|
|
787
|
+
"createSignal, createEffect, createComputed, createRoot, batch",
|
|
788
|
+
"@tachui/core/reactive"
|
|
789
|
+
), e.forEach((i) => this.generateEnhancedNode(i)), this.generateMountFunction(), {
|
|
790
|
+
code: this.buildFinalCode(),
|
|
791
|
+
map: this.options.sourceMaps ? this.generateSourceMap() : void 0,
|
|
792
|
+
dependencies: Array.from(this.dependencies),
|
|
793
|
+
exports: Array.from(this.exports)
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Generate code for enhanced AST nodes
|
|
798
|
+
*/
|
|
799
|
+
generateEnhancedNode(e) {
|
|
800
|
+
switch (e.type) {
|
|
801
|
+
case "Component":
|
|
802
|
+
this.generateEnhancedComponent(e);
|
|
803
|
+
break;
|
|
804
|
+
case "Conditional":
|
|
805
|
+
this.generateConditionalRendering(e);
|
|
806
|
+
break;
|
|
807
|
+
case "ForEach":
|
|
808
|
+
this.generateListRendering(e);
|
|
809
|
+
break;
|
|
810
|
+
case "PropertyWrapper":
|
|
811
|
+
this.generatePropertyWrapper(e);
|
|
812
|
+
break;
|
|
813
|
+
case "StateBinding":
|
|
814
|
+
this.generateStateBinding(e);
|
|
815
|
+
break;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Generate conditional rendering with reactive effects
|
|
820
|
+
*/
|
|
821
|
+
generateConditionalRendering(e) {
|
|
822
|
+
const t = this.createVariable("condition"), i = this.createVariable("conditionalContainer");
|
|
823
|
+
this.addLine("// Conditional rendering"), this.addLine(`const ${i} = document.createElement('div')`), this.addLine(`${i}.className = 'tachui-conditional'`);
|
|
824
|
+
const n = this.expressionToCode(e.condition);
|
|
825
|
+
this.addLine(`const ${t} = createComputed(() => ${n})`), this.addLine("createEffect(() => {"), this.indent(), this.addLine("// Clear previous content"), this.addLine(`${i}.innerHTML = ''`), this.addEmptyLine(), this.addLine(`if (${t}()) {`), this.indent(), this.addLine("// Render then body"), e.thenBody.forEach((s) => {
|
|
826
|
+
this.generateEnhancedNode(s);
|
|
827
|
+
const r = this.getLastVariable();
|
|
828
|
+
r && this.addLine(`${i}.appendChild(${r})`);
|
|
829
|
+
}), this.dedent(), e.elseBody && e.elseBody.length > 0 && (this.addLine("} else {"), this.indent(), this.addLine("// Render else body"), e.elseBody.forEach((s) => {
|
|
830
|
+
this.generateEnhancedNode(s);
|
|
831
|
+
const r = this.getLastVariable();
|
|
832
|
+
r && this.addLine(`${i}.appendChild(${r})`);
|
|
833
|
+
}), this.dedent()), this.addLine("}"), this.dedent(), this.addLine("})"), this.addEmptyLine();
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Generate list rendering with keyed updates
|
|
837
|
+
*/
|
|
838
|
+
generateListRendering(e) {
|
|
839
|
+
const t = this.createVariable("listContainer"), i = this.createVariable("items"), n = this.createVariable("renderedItems");
|
|
840
|
+
this.addLine("// List rendering with keyed updates"), this.addLine(`const ${t} = document.createElement('div')`), this.addLine(`${t}.className = 'tachui-list'`), this.addLine(`let ${n} = new Map()`);
|
|
841
|
+
const s = this.expressionToCode(e.iterable);
|
|
842
|
+
if (this.addLine(`const ${i} = createComputed(() => ${s})`), this.addLine("createEffect(() => {"), this.indent(), this.addLine(`const currentItems = ${i}()`), this.addLine("const newRenderedItems = new Map()"), this.addEmptyLine(), this.addLine("// Update existing items and create new ones"), this.addLine(`currentItems.forEach((${e.itemIdentifier}, index) => {`), this.indent(), this.options.generateKeyedLists) {
|
|
843
|
+
this.addLine(`const key = ${e.itemIdentifier}.id || index`), this.addLine(`let itemElement = ${n}.get(key)`), this.addEmptyLine(), this.addLine("if (!itemElement) {"), this.indent(), this.addLine("// Create new item element"), this.generateListItemContent(e);
|
|
844
|
+
const r = this.getLastVariable();
|
|
845
|
+
this.addLine(`itemElement = ${r}`), this.dedent(), this.addLine("}"), this.addEmptyLine(), this.addLine("newRenderedItems.set(key, itemElement)"), this.addLine(`${t}.appendChild(itemElement)`);
|
|
846
|
+
} else {
|
|
847
|
+
this.addLine("// Simple list item generation"), this.generateListItemContent(e);
|
|
848
|
+
const r = this.getLastVariable();
|
|
849
|
+
this.addLine(`${t}.appendChild(${r})`);
|
|
850
|
+
}
|
|
851
|
+
this.dedent(), this.addLine("})"), this.addEmptyLine(), this.options.generateKeyedLists && (this.addLine("// Remove items that are no longer in the list"), this.addLine(`${n}.forEach((element, key) => {`), this.indent(), this.addLine("if (!newRenderedItems.has(key)) {"), this.indent(), this.addLine("element.remove()"), this.dedent(), this.addLine("}"), this.dedent(), this.addLine("})"), this.addEmptyLine(), this.addLine(`${n} = newRenderedItems`)), this.dedent(), this.addLine("})"), this.addEmptyLine();
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Generate content for list items
|
|
855
|
+
*/
|
|
856
|
+
generateListItemContent(e) {
|
|
857
|
+
this.addLine("// List item content"), e.body.forEach((t) => {
|
|
858
|
+
this.generateEnhancedNode(t);
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Generate property wrapper code
|
|
863
|
+
*/
|
|
864
|
+
generatePropertyWrapper(e) {
|
|
865
|
+
const { wrapper: t, identifier: i, initialValue: n } = e;
|
|
866
|
+
switch (this.addLine(`// @${t} property wrapper`), t) {
|
|
867
|
+
case "State": {
|
|
868
|
+
const s = n ? this.expressionToCode(n) : "undefined";
|
|
869
|
+
this.addLine(
|
|
870
|
+
`const [${i}, set${this.capitalize(i)}] = createSignal(${s})`
|
|
871
|
+
), this.dependencies.add(i);
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
874
|
+
case "Computed":
|
|
875
|
+
if (n) {
|
|
876
|
+
const s = this.expressionToCode(n);
|
|
877
|
+
this.addLine(`const ${i} = createComputed(() => ${s})`), this.dependencies.add(i);
|
|
878
|
+
}
|
|
879
|
+
break;
|
|
880
|
+
case "Effect":
|
|
881
|
+
if (n) {
|
|
882
|
+
const s = this.expressionToCode(n);
|
|
883
|
+
this.addLine(`const ${i} = createEffect(() => ${s})`);
|
|
884
|
+
}
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
this.addEmptyLine();
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Generate state binding code
|
|
891
|
+
*/
|
|
892
|
+
generateStateBinding(e) {
|
|
893
|
+
this.addLine(`// State binding: $${e.identifier}`), this.addLine(`const ${e.identifier}Binding = {`), this.indent(), this.addLine(`get: () => ${e.identifier}(),`), this.addLine(`set: set${this.capitalize(e.identifier)}`), this.dedent(), this.addLine("}"), this.addEmptyLine();
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Generate enhanced component with reactive features
|
|
897
|
+
*/
|
|
898
|
+
generateEnhancedComponent(e) {
|
|
899
|
+
switch (e.name) {
|
|
900
|
+
case "VStack":
|
|
901
|
+
case "HStack":
|
|
902
|
+
case "ZStack":
|
|
903
|
+
this.generateEnhancedStackComponent(e);
|
|
904
|
+
break;
|
|
905
|
+
case "Text":
|
|
906
|
+
this.generateEnhancedTextComponent(e);
|
|
907
|
+
break;
|
|
908
|
+
case "Button":
|
|
909
|
+
this.generateEnhancedButtonComponent(e);
|
|
910
|
+
break;
|
|
911
|
+
case "TextField":
|
|
912
|
+
this.generateEnhancedTextFieldComponent(e);
|
|
913
|
+
break;
|
|
914
|
+
default:
|
|
915
|
+
this.generateEnhancedGenericComponent(e);
|
|
916
|
+
break;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Generate enhanced stack component with reactive children
|
|
921
|
+
*/
|
|
922
|
+
generateEnhancedStackComponent(e) {
|
|
923
|
+
const t = e.name.toLowerCase().replace("stack", ""), i = this.createVariable("container");
|
|
924
|
+
this.addLine(`// Enhanced ${e.name} component`), this.addLine(`const ${i} = document.createElement('div')`), this.addLine(
|
|
925
|
+
`${i}.className = 'tachui-${t} ${this.generateStackClasses(e.name)}'`
|
|
926
|
+
), this.addLine("// Reactive children management"), e.children.forEach((n) => {
|
|
927
|
+
this.generateEnhancedNode(n);
|
|
928
|
+
const s = this.getLastVariable();
|
|
929
|
+
s && this.addLine(`${i}.appendChild(${s})`);
|
|
930
|
+
}), this.generateEnhancedModifiers(e.modifiers, i), this.addEmptyLine();
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Generate enhanced text component with reactive content
|
|
934
|
+
*/
|
|
935
|
+
generateEnhancedTextComponent(e) {
|
|
936
|
+
const t = this.createVariable("textElement"), i = this.getTextContent(e.children);
|
|
937
|
+
this.addLine("// Enhanced Text component"), this.addLine(`const ${t} = document.createElement('span')`), this.addLine(`${t}.className = 'tachui-text'`), this.isReactiveExpression(i) ? (this.addLine("createEffect(() => {"), this.indent(), this.addLine(`${t}.textContent = String(${i})`), this.dedent(), this.addLine("})")) : this.addLine(`${t}.textContent = ${i}`), this.generateEnhancedModifiers(e.modifiers, t), this.addEmptyLine();
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Generate enhanced button component
|
|
941
|
+
*/
|
|
942
|
+
generateEnhancedButtonComponent(e) {
|
|
943
|
+
const t = this.createVariable("buttonElement"), i = this.getTextContent(e.children);
|
|
944
|
+
this.addLine("// Enhanced Button component"), this.addLine(`const ${t} = document.createElement('button')`), this.addLine(`${t}.className = 'tachui-button'`), this.isReactiveExpression(i) ? (this.addLine("createEffect(() => {"), this.indent(), this.addLine(`${t}.textContent = String(${i})`), this.dedent(), this.addLine("})")) : this.addLine(`${t}.textContent = ${i}`), this.generateEnhancedModifiers(e.modifiers, t), this.addEmptyLine();
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Generate enhanced TextField component with two-way binding
|
|
948
|
+
*/
|
|
949
|
+
generateEnhancedTextFieldComponent(e) {
|
|
950
|
+
const t = this.createVariable("textFieldElement"), i = e.children.length > 0 ? this.getTextContent([e.children[0]]) : '""';
|
|
951
|
+
this.addLine("// Enhanced TextField component"), this.addLine(`const ${t} = document.createElement('input')`), this.addLine(`${t}.type = 'text'`), this.addLine(`${t}.className = 'tachui-textfield'`), this.addLine(`${t}.placeholder = ${i}`);
|
|
952
|
+
const n = e.children.find((s) => s.type === "StateBinding");
|
|
953
|
+
n && (this.addLine("// Two-way data binding"), this.addLine("createEffect(() => {"), this.indent(), this.addLine(`${t}.value = String(${n.identifier}() || '')`), this.dedent(), this.addLine("})"), this.addLine(`${t}.addEventListener('input', (e) => {`), this.indent(), this.addLine(`set${this.capitalize(n.identifier)}(e.target.value)`), this.dedent(), this.addLine("})")), this.generateEnhancedModifiers(e.modifiers, t), this.addEmptyLine();
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Generate enhanced generic component
|
|
957
|
+
*/
|
|
958
|
+
generateEnhancedGenericComponent(e) {
|
|
959
|
+
const t = this.createVariable("element");
|
|
960
|
+
this.addLine(`// Enhanced ${e.name} component`), this.addLine(`const ${t} = document.createElement('div')`), this.addLine(`${t}.className = 'tachui-${e.name.toLowerCase()}'`), e.children.forEach((i) => {
|
|
961
|
+
this.generateEnhancedNode(i);
|
|
962
|
+
const n = this.getLastVariable();
|
|
963
|
+
n && this.addLine(`${t}.appendChild(${n})`);
|
|
964
|
+
}), this.generateEnhancedModifiers(e.modifiers, t), this.addEmptyLine();
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Generate enhanced modifiers with reactive updates
|
|
968
|
+
*/
|
|
969
|
+
generateEnhancedModifiers(e, t) {
|
|
970
|
+
if (e.length === 0) return;
|
|
971
|
+
const i = [], n = [], s = [];
|
|
972
|
+
e.forEach((r) => {
|
|
973
|
+
const o = this.convertModifierToStyle(r);
|
|
974
|
+
o && (this.modifierHasReactiveContent(r) ? n.push(o) : i.push(o));
|
|
975
|
+
const h = this.convertModifierToHandler(r, t);
|
|
976
|
+
h && s.push(h);
|
|
977
|
+
}), i.length > 0 && (this.addLine(`Object.assign(${t}.style, {`), this.indent(), i.forEach((r) => this.addLine(`${r},`)), this.dedent(), this.addLine("})")), n.length > 0 && (this.addLine("createEffect(() => {"), this.indent(), this.addLine(`Object.assign(${t}.style, {`), this.indent(), n.forEach((r) => this.addLine(`${r},`)), this.dedent(), this.addLine("})"), this.dedent(), this.addLine("})")), s.forEach((r) => this.addLine(r));
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Generate component mount function
|
|
981
|
+
*/
|
|
982
|
+
generateMountFunction() {
|
|
983
|
+
if (this.addLine("// Component mount function"), this.addLine("export function mountComponent(container) {"), this.indent(), this.addLine("return createRoot(() => {"), this.indent(), this.variables.length > 0) {
|
|
984
|
+
const e = this.variables[this.variables.length - 1];
|
|
985
|
+
this.addLine(`container.appendChild(${e})`), this.addLine(`return () => container.removeChild(${e})`);
|
|
986
|
+
}
|
|
987
|
+
this.dedent(), this.addLine("})"), this.dedent(), this.addLine("}"), this.exports.add("mountComponent");
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* Helper methods
|
|
991
|
+
*/
|
|
992
|
+
expressionToCode(e) {
|
|
993
|
+
switch (e.type) {
|
|
994
|
+
case "Literal": {
|
|
995
|
+
const t = e;
|
|
996
|
+
return typeof t.value == "string" ? `"${t.value}"` : String(t.value);
|
|
997
|
+
}
|
|
998
|
+
case "Identifier":
|
|
999
|
+
return e.name;
|
|
1000
|
+
case "CallExpression": {
|
|
1001
|
+
const t = e, i = t.arguments.map((n) => this.expressionToCode(n)).join(", ");
|
|
1002
|
+
return `${this.expressionToCode(t.callee)}(${i})`;
|
|
1003
|
+
}
|
|
1004
|
+
case "MemberExpression": {
|
|
1005
|
+
const t = e;
|
|
1006
|
+
return `${t.object}.${t.property}`;
|
|
1007
|
+
}
|
|
1008
|
+
case "ArrayExpression":
|
|
1009
|
+
return `[${e.elements.map((n) => this.expressionToCode(n)).join(", ")}]`;
|
|
1010
|
+
default:
|
|
1011
|
+
return '""';
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
getTextContent(e) {
|
|
1015
|
+
if (e.length === 0) return '""';
|
|
1016
|
+
const t = e[0];
|
|
1017
|
+
return t.type === "Literal" || t.type === "Identifier" || t.type === "CallExpression" || t.type === "MemberExpression" || t.type === "ArrayExpression" ? this.expressionToCode(t) : '""';
|
|
1018
|
+
}
|
|
1019
|
+
isReactiveExpression(e) {
|
|
1020
|
+
return e.includes("()") || e.includes("get") || !e.startsWith('"') && !e.match(/^\d+$/);
|
|
1021
|
+
}
|
|
1022
|
+
modifierHasReactiveContent(e) {
|
|
1023
|
+
return e.arguments.some((t) => {
|
|
1024
|
+
const i = this.expressionToCode(t);
|
|
1025
|
+
return this.isReactiveExpression(i);
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
convertModifierToStyle(e) {
|
|
1029
|
+
const t = e.arguments;
|
|
1030
|
+
switch (e.name) {
|
|
1031
|
+
case "padding":
|
|
1032
|
+
return `padding: ${t.length > 0 ? this.expressionToCode(t[0]) : '"8px"'}`;
|
|
1033
|
+
case "background":
|
|
1034
|
+
if (t.length > 0)
|
|
1035
|
+
return `backgroundColor: ${this.expressionToCode(t[0])}`;
|
|
1036
|
+
break;
|
|
1037
|
+
case "foregroundColor":
|
|
1038
|
+
if (t.length > 0)
|
|
1039
|
+
return `color: ${this.expressionToCode(t[0])}`;
|
|
1040
|
+
break;
|
|
1041
|
+
case "font":
|
|
1042
|
+
if (t.length > 0)
|
|
1043
|
+
return `fontSize: ${this.expressionToCode(t[0])}`;
|
|
1044
|
+
break;
|
|
1045
|
+
case "cornerRadius":
|
|
1046
|
+
if (t.length > 0)
|
|
1047
|
+
return `borderRadius: ${this.expressionToCode(t[0])}px`;
|
|
1048
|
+
break;
|
|
1049
|
+
case "opacity":
|
|
1050
|
+
if (t.length > 0)
|
|
1051
|
+
return `opacity: ${this.expressionToCode(t[0])}`;
|
|
1052
|
+
break;
|
|
1053
|
+
}
|
|
1054
|
+
return null;
|
|
1055
|
+
}
|
|
1056
|
+
convertModifierToHandler(e, t) {
|
|
1057
|
+
if (e.name === "onTapGesture" && e.arguments.length > 0) {
|
|
1058
|
+
const i = this.expressionToCode(e.arguments[0]);
|
|
1059
|
+
return `${t}.addEventListener('click', ${i})`;
|
|
1060
|
+
}
|
|
1061
|
+
return null;
|
|
1062
|
+
}
|
|
1063
|
+
generateStackClasses(e) {
|
|
1064
|
+
switch (e) {
|
|
1065
|
+
case "VStack":
|
|
1066
|
+
return "flex flex-col";
|
|
1067
|
+
case "HStack":
|
|
1068
|
+
return "flex flex-row";
|
|
1069
|
+
case "ZStack":
|
|
1070
|
+
return "relative";
|
|
1071
|
+
default:
|
|
1072
|
+
return "flex";
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
capitalize(e) {
|
|
1076
|
+
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1077
|
+
}
|
|
1078
|
+
createVariable(e) {
|
|
1079
|
+
const t = `${e}${this.variables.length + 1}`;
|
|
1080
|
+
return this.variables.push(t), t;
|
|
1081
|
+
}
|
|
1082
|
+
getLastVariable() {
|
|
1083
|
+
return this.variables.length > 0 ? this.variables[this.variables.length - 1] : null;
|
|
1084
|
+
}
|
|
1085
|
+
addImport(e, t) {
|
|
1086
|
+
this.imports.add(`import { ${e} } from '${t}'`);
|
|
1087
|
+
}
|
|
1088
|
+
addLine(e) {
|
|
1089
|
+
const t = " ".repeat(this.indentLevel);
|
|
1090
|
+
this.code.push(t + e);
|
|
1091
|
+
}
|
|
1092
|
+
addEmptyLine() {
|
|
1093
|
+
this.code.push("");
|
|
1094
|
+
}
|
|
1095
|
+
indent() {
|
|
1096
|
+
this.indentLevel++;
|
|
1097
|
+
}
|
|
1098
|
+
dedent() {
|
|
1099
|
+
this.indentLevel = Math.max(0, this.indentLevel - 1);
|
|
1100
|
+
}
|
|
1101
|
+
buildFinalCode() {
|
|
1102
|
+
const e = Array.from(this.imports).join(`
|
|
1103
|
+
`), t = this.code.join(`
|
|
1104
|
+
`);
|
|
1105
|
+
return `${e}
|
|
1106
|
+
|
|
1107
|
+
${t}`;
|
|
1108
|
+
}
|
|
1109
|
+
generateSourceMap() {
|
|
1110
|
+
return null;
|
|
1111
|
+
}
|
|
1112
|
+
reset() {
|
|
1113
|
+
this.imports.clear(), this.variables = [], this.code = [], this.indentLevel = 0, this.dependencies.clear(), this.exports.clear();
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
function X(a, e = {}) {
|
|
1117
|
+
return new T(e).generate(a);
|
|
1118
|
+
}
|
|
1119
|
+
var I = Object.defineProperty, V = (a, e, t) => e in a ? I(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t, f = (a, e, t) => V(a, typeof e != "symbol" ? e + "" : e, t);
|
|
1120
|
+
function P(a, e) {
|
|
1121
|
+
return new W(a, e).parse();
|
|
1122
|
+
}
|
|
1123
|
+
class W {
|
|
1124
|
+
constructor(e, t) {
|
|
1125
|
+
f(this, "code"), f(this, "filename"), f(this, "position", 0), f(this, "line", 1), f(this, "column", 1), this.code = e, this.filename = t;
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Main parsing entry point
|
|
1129
|
+
*/
|
|
1130
|
+
parse() {
|
|
1131
|
+
const e = [];
|
|
1132
|
+
for (; !this.isAtEnd() && (this.skipWhitespace(), !this.isAtEnd()); ) {
|
|
1133
|
+
const t = this.parseNode();
|
|
1134
|
+
t && e.push(t);
|
|
1135
|
+
}
|
|
1136
|
+
return e;
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Parse a single AST node
|
|
1140
|
+
*/
|
|
1141
|
+
parseNode() {
|
|
1142
|
+
const e = this.currentPosition();
|
|
1143
|
+
return this.isComponentStart() ? this.parseComponent(e) : (this.advance(), null);
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Parse a SwiftUI component (VStack, Text, Button, etc.)
|
|
1147
|
+
*/
|
|
1148
|
+
parseComponent(e) {
|
|
1149
|
+
const t = this.parseIdentifier();
|
|
1150
|
+
if (!t)
|
|
1151
|
+
throw new Error(`Expected component name at line ${this.line}`);
|
|
1152
|
+
this.skipWhitespace();
|
|
1153
|
+
const i = [], n = [];
|
|
1154
|
+
if (this.peek() === "{") {
|
|
1155
|
+
for (this.advance(), this.skipWhitespace(); !this.isAtEnd() && this.peek() !== "}"; ) {
|
|
1156
|
+
this.skipWhitespace();
|
|
1157
|
+
const r = this.parseNode();
|
|
1158
|
+
r && i.push(r);
|
|
1159
|
+
}
|
|
1160
|
+
this.peek() === "}" && this.advance();
|
|
1161
|
+
} else if (this.peek() === "(") {
|
|
1162
|
+
this.advance(), this.skipWhitespace();
|
|
1163
|
+
const r = this.parseExpression();
|
|
1164
|
+
r && i.push(r), this.skipWhitespace(), this.peek() === ")" && this.advance();
|
|
1165
|
+
}
|
|
1166
|
+
for (this.skipWhitespace(); this.peek() === "."; ) {
|
|
1167
|
+
const r = this.parseModifier();
|
|
1168
|
+
r && n.push(r), this.skipWhitespace();
|
|
1169
|
+
}
|
|
1170
|
+
const s = this.currentPosition();
|
|
1171
|
+
return {
|
|
1172
|
+
type: "Component",
|
|
1173
|
+
name: t,
|
|
1174
|
+
children: i,
|
|
1175
|
+
modifiers: n,
|
|
1176
|
+
loc: {
|
|
1177
|
+
start: e,
|
|
1178
|
+
end: s,
|
|
1179
|
+
source: this.filename
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
// Concatenation optimization methods moved to post-processing functions
|
|
1184
|
+
/**
|
|
1185
|
+
* Parse a modifier (.padding(), .background(), etc.)
|
|
1186
|
+
*/
|
|
1187
|
+
parseModifier() {
|
|
1188
|
+
if (this.peek() !== ".") return null;
|
|
1189
|
+
const e = this.currentPosition();
|
|
1190
|
+
this.advance();
|
|
1191
|
+
const t = this.parseIdentifier();
|
|
1192
|
+
if (!t) return null;
|
|
1193
|
+
const i = [];
|
|
1194
|
+
if (this.peek() === "(") {
|
|
1195
|
+
for (this.advance(), this.skipWhitespace(); !this.isAtEnd() && this.peek() !== ")"; ) {
|
|
1196
|
+
const s = this.parseExpression();
|
|
1197
|
+
s && i.push(s), this.skipWhitespace(), this.peek() === "," && (this.advance(), this.skipWhitespace());
|
|
1198
|
+
}
|
|
1199
|
+
this.peek() === ")" && this.advance();
|
|
1200
|
+
}
|
|
1201
|
+
const n = this.currentPosition();
|
|
1202
|
+
return {
|
|
1203
|
+
type: "Modifier",
|
|
1204
|
+
name: t,
|
|
1205
|
+
arguments: i,
|
|
1206
|
+
loc: {
|
|
1207
|
+
start: e,
|
|
1208
|
+
end: n,
|
|
1209
|
+
source: this.filename
|
|
1210
|
+
}
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Parse an expression (literal, identifier, function call)
|
|
1215
|
+
*/
|
|
1216
|
+
parseExpression() {
|
|
1217
|
+
this.skipWhitespace();
|
|
1218
|
+
const e = this.currentPosition();
|
|
1219
|
+
if (this.peek() === '"' || this.peek() === "'")
|
|
1220
|
+
return this.parseStringLiteral(e);
|
|
1221
|
+
if (this.isDigit(this.peek()))
|
|
1222
|
+
return this.parseNumberLiteral(e);
|
|
1223
|
+
if (this.match("true") || this.match("false")) {
|
|
1224
|
+
const i = this.code.slice(e.offset, this.position);
|
|
1225
|
+
return {
|
|
1226
|
+
type: "Literal",
|
|
1227
|
+
value: i === "true",
|
|
1228
|
+
raw: i,
|
|
1229
|
+
loc: {
|
|
1230
|
+
start: e,
|
|
1231
|
+
end: this.currentPosition(),
|
|
1232
|
+
source: this.filename
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
const t = this.parseIdentifier();
|
|
1237
|
+
if (t) {
|
|
1238
|
+
const i = this.currentPosition();
|
|
1239
|
+
return {
|
|
1240
|
+
type: "Identifier",
|
|
1241
|
+
name: t,
|
|
1242
|
+
loc: {
|
|
1243
|
+
start: e,
|
|
1244
|
+
end: i,
|
|
1245
|
+
source: this.filename
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
return null;
|
|
1250
|
+
}
|
|
1251
|
+
/**
|
|
1252
|
+
* Parse a string literal
|
|
1253
|
+
*/
|
|
1254
|
+
parseStringLiteral(e) {
|
|
1255
|
+
const t = this.peek();
|
|
1256
|
+
this.advance();
|
|
1257
|
+
let i = "";
|
|
1258
|
+
for (; !this.isAtEnd() && this.peek() !== t; )
|
|
1259
|
+
if (this.peek() === "\\") {
|
|
1260
|
+
this.advance();
|
|
1261
|
+
const s = this.peek();
|
|
1262
|
+
switch (s) {
|
|
1263
|
+
case "n":
|
|
1264
|
+
i += `
|
|
1265
|
+
`;
|
|
1266
|
+
break;
|
|
1267
|
+
case "t":
|
|
1268
|
+
i += " ";
|
|
1269
|
+
break;
|
|
1270
|
+
case "r":
|
|
1271
|
+
i += "\r";
|
|
1272
|
+
break;
|
|
1273
|
+
case "\\":
|
|
1274
|
+
i += "\\";
|
|
1275
|
+
break;
|
|
1276
|
+
case '"':
|
|
1277
|
+
i += '"';
|
|
1278
|
+
break;
|
|
1279
|
+
case "'":
|
|
1280
|
+
i += "'";
|
|
1281
|
+
break;
|
|
1282
|
+
default:
|
|
1283
|
+
i += s;
|
|
1284
|
+
break;
|
|
1285
|
+
}
|
|
1286
|
+
this.advance();
|
|
1287
|
+
} else
|
|
1288
|
+
i += this.peek(), this.advance();
|
|
1289
|
+
this.peek() === t && this.advance();
|
|
1290
|
+
const n = this.code.slice(e.offset, this.position);
|
|
1291
|
+
return {
|
|
1292
|
+
type: "Literal",
|
|
1293
|
+
value: i,
|
|
1294
|
+
raw: n,
|
|
1295
|
+
loc: {
|
|
1296
|
+
start: e,
|
|
1297
|
+
end: this.currentPosition(),
|
|
1298
|
+
source: this.filename
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Parse a number literal
|
|
1304
|
+
*/
|
|
1305
|
+
parseNumberLiteral(e) {
|
|
1306
|
+
let t = "";
|
|
1307
|
+
for (; !this.isAtEnd() && (this.isDigit(this.peek()) || this.peek() === "."); )
|
|
1308
|
+
t += this.peek(), this.advance();
|
|
1309
|
+
return {
|
|
1310
|
+
type: "Literal",
|
|
1311
|
+
value: t.includes(".") ? parseFloat(t) : parseInt(t, 10),
|
|
1312
|
+
raw: t,
|
|
1313
|
+
loc: {
|
|
1314
|
+
start: e,
|
|
1315
|
+
end: this.currentPosition(),
|
|
1316
|
+
source: this.filename
|
|
1317
|
+
}
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
/**
|
|
1321
|
+
* Parse an identifier (component name, variable name, etc.)
|
|
1322
|
+
*/
|
|
1323
|
+
parseIdentifier() {
|
|
1324
|
+
if (!this.isAlpha(this.peek()) && this.peek() !== "_")
|
|
1325
|
+
return null;
|
|
1326
|
+
let e = "";
|
|
1327
|
+
for (; !this.isAtEnd() && (this.isAlphaNumeric(this.peek()) || this.peek() === "_"); )
|
|
1328
|
+
e += this.peek(), this.advance();
|
|
1329
|
+
return e;
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* Helper methods
|
|
1333
|
+
*/
|
|
1334
|
+
isComponentStart() {
|
|
1335
|
+
const e = this.position, t = this.line, i = this.column, n = this.parseIdentifier(), s = n && this.isValidComponentName(n);
|
|
1336
|
+
return this.position = e, this.line = t, this.column = i, !!s;
|
|
1337
|
+
}
|
|
1338
|
+
isValidComponentName(e) {
|
|
1339
|
+
return [
|
|
1340
|
+
"VStack",
|
|
1341
|
+
"HStack",
|
|
1342
|
+
"ZStack",
|
|
1343
|
+
"List",
|
|
1344
|
+
"Form",
|
|
1345
|
+
"Text",
|
|
1346
|
+
"Button",
|
|
1347
|
+
"Image",
|
|
1348
|
+
"TextField",
|
|
1349
|
+
"Toggle"
|
|
1350
|
+
].includes(e);
|
|
1351
|
+
}
|
|
1352
|
+
skipWhitespace() {
|
|
1353
|
+
for (; !this.isAtEnd() && this.isWhitespace(this.peek()); )
|
|
1354
|
+
this.peek() === `
|
|
1355
|
+
` ? (this.line++, this.column = 1) : this.column++, this.position++;
|
|
1356
|
+
}
|
|
1357
|
+
match(e) {
|
|
1358
|
+
return this.code.slice(this.position, this.position + e.length) === e ? (this.position += e.length, this.column += e.length, !0) : !1;
|
|
1359
|
+
}
|
|
1360
|
+
peek() {
|
|
1361
|
+
return this.isAtEnd() ? "\0" : this.code[this.position];
|
|
1362
|
+
}
|
|
1363
|
+
advance() {
|
|
1364
|
+
const e = this.peek();
|
|
1365
|
+
return this.isAtEnd() || (this.position++, e === `
|
|
1366
|
+
` ? (this.line++, this.column = 1) : this.column++), e;
|
|
1367
|
+
}
|
|
1368
|
+
isAtEnd() {
|
|
1369
|
+
return this.position >= this.code.length;
|
|
1370
|
+
}
|
|
1371
|
+
isWhitespace(e) {
|
|
1372
|
+
return /\s/.test(e);
|
|
1373
|
+
}
|
|
1374
|
+
isAlpha(e) {
|
|
1375
|
+
return /[a-zA-Z]/.test(e);
|
|
1376
|
+
}
|
|
1377
|
+
isDigit(e) {
|
|
1378
|
+
return /[0-9]/.test(e);
|
|
1379
|
+
}
|
|
1380
|
+
isAlphaNumeric(e) {
|
|
1381
|
+
return this.isAlpha(e) || this.isDigit(e);
|
|
1382
|
+
}
|
|
1383
|
+
currentPosition() {
|
|
1384
|
+
return {
|
|
1385
|
+
line: this.line,
|
|
1386
|
+
column: this.column,
|
|
1387
|
+
offset: this.position
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
function J(a = {}) {
|
|
1392
|
+
const {
|
|
1393
|
+
include: e = [".tsx", ".ts"],
|
|
1394
|
+
exclude: t = ["node_modules/**", "**/*.test.*", "**/*.bench.*"],
|
|
1395
|
+
dev: i = process.env.NODE_ENV === "development",
|
|
1396
|
+
transform: n = {}
|
|
1397
|
+
} = a;
|
|
1398
|
+
return {
|
|
1399
|
+
name: "tachui-transform",
|
|
1400
|
+
enforce: "pre",
|
|
1401
|
+
// Run before other plugins
|
|
1402
|
+
configResolved(s) {
|
|
1403
|
+
i && s.command === "serve" && console.log("🚀 TachUI plugin loaded in development mode");
|
|
1404
|
+
},
|
|
1405
|
+
buildStart() {
|
|
1406
|
+
this.addWatchFile("tachui.config.ts");
|
|
1407
|
+
},
|
|
1408
|
+
resolveId(s) {
|
|
1409
|
+
return s === "virtual:tachui-runtime" ? s : null;
|
|
1410
|
+
},
|
|
1411
|
+
load(s) {
|
|
1412
|
+
return s === "virtual:tachui-runtime" ? q() : null;
|
|
1413
|
+
},
|
|
1414
|
+
transform(s, r) {
|
|
1415
|
+
if (!Z(r, e, t))
|
|
1416
|
+
return null;
|
|
1417
|
+
try {
|
|
1418
|
+
let o = s, h = !1;
|
|
1419
|
+
const d = N(s, r);
|
|
1420
|
+
if (d.length > 0) {
|
|
1421
|
+
const c = R(
|
|
1422
|
+
d,
|
|
1423
|
+
r
|
|
1424
|
+
);
|
|
1425
|
+
z(c, r, i), o = U(
|
|
1426
|
+
o,
|
|
1427
|
+
d
|
|
1428
|
+
), h = !0, i && (global.__tachui_optimization_data = global.__tachui_optimization_data || [], global.__tachui_optimization_data.push({
|
|
1429
|
+
filename: r,
|
|
1430
|
+
patterns: d,
|
|
1431
|
+
report: c,
|
|
1432
|
+
timestamp: Date.now()
|
|
1433
|
+
}));
|
|
1434
|
+
}
|
|
1435
|
+
if (G(o)) {
|
|
1436
|
+
i && d.length === 0 && console.log(`🔄 Transforming SwiftUI syntax: ${r}`);
|
|
1437
|
+
const c = P(o, r), g = x(c, {
|
|
1438
|
+
...n,
|
|
1439
|
+
sourceFile: r,
|
|
1440
|
+
sourceMaps: n.sourceMaps ?? i
|
|
1441
|
+
});
|
|
1442
|
+
return {
|
|
1443
|
+
code: g.code,
|
|
1444
|
+
map: g.map
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1447
|
+
return h ? {
|
|
1448
|
+
code: o,
|
|
1449
|
+
map: null
|
|
1450
|
+
// TODO: Generate source maps for concatenation transformations
|
|
1451
|
+
} : null;
|
|
1452
|
+
} catch (o) {
|
|
1453
|
+
const h = o instanceof Error ? o.message : String(o);
|
|
1454
|
+
return this.error(`TachUI transformation failed in ${r}: ${h}`), null;
|
|
1455
|
+
}
|
|
1456
|
+
},
|
|
1457
|
+
handleHotUpdate(s) {
|
|
1458
|
+
if (s.file.endsWith(".tui.tsx") || s.file.endsWith(".tui.ts"))
|
|
1459
|
+
return s.server.ws.send({
|
|
1460
|
+
type: "full-reload"
|
|
1461
|
+
}), [];
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
function N(a, e) {
|
|
1466
|
+
const t = [];
|
|
1467
|
+
try {
|
|
1468
|
+
let i = function(s) {
|
|
1469
|
+
if (l.isCallExpression(s) && l.isPropertyAccessExpression(s.expression) && s.expression.name.text === "concat") {
|
|
1470
|
+
const r = s.expression.expression;
|
|
1471
|
+
if (l.isCallExpression(r) && l.isPropertyAccessExpression(r.expression) && r.expression.name.text === "build") {
|
|
1472
|
+
const o = r.expression.expression, h = k(o, a), d = s.arguments.length > 0 ? k(s.arguments[0], a) : "";
|
|
1473
|
+
if (h && d) {
|
|
1474
|
+
const c = s.getStart(n), g = s.getEnd(), L = O(
|
|
1475
|
+
h,
|
|
1476
|
+
d
|
|
1477
|
+
), C = H(
|
|
1478
|
+
h,
|
|
1479
|
+
d,
|
|
1480
|
+
a
|
|
1481
|
+
);
|
|
1482
|
+
t.push({
|
|
1483
|
+
type: L ? "static" : "dynamic",
|
|
1484
|
+
location: { start: c, end: g },
|
|
1485
|
+
leftComponent: h.trim(),
|
|
1486
|
+
rightComponent: d.trim(),
|
|
1487
|
+
optimizable: L,
|
|
1488
|
+
accessibilityNeeds: C
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
l.forEachChild(s, i);
|
|
1494
|
+
};
|
|
1495
|
+
const n = l.createSourceFile(
|
|
1496
|
+
e,
|
|
1497
|
+
a,
|
|
1498
|
+
l.ScriptTarget.Latest,
|
|
1499
|
+
!0,
|
|
1500
|
+
e.endsWith(".tsx") ? l.ScriptKind.TSX : l.ScriptKind.TS
|
|
1501
|
+
);
|
|
1502
|
+
i(n);
|
|
1503
|
+
} catch (i) {
|
|
1504
|
+
console.warn(
|
|
1505
|
+
`Failed to parse ${e} for concatenation analysis:`,
|
|
1506
|
+
i
|
|
1507
|
+
);
|
|
1508
|
+
}
|
|
1509
|
+
return t;
|
|
1510
|
+
}
|
|
1511
|
+
function k(a, e) {
|
|
1512
|
+
const t = a.getStart(), i = a.getEnd();
|
|
1513
|
+
return e.substring(t, i);
|
|
1514
|
+
}
|
|
1515
|
+
function R(a, e) {
|
|
1516
|
+
const t = a.filter((c) => c.optimizable), i = a.filter((c) => !c.optimizable), n = /* @__PURE__ */ new Set();
|
|
1517
|
+
a.forEach((c) => {
|
|
1518
|
+
n.add(`concatenation-${c.accessibilityNeeds}`);
|
|
1519
|
+
});
|
|
1520
|
+
const s = 87.76, r = n.size * 5, o = Math.max(0, s - r), h = {
|
|
1521
|
+
minimal: a.filter((c) => c.accessibilityNeeds === "minimal").length,
|
|
1522
|
+
aria: a.filter((c) => c.accessibilityNeeds === "aria").length,
|
|
1523
|
+
full: a.filter((c) => c.accessibilityNeeds === "full").length
|
|
1524
|
+
}, d = _(a);
|
|
1525
|
+
return {
|
|
1526
|
+
totalPatterns: a.length,
|
|
1527
|
+
optimizedPatterns: t.length,
|
|
1528
|
+
runtimePatterns: i.length,
|
|
1529
|
+
bundleImpact: {
|
|
1530
|
+
estimatedSavingsKB: o,
|
|
1531
|
+
runtimeReduction: `${Math.round(o / s * 100)}%`,
|
|
1532
|
+
selectedRuntimes: n
|
|
1533
|
+
},
|
|
1534
|
+
accessibilityBreakdown: h,
|
|
1535
|
+
recommendations: d
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
function _(a) {
|
|
1539
|
+
const e = [];
|
|
1540
|
+
return a.forEach((t) => {
|
|
1541
|
+
t.optimizable || M(
|
|
1542
|
+
t.leftComponent,
|
|
1543
|
+
t.rightComponent
|
|
1544
|
+
) && e.push({
|
|
1545
|
+
type: "static",
|
|
1546
|
+
pattern: t,
|
|
1547
|
+
suggestion: "Consider extracting variable interpolation to enable static concatenation",
|
|
1548
|
+
impact: "medium"
|
|
1549
|
+
}), t.accessibilityNeeds === "full" && F(t) && e.push({
|
|
1550
|
+
type: "accessibility",
|
|
1551
|
+
pattern: t,
|
|
1552
|
+
suggestion: "This concatenation could use minimal ARIA - consider simplifying accessibility requirements",
|
|
1553
|
+
impact: "low"
|
|
1554
|
+
}), t.type === "dynamic" && B(t) && e.push({
|
|
1555
|
+
type: "performance",
|
|
1556
|
+
pattern: t,
|
|
1557
|
+
suggestion: "High-frequency dynamic concatenation - consider memoization or caching",
|
|
1558
|
+
impact: "high"
|
|
1559
|
+
});
|
|
1560
|
+
}), e;
|
|
1561
|
+
}
|
|
1562
|
+
function z(a, e, t) {
|
|
1563
|
+
if (!t || a.totalPatterns === 0) return;
|
|
1564
|
+
const i = e.split("/").pop() || e;
|
|
1565
|
+
console.log(`
|
|
1566
|
+
🔗 TachUI Concatenation Analysis - ${i}`), console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"), console.log("📊 Pattern Summary:"), console.log(` Total patterns: ${a.totalPatterns}`), console.log(` ✅ Optimized: ${a.optimizedPatterns} (static)`), console.log(` 🔄 Runtime: ${a.runtimePatterns} (dynamic)`), console.log(`
|
|
1567
|
+
📦 Bundle Impact:`), console.log(
|
|
1568
|
+
` Estimated savings: ${a.bundleImpact.estimatedSavingsKB.toFixed(1)}KB`
|
|
1569
|
+
), console.log(` Runtime reduction: ${a.bundleImpact.runtimeReduction}`), console.log(
|
|
1570
|
+
` Selected runtimes: ${Array.from(a.bundleImpact.selectedRuntimes).join(", ")}`
|
|
1571
|
+
), console.log(`
|
|
1572
|
+
♿ Accessibility Breakdown:`), console.log(` Minimal: ${a.accessibilityBreakdown.minimal}`), console.log(` ARIA: ${a.accessibilityBreakdown.aria}`), console.log(` Full: ${a.accessibilityBreakdown.full}`), a.recommendations.length > 0 && (console.log(`
|
|
1573
|
+
💡 Optimization Recommendations:`), a.recommendations.forEach((n) => {
|
|
1574
|
+
const s = n.impact === "high" ? "🔴" : n.impact === "medium" ? "🟡" : "🔵";
|
|
1575
|
+
console.log(` ${s} ${n.suggestion}`);
|
|
1576
|
+
})), console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1577
|
+
`);
|
|
1578
|
+
}
|
|
1579
|
+
function M(a, e) {
|
|
1580
|
+
const t = /Text\s*\(\s*["'][^"']*["']\s*\)/;
|
|
1581
|
+
return t.test(a) || t.test(e);
|
|
1582
|
+
}
|
|
1583
|
+
function F(a) {
|
|
1584
|
+
return !a.leftComponent.includes("Button") && !a.rightComponent.includes("Button") && !a.leftComponent.includes("Link") && !a.rightComponent.includes("Link");
|
|
1585
|
+
}
|
|
1586
|
+
function B(a) {
|
|
1587
|
+
return a.leftComponent.includes("entry[") || a.rightComponent.includes("entry[") || a.leftComponent.includes(".map") || a.rightComponent.includes(".map");
|
|
1588
|
+
}
|
|
1589
|
+
function O(a, e) {
|
|
1590
|
+
const t = /\$\{[^}]+\}|[a-zA-Z_$][a-zA-Z0-9_$]*\s*\(/;
|
|
1591
|
+
return !t.test(a) && !t.test(e);
|
|
1592
|
+
}
|
|
1593
|
+
function H(a, e, t) {
|
|
1594
|
+
const i = /aria[A-Z][a-zA-Z]*|role\s*:/i.test(t), n = /Button|Link|onTapGesture|onClick/i.test(
|
|
1595
|
+
a + e
|
|
1596
|
+
), s = /VStack|HStack|ZStack|Form/i.test(t);
|
|
1597
|
+
return i || s ? "full" : n ? "aria" : "minimal";
|
|
1598
|
+
}
|
|
1599
|
+
function U(a, e) {
|
|
1600
|
+
let t = a;
|
|
1601
|
+
for (const i of e.reverse())
|
|
1602
|
+
if (i.optimizable) {
|
|
1603
|
+
const n = j(i);
|
|
1604
|
+
t = t.slice(0, i.location.start) + n + t.slice(i.location.end);
|
|
1605
|
+
}
|
|
1606
|
+
return t;
|
|
1607
|
+
}
|
|
1608
|
+
function j(a) {
|
|
1609
|
+
const { leftComponent: e, rightComponent: t, accessibilityNeeds: i } = a;
|
|
1610
|
+
return `(() => {
|
|
1611
|
+
${D(i)}
|
|
1612
|
+
const leftEl = ${e}.build();
|
|
1613
|
+
const rightEl = ${t}.build();
|
|
1614
|
+
return createOptimizedConcatenation(leftEl, rightEl, '${i}');
|
|
1615
|
+
})()`;
|
|
1616
|
+
}
|
|
1617
|
+
function D(a) {
|
|
1618
|
+
switch (a) {
|
|
1619
|
+
case "minimal":
|
|
1620
|
+
return "import { createOptimizedConcatenation } from '@tachui/core/runtime/concatenation-minimal';";
|
|
1621
|
+
case "aria":
|
|
1622
|
+
return "import { createOptimizedConcatenation } from '@tachui/core/runtime/concatenation-aria';";
|
|
1623
|
+
case "full":
|
|
1624
|
+
return "import { createOptimizedConcatenation } from '@tachui/core/runtime/concatenation-full';";
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
function Z(a, e, t) {
|
|
1628
|
+
return e.some((s) => a.endsWith(s)) ? !t.some((s) => s.includes("**") ? new RegExp(
|
|
1629
|
+
s.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*")
|
|
1630
|
+
).test(a) : a.includes(s)) : !1;
|
|
1631
|
+
}
|
|
1632
|
+
function G(a) {
|
|
1633
|
+
return [
|
|
1634
|
+
/\b(VStack|HStack|ZStack|List|Form)\s*\{/,
|
|
1635
|
+
/\b(Text|Button|Image|TextField|Toggle)\s*\(/,
|
|
1636
|
+
/\.(padding|background|foregroundColor|font|frame)\s*\(/,
|
|
1637
|
+
/\.onTapGesture\s*\(/
|
|
1638
|
+
].some((t) => t.test(a));
|
|
1639
|
+
}
|
|
1640
|
+
function q() {
|
|
1641
|
+
return `
|
|
1642
|
+
// TachUI Runtime Module
|
|
1643
|
+
// This provides runtime utilities for transformed components
|
|
1644
|
+
|
|
1645
|
+
import { createSignal, createEffect, createComputed } from '@tachui/core/reactive'
|
|
1646
|
+
|
|
1647
|
+
export { createSignal, createEffect, createComputed }
|
|
1648
|
+
|
|
1649
|
+
// Runtime helpers for component lifecycle
|
|
1650
|
+
export function mountComponent(element, render) {
|
|
1651
|
+
const dispose = render()
|
|
1652
|
+
element._tachui_dispose = dispose
|
|
1653
|
+
return dispose
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
export function unmountComponent(element) {
|
|
1657
|
+
if (element._tachui_dispose) {
|
|
1658
|
+
element._tachui_dispose()
|
|
1659
|
+
delete element._tachui_dispose
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
// Hot reload support
|
|
1664
|
+
if (import.meta.hot) {
|
|
1665
|
+
import.meta.hot.accept()
|
|
1666
|
+
|
|
1667
|
+
// Re-mount components on hot reload
|
|
1668
|
+
import.meta.hot.dispose(() => {
|
|
1669
|
+
document.querySelectorAll('[data-tachui-component]').forEach(unmountComponent)
|
|
1670
|
+
})
|
|
1671
|
+
}
|
|
1672
|
+
`;
|
|
1673
|
+
}
|
|
1674
|
+
export {
|
|
1675
|
+
X as a,
|
|
1676
|
+
P as b,
|
|
1677
|
+
J as c,
|
|
1678
|
+
x as g,
|
|
1679
|
+
K as p
|
|
1680
|
+
};
|