@pithyjs/vite-plugin 0.1.0-beta.0

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 (167) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +237 -0
  3. package/dist/aotCodegen/generateBindings.d.ts +184 -0
  4. package/dist/aotCodegen/generateBindings.d.ts.map +1 -0
  5. package/dist/aotCodegen/generateBindings.js +326 -0
  6. package/dist/aotCodegen/generateBindings.js.map +1 -0
  7. package/dist/aotCodegen/generateDomFactory.d.ts +59 -0
  8. package/dist/aotCodegen/generateDomFactory.d.ts.map +1 -0
  9. package/dist/aotCodegen/generateDomFactory.js +302 -0
  10. package/dist/aotCodegen/generateDomFactory.js.map +1 -0
  11. package/dist/aotCodegen/index.d.ts +18 -0
  12. package/dist/aotCodegen/index.d.ts.map +1 -0
  13. package/dist/aotCodegen/index.js +17 -0
  14. package/dist/aotCodegen/index.js.map +1 -0
  15. package/dist/aotCodegen/serializeNode.d.ts +74 -0
  16. package/dist/aotCodegen/serializeNode.d.ts.map +1 -0
  17. package/dist/aotCodegen/serializeNode.js +169 -0
  18. package/dist/aotCodegen/serializeNode.js.map +1 -0
  19. package/dist/aotCodegen/structuralCodegen.d.ts +38 -0
  20. package/dist/aotCodegen/structuralCodegen.d.ts.map +1 -0
  21. package/dist/aotCodegen/structuralCodegen.js +56 -0
  22. package/dist/aotCodegen/structuralCodegen.js.map +1 -0
  23. package/dist/aotCodegen/utils.d.ts +38 -0
  24. package/dist/aotCodegen/utils.d.ts.map +1 -0
  25. package/dist/aotCodegen/utils.js +48 -0
  26. package/dist/aotCodegen/utils.js.map +1 -0
  27. package/dist/babelPlugin/babelPlugin.d.ts +44 -0
  28. package/dist/babelPlugin/babelPlugin.d.ts.map +1 -0
  29. package/dist/babelPlugin/babelPlugin.js +392 -0
  30. package/dist/babelPlugin/babelPlugin.js.map +1 -0
  31. package/dist/babelPlugin/extractOriginalTagNames.d.ts +20 -0
  32. package/dist/babelPlugin/extractOriginalTagNames.d.ts.map +1 -0
  33. package/dist/babelPlugin/extractOriginalTagNames.js +44 -0
  34. package/dist/babelPlugin/extractOriginalTagNames.js.map +1 -0
  35. package/dist/babelPlugin/extractUsedIdentifiers.d.ts +26 -0
  36. package/dist/babelPlugin/extractUsedIdentifiers.d.ts.map +1 -0
  37. package/dist/babelPlugin/extractUsedIdentifiers.js +206 -0
  38. package/dist/babelPlugin/extractUsedIdentifiers.js.map +1 -0
  39. package/dist/buildPlugin/plugin.d.ts +79 -0
  40. package/dist/buildPlugin/plugin.d.ts.map +1 -0
  41. package/dist/buildPlugin/plugin.js +142 -0
  42. package/dist/buildPlugin/plugin.js.map +1 -0
  43. package/dist/designSystemPlugin/collector.d.ts +63 -0
  44. package/dist/designSystemPlugin/collector.d.ts.map +1 -0
  45. package/dist/designSystemPlugin/collector.js +175 -0
  46. package/dist/designSystemPlugin/collector.js.map +1 -0
  47. package/dist/designSystemPlugin/cssTokens.d.ts +34 -0
  48. package/dist/designSystemPlugin/cssTokens.d.ts.map +1 -0
  49. package/dist/designSystemPlugin/cssTokens.js +56 -0
  50. package/dist/designSystemPlugin/cssTokens.js.map +1 -0
  51. package/dist/designSystemPlugin/enumerate.d.ts +24 -0
  52. package/dist/designSystemPlugin/enumerate.d.ts.map +1 -0
  53. package/dist/designSystemPlugin/enumerate.js +430 -0
  54. package/dist/designSystemPlugin/enumerate.js.map +1 -0
  55. package/dist/designSystemPlugin/extractor.d.ts +95 -0
  56. package/dist/designSystemPlugin/extractor.d.ts.map +1 -0
  57. package/dist/designSystemPlugin/extractor.js +150 -0
  58. package/dist/designSystemPlugin/extractor.js.map +1 -0
  59. package/dist/designSystemPlugin/generator.d.ts +33 -0
  60. package/dist/designSystemPlugin/generator.d.ts.map +1 -0
  61. package/dist/designSystemPlugin/generator.js +256 -0
  62. package/dist/designSystemPlugin/generator.js.map +1 -0
  63. package/dist/designSystemPlugin/index.d.ts +18 -0
  64. package/dist/designSystemPlugin/index.d.ts.map +1 -0
  65. package/dist/designSystemPlugin/index.js +19 -0
  66. package/dist/designSystemPlugin/index.js.map +1 -0
  67. package/dist/designSystemPlugin/patterns/a11y.d.ts +19 -0
  68. package/dist/designSystemPlugin/patterns/a11y.d.ts.map +1 -0
  69. package/dist/designSystemPlugin/patterns/a11y.js +230 -0
  70. package/dist/designSystemPlugin/patterns/a11y.js.map +1 -0
  71. package/dist/designSystemPlugin/patterns/borders.d.ts +18 -0
  72. package/dist/designSystemPlugin/patterns/borders.d.ts.map +1 -0
  73. package/dist/designSystemPlugin/patterns/borders.js +474 -0
  74. package/dist/designSystemPlugin/patterns/borders.js.map +1 -0
  75. package/dist/designSystemPlugin/patterns/colors.d.ts +18 -0
  76. package/dist/designSystemPlugin/patterns/colors.d.ts.map +1 -0
  77. package/dist/designSystemPlugin/patterns/colors.js +134 -0
  78. package/dist/designSystemPlugin/patterns/colors.js.map +1 -0
  79. package/dist/designSystemPlugin/patterns/iconography.d.ts +18 -0
  80. package/dist/designSystemPlugin/patterns/iconography.d.ts.map +1 -0
  81. package/dist/designSystemPlugin/patterns/iconography.js +61 -0
  82. package/dist/designSystemPlugin/patterns/iconography.js.map +1 -0
  83. package/dist/designSystemPlugin/patterns/index.d.ts +22 -0
  84. package/dist/designSystemPlugin/patterns/index.d.ts.map +1 -0
  85. package/dist/designSystemPlugin/patterns/index.js +44 -0
  86. package/dist/designSystemPlugin/patterns/index.js.map +1 -0
  87. package/dist/designSystemPlugin/patterns/layout.d.ts +34 -0
  88. package/dist/designSystemPlugin/patterns/layout.d.ts.map +1 -0
  89. package/dist/designSystemPlugin/patterns/layout.js +917 -0
  90. package/dist/designSystemPlugin/patterns/layout.js.map +1 -0
  91. package/dist/designSystemPlugin/patterns/motion.d.ts +19 -0
  92. package/dist/designSystemPlugin/patterns/motion.d.ts.map +1 -0
  93. package/dist/designSystemPlugin/patterns/motion.js +162 -0
  94. package/dist/designSystemPlugin/patterns/motion.js.map +1 -0
  95. package/dist/designSystemPlugin/patterns/radius.d.ts +18 -0
  96. package/dist/designSystemPlugin/patterns/radius.d.ts.map +1 -0
  97. package/dist/designSystemPlugin/patterns/radius.js +107 -0
  98. package/dist/designSystemPlugin/patterns/radius.js.map +1 -0
  99. package/dist/designSystemPlugin/patterns/shadows.d.ts +19 -0
  100. package/dist/designSystemPlugin/patterns/shadows.d.ts.map +1 -0
  101. package/dist/designSystemPlugin/patterns/shadows.js +161 -0
  102. package/dist/designSystemPlugin/patterns/shadows.js.map +1 -0
  103. package/dist/designSystemPlugin/patterns/smartContainer.d.ts +18 -0
  104. package/dist/designSystemPlugin/patterns/smartContainer.d.ts.map +1 -0
  105. package/dist/designSystemPlugin/patterns/smartContainer.js +96 -0
  106. package/dist/designSystemPlugin/patterns/smartContainer.js.map +1 -0
  107. package/dist/designSystemPlugin/patterns/spacing.d.ts +18 -0
  108. package/dist/designSystemPlugin/patterns/spacing.d.ts.map +1 -0
  109. package/dist/designSystemPlugin/patterns/spacing.js +333 -0
  110. package/dist/designSystemPlugin/patterns/spacing.js.map +1 -0
  111. package/dist/designSystemPlugin/patterns/typography.d.ts +18 -0
  112. package/dist/designSystemPlugin/patterns/typography.d.ts.map +1 -0
  113. package/dist/designSystemPlugin/patterns/typography.js +416 -0
  114. package/dist/designSystemPlugin/patterns/typography.js.map +1 -0
  115. package/dist/designSystemPlugin/plugin.d.ts +39 -0
  116. package/dist/designSystemPlugin/plugin.d.ts.map +1 -0
  117. package/dist/designSystemPlugin/plugin.js +351 -0
  118. package/dist/designSystemPlugin/plugin.js.map +1 -0
  119. package/dist/designSystemPlugin/types.d.ts +156 -0
  120. package/dist/designSystemPlugin/types.d.ts.map +1 -0
  121. package/dist/designSystemPlugin/types.js +49 -0
  122. package/dist/designSystemPlugin/types.js.map +1 -0
  123. package/dist/htmlTransform/htmlTransform.d.ts +47 -0
  124. package/dist/htmlTransform/htmlTransform.d.ts.map +1 -0
  125. package/dist/htmlTransform/htmlTransform.js +86 -0
  126. package/dist/htmlTransform/htmlTransform.js.map +1 -0
  127. package/dist/iconsPlugin/index.d.ts +18 -0
  128. package/dist/iconsPlugin/index.d.ts.map +1 -0
  129. package/dist/iconsPlugin/index.js +17 -0
  130. package/dist/iconsPlugin/index.js.map +1 -0
  131. package/dist/iconsPlugin/optimize.d.ts +54 -0
  132. package/dist/iconsPlugin/optimize.d.ts.map +1 -0
  133. package/dist/iconsPlugin/optimize.js +253 -0
  134. package/dist/iconsPlugin/optimize.js.map +1 -0
  135. package/dist/iconsPlugin/plugin.d.ts +49 -0
  136. package/dist/iconsPlugin/plugin.d.ts.map +1 -0
  137. package/dist/iconsPlugin/plugin.js +242 -0
  138. package/dist/iconsPlugin/plugin.js.map +1 -0
  139. package/dist/iconsPlugin/types.d.ts +49 -0
  140. package/dist/iconsPlugin/types.d.ts.map +1 -0
  141. package/dist/iconsPlugin/types.js +30 -0
  142. package/dist/iconsPlugin/types.js.map +1 -0
  143. package/dist/index.d.ts +31 -0
  144. package/dist/index.d.ts.map +1 -0
  145. package/dist/index.js +37 -0
  146. package/dist/index.js.map +1 -0
  147. package/dist/pithyPlugin/plugin.d.ts +38 -0
  148. package/dist/pithyPlugin/plugin.d.ts.map +1 -0
  149. package/dist/pithyPlugin/plugin.js +119 -0
  150. package/dist/pithyPlugin/plugin.js.map +1 -0
  151. package/dist/routerPlugin/manifest.d.ts +33 -0
  152. package/dist/routerPlugin/manifest.d.ts.map +1 -0
  153. package/dist/routerPlugin/manifest.js +223 -0
  154. package/dist/routerPlugin/manifest.js.map +1 -0
  155. package/dist/routerPlugin/plugin.d.ts +51 -0
  156. package/dist/routerPlugin/plugin.d.ts.map +1 -0
  157. package/dist/routerPlugin/plugin.js +164 -0
  158. package/dist/routerPlugin/plugin.js.map +1 -0
  159. package/dist/routerPlugin/scanner.d.ts +69 -0
  160. package/dist/routerPlugin/scanner.d.ts.map +1 -0
  161. package/dist/routerPlugin/scanner.js +290 -0
  162. package/dist/routerPlugin/scanner.js.map +1 -0
  163. package/dist/ssrPlugin/plugin.d.ts +76 -0
  164. package/dist/ssrPlugin/plugin.d.ts.map +1 -0
  165. package/dist/ssrPlugin/plugin.js +439 -0
  166. package/dist/ssrPlugin/plugin.js.map +1 -0
  167. package/package.json +57 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PithyJS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,237 @@
1
+ # @pithyjs/vite-plugin
2
+
3
+ Vite plugins for the PithyJS framework. Provides `.pithy` file compilation, `html\`…\`` template transformation, file-based routing, build optimization, design system CSS tree-shaking, SSR dev server, and icon sprite generation.
4
+
5
+ ## Installation
6
+
7
+ <!-- @codex:auto install="@pithyjs/vite-plugin" -->
8
+ ```bash
9
+ npm install @pithyjs/vite-plugin
10
+ ```
11
+
12
+ ```bash
13
+ pnpm add @pithyjs/vite-plugin
14
+ ```
15
+
16
+ ```bash
17
+ yarn add @pithyjs/vite-plugin
18
+ ```
19
+ <!-- @codex:end -->
20
+
21
+ ## Plugins
22
+
23
+ ### pithyPlugin
24
+
25
+ Transforms `.pithy` single-file components into compiled TypeScript modules with HMR support.
26
+
27
+ ### htmlTransformPlugin
28
+
29
+ Babel-based transform for `html\`…\`` tagged template literals. Supports AOT compilation to eliminate runtime HTML parsing.
30
+
31
+ ### pithyRouter
32
+
33
+ File-based routing plugin. Scans a routes directory and generates a typed route manifest as a virtual module.
34
+
35
+ ### pithyBuild
36
+
37
+ Build optimization plugin providing chunk naming strategies, vendor splitting, and route-based code splitting.
38
+
39
+ ### designSystemPlugin
40
+
41
+ CSS tree-shaking plugin that extracts used utility classes and generates only the CSS needed.
42
+
43
+ ### pithySSR
44
+
45
+ SSR dev server plugin with auto-mode (pithy.config.ts) and legacy mode (entry-server.ts).
46
+
47
+ ### pithyIcons
48
+
49
+ SVG icon sprite generation plugin with optimization, HMR, and virtual module output.
50
+
51
+ ## API Reference
52
+
53
+ ### .pithy Plugin
54
+
55
+ <!-- @codex:auto api="pithy.vite.plugin" format="table" -->
56
+ | API | Signature | Stability | Description |
57
+ | --- | --- | --- | --- |
58
+ | pithyPlugin | `() => Plugin` | stable | - |
59
+ <!-- @codex:end -->
60
+
61
+ ### HTML Transform Plugin
62
+
63
+ <!-- @codex:auto api="pithy.vite.html-transform-plugin" format="table" -->
64
+ | API | Signature | Stability | Description |
65
+ | --- | --- | --- | --- |
66
+ | HtmlTransformPluginOptions | `interface HtmlTransformPluginOptions` | stable | - |
67
+ | htmlTransformPlugin | `(options?: HtmlTransformPluginOptions) => PluginOption` | stable | - |
68
+ <!-- @codex:end -->
69
+
70
+ ### Build Plugin
71
+
72
+ <!-- @codex:auto api="pithy.vite.build-plugin" format="table" -->
73
+ | API | Signature | Stability | Description |
74
+ | --- | --- | --- | --- |
75
+ | pithyBuild | `(options?: PithyBuildOptions) => Plugin` | stable | - |
76
+ <!-- @codex:end -->
77
+
78
+ ### Router Plugin
79
+
80
+ <!-- @codex:auto api="pithy.vite-plugin-router" format="table" -->
81
+ | API | Signature | Stability | Description |
82
+ | --- | --- | --- | --- |
83
+ | pithyRouter | `(options?: PithyRouterPluginOptions) => Plugin` | experimental | - |
84
+ <!-- @codex:end -->
85
+
86
+ ### Design System Plugin
87
+
88
+ <!-- @codex:auto api="pithy.vite-plugin-design-system" format="table" -->
89
+ | API | Signature | Stability | Description |
90
+ | --- | --- | --- | --- |
91
+ | designSystemPlugin | `(options?: DesignSystemPluginOptions) => Plugin` | experimental | - |
92
+ <!-- @codex:end -->
93
+
94
+ ### Icons Plugin
95
+
96
+ <!-- @codex:auto api="pithy.vite-plugin-icons" format="table" -->
97
+ | API | Signature | Stability | Description |
98
+ | --- | --- | --- | --- |
99
+ | pithyIcons | `(options?: PithyIconsOptions) => Plugin` | stable | - |
100
+ <!-- @codex:end -->
101
+
102
+ ### SSR Plugin
103
+
104
+ <!-- @codex:auto api="pithy.vite-plugin-ssr" format="table" -->
105
+ | API | Signature | Stability | Description |
106
+ | --- | --- | --- | --- |
107
+ | pithySSR | `(options?: PithySSRPluginOptions) => Plugin` | experimental | - |
108
+ <!-- @codex:end -->
109
+
110
+ ## Examples
111
+
112
+ <!-- @codex:auto examples="pithy.vite.plugin" -->
113
+ ```ts
114
+ import { pithyPlugin } from '@pithyjs/vite-plugin';
115
+
116
+ export default defineConfig({
117
+ plugins: [pithyPlugin()],
118
+ });
119
+ ```
120
+ <!-- @codex:end -->
121
+
122
+ <!-- @codex:auto examples="pithy.vite.html-transform-plugin" -->
123
+ ```ts
124
+ import { htmlTransformPlugin } from '@pithyjs/vite-plugin';
125
+
126
+ export default defineConfig({
127
+ plugins: [htmlTransformPlugin({ aot: true })],
128
+ });
129
+ ```
130
+ <!-- @codex:end -->
131
+
132
+ <!-- @codex:auto examples="pithy.vite.build-plugin" -->
133
+ ```ts
134
+ // vite.config.ts
135
+ import { pithyBuild } from '@pithyjs/vite-plugin';
136
+
137
+ export default defineConfig({
138
+ plugins: [
139
+ pithyBuild(),
140
+ ],
141
+ });
142
+ ```
143
+ <!-- @codex:end -->
144
+
145
+ <!-- @codex:auto examples="pithy.vite-plugin-router" -->
146
+ ```ts
147
+ import { pithyRouter } from '@pithyjs/vite-plugin';
148
+
149
+ export default defineConfig({
150
+ plugins: [pithyRouter({ routesDir: 'src/routes' })],
151
+ });
152
+ ```
153
+ <!-- @codex:end -->
154
+
155
+ <!-- @codex:auto examples="pithy.vite-plugin-design-system" -->
156
+ ```typescript
157
+ // vite.config.ts
158
+ import { designSystemPlugin } from '@pithyjs/vite-plugin';
159
+ export default defineConfig({
160
+ plugins: [
161
+ designSystemPlugin({
162
+ safelist: ['u-bg-success', /^u-text-/],
163
+ debug: true,
164
+ })
165
+ ]
166
+ });
167
+ ```
168
+ <!-- @codex:end -->
169
+
170
+ <!-- @codex:auto examples="pithy.vite-plugin-icons" -->
171
+ ```ts
172
+ // vite.config.ts
173
+ import { pithyIcons } from '@pithyjs/vite-plugin';
174
+
175
+ export default defineConfig({
176
+ plugins: [
177
+ pithyIcons({ dir: 'src/icons' })
178
+ ]
179
+ });
180
+ ```
181
+
182
+ ```ts
183
+ // main.ts — register icons at app startup
184
+ import { SPRITE_URL, ICON_NAMES, ICON_META } from "virtual:pithy-icons";
185
+ import { registerIconSprite } from "@pithyjs/ui-kit/icons";
186
+ registerIconSprite(SPRITE_URL, ICON_NAMES, ICON_META);
187
+ ```
188
+ <!-- @codex:end -->
189
+
190
+ ## Testing
191
+
192
+ <!-- @codex:auto testing="pithy.vite.plugin" -->
193
+ | Feature | Unit | Integration | E2E | Status |
194
+ | --- | --- | --- | --- | --- |
195
+ | pithyPlugin | - | - | - | Missing unit, integration |
196
+ <!-- @codex:end -->
197
+
198
+ <!-- @codex:auto testing="pithy.vite.html-transform-plugin" -->
199
+ | Feature | Unit | Integration | E2E | Status |
200
+ | --- | --- | --- | --- | --- |
201
+ | HtmlTransformPluginOptions | - | - | - | Missing unit, integration |
202
+ | htmlTransformPlugin | ✓ | - | - | Missing integration |
203
+ <!-- @codex:end -->
204
+
205
+ <!-- @codex:auto testing="pithy.vite.build-plugin" -->
206
+ | Feature | Unit | Integration | E2E | Status |
207
+ | --- | --- | --- | --- | --- |
208
+ | pithyBuild | - | - | - | Missing integration |
209
+ <!-- @codex:end -->
210
+
211
+ <!-- @codex:auto testing="pithy.vite-plugin-router" -->
212
+ | Feature | Unit | Integration | E2E | Status |
213
+ | --- | --- | --- | --- | --- |
214
+ | pithyRouter | ✓ | - | - | Missing integration |
215
+ <!-- @codex:end -->
216
+
217
+ <!-- @codex:auto testing="pithy.vite-plugin-design-system" -->
218
+ | Feature | Unit | Integration | E2E | Status |
219
+ | --- | --- | --- | --- | --- |
220
+ | designSystemPlugin | - | ✓ | - | Complete |
221
+ <!-- @codex:end -->
222
+
223
+ <!-- @codex:auto testing="pithy.vite-plugin-icons" -->
224
+ | Feature | Unit | Integration | E2E | Status |
225
+ | --- | --- | --- | --- | --- |
226
+ | pithyIcons | ✓ | - | - | Complete |
227
+ <!-- @codex:end -->
228
+
229
+ <!-- @codex:auto testing="pithy.vite-plugin-ssr" -->
230
+ | Feature | Unit | Integration | E2E | Status |
231
+ | --- | --- | --- | --- | --- |
232
+ | pithySSR | ✓ | - | - | Complete |
233
+ <!-- @codex:end -->
234
+
235
+ ## License
236
+
237
+ MIT
@@ -0,0 +1,184 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.aot.generate-bindings",
4
+ "title": "AOT Binding Descriptor Generator",
5
+ "category": "compiler",
6
+ "description": "Generates binding descriptors from template nodes for AOT compilation of reactive bindings.",
7
+ "since": "0.0.1",
8
+ "stability": "experimental",
9
+ "testing": {
10
+ "unit": { "required": true, "covered": true, "file": "aotCodegen.test.ts" },
11
+ "integration": { "required": false, "covered": false },
12
+ "e2e": { "required": false, "covered": false }
13
+ }
14
+ }
15
+ */
16
+ import type { PithyNode } from '../../../compiler/src/parse/types';
17
+ export type EventDescriptor = {
18
+ t: 'event';
19
+ pid: string;
20
+ event: string;
21
+ expr: string;
22
+ mods?: string[];
23
+ };
24
+ export type InterpolationDescriptor = {
25
+ t: 'interp';
26
+ pid: string;
27
+ parts: ({
28
+ s: string;
29
+ } | {
30
+ e: string;
31
+ })[];
32
+ };
33
+ export type ClassDescriptor = {
34
+ t: 'class';
35
+ pid: string;
36
+ name: string;
37
+ expr: string;
38
+ };
39
+ export type BoundDescriptor = {
40
+ t: 'bound';
41
+ pid: string;
42
+ attr: string;
43
+ expr: string;
44
+ };
45
+ export type StyleDescriptor = {
46
+ t: 'style';
47
+ pid: string;
48
+ prop: string;
49
+ expr: string;
50
+ };
51
+ export type RefDescriptor = {
52
+ t: 'ref';
53
+ pid: string;
54
+ name: string;
55
+ };
56
+ export type BindDescriptor = {
57
+ t: 'bind';
58
+ pid: string;
59
+ expr: string;
60
+ };
61
+ export type ComponentDescriptor = {
62
+ t: 'comp';
63
+ pid: string;
64
+ /** Original component tag name (for context lookup) */
65
+ tag: string;
66
+ /** Non-directive attributes as prop expressions */
67
+ props: Record<string, string>;
68
+ };
69
+ export type DeferDescriptor = {
70
+ t: 'defer';
71
+ pid: string;
72
+ /** Trigger type: 'visible' or 'when' */
73
+ trigger: string;
74
+ /** LazyHandle expression */
75
+ load: string;
76
+ /** Placeholder component expression */
77
+ placeholder?: string;
78
+ /** Condition expression (for @defer="when") */
79
+ when?: string;
80
+ /** Loading priority ('high' | 'low') */
81
+ priority?: string;
82
+ /** Timeout in ms */
83
+ timeout?: number;
84
+ };
85
+ export type ErrorBoundaryDescriptor = {
86
+ t: 'error';
87
+ pid: string;
88
+ /** Error signal expression */
89
+ expr: string;
90
+ };
91
+ export type ProjectionDescriptor = {
92
+ t: 'proj';
93
+ pid: string;
94
+ /** Slot name (empty string for default slot) */
95
+ name: string;
96
+ /** Fallback content sub-factory function name */
97
+ fallback?: string;
98
+ };
99
+ export type IfBranch = {
100
+ /** Condition expression (absent for @else) */
101
+ expr?: string;
102
+ /** Sub-factory function name */
103
+ factory: string;
104
+ };
105
+ export type IfDescriptor = {
106
+ t: 'if';
107
+ pid: string;
108
+ branches: IfBranch[];
109
+ };
110
+ export type ForDescriptor = {
111
+ t: 'for';
112
+ pid: string;
113
+ /** Loop item variable name */
114
+ item: string;
115
+ /** Loop index variable name */
116
+ index?: string;
117
+ /** Collection expression */
118
+ expr: string;
119
+ /** TrackBy expression */
120
+ trackBy?: string;
121
+ /** Body sub-factory function name */
122
+ factory: string;
123
+ };
124
+ export type SwitchCase = {
125
+ /** Case value expression (absent for @default) */
126
+ val?: string;
127
+ /** Case sub-factory function name */
128
+ factory: string;
129
+ };
130
+ export type SwitchDescriptor = {
131
+ t: 'switch';
132
+ pid: string;
133
+ /** Switch expression */
134
+ expr: string;
135
+ cases: SwitchCase[];
136
+ };
137
+ /** Union of all binding descriptor types (Phase 1 + Phase 2 + Phase 3). */
138
+ export type BindingDescriptor = EventDescriptor | InterpolationDescriptor | ClassDescriptor | StyleDescriptor | BoundDescriptor | RefDescriptor | BindDescriptor | IfDescriptor | ForDescriptor | SwitchDescriptor | ComponentDescriptor | DeferDescriptor | ErrorBoundaryDescriptor | ProjectionDescriptor;
139
+ /**
140
+ * Walk a PithyNode tree and extract non-structural binding descriptors.
141
+ *
142
+ * Extracts:
143
+ * - Event handlers (`@click="expr"`)
144
+ * - Text interpolations (`{{ expr }}`)
145
+ * - Class directives (`[class.active]="expr"`)
146
+ * - Style bindings (`[style.color]="expr"`)
147
+ * - Bound attributes (`[attr]="expr"`)
148
+ * - Ref directives (`@ref="name"`)
149
+ * - Two-way bind (`@bind="signal"`)
150
+ *
151
+ * Skips structural directive nodes (@if, @for, @switch, @case, @else, etc.)
152
+ * — those are handled by sub-factories via `generateDomFactory`.
153
+ * Also extracts Phase 3 descriptors: components, @defer, @error.
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const descriptors = generateBindings(pithyNodes);
158
+ * // Returns: [{ t: 'event', pid: 'r1', event: 'click', expr: 'increment()' }, ...]
159
+ * ```
160
+ */
161
+ /** @codexApi {"parent":"pithy.aot.generate-bindings","name":"generateBindings","stability":"experimental","signature":"(nodes: PithyNode[]) => BindingDescriptor[]"} */
162
+ export declare function generateBindings(nodes: PithyNode[]): BindingDescriptor[];
163
+ /**
164
+ * Serialize a binding descriptor array to a JS code string.
165
+ *
166
+ * Produces a compact JSON-like representation with single-quoted strings
167
+ * and single-letter keys, suitable for inlining in generated factory code.
168
+ * Returns `'[]'` for empty arrays.
169
+ *
170
+ * @param descriptors - Array of binding descriptors from `generateBindings`
171
+ * @returns JS code string (e.g. `[{t:'event',pid:'r1',event:'click',expr:'inc()'}]`)
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * const code = serializeBindings([
176
+ * { t: 'event', pid: 'r1', event: 'click', expr: 'inc()' },
177
+ * { t: 'ref', pid: 'r2', name: 'myRef' },
178
+ * ]);
179
+ * // code: "[{t:'event',pid:'r1',event:'click',expr:'inc()'},{t:'ref',pid:'r2',name:'myRef'}]"
180
+ * ```
181
+ */
182
+ /** @codexApi {"parent":"pithy.aot.generate-bindings","name":"serializeBindings","stability":"experimental","signature":"(descriptors: BindingDescriptor[]) => string"} */
183
+ export declare function serializeBindings(descriptors: BindingDescriptor[]): string;
184
+ //# sourceMappingURL=generateBindings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateBindings.d.ts","sourceRoot":"","sources":["../../src/aotCodegen/generateBindings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAcnE,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,EAAE,OAAO,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,EAAE,QAAQ,CAAC;IACZ,GAAG,EAAE,MAAM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